From b1af02ca710094452521965d02b1eb051c1911b9 Mon Sep 17 00:00:00 2001 From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Date: Tue, 2 Dec 2025 17:38:18 -0300 Subject: [PATCH 001/621] debugger: Improve step icons (#44017) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes https://github.com/zed-industries/zed/issues/38475 Screenshot 2025-12-02 at 5  24@2x Release Notes: - N/A --- assets/icons/debug_step_back.svg | 1 - assets/icons/debug_step_into.svg | 6 ++- assets/icons/debug_step_out.svg | 6 ++- assets/icons/debug_step_over.svg | 6 ++- crates/debugger_ui/src/debugger_panel.rs | 47 +++++++++++------------- crates/icons/src/icons.rs | 1 - 6 files changed, 37 insertions(+), 30 deletions(-) delete mode 100644 assets/icons/debug_step_back.svg diff --git a/assets/icons/debug_step_back.svg b/assets/icons/debug_step_back.svg deleted file mode 100644 index 61d45866f61cbabbd9a7ae9975809d342cb76ed5..0000000000000000000000000000000000000000 --- a/assets/icons/debug_step_back.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/assets/icons/debug_step_into.svg b/assets/icons/debug_step_into.svg index 9a517fc7ca0762b17446a75cd90f39a91e1b51cf..0a5882354380b659425fecca2b4c6000516e422f 100644 --- a/assets/icons/debug_step_into.svg +++ b/assets/icons/debug_step_into.svg @@ -1 +1,5 @@ - + + + + + diff --git a/assets/icons/debug_step_out.svg b/assets/icons/debug_step_out.svg index 147a44f930f34f6c3ddce94693a178a932129cb5..c128f56111f2b68d7229f9d2f61b6b2496f99bba 100644 --- a/assets/icons/debug_step_out.svg +++ b/assets/icons/debug_step_out.svg @@ -1 +1,5 @@ - + + + + + diff --git a/assets/icons/debug_step_over.svg b/assets/icons/debug_step_over.svg index 336abc11deb866a128e8418dab47af01b6e4d3f6..5d8ccd5b7a20b2f8a108ab4c2e03694db4f6f8a8 100644 --- a/assets/icons/debug_step_over.svg +++ b/assets/icons/debug_step_over.svg @@ -1 +1,5 @@ - + + + + + diff --git a/crates/debugger_ui/src/debugger_panel.rs b/crates/debugger_ui/src/debugger_panel.rs index 3890fa6326329d0d72aa6f81c6b94e7c2f364d34..ffdd4a22e3d092eb5d3d6626dcfe8b167ae03936 100644 --- a/crates/debugger_ui/src/debugger_panel.rs +++ b/crates/debugger_ui/src/debugger_panel.rs @@ -740,7 +740,7 @@ impl DebugPanel { } }) .child( - IconButton::new("debug-step-over", IconName::ArrowRight) + IconButton::new("step-over", IconName::DebugStepOver) .icon_size(IconSize::Small) .on_click(window.listener_for( running_state, @@ -762,32 +762,29 @@ impl DebugPanel { }), ) .child( - IconButton::new( - "debug-step-into", - IconName::ArrowDownRight, - ) - .icon_size(IconSize::Small) - .on_click(window.listener_for( - running_state, - |this, _, _window, cx| { - this.step_in(cx); - }, - )) - .disabled(thread_status != ThreadStatus::Stopped) - .tooltip({ - let focus_handle = focus_handle.clone(); - move |_window, cx| { - Tooltip::for_action_in( - "Step In", - &StepInto, - &focus_handle, - cx, - ) - } - }), + IconButton::new("step-into", IconName::DebugStepInto) + .icon_size(IconSize::Small) + .on_click(window.listener_for( + running_state, + |this, _, _window, cx| { + this.step_in(cx); + }, + )) + .disabled(thread_status != ThreadStatus::Stopped) + .tooltip({ + let focus_handle = focus_handle.clone(); + move |_window, cx| { + Tooltip::for_action_in( + "Step In", + &StepInto, + &focus_handle, + cx, + ) + } + }), ) .child( - IconButton::new("debug-step-out", IconName::ArrowUpRight) + IconButton::new("step-out", IconName::DebugStepOut) .icon_size(IconSize::Small) .on_click(window.listener_for( running_state, diff --git a/crates/icons/src/icons.rs b/crates/icons/src/icons.rs index da3b298751d9c1921d14722490e3cbc680292099..d28e2c1030c3c2378aa7997f4799c503cee97105 100644 --- a/crates/icons/src/icons.rs +++ b/crates/icons/src/icons.rs @@ -86,7 +86,6 @@ pub enum IconName { DebugIgnoreBreakpoints, DebugLogBreakpoint, DebugPause, - DebugStepBack, DebugStepInto, DebugStepOut, DebugStepOver, From d283338885d232c281907809c4b255eaad90a3af Mon Sep 17 00:00:00 2001 From: "Joseph T. Lyons" Date: Tue, 2 Dec 2025 15:39:29 -0500 Subject: [PATCH 002/621] Add "File History" option to Git Panel entry context menu (#44016) Sublime Merge: image Fork: image Zed: image Release Notes: - Added a "File History" option to Git Panel entry context menu --- crates/git_ui/src/git_panel.rs | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs index 8579cafa58a22ea6d182f23b753d3b1a365f37fa..092768c2cd97fa82079979301704ee66c969196e 100644 --- a/crates/git_ui/src/git_panel.rs +++ b/crates/git_ui/src/git_panel.rs @@ -6,7 +6,8 @@ use crate::project_diff::{self, Diff, ProjectDiff}; use crate::remote_output::{self, RemoteAction, SuccessMessage}; use crate::{branch_picker, picker_prompt, render_remote_button}; use crate::{ - git_panel_settings::GitPanelSettings, git_status_icon, repository_selector::RepositorySelector, + file_history_view::FileHistoryView, git_panel_settings::GitPanelSettings, git_status_icon, + repository_selector::RepositorySelector, }; use agent_settings::AgentSettings; use anyhow::Context as _; @@ -842,6 +843,26 @@ impl GitPanel { }); } + fn file_history(&mut self, _: &git::FileHistory, window: &mut Window, cx: &mut Context) { + maybe!({ + let entry = self.entries.get(self.selected_entry?)?.status_entry()?; + let active_repo = self.active_repository.as_ref()?; + let repo_path = entry.repo_path.clone(); + let git_store = self.project.read(cx).git_store(); + + FileHistoryView::open( + repo_path, + git_store.downgrade(), + active_repo.downgrade(), + self.workspace.clone(), + window, + cx, + ); + + Some(()) + }); + } + fn open_file( &mut self, _: &menu::SecondaryConfirm, @@ -3997,6 +4018,8 @@ impl GitPanel { .separator() .action("Open Diff", Confirm.boxed_clone()) .action("Open File", SecondaryConfirm.boxed_clone()) + .separator() + .action("File History", Box::new(git::FileHistory)) }); self.selected_entry = Some(ix); self.set_context_menu(context_menu, position, window, cx); @@ -4499,6 +4522,7 @@ impl Render for GitPanel { .on_action(cx.listener(Self::close_panel)) .on_action(cx.listener(Self::open_diff)) .on_action(cx.listener(Self::open_file)) + .on_action(cx.listener(Self::file_history)) .on_action(cx.listener(Self::focus_changes_list)) .on_action(cx.listener(Self::focus_editor)) .on_action(cx.listener(Self::expand_commit_editor)) From 4e043cd56b8ee15c5d40ad4a94a28ca7ee449f68 Mon Sep 17 00:00:00 2001 From: David Kleingeld Date: Tue, 2 Dec 2025 21:40:26 +0100 Subject: [PATCH 003/621] Add git team to git in REVIEWERS.conl (#41841) Release Notes: - N/A --- REVIEWERS.conl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/REVIEWERS.conl b/REVIEWERS.conl index 86658189d0ebc3861648c1dd410a3b0b8c199706..45155ba3468f29062b58aa9094defc7f86110885 100644 --- a/REVIEWERS.conl +++ b/REVIEWERS.conl @@ -53,6 +53,10 @@ extension git = @cole-miller = @danilo-leal + = @dvdsk + = @kubkon + = @Anthony-Eid + = @cameron1024 gpui = @Anthony-Eid From 23e5477a4cc5921d1a6b35ef3ebbd6bf413b35aa Mon Sep 17 00:00:00 2001 From: Pranav Joglekar Date: Wed, 3 Dec 2025 02:28:20 +0530 Subject: [PATCH 004/621] vim: Move to opening html tag from / in closing tag (#42513) Closes #41582 Release Notes: - Improves the '%' vim motion for html by moving the cursor to the opening tag when its positioned on the `/` ( slash ) of the closing tag --- crates/vim/src/motion.rs | 31 +++++++++++++++++--- crates/vim/test_data/test_matching_tags.json | 5 ++++ 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/crates/vim/src/motion.rs b/crates/vim/src/motion.rs index dc108b0957d993b2229e8c04fed5923e9de250d4..6ba28a1c236ada7c08eeabac9d9189991434a807 100644 --- a/crates/vim/src/motion.rs +++ b/crates/vim/src/motion.rs @@ -2388,10 +2388,16 @@ fn matching(map: &DisplaySnapshot, display_point: DisplayPoint) -> DisplayPoint .or_else(|| snapshot.innermost_enclosing_bracket_ranges(offset..offset, None)); if let Some((opening_range, closing_range)) = bracket_ranges { - if opening_range.contains(&offset) { - return closing_range.start.to_display_point(map); - } else if closing_range.contains(&offset) { - return opening_range.start.to_display_point(map); + let mut chars = map.buffer_snapshot().chars_at(offset); + match chars.next() { + Some('/') => {} + _ => { + if opening_range.contains(&offset) { + return closing_range.start.to_display_point(map); + } else if closing_range.contains(&offset) { + return opening_range.start.to_display_point(map); + } + } } } @@ -3443,6 +3449,23 @@ mod test { test = "test" /> "#}); + + // test nested closing tag + cx.set_shared_state(indoc! {r#" + + + "#}) + .await; + cx.simulate_shared_keystrokes("%").await; + cx.shared_state().await.assert_eq(indoc! {r#" + + <ˇ/body> + "#}); + cx.simulate_shared_keystrokes("%").await; + cx.shared_state().await.assert_eq(indoc! {r#" + <ˇbody> + + "#}); } #[gpui::test] diff --git a/crates/vim/test_data/test_matching_tags.json b/crates/vim/test_data/test_matching_tags.json index bb4f5fd450dee78319a23e8026b2cb1c4d224b19..b401033a941f201ddcf9c3a4128659ae27d787b4 100644 --- a/crates/vim/test_data/test_matching_tags.json +++ b/crates/vim/test_data/test_matching_tags.json @@ -13,3 +13,8 @@ {"Put":{"state":"\n \n"}} {"Key":"%"} {"Get":{"state":"\n ˇ\n","mode":"Normal"}} +{"Put":{"state":"\n \n \n"}} +{"Key":"%"} +{"Get":{"state":"\n \n <ˇ/body>\n","mode":"Normal"}} +{"Key":"%"} +{"Get":{"state":"\n <ˇbody>\n \n","mode":"Normal"}} From a2ddb0f1cb96f3711da4cf85d51282103820831c Mon Sep 17 00:00:00 2001 From: John Tur Date: Tue, 2 Dec 2025 16:15:18 -0500 Subject: [PATCH 005/621] Fix "busy" cursor appearing on startup (#44019) Closes https://github.com/zed-industries/zed/issues/43910 Release Notes: - N/A --- Cargo.lock | 1 + crates/crashes/Cargo.toml | 3 ++ crates/crashes/src/crashes.rs | 58 +++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 6e558cbf395866ce6b75ff5764ba98a5ec81607a..6f584fbc7fba2182b95343e24704662c53221b12 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4184,6 +4184,7 @@ dependencies = [ "serde_json", "smol", "system_specs", + "windows 0.61.3", "zstd 0.11.2+zstd.1.5.2", ] diff --git a/crates/crashes/Cargo.toml b/crates/crashes/Cargo.toml index 3f85039e9ea3bce8e702991461adec4a931d3e4a..bd1c1121848e34349b5cd58c0fa033d380fa791b 100644 --- a/crates/crashes/Cargo.toml +++ b/crates/crashes/Cargo.toml @@ -23,6 +23,9 @@ zstd.workspace = true [target.'cfg(target_os = "macos")'.dependencies] mach2.workspace = true +[target.'cfg(target_os = "windows")'.dependencies] +windows.workspace = true + [lints] workspace = true diff --git a/crates/crashes/src/crashes.rs b/crates/crashes/src/crashes.rs index baf0bcde3b0769c4fc6cf958c86e181cda615683..4c601c393004beca1d5e550e1eeae7f126751448 100644 --- a/crates/crashes/src/crashes.rs +++ b/crates/crashes/src/crashes.rs @@ -3,6 +3,8 @@ use log::info; use minidumper::{Client, LoopAction, MinidumpBinary}; use release_channel::{RELEASE_CHANNEL, ReleaseChannel}; use serde::{Deserialize, Serialize}; + +#[cfg(not(target_os = "windows"))] use smol::process::Command; #[cfg(target_os = "macos")] @@ -70,11 +72,16 @@ pub async fn init(crash_init: InitCrashHandler) { // used by the crash handler isn't destroyed correctly which causes it to stay on the file // system and block further attempts to initialize crash handlers with that socket path. let socket_name = paths::temp_dir().join(format!("zed-crash-handler-{zed_pid}")); + #[cfg(not(target_os = "windows"))] let _crash_handler = Command::new(exe) .arg("--crash-handler") .arg(&socket_name) .spawn() .expect("unable to spawn server process"); + + #[cfg(target_os = "windows")] + spawn_crash_handler_windows(&exe, &socket_name); + #[cfg(target_os = "linux")] let server_pid = _crash_handler.id(); info!("spawning crash handler process"); @@ -342,6 +349,57 @@ pub fn panic_hook(info: &PanicHookInfo) { } } +#[cfg(target_os = "windows")] +fn spawn_crash_handler_windows(exe: &Path, socket_name: &Path) { + use std::ffi::OsStr; + use std::iter::once; + use std::os::windows::ffi::OsStrExt; + use windows::Win32::System::Threading::{ + CreateProcessW, PROCESS_CREATION_FLAGS, PROCESS_INFORMATION, STARTF_FORCEOFFFEEDBACK, + STARTUPINFOW, + }; + use windows::core::PWSTR; + + let mut command_line: Vec = OsStr::new(&format!( + "\"{}\" --crash-handler \"{}\"", + exe.display(), + socket_name.display() + )) + .encode_wide() + .chain(once(0)) + .collect(); + + let mut startup_info = STARTUPINFOW::default(); + startup_info.cb = std::mem::size_of::() as u32; + + // By default, Windows enables a "busy" cursor when a GUI application is launched. + // This cursor is disabled once the application starts processing window messages. + // Since the crash handler process doesn't process messages, this "busy" cursor stays enabled for a long time. + // Disable the cursor feedback to prevent this from happening. + startup_info.dwFlags = STARTF_FORCEOFFFEEDBACK; + + let mut process_info = PROCESS_INFORMATION::default(); + + unsafe { + CreateProcessW( + None, + Some(PWSTR(command_line.as_mut_ptr())), + None, + None, + false, + PROCESS_CREATION_FLAGS(0), + None, + None, + &startup_info, + &mut process_info, + ) + .expect("unable to spawn server process"); + + windows::Win32::Foundation::CloseHandle(process_info.hProcess).ok(); + windows::Win32::Foundation::CloseHandle(process_info.hThread).ok(); + } +} + pub fn crash_server(socket: &Path) { let Ok(mut server) = minidumper::Server::with_name(socket) else { log::info!("Couldn't create socket, there may already be a running crash server"); From 96a917091a80c0430b6b7d816d747e3bbf14f533 Mon Sep 17 00:00:00 2001 From: Andrew Farkas <6060305+HactarCE@users.noreply.github.com> Date: Tue, 2 Dec 2025 16:33:41 -0500 Subject: [PATCH 006/621] Apply `show_completions_on_input: false` to word & snippet completions (#44021) Closes #43408 Previously, we checked the setting inside `is_completion_trigger()`, which only affects LSP completions. This was ok because user-defined snippets were tacked onto LSP completions. Then #42122 and #42398 made snippet completions their own thing, similar to word completions, surfacing #43408. This PR moves the settings check into `open_or_update_completions_menu()` so it applies to all completions. Release Notes: - Fixed setting `show_completions_on_input: false` so that it affects word and user-defined snippet completions as well as LSP completions --- crates/agent_ui/src/completion_provider.rs | 1 - crates/agent_ui/src/slash_command.rs | 1 - .../src/session/running/console.rs | 4 -- crates/editor/src/editor.rs | 40 +++++++++---------- crates/inspector_ui/src/div_inspector.rs | 1 - crates/keymap_editor/src/keymap_editor.rs | 1 - 6 files changed, 18 insertions(+), 30 deletions(-) diff --git a/crates/agent_ui/src/completion_provider.rs b/crates/agent_ui/src/completion_provider.rs index 2e3cf0d551fc649e61ae26e47fa53301def2aacc..a2b6e0510e25c12cfbfb98d3e72cb0d2c830887a 100644 --- a/crates/agent_ui/src/completion_provider.rs +++ b/crates/agent_ui/src/completion_provider.rs @@ -1114,7 +1114,6 @@ impl CompletionProvider for PromptCompletio position: language::Anchor, _text: &str, _trigger_in_words: bool, - _menu_is_open: bool, cx: &mut Context, ) -> bool { let buffer = buffer.read(cx); diff --git a/crates/agent_ui/src/slash_command.rs b/crates/agent_ui/src/slash_command.rs index 7d3ea0105a0aafb4cfccf4076cb95e28c99dec28..e328ef6725e5e789bd402667da91417ad69a372d 100644 --- a/crates/agent_ui/src/slash_command.rs +++ b/crates/agent_ui/src/slash_command.rs @@ -341,7 +341,6 @@ impl CompletionProvider for SlashCommandCompletionProvider { position: language::Anchor, _text: &str, _trigger_in_words: bool, - _menu_is_open: bool, cx: &mut Context, ) -> bool { let buffer = buffer.read(cx); diff --git a/crates/debugger_ui/src/session/running/console.rs b/crates/debugger_ui/src/session/running/console.rs index 717169ff5ad1d0f479075ca996c550a774a4307a..d20108b61205bacd3ea09af0ea34fabbec621c20 100644 --- a/crates/debugger_ui/src/session/running/console.rs +++ b/crates/debugger_ui/src/session/running/console.rs @@ -559,7 +559,6 @@ impl CompletionProvider for ConsoleQueryBarCompletionProvider { position: language::Anchor, text: &str, trigger_in_words: bool, - menu_is_open: bool, cx: &mut Context, ) -> bool { let mut chars = text.chars(); @@ -570,9 +569,6 @@ impl CompletionProvider for ConsoleQueryBarCompletionProvider { }; let snapshot = buffer.read(cx).snapshot(); - if !menu_is_open && !snapshot.settings_at(position, cx).show_completions_on_input { - return false; - } let classifier = snapshot .char_classifier_at(position) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 114dbac23e80814c64471d7123ef73a29ccfc115..babedf1e0829bb1105b2c9c3787d98aa662eedde 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -5509,6 +5509,22 @@ impl Editor { }; let buffer_snapshot = buffer.read(cx).snapshot(); + let menu_is_open = matches!( + self.context_menu.borrow().as_ref(), + Some(CodeContextMenu::Completions(_)) + ); + + let language = buffer_snapshot + .language_at(buffer_position.text_anchor) + .map(|language| language.name()); + + let language_settings = language_settings(language.clone(), buffer_snapshot.file(), cx); + let completion_settings = language_settings.completions.clone(); + + if !menu_is_open && trigger.is_some() && !language_settings.show_completions_on_input { + return; + } + let query: Option> = Self::completion_query(&multibuffer_snapshot, buffer_position) .map(|query| query.into()); @@ -5517,14 +5533,8 @@ impl Editor { // Hide the current completions menu when query is empty. Without this, cached // completions from before the trigger char may be reused (#32774). - if query.is_none() { - let menu_is_open = matches!( - self.context_menu.borrow().as_ref(), - Some(CodeContextMenu::Completions(_)) - ); - if menu_is_open { - self.hide_context_menu(window, cx); - } + if query.is_none() && menu_is_open { + self.hide_context_menu(window, cx); } let mut ignore_word_threshold = false; @@ -5613,14 +5623,6 @@ impl Editor { (buffer_position..buffer_position, None) }; - let language = buffer_snapshot - .language_at(buffer_position) - .map(|language| language.name()); - - let completion_settings = language_settings(language.clone(), buffer_snapshot.file(), cx) - .completions - .clone(); - let show_completion_documentation = buffer_snapshot .settings_at(buffer_position, cx) .show_completion_documentation; @@ -5651,7 +5653,6 @@ impl Editor { position.text_anchor, trigger, trigger_in_words, - completions_source.is_some(), cx, ) }) @@ -23486,7 +23487,6 @@ pub trait CompletionProvider { position: language::Anchor, text: &str, trigger_in_words: bool, - menu_is_open: bool, cx: &mut Context, ) -> bool; @@ -23865,7 +23865,6 @@ impl CompletionProvider for Entity { position: language::Anchor, text: &str, trigger_in_words: bool, - menu_is_open: bool, cx: &mut Context, ) -> bool { let mut chars = text.chars(); @@ -23880,9 +23879,6 @@ impl CompletionProvider for Entity { let buffer = buffer.read(cx); let snapshot = buffer.snapshot(); - if !menu_is_open && !snapshot.settings_at(position, cx).show_completions_on_input { - return false; - } let classifier = snapshot .char_classifier_at(position) .scope_context(Some(CharScopeContext::Completion)); diff --git a/crates/inspector_ui/src/div_inspector.rs b/crates/inspector_ui/src/div_inspector.rs index 35a5d2786f8d044dd9c41a3a4605538ea8f37c37..9b145e920e48605f19f566ca14a7caf63aff8f0a 100644 --- a/crates/inspector_ui/src/div_inspector.rs +++ b/crates/inspector_ui/src/div_inspector.rs @@ -686,7 +686,6 @@ impl CompletionProvider for RustStyleCompletionProvider { position: language::Anchor, _text: &str, _trigger_in_words: bool, - _menu_is_open: bool, cx: &mut Context, ) -> bool { completion_replace_range(&buffer.read(cx).snapshot(), &position).is_some() diff --git a/crates/keymap_editor/src/keymap_editor.rs b/crates/keymap_editor/src/keymap_editor.rs index ce78a1d60ac610bbf10383377fef667c0a4eaa36..113d5026eb89587714172ff4c76698bcadb5fd6a 100644 --- a/crates/keymap_editor/src/keymap_editor.rs +++ b/crates/keymap_editor/src/keymap_editor.rs @@ -3001,7 +3001,6 @@ impl CompletionProvider for KeyContextCompletionProvider { _position: language::Anchor, text: &str, _trigger_in_words: bool, - _menu_is_open: bool, _cx: &mut Context, ) -> bool { text.chars() From a2d57fc7b6933ecceeb1393f905457b1d33d2e35 Mon Sep 17 00:00:00 2001 From: Marshall Bowers Date: Tue, 2 Dec 2025 17:26:40 -0500 Subject: [PATCH 007/621] zed_extension_api: Fork new version of extension API (#44025) This PR forks a new version of the `zed_extension_api` in preparation for new changes. We're jumping from v0.6.0 to v0.8.0 for the WIT because we released v0.7.0 of the `zed_extension_api` without any WIT changes (it probably should have been v0.6.1, instead). Release Notes: - N/A --- Cargo.lock | 10 +- crates/extension_api/Cargo.toml | 5 +- crates/extension_api/src/extension_api.rs | 2 +- .../extension_api/wit/since_v0.8.0/common.wit | 12 + .../wit/since_v0.8.0/context-server.wit | 11 + crates/extension_api/wit/since_v0.8.0/dap.wit | 123 ++ .../wit/since_v0.8.0/extension.wit | 167 +++ .../extension_api/wit/since_v0.8.0/github.wit | 35 + .../wit/since_v0.8.0/http-client.wit | 67 + crates/extension_api/wit/since_v0.8.0/lsp.wit | 90 ++ .../extension_api/wit/since_v0.8.0/nodejs.wit | 13 + .../wit/since_v0.8.0/platform.wit | 24 + .../wit/since_v0.8.0/process.wit | 29 + .../wit/since_v0.8.0/settings.rs | 40 + .../wit/since_v0.8.0/slash-command.wit | 41 + crates/extension_host/src/wasm_host/wit.rs | 112 +- .../src/wasm_host/wit/since_v0_6_0.rs | 1013 +-------------- .../src/wasm_host/wit/since_v0_8_0.rs | 1109 +++++++++++++++++ 18 files changed, 1941 insertions(+), 962 deletions(-) create mode 100644 crates/extension_api/wit/since_v0.8.0/common.wit create mode 100644 crates/extension_api/wit/since_v0.8.0/context-server.wit create mode 100644 crates/extension_api/wit/since_v0.8.0/dap.wit create mode 100644 crates/extension_api/wit/since_v0.8.0/extension.wit create mode 100644 crates/extension_api/wit/since_v0.8.0/github.wit create mode 100644 crates/extension_api/wit/since_v0.8.0/http-client.wit create mode 100644 crates/extension_api/wit/since_v0.8.0/lsp.wit create mode 100644 crates/extension_api/wit/since_v0.8.0/nodejs.wit create mode 100644 crates/extension_api/wit/since_v0.8.0/platform.wit create mode 100644 crates/extension_api/wit/since_v0.8.0/process.wit create mode 100644 crates/extension_api/wit/since_v0.8.0/settings.rs create mode 100644 crates/extension_api/wit/since_v0.8.0/slash-command.wit create mode 100644 crates/extension_host/src/wasm_host/wit/since_v0_8_0.rs diff --git a/Cargo.lock b/Cargo.lock index 6f584fbc7fba2182b95343e24704662c53221b12..7f4813a3ee430462221732b3f6145170cada155b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -21496,6 +21496,8 @@ dependencies = [ [[package]] name = "zed_extension_api" version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0729d50b4ca0a7e28e590bbe32e3ca0194d97ef654961451a424c661a366fca0" dependencies = [ "serde", "serde_json", @@ -21504,9 +21506,7 @@ dependencies = [ [[package]] name = "zed_extension_api" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0729d50b4ca0a7e28e590bbe32e3ca0194d97ef654961451a424c661a366fca0" +version = "0.8.0" dependencies = [ "serde", "serde_json", @@ -21524,7 +21524,7 @@ dependencies = [ name = "zed_html" version = "0.2.3" dependencies = [ - "zed_extension_api 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "zed_extension_api 0.7.0", ] [[package]] @@ -21538,7 +21538,7 @@ dependencies = [ name = "zed_test_extension" version = "0.1.0" dependencies = [ - "zed_extension_api 0.7.0", + "zed_extension_api 0.8.0", ] [[package]] diff --git a/crates/extension_api/Cargo.toml b/crates/extension_api/Cargo.toml index 318a0024bf4d9bae76af888b6668d7c21f37f804..829455e62912883bea85f429a1a8917e6360d0fb 100644 --- a/crates/extension_api/Cargo.toml +++ b/crates/extension_api/Cargo.toml @@ -1,12 +1,13 @@ [package] name = "zed_extension_api" -version = "0.7.0" +version = "0.8.0" description = "APIs for creating Zed extensions in Rust" repository = "https://github.com/zed-industries/zed" documentation = "https://docs.rs/zed_extension_api" keywords = ["zed", "extension"] edition.workspace = true -publish = true +# Change back to `true` when we're ready to publish v0.8.0. +publish = false license = "Apache-2.0" [lints] diff --git a/crates/extension_api/src/extension_api.rs b/crates/extension_api/src/extension_api.rs index 723e5442098f1a66b78b86fa7ed980a18944778b..9418623224289f795fed061acbfc6035a4cc5cdf 100644 --- a/crates/extension_api/src/extension_api.rs +++ b/crates/extension_api/src/extension_api.rs @@ -334,7 +334,7 @@ mod wit { wit_bindgen::generate!({ skip: ["init-extension"], - path: "./wit/since_v0.6.0", + path: "./wit/since_v0.8.0", }); } diff --git a/crates/extension_api/wit/since_v0.8.0/common.wit b/crates/extension_api/wit/since_v0.8.0/common.wit new file mode 100644 index 0000000000000000000000000000000000000000..139e7ba0ca4d1cc5ac78ccd23673ca749d6e46b2 --- /dev/null +++ b/crates/extension_api/wit/since_v0.8.0/common.wit @@ -0,0 +1,12 @@ +interface common { + /// A (half-open) range (`[start, end)`). + record range { + /// The start of the range (inclusive). + start: u32, + /// The end of the range (exclusive). + end: u32, + } + + /// A list of environment variables. + type env-vars = list>; +} diff --git a/crates/extension_api/wit/since_v0.8.0/context-server.wit b/crates/extension_api/wit/since_v0.8.0/context-server.wit new file mode 100644 index 0000000000000000000000000000000000000000..7234e0e6d0f6d444e92a056a92f6c90c7dc053b4 --- /dev/null +++ b/crates/extension_api/wit/since_v0.8.0/context-server.wit @@ -0,0 +1,11 @@ +interface context-server { + /// Configuration for context server setup and installation. + record context-server-configuration { + /// Installation instructions in Markdown format. + installation-instructions: string, + /// JSON schema for settings validation. + settings-schema: string, + /// Default settings template. + default-settings: string, + } +} diff --git a/crates/extension_api/wit/since_v0.8.0/dap.wit b/crates/extension_api/wit/since_v0.8.0/dap.wit new file mode 100644 index 0000000000000000000000000000000000000000..693befe02f9c313455facd4839572528c3408fd1 --- /dev/null +++ b/crates/extension_api/wit/since_v0.8.0/dap.wit @@ -0,0 +1,123 @@ +interface dap { + use common.{env-vars}; + + /// Resolves a specified TcpArgumentsTemplate into TcpArguments + resolve-tcp-template: func(template: tcp-arguments-template) -> result; + + record launch-request { + program: string, + cwd: option, + args: list, + envs: env-vars, + } + + record attach-request { + process-id: option, + } + + variant debug-request { + launch(launch-request), + attach(attach-request) + } + + record tcp-arguments { + port: u16, + host: u32, + timeout: option, + } + + record tcp-arguments-template { + port: option, + host: option, + timeout: option, + } + + /// Debug Config is the "highest-level" configuration for a debug session. + /// It comes from a new process modal UI; thus, it is essentially debug-adapter-agnostic. + /// It is expected of the extension to translate this generic configuration into something that can be debugged by the adapter (debug scenario). + record debug-config { + /// Name of the debug task + label: string, + /// The debug adapter to use + adapter: string, + request: debug-request, + stop-on-entry: option, + } + + record task-template { + /// Human readable name of the task to display in the UI. + label: string, + /// Executable command to spawn. + command: string, + args: list, + env: env-vars, + cwd: option, + } + + /// A task template with substituted task variables. + type resolved-task = task-template; + + /// A task template for building a debug target. + type build-task-template = task-template; + + variant build-task-definition { + by-name(string), + template(build-task-definition-template-payload ) + } + record build-task-definition-template-payload { + locator-name: option, + template: build-task-template + } + + /// Debug Scenario is the user-facing configuration type (used in debug.json). It is still concerned with what to debug and not necessarily how to do it (except for any + /// debug-adapter-specific configuration options). + record debug-scenario { + /// Unsubstituted label for the task.DebugAdapterBinary + label: string, + /// Name of the Debug Adapter this configuration is intended for. + adapter: string, + /// An optional build step to be ran prior to starting a debug session. Build steps are used by Zed's locators to locate the executable to debug. + build: option, + /// JSON-encoded configuration for a given debug adapter. + config: string, + /// TCP connection parameters (if they were specified by user) + tcp-connection: option, + } + + enum start-debugging-request-arguments-request { + launch, + attach, + } + + record debug-task-definition { + /// Unsubstituted label for the task.DebugAdapterBinary + label: string, + /// Name of the Debug Adapter this configuration is intended for. + adapter: string, + /// JSON-encoded configuration for a given debug adapter. + config: string, + /// TCP connection parameters (if they were specified by user) + tcp-connection: option, + } + + record start-debugging-request-arguments { + /// JSON-encoded configuration for a given debug adapter. It is specific to each debug adapter. + /// `configuration` will have it's Zed variable references substituted prior to being passed to the debug adapter. + configuration: string, + request: start-debugging-request-arguments-request, + } + + /// The lowest-level representation of a debug session, which specifies: + /// - How to start a debug adapter process + /// - How to start a debug session with it (using DAP protocol) + /// for a given debug scenario. + record debug-adapter-binary { + command: option, + arguments: list, + envs: env-vars, + cwd: option, + /// Zed will use TCP transport if `connection` is specified. + connection: option, + request-args: start-debugging-request-arguments + } +} diff --git a/crates/extension_api/wit/since_v0.8.0/extension.wit b/crates/extension_api/wit/since_v0.8.0/extension.wit new file mode 100644 index 0000000000000000000000000000000000000000..8195162b89a420d322970bf894bd9ec824119087 --- /dev/null +++ b/crates/extension_api/wit/since_v0.8.0/extension.wit @@ -0,0 +1,167 @@ +package zed:extension; + +world extension { + import context-server; + import dap; + import github; + import http-client; + import platform; + import process; + import nodejs; + + use common.{env-vars, range}; + use context-server.{context-server-configuration}; + use dap.{attach-request, build-task-template, debug-config, debug-adapter-binary, debug-task-definition, debug-request, debug-scenario, launch-request, resolved-task, start-debugging-request-arguments-request}; + use lsp.{completion, symbol}; + use process.{command}; + use slash-command.{slash-command, slash-command-argument-completion, slash-command-output}; + + /// Initializes the extension. + export init-extension: func(); + + /// The type of a downloaded file. + enum downloaded-file-type { + /// A gzipped file (`.gz`). + gzip, + /// A gzipped tar archive (`.tar.gz`). + gzip-tar, + /// A ZIP file (`.zip`). + zip, + /// An uncompressed file. + uncompressed, + } + + /// The installation status for a language server. + variant language-server-installation-status { + /// The language server has no installation status. + none, + /// The language server is being downloaded. + downloading, + /// The language server is checking for updates. + checking-for-update, + /// The language server installation failed for specified reason. + failed(string), + } + + record settings-location { + worktree-id: u64, + path: string, + } + + import get-settings: func(path: option, category: string, key: option) -> result; + + /// Downloads a file from the given URL and saves it to the given path within the extension's + /// working directory. + /// + /// The file will be extracted according to the given file type. + import download-file: func(url: string, file-path: string, file-type: downloaded-file-type) -> result<_, string>; + + /// Makes the file at the given path executable. + import make-file-executable: func(filepath: string) -> result<_, string>; + + /// Updates the installation status for the given language server. + import set-language-server-installation-status: func(language-server-name: string, status: language-server-installation-status); + + /// A Zed worktree. + resource worktree { + /// Returns the ID of the worktree. + id: func() -> u64; + /// Returns the root path of the worktree. + root-path: func() -> string; + /// Returns the textual contents of the specified file in the worktree. + read-text-file: func(path: string) -> result; + /// Returns the path to the given binary name, if one is present on the `$PATH`. + which: func(binary-name: string) -> option; + /// Returns the current shell environment. + shell-env: func() -> env-vars; + } + + /// A Zed project. + resource project { + /// Returns the IDs of all of the worktrees in this project. + worktree-ids: func() -> list; + } + + /// A key-value store. + resource key-value-store { + /// Inserts an entry under the specified key. + insert: func(key: string, value: string) -> result<_, string>; + } + + /// Returns the command used to start up the language server. + export language-server-command: func(language-server-id: string, worktree: borrow) -> result; + + /// Returns the initialization options to pass to the language server on startup. + /// + /// The initialization options are represented as a JSON string. + export language-server-initialization-options: func(language-server-id: string, worktree: borrow) -> result, string>; + + /// Returns the workspace configuration options to pass to the language server. + export language-server-workspace-configuration: func(language-server-id: string, worktree: borrow) -> result, string>; + + /// Returns the initialization options to pass to the other language server. + export language-server-additional-initialization-options: func(language-server-id: string, target-language-server-id: string, worktree: borrow) -> result, string>; + + /// Returns the workspace configuration options to pass to the other language server. + export language-server-additional-workspace-configuration: func(language-server-id: string, target-language-server-id: string, worktree: borrow) -> result, string>; + + /// A label containing some code. + record code-label { + /// The source code to parse with Tree-sitter. + code: string, + /// The spans to display in the label. + spans: list, + /// The range of the displayed label to include when filtering. + filter-range: range, + } + + /// A span within a code label. + variant code-label-span { + /// A range into the parsed code. + code-range(range), + /// A span containing a code literal. + literal(code-label-span-literal), + } + + /// A span containing a code literal. + record code-label-span-literal { + /// The literal text. + text: string, + /// The name of the highlight to use for this literal. + highlight-name: option, + } + + export labels-for-completions: func(language-server-id: string, completions: list) -> result>, string>; + export labels-for-symbols: func(language-server-id: string, symbols: list) -> result>, string>; + + + /// Returns the completions that should be shown when completing the provided slash command with the given query. + export complete-slash-command-argument: func(command: slash-command, args: list) -> result, string>; + + /// Returns the output from running the provided slash command. + export run-slash-command: func(command: slash-command, args: list, worktree: option>) -> result; + + /// Returns the command used to start up a context server. + export context-server-command: func(context-server-id: string, project: borrow) -> result; + + /// Returns the configuration for a context server. + export context-server-configuration: func(context-server-id: string, project: borrow) -> result, string>; + + /// Returns a list of packages as suggestions to be included in the `/docs` + /// search results. + /// + /// This can be used to provide completions for known packages (e.g., from the + /// local project or a registry) before a package has been indexed. + export suggest-docs-packages: func(provider-name: string) -> result, string>; + + /// Indexes the docs for the specified package. + export index-docs: func(provider-name: string, package-name: string, database: borrow) -> result<_, string>; + + /// Returns a configured debug adapter binary for a given debug task. + export get-dap-binary: func(adapter-name: string, config: debug-task-definition, user-installed-path: option, worktree: borrow) -> result; + /// Returns the kind of a debug scenario (launch or attach). + export dap-request-kind: func(adapter-name: string, config: string) -> result; + export dap-config-to-scenario: func(config: debug-config) -> result; + export dap-locator-create-scenario: func(locator-name: string, build-config-template: build-task-template, resolved-label: string, debug-adapter-name: string) -> option; + export run-dap-locator: func(locator-name: string, config: resolved-task) -> result; +} diff --git a/crates/extension_api/wit/since_v0.8.0/github.wit b/crates/extension_api/wit/since_v0.8.0/github.wit new file mode 100644 index 0000000000000000000000000000000000000000..21cd5d48056af08441d3bb5aa8547edd97a874d7 --- /dev/null +++ b/crates/extension_api/wit/since_v0.8.0/github.wit @@ -0,0 +1,35 @@ +interface github { + /// A GitHub release. + record github-release { + /// The version of the release. + version: string, + /// The list of assets attached to the release. + assets: list, + } + + /// An asset from a GitHub release. + record github-release-asset { + /// The name of the asset. + name: string, + /// The download URL for the asset. + download-url: string, + } + + /// The options used to filter down GitHub releases. + record github-release-options { + /// Whether releases without assets should be included. + require-assets: bool, + /// Whether pre-releases should be included. + pre-release: bool, + } + + /// Returns the latest release for the given GitHub repository. + /// + /// Takes repo as a string in the form "/", for example: "zed-industries/zed". + latest-github-release: func(repo: string, options: github-release-options) -> result; + + /// Returns the GitHub release with the specified tag name for the given GitHub repository. + /// + /// Returns an error if a release with the given tag name does not exist. + github-release-by-tag-name: func(repo: string, tag: string) -> result; +} diff --git a/crates/extension_api/wit/since_v0.8.0/http-client.wit b/crates/extension_api/wit/since_v0.8.0/http-client.wit new file mode 100644 index 0000000000000000000000000000000000000000..bb0206c17a52d4d20b99f445dca4ac606e0485f7 --- /dev/null +++ b/crates/extension_api/wit/since_v0.8.0/http-client.wit @@ -0,0 +1,67 @@ +interface http-client { + /// An HTTP request. + record http-request { + /// The HTTP method for the request. + method: http-method, + /// The URL to which the request should be made. + url: string, + /// The headers for the request. + headers: list>, + /// The request body. + body: option>, + /// The policy to use for redirects. + redirect-policy: redirect-policy, + } + + /// HTTP methods. + enum http-method { + /// `GET` + get, + /// `HEAD` + head, + /// `POST` + post, + /// `PUT` + put, + /// `DELETE` + delete, + /// `OPTIONS` + options, + /// `PATCH` + patch, + } + + /// The policy for dealing with redirects received from the server. + variant redirect-policy { + /// Redirects from the server will not be followed. + /// + /// This is the default behavior. + no-follow, + /// Redirects from the server will be followed up to the specified limit. + follow-limit(u32), + /// All redirects from the server will be followed. + follow-all, + } + + /// An HTTP response. + record http-response { + /// The response headers. + headers: list>, + /// The response body. + body: list, + } + + /// Performs an HTTP request and returns the response. + fetch: func(req: http-request) -> result; + + /// An HTTP response stream. + resource http-response-stream { + /// Retrieves the next chunk of data from the response stream. + /// + /// Returns `Ok(None)` if the stream has ended. + next-chunk: func() -> result>, string>; + } + + /// Performs an HTTP request and returns a response stream. + fetch-stream: func(req: http-request) -> result; +} diff --git a/crates/extension_api/wit/since_v0.8.0/lsp.wit b/crates/extension_api/wit/since_v0.8.0/lsp.wit new file mode 100644 index 0000000000000000000000000000000000000000..91a36c93a66467ea7dc7d78932d3821dae79d864 --- /dev/null +++ b/crates/extension_api/wit/since_v0.8.0/lsp.wit @@ -0,0 +1,90 @@ +interface lsp { + /// An LSP completion. + record completion { + label: string, + label-details: option, + detail: option, + kind: option, + insert-text-format: option, + } + + /// The kind of an LSP completion. + variant completion-kind { + text, + method, + function, + %constructor, + field, + variable, + class, + %interface, + module, + property, + unit, + value, + %enum, + keyword, + snippet, + color, + file, + reference, + folder, + enum-member, + constant, + struct, + event, + operator, + type-parameter, + other(s32), + } + + /// Label details for an LSP completion. + record completion-label-details { + detail: option, + description: option, + } + + /// Defines how to interpret the insert text in a completion item. + variant insert-text-format { + plain-text, + snippet, + other(s32), + } + + /// An LSP symbol. + record symbol { + kind: symbol-kind, + name: string, + } + + /// The kind of an LSP symbol. + variant symbol-kind { + file, + module, + namespace, + %package, + class, + method, + property, + field, + %constructor, + %enum, + %interface, + function, + variable, + constant, + %string, + number, + boolean, + array, + object, + key, + null, + enum-member, + struct, + event, + operator, + type-parameter, + other(s32), + } +} diff --git a/crates/extension_api/wit/since_v0.8.0/nodejs.wit b/crates/extension_api/wit/since_v0.8.0/nodejs.wit new file mode 100644 index 0000000000000000000000000000000000000000..c814548314162c862e81a98b3fba6950dc2a7f41 --- /dev/null +++ b/crates/extension_api/wit/since_v0.8.0/nodejs.wit @@ -0,0 +1,13 @@ +interface nodejs { + /// Returns the path to the Node binary used by Zed. + node-binary-path: func() -> result; + + /// Returns the latest version of the given NPM package. + npm-package-latest-version: func(package-name: string) -> result; + + /// Returns the installed version of the given NPM package, if it exists. + npm-package-installed-version: func(package-name: string) -> result, string>; + + /// Installs the specified NPM package. + npm-install-package: func(package-name: string, version: string) -> result<_, string>; +} diff --git a/crates/extension_api/wit/since_v0.8.0/platform.wit b/crates/extension_api/wit/since_v0.8.0/platform.wit new file mode 100644 index 0000000000000000000000000000000000000000..48472a99bc175fdc24231a690db021433d5a2505 --- /dev/null +++ b/crates/extension_api/wit/since_v0.8.0/platform.wit @@ -0,0 +1,24 @@ +interface platform { + /// An operating system. + enum os { + /// macOS. + mac, + /// Linux. + linux, + /// Windows. + windows, + } + + /// A platform architecture. + enum architecture { + /// AArch64 (e.g., Apple Silicon). + aarch64, + /// x86. + x86, + /// x86-64. + x8664, + } + + /// Gets the current operating system and architecture. + current-platform: func() -> tuple; +} diff --git a/crates/extension_api/wit/since_v0.8.0/process.wit b/crates/extension_api/wit/since_v0.8.0/process.wit new file mode 100644 index 0000000000000000000000000000000000000000..d9a5728a3d8f5bdaa578d9dd9fc087610688cf27 --- /dev/null +++ b/crates/extension_api/wit/since_v0.8.0/process.wit @@ -0,0 +1,29 @@ +interface process { + use common.{env-vars}; + + /// A command. + record command { + /// The command to execute. + command: string, + /// The arguments to pass to the command. + args: list, + /// The environment variables to set for the command. + env: env-vars, + } + + /// The output of a finished process. + record output { + /// The status (exit code) of the process. + /// + /// On Unix, this will be `None` if the process was terminated by a signal. + status: option, + /// The data that the process wrote to stdout. + stdout: list, + /// The data that the process wrote to stderr. + stderr: list, + } + + /// Executes the given command as a child process, waiting for it to finish + /// and collecting all of its output. + run-command: func(command: command) -> result; +} diff --git a/crates/extension_api/wit/since_v0.8.0/settings.rs b/crates/extension_api/wit/since_v0.8.0/settings.rs new file mode 100644 index 0000000000000000000000000000000000000000..19e28c1ba955a998fe7b97f3eacb57c4b1104154 --- /dev/null +++ b/crates/extension_api/wit/since_v0.8.0/settings.rs @@ -0,0 +1,40 @@ +use serde::{Deserialize, Serialize}; +use std::{collections::HashMap, num::NonZeroU32}; + +/// The settings for a particular language. +#[derive(Debug, Serialize, Deserialize)] +pub struct LanguageSettings { + /// How many columns a tab should occupy. + pub tab_size: NonZeroU32, +} + +/// The settings for a particular language server. +#[derive(Default, Debug, Serialize, Deserialize)] +pub struct LspSettings { + /// The settings for the language server binary. + pub binary: Option, + /// The initialization options to pass to the language server. + pub initialization_options: Option, + /// The settings to pass to language server. + pub settings: Option, +} + +/// The settings for a particular context server. +#[derive(Default, Debug, Serialize, Deserialize, PartialEq, Eq)] +pub struct ContextServerSettings { + /// The settings for the context server binary. + pub command: Option, + /// The settings to pass to the context server. + pub settings: Option, +} + +/// The settings for a command. +#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)] +pub struct CommandSettings { + /// The path to the command. + pub path: Option, + /// The arguments to pass to the command. + pub arguments: Option>, + /// The environment variables. + pub env: Option>, +} diff --git a/crates/extension_api/wit/since_v0.8.0/slash-command.wit b/crates/extension_api/wit/since_v0.8.0/slash-command.wit new file mode 100644 index 0000000000000000000000000000000000000000..f52561c2ef412be071820f3a71621c3c4f3f9da3 --- /dev/null +++ b/crates/extension_api/wit/since_v0.8.0/slash-command.wit @@ -0,0 +1,41 @@ +interface slash-command { + use common.{range}; + + /// A slash command for use in the Assistant. + record slash-command { + /// The name of the slash command. + name: string, + /// The description of the slash command. + description: string, + /// The tooltip text to display for the run button. + tooltip-text: string, + /// Whether this slash command requires an argument. + requires-argument: bool, + } + + /// The output of a slash command. + record slash-command-output { + /// The text produced by the slash command. + text: string, + /// The list of sections to show in the slash command placeholder. + sections: list, + } + + /// A section in the slash command output. + record slash-command-output-section { + /// The range this section occupies. + range: range, + /// The label to display in the placeholder for this section. + label: string, + } + + /// A completion for a slash command argument. + record slash-command-argument-completion { + /// The label to display for this completion. + label: string, + /// The new text that should be inserted into the command when this completion is accepted. + new-text: string, + /// Whether the command should be run when accepting this completion. + run-command: bool, + } +} diff --git a/crates/extension_host/src/wasm_host/wit.rs b/crates/extension_host/src/wasm_host/wit.rs index 4c88af1b0a023441b237a26e5c14f1e6f0d0102d..5058c63365021a00dc9abf9fc05e9085757e161e 100644 --- a/crates/extension_host/src/wasm_host/wit.rs +++ b/crates/extension_host/src/wasm_host/wit.rs @@ -7,6 +7,7 @@ mod since_v0_3_0; mod since_v0_4_0; mod since_v0_5_0; mod since_v0_6_0; +mod since_v0_8_0; use dap::DebugRequest; use extension::{DebugTaskDefinition, KeyValueStoreDelegate, WorktreeDelegate}; use gpui::BackgroundExecutor; @@ -20,7 +21,7 @@ use crate::wasm_host::wit::since_v0_6_0::dap::StartDebuggingRequestArgumentsRequ use super::{WasmState, wasm_engine}; use anyhow::{Context as _, Result, anyhow}; use semver::Version; -use since_v0_6_0 as latest; +use since_v0_8_0 as latest; use std::{ops::RangeInclusive, path::PathBuf, sync::Arc}; use wasmtime::{ Store, @@ -66,7 +67,7 @@ pub fn wasm_api_version_range(release_channel: ReleaseChannel) -> RangeInclusive let max_version = match release_channel { ReleaseChannel::Dev | ReleaseChannel::Nightly => latest::MAX_VERSION, - ReleaseChannel::Stable | ReleaseChannel::Preview => latest::MAX_VERSION, + ReleaseChannel::Stable | ReleaseChannel::Preview => since_v0_6_0::MAX_VERSION, }; since_v0_0_1::MIN_VERSION..=max_version @@ -95,6 +96,7 @@ pub fn authorize_access_to_unreleased_wasm_api_version( } pub enum Extension { + V0_8_0(since_v0_8_0::Extension), V0_6_0(since_v0_6_0::Extension), V0_5_0(since_v0_5_0::Extension), V0_4_0(since_v0_4_0::Extension), @@ -118,10 +120,21 @@ impl Extension { let _ = release_channel; if version >= latest::MIN_VERSION { + authorize_access_to_unreleased_wasm_api_version(release_channel)?; + let extension = latest::Extension::instantiate_async(store, component, latest::linker(executor)) .await .context("failed to instantiate wasm extension")?; + Ok(Self::V0_8_0(extension)) + } else if version >= since_v0_6_0::MIN_VERSION { + let extension = since_v0_6_0::Extension::instantiate_async( + store, + component, + since_v0_6_0::linker(executor), + ) + .await + .context("failed to instantiate wasm extension")?; Ok(Self::V0_6_0(extension)) } else if version >= since_v0_5_0::MIN_VERSION { let extension = since_v0_5_0::Extension::instantiate_async( @@ -200,6 +213,7 @@ impl Extension { pub async fn call_init_extension(&self, store: &mut Store) -> Result<()> { match self { + Extension::V0_8_0(ext) => ext.call_init_extension(store).await, Extension::V0_6_0(ext) => ext.call_init_extension(store).await, Extension::V0_5_0(ext) => ext.call_init_extension(store).await, Extension::V0_4_0(ext) => ext.call_init_extension(store).await, @@ -220,6 +234,10 @@ impl Extension { resource: Resource>, ) -> Result> { match self { + Extension::V0_8_0(ext) => { + ext.call_language_server_command(store, &language_server_id.0, resource) + .await + } Extension::V0_6_0(ext) => { ext.call_language_server_command(store, &language_server_id.0, resource) .await @@ -282,6 +300,14 @@ impl Extension { resource: Resource>, ) -> Result, String>> { match self { + Extension::V0_8_0(ext) => { + ext.call_language_server_initialization_options( + store, + &language_server_id.0, + resource, + ) + .await + } Extension::V0_6_0(ext) => { ext.call_language_server_initialization_options( store, @@ -371,6 +397,14 @@ impl Extension { resource: Resource>, ) -> Result, String>> { match self { + Extension::V0_8_0(ext) => { + ext.call_language_server_workspace_configuration( + store, + &language_server_id.0, + resource, + ) + .await + } Extension::V0_6_0(ext) => { ext.call_language_server_workspace_configuration( store, @@ -439,6 +473,15 @@ impl Extension { resource: Resource>, ) -> Result, String>> { match self { + Extension::V0_8_0(ext) => { + ext.call_language_server_additional_initialization_options( + store, + &language_server_id.0, + &target_language_server_id.0, + resource, + ) + .await + } Extension::V0_6_0(ext) => { ext.call_language_server_additional_initialization_options( store, @@ -483,6 +526,15 @@ impl Extension { resource: Resource>, ) -> Result, String>> { match self { + Extension::V0_8_0(ext) => { + ext.call_language_server_additional_workspace_configuration( + store, + &language_server_id.0, + &target_language_server_id.0, + resource, + ) + .await + } Extension::V0_6_0(ext) => { ext.call_language_server_additional_workspace_configuration( store, @@ -526,10 +578,23 @@ impl Extension { completions: Vec, ) -> Result>, String>> { match self { - Extension::V0_6_0(ext) => { + Extension::V0_8_0(ext) => { ext.call_labels_for_completions(store, &language_server_id.0, &completions) .await } + Extension::V0_6_0(ext) => Ok(ext + .call_labels_for_completions( + store, + &language_server_id.0, + &completions.into_iter().collect::>(), + ) + .await? + .map(|labels| { + labels + .into_iter() + .map(|label| label.map(Into::into)) + .collect() + })), Extension::V0_5_0(ext) => Ok(ext .call_labels_for_completions( store, @@ -619,10 +684,23 @@ impl Extension { symbols: Vec, ) -> Result>, String>> { match self { - Extension::V0_6_0(ext) => { + Extension::V0_8_0(ext) => { ext.call_labels_for_symbols(store, &language_server_id.0, &symbols) .await } + Extension::V0_6_0(ext) => Ok(ext + .call_labels_for_symbols( + store, + &language_server_id.0, + &symbols.into_iter().collect::>(), + ) + .await? + .map(|labels| { + labels + .into_iter() + .map(|label| label.map(Into::into)) + .collect() + })), Extension::V0_5_0(ext) => Ok(ext .call_labels_for_symbols( store, @@ -712,6 +790,10 @@ impl Extension { arguments: &[String], ) -> Result, String>> { match self { + Extension::V0_8_0(ext) => { + ext.call_complete_slash_command_argument(store, command, arguments) + .await + } Extension::V0_6_0(ext) => { ext.call_complete_slash_command_argument(store, command, arguments) .await @@ -750,6 +832,10 @@ impl Extension { resource: Option>>, ) -> Result> { match self { + Extension::V0_8_0(ext) => { + ext.call_run_slash_command(store, command, arguments, resource) + .await + } Extension::V0_6_0(ext) => { ext.call_run_slash_command(store, command, arguments, resource) .await @@ -787,6 +873,10 @@ impl Extension { project: Resource, ) -> Result> { match self { + Extension::V0_8_0(ext) => { + ext.call_context_server_command(store, &context_server_id, project) + .await + } Extension::V0_6_0(ext) => { ext.call_context_server_command(store, &context_server_id, project) .await @@ -823,6 +913,10 @@ impl Extension { project: Resource, ) -> Result, String>> { match self { + Extension::V0_8_0(ext) => { + ext.call_context_server_configuration(store, &context_server_id, project) + .await + } Extension::V0_6_0(ext) => { ext.call_context_server_configuration(store, &context_server_id, project) .await @@ -849,6 +943,7 @@ impl Extension { provider: &str, ) -> Result, String>> { match self { + Extension::V0_8_0(ext) => ext.call_suggest_docs_packages(store, provider).await, Extension::V0_6_0(ext) => ext.call_suggest_docs_packages(store, provider).await, Extension::V0_5_0(ext) => ext.call_suggest_docs_packages(store, provider).await, Extension::V0_4_0(ext) => ext.call_suggest_docs_packages(store, provider).await, @@ -869,6 +964,10 @@ impl Extension { kv_store: Resource>, ) -> Result> { match self { + Extension::V0_8_0(ext) => { + ext.call_index_docs(store, provider, package_name, kv_store) + .await + } Extension::V0_6_0(ext) => { ext.call_index_docs(store, provider, package_name, kv_store) .await @@ -898,6 +997,7 @@ impl Extension { } } } + pub async fn call_get_dap_binary( &self, store: &mut Store, @@ -924,6 +1024,7 @@ impl Extension { _ => anyhow::bail!("`get_dap_binary` not available prior to v0.6.0"), } } + pub async fn call_dap_request_kind( &self, store: &mut Store, @@ -944,6 +1045,7 @@ impl Extension { _ => anyhow::bail!("`dap_request_kind` not available prior to v0.6.0"), } } + pub async fn call_dap_config_to_scenario( &self, store: &mut Store, @@ -962,6 +1064,7 @@ impl Extension { _ => anyhow::bail!("`dap_config_to_scenario` not available prior to v0.6.0"), } } + pub async fn call_dap_locator_create_scenario( &self, store: &mut Store, @@ -988,6 +1091,7 @@ impl Extension { _ => anyhow::bail!("`dap_locator_create_scenario` not available prior to v0.6.0"), } } + pub async fn call_run_dap_locator( &self, store: &mut Store, diff --git a/crates/extension_host/src/wasm_host/wit/since_v0_6_0.rs b/crates/extension_host/src/wasm_host/wit/since_v0_6_0.rs index c96e5216c4703df2a73e1a0bc27c90d13adbb782..8595c278b95a433f782ea5c53e2c97c75aa353da 100644 --- a/crates/extension_host/src/wasm_host/wit/since_v0_6_0.rs +++ b/crates/extension_host/src/wasm_host/wit/since_v0_6_0.rs @@ -1,41 +1,13 @@ -use crate::wasm_host::wit::since_v0_6_0::{ - dap::{ - AttachRequest, BuildTaskDefinition, BuildTaskDefinitionTemplatePayload, LaunchRequest, - StartDebuggingRequestArguments, TcpArguments, TcpArgumentsTemplate, - }, - slash_command::SlashCommandOutputSection, -}; -use crate::wasm_host::wit::{CompletionKind, CompletionLabelDetails, InsertTextFormat, SymbolKind}; -use crate::wasm_host::{WasmState, wit::ToWasmtimeResult}; -use ::http_client::{AsyncBody, HttpRequestExt}; -use ::settings::{Settings, WorktreeId}; -use anyhow::{Context as _, Result, bail}; -use async_compression::futures::bufread::GzipDecoder; -use async_tar::Archive; -use async_trait::async_trait; -use extension::{ - ExtensionLanguageServerProxy, KeyValueStoreDelegate, ProjectDelegate, WorktreeDelegate, -}; -use futures::{AsyncReadExt, lock::Mutex}; -use futures::{FutureExt as _, io::BufReader}; -use gpui::{BackgroundExecutor, SharedString}; -use language::{BinaryStatus, LanguageName, language_settings::AllLanguageSettings}; -use project::project_settings::ProjectSettings; +use crate::wasm_host::WasmState; +use anyhow::Result; +use extension::{KeyValueStoreDelegate, ProjectDelegate, WorktreeDelegate}; +use gpui::BackgroundExecutor; use semver::Version; -use std::{ - env, - net::Ipv4Addr, - path::{Path, PathBuf}, - str::FromStr, - sync::{Arc, OnceLock}, -}; -use task::{SpawnInTerminal, ZedDebugConfig}; -use url::Url; -use util::{ - archive::extract_zip, fs::make_file_executable, maybe, paths::PathStyle, rel_path::RelPath, -}; +use std::sync::{Arc, OnceLock}; use wasmtime::component::{Linker, Resource}; +use super::latest; + pub const MIN_VERSION: Version = Version::new(0, 6, 0); pub const MAX_VERSION: Version = Version::new(0, 7, 0); @@ -44,10 +16,19 @@ wasmtime::component::bindgen!({ trappable_imports: true, path: "../extension_api/wit/since_v0.6.0", with: { - "worktree": ExtensionWorktree, - "project": ExtensionProject, - "key-value-store": ExtensionKeyValueStore, - "zed:extension/http-client/http-response-stream": ExtensionHttpResponseStream + "worktree": ExtensionWorktree, + "project": ExtensionProject, + "key-value-store": ExtensionKeyValueStore, + "zed:extension/common": latest::zed::extension::common, + "zed:extension/github": latest::zed::extension::github, + "zed:extension/http-client": latest::zed::extension::http_client, + "zed:extension/lsp": latest::zed::extension::lsp, + "zed:extension/nodejs": latest::zed::extension::nodejs, + "zed:extension/platform": latest::zed::extension::platform, + "zed:extension/process": latest::zed::extension::process, + "zed:extension/slash-command": latest::zed::extension::slash_command, + "zed:extension/context-server": latest::zed::extension::context_server, + "zed:extension/dap": latest::zed::extension::dap, }, }); @@ -61,289 +42,32 @@ mod settings { pub type ExtensionWorktree = Arc; pub type ExtensionProject = Arc; pub type ExtensionKeyValueStore = Arc; -pub type ExtensionHttpResponseStream = Arc>>; pub fn linker(executor: &BackgroundExecutor) -> &'static Linker { static LINKER: OnceLock> = OnceLock::new(); LINKER.get_or_init(|| super::new_linker(executor, Extension::add_to_linker)) } -impl From for std::ops::Range { - fn from(range: Range) -> Self { - let start = range.start as usize; - let end = range.end as usize; - start..end - } -} - -impl From for extension::Command { - fn from(value: Command) -> Self { - Self { - command: value.command.into(), - args: value.args, - env: value.env, - } - } -} - -impl From - for extension::StartDebuggingRequestArgumentsRequest -{ - fn from(value: StartDebuggingRequestArgumentsRequest) -> Self { - match value { - StartDebuggingRequestArgumentsRequest::Launch => Self::Launch, - StartDebuggingRequestArgumentsRequest::Attach => Self::Attach, - } - } -} -impl TryFrom for extension::StartDebuggingRequestArguments { - type Error = anyhow::Error; - - fn try_from(value: StartDebuggingRequestArguments) -> Result { - Ok(Self { - configuration: serde_json::from_str(&value.configuration)?, - request: value.request.into(), - }) - } -} -impl From for extension::TcpArguments { - fn from(value: TcpArguments) -> Self { - Self { - host: value.host.into(), - port: value.port, - timeout: value.timeout, - } - } -} - -impl From for TcpArgumentsTemplate { - fn from(value: extension::TcpArgumentsTemplate) -> Self { - Self { - host: value.host.map(Ipv4Addr::to_bits), - port: value.port, - timeout: value.timeout, - } - } -} - -impl From for extension::TcpArgumentsTemplate { - fn from(value: TcpArgumentsTemplate) -> Self { - Self { - host: value.host.map(Ipv4Addr::from_bits), - port: value.port, - timeout: value.timeout, - } - } -} - -impl TryFrom for DebugTaskDefinition { - type Error = anyhow::Error; - fn try_from(value: extension::DebugTaskDefinition) -> Result { - Ok(Self { - label: value.label.to_string(), - adapter: value.adapter.to_string(), - config: value.config.to_string(), - tcp_connection: value.tcp_connection.map(Into::into), - }) - } -} - -impl From for DebugRequest { - fn from(value: task::DebugRequest) -> Self { - match value { - task::DebugRequest::Launch(launch_request) => Self::Launch(launch_request.into()), - task::DebugRequest::Attach(attach_request) => Self::Attach(attach_request.into()), - } - } -} - -impl From for task::DebugRequest { - fn from(value: DebugRequest) -> Self { - match value { - DebugRequest::Launch(launch_request) => Self::Launch(launch_request.into()), - DebugRequest::Attach(attach_request) => Self::Attach(attach_request.into()), - } - } -} - -impl From for LaunchRequest { - fn from(value: task::LaunchRequest) -> Self { - Self { - program: value.program, - cwd: value.cwd.map(|p| p.to_string_lossy().into_owned()), - args: value.args, - envs: value.env.into_iter().collect(), - } - } -} - -impl From for AttachRequest { - fn from(value: task::AttachRequest) -> Self { - Self { - process_id: value.process_id, - } - } -} - -impl From for task::LaunchRequest { - fn from(value: LaunchRequest) -> Self { - Self { - program: value.program, - cwd: value.cwd.map(|p| p.into()), - args: value.args, - env: value.envs.into_iter().collect(), - } - } -} -impl From for task::AttachRequest { - fn from(value: AttachRequest) -> Self { - Self { - process_id: value.process_id, - } - } -} - -impl From for DebugConfig { - fn from(value: ZedDebugConfig) -> Self { - Self { - label: value.label.into(), - adapter: value.adapter.into(), - request: value.request.into(), - stop_on_entry: value.stop_on_entry, - } - } -} -impl TryFrom for extension::DebugAdapterBinary { - type Error = anyhow::Error; - fn try_from(value: DebugAdapterBinary) -> Result { - Ok(Self { - command: value.command, - arguments: value.arguments, - envs: value.envs.into_iter().collect(), - cwd: value.cwd.map(|s| s.into()), - connection: value.connection.map(Into::into), - request_args: value.request_args.try_into()?, - }) - } -} - -impl From for extension::BuildTaskDefinition { - fn from(value: BuildTaskDefinition) -> Self { - match value { - BuildTaskDefinition::ByName(name) => Self::ByName(name.into()), - BuildTaskDefinition::Template(build_task_template) => Self::Template { - task_template: build_task_template.template.into(), - locator_name: build_task_template.locator_name.map(SharedString::from), - }, - } - } -} - -impl From for BuildTaskDefinition { - fn from(value: extension::BuildTaskDefinition) -> Self { - match value { - extension::BuildTaskDefinition::ByName(name) => Self::ByName(name.into()), - extension::BuildTaskDefinition::Template { - task_template, - locator_name, - } => Self::Template(BuildTaskDefinitionTemplatePayload { - template: task_template.into(), - locator_name: locator_name.map(String::from), - }), - } - } -} -impl From for extension::BuildTaskTemplate { - fn from(value: BuildTaskTemplate) -> Self { - Self { - label: value.label, - command: value.command, - args: value.args, - env: value.env.into_iter().collect(), - cwd: value.cwd, - ..Default::default() - } - } -} -impl From for BuildTaskTemplate { - fn from(value: extension::BuildTaskTemplate) -> Self { - Self { - label: value.label, - command: value.command, - args: value.args, - env: value.env.into_iter().collect(), - cwd: value.cwd, - } - } -} - -impl TryFrom for extension::DebugScenario { - type Error = anyhow::Error; - - fn try_from(value: DebugScenario) -> std::result::Result { - Ok(Self { - adapter: value.adapter.into(), - label: value.label.into(), - build: value.build.map(Into::into), - config: serde_json::Value::from_str(&value.config)?, - tcp_connection: value.tcp_connection.map(Into::into), - }) - } -} - -impl From for DebugScenario { - fn from(value: extension::DebugScenario) -> Self { - Self { - adapter: value.adapter.into(), - label: value.label.into(), - build: value.build.map(Into::into), - config: value.config.to_string(), - tcp_connection: value.tcp_connection.map(Into::into), - } - } -} - -impl TryFrom for ResolvedTask { - type Error = anyhow::Error; - - fn try_from(value: SpawnInTerminal) -> Result { - Ok(Self { - label: value.label, - command: value.command.context("missing command")?, - args: value.args, - env: value.env.into_iter().collect(), - cwd: value.cwd.map(|s| { - let s = s.to_string_lossy(); - if cfg!(target_os = "windows") { - s.replace('\\', "/") - } else { - s.into_owned() - } - }), - }) - } -} - -impl From for extension::CodeLabel { +impl From for latest::CodeLabel { fn from(value: CodeLabel) -> Self { Self { code: value.code, spans: value.spans.into_iter().map(Into::into).collect(), - filter_range: value.filter_range.into(), + filter_range: value.filter_range, } } } -impl From for extension::CodeLabelSpan { +impl From for latest::CodeLabelSpan { fn from(value: CodeLabelSpan) -> Self { match value { - CodeLabelSpan::CodeRange(range) => Self::CodeRange(range.into()), + CodeLabelSpan::CodeRange(range) => Self::CodeRange(range), CodeLabelSpan::Literal(literal) => Self::Literal(literal.into()), } } } -impl From for extension::CodeLabelSpanLiteral { +impl From for latest::CodeLabelSpanLiteral { fn from(value: CodeLabelSpanLiteral) -> Self { Self { text: value.text, @@ -352,167 +76,37 @@ impl From for extension::CodeLabelSpanLiteral { } } -impl From for Completion { - fn from(value: extension::Completion) -> Self { +impl From for latest::SettingsLocation { + fn from(value: SettingsLocation) -> Self { Self { - label: value.label, - label_details: value.label_details.map(Into::into), - detail: value.detail, - kind: value.kind.map(Into::into), - insert_text_format: value.insert_text_format.map(Into::into), + worktree_id: value.worktree_id, + path: value.path, } } } -impl From for CompletionLabelDetails { - fn from(value: extension::CompletionLabelDetails) -> Self { - Self { - detail: value.detail, - description: value.description, - } - } -} - -impl From for CompletionKind { - fn from(value: extension::CompletionKind) -> Self { +impl From for latest::LanguageServerInstallationStatus { + fn from(value: LanguageServerInstallationStatus) -> Self { match value { - extension::CompletionKind::Text => Self::Text, - extension::CompletionKind::Method => Self::Method, - extension::CompletionKind::Function => Self::Function, - extension::CompletionKind::Constructor => Self::Constructor, - extension::CompletionKind::Field => Self::Field, - extension::CompletionKind::Variable => Self::Variable, - extension::CompletionKind::Class => Self::Class, - extension::CompletionKind::Interface => Self::Interface, - extension::CompletionKind::Module => Self::Module, - extension::CompletionKind::Property => Self::Property, - extension::CompletionKind::Unit => Self::Unit, - extension::CompletionKind::Value => Self::Value, - extension::CompletionKind::Enum => Self::Enum, - extension::CompletionKind::Keyword => Self::Keyword, - extension::CompletionKind::Snippet => Self::Snippet, - extension::CompletionKind::Color => Self::Color, - extension::CompletionKind::File => Self::File, - extension::CompletionKind::Reference => Self::Reference, - extension::CompletionKind::Folder => Self::Folder, - extension::CompletionKind::EnumMember => Self::EnumMember, - extension::CompletionKind::Constant => Self::Constant, - extension::CompletionKind::Struct => Self::Struct, - extension::CompletionKind::Event => Self::Event, - extension::CompletionKind::Operator => Self::Operator, - extension::CompletionKind::TypeParameter => Self::TypeParameter, - extension::CompletionKind::Other(value) => Self::Other(value), + LanguageServerInstallationStatus::None => Self::None, + LanguageServerInstallationStatus::Downloading => Self::Downloading, + LanguageServerInstallationStatus::CheckingForUpdate => Self::CheckingForUpdate, + LanguageServerInstallationStatus::Failed(message) => Self::Failed(message), } } } -impl From for InsertTextFormat { - fn from(value: extension::InsertTextFormat) -> Self { +impl From for latest::DownloadedFileType { + fn from(value: DownloadedFileType) -> Self { match value { - extension::InsertTextFormat::PlainText => Self::PlainText, - extension::InsertTextFormat::Snippet => Self::Snippet, - extension::InsertTextFormat::Other(value) => Self::Other(value), + DownloadedFileType::Gzip => Self::Gzip, + DownloadedFileType::GzipTar => Self::GzipTar, + DownloadedFileType::Zip => Self::Zip, + DownloadedFileType::Uncompressed => Self::Uncompressed, } } } -impl From for Symbol { - fn from(value: extension::Symbol) -> Self { - Self { - kind: value.kind.into(), - name: value.name, - } - } -} - -impl From for SymbolKind { - fn from(value: extension::SymbolKind) -> Self { - match value { - extension::SymbolKind::File => Self::File, - extension::SymbolKind::Module => Self::Module, - extension::SymbolKind::Namespace => Self::Namespace, - extension::SymbolKind::Package => Self::Package, - extension::SymbolKind::Class => Self::Class, - extension::SymbolKind::Method => Self::Method, - extension::SymbolKind::Property => Self::Property, - extension::SymbolKind::Field => Self::Field, - extension::SymbolKind::Constructor => Self::Constructor, - extension::SymbolKind::Enum => Self::Enum, - extension::SymbolKind::Interface => Self::Interface, - extension::SymbolKind::Function => Self::Function, - extension::SymbolKind::Variable => Self::Variable, - extension::SymbolKind::Constant => Self::Constant, - extension::SymbolKind::String => Self::String, - extension::SymbolKind::Number => Self::Number, - extension::SymbolKind::Boolean => Self::Boolean, - extension::SymbolKind::Array => Self::Array, - extension::SymbolKind::Object => Self::Object, - extension::SymbolKind::Key => Self::Key, - extension::SymbolKind::Null => Self::Null, - extension::SymbolKind::EnumMember => Self::EnumMember, - extension::SymbolKind::Struct => Self::Struct, - extension::SymbolKind::Event => Self::Event, - extension::SymbolKind::Operator => Self::Operator, - extension::SymbolKind::TypeParameter => Self::TypeParameter, - extension::SymbolKind::Other(value) => Self::Other(value), - } - } -} - -impl From for SlashCommand { - fn from(value: extension::SlashCommand) -> Self { - Self { - name: value.name, - description: value.description, - tooltip_text: value.tooltip_text, - requires_argument: value.requires_argument, - } - } -} - -impl From for extension::SlashCommandOutput { - fn from(value: SlashCommandOutput) -> Self { - Self { - text: value.text, - sections: value.sections.into_iter().map(Into::into).collect(), - } - } -} - -impl From for extension::SlashCommandOutputSection { - fn from(value: SlashCommandOutputSection) -> Self { - Self { - range: value.range.start as usize..value.range.end as usize, - label: value.label, - } - } -} - -impl From for extension::SlashCommandArgumentCompletion { - fn from(value: SlashCommandArgumentCompletion) -> Self { - Self { - label: value.label, - new_text: value.new_text, - run_command: value.run_command, - } - } -} - -impl TryFrom for extension::ContextServerConfiguration { - type Error = anyhow::Error; - - fn try_from(value: ContextServerConfiguration) -> Result { - let settings_schema: serde_json::Value = serde_json::from_str(&value.settings_schema) - .context("Failed to parse settings_schema")?; - - Ok(Self { - installation_instructions: value.installation_instructions, - default_settings: value.default_settings, - settings_schema, - }) - } -} - impl HostKeyValueStore for WasmState { async fn insert( &mut self, @@ -520,8 +114,7 @@ impl HostKeyValueStore for WasmState { key: String, value: String, ) -> wasmtime::Result> { - let kv_store = self.table.get(&kv_store)?; - kv_store.insert(key, value).await.to_wasmtime_result() + latest::HostKeyValueStore::insert(self, kv_store, key, value).await } async fn drop(&mut self, _worktree: Resource) -> Result<()> { @@ -535,8 +128,7 @@ impl HostProject for WasmState { &mut self, project: Resource, ) -> wasmtime::Result> { - let project = self.table.get(&project)?; - Ok(project.worktree_ids()) + latest::HostProject::worktree_ids(self, project).await } async fn drop(&mut self, _project: Resource) -> Result<()> { @@ -547,16 +139,14 @@ impl HostProject for WasmState { impl HostWorktree for WasmState { async fn id(&mut self, delegate: Resource>) -> wasmtime::Result { - let delegate = self.table.get(&delegate)?; - Ok(delegate.id()) + latest::HostWorktree::id(self, delegate).await } async fn root_path( &mut self, delegate: Resource>, ) -> wasmtime::Result { - let delegate = self.table.get(&delegate)?; - Ok(delegate.root_path()) + latest::HostWorktree::root_path(self, delegate).await } async fn read_text_file( @@ -564,19 +154,14 @@ impl HostWorktree for WasmState { delegate: Resource>, path: String, ) -> wasmtime::Result> { - let delegate = self.table.get(&delegate)?; - Ok(delegate - .read_text_file(&RelPath::new(Path::new(&path), PathStyle::Posix)?) - .await - .map_err(|error| error.to_string())) + latest::HostWorktree::read_text_file(self, delegate, path).await } async fn shell_env( &mut self, delegate: Resource>, ) -> wasmtime::Result { - let delegate = self.table.get(&delegate)?; - Ok(delegate.shell_env().await.into_iter().collect()) + latest::HostWorktree::shell_env(self, delegate).await } async fn which( @@ -584,8 +169,7 @@ impl HostWorktree for WasmState { delegate: Resource>, binary_name: String, ) -> wasmtime::Result> { - let delegate = self.table.get(&delegate)?; - Ok(delegate.which(binary_name).await) + latest::HostWorktree::which(self, delegate, binary_name).await } async fn drop(&mut self, _worktree: Resource) -> Result<()> { @@ -594,319 +178,6 @@ impl HostWorktree for WasmState { } } -impl common::Host for WasmState {} - -impl http_client::Host for WasmState { - async fn fetch( - &mut self, - request: http_client::HttpRequest, - ) -> wasmtime::Result> { - maybe!(async { - let url = &request.url; - let request = convert_request(&request)?; - let mut response = self.host.http_client.send(request).await?; - - if response.status().is_client_error() || response.status().is_server_error() { - bail!("failed to fetch '{url}': status code {}", response.status()) - } - convert_response(&mut response).await - }) - .await - .to_wasmtime_result() - } - - async fn fetch_stream( - &mut self, - request: http_client::HttpRequest, - ) -> wasmtime::Result, String>> { - let request = convert_request(&request)?; - let response = self.host.http_client.send(request); - maybe!(async { - let response = response.await?; - let stream = Arc::new(Mutex::new(response)); - let resource = self.table.push(stream)?; - Ok(resource) - }) - .await - .to_wasmtime_result() - } -} - -impl http_client::HostHttpResponseStream for WasmState { - async fn next_chunk( - &mut self, - resource: Resource, - ) -> wasmtime::Result>, String>> { - let stream = self.table.get(&resource)?.clone(); - maybe!(async move { - let mut response = stream.lock().await; - let mut buffer = vec![0; 8192]; // 8KB buffer - let bytes_read = response.body_mut().read(&mut buffer).await?; - if bytes_read == 0 { - Ok(None) - } else { - buffer.truncate(bytes_read); - Ok(Some(buffer)) - } - }) - .await - .to_wasmtime_result() - } - - async fn drop(&mut self, _resource: Resource) -> Result<()> { - Ok(()) - } -} - -impl From for ::http_client::Method { - fn from(value: http_client::HttpMethod) -> Self { - match value { - http_client::HttpMethod::Get => Self::GET, - http_client::HttpMethod::Post => Self::POST, - http_client::HttpMethod::Put => Self::PUT, - http_client::HttpMethod::Delete => Self::DELETE, - http_client::HttpMethod::Head => Self::HEAD, - http_client::HttpMethod::Options => Self::OPTIONS, - http_client::HttpMethod::Patch => Self::PATCH, - } - } -} - -fn convert_request( - extension_request: &http_client::HttpRequest, -) -> anyhow::Result<::http_client::Request> { - let mut request = ::http_client::Request::builder() - .method(::http_client::Method::from(extension_request.method)) - .uri(&extension_request.url) - .follow_redirects(match extension_request.redirect_policy { - http_client::RedirectPolicy::NoFollow => ::http_client::RedirectPolicy::NoFollow, - http_client::RedirectPolicy::FollowLimit(limit) => { - ::http_client::RedirectPolicy::FollowLimit(limit) - } - http_client::RedirectPolicy::FollowAll => ::http_client::RedirectPolicy::FollowAll, - }); - for (key, value) in &extension_request.headers { - request = request.header(key, value); - } - let body = extension_request - .body - .clone() - .map(AsyncBody::from) - .unwrap_or_default(); - request.body(body).map_err(anyhow::Error::from) -} - -async fn convert_response( - response: &mut ::http_client::Response, -) -> anyhow::Result { - let mut extension_response = http_client::HttpResponse { - body: Vec::new(), - headers: Vec::new(), - }; - - for (key, value) in response.headers() { - extension_response - .headers - .push((key.to_string(), value.to_str().unwrap_or("").to_string())); - } - - response - .body_mut() - .read_to_end(&mut extension_response.body) - .await?; - - Ok(extension_response) -} - -impl nodejs::Host for WasmState { - async fn node_binary_path(&mut self) -> wasmtime::Result> { - self.host - .node_runtime - .binary_path() - .await - .map(|path| path.to_string_lossy().into_owned()) - .to_wasmtime_result() - } - - async fn npm_package_latest_version( - &mut self, - package_name: String, - ) -> wasmtime::Result> { - self.host - .node_runtime - .npm_package_latest_version(&package_name) - .await - .to_wasmtime_result() - } - - async fn npm_package_installed_version( - &mut self, - package_name: String, - ) -> wasmtime::Result, String>> { - self.host - .node_runtime - .npm_package_installed_version(&self.work_dir(), &package_name) - .await - .to_wasmtime_result() - } - - async fn npm_install_package( - &mut self, - package_name: String, - version: String, - ) -> wasmtime::Result> { - self.capability_granter - .grant_npm_install_package(&package_name)?; - - self.host - .node_runtime - .npm_install_packages(&self.work_dir(), &[(&package_name, &version)]) - .await - .to_wasmtime_result() - } -} - -#[async_trait] -impl lsp::Host for WasmState {} - -impl From<::http_client::github::GithubRelease> for github::GithubRelease { - fn from(value: ::http_client::github::GithubRelease) -> Self { - Self { - version: value.tag_name, - assets: value.assets.into_iter().map(Into::into).collect(), - } - } -} - -impl From<::http_client::github::GithubReleaseAsset> for github::GithubReleaseAsset { - fn from(value: ::http_client::github::GithubReleaseAsset) -> Self { - Self { - name: value.name, - download_url: value.browser_download_url, - } - } -} - -impl github::Host for WasmState { - async fn latest_github_release( - &mut self, - repo: String, - options: github::GithubReleaseOptions, - ) -> wasmtime::Result> { - maybe!(async { - let release = ::http_client::github::latest_github_release( - &repo, - options.require_assets, - options.pre_release, - self.host.http_client.clone(), - ) - .await?; - Ok(release.into()) - }) - .await - .to_wasmtime_result() - } - - async fn github_release_by_tag_name( - &mut self, - repo: String, - tag: String, - ) -> wasmtime::Result> { - maybe!(async { - let release = ::http_client::github::get_release_by_tag_name( - &repo, - &tag, - self.host.http_client.clone(), - ) - .await?; - Ok(release.into()) - }) - .await - .to_wasmtime_result() - } -} - -impl platform::Host for WasmState { - async fn current_platform(&mut self) -> Result<(platform::Os, platform::Architecture)> { - Ok(( - match env::consts::OS { - "macos" => platform::Os::Mac, - "linux" => platform::Os::Linux, - "windows" => platform::Os::Windows, - _ => panic!("unsupported os"), - }, - match env::consts::ARCH { - "aarch64" => platform::Architecture::Aarch64, - "x86" => platform::Architecture::X86, - "x86_64" => platform::Architecture::X8664, - _ => panic!("unsupported architecture"), - }, - )) - } -} - -impl From for process::Output { - fn from(output: std::process::Output) -> Self { - Self { - status: output.status.code(), - stdout: output.stdout, - stderr: output.stderr, - } - } -} - -impl process::Host for WasmState { - async fn run_command( - &mut self, - command: process::Command, - ) -> wasmtime::Result> { - maybe!(async { - self.capability_granter - .grant_exec(&command.command, &command.args)?; - - let output = util::command::new_smol_command(command.command.as_str()) - .args(&command.args) - .envs(command.env) - .output() - .await?; - - Ok(output.into()) - }) - .await - .to_wasmtime_result() - } -} - -#[async_trait] -impl slash_command::Host for WasmState {} - -#[async_trait] -impl context_server::Host for WasmState {} - -impl dap::Host for WasmState { - async fn resolve_tcp_template( - &mut self, - template: TcpArgumentsTemplate, - ) -> wasmtime::Result> { - maybe!(async { - let (host, port, timeout) = - ::dap::configure_tcp_connection(task::TcpArgumentsTemplate { - port: template.port, - host: template.host.map(Ipv4Addr::from_bits), - timeout: template.timeout, - }) - .await?; - Ok(TcpArguments { - port, - host: host.to_bits(), - timeout, - }) - }) - .await - .to_wasmtime_result() - } -} - impl ExtensionImports for WasmState { async fn get_settings( &mut self, @@ -914,96 +185,13 @@ impl ExtensionImports for WasmState { category: String, key: Option, ) -> wasmtime::Result> { - self.on_main_thread(|cx| { - async move { - let path = location.as_ref().and_then(|location| { - RelPath::new(Path::new(&location.path), PathStyle::Posix).ok() - }); - let location = path - .as_ref() - .zip(location.as_ref()) - .map(|(path, location)| ::settings::SettingsLocation { - worktree_id: WorktreeId::from_proto(location.worktree_id), - path, - }); - - cx.update(|cx| match category.as_str() { - "language" => { - let key = key.map(|k| LanguageName::new(&k)); - let settings = AllLanguageSettings::get(location, cx).language( - location, - key.as_ref(), - cx, - ); - Ok(serde_json::to_string(&settings::LanguageSettings { - tab_size: settings.tab_size, - })?) - } - "lsp" => { - let settings = key - .and_then(|key| { - ProjectSettings::get(location, cx) - .lsp - .get(&::lsp::LanguageServerName::from_proto(key)) - }) - .cloned() - .unwrap_or_default(); - Ok(serde_json::to_string(&settings::LspSettings { - binary: settings.binary.map(|binary| settings::CommandSettings { - path: binary.path, - arguments: binary.arguments, - env: binary.env.map(|env| env.into_iter().collect()), - }), - settings: settings.settings, - initialization_options: settings.initialization_options, - })?) - } - "context_servers" => { - let settings = key - .and_then(|key| { - ProjectSettings::get(location, cx) - .context_servers - .get(key.as_str()) - }) - .cloned() - .unwrap_or_else(|| { - project::project_settings::ContextServerSettings::default_extension( - ) - }); - - match settings { - project::project_settings::ContextServerSettings::Stdio { - enabled: _, - command, - } => Ok(serde_json::to_string(&settings::ContextServerSettings { - command: Some(settings::CommandSettings { - path: command.path.to_str().map(|path| path.to_string()), - arguments: Some(command.args), - env: command.env.map(|env| env.into_iter().collect()), - }), - settings: None, - })?), - project::project_settings::ContextServerSettings::Extension { - enabled: _, - settings, - } => Ok(serde_json::to_string(&settings::ContextServerSettings { - command: None, - settings: Some(settings), - })?), - project::project_settings::ContextServerSettings::Http { .. } => { - bail!("remote context server settings not supported in 0.6.0") - } - } - } - _ => { - bail!("Unknown settings category: {}", category); - } - }) - } - .boxed_local() - }) - .await? - .to_wasmtime_result() + latest::ExtensionImports::get_settings( + self, + location.map(|location| location.into()), + category, + key, + ) + .await } async fn set_language_server_installation_status( @@ -1011,18 +199,12 @@ impl ExtensionImports for WasmState { server_name: String, status: LanguageServerInstallationStatus, ) -> wasmtime::Result<()> { - let status = match status { - LanguageServerInstallationStatus::CheckingForUpdate => BinaryStatus::CheckingForUpdate, - LanguageServerInstallationStatus::Downloading => BinaryStatus::Downloading, - LanguageServerInstallationStatus::None => BinaryStatus::None, - LanguageServerInstallationStatus::Failed(error) => BinaryStatus::Failed { error }, - }; - - self.host - .proxy - .update_language_server_status(::lsp::LanguageServerName(server_name.into()), status); - - Ok(()) + latest::ExtensionImports::set_language_server_installation_status( + self, + server_name, + status.into(), + ) + .await } async fn download_file( @@ -1031,79 +213,10 @@ impl ExtensionImports for WasmState { path: String, file_type: DownloadedFileType, ) -> wasmtime::Result> { - maybe!(async { - let parsed_url = Url::parse(&url)?; - self.capability_granter.grant_download_file(&parsed_url)?; - - let path = PathBuf::from(path); - let extension_work_dir = self.host.work_dir.join(self.manifest.id.as_ref()); - - self.host.fs.create_dir(&extension_work_dir).await?; - - let destination_path = self - .host - .writeable_path_from_extension(&self.manifest.id, &path)?; - - let mut response = self - .host - .http_client - .get(&url, Default::default(), true) - .await - .context("downloading release")?; - - anyhow::ensure!( - response.status().is_success(), - "download failed with status {}", - response.status() - ); - let body = BufReader::new(response.body_mut()); - - match file_type { - DownloadedFileType::Uncompressed => { - futures::pin_mut!(body); - self.host - .fs - .create_file_with(&destination_path, body) - .await?; - } - DownloadedFileType::Gzip => { - let body = GzipDecoder::new(body); - futures::pin_mut!(body); - self.host - .fs - .create_file_with(&destination_path, body) - .await?; - } - DownloadedFileType::GzipTar => { - let body = GzipDecoder::new(body); - futures::pin_mut!(body); - self.host - .fs - .extract_tar_file(&destination_path, Archive::new(body)) - .await?; - } - DownloadedFileType::Zip => { - futures::pin_mut!(body); - extract_zip(&destination_path, body) - .await - .with_context(|| format!("unzipping {path:?} archive"))?; - } - } - - Ok(()) - }) - .await - .to_wasmtime_result() + latest::ExtensionImports::download_file(self, url, path, file_type.into()).await } async fn make_file_executable(&mut self, path: String) -> wasmtime::Result> { - let path = self - .host - .writeable_path_from_extension(&self.manifest.id, Path::new(&path))?; - - make_file_executable(&path) - .await - .with_context(|| format!("setting permissions for path {path:?}")) - .to_wasmtime_result() + latest::ExtensionImports::make_file_executable(self, path).await } } diff --git a/crates/extension_host/src/wasm_host/wit/since_v0_8_0.rs b/crates/extension_host/src/wasm_host/wit/since_v0_8_0.rs new file mode 100644 index 0000000000000000000000000000000000000000..a2776f9f3b5b055d00787fb59c9bbca582352b1f --- /dev/null +++ b/crates/extension_host/src/wasm_host/wit/since_v0_8_0.rs @@ -0,0 +1,1109 @@ +use crate::wasm_host::wit::since_v0_6_0::{ + dap::{ + AttachRequest, BuildTaskDefinition, BuildTaskDefinitionTemplatePayload, LaunchRequest, + StartDebuggingRequestArguments, TcpArguments, TcpArgumentsTemplate, + }, + slash_command::SlashCommandOutputSection, +}; +use crate::wasm_host::wit::{CompletionKind, CompletionLabelDetails, InsertTextFormat, SymbolKind}; +use crate::wasm_host::{WasmState, wit::ToWasmtimeResult}; +use ::http_client::{AsyncBody, HttpRequestExt}; +use ::settings::{Settings, WorktreeId}; +use anyhow::{Context as _, Result, bail}; +use async_compression::futures::bufread::GzipDecoder; +use async_tar::Archive; +use async_trait::async_trait; +use extension::{ + ExtensionLanguageServerProxy, KeyValueStoreDelegate, ProjectDelegate, WorktreeDelegate, +}; +use futures::{AsyncReadExt, lock::Mutex}; +use futures::{FutureExt as _, io::BufReader}; +use gpui::{BackgroundExecutor, SharedString}; +use language::{BinaryStatus, LanguageName, language_settings::AllLanguageSettings}; +use project::project_settings::ProjectSettings; +use semver::Version; +use std::{ + env, + net::Ipv4Addr, + path::{Path, PathBuf}, + str::FromStr, + sync::{Arc, OnceLock}, +}; +use task::{SpawnInTerminal, ZedDebugConfig}; +use url::Url; +use util::{ + archive::extract_zip, fs::make_file_executable, maybe, paths::PathStyle, rel_path::RelPath, +}; +use wasmtime::component::{Linker, Resource}; + +pub const MIN_VERSION: Version = Version::new(0, 8, 0); +pub const MAX_VERSION: Version = Version::new(0, 8, 0); + +wasmtime::component::bindgen!({ + async: true, + trappable_imports: true, + path: "../extension_api/wit/since_v0.8.0", + with: { + "worktree": ExtensionWorktree, + "project": ExtensionProject, + "key-value-store": ExtensionKeyValueStore, + "zed:extension/http-client/http-response-stream": ExtensionHttpResponseStream + }, +}); + +pub use self::zed::extension::*; + +mod settings { + #![allow(dead_code)] + include!(concat!(env!("OUT_DIR"), "/since_v0.8.0/settings.rs")); +} + +pub type ExtensionWorktree = Arc; +pub type ExtensionProject = Arc; +pub type ExtensionKeyValueStore = Arc; +pub type ExtensionHttpResponseStream = Arc>>; + +pub fn linker(executor: &BackgroundExecutor) -> &'static Linker { + static LINKER: OnceLock> = OnceLock::new(); + LINKER.get_or_init(|| super::new_linker(executor, Extension::add_to_linker)) +} + +impl From for std::ops::Range { + fn from(range: Range) -> Self { + let start = range.start as usize; + let end = range.end as usize; + start..end + } +} + +impl From for extension::Command { + fn from(value: Command) -> Self { + Self { + command: value.command.into(), + args: value.args, + env: value.env, + } + } +} + +impl From + for extension::StartDebuggingRequestArgumentsRequest +{ + fn from(value: StartDebuggingRequestArgumentsRequest) -> Self { + match value { + StartDebuggingRequestArgumentsRequest::Launch => Self::Launch, + StartDebuggingRequestArgumentsRequest::Attach => Self::Attach, + } + } +} +impl TryFrom for extension::StartDebuggingRequestArguments { + type Error = anyhow::Error; + + fn try_from(value: StartDebuggingRequestArguments) -> Result { + Ok(Self { + configuration: serde_json::from_str(&value.configuration)?, + request: value.request.into(), + }) + } +} +impl From for extension::TcpArguments { + fn from(value: TcpArguments) -> Self { + Self { + host: value.host.into(), + port: value.port, + timeout: value.timeout, + } + } +} + +impl From for TcpArgumentsTemplate { + fn from(value: extension::TcpArgumentsTemplate) -> Self { + Self { + host: value.host.map(Ipv4Addr::to_bits), + port: value.port, + timeout: value.timeout, + } + } +} + +impl From for extension::TcpArgumentsTemplate { + fn from(value: TcpArgumentsTemplate) -> Self { + Self { + host: value.host.map(Ipv4Addr::from_bits), + port: value.port, + timeout: value.timeout, + } + } +} + +impl TryFrom for DebugTaskDefinition { + type Error = anyhow::Error; + fn try_from(value: extension::DebugTaskDefinition) -> Result { + Ok(Self { + label: value.label.to_string(), + adapter: value.adapter.to_string(), + config: value.config.to_string(), + tcp_connection: value.tcp_connection.map(Into::into), + }) + } +} + +impl From for DebugRequest { + fn from(value: task::DebugRequest) -> Self { + match value { + task::DebugRequest::Launch(launch_request) => Self::Launch(launch_request.into()), + task::DebugRequest::Attach(attach_request) => Self::Attach(attach_request.into()), + } + } +} + +impl From for task::DebugRequest { + fn from(value: DebugRequest) -> Self { + match value { + DebugRequest::Launch(launch_request) => Self::Launch(launch_request.into()), + DebugRequest::Attach(attach_request) => Self::Attach(attach_request.into()), + } + } +} + +impl From for LaunchRequest { + fn from(value: task::LaunchRequest) -> Self { + Self { + program: value.program, + cwd: value.cwd.map(|p| p.to_string_lossy().into_owned()), + args: value.args, + envs: value.env.into_iter().collect(), + } + } +} + +impl From for AttachRequest { + fn from(value: task::AttachRequest) -> Self { + Self { + process_id: value.process_id, + } + } +} + +impl From for task::LaunchRequest { + fn from(value: LaunchRequest) -> Self { + Self { + program: value.program, + cwd: value.cwd.map(|p| p.into()), + args: value.args, + env: value.envs.into_iter().collect(), + } + } +} +impl From for task::AttachRequest { + fn from(value: AttachRequest) -> Self { + Self { + process_id: value.process_id, + } + } +} + +impl From for DebugConfig { + fn from(value: ZedDebugConfig) -> Self { + Self { + label: value.label.into(), + adapter: value.adapter.into(), + request: value.request.into(), + stop_on_entry: value.stop_on_entry, + } + } +} +impl TryFrom for extension::DebugAdapterBinary { + type Error = anyhow::Error; + fn try_from(value: DebugAdapterBinary) -> Result { + Ok(Self { + command: value.command, + arguments: value.arguments, + envs: value.envs.into_iter().collect(), + cwd: value.cwd.map(|s| s.into()), + connection: value.connection.map(Into::into), + request_args: value.request_args.try_into()?, + }) + } +} + +impl From for extension::BuildTaskDefinition { + fn from(value: BuildTaskDefinition) -> Self { + match value { + BuildTaskDefinition::ByName(name) => Self::ByName(name.into()), + BuildTaskDefinition::Template(build_task_template) => Self::Template { + task_template: build_task_template.template.into(), + locator_name: build_task_template.locator_name.map(SharedString::from), + }, + } + } +} + +impl From for BuildTaskDefinition { + fn from(value: extension::BuildTaskDefinition) -> Self { + match value { + extension::BuildTaskDefinition::ByName(name) => Self::ByName(name.into()), + extension::BuildTaskDefinition::Template { + task_template, + locator_name, + } => Self::Template(BuildTaskDefinitionTemplatePayload { + template: task_template.into(), + locator_name: locator_name.map(String::from), + }), + } + } +} +impl From for extension::BuildTaskTemplate { + fn from(value: BuildTaskTemplate) -> Self { + Self { + label: value.label, + command: value.command, + args: value.args, + env: value.env.into_iter().collect(), + cwd: value.cwd, + ..Default::default() + } + } +} +impl From for BuildTaskTemplate { + fn from(value: extension::BuildTaskTemplate) -> Self { + Self { + label: value.label, + command: value.command, + args: value.args, + env: value.env.into_iter().collect(), + cwd: value.cwd, + } + } +} + +impl TryFrom for extension::DebugScenario { + type Error = anyhow::Error; + + fn try_from(value: DebugScenario) -> std::result::Result { + Ok(Self { + adapter: value.adapter.into(), + label: value.label.into(), + build: value.build.map(Into::into), + config: serde_json::Value::from_str(&value.config)?, + tcp_connection: value.tcp_connection.map(Into::into), + }) + } +} + +impl From for DebugScenario { + fn from(value: extension::DebugScenario) -> Self { + Self { + adapter: value.adapter.into(), + label: value.label.into(), + build: value.build.map(Into::into), + config: value.config.to_string(), + tcp_connection: value.tcp_connection.map(Into::into), + } + } +} + +impl TryFrom for ResolvedTask { + type Error = anyhow::Error; + + fn try_from(value: SpawnInTerminal) -> Result { + Ok(Self { + label: value.label, + command: value.command.context("missing command")?, + args: value.args, + env: value.env.into_iter().collect(), + cwd: value.cwd.map(|s| { + let s = s.to_string_lossy(); + if cfg!(target_os = "windows") { + s.replace('\\', "/") + } else { + s.into_owned() + } + }), + }) + } +} + +impl From for extension::CodeLabel { + fn from(value: CodeLabel) -> Self { + Self { + code: value.code, + spans: value.spans.into_iter().map(Into::into).collect(), + filter_range: value.filter_range.into(), + } + } +} + +impl From for extension::CodeLabelSpan { + fn from(value: CodeLabelSpan) -> Self { + match value { + CodeLabelSpan::CodeRange(range) => Self::CodeRange(range.into()), + CodeLabelSpan::Literal(literal) => Self::Literal(literal.into()), + } + } +} + +impl From for extension::CodeLabelSpanLiteral { + fn from(value: CodeLabelSpanLiteral) -> Self { + Self { + text: value.text, + highlight_name: value.highlight_name, + } + } +} + +impl From for Completion { + fn from(value: extension::Completion) -> Self { + Self { + label: value.label, + label_details: value.label_details.map(Into::into), + detail: value.detail, + kind: value.kind.map(Into::into), + insert_text_format: value.insert_text_format.map(Into::into), + } + } +} + +impl From for CompletionLabelDetails { + fn from(value: extension::CompletionLabelDetails) -> Self { + Self { + detail: value.detail, + description: value.description, + } + } +} + +impl From for CompletionKind { + fn from(value: extension::CompletionKind) -> Self { + match value { + extension::CompletionKind::Text => Self::Text, + extension::CompletionKind::Method => Self::Method, + extension::CompletionKind::Function => Self::Function, + extension::CompletionKind::Constructor => Self::Constructor, + extension::CompletionKind::Field => Self::Field, + extension::CompletionKind::Variable => Self::Variable, + extension::CompletionKind::Class => Self::Class, + extension::CompletionKind::Interface => Self::Interface, + extension::CompletionKind::Module => Self::Module, + extension::CompletionKind::Property => Self::Property, + extension::CompletionKind::Unit => Self::Unit, + extension::CompletionKind::Value => Self::Value, + extension::CompletionKind::Enum => Self::Enum, + extension::CompletionKind::Keyword => Self::Keyword, + extension::CompletionKind::Snippet => Self::Snippet, + extension::CompletionKind::Color => Self::Color, + extension::CompletionKind::File => Self::File, + extension::CompletionKind::Reference => Self::Reference, + extension::CompletionKind::Folder => Self::Folder, + extension::CompletionKind::EnumMember => Self::EnumMember, + extension::CompletionKind::Constant => Self::Constant, + extension::CompletionKind::Struct => Self::Struct, + extension::CompletionKind::Event => Self::Event, + extension::CompletionKind::Operator => Self::Operator, + extension::CompletionKind::TypeParameter => Self::TypeParameter, + extension::CompletionKind::Other(value) => Self::Other(value), + } + } +} + +impl From for InsertTextFormat { + fn from(value: extension::InsertTextFormat) -> Self { + match value { + extension::InsertTextFormat::PlainText => Self::PlainText, + extension::InsertTextFormat::Snippet => Self::Snippet, + extension::InsertTextFormat::Other(value) => Self::Other(value), + } + } +} + +impl From for Symbol { + fn from(value: extension::Symbol) -> Self { + Self { + kind: value.kind.into(), + name: value.name, + } + } +} + +impl From for SymbolKind { + fn from(value: extension::SymbolKind) -> Self { + match value { + extension::SymbolKind::File => Self::File, + extension::SymbolKind::Module => Self::Module, + extension::SymbolKind::Namespace => Self::Namespace, + extension::SymbolKind::Package => Self::Package, + extension::SymbolKind::Class => Self::Class, + extension::SymbolKind::Method => Self::Method, + extension::SymbolKind::Property => Self::Property, + extension::SymbolKind::Field => Self::Field, + extension::SymbolKind::Constructor => Self::Constructor, + extension::SymbolKind::Enum => Self::Enum, + extension::SymbolKind::Interface => Self::Interface, + extension::SymbolKind::Function => Self::Function, + extension::SymbolKind::Variable => Self::Variable, + extension::SymbolKind::Constant => Self::Constant, + extension::SymbolKind::String => Self::String, + extension::SymbolKind::Number => Self::Number, + extension::SymbolKind::Boolean => Self::Boolean, + extension::SymbolKind::Array => Self::Array, + extension::SymbolKind::Object => Self::Object, + extension::SymbolKind::Key => Self::Key, + extension::SymbolKind::Null => Self::Null, + extension::SymbolKind::EnumMember => Self::EnumMember, + extension::SymbolKind::Struct => Self::Struct, + extension::SymbolKind::Event => Self::Event, + extension::SymbolKind::Operator => Self::Operator, + extension::SymbolKind::TypeParameter => Self::TypeParameter, + extension::SymbolKind::Other(value) => Self::Other(value), + } + } +} + +impl From for SlashCommand { + fn from(value: extension::SlashCommand) -> Self { + Self { + name: value.name, + description: value.description, + tooltip_text: value.tooltip_text, + requires_argument: value.requires_argument, + } + } +} + +impl From for extension::SlashCommandOutput { + fn from(value: SlashCommandOutput) -> Self { + Self { + text: value.text, + sections: value.sections.into_iter().map(Into::into).collect(), + } + } +} + +impl From for extension::SlashCommandOutputSection { + fn from(value: SlashCommandOutputSection) -> Self { + Self { + range: value.range.start as usize..value.range.end as usize, + label: value.label, + } + } +} + +impl From for extension::SlashCommandArgumentCompletion { + fn from(value: SlashCommandArgumentCompletion) -> Self { + Self { + label: value.label, + new_text: value.new_text, + run_command: value.run_command, + } + } +} + +impl TryFrom for extension::ContextServerConfiguration { + type Error = anyhow::Error; + + fn try_from(value: ContextServerConfiguration) -> Result { + let settings_schema: serde_json::Value = serde_json::from_str(&value.settings_schema) + .context("Failed to parse settings_schema")?; + + Ok(Self { + installation_instructions: value.installation_instructions, + default_settings: value.default_settings, + settings_schema, + }) + } +} + +impl HostKeyValueStore for WasmState { + async fn insert( + &mut self, + kv_store: Resource, + key: String, + value: String, + ) -> wasmtime::Result> { + let kv_store = self.table.get(&kv_store)?; + kv_store.insert(key, value).await.to_wasmtime_result() + } + + async fn drop(&mut self, _worktree: Resource) -> Result<()> { + // We only ever hand out borrows of key-value stores. + Ok(()) + } +} + +impl HostProject for WasmState { + async fn worktree_ids( + &mut self, + project: Resource, + ) -> wasmtime::Result> { + let project = self.table.get(&project)?; + Ok(project.worktree_ids()) + } + + async fn drop(&mut self, _project: Resource) -> Result<()> { + // We only ever hand out borrows of projects. + Ok(()) + } +} + +impl HostWorktree for WasmState { + async fn id(&mut self, delegate: Resource>) -> wasmtime::Result { + let delegate = self.table.get(&delegate)?; + Ok(delegate.id()) + } + + async fn root_path( + &mut self, + delegate: Resource>, + ) -> wasmtime::Result { + let delegate = self.table.get(&delegate)?; + Ok(delegate.root_path()) + } + + async fn read_text_file( + &mut self, + delegate: Resource>, + path: String, + ) -> wasmtime::Result> { + let delegate = self.table.get(&delegate)?; + Ok(delegate + .read_text_file(&RelPath::new(Path::new(&path), PathStyle::Posix)?) + .await + .map_err(|error| error.to_string())) + } + + async fn shell_env( + &mut self, + delegate: Resource>, + ) -> wasmtime::Result { + let delegate = self.table.get(&delegate)?; + Ok(delegate.shell_env().await.into_iter().collect()) + } + + async fn which( + &mut self, + delegate: Resource>, + binary_name: String, + ) -> wasmtime::Result> { + let delegate = self.table.get(&delegate)?; + Ok(delegate.which(binary_name).await) + } + + async fn drop(&mut self, _worktree: Resource) -> Result<()> { + // We only ever hand out borrows of worktrees. + Ok(()) + } +} + +impl common::Host for WasmState {} + +impl http_client::Host for WasmState { + async fn fetch( + &mut self, + request: http_client::HttpRequest, + ) -> wasmtime::Result> { + maybe!(async { + let url = &request.url; + let request = convert_request(&request)?; + let mut response = self.host.http_client.send(request).await?; + + if response.status().is_client_error() || response.status().is_server_error() { + bail!("failed to fetch '{url}': status code {}", response.status()) + } + convert_response(&mut response).await + }) + .await + .to_wasmtime_result() + } + + async fn fetch_stream( + &mut self, + request: http_client::HttpRequest, + ) -> wasmtime::Result, String>> { + let request = convert_request(&request)?; + let response = self.host.http_client.send(request); + maybe!(async { + let response = response.await?; + let stream = Arc::new(Mutex::new(response)); + let resource = self.table.push(stream)?; + Ok(resource) + }) + .await + .to_wasmtime_result() + } +} + +impl http_client::HostHttpResponseStream for WasmState { + async fn next_chunk( + &mut self, + resource: Resource, + ) -> wasmtime::Result>, String>> { + let stream = self.table.get(&resource)?.clone(); + maybe!(async move { + let mut response = stream.lock().await; + let mut buffer = vec![0; 8192]; // 8KB buffer + let bytes_read = response.body_mut().read(&mut buffer).await?; + if bytes_read == 0 { + Ok(None) + } else { + buffer.truncate(bytes_read); + Ok(Some(buffer)) + } + }) + .await + .to_wasmtime_result() + } + + async fn drop(&mut self, _resource: Resource) -> Result<()> { + Ok(()) + } +} + +impl From for ::http_client::Method { + fn from(value: http_client::HttpMethod) -> Self { + match value { + http_client::HttpMethod::Get => Self::GET, + http_client::HttpMethod::Post => Self::POST, + http_client::HttpMethod::Put => Self::PUT, + http_client::HttpMethod::Delete => Self::DELETE, + http_client::HttpMethod::Head => Self::HEAD, + http_client::HttpMethod::Options => Self::OPTIONS, + http_client::HttpMethod::Patch => Self::PATCH, + } + } +} + +fn convert_request( + extension_request: &http_client::HttpRequest, +) -> anyhow::Result<::http_client::Request> { + let mut request = ::http_client::Request::builder() + .method(::http_client::Method::from(extension_request.method)) + .uri(&extension_request.url) + .follow_redirects(match extension_request.redirect_policy { + http_client::RedirectPolicy::NoFollow => ::http_client::RedirectPolicy::NoFollow, + http_client::RedirectPolicy::FollowLimit(limit) => { + ::http_client::RedirectPolicy::FollowLimit(limit) + } + http_client::RedirectPolicy::FollowAll => ::http_client::RedirectPolicy::FollowAll, + }); + for (key, value) in &extension_request.headers { + request = request.header(key, value); + } + let body = extension_request + .body + .clone() + .map(AsyncBody::from) + .unwrap_or_default(); + request.body(body).map_err(anyhow::Error::from) +} + +async fn convert_response( + response: &mut ::http_client::Response, +) -> anyhow::Result { + let mut extension_response = http_client::HttpResponse { + body: Vec::new(), + headers: Vec::new(), + }; + + for (key, value) in response.headers() { + extension_response + .headers + .push((key.to_string(), value.to_str().unwrap_or("").to_string())); + } + + response + .body_mut() + .read_to_end(&mut extension_response.body) + .await?; + + Ok(extension_response) +} + +impl nodejs::Host for WasmState { + async fn node_binary_path(&mut self) -> wasmtime::Result> { + self.host + .node_runtime + .binary_path() + .await + .map(|path| path.to_string_lossy().into_owned()) + .to_wasmtime_result() + } + + async fn npm_package_latest_version( + &mut self, + package_name: String, + ) -> wasmtime::Result> { + self.host + .node_runtime + .npm_package_latest_version(&package_name) + .await + .to_wasmtime_result() + } + + async fn npm_package_installed_version( + &mut self, + package_name: String, + ) -> wasmtime::Result, String>> { + self.host + .node_runtime + .npm_package_installed_version(&self.work_dir(), &package_name) + .await + .to_wasmtime_result() + } + + async fn npm_install_package( + &mut self, + package_name: String, + version: String, + ) -> wasmtime::Result> { + self.capability_granter + .grant_npm_install_package(&package_name)?; + + self.host + .node_runtime + .npm_install_packages(&self.work_dir(), &[(&package_name, &version)]) + .await + .to_wasmtime_result() + } +} + +#[async_trait] +impl lsp::Host for WasmState {} + +impl From<::http_client::github::GithubRelease> for github::GithubRelease { + fn from(value: ::http_client::github::GithubRelease) -> Self { + Self { + version: value.tag_name, + assets: value.assets.into_iter().map(Into::into).collect(), + } + } +} + +impl From<::http_client::github::GithubReleaseAsset> for github::GithubReleaseAsset { + fn from(value: ::http_client::github::GithubReleaseAsset) -> Self { + Self { + name: value.name, + download_url: value.browser_download_url, + } + } +} + +impl github::Host for WasmState { + async fn latest_github_release( + &mut self, + repo: String, + options: github::GithubReleaseOptions, + ) -> wasmtime::Result> { + maybe!(async { + let release = ::http_client::github::latest_github_release( + &repo, + options.require_assets, + options.pre_release, + self.host.http_client.clone(), + ) + .await?; + Ok(release.into()) + }) + .await + .to_wasmtime_result() + } + + async fn github_release_by_tag_name( + &mut self, + repo: String, + tag: String, + ) -> wasmtime::Result> { + maybe!(async { + let release = ::http_client::github::get_release_by_tag_name( + &repo, + &tag, + self.host.http_client.clone(), + ) + .await?; + Ok(release.into()) + }) + .await + .to_wasmtime_result() + } +} + +impl platform::Host for WasmState { + async fn current_platform(&mut self) -> Result<(platform::Os, platform::Architecture)> { + Ok(( + match env::consts::OS { + "macos" => platform::Os::Mac, + "linux" => platform::Os::Linux, + "windows" => platform::Os::Windows, + _ => panic!("unsupported os"), + }, + match env::consts::ARCH { + "aarch64" => platform::Architecture::Aarch64, + "x86" => platform::Architecture::X86, + "x86_64" => platform::Architecture::X8664, + _ => panic!("unsupported architecture"), + }, + )) + } +} + +impl From for process::Output { + fn from(output: std::process::Output) -> Self { + Self { + status: output.status.code(), + stdout: output.stdout, + stderr: output.stderr, + } + } +} + +impl process::Host for WasmState { + async fn run_command( + &mut self, + command: process::Command, + ) -> wasmtime::Result> { + maybe!(async { + self.capability_granter + .grant_exec(&command.command, &command.args)?; + + let output = util::command::new_smol_command(command.command.as_str()) + .args(&command.args) + .envs(command.env) + .output() + .await?; + + Ok(output.into()) + }) + .await + .to_wasmtime_result() + } +} + +#[async_trait] +impl slash_command::Host for WasmState {} + +#[async_trait] +impl context_server::Host for WasmState {} + +impl dap::Host for WasmState { + async fn resolve_tcp_template( + &mut self, + template: TcpArgumentsTemplate, + ) -> wasmtime::Result> { + maybe!(async { + let (host, port, timeout) = + ::dap::configure_tcp_connection(task::TcpArgumentsTemplate { + port: template.port, + host: template.host.map(Ipv4Addr::from_bits), + timeout: template.timeout, + }) + .await?; + Ok(TcpArguments { + port, + host: host.to_bits(), + timeout, + }) + }) + .await + .to_wasmtime_result() + } +} + +impl ExtensionImports for WasmState { + async fn get_settings( + &mut self, + location: Option, + category: String, + key: Option, + ) -> wasmtime::Result> { + self.on_main_thread(|cx| { + async move { + let path = location.as_ref().and_then(|location| { + RelPath::new(Path::new(&location.path), PathStyle::Posix).ok() + }); + let location = path + .as_ref() + .zip(location.as_ref()) + .map(|(path, location)| ::settings::SettingsLocation { + worktree_id: WorktreeId::from_proto(location.worktree_id), + path, + }); + + cx.update(|cx| match category.as_str() { + "language" => { + let key = key.map(|k| LanguageName::new(&k)); + let settings = AllLanguageSettings::get(location, cx).language( + location, + key.as_ref(), + cx, + ); + Ok(serde_json::to_string(&settings::LanguageSettings { + tab_size: settings.tab_size, + })?) + } + "lsp" => { + let settings = key + .and_then(|key| { + ProjectSettings::get(location, cx) + .lsp + .get(&::lsp::LanguageServerName::from_proto(key)) + }) + .cloned() + .unwrap_or_default(); + Ok(serde_json::to_string(&settings::LspSettings { + binary: settings.binary.map(|binary| settings::CommandSettings { + path: binary.path, + arguments: binary.arguments, + env: binary.env.map(|env| env.into_iter().collect()), + }), + settings: settings.settings, + initialization_options: settings.initialization_options, + })?) + } + "context_servers" => { + let settings = key + .and_then(|key| { + ProjectSettings::get(location, cx) + .context_servers + .get(key.as_str()) + }) + .cloned() + .unwrap_or_else(|| { + project::project_settings::ContextServerSettings::default_extension( + ) + }); + + match settings { + project::project_settings::ContextServerSettings::Stdio { + enabled: _, + command, + } => Ok(serde_json::to_string(&settings::ContextServerSettings { + command: Some(settings::CommandSettings { + path: command.path.to_str().map(|path| path.to_string()), + arguments: Some(command.args), + env: command.env.map(|env| env.into_iter().collect()), + }), + settings: None, + })?), + project::project_settings::ContextServerSettings::Extension { + enabled: _, + settings, + } => Ok(serde_json::to_string(&settings::ContextServerSettings { + command: None, + settings: Some(settings), + })?), + project::project_settings::ContextServerSettings::Http { .. } => { + bail!("remote context server settings not supported in 0.6.0") + } + } + } + _ => { + bail!("Unknown settings category: {}", category); + } + }) + } + .boxed_local() + }) + .await? + .to_wasmtime_result() + } + + async fn set_language_server_installation_status( + &mut self, + server_name: String, + status: LanguageServerInstallationStatus, + ) -> wasmtime::Result<()> { + let status = match status { + LanguageServerInstallationStatus::CheckingForUpdate => BinaryStatus::CheckingForUpdate, + LanguageServerInstallationStatus::Downloading => BinaryStatus::Downloading, + LanguageServerInstallationStatus::None => BinaryStatus::None, + LanguageServerInstallationStatus::Failed(error) => BinaryStatus::Failed { error }, + }; + + self.host + .proxy + .update_language_server_status(::lsp::LanguageServerName(server_name.into()), status); + + Ok(()) + } + + async fn download_file( + &mut self, + url: String, + path: String, + file_type: DownloadedFileType, + ) -> wasmtime::Result> { + maybe!(async { + let parsed_url = Url::parse(&url)?; + self.capability_granter.grant_download_file(&parsed_url)?; + + let path = PathBuf::from(path); + let extension_work_dir = self.host.work_dir.join(self.manifest.id.as_ref()); + + self.host.fs.create_dir(&extension_work_dir).await?; + + let destination_path = self + .host + .writeable_path_from_extension(&self.manifest.id, &path)?; + + let mut response = self + .host + .http_client + .get(&url, Default::default(), true) + .await + .context("downloading release")?; + + anyhow::ensure!( + response.status().is_success(), + "download failed with status {}", + response.status() + ); + let body = BufReader::new(response.body_mut()); + + match file_type { + DownloadedFileType::Uncompressed => { + futures::pin_mut!(body); + self.host + .fs + .create_file_with(&destination_path, body) + .await?; + } + DownloadedFileType::Gzip => { + let body = GzipDecoder::new(body); + futures::pin_mut!(body); + self.host + .fs + .create_file_with(&destination_path, body) + .await?; + } + DownloadedFileType::GzipTar => { + let body = GzipDecoder::new(body); + futures::pin_mut!(body); + self.host + .fs + .extract_tar_file(&destination_path, Archive::new(body)) + .await?; + } + DownloadedFileType::Zip => { + futures::pin_mut!(body); + extract_zip(&destination_path, body) + .await + .with_context(|| format!("unzipping {path:?} archive"))?; + } + } + + Ok(()) + }) + .await + .to_wasmtime_result() + } + + async fn make_file_executable(&mut self, path: String) -> wasmtime::Result> { + let path = self + .host + .writeable_path_from_extension(&self.manifest.id, Path::new(&path))?; + + make_file_executable(&path) + .await + .with_context(|| format!("setting permissions for path {path:?}")) + .to_wasmtime_result() + } +} From bcf9142bbcaf53c121251467423cc70660218d85 Mon Sep 17 00:00:00 2001 From: Dino Date: Tue, 2 Dec 2025 22:29:48 +0000 Subject: [PATCH 008/621] Update tree-sitter-bash to 0.25.1 (#44009) With the merging and publishing of https://github.com/tree-sitter/tree-sitter-bash/pull/311 , we can now go ahead and update the version of `tree-sitter-bash` that Zed relies on to the latest version. Closes #42091 Release Notes: - Improved grammar for "Shell Script" --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7f4813a3ee430462221732b3f6145170cada155b..eb77b9edfb7bd358c414d3bf9b1f8aec6a05f539 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -18007,9 +18007,9 @@ dependencies = [ [[package]] name = "tree-sitter-bash" -version = "0.25.0" +version = "0.25.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "871b0606e667e98a1237ebdc1b0d7056e0aebfdc3141d12b399865d4cb6ed8a6" +checksum = "9e5ec769279cc91b561d3df0d8a5deb26b0ad40d183127f409494d6d8fc53062" dependencies = [ "cc", "tree-sitter-language", diff --git a/Cargo.toml b/Cargo.toml index b3e77414fe511445a73d3341b53ab8f8f589d884..e73e0108f2726c1223a64ba0221c41d8b4394262 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -672,7 +672,7 @@ toml = "0.8" toml_edit = { version = "0.22", default-features = false, features = ["display", "parse", "serde"] } tower-http = "0.4.4" tree-sitter = { version = "0.25.10", features = ["wasm"] } -tree-sitter-bash = "0.25.0" +tree-sitter-bash = "0.25.1" tree-sitter-c = "0.23" tree-sitter-cpp = { git = "https://github.com/tree-sitter/tree-sitter-cpp", rev = "5cb9b693cfd7bfacab1d9ff4acac1a4150700609" } tree-sitter-css = "0.23" From 22bf449b9e1d605e66e5ebb32588a2def8b6b478 Mon Sep 17 00:00:00 2001 From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Date: Tue, 2 Dec 2025 19:30:18 -0300 Subject: [PATCH 009/621] settings_ui: Fix some non-title case settings items (#44026) Release Notes: - N/A --- crates/settings_ui/src/page_data.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/settings_ui/src/page_data.rs b/crates/settings_ui/src/page_data.rs index fd1bbbcc6e0be6abcfbbdeeb85c0c33203db5ee1..1525271a39776f4b8b456244f40e3dfbc43cbaac 100644 --- a/crates/settings_ui/src/page_data.rs +++ b/crates/settings_ui/src/page_data.rs @@ -6526,7 +6526,7 @@ fn language_settings_data() -> Vec { files: USER | PROJECT, }), SettingsPageItem::SettingItem(SettingItem { - title: "Jsx Tag Auto Close", + title: "JSX Tag Auto Close", description: "Whether to automatically close JSX tags.", field: Box::new(SettingField { json_path: Some("languages.$(language).jsx_tag_auto_close"), @@ -7053,7 +7053,7 @@ fn language_settings_data() -> Vec { files: USER | PROJECT, }), SettingsPageItem::SettingItem(SettingItem { - title: "Colorize brackets", + title: "Colorize Brackets", description: "Whether to colorize brackets in the editor.", field: Box::new(SettingField { json_path: Some("languages.$(language).colorize_brackets"), From 8a12ecf8491663af8e030a6f2ef3e4203239de1b Mon Sep 17 00:00:00 2001 From: Agus Zubiaga Date: Tue, 2 Dec 2025 19:30:43 -0300 Subject: [PATCH 010/621] commit view: Display message within editor (#44024) #42441 moved the commit message out of the multi-buffer editor into its own header element which looks nicer, but unfortunately can make the view become unusable when the commit message is too long since it doesn't scroll with the diff. This PR maintains the metadata in its own element, but moves the commit message back to the editor so the user can scroll past it. This does mean that we lose markdown rendering for now, but we think this is a good solution for the moment. https://github.com/user-attachments/assets/d67cf22e-1a79-451a-932a-cdc8a65e43de Release Notes: - N/A --------- Co-authored-by: cameron --- crates/editor/src/editor.rs | 4 + crates/git_ui/src/commit_view.rs | 303 +++++++++---------------------- 2 files changed, 94 insertions(+), 213 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index babedf1e0829bb1105b2c9c3787d98aa662eedde..6f936a211d3b5eb308b26e4351350666e616bf6c 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -22598,6 +22598,10 @@ impl Editor { } } + pub fn last_gutter_dimensions(&self) -> &GutterDimensions { + &self.gutter_dimensions + } + pub fn wait_for_diff_to_load(&self) -> Option>> { self.load_diff_task.clone() } diff --git a/crates/git_ui/src/commit_view.rs b/crates/git_ui/src/commit_view.rs index 60060a389eea47e8bbcde19b43c823d49f27091e..4f6633a18c031b8f231f43f8b0efc13e7fd710a7 100644 --- a/crates/git_ui/src/commit_view.rs +++ b/crates/git_ui/src/commit_view.rs @@ -1,19 +1,18 @@ use anyhow::{Context as _, Result}; use buffer_diff::{BufferDiff, BufferDiffSnapshot}; -use editor::{Addon, Editor, EditorEvent, MultiBuffer}; +use editor::display_map::{BlockPlacement, BlockProperties, BlockStyle}; +use editor::{Addon, Editor, EditorEvent, ExcerptId, ExcerptRange, MultiBuffer}; use git::repository::{CommitDetails, CommitDiff, RepoPath}; use git::{GitHostingProviderRegistry, GitRemote, parse_git_remote_url}; use gpui::{ AnyElement, App, AppContext as _, Asset, AsyncApp, AsyncWindowContext, Context, Element, Entity, EventEmitter, FocusHandle, Focusable, InteractiveElement, IntoElement, ParentElement, - PromptLevel, Render, Styled, Task, TextStyleRefinement, UnderlineStyle, WeakEntity, Window, - actions, px, + PromptLevel, Render, Styled, Task, WeakEntity, Window, actions, }; use language::{ - Buffer, Capability, DiskState, File, LanguageRegistry, LineEnding, ReplicaId, Rope, TextBuffer, - ToPoint, + Anchor, Buffer, Capability, DiskState, File, LanguageRegistry, LineEnding, ReplicaId, Rope, + TextBuffer, ToPoint, }; -use markdown::{Markdown, MarkdownElement, MarkdownStyle}; use multi_buffer::ExcerptInfo; use multi_buffer::PathKey; use project::{Project, WorktreeId, git_store::Repository}; @@ -63,7 +62,6 @@ pub struct CommitView { multibuffer: Entity, repository: Entity, remote: Option, - markdown: Entity, } struct GitBlob { @@ -167,6 +165,8 @@ impl CommitView { .map(|worktree| worktree.read(cx).id()); let repository_clone = repository.clone(); + let commit_message = commit.message.clone(); + cx.spawn(async move |this, cx| { for file in commit_diff.files { let is_deleted = file.new_text.is_none(); @@ -227,6 +227,58 @@ impl CommitView { }); })?; } + + let message_buffer = cx.new(|cx| { + let mut buffer = Buffer::local(commit_message, cx); + buffer.set_capability(Capability::ReadOnly, cx); + buffer + })?; + + this.update(cx, |this, cx| { + this.multibuffer.update(cx, |multibuffer, cx| { + let range = ExcerptRange { + context: Anchor::MIN..Anchor::MAX, + primary: Anchor::MIN..Anchor::MAX, + }; + multibuffer.insert_excerpts_after( + ExcerptId::min(), + message_buffer.clone(), + [range], + cx, + ) + }); + + this.editor.update(cx, |editor, cx| { + editor.disable_header_for_buffer(message_buffer.read(cx).remote_id(), cx); + + editor.insert_blocks( + [BlockProperties { + placement: BlockPlacement::Above(editor::Anchor::min()), + height: Some(1), + style: BlockStyle::Sticky, + render: Arc::new(|_| gpui::Empty.into_any_element()), + priority: 0, + }] + .into_iter() + .chain( + editor + .buffer() + .read(cx) + .buffer_anchor_to_anchor(&message_buffer, Anchor::MAX, cx) + .map(|anchor| BlockProperties { + placement: BlockPlacement::Below(anchor), + height: Some(1), + style: BlockStyle::Sticky, + render: Arc::new(|_| gpui::Empty.into_any_element()), + priority: 0, + }), + ), + None, + cx, + ) + }); + })?; + anyhow::Ok(()) }) .detach(); @@ -246,14 +298,6 @@ impl CommitView { }) }); - let processed_message = if let Some(ref remote) = remote { - Self::process_github_issues(&commit.message, remote) - } else { - commit.message.to_string() - }; - - let markdown = cx.new(|cx| Markdown::new(processed_message.into(), None, None, cx)); - Self { commit, editor, @@ -261,18 +305,9 @@ impl CommitView { stash, repository, remote, - markdown, } } - fn fallback_commit_avatar() -> AnyElement { - Icon::new(IconName::Person) - .color(Color::Muted) - .size(IconSize::Medium) - .into_element() - .into_any() - } - fn render_commit_avatar( &self, sha: &SharedString, @@ -280,21 +315,34 @@ impl CommitView { window: &mut Window, cx: &mut App, ) -> AnyElement { + let size = size.into(); let remote = self.remote.as_ref().filter(|r| r.host_supports_avatars()); if let Some(remote) = remote { let avatar_asset = CommitAvatarAsset::new(remote.clone(), sha.clone()); if let Some(Some(url)) = window.use_asset::(&avatar_asset, cx) { - Avatar::new(url.to_string()) + return Avatar::new(url.to_string()) .size(size) .into_element() - .into_any() - } else { - Self::fallback_commit_avatar() + .into_any(); } - } else { - Self::fallback_commit_avatar() } + + v_flex() + .w(size) + .h(size) + .border_1() + .border_color(cx.theme().colors().border) + .rounded_full() + .justify_center() + .items_center() + .child( + Icon::new(IconName::Person) + .color(Color::Muted) + .size(IconSize::Medium) + .into_element(), + ) + .into_any() } fn render_header(&self, window: &mut Window, cx: &mut Context) -> impl IntoElement { @@ -322,14 +370,24 @@ impl CommitView { v_flex() .p_4() + .pl_0() .gap_4() .border_b_1() .border_color(cx.theme().colors().border) .child( h_flex() .items_start() - .gap_3() - .child(self.render_commit_avatar(&commit.sha, gpui::rems(3.0), window, cx)) + .child( + h_flex() + .w(self.editor.read(cx).last_gutter_dimensions().full_width()) + .justify_center() + .child(self.render_commit_avatar( + &commit.sha, + gpui::rems(3.0), + window, + cx, + )), + ) .child( v_flex() .gap_1() @@ -353,66 +411,6 @@ impl CommitView { .on_click(move |_, _, cx| cx.open_url(&url)) })), ) - .child(self.render_commit_message(window, cx)) - } - - fn process_github_issues(message: &str, remote: &GitRemote) -> String { - let mut result = String::new(); - let chars: Vec = message.chars().collect(); - let mut i = 0; - - while i < chars.len() { - if chars[i] == '#' && i + 1 < chars.len() && chars[i + 1].is_ascii_digit() { - let mut j = i + 1; - while j < chars.len() && chars[j].is_ascii_digit() { - j += 1; - } - let issue_number = &message[i + 1..i + (j - i)]; - let url = format!( - "{}/{}/{}/issues/{}", - remote.host.base_url().as_str().trim_end_matches('/'), - remote.owner, - remote.repo, - issue_number - ); - result.push_str(&format!("[#{}]({})", issue_number, url)); - i = j; - } else if i + 3 < chars.len() - && chars[i] == 'G' - && chars[i + 1] == 'H' - && chars[i + 2] == '-' - && chars[i + 3].is_ascii_digit() - { - let mut j = i + 3; - while j < chars.len() && chars[j].is_ascii_digit() { - j += 1; - } - let issue_number = &message[i + 3..i + (j - i)]; - let url = format!( - "{}/{}/{}/issues/{}", - remote.host.base_url().as_str().trim_end_matches('/'), - remote.owner, - remote.repo, - issue_number - ); - result.push_str(&format!("[GH-{}]({})", issue_number, url)); - i = j; - } else { - result.push(chars[i]); - i += 1; - } - } - - result - } - - fn render_commit_message( - &self, - window: &mut Window, - cx: &mut Context, - ) -> impl IntoElement { - let style = hover_markdown_style(window, cx); - MarkdownElement::new(self.markdown.clone(), style) } fn apply_stash(workspace: &mut Workspace, window: &mut Window, cx: &mut App) { @@ -963,12 +961,6 @@ impl Item for CommitView { .update(cx, |editor, cx| editor.clone(window, cx)) }); let multibuffer = editor.read(cx).buffer().clone(); - let processed_message = if let Some(ref remote) = self.remote { - Self::process_github_issues(&self.commit.message, remote) - } else { - self.commit.message.to_string() - }; - let markdown = cx.new(|cx| Markdown::new(processed_message.into(), None, None, cx)); Self { editor, multibuffer, @@ -976,7 +968,6 @@ impl Item for CommitView { stash: self.stash, repository: self.repository.clone(), remote: self.remote.clone(), - markdown, } }))) } @@ -1046,117 +1037,3 @@ fn stash_matches_index(sha: &str, stash_index: usize, repo: &Repository) -> bool .map(|entry| entry.oid.to_string() == sha) .unwrap_or(false) } - -fn hover_markdown_style(window: &Window, cx: &App) -> MarkdownStyle { - let colors = cx.theme().colors(); - let mut style = MarkdownStyle::default(); - style.base_text_style = window.text_style(); - style.syntax = cx.theme().syntax().clone(); - style.selection_background_color = colors.element_selection_background; - style.link = TextStyleRefinement { - color: Some(colors.text_accent), - underline: Some(UnderlineStyle { - thickness: px(1.0), - color: Some(colors.text_accent), - wavy: false, - }), - ..Default::default() - }; - style -} - -#[cfg(test)] -mod tests { - use super::*; - use git_hosting_providers::Github; - - fn create_test_remote() -> GitRemote { - GitRemote { - host: Arc::new(Github::public_instance()), - owner: "zed-industries".into(), - repo: "zed".into(), - } - } - - #[test] - fn test_process_github_issues_simple_issue_number() { - let remote = create_test_remote(); - let message = "Fix bug #123"; - let result = CommitView::process_github_issues(message, &remote); - assert_eq!( - result, - "Fix bug [#123](https://github.com/zed-industries/zed/issues/123)" - ); - } - - #[test] - fn test_process_github_issues_multiple_issue_numbers() { - let remote = create_test_remote(); - let message = "Fix #123 and #456"; - let result = CommitView::process_github_issues(message, &remote); - assert_eq!( - result, - "Fix [#123](https://github.com/zed-industries/zed/issues/123) and [#456](https://github.com/zed-industries/zed/issues/456)" - ); - } - - #[test] - fn test_process_github_issues_gh_format() { - let remote = create_test_remote(); - let message = "Fix GH-789"; - let result = CommitView::process_github_issues(message, &remote); - assert_eq!( - result, - "Fix [GH-789](https://github.com/zed-industries/zed/issues/789)" - ); - } - - #[test] - fn test_process_github_issues_mixed_formats() { - let remote = create_test_remote(); - let message = "Fix #123 and GH-456"; - let result = CommitView::process_github_issues(message, &remote); - assert_eq!( - result, - "Fix [#123](https://github.com/zed-industries/zed/issues/123) and [GH-456](https://github.com/zed-industries/zed/issues/456)" - ); - } - - #[test] - fn test_process_github_issues_no_issues() { - let remote = create_test_remote(); - let message = "This is a commit message without any issues"; - let result = CommitView::process_github_issues(message, &remote); - assert_eq!(result, message); - } - - #[test] - fn test_process_github_issues_hash_without_number() { - let remote = create_test_remote(); - let message = "Use # for comments"; - let result = CommitView::process_github_issues(message, &remote); - assert_eq!(result, message); - } - - #[test] - fn test_process_github_issues_consecutive_issues() { - let remote = create_test_remote(); - let message = "#123#456"; - let result = CommitView::process_github_issues(message, &remote); - assert_eq!( - result, - "[#123](https://github.com/zed-industries/zed/issues/123)[#456](https://github.com/zed-industries/zed/issues/456)" - ); - } - - #[test] - fn test_process_github_issues_multiline() { - let remote = create_test_remote(); - let message = "Fix #123\n\nThis also fixes #456"; - let result = CommitView::process_github_issues(message, &remote); - assert_eq!( - result, - "Fix [#123](https://github.com/zed-industries/zed/issues/123)\n\nThis also fixes [#456](https://github.com/zed-industries/zed/issues/456)" - ); - } -} From b4e1d86a1631f37026f201ce64fbaaa54af2de44 Mon Sep 17 00:00:00 2001 From: Mikhail Pertsev Date: Tue, 2 Dec 2025 23:44:03 +0100 Subject: [PATCH 011/621] git: Use UI font in commit and blame popovers (#43975) Closes #30353 Release Notes: - Fixed: Hover tooltips in git commit and blame popovers now consistently use the UI font --- crates/git_ui/src/blame_ui.rs | 3 --- crates/git_ui/src/commit_tooltip.rs | 5 +---- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/crates/git_ui/src/blame_ui.rs b/crates/git_ui/src/blame_ui.rs index d3f89831898c4ef3e3fa5c088d0094c0efa6e8b5..47703e09824a49c633798c7967652d7f48f821be 100644 --- a/crates/git_ui/src/blame_ui.rs +++ b/crates/git_ui/src/blame_ui.rs @@ -198,9 +198,6 @@ impl BlameRenderer for GitBlameRenderer { let link_color = cx.theme().colors().text_accent; let markdown_style = { let mut style = hover_markdown_style(window, cx); - if let Some(code_block) = &style.code_block.text { - style.base_text_style.refine(code_block); - } style.link.refine(&TextStyleRefinement { color: Some(link_color), underline: Some(UnderlineStyle { diff --git a/crates/git_ui/src/commit_tooltip.rs b/crates/git_ui/src/commit_tooltip.rs index 26bd42c6549457df0f530580bbfc838797134860..6dfe92427df5b9fd5aa051aeb1635b2e782ad3a4 100644 --- a/crates/git_ui/src/commit_tooltip.rs +++ b/crates/git_ui/src/commit_tooltip.rs @@ -197,10 +197,7 @@ impl Render for CommitTooltip { time_format::TimestampFormat::MediumAbsolute, ); let markdown_style = { - let mut style = hover_markdown_style(window, cx); - if let Some(code_block) = &style.code_block.text { - style.base_text_style.refine(code_block); - } + let style = hover_markdown_style(window, cx); style }; From 39536cae83756ba36bfb334b8b7429bd04ddb584 Mon Sep 17 00:00:00 2001 From: "Joseph T. Lyons" Date: Tue, 2 Dec 2025 17:44:22 -0500 Subject: [PATCH 012/621] docs: Add Conda package to Linux community-maintained packages list (#44029) Release Notes: - N/A --- docs/src/linux.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/src/linux.md b/docs/src/linux.md index 715b3a1bab4b6d580886207b50f54b741f72e5c2..b535a5e78a8c82892602f016ecea1b333447a0c9 100644 --- a/docs/src/linux.md +++ b/docs/src/linux.md @@ -41,6 +41,7 @@ There are several third-party Zed packages for various Linux distributions and p - Arch: [`zed`](https://archlinux.org/packages/extra/x86_64/zed/) - Arch (AUR): [`zed-git`](https://aur.archlinux.org/packages/zed-git), [`zed-preview`](https://aur.archlinux.org/packages/zed-preview), [`zed-preview-bin`](https://aur.archlinux.org/packages/zed-preview-bin) - Alpine: `zed` ([aarch64](https://pkgs.alpinelinux.org/package/edge/testing/aarch64/zed)) ([x86_64](https://pkgs.alpinelinux.org/package/edge/testing/x86_64/zed)) +- Conda: [`zed`](https://anaconda.org/conda-forge/zed) - Nix: `zed-editor` ([unstable](https://search.nixos.org/packages?channel=unstable&show=zed-editor)) - Fedora/Ultramarine (Terra): [`zed`](https://github.com/terrapkg/packages/tree/frawhide/anda/devs/zed/stable), [`zed-preview`](https://github.com/terrapkg/packages/tree/frawhide/anda/devs/zed/preview), [`zed-nightly`](https://github.com/terrapkg/packages/tree/frawhide/anda/devs/zed/nightly) - Solus: [`zed`](https://github.com/getsolus/packages/tree/main/packages/z/zed) From 98dec9246e10d7d7606e676c4e44be15fa490de3 Mon Sep 17 00:00:00 2001 From: Marshall Bowers Date: Tue, 2 Dec 2025 18:28:30 -0500 Subject: [PATCH 013/621] zed: Promote comment to a doc comment (#44031) This PR promotes a line comment above a variant member to a doc comment, so that the docs show up on hover. Release Notes: - N/A --- crates/zed/src/zed/open_listener.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/zed/src/zed/open_listener.rs b/crates/zed/src/zed/open_listener.rs index 13b636731798ebe13bb7c9ae8d97bf52356ea0b2..5e855aa5a949254ba32658c26a59c48c7413844e 100644 --- a/crates/zed/src/zed/open_listener.rs +++ b/crates/zed/src/zed/open_listener.rs @@ -54,7 +54,7 @@ pub enum OpenRequestKind { schema_path: String, }, Setting { - // None just opens settings without navigating to a specific path + /// `None` opens settings without navigating to a specific path. setting_path: Option, }, } From 65b4e9b10ac0bf588f5b90fb65e500e27ae7123d Mon Sep 17 00:00:00 2001 From: Rani Malach <137104974+Rani367@users.noreply.github.com> Date: Wed, 3 Dec 2025 01:44:08 +0200 Subject: [PATCH 014/621] extensions_ui: Add upsell banners for integrated extensions (#43872) Add informational banners for extensions that have been integrated into Zed core: - Basedpyright (Python language server) - Ruff (Python linter) - Ty (Python language server) These banners appear when users search for these extensions, informing them that the functionality is now built-in and linking to relevant documentation. The banners trigger when: - Users search by extension ID (e.g., 'id:ruff') - Users search using relevant keywords (e.g., 'basedpyright', 'pyright', 'ruff', 'ty') Supersedes #43844 Closes #43837 Release Notes: - Added banners to the extensions page when searching for Basedpyright, Ruff, or Ty, indicating that these features are now built-in. --------- Co-authored-by: Marshall Bowers --- crates/extensions_ui/src/extensions_ui.rs | 36 +++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/crates/extensions_ui/src/extensions_ui.rs b/crates/extensions_ui/src/extensions_ui.rs index e6d30527e0d7672255bf8f61cfd56fe06b409920..11a5d1797a7173a9b5d23e2eae19bf028f37d7ed 100644 --- a/crates/extensions_ui/src/extensions_ui.rs +++ b/crates/extensions_ui/src/extensions_ui.rs @@ -229,8 +229,10 @@ enum Feature { AgentClaude, AgentCodex, AgentGemini, + ExtensionBasedpyright, ExtensionRuff, ExtensionTailwind, + ExtensionTy, Git, LanguageBash, LanguageC, @@ -251,8 +253,13 @@ fn keywords_by_feature() -> &'static BTreeMap> { (Feature::AgentClaude, vec!["claude", "claude code"]), (Feature::AgentCodex, vec!["codex", "codex cli"]), (Feature::AgentGemini, vec!["gemini", "gemini cli"]), + ( + Feature::ExtensionBasedpyright, + vec!["basedpyright", "pyright"], + ), (Feature::ExtensionRuff, vec!["ruff"]), (Feature::ExtensionTailwind, vec!["tail", "tailwind"]), + (Feature::ExtensionTy, vec!["ty"]), (Feature::Git, vec!["git"]), (Feature::LanguageBash, vec!["sh", "bash"]), (Feature::LanguageC, vec!["c", "clang"]), @@ -1364,6 +1371,23 @@ impl ExtensionsPage { return; }; + if let Some(id) = search.strip_prefix("id:") { + self.upsells.clear(); + + let upsell = match id.to_lowercase().as_str() { + "ruff" => Some(Feature::ExtensionRuff), + "basedpyright" => Some(Feature::ExtensionBasedpyright), + "ty" => Some(Feature::ExtensionTy), + _ => None, + }; + + if let Some(upsell) = upsell { + self.upsells.insert(upsell); + } + + return; + } + let search = search.to_lowercase(); let search_terms = search .split_whitespace() @@ -1482,6 +1506,12 @@ impl ExtensionsPage { false, cx, ), + Feature::ExtensionBasedpyright => self.render_feature_upsell_banner( + "Basedpyright (Python language server) support is built-in to Zed!".into(), + "https://zed.dev/docs/languages/python#basedpyright".into(), + false, + cx, + ), Feature::ExtensionRuff => self.render_feature_upsell_banner( "Ruff (linter for Python) support is built-in to Zed!".into(), "https://zed.dev/docs/languages/python#code-formatting--linting".into(), @@ -1494,6 +1524,12 @@ impl ExtensionsPage { false, cx, ), + Feature::ExtensionTy => self.render_feature_upsell_banner( + "Ty (Python language server) support is built-in to Zed!".into(), + "https://zed.dev/docs/languages/python".into(), + false, + cx, + ), Feature::Git => self.render_feature_upsell_banner( "Zed comes with basic Git support—more features are coming in the future." .into(), From 2bf47879dee6dc8c21613b83e058a1dd4b9bde29 Mon Sep 17 00:00:00 2001 From: "Joseph T. Lyons" Date: Tue, 2 Dec 2025 20:47:01 -0500 Subject: [PATCH 015/621] Hide "File History" for untracked files in Git Panel context menu (#44035) --- crates/git_ui/src/git_panel.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs index 092768c2cd97fa82079979301704ee66c969196e..bd17788506faa62f33618d4450000af1e7b8aec9 100644 --- a/crates/git_ui/src/git_panel.rs +++ b/crates/git_ui/src/git_panel.rs @@ -4011,15 +4011,21 @@ impl GitPanel { if entry.status.is_created() { context_menu = - context_menu.action("Add to .gitignore", git::AddToGitignore.boxed_clone()); + context_menu.action("Add to .gitignore", git::AddToGitignore.boxed_clone()) } - context_menu + let mut context_menu = context_menu .separator() .action("Open Diff", Confirm.boxed_clone()) - .action("Open File", SecondaryConfirm.boxed_clone()) - .separator() - .action("File History", Box::new(git::FileHistory)) + .action("Open File", SecondaryConfirm.boxed_clone()); + + if !entry.status.is_created() { + context_menu = context_menu + .separator() + .action("File History", Box::new(git::FileHistory)); + } + + context_menu }); self.selected_entry = Some(ix); self.set_context_menu(context_menu, position, window, cx); From ad51017f20d8e3ae07e5127cceb2abebbba6ebe0 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Wed, 3 Dec 2025 10:27:55 +0200 Subject: [PATCH 016/621] Properly filter out the greedy bracket pairs (#44022) Follow-up of https://github.com/zed-industries/zed/pull/43607 Release Notes: - N/A --- crates/editor/src/bracket_colorization.rs | 13 ++ crates/language/src/buffer.rs | 153 +++++++++------------- 2 files changed, 78 insertions(+), 88 deletions(-) diff --git a/crates/editor/src/bracket_colorization.rs b/crates/editor/src/bracket_colorization.rs index 053ddbc002a95ee65ca34088310afb16a1141b82..e4933b3ad5d8a2cae80e882abaa2eb34dfd3a429 100644 --- a/crates/editor/src/bracket_colorization.rs +++ b/crates/editor/src/bracket_colorization.rs @@ -333,6 +333,19 @@ where &bracket_colors_markup(&mut cx), "All markdown brackets should be colored based on their depth" ); + + cx.set_state(indoc! {r#"ˇ{{}}"#}); + cx.executor().advance_clock(Duration::from_millis(100)); + cx.executor().run_until_parked(); + + assert_eq!( + r#"«1{«2{}2»}1» +1 hsla(207.80, 16.20%, 69.19%, 1.00) +2 hsla(29.00, 54.00%, 65.88%, 1.00) +"#, + &bracket_colors_markup(&mut cx), + "All markdown brackets should be colored based on their depth, again" + ); } #[gpui::test] diff --git a/crates/language/src/buffer.rs b/crates/language/src/buffer.rs index 46d7f655627e1c01612b703a64bc0ab58d1b6669..c6eb3ff66b08b03f39466af4a8b65805003a8bd3 100644 --- a/crates/language/src/buffer.rs +++ b/crates/language/src/buffer.rs @@ -32,7 +32,6 @@ use gpui::{ Task, TaskLabel, TextStyle, }; -use itertools::Itertools; use lsp::{LanguageServerId, NumberOrString}; use parking_lot::{Mutex, RawMutex, lock_api::MutexGuard}; use serde::{Deserialize, Serialize}; @@ -45,7 +44,7 @@ use std::{ borrow::Cow, cell::Cell, cmp::{self, Ordering, Reverse}, - collections::{BTreeMap, BTreeSet, hash_map}, + collections::{BTreeMap, BTreeSet}, future::Future, iter::{self, Iterator, Peekable}, mem, @@ -4284,7 +4283,6 @@ impl BufferSnapshot { let mut new_bracket_matches = HashMap::default(); let mut all_bracket_matches = HashMap::default(); - let mut bracket_matches_to_color = HashMap::default(); for chunk in tree_sitter_data .chunks @@ -4301,7 +4299,10 @@ impl BufferSnapshot { let bracket_matches = match tree_sitter_data.brackets_by_chunks[chunk.id].take() { Some(cached_brackets) => cached_brackets, None => { - let mut bracket_pairs_ends = Vec::new(); + let mut all_brackets = Vec::new(); + let mut opens = Vec::new(); + let mut color_pairs = Vec::new(); + let mut matches = self.syntax .matches(chunk_range.clone(), &self.text, |grammar| { @@ -4313,100 +4314,76 @@ impl BufferSnapshot { .map(|grammar| grammar.brackets_config.as_ref().unwrap()) .collect::>(); - let chunk_range = chunk_range.clone(); - let tree_sitter_matches = iter::from_fn(|| { - while let Some(mat) = matches.peek() { - let mut open = None; - let mut close = None; - let depth = mat.depth; - let config = configs[mat.grammar_index]; - let pattern = &config.patterns[mat.pattern_index]; - for capture in mat.captures { - if capture.index == config.open_capture_ix { - open = Some(capture.node.byte_range()); - } else if capture.index == config.close_capture_ix { - close = Some(capture.node.byte_range()); - } + while let Some(mat) = matches.peek() { + let mut open = None; + let mut close = None; + let syntax_layer_depth = mat.depth; + let config = configs[mat.grammar_index]; + let pattern = &config.patterns[mat.pattern_index]; + for capture in mat.captures { + if capture.index == config.open_capture_ix { + open = Some(capture.node.byte_range()); + } else if capture.index == config.close_capture_ix { + close = Some(capture.node.byte_range()); } + } - matches.advance(); + matches.advance(); - let Some((open_range, close_range)) = open.zip(close) else { - continue; - }; + let Some((open_range, close_range)) = open.zip(close) else { + continue; + }; - let bracket_range = open_range.start..=close_range.end; - if !bracket_range.overlaps(&chunk_range) { - continue; - } + let bracket_range = open_range.start..=close_range.end; + if !bracket_range.overlaps(&chunk_range) { + continue; + } - if !pattern.rainbow_exclude - // Also, certain languages have "brackets" that are not brackets, e.g. tags. and such - // bracket will match the entire tag with all text inside. - // For now, avoid highlighting any pair that has more than single char in each bracket. - // We need to colorize `` bracket pairs, so cannot make this check stricter. - && (open_range.len() == 1 || close_range.len() == 1) - { - // Certain tree-sitter grammars may return more bracket pairs than needed: - // see `test_markdown_bracket_colorization` for a set-up that returns pairs with the same start bracket and different end one. - // Pick the pair with the shortest range in case of ambiguity. - match bracket_matches_to_color.entry(open_range.clone()) { - hash_map::Entry::Vacant(v) => { - v.insert(close_range.clone()); - } - hash_map::Entry::Occupied(mut o) => { - let previous_close_range = o.get(); - let previous_length = - previous_close_range.end - open_range.start; - let new_length = close_range.end - open_range.start; - if new_length < previous_length { - o.insert(close_range.clone()); - } - } - } - } - return Some((open_range, close_range, pattern, depth)); + let index = all_brackets.len(); + all_brackets.push(BracketMatch { + open_range: open_range.clone(), + close_range: close_range.clone(), + newline_only: pattern.newline_only, + syntax_layer_depth, + color_index: None, + }); + + // Certain languages have "brackets" that are not brackets, e.g. tags. and such + // bracket will match the entire tag with all text inside. + // For now, avoid highlighting any pair that has more than single char in each bracket. + // We need to colorize `` bracket pairs, so cannot make this check stricter. + let should_color = !pattern.rainbow_exclude + && (open_range.len() == 1 || close_range.len() == 1); + if should_color { + opens.push(open_range.clone()); + color_pairs.push((open_range, close_range, index)); } - None - }) - .sorted_by_key(|(open_range, _, _, _)| open_range.start) - .collect::>(); + } - let new_matches = tree_sitter_matches - .into_iter() - .map(|(open_range, close_range, pattern, syntax_layer_depth)| { - let participates_in_colorizing = - bracket_matches_to_color.get(&open_range).is_some_and( - |close_range_to_color| close_range_to_color == &close_range, - ); - let color_index = if participates_in_colorizing { - while let Some(&last_bracket_end) = bracket_pairs_ends.last() { - if last_bracket_end <= open_range.start { - bracket_pairs_ends.pop(); - } else { - break; - } - } + opens.sort_by_key(|r| (r.start, r.end)); + opens.dedup_by(|a, b| a.start == b.start && a.end == b.end); + color_pairs.sort_by_key(|(_, close, _)| close.end); - let bracket_depth = bracket_pairs_ends.len(); - bracket_pairs_ends.push(close_range.end); - Some(bracket_depth) - } else { - None - }; + let mut open_stack = Vec::new(); + let mut open_index = 0; + for (open, close, index) in color_pairs { + while open_index < opens.len() && opens[open_index].start < close.start { + open_stack.push(opens[open_index].clone()); + open_index += 1; + } - BracketMatch { - open_range, - close_range, - syntax_layer_depth, - newline_only: pattern.newline_only, - color_index, - } - }) - .collect::>(); + if open_stack.last() == Some(&open) { + let depth_index = open_stack.len() - 1; + all_brackets[index].color_index = Some(depth_index); + open_stack.pop(); + } + } - new_bracket_matches.insert(chunk.id, new_matches.clone()); - new_matches + all_brackets.sort_by_key(|bracket_match| { + (bracket_match.open_range.start, bracket_match.open_range.end) + }); + new_bracket_matches.insert(chunk.id, all_brackets.clone()); + all_brackets } }; all_bracket_matches.insert(chunk.row_range(), bracket_matches); From 9857fd233dc22cc2c44fc5c12d8d8620154d0a73 Mon Sep 17 00:00:00 2001 From: lipcut <96253127+lipcut@users.noreply.github.com> Date: Wed, 3 Dec 2025 16:30:54 +0800 Subject: [PATCH 017/621] Make highlighting of C preprocessing directive same as C++ (#44043) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Small fix for consistency between C and C++ highlighting. Related to https://github.com/zed-industries/zed/issues/9461 Release Notes: - Change syntax highlighting for preprocessing directive in C so it can be configured with `keyword.directive` instead of being treated as other `keyword`. The behavior should be like the C++ one now. 圖片 --- crates/languages/src/c/highlights.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/languages/src/c/highlights.scm b/crates/languages/src/c/highlights.scm index 40e0d7147e98287f5ed7587d690e25bc8bacaa0b..46c970e69d97a232dc9d83aa6b9470de74f74833 100644 --- a/crates/languages/src/c/highlights.scm +++ b/crates/languages/src/c/highlights.scm @@ -36,7 +36,7 @@ "#ifndef" "#include" (preproc_directive) -] @keyword +] @keyword.directive [ "=" From 50d0f29624e8a0264fa65ee21733a6e1844e9934 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Wed, 3 Dec 2025 11:29:18 +0100 Subject: [PATCH 018/621] languages: Fix python run module task failing on windows (#44064) Fixes #40155 Release Notes: - Fixed python's run module task not working on windows platforms Co-authored by: Smit Barmase --- crates/languages/src/python.rs | 58 ++++++++++++++++++++++++++++------ 1 file changed, 48 insertions(+), 10 deletions(-) diff --git a/crates/languages/src/python.rs b/crates/languages/src/python.rs index 56512ee8af39df52283aa88d6885a192732ed020..bcdc7969b4f2b22f5136c733afd477f7d0cf0187 100644 --- a/crates/languages/src/python.rs +++ b/crates/languages/src/python.rs @@ -28,6 +28,7 @@ use std::env::consts; use terminal::terminal_settings::TerminalSettings; use util::command::new_smol_command; use util::fs::{make_file_executable, remove_matching}; +use util::paths::PathStyle; use util::rel_path::RelPath; use http_client::github_download::{GithubBinaryMetadata, download_server_binary}; @@ -884,7 +885,7 @@ impl PythonContextProvider { variables: &task::TaskVariables, ) -> Option<(VariableName, String)> { let python_module_name = - python_module_name_from_relative_path(variables.get(&VariableName::RelativeFile)?); + python_module_name_from_relative_path(variables.get(&VariableName::RelativeFile)?)?; let unittest_class_name = variables.get(&VariableName::Custom(Cow::Borrowed("_unittest_class_name"))); @@ -941,9 +942,10 @@ impl PythonContextProvider { &self, variables: &task::TaskVariables, ) -> Result<(VariableName, String)> { - let python_module_name = python_module_name_from_relative_path( - variables.get(&VariableName::RelativeFile).unwrap_or(""), - ); + let python_module_name = variables + .get(&VariableName::RelativeFile) + .and_then(|module| python_module_name_from_relative_path(module)) + .unwrap_or_default(); let module_target = (PYTHON_MODULE_NAME_TASK_VARIABLE.clone(), python_module_name); @@ -951,12 +953,15 @@ impl PythonContextProvider { } } -fn python_module_name_from_relative_path(relative_path: &str) -> String { - let path_with_dots = relative_path.replace('/', "."); - path_with_dots - .strip_suffix(".py") - .unwrap_or(&path_with_dots) - .to_string() +fn python_module_name_from_relative_path(relative_path: &str) -> Option { + let rel_path = RelPath::new(relative_path.as_ref(), PathStyle::local()).ok()?; + let path_with_dots = rel_path.display(PathStyle::Posix).replace('/', "."); + Some( + path_with_dots + .strip_suffix(".py") + .map(ToOwned::to_owned) + .unwrap_or(path_with_dots), + ) } fn is_python_env_global(k: &PythonEnvironmentKind) -> bool { @@ -2311,6 +2316,8 @@ mod tests { use settings::SettingsStore; use std::num::NonZeroU32; + use crate::python::python_module_name_from_relative_path; + #[gpui::test] async fn test_python_autoindent(cx: &mut TestAppContext) { cx.executor().set_block_on_ticks(usize::MAX..=usize::MAX); @@ -2439,4 +2446,35 @@ mod tests { buffer }); } + + #[test] + fn test_python_module_name_from_relative_path() { + assert_eq!( + python_module_name_from_relative_path("foo/bar.py"), + Some("foo.bar".to_string()) + ); + assert_eq!( + python_module_name_from_relative_path("foo/bar"), + Some("foo.bar".to_string()) + ); + if cfg!(windows) { + assert_eq!( + python_module_name_from_relative_path("foo\\bar.py"), + Some("foo.bar".to_string()) + ); + assert_eq!( + python_module_name_from_relative_path("foo\\bar"), + Some("foo.bar".to_string()) + ); + } else { + assert_eq!( + python_module_name_from_relative_path("foo\\bar.py"), + Some("foo\\bar".to_string()) + ); + assert_eq!( + python_module_name_from_relative_path("foo\\bar"), + Some("foo\\bar".to_string()) + ); + } + } } From fe6fa1bbdce5ff89d5b9942f9a17a87d72557078 Mon Sep 17 00:00:00 2001 From: Ben Brandt Date: Wed, 3 Dec 2025 12:11:23 +0100 Subject: [PATCH 019/621] Revert "acp: Add a timeout when initializing an ACP agent so the user isn't waiting forever" (#44066) Reverts zed-industries/zed#43663 --- crates/agent_ui/src/acp/thread_view.rs | 62 +------------------------- 1 file changed, 1 insertion(+), 61 deletions(-) diff --git a/crates/agent_ui/src/acp/thread_view.rs b/crates/agent_ui/src/acp/thread_view.rs index a9b4127ea97f62dde3cb2af299050bc0e06a06bc..9c4717c5189eb3397ec153560156d9c77e5125ba 100644 --- a/crates/agent_ui/src/acp/thread_view.rs +++ b/crates/agent_ui/src/acp/thread_view.rs @@ -498,17 +498,7 @@ impl AcpThreadView { Some(new_version_available_tx), ); - let agent_name = agent.name(); - let timeout = cx.background_executor().timer(Duration::from_secs(30)); - let connect_task = smol::future::or( - agent.connect(root_dir.as_deref(), delegate, cx), - async move { - timeout.await; - Err(anyhow::Error::new(LoadError::Other( - format!("{agent_name} is unable to initialize after 30 seconds.").into(), - ))) - }, - ); + let connect_task = agent.connect(root_dir.as_deref(), delegate, cx); let load_task = cx.spawn_in(window, async move |this, cx| { let connection = match connect_task.await { Ok((connection, login)) => { @@ -7399,54 +7389,4 @@ pub(crate) mod tests { assert_eq!(text, expected_txt); }) } - - #[gpui::test] - async fn test_initialize_timeout(cx: &mut TestAppContext) { - init_test(cx); - - struct InfiniteInitialize; - - impl AgentServer for InfiniteInitialize { - fn telemetry_id(&self) -> &'static str { - "test" - } - - fn logo(&self) -> ui::IconName { - ui::IconName::Ai - } - - fn name(&self) -> SharedString { - "Test".into() - } - - fn connect( - &self, - _root_dir: Option<&Path>, - _delegate: AgentServerDelegate, - cx: &mut App, - ) -> Task, Option)>> - { - cx.spawn(async |_| futures::future::pending().await) - } - - fn into_any(self: Rc) -> Rc { - self - } - } - - let (thread_view, cx) = setup_thread_view(InfiniteInitialize, cx).await; - - cx.executor().advance_clock(Duration::from_secs(31)); - cx.run_until_parked(); - - let error = thread_view.read_with(cx, |thread_view, _| match &thread_view.thread_state { - ThreadState::LoadError(err) => err.clone(), - _ => panic!("Incorrect thread state"), - }); - - match error { - LoadError::Other(str) => assert!(str.contains("initialize")), - _ => panic!("Unexpected load error"), - } - } } From 0f67f08795eb7e97ca4003eac7974b9d8bd965f9 Mon Sep 17 00:00:00 2001 From: Ben Brandt Date: Wed, 3 Dec 2025 12:24:08 +0100 Subject: [PATCH 020/621] Update to ACP SDK v0.8.0 (#44063) Uses the latest version of the SDK + schema crate. A bit painful because we needed to move to `#[non_exhaustive]` on all of these structs/enums, but will be much easier going forward. Also, since we depend on unstable features, I am pinning the version so we don't accidentally introduce compilation errors from other update cycles. Release Notes: - N/A --- Cargo.lock | 9 +- Cargo.toml | 2 +- crates/acp_thread/src/acp_thread.rs | 420 +++++++------------- crates/acp_thread/src/connection.rs | 26 +- crates/acp_thread/src/mention.rs | 2 +- crates/acp_thread/src/terminal.rs | 44 +- crates/agent/src/agent.rs | 55 +-- crates/agent/src/db.rs | 2 +- crates/agent/src/history_store.rs | 6 +- crates/agent/src/tests/mod.rs | 100 ++--- crates/agent/src/thread.rs | 210 ++++------ crates/agent/src/tools/edit_file_tool.rs | 20 +- crates/agent/src/tools/find_path_tool.rs | 50 ++- crates/agent/src/tools/read_file_tool.rs | 22 +- crates/agent/src/tools/terminal_tool.rs | 7 +- crates/agent/src/tools/thinking_tool.rs | 6 +- crates/agent/src/tools/web_search_tool.rs | 47 +-- crates/agent_servers/src/acp.rs | 218 ++++------ crates/agent_servers/src/claude.rs | 4 +- crates/agent_servers/src/codex.rs | 4 +- crates/agent_servers/src/custom.rs | 4 +- crates/agent_servers/src/e2e_tests.rs | 25 +- crates/agent_ui/src/acp/entry_view_state.rs | 23 +- crates/agent_ui/src/acp/message_editor.rs | 186 +++------ crates/agent_ui/src/acp/model_selector.rs | 2 +- crates/agent_ui/src/acp/thread_view.rs | 226 ++++------- crates/eval/src/example.rs | 13 +- crates/eval/src/instance.rs | 7 +- 28 files changed, 631 insertions(+), 1109 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index eb77b9edfb7bd358c414d3bf9b1f8aec6a05f539..3c535c27415b776e3b4210a236f39a6f6d376954 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -215,9 +215,9 @@ dependencies = [ [[package]] name = "agent-client-protocol" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525705e39c11cd73f7bc784e3681a9386aa30c8d0630808d3dc2237eb4f9cb1b" +checksum = "3e639d6b544ad39f5b4e05802db5eb04e1518284eb05fda1839931003e0244c8" dependencies = [ "agent-client-protocol-schema", "anyhow", @@ -226,16 +226,15 @@ dependencies = [ "derive_more 2.0.1", "futures 0.3.31", "log", - "parking_lot", "serde", "serde_json", ] [[package]] name = "agent-client-protocol-schema" -version = "0.6.2" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecf16c18fea41282d6bbadd1549a06be6836bddb1893f44a6235f340fa24e2af" +checksum = "f182f5e14bef8232b239719bd99166bb11e986c08fc211f28e392f880d3093ba" dependencies = [ "anyhow", "derive_more 2.0.1", diff --git a/Cargo.toml b/Cargo.toml index e73e0108f2726c1223a64ba0221c41d8b4394262..6cd80981ce62a245310e6e1a1d447bdc804aa32a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -439,7 +439,7 @@ zlog_settings = { path = "crates/zlog_settings" } # External crates # -agent-client-protocol = { version = "0.7.0", features = ["unstable"] } +agent-client-protocol = { version = "=0.8.0", features = ["unstable"] } aho-corasick = "1.1" alacritty_terminal = "0.25.1-rc1" any_vec = "0.14" diff --git a/crates/acp_thread/src/acp_thread.rs b/crates/acp_thread/src/acp_thread.rs index a42eaa491f7f98e9965cd3aba801690ed996a39a..9c7590ccd6c5871c4db72b89eff344b3eca877a7 100644 --- a/crates/acp_thread/src/acp_thread.rs +++ b/crates/acp_thread/src/acp_thread.rs @@ -201,17 +201,19 @@ impl ToolCall { }; let mut content = Vec::with_capacity(tool_call.content.len()); for item in tool_call.content { - content.push(ToolCallContent::from_acp( + if let Some(item) = ToolCallContent::from_acp( item, language_registry.clone(), path_style, terminals, cx, - )?); + )? { + content.push(item); + } } let result = Self { - id: tool_call.id, + id: tool_call.tool_call_id, label: cx .new(|cx| Markdown::new(title.into(), Some(language_registry.clone()), None, cx)), kind: tool_call.kind, @@ -241,6 +243,7 @@ impl ToolCall { locations, raw_input, raw_output, + .. } = fields; if let Some(kind) = kind { @@ -262,21 +265,29 @@ impl ToolCall { } if let Some(content) = content { - let new_content_len = content.len(); + let mut new_content_len = content.len(); let mut content = content.into_iter(); // Reuse existing content if we can for (old, new) in self.content.iter_mut().zip(content.by_ref()) { - old.update_from_acp(new, language_registry.clone(), path_style, terminals, cx)?; + let valid_content = + old.update_from_acp(new, language_registry.clone(), path_style, terminals, cx)?; + if !valid_content { + new_content_len -= 1; + } } for new in content { - self.content.push(ToolCallContent::from_acp( + if let Some(new) = ToolCallContent::from_acp( new, language_registry.clone(), path_style, terminals, cx, - )?) + )? { + self.content.push(new); + } else { + new_content_len -= 1; + } } self.content.truncate(new_content_len); } @@ -425,6 +436,7 @@ impl From for ToolCallStatus { acp::ToolCallStatus::InProgress => Self::InProgress, acp::ToolCallStatus::Completed => Self::Completed, acp::ToolCallStatus::Failed => Self::Failed, + _ => Self::Pending, } } } @@ -537,7 +549,7 @@ impl ContentBlock { .. }) => Self::resource_link_md(&uri, path_style), acp::ContentBlock::Image(image) => Self::image_md(&image), - acp::ContentBlock::Audio(_) | acp::ContentBlock::Resource(_) => String::new(), + _ => String::new(), } } @@ -591,15 +603,17 @@ impl ToolCallContent { path_style: PathStyle, terminals: &HashMap>, cx: &mut App, - ) -> Result { + ) -> Result> { match content { - acp::ToolCallContent::Content { content } => Ok(Self::ContentBlock(ContentBlock::new( - content, - &language_registry, - path_style, - cx, - ))), - acp::ToolCallContent::Diff { diff } => Ok(Self::Diff(cx.new(|cx| { + acp::ToolCallContent::Content(acp::Content { content, .. }) => { + Ok(Some(Self::ContentBlock(ContentBlock::new( + content, + &language_registry, + path_style, + cx, + )))) + } + acp::ToolCallContent::Diff(diff) => Ok(Some(Self::Diff(cx.new(|cx| { Diff::finalized( diff.path.to_string_lossy().into_owned(), diff.old_text, @@ -607,12 +621,13 @@ impl ToolCallContent { language_registry, cx, ) - }))), - acp::ToolCallContent::Terminal { terminal_id } => terminals + })))), + acp::ToolCallContent::Terminal(acp::Terminal { terminal_id, .. }) => terminals .get(&terminal_id) .cloned() - .map(Self::Terminal) + .map(|terminal| Some(Self::Terminal(terminal))) .ok_or_else(|| anyhow::anyhow!("Terminal with id `{}` not found", terminal_id)), + _ => Ok(None), } } @@ -623,9 +638,9 @@ impl ToolCallContent { path_style: PathStyle, terminals: &HashMap>, cx: &mut App, - ) -> Result<()> { + ) -> Result { let needs_update = match (&self, &new) { - (Self::Diff(old_diff), acp::ToolCallContent::Diff { diff: new_diff }) => { + (Self::Diff(old_diff), acp::ToolCallContent::Diff(new_diff)) => { old_diff.read(cx).needs_update( new_diff.old_text.as_deref().unwrap_or(""), &new_diff.new_text, @@ -635,10 +650,14 @@ impl ToolCallContent { _ => true, }; - if needs_update { - *self = Self::from_acp(new, language_registry, path_style, terminals, cx)?; + if let Some(update) = Self::from_acp(new, language_registry, path_style, terminals, cx)? { + if needs_update { + *self = update; + } + Ok(true) + } else { + Ok(false) } - Ok(()) } pub fn to_markdown(&self, cx: &App) -> String { @@ -660,7 +679,7 @@ pub enum ToolCallUpdate { impl ToolCallUpdate { fn id(&self) -> &acp::ToolCallId { match self { - Self::UpdateFields(update) => &update.id, + Self::UpdateFields(update) => &update.tool_call_id, Self::UpdateDiff(diff) => &diff.id, Self::UpdateTerminal(terminal) => &terminal.id, } @@ -732,6 +751,7 @@ impl Plan { acp::PlanEntryStatus::Completed => { stats.completed += 1; } + _ => {} } } @@ -1154,6 +1174,7 @@ impl AcpThread { current_mode_id, .. }) => cx.emit(AcpThreadEvent::ModeUpdated(current_mode_id)), + _ => {} } Ok(()) } @@ -1287,11 +1308,7 @@ impl AcpThread { label: cx.new(|cx| Markdown::new("Tool call not found".into(), None, None, cx)), kind: acp::ToolKind::Fetch, content: vec![ToolCallContent::ContentBlock(ContentBlock::new( - acp::ContentBlock::Text(acp::TextContent { - text: "Tool call not found".to_string(), - annotations: None, - meta: None, - }), + "Tool call not found".into(), &languages, path_style, cx, @@ -1315,7 +1332,7 @@ impl AcpThread { let location_updated = update.fields.locations.is_some(); call.update_fields(update.fields, languages, path_style, &self.terminals, cx)?; if location_updated { - self.resolve_locations(update.id, cx); + self.resolve_locations(update.tool_call_id, cx); } } ToolCallUpdate::UpdateDiff(update) => { @@ -1353,7 +1370,7 @@ impl AcpThread { ) -> Result<(), acp::Error> { let language_registry = self.project.read(cx).languages().clone(); let path_style = self.project.read(cx).path_style(cx); - let id = update.id.clone(); + let id = update.tool_call_id.clone(); let agent = self.connection().telemetry_id(); let session = self.session_id(); @@ -1518,16 +1535,16 @@ impl AcpThread { // some tools would (incorrectly) continue to auto-accept. if let Some(allow_once_option) = options.iter().find_map(|option| { if matches!(option.kind, acp::PermissionOptionKind::AllowOnce) { - Some(option.id.clone()) + Some(option.option_id.clone()) } else { None } }) { self.upsert_tool_call_inner(tool_call, ToolCallStatus::Pending, cx)?; return Ok(async { - acp::RequestPermissionOutcome::Selected { - option_id: allow_once_option, - } + acp::RequestPermissionOutcome::Selected(acp::SelectedPermissionOutcome::new( + allow_once_option, + )) } .boxed()); } @@ -1543,7 +1560,9 @@ impl AcpThread { let fut = async { match rx.await { - Ok(option) => acp::RequestPermissionOutcome::Selected { option_id: option }, + Ok(option) => acp::RequestPermissionOutcome::Selected( + acp::SelectedPermissionOutcome::new(option), + ), Err(oneshot::Canceled) => acp::RequestPermissionOutcome::Cancelled, } } @@ -1570,6 +1589,7 @@ impl AcpThread { acp::PermissionOptionKind::AllowOnce | acp::PermissionOptionKind::AllowAlways => { ToolCallStatus::InProgress } + _ => ToolCallStatus::InProgress, }; let curr_status = mem::replace(&mut call.status, new_status); @@ -1648,14 +1668,7 @@ impl AcpThread { message: &str, cx: &mut Context, ) -> BoxFuture<'static, Result<()>> { - self.send( - vec![acp::ContentBlock::Text(acp::TextContent { - text: message.to_string(), - annotations: None, - meta: None, - })], - cx, - ) + self.send(vec![message.into()], cx) } pub fn send( @@ -1669,11 +1682,7 @@ impl AcpThread { self.project.read(cx).path_style(cx), cx, ); - let request = acp::PromptRequest { - prompt: message.clone(), - session_id: self.session_id.clone(), - meta: None, - }; + let request = acp::PromptRequest::new(self.session_id.clone(), message.clone()); let git_store = self.project.read(cx).git_store().clone(); let message_id = if self.connection.truncate(&self.session_id, cx).is_some() { @@ -1765,7 +1774,7 @@ impl AcpThread { result, Ok(Ok(acp::PromptResponse { stop_reason: acp::StopReason::Cancelled, - meta: None, + .. })) ); @@ -1781,7 +1790,7 @@ impl AcpThread { // Handle refusal - distinguish between user prompt and tool call refusals if let Ok(Ok(acp::PromptResponse { stop_reason: acp::StopReason::Refusal, - meta: _, + .. })) = result { if let Some((user_msg_ix, _)) = this.last_user_message() { @@ -2017,7 +2026,7 @@ impl AcpThread { })?; Ok(project.open_buffer(path, cx)) }) - .map_err(|e| acp::Error::internal_error().with_data(e.to_string())) + .map_err(|e| acp::Error::internal_error().data(e.to_string())) .flatten()?; let buffer = load.await?; @@ -2050,7 +2059,7 @@ impl AcpThread { let start_position = Point::new(line, 0); if start_position > max_point { - return Err(acp::Error::invalid_params().with_data(format!( + return Err(acp::Error::invalid_params().data(format!( "Attempting to read beyond the end of the file, line {}:{}", max_point.row + 1, max_point.column @@ -2202,7 +2211,7 @@ impl AcpThread { let language_registry = project.read(cx).languages().clone(); let is_windows = project.read(cx).path_style(cx).is_windows(); - let terminal_id = acp::TerminalId(Uuid::new_v4().to_string().into()); + let terminal_id = acp::TerminalId::new(Uuid::new_v4().to_string()); let terminal_task = cx.spawn({ let terminal_id = terminal_id.clone(); async move |_this, cx| { @@ -2412,7 +2421,7 @@ mod tests { .await .unwrap(); - let terminal_id = acp::TerminalId(uuid::Uuid::new_v4().to_string().into()); + let terminal_id = acp::TerminalId::new(uuid::Uuid::new_v4().to_string()); // Send Output BEFORE Created - should be buffered by acp_thread thread.update(cx, |thread, cx| { @@ -2474,7 +2483,7 @@ mod tests { .await .unwrap(); - let terminal_id = acp::TerminalId(uuid::Uuid::new_v4().to_string().into()); + let terminal_id = acp::TerminalId::new(uuid::Uuid::new_v4().to_string()); // Send Output BEFORE Created thread.update(cx, |thread, cx| { @@ -2492,11 +2501,7 @@ mod tests { thread.on_terminal_provider_event( TerminalProviderEvent::Exit { terminal_id: terminal_id.clone(), - status: acp::TerminalExitStatus { - exit_code: Some(0), - signal: None, - meta: None, - }, + status: acp::TerminalExitStatus::new().exit_code(0), }, cx, ); @@ -2553,15 +2558,7 @@ mod tests { // Test creating a new user message thread.update(cx, |thread, cx| { - thread.push_user_content_block( - None, - acp::ContentBlock::Text(acp::TextContent { - annotations: None, - text: "Hello, ".to_string(), - meta: None, - }), - cx, - ); + thread.push_user_content_block(None, "Hello, ".into(), cx); }); thread.update(cx, |thread, cx| { @@ -2577,15 +2574,7 @@ mod tests { // Test appending to existing user message let message_1_id = UserMessageId::new(); thread.update(cx, |thread, cx| { - thread.push_user_content_block( - Some(message_1_id.clone()), - acp::ContentBlock::Text(acp::TextContent { - annotations: None, - text: "world!".to_string(), - meta: None, - }), - cx, - ); + thread.push_user_content_block(Some(message_1_id.clone()), "world!".into(), cx); }); thread.update(cx, |thread, cx| { @@ -2600,26 +2589,14 @@ mod tests { // Test creating new user message after assistant message thread.update(cx, |thread, cx| { - thread.push_assistant_content_block( - acp::ContentBlock::Text(acp::TextContent { - annotations: None, - text: "Assistant response".to_string(), - meta: None, - }), - false, - cx, - ); + thread.push_assistant_content_block("Assistant response".into(), false, cx); }); let message_2_id = UserMessageId::new(); thread.update(cx, |thread, cx| { thread.push_user_content_block( Some(message_2_id.clone()), - acp::ContentBlock::Text(acp::TextContent { - annotations: None, - text: "New user message".to_string(), - meta: None, - }), + "New user message".into(), cx, ); }); @@ -2647,27 +2624,22 @@ mod tests { thread.update(&mut cx, |thread, cx| { thread .handle_session_update( - acp::SessionUpdate::AgentThoughtChunk(acp::ContentChunk { - content: "Thinking ".into(), - meta: None, - }), + acp::SessionUpdate::AgentThoughtChunk(acp::ContentChunk::new( + "Thinking ".into(), + )), cx, ) .unwrap(); thread .handle_session_update( - acp::SessionUpdate::AgentThoughtChunk(acp::ContentChunk { - content: "hard!".into(), - meta: None, - }), + acp::SessionUpdate::AgentThoughtChunk(acp::ContentChunk::new( + "hard!".into(), + )), cx, ) .unwrap(); })?; - Ok(acp::PromptResponse { - stop_reason: acp::StopReason::EndTurn, - meta: None, - }) + Ok(acp::PromptResponse::new(acp::StopReason::EndTurn)) } .boxed_local() }, @@ -2735,10 +2707,7 @@ mod tests { .unwrap() .await .unwrap(); - Ok(acp::PromptResponse { - stop_reason: acp::StopReason::EndTurn, - meta: None, - }) + Ok(acp::PromptResponse::new(acp::StopReason::EndTurn)) } .boxed_local() }, @@ -2969,7 +2938,7 @@ mod tests { let fs = FakeFs::new(cx.executor()); let project = Project::test(fs, [], cx).await; - let id = acp::ToolCallId("test".into()); + let id = acp::ToolCallId::new("test"); let connection = Rc::new(FakeAgentConnection::new().on_user_message({ let id = id.clone(); @@ -2979,26 +2948,17 @@ mod tests { thread .update(&mut cx, |thread, cx| { thread.handle_session_update( - acp::SessionUpdate::ToolCall(acp::ToolCall { - id: id.clone(), - title: "Label".into(), - kind: acp::ToolKind::Fetch, - status: acp::ToolCallStatus::InProgress, - content: vec![], - locations: vec![], - raw_input: None, - raw_output: None, - meta: None, - }), + acp::SessionUpdate::ToolCall( + acp::ToolCall::new(id.clone(), "Label") + .kind(acp::ToolKind::Fetch) + .status(acp::ToolCallStatus::InProgress), + ), cx, ) }) .unwrap() .unwrap(); - Ok(acp::PromptResponse { - stop_reason: acp::StopReason::EndTurn, - meta: None, - }) + Ok(acp::PromptResponse::new(acp::StopReason::EndTurn)) } .boxed_local() } @@ -3040,14 +3000,10 @@ mod tests { thread .update(cx, |thread, cx| { thread.handle_session_update( - acp::SessionUpdate::ToolCallUpdate(acp::ToolCallUpdate { + acp::SessionUpdate::ToolCallUpdate(acp::ToolCallUpdate::new( id, - fields: acp::ToolCallUpdateFields { - status: Some(acp::ToolCallStatus::Completed), - ..Default::default() - }, - meta: None, - }), + acp::ToolCallUpdateFields::new().status(acp::ToolCallStatus::Completed), + )), cx, ) }) @@ -3079,33 +3035,21 @@ mod tests { thread .update(&mut cx, |thread, cx| { thread.handle_session_update( - acp::SessionUpdate::ToolCall(acp::ToolCall { - id: acp::ToolCallId("test".into()), - title: "Label".into(), - kind: acp::ToolKind::Edit, - status: acp::ToolCallStatus::Completed, - content: vec![acp::ToolCallContent::Diff { - diff: acp::Diff { - path: "/test/test.txt".into(), - old_text: None, - new_text: "foo".into(), - meta: None, - }, - }], - locations: vec![], - raw_input: None, - raw_output: None, - meta: None, - }), + acp::SessionUpdate::ToolCall( + acp::ToolCall::new("test", "Label") + .kind(acp::ToolKind::Edit) + .status(acp::ToolCallStatus::Completed) + .content(vec![acp::ToolCallContent::Diff(acp::Diff::new( + "/test/test.txt", + "foo", + ))]), + ), cx, ) }) .unwrap() .unwrap(); - Ok(acp::PromptResponse { - stop_reason: acp::StopReason::EndTurn, - meta: None, - }) + Ok(acp::PromptResponse::new(acp::StopReason::EndTurn)) } .boxed_local() } @@ -3158,18 +3102,14 @@ mod tests { thread.update(&mut cx, |thread, cx| { thread .handle_session_update( - acp::SessionUpdate::AgentMessageChunk(acp::ContentChunk { - content: content.text.to_uppercase().into(), - meta: None, - }), + acp::SessionUpdate::AgentMessageChunk(acp::ContentChunk::new( + content.text.to_uppercase().into(), + )), cx, ) .unwrap(); })?; - Ok(acp::PromptResponse { - stop_reason: acp::StopReason::EndTurn, - meta: None, - }) + Ok(acp::PromptResponse::new(acp::StopReason::EndTurn)) } .boxed_local() } @@ -3325,34 +3265,22 @@ mod tests { thread.update(&mut cx, |thread, cx| { thread .handle_session_update( - acp::SessionUpdate::ToolCall(acp::ToolCall { - id: acp::ToolCallId("tool1".into()), - title: "Test Tool".into(), - kind: acp::ToolKind::Fetch, - status: acp::ToolCallStatus::Completed, - content: vec![], - locations: vec![], - raw_input: Some(serde_json::json!({"query": "test"})), - raw_output: Some( - serde_json::json!({"result": "inappropriate content"}), - ), - meta: None, - }), + acp::SessionUpdate::ToolCall( + acp::ToolCall::new("tool1", "Test Tool") + .kind(acp::ToolKind::Fetch) + .status(acp::ToolCallStatus::Completed) + .raw_input(serde_json::json!({"query": "test"})) + .raw_output(serde_json::json!({"result": "inappropriate content"})), + ), cx, ) .unwrap(); })?; // Now return refusal because of the tool result - Ok(acp::PromptResponse { - stop_reason: acp::StopReason::Refusal, - meta: None, - }) + Ok(acp::PromptResponse::new(acp::StopReason::Refusal)) } else { - Ok(acp::PromptResponse { - stop_reason: acp::StopReason::EndTurn, - meta: None, - }) + Ok(acp::PromptResponse::new(acp::StopReason::EndTurn)) } } .boxed_local() @@ -3380,16 +3308,7 @@ mod tests { }); // Send a user message - this will trigger tool call and then refusal - let send_task = thread.update(cx, |thread, cx| { - thread.send( - vec![acp::ContentBlock::Text(acp::TextContent { - text: "Hello".into(), - annotations: None, - meta: None, - })], - cx, - ) - }); + let send_task = thread.update(cx, |thread, cx| thread.send(vec!["Hello".into()], cx)); cx.background_executor.spawn(send_task).detach(); cx.run_until_parked(); @@ -3435,21 +3354,11 @@ mod tests { let refuse_next = refuse_next.clone(); move |_request, _thread, _cx| { if refuse_next.load(SeqCst) { - async move { - Ok(acp::PromptResponse { - stop_reason: acp::StopReason::Refusal, - meta: None, - }) - } - .boxed_local() + async move { Ok(acp::PromptResponse::new(acp::StopReason::Refusal)) } + .boxed_local() } else { - async move { - Ok(acp::PromptResponse { - stop_reason: acp::StopReason::EndTurn, - meta: None, - }) - } - .boxed_local() + async move { Ok(acp::PromptResponse::new(acp::StopReason::EndTurn)) } + .boxed_local() } } })); @@ -3506,10 +3415,7 @@ mod tests { let refuse_next = refuse_next.clone(); async move { if refuse_next.load(SeqCst) { - return Ok(acp::PromptResponse { - stop_reason: acp::StopReason::Refusal, - meta: None, - }); + return Ok(acp::PromptResponse::new(acp::StopReason::Refusal)); } let acp::ContentBlock::Text(content) = &request.prompt[0] else { @@ -3518,18 +3424,14 @@ mod tests { thread.update(&mut cx, |thread, cx| { thread .handle_session_update( - acp::SessionUpdate::AgentMessageChunk(acp::ContentChunk { - content: content.text.to_uppercase().into(), - meta: None, - }), + acp::SessionUpdate::AgentMessageChunk(acp::ContentChunk::new( + content.text.to_uppercase().into(), + )), cx, ) .unwrap(); })?; - Ok(acp::PromptResponse { - stop_reason: acp::StopReason::EndTurn, - meta: None, - }) + Ok(acp::PromptResponse::new(acp::StopReason::EndTurn)) } .boxed_local() } @@ -3668,13 +3570,12 @@ mod tests { _cwd: &Path, cx: &mut App, ) -> Task>> { - let session_id = acp::SessionId( + let session_id = acp::SessionId::new( rand::rng() .sample_iter(&distr::Alphanumeric) .take(7) .map(char::from) - .collect::() - .into(), + .collect::(), ); let action_log = cx.new(|_| ActionLog::new(project.clone())); let thread = cx.new(|cx| { @@ -3684,12 +3585,12 @@ mod tests { project, action_log, session_id.clone(), - watch::Receiver::constant(acp::PromptCapabilities { - image: true, - audio: true, - embedded_context: true, - meta: None, - }), + watch::Receiver::constant( + acp::PromptCapabilities::new() + .image(true) + .audio(true) + .embedded_context(true), + ), cx, ) }); @@ -3718,10 +3619,7 @@ mod tests { let thread = thread.clone(); cx.spawn(async move |cx| handler(params, thread, cx.clone()).await) } else { - Task::ready(Ok(acp::PromptResponse { - stop_reason: acp::StopReason::EndTurn, - meta: None, - })) + Task::ready(Ok(acp::PromptResponse::new(acp::StopReason::EndTurn))) } } @@ -3776,17 +3674,13 @@ mod tests { .unwrap(); // Try to update a tool call that doesn't exist - let nonexistent_id = acp::ToolCallId("nonexistent-tool-call".into()); + let nonexistent_id = acp::ToolCallId::new("nonexistent-tool-call"); thread.update(cx, |thread, cx| { let result = thread.handle_session_update( - acp::SessionUpdate::ToolCallUpdate(acp::ToolCallUpdate { - id: nonexistent_id.clone(), - fields: acp::ToolCallUpdateFields { - status: Some(acp::ToolCallStatus::Completed), - ..Default::default() - }, - meta: None, - }), + acp::SessionUpdate::ToolCallUpdate(acp::ToolCallUpdate::new( + nonexistent_id.clone(), + acp::ToolCallUpdateFields::new().status(acp::ToolCallStatus::Completed), + )), cx, ); @@ -3861,7 +3755,7 @@ mod tests { .unwrap(); // Create 2 terminals BEFORE the checkpoint that have completed running - let terminal_id_1 = acp::TerminalId(uuid::Uuid::new_v4().to_string().into()); + let terminal_id_1 = acp::TerminalId::new(uuid::Uuid::new_v4().to_string()); let mock_terminal_1 = cx.new(|cx| { let builder = ::terminal::TerminalBuilder::new_display_only( ::terminal::terminal_settings::CursorShape::default(), @@ -3900,17 +3794,13 @@ mod tests { thread.on_terminal_provider_event( TerminalProviderEvent::Exit { terminal_id: terminal_id_1.clone(), - status: acp::TerminalExitStatus { - exit_code: Some(0), - signal: None, - meta: None, - }, + status: acp::TerminalExitStatus::new().exit_code(0), }, cx, ); }); - let terminal_id_2 = acp::TerminalId(uuid::Uuid::new_v4().to_string().into()); + let terminal_id_2 = acp::TerminalId::new(uuid::Uuid::new_v4().to_string()); let mock_terminal_2 = cx.new(|cx| { let builder = ::terminal::TerminalBuilder::new_display_only( ::terminal::terminal_settings::CursorShape::default(), @@ -3949,11 +3839,7 @@ mod tests { thread.on_terminal_provider_event( TerminalProviderEvent::Exit { terminal_id: terminal_id_2.clone(), - status: acp::TerminalExitStatus { - exit_code: Some(0), - signal: None, - meta: None, - }, + status: acp::TerminalExitStatus::new().exit_code(0), }, cx, ); @@ -3973,7 +3859,7 @@ mod tests { // Create a terminal AFTER the checkpoint we'll restore to. // This simulates the AI agent starting a long-running terminal command. - let terminal_id = acp::TerminalId(uuid::Uuid::new_v4().to_string().into()); + let terminal_id = acp::TerminalId::new(uuid::Uuid::new_v4().to_string()); let mock_terminal = cx.new(|cx| { let builder = ::terminal::TerminalBuilder::new_display_only( ::terminal::terminal_settings::CursorShape::default(), @@ -4015,21 +3901,15 @@ mod tests { thread.update(cx, |thread, cx| { thread .handle_session_update( - acp::SessionUpdate::ToolCall(acp::ToolCall { - id: acp::ToolCallId("terminal-tool-1".into()), - title: "Running command".into(), - kind: acp::ToolKind::Execute, - status: acp::ToolCallStatus::InProgress, - content: vec![acp::ToolCallContent::Terminal { - terminal_id: terminal_id.clone(), - }], - locations: vec![], - raw_input: Some( - serde_json::json!({"command": "sleep 1000", "cd": "/test"}), - ), - raw_output: None, - meta: None, - }), + acp::SessionUpdate::ToolCall( + acp::ToolCall::new("terminal-tool-1", "Running command") + .kind(acp::ToolKind::Execute) + .status(acp::ToolCallStatus::InProgress) + .content(vec![acp::ToolCallContent::Terminal(acp::Terminal::new( + terminal_id.clone(), + ))]) + .raw_input(serde_json::json!({"command": "sleep 1000", "cd": "/test"})), + ), cx, ) .unwrap(); diff --git a/crates/acp_thread/src/connection.rs b/crates/acp_thread/src/connection.rs index 80bec0ee9d351711bdf435cfe63eb99eb1e499e3..8213786a182e1d93d1bfc1a8918a8830ecaa754b 100644 --- a/crates/acp_thread/src/connection.rs +++ b/crates/acp_thread/src/connection.rs @@ -336,7 +336,7 @@ mod test_support { _cwd: &Path, cx: &mut gpui::App, ) -> Task>> { - let session_id = acp::SessionId(self.sessions.lock().len().to_string().into()); + let session_id = acp::SessionId::new(self.sessions.lock().len().to_string()); let action_log = cx.new(|_| ActionLog::new(project.clone())); let thread = cx.new(|cx| { AcpThread::new( @@ -345,12 +345,12 @@ mod test_support { project, action_log, session_id.clone(), - watch::Receiver::constant(acp::PromptCapabilities { - image: true, - audio: true, - embedded_context: true, - meta: None, - }), + watch::Receiver::constant( + acp::PromptCapabilities::new() + .image(true) + .audio(true) + .embedded_context(true), + ), cx, ) }); @@ -389,10 +389,7 @@ mod test_support { response_tx.replace(tx); cx.spawn(async move |_| { let stop_reason = rx.await?; - Ok(acp::PromptResponse { - stop_reason, - meta: None, - }) + Ok(acp::PromptResponse::new(stop_reason)) }) } else { for update in self.next_prompt_updates.lock().drain(..) { @@ -400,7 +397,7 @@ mod test_support { let update = update.clone(); let permission_request = if let acp::SessionUpdate::ToolCall(tool_call) = &update - && let Some(options) = self.permission_requests.get(&tool_call.id) + && let Some(options) = self.permission_requests.get(&tool_call.tool_call_id) { Some((tool_call.clone(), options.clone())) } else { @@ -429,10 +426,7 @@ mod test_support { cx.spawn(async move |_| { try_join_all(tasks).await?; - Ok(acp::PromptResponse { - stop_reason: acp::StopReason::EndTurn, - meta: None, - }) + Ok(acp::PromptResponse::new(acp::StopReason::EndTurn)) }) } } diff --git a/crates/acp_thread/src/mention.rs b/crates/acp_thread/src/mention.rs index b78eac4903a259a1044892fb2c8233f7e973f025..c1b7032cfaa904764055bb79a3cac7e7ac74b0c1 100644 --- a/crates/acp_thread/src/mention.rs +++ b/crates/acp_thread/src/mention.rs @@ -108,7 +108,7 @@ impl MentionUri { if let Some(thread_id) = path.strip_prefix("/agent/thread/") { let name = single_query_param(&url, "name")?.context("Missing thread name")?; Ok(Self::Thread { - id: acp::SessionId(thread_id.into()), + id: acp::SessionId::new(thread_id), name, }) } else if let Some(path) = path.strip_prefix("/agent/text-thread/") { diff --git a/crates/acp_thread/src/terminal.rs b/crates/acp_thread/src/terminal.rs index 8b08868616e19b0d1855558a057af8eebc314e4a..fb9115650d1277e7e9982bfc851d8df142f048ad 100644 --- a/crates/acp_thread/src/terminal.rs +++ b/crates/acp_thread/src/terminal.rs @@ -75,11 +75,15 @@ impl Terminal { let exit_status = exit_status.map(portable_pty::ExitStatus::from); - acp::TerminalExitStatus { - exit_code: exit_status.as_ref().map(|e| e.exit_code()), - signal: exit_status.and_then(|e| e.signal().map(Into::into)), - meta: None, + let mut status = acp::TerminalExitStatus::new(); + + if let Some(exit_status) = exit_status.as_ref() { + status = status.exit_code(exit_status.exit_code()); + if let Some(signal) = exit_status.signal() { + status = status.signal(signal); + } } + status }) .shared(), } @@ -101,27 +105,23 @@ impl Terminal { pub fn current_output(&self, cx: &App) -> acp::TerminalOutputResponse { if let Some(output) = self.output.as_ref() { - let exit_status = output.exit_status.map(portable_pty::ExitStatus::from); - - acp::TerminalOutputResponse { - output: output.content.clone(), - truncated: output.original_content_len > output.content.len(), - exit_status: Some(acp::TerminalExitStatus { - exit_code: exit_status.as_ref().map(|e| e.exit_code()), - signal: exit_status.and_then(|e| e.signal().map(Into::into)), - meta: None, - }), - meta: None, + let mut exit_status = acp::TerminalExitStatus::new(); + if let Some(status) = output.exit_status.map(portable_pty::ExitStatus::from) { + exit_status = exit_status.exit_code(status.exit_code()); + if let Some(signal) = status.signal() { + exit_status = exit_status.signal(signal); + } } + + acp::TerminalOutputResponse::new( + output.content.clone(), + output.original_content_len > output.content.len(), + ) + .exit_status(exit_status) } else { let (current_content, original_len) = self.truncated_output(cx); - - acp::TerminalOutputResponse { - truncated: current_content.len() < original_len, - output: current_content, - exit_status: None, - meta: None, - } + let truncated = current_content.len() < original_len; + acp::TerminalOutputResponse::new(current_content, truncated) } } diff --git a/crates/agent/src/agent.rs b/crates/agent/src/agent.rs index 404cd6549e5786b92c49379918346b83fcc0e0c1..aec0767c25422dbfeae6fdddcf33e54f8045995c 100644 --- a/crates/agent/src/agent.rs +++ b/crates/agent/src/agent.rs @@ -170,7 +170,7 @@ impl LanguageModels { } fn model_id(model: &Arc) -> acp::ModelId { - acp::ModelId(format!("{}/{}", model.provider_id().0, model.id().0).into()) + acp::ModelId::new(format!("{}/{}", model.provider_id().0, model.id().0)) } fn authenticate_all_language_model_providers(cx: &mut App) -> Task<()> { @@ -789,28 +789,12 @@ impl NativeAgentConnection { } ThreadEvent::AgentText(text) => { acp_thread.update(cx, |thread, cx| { - thread.push_assistant_content_block( - acp::ContentBlock::Text(acp::TextContent { - text, - annotations: None, - meta: None, - }), - false, - cx, - ) + thread.push_assistant_content_block(text.into(), false, cx) })?; } ThreadEvent::AgentThinking(text) => { acp_thread.update(cx, |thread, cx| { - thread.push_assistant_content_block( - acp::ContentBlock::Text(acp::TextContent { - text, - annotations: None, - meta: None, - }), - true, - cx, - ) + thread.push_assistant_content_block(text.into(), true, cx) })?; } ThreadEvent::ToolCallAuthorization(ToolCallAuthorization { @@ -824,8 +808,9 @@ impl NativeAgentConnection { ) })??; cx.background_spawn(async move { - if let acp::RequestPermissionOutcome::Selected { option_id } = - outcome_task.await + if let acp::RequestPermissionOutcome::Selected( + acp::SelectedPermissionOutcome { option_id, .. }, + ) = outcome_task.await { response .send(option_id) @@ -852,10 +837,7 @@ impl NativeAgentConnection { } ThreadEvent::Stop(stop_reason) => { log::debug!("Assistant message complete: {:?}", stop_reason); - return Ok(acp::PromptResponse { - stop_reason, - meta: None, - }); + return Ok(acp::PromptResponse::new(stop_reason)); } } } @@ -867,10 +849,7 @@ impl NativeAgentConnection { } log::debug!("Response stream completed"); - anyhow::Ok(acp::PromptResponse { - stop_reason: acp::StopReason::EndTurn, - meta: None, - }) + anyhow::Ok(acp::PromptResponse::new(acp::StopReason::EndTurn)) }) } } @@ -1374,7 +1353,7 @@ mod internal_tests { IndexMap::from_iter([( AgentModelGroupName("Fake".into()), vec![AgentModelInfo { - id: acp::ModelId("fake/fake".into()), + id: acp::ModelId::new("fake/fake"), name: "Fake".into(), description: None, icon: Some(ui::IconName::ZedAssistant), @@ -1435,7 +1414,7 @@ mod internal_tests { // Select a model let selector = connection.model_selector(&session_id).unwrap(); - let model_id = acp::ModelId("fake/fake".into()); + let model_id = acp::ModelId::new("fake/fake"); cx.update(|cx| selector.select_model(model_id.clone(), cx)) .await .unwrap(); @@ -1521,20 +1500,14 @@ mod internal_tests { thread.send( vec![ "What does ".into(), - acp::ContentBlock::ResourceLink(acp::ResourceLink { - name: "b.md".into(), - uri: MentionUri::File { + acp::ContentBlock::ResourceLink(acp::ResourceLink::new( + "b.md", + MentionUri::File { abs_path: path!("/a/b.md").into(), } .to_uri() .to_string(), - annotations: None, - description: None, - mime_type: None, - size: None, - title: None, - meta: None, - }), + )), " mean?".into(), ], cx, diff --git a/crates/agent/src/db.rs b/crates/agent/src/db.rs index d5166c5df931b6f7fad63769449aaa9784b5263f..7a88c5870574cae424bd1fff50f1d20cdb00fa44 100644 --- a/crates/agent/src/db.rs +++ b/crates/agent/src/db.rs @@ -366,7 +366,7 @@ impl ThreadsDatabase { for (id, summary, updated_at) in rows { threads.push(DbThreadMetadata { - id: acp::SessionId(id), + id: acp::SessionId::new(id), title: summary.into(), updated_at: DateTime::parse_from_rfc3339(&updated_at)?.with_timezone(&Utc), }); diff --git a/crates/agent/src/history_store.rs b/crates/agent/src/history_store.rs index efc0e3966d30fbc8bc7857c9da0404ce7dd4201f..5a1b923d139060ed7df679a69d96928d03559c9d 100644 --- a/crates/agent/src/history_store.rs +++ b/crates/agent/src/history_store.rs @@ -354,9 +354,9 @@ impl HistoryStore { .into_iter() .take(MAX_RECENTLY_OPENED_ENTRIES) .flat_map(|entry| match entry { - SerializedRecentOpen::AcpThread(id) => Some(HistoryEntryId::AcpThread( - acp::SessionId(id.as_str().into()), - )), + SerializedRecentOpen::AcpThread(id) => { + Some(HistoryEntryId::AcpThread(acp::SessionId::new(id.as_str()))) + } SerializedRecentOpen::TextThread(file_name) => Some( HistoryEntryId::TextThread(text_threads_dir().join(file_name).into()), ), diff --git a/crates/agent/src/tests/mod.rs b/crates/agent/src/tests/mod.rs index b33080671980eb28c7900aea4bb0942d152a054a..5948200dd796a336cbccbc1644c3bb200960de51 100644 --- a/crates/agent/src/tests/mod.rs +++ b/crates/agent/src/tests/mod.rs @@ -493,14 +493,14 @@ async fn test_tool_authorization(cx: &mut TestAppContext) { // Approve the first tool_call_auth_1 .response - .send(tool_call_auth_1.options[1].id.clone()) + .send(tool_call_auth_1.options[1].option_id.clone()) .unwrap(); cx.run_until_parked(); // Reject the second tool_call_auth_2 .response - .send(tool_call_auth_1.options[2].id.clone()) + .send(tool_call_auth_1.options[2].option_id.clone()) .unwrap(); cx.run_until_parked(); @@ -510,14 +510,14 @@ async fn test_tool_authorization(cx: &mut TestAppContext) { message.content, vec![ language_model::MessageContent::ToolResult(LanguageModelToolResult { - tool_use_id: tool_call_auth_1.tool_call.id.0.to_string().into(), + tool_use_id: tool_call_auth_1.tool_call.tool_call_id.0.to_string().into(), tool_name: ToolRequiringPermission::name().into(), is_error: false, content: "Allowed".into(), output: Some("Allowed".into()) }), language_model::MessageContent::ToolResult(LanguageModelToolResult { - tool_use_id: tool_call_auth_2.tool_call.id.0.to_string().into(), + tool_use_id: tool_call_auth_2.tool_call.tool_call_id.0.to_string().into(), tool_name: ToolRequiringPermission::name().into(), is_error: true, content: "Permission to run tool denied by user".into(), @@ -543,7 +543,7 @@ async fn test_tool_authorization(cx: &mut TestAppContext) { let tool_call_auth_3 = next_tool_call_authorization(&mut events).await; tool_call_auth_3 .response - .send(tool_call_auth_3.options[0].id.clone()) + .send(tool_call_auth_3.options[0].option_id.clone()) .unwrap(); cx.run_until_parked(); let completion = fake_model.pending_completions().pop().unwrap(); @@ -552,7 +552,7 @@ async fn test_tool_authorization(cx: &mut TestAppContext) { message.content, vec![language_model::MessageContent::ToolResult( LanguageModelToolResult { - tool_use_id: tool_call_auth_3.tool_call.id.0.to_string().into(), + tool_use_id: tool_call_auth_3.tool_call.tool_call_id.0.to_string().into(), tool_name: ToolRequiringPermission::name().into(), is_error: false, content: "Allowed".into(), @@ -1353,20 +1353,20 @@ async fn test_cancellation(cx: &mut TestAppContext) { ThreadEvent::ToolCall(tool_call) => { assert_eq!(tool_call.title, expected_tools.remove(0)); if tool_call.title == "Echo" { - echo_id = Some(tool_call.id); + echo_id = Some(tool_call.tool_call_id); } } ThreadEvent::ToolCallUpdate(acp_thread::ToolCallUpdate::UpdateFields( acp::ToolCallUpdate { - id, + tool_call_id, fields: acp::ToolCallUpdateFields { status: Some(acp::ToolCallStatus::Completed), .. }, - meta: None, + .. }, - )) if Some(&id) == echo_id.as_ref() => { + )) if Some(&tool_call_id) == echo_id.as_ref() => { echo_completed = true; } _ => {} @@ -1995,11 +1995,7 @@ async fn test_agent_connection(cx: &mut TestAppContext) { .update(|cx| { connection.prompt( Some(acp_thread::UserMessageId::new()), - acp::PromptRequest { - session_id: session_id.clone(), - prompt: vec!["ghi".into()], - meta: None, - }, + acp::PromptRequest::new(session_id.clone(), vec!["ghi".into()]), cx, ) }) @@ -2056,68 +2052,50 @@ async fn test_tool_updates_to_completion(cx: &mut TestAppContext) { let tool_call = expect_tool_call(&mut events).await; assert_eq!( tool_call, - acp::ToolCall { - id: acp::ToolCallId("1".into()), - title: "Thinking".into(), - kind: acp::ToolKind::Think, - status: acp::ToolCallStatus::Pending, - content: vec![], - locations: vec![], - raw_input: Some(json!({})), - raw_output: None, - meta: Some(json!({ "tool_name": "thinking" })), - } + acp::ToolCall::new("1", "Thinking") + .kind(acp::ToolKind::Think) + .raw_input(json!({})) + .meta(acp::Meta::from_iter([( + "tool_name".into(), + "thinking".into() + )])) ); let update = expect_tool_call_update_fields(&mut events).await; assert_eq!( update, - acp::ToolCallUpdate { - id: acp::ToolCallId("1".into()), - fields: acp::ToolCallUpdateFields { - title: Some("Thinking".into()), - kind: Some(acp::ToolKind::Think), - raw_input: Some(json!({ "content": "Thinking hard!" })), - ..Default::default() - }, - meta: None, - } + acp::ToolCallUpdate::new( + "1", + acp::ToolCallUpdateFields::new() + .title("Thinking") + .kind(acp::ToolKind::Think) + .raw_input(json!({ "content": "Thinking hard!"})) + ) ); let update = expect_tool_call_update_fields(&mut events).await; assert_eq!( update, - acp::ToolCallUpdate { - id: acp::ToolCallId("1".into()), - fields: acp::ToolCallUpdateFields { - status: Some(acp::ToolCallStatus::InProgress), - ..Default::default() - }, - meta: None, - } + acp::ToolCallUpdate::new( + "1", + acp::ToolCallUpdateFields::new().status(acp::ToolCallStatus::InProgress) + ) ); let update = expect_tool_call_update_fields(&mut events).await; assert_eq!( update, - acp::ToolCallUpdate { - id: acp::ToolCallId("1".into()), - fields: acp::ToolCallUpdateFields { - content: Some(vec!["Thinking hard!".into()]), - ..Default::default() - }, - meta: None, - } + acp::ToolCallUpdate::new( + "1", + acp::ToolCallUpdateFields::new().content(vec!["Thinking hard!".into()]) + ) ); let update = expect_tool_call_update_fields(&mut events).await; assert_eq!( update, - acp::ToolCallUpdate { - id: acp::ToolCallId("1".into()), - fields: acp::ToolCallUpdateFields { - status: Some(acp::ToolCallStatus::Completed), - raw_output: Some("Finished thinking.".into()), - ..Default::default() - }, - meta: None, - } + acp::ToolCallUpdate::new( + "1", + acp::ToolCallUpdateFields::new() + .status(acp::ToolCallStatus::Completed) + .raw_output("Finished thinking.".into()) + ) ); } diff --git a/crates/agent/src/thread.rs b/crates/agent/src/thread.rs index 294c96b3ecb7800ab5b5f62749d335682efebd60..da95c4294757a23960d6c5c78aa905e63834debb 100644 --- a/crates/agent/src/thread.rs +++ b/crates/agent/src/thread.rs @@ -619,12 +619,9 @@ pub struct Thread { impl Thread { fn prompt_capabilities(model: Option<&dyn LanguageModel>) -> acp::PromptCapabilities { let image = model.map_or(true, |model| model.supports_images()); - acp::PromptCapabilities { - meta: None, - image, - audio: false, - embedded_context: true, - } + acp::PromptCapabilities::new() + .image(image) + .embedded_context(true) } pub fn new( @@ -640,7 +637,7 @@ impl Thread { let (prompt_capabilities_tx, prompt_capabilities_rx) = watch::channel(Self::prompt_capabilities(model.as_deref())); Self { - id: acp::SessionId(uuid::Uuid::new_v4().to_string().into()), + id: acp::SessionId::new(uuid::Uuid::new_v4().to_string()), prompt_id: PromptId::new(), updated_at: Utc::now(), title: None, @@ -737,17 +734,11 @@ impl Thread { let Some(tool) = tool else { stream .0 - .unbounded_send(Ok(ThreadEvent::ToolCall(acp::ToolCall { - meta: None, - id: acp::ToolCallId(tool_use.id.to_string().into()), - title: tool_use.name.to_string(), - kind: acp::ToolKind::Other, - status: acp::ToolCallStatus::Failed, - content: Vec::new(), - locations: Vec::new(), - raw_input: Some(tool_use.input.clone()), - raw_output: None, - }))) + .unbounded_send(Ok(ThreadEvent::ToolCall( + acp::ToolCall::new(tool_use.id.to_string(), tool_use.name.to_string()) + .status(acp::ToolCallStatus::Failed) + .raw_input(tool_use.input.clone()), + ))) .ok(); return; }; @@ -775,24 +766,20 @@ impl Thread { .log_err(); } - stream.update_tool_call_fields( - &tool_use.id, - acp::ToolCallUpdateFields { - status: Some( - tool_result - .as_ref() - .map_or(acp::ToolCallStatus::Failed, |result| { - if result.is_error { - acp::ToolCallStatus::Failed - } else { - acp::ToolCallStatus::Completed - } - }), - ), - raw_output: output, - ..Default::default() + let mut fields = acp::ToolCallUpdateFields::new().status(tool_result.as_ref().map_or( + acp::ToolCallStatus::Failed, + |result| { + if result.is_error { + acp::ToolCallStatus::Failed + } else { + acp::ToolCallStatus::Completed + } }, - ); + )); + if let Some(output) = output { + fields = fields.raw_output(output); + } + stream.update_tool_call_fields(&tool_use.id, fields); } pub fn from_db( @@ -1272,18 +1259,15 @@ impl Thread { while let Some(tool_result) = tool_results.next().await { log::debug!("Tool finished {:?}", tool_result); - event_stream.update_tool_call_fields( - &tool_result.tool_use_id, - acp::ToolCallUpdateFields { - status: Some(if tool_result.is_error { - acp::ToolCallStatus::Failed - } else { - acp::ToolCallStatus::Completed - }), - raw_output: tool_result.output.clone(), - ..Default::default() - }, - ); + let mut fields = acp::ToolCallUpdateFields::new().status(if tool_result.is_error { + acp::ToolCallStatus::Failed + } else { + acp::ToolCallStatus::Completed + }); + if let Some(output) = &tool_result.output { + fields = fields.raw_output(output.clone()); + } + event_stream.update_tool_call_fields(&tool_result.tool_use_id, fields); this.update(cx, |this, _cx| { this.pending_message() .tool_results @@ -1560,12 +1544,10 @@ impl Thread { } else { event_stream.update_tool_call_fields( &tool_use.id, - acp::ToolCallUpdateFields { - title: Some(title.into()), - kind: Some(kind), - raw_input: Some(tool_use.input.clone()), - ..Default::default() - }, + acp::ToolCallUpdateFields::new() + .title(title) + .kind(kind) + .raw_input(tool_use.input.clone()), ); } @@ -1587,10 +1569,9 @@ impl Thread { let fs = self.project.read(cx).fs().clone(); let tool_event_stream = ToolCallEventStream::new(tool_use.id.clone(), event_stream.clone(), Some(fs)); - tool_event_stream.update_fields(acp::ToolCallUpdateFields { - status: Some(acp::ToolCallStatus::InProgress), - ..Default::default() - }); + tool_event_stream.update_fields( + acp::ToolCallUpdateFields::new().status(acp::ToolCallStatus::InProgress), + ); let supports_images = self.model().is_some_and(|model| model.supports_images()); let tool_result = tool.run(tool_use.input, tool_event_stream, cx); log::debug!("Running tool {}", tool_use.name); @@ -2381,19 +2362,13 @@ impl ThreadEventStream { kind: acp::ToolKind, input: serde_json::Value, ) -> acp::ToolCall { - acp::ToolCall { - meta: Some(serde_json::json!({ - "tool_name": tool_name - })), - id: acp::ToolCallId(id.to_string().into()), - title, - kind, - status: acp::ToolCallStatus::Pending, - content: vec![], - locations: vec![], - raw_input: Some(input), - raw_output: None, - } + acp::ToolCall::new(id.to_string(), title) + .kind(kind) + .raw_input(input) + .meta(acp::Meta::from_iter([( + "tool_name".into(), + tool_name.into(), + )])) } fn update_tool_call_fields( @@ -2403,12 +2378,7 @@ impl ThreadEventStream { ) { self.0 .unbounded_send(Ok(ThreadEvent::ToolCallUpdate( - acp::ToolCallUpdate { - meta: None, - id: acp::ToolCallId(tool_use_id.to_string().into()), - fields, - } - .into(), + acp::ToolCallUpdate::new(tool_use_id.to_string(), fields).into(), ))) .ok(); } @@ -2471,7 +2441,7 @@ impl ToolCallEventStream { .0 .unbounded_send(Ok(ThreadEvent::ToolCallUpdate( acp_thread::ToolCallUpdateDiff { - id: acp::ToolCallId(self.tool_use_id.to_string().into()), + id: acp::ToolCallId::new(self.tool_use_id.to_string()), diff, } .into(), @@ -2489,33 +2459,26 @@ impl ToolCallEventStream { .0 .unbounded_send(Ok(ThreadEvent::ToolCallAuthorization( ToolCallAuthorization { - tool_call: acp::ToolCallUpdate { - meta: None, - id: acp::ToolCallId(self.tool_use_id.to_string().into()), - fields: acp::ToolCallUpdateFields { - title: Some(title.into()), - ..Default::default() - }, - }, + tool_call: acp::ToolCallUpdate::new( + self.tool_use_id.to_string(), + acp::ToolCallUpdateFields::new().title(title), + ), options: vec![ - acp::PermissionOption { - id: acp::PermissionOptionId("always_allow".into()), - name: "Always Allow".into(), - kind: acp::PermissionOptionKind::AllowAlways, - meta: None, - }, - acp::PermissionOption { - id: acp::PermissionOptionId("allow".into()), - name: "Allow".into(), - kind: acp::PermissionOptionKind::AllowOnce, - meta: None, - }, - acp::PermissionOption { - id: acp::PermissionOptionId("deny".into()), - name: "Deny".into(), - kind: acp::PermissionOptionKind::RejectOnce, - meta: None, - }, + acp::PermissionOption::new( + acp::PermissionOptionId::new("always_allow"), + "Always Allow", + acp::PermissionOptionKind::AllowAlways, + ), + acp::PermissionOption::new( + acp::PermissionOptionId::new("allow"), + "Allow", + acp::PermissionOptionKind::AllowOnce, + ), + acp::PermissionOption::new( + acp::PermissionOptionId::new("deny"), + "Deny", + acp::PermissionOptionKind::RejectOnce, + ), ], response: response_tx, }, @@ -2660,7 +2623,15 @@ impl UserMessageContent { // TODO Self::Text("[blob]".to_string()) } + other => { + log::warn!("Unexpected content type: {:?}", other); + Self::Text("[unknown]".to_string()) + } }, + other => { + log::warn!("Unexpected content type: {:?}", other); + Self::Text("[unknown]".to_string()) + } } } } @@ -2668,32 +2639,15 @@ impl UserMessageContent { impl From for acp::ContentBlock { fn from(content: UserMessageContent) -> Self { match content { - UserMessageContent::Text(text) => acp::ContentBlock::Text(acp::TextContent { - text, - annotations: None, - meta: None, - }), - UserMessageContent::Image(image) => acp::ContentBlock::Image(acp::ImageContent { - data: image.source.to_string(), - mime_type: "image/png".to_string(), - meta: None, - annotations: None, - uri: None, - }), - UserMessageContent::Mention { uri, content } => { - acp::ContentBlock::Resource(acp::EmbeddedResource { - meta: None, - resource: acp::EmbeddedResourceResource::TextResourceContents( - acp::TextResourceContents { - meta: None, - mime_type: None, - text: content, - uri: uri.to_uri().to_string(), - }, - ), - annotations: None, - }) + UserMessageContent::Text(text) => text.into(), + UserMessageContent::Image(image) => { + acp::ContentBlock::Image(acp::ImageContent::new(image.source, "image/png")) } + UserMessageContent::Mention { uri, content } => acp::ContentBlock::Resource( + acp::EmbeddedResource::new(acp::EmbeddedResourceResource::TextResourceContents( + acp::TextResourceContents::new(content, uri.to_uri().to_string()), + )), + ), } } } diff --git a/crates/agent/src/tools/edit_file_tool.rs b/crates/agent/src/tools/edit_file_tool.rs index de2dd384693c8af3e04007895c843743c5ead722..cbe96a6b20d6e325beb9aedb6cf6d2eca1df171a 100644 --- a/crates/agent/src/tools/edit_file_tool.rs +++ b/crates/agent/src/tools/edit_file_tool.rs @@ -273,14 +273,9 @@ impl AgentTool for EditFileTool { }; let abs_path = project.read(cx).absolute_path(&project_path, cx); if let Some(abs_path) = abs_path.clone() { - event_stream.update_fields(ToolCallUpdateFields { - locations: Some(vec![acp::ToolCallLocation { - path: abs_path, - line: None, - meta: None, - }]), - ..Default::default() - }); + event_stream.update_fields( + ToolCallUpdateFields::new().locations(vec![acp::ToolCallLocation::new(abs_path)]), + ); } let authorize = self.authorize(&input, &event_stream, cx); @@ -389,10 +384,11 @@ impl AgentTool for EditFileTool { range.start.to_point(&buffer.snapshot()).row }).ok(); if let Some(abs_path) = abs_path.clone() { - event_stream.update_fields(ToolCallUpdateFields { - locations: Some(vec![ToolCallLocation { path: abs_path, line, meta: None }]), - ..Default::default() - }); + let mut location = ToolCallLocation::new(abs_path); + if let Some(line) = line { + location = location.line(line); + } + event_stream.update_fields(ToolCallUpdateFields::new().locations(vec![location])); } emitted_location = true; } diff --git a/crates/agent/src/tools/find_path_tool.rs b/crates/agent/src/tools/find_path_tool.rs index 70d7b29f75d4da984c4acda13dcdbfe7bc69fbbc..3c34f14c3a78f0fa8a6ee6794ef2567fe13d5d3c 100644 --- a/crates/agent/src/tools/find_path_tool.rs +++ b/crates/agent/src/tools/find_path_tool.rs @@ -118,33 +118,29 @@ impl AgentTool for FindPathTool { let paginated_matches: &[PathBuf] = &matches[cmp::min(input.offset, matches.len()) ..cmp::min(input.offset + RESULTS_PER_PAGE, matches.len())]; - event_stream.update_fields(acp::ToolCallUpdateFields { - title: Some(if paginated_matches.is_empty() { - "No matches".into() - } else if paginated_matches.len() == 1 { - "1 match".into() - } else { - format!("{} matches", paginated_matches.len()) - }), - content: Some( - paginated_matches - .iter() - .map(|path| acp::ToolCallContent::Content { - content: acp::ContentBlock::ResourceLink(acp::ResourceLink { - uri: format!("file://{}", path.display()), - name: path.to_string_lossy().into(), - annotations: None, - description: None, - mime_type: None, - size: None, - title: None, - meta: None, - }), - }) - .collect(), - ), - ..Default::default() - }); + event_stream.update_fields( + acp::ToolCallUpdateFields::new() + .title(if paginated_matches.is_empty() { + "No matches".into() + } else if paginated_matches.len() == 1 { + "1 match".into() + } else { + format!("{} matches", paginated_matches.len()) + }) + .content( + paginated_matches + .iter() + .map(|path| { + acp::ToolCallContent::Content(acp::Content::new( + acp::ContentBlock::ResourceLink(acp::ResourceLink::new( + path.to_string_lossy(), + format!("file://{}", path.display()), + )), + )) + }) + .collect(), + ), + ); Ok(FindPathToolOutput { offset: input.offset, diff --git a/crates/agent/src/tools/read_file_tool.rs b/crates/agent/src/tools/read_file_tool.rs index fd7b85d5ee4d075f5ab5f3fcdef2d1919e763dd7..4457a6e5ca21a2fc88c76c718160d1d59171e66a 100644 --- a/crates/agent/src/tools/read_file_tool.rs +++ b/crates/agent/src/tools/read_file_tool.rs @@ -152,15 +152,12 @@ impl AgentTool for ReadFileTool { } let file_path = input.path.clone(); + let mut location = acp::ToolCallLocation::new(&abs_path); + if let Some(line) = input.start_line { + location = location.line(line.saturating_sub(1)); + } - event_stream.update_fields(ToolCallUpdateFields { - locations: Some(vec![acp::ToolCallLocation { - path: abs_path.clone(), - line: input.start_line.map(|line| line.saturating_sub(1)), - meta: None, - }]), - ..Default::default() - }); + event_stream.update_fields(ToolCallUpdateFields::new().locations(vec![location])); if image_store::is_image_file(&self.project, &project_path, cx) { return cx.spawn(async move |cx| { @@ -289,12 +286,9 @@ impl AgentTool for ReadFileTool { text, } .to_string(); - event_stream.update_fields(ToolCallUpdateFields { - content: Some(vec![acp::ToolCallContent::Content { - content: markdown.into(), - }]), - ..Default::default() - }) + event_stream.update_fields(ToolCallUpdateFields::new().content(vec![ + acp::ToolCallContent::Content(acp::Content::new(markdown)), + ])); } })?; diff --git a/crates/agent/src/tools/terminal_tool.rs b/crates/agent/src/tools/terminal_tool.rs index 6d30c19152001deaef5deeacbdf266e28ac03d08..2db4a2d86038579fca62224f3a7c567f93fc6922 100644 --- a/crates/agent/src/tools/terminal_tool.rs +++ b/crates/agent/src/tools/terminal_tool.rs @@ -112,10 +112,9 @@ impl AgentTool for TerminalTool { .await?; let terminal_id = terminal.id(cx)?; - event_stream.update_fields(acp::ToolCallUpdateFields { - content: Some(vec![acp::ToolCallContent::Terminal { terminal_id }]), - ..Default::default() - }); + event_stream.update_fields(acp::ToolCallUpdateFields::new().content(vec![ + acp::ToolCallContent::Terminal(acp::Terminal::new(terminal_id)), + ])); let exit_status = terminal.wait_for_exit(cx)?.await; let output = terminal.current_output(cx)?; diff --git a/crates/agent/src/tools/thinking_tool.rs b/crates/agent/src/tools/thinking_tool.rs index 0a68f7545f81ce3202c110b1435d33b57adf409c..96024326f6f1610f500972b1a98be45258e3966b 100644 --- a/crates/agent/src/tools/thinking_tool.rs +++ b/crates/agent/src/tools/thinking_tool.rs @@ -43,10 +43,8 @@ impl AgentTool for ThinkingTool { event_stream: ToolCallEventStream, _cx: &mut App, ) -> Task> { - event_stream.update_fields(acp::ToolCallUpdateFields { - content: Some(vec![input.content.into()]), - ..Default::default() - }); + event_stream + .update_fields(acp::ToolCallUpdateFields::new().content(vec![input.content.into()])); Task::ready(Ok("Finished thinking.".to_string())) } } diff --git a/crates/agent/src/tools/web_search_tool.rs b/crates/agent/src/tools/web_search_tool.rs index 03e9db6601579e082e4d83de50f1999209d9f197..d78b692126f62d6ed7fd00f585618ab6b6ba55e2 100644 --- a/crates/agent/src/tools/web_search_tool.rs +++ b/crates/agent/src/tools/web_search_tool.rs @@ -76,10 +76,8 @@ impl AgentTool for WebSearchTool { let response = match search_task.await { Ok(response) => response, Err(err) => { - event_stream.update_fields(acp::ToolCallUpdateFields { - title: Some("Web Search Failed".to_string()), - ..Default::default() - }); + event_stream + .update_fields(acp::ToolCallUpdateFields::new().title("Web Search Failed")); return Err(err); } }; @@ -107,26 +105,23 @@ fn emit_update(response: &WebSearchResponse, event_stream: &ToolCallEventStream) } else { format!("{} results", response.results.len()) }; - event_stream.update_fields(acp::ToolCallUpdateFields { - title: Some(format!("Searched the web: {result_text}")), - content: Some( - response - .results - .iter() - .map(|result| acp::ToolCallContent::Content { - content: acp::ContentBlock::ResourceLink(acp::ResourceLink { - name: result.title.clone(), - uri: result.url.clone(), - title: Some(result.title.clone()), - description: Some(result.text.clone()), - mime_type: None, - annotations: None, - size: None, - meta: None, - }), - }) - .collect(), - ), - ..Default::default() - }); + event_stream.update_fields( + acp::ToolCallUpdateFields::new() + .title(format!("Searched the web: {result_text}")) + .content( + response + .results + .iter() + .map(|result| { + acp::ToolCallContent::Content(acp::Content::new( + acp::ContentBlock::ResourceLink( + acp::ResourceLink::new(result.title.clone(), result.url.clone()) + .title(result.title.clone()) + .description(result.text.clone()), + ), + )) + }) + .collect(), + ), + ); } diff --git a/crates/agent_servers/src/acp.rs b/crates/agent_servers/src/acp.rs index a44bdd1f22478e92ace192c939561f855c2814bd..f035e981919deb2fa15069866507abd8be0ac209 100644 --- a/crates/agent_servers/src/acp.rs +++ b/crates/agent_servers/src/acp.rs @@ -76,7 +76,7 @@ pub async fn connect( Ok(Rc::new(conn) as _) } -const MINIMUM_SUPPORTED_VERSION: acp::ProtocolVersion = acp::V1; +const MINIMUM_SUPPORTED_VERSION: acp::ProtocolVersion = acp::ProtocolVersion::V1; impl AcpConnection { pub async fn stdio( @@ -173,29 +173,27 @@ impl AcpConnection { }); })?; + let mut client_info = acp::Implementation::new("zed", version); + if let Some(release_channel) = release_channel { + client_info = client_info.title(release_channel); + } let response = connection - .initialize(acp::InitializeRequest { - protocol_version: acp::VERSION, - client_capabilities: acp::ClientCapabilities { - fs: acp::FileSystemCapability { - read_text_file: true, - write_text_file: true, - meta: None, - }, - terminal: true, - meta: Some(serde_json::json!({ - // Experimental: Allow for rendering terminal output from the agents - "terminal_output": true, - "terminal-auth": true, - })), - }, - client_info: Some(acp::Implementation { - name: "zed".to_owned(), - title: release_channel.map(|c| c.to_owned()), - version, - }), - meta: None, - }) + .initialize( + acp::InitializeRequest::new(acp::ProtocolVersion::V1) + .client_capabilities( + acp::ClientCapabilities::new() + .fs(acp::FileSystemCapability::new() + .read_text_file(true) + .write_text_file(true)) + .terminal(true) + // Experimental: Allow for rendering terminal output from the agents + .meta(acp::Meta::from_iter([ + ("terminal_output".into(), true.into()), + ("terminal-auth".into(), true.into()), + ])), + ) + .client_info(client_info), + ) .await?; if response.protocol_version < MINIMUM_SUPPORTED_VERSION { @@ -253,14 +251,13 @@ impl AgentConnection for AcpConnection { let default_model = self.default_model.clone(); let cwd = cwd.to_path_buf(); let context_server_store = project.read(cx).context_server_store().read(cx); - let mcp_servers = - if project.read(cx).is_local() { - context_server_store - .configured_server_ids() - .iter() - .filter_map(|id| { - let configuration = context_server_store.configuration_for_server(id)?; - match &*configuration { + let mcp_servers = if project.read(cx).is_local() { + context_server_store + .configured_server_ids() + .iter() + .filter_map(|id| { + let configuration = context_server_store.configuration_for_server(id)?; + match &*configuration { project::context_server_store::ContextServerConfiguration::Custom { command, .. @@ -268,47 +265,41 @@ impl AgentConnection for AcpConnection { | project::context_server_store::ContextServerConfiguration::Extension { command, .. - } => Some(acp::McpServer::Stdio { - name: id.0.to_string(), - command: command.path.clone(), - args: command.args.clone(), - env: if let Some(env) = command.env.as_ref() { - env.iter() - .map(|(name, value)| acp::EnvVariable { - name: name.clone(), - value: value.clone(), - meta: None, - }) - .collect() - } else { - vec![] - }, - }), + } => Some(acp::McpServer::Stdio( + acp::McpServerStdio::new(id.0.to_string(), &command.path) + .args(command.args.clone()) + .env(if let Some(env) = command.env.as_ref() { + env.iter() + .map(|(name, value)| acp::EnvVariable::new(name, value)) + .collect() + } else { + vec![] + }), + )), project::context_server_store::ContextServerConfiguration::Http { url, headers, - } => Some(acp::McpServer::Http { - name: id.0.to_string(), - url: url.to_string(), - headers: headers.iter().map(|(name, value)| acp::HttpHeader { - name: name.clone(), - value: value.clone(), - meta: None, - }).collect(), - }), + } => Some(acp::McpServer::Http( + acp::McpServerHttp::new(id.0.to_string(), url.to_string()).headers( + headers + .iter() + .map(|(name, value)| acp::HttpHeader::new(name, value)) + .collect(), + ), + )), } - }) - .collect() - } else { - // In SSH projects, the external agent is running on the remote - // machine, and currently we only run MCP servers on the local - // machine. So don't pass any MCP servers to the agent in that case. - Vec::new() - }; + }) + .collect() + } else { + // In SSH projects, the external agent is running on the remote + // machine, and currently we only run MCP servers on the local + // machine. So don't pass any MCP servers to the agent in that case. + Vec::new() + }; cx.spawn(async move |cx| { let response = conn - .new_session(acp::NewSessionRequest { mcp_servers, cwd, meta: None }) + .new_session(acp::NewSessionRequest::new(cwd).mcp_servers(mcp_servers)) .await .map_err(|err| { if err.code == acp::ErrorCode::AUTH_REQUIRED.code { @@ -341,11 +332,7 @@ impl AgentConnection for AcpConnection { let modes = modes.clone(); let conn = conn.clone(); async move |_| { - let result = conn.set_session_mode(acp::SetSessionModeRequest { - session_id, - mode_id: default_mode, - meta: None, - }) + let result = conn.set_session_mode(acp::SetSessionModeRequest::new(session_id, default_mode)) .await.log_err(); if result.is_none() { @@ -388,11 +375,7 @@ impl AgentConnection for AcpConnection { let models = models.clone(); let conn = conn.clone(); async move |_| { - let result = conn.set_session_model(acp::SetSessionModelRequest { - session_id, - model_id: default_model, - meta: None, - }) + let result = conn.set_session_model(acp::SetSessionModelRequest::new(session_id, default_model)) .await.log_err(); if result.is_none() { @@ -456,12 +439,8 @@ impl AgentConnection for AcpConnection { fn authenticate(&self, method_id: acp::AuthMethodId, cx: &mut App) -> Task> { let conn = self.connection.clone(); cx.foreground_executor().spawn(async move { - conn.authenticate(acp::AuthenticateRequest { - method_id: method_id.clone(), - meta: None, - }) - .await?; - + conn.authenticate(acp::AuthenticateRequest::new(method_id)) + .await?; Ok(()) }) } @@ -515,10 +494,7 @@ impl AgentConnection for AcpConnection { && (details.contains("This operation was aborted") || details.contains("The user aborted a request")) { - Ok(acp::PromptResponse { - stop_reason: acp::StopReason::Cancelled, - meta: None, - }) + Ok(acp::PromptResponse::new(acp::StopReason::Cancelled)) } else { Err(anyhow!(details)) } @@ -535,10 +511,7 @@ impl AgentConnection for AcpConnection { session.suppress_abort_err = true; } let conn = self.connection.clone(); - let params = acp::CancelNotification { - session_id: session_id.clone(), - meta: None, - }; + let params = acp::CancelNotification::new(session_id.clone()); cx.foreground_executor() .spawn(async move { conn.cancel(params).await }) .detach(); @@ -619,11 +592,7 @@ impl acp_thread::AgentSessionModes for AcpSessionModes { let state = self.state.clone(); cx.foreground_executor().spawn(async move { let result = connection - .set_session_mode(acp::SetSessionModeRequest { - session_id, - mode_id, - meta: None, - }) + .set_session_mode(acp::SetSessionModeRequest::new(session_id, mode_id)) .await; if result.is_err() { @@ -682,11 +651,7 @@ impl acp_thread::AgentModelSelector for AcpModelSelector { let state = self.state.clone(); cx.foreground_executor().spawn(async move { let result = connection - .set_session_model(acp::SetSessionModelRequest { - session_id, - model_id, - meta: None, - }) + .set_session_model(acp::SetSessionModelRequest::new(session_id, model_id)) .await; if result.is_err() { @@ -748,10 +713,7 @@ impl acp::Client for ClientDelegate { let outcome = task.await; - Ok(acp::RequestPermissionResponse { - outcome, - meta: None, - }) + Ok(acp::RequestPermissionResponse::new(outcome)) } async fn write_text_file( @@ -783,10 +745,7 @@ impl acp::Client for ClientDelegate { let content = task.await?; - Ok(acp::ReadTextFileResponse { - content, - meta: None, - }) + Ok(acp::ReadTextFileResponse::new(content)) } async fn session_notification( @@ -821,7 +780,7 @@ impl acp::Client for ClientDelegate { if let Some(terminal_info) = meta.get("terminal_info") { if let Some(id_str) = terminal_info.get("terminal_id").and_then(|v| v.as_str()) { - let terminal_id = acp::TerminalId(id_str.into()); + let terminal_id = acp::TerminalId::new(id_str); let cwd = terminal_info .get("cwd") .and_then(|v| v.as_str().map(PathBuf::from)); @@ -837,7 +796,7 @@ impl acp::Client for ClientDelegate { let lower = cx.new(|cx| builder.subscribe(cx)); thread.on_terminal_provider_event( TerminalProviderEvent::Created { - terminal_id: terminal_id.clone(), + terminal_id, label: tc.title.clone(), cwd, output_byte_limit: None, @@ -862,15 +821,12 @@ impl acp::Client for ClientDelegate { if let Some(meta) = &tcu.meta { if let Some(term_out) = meta.get("terminal_output") { if let Some(id_str) = term_out.get("terminal_id").and_then(|v| v.as_str()) { - let terminal_id = acp::TerminalId(id_str.into()); + let terminal_id = acp::TerminalId::new(id_str); if let Some(s) = term_out.get("data").and_then(|v| v.as_str()) { let data = s.as_bytes().to_vec(); let _ = session.thread.update(&mut self.cx.clone(), |thread, cx| { thread.on_terminal_provider_event( - TerminalProviderEvent::Output { - terminal_id: terminal_id.clone(), - data, - }, + TerminalProviderEvent::Output { terminal_id, data }, cx, ); }); @@ -881,21 +837,19 @@ impl acp::Client for ClientDelegate { // terminal_exit if let Some(term_exit) = meta.get("terminal_exit") { if let Some(id_str) = term_exit.get("terminal_id").and_then(|v| v.as_str()) { - let terminal_id = acp::TerminalId(id_str.into()); - let status = acp::TerminalExitStatus { - exit_code: term_exit - .get("exit_code") - .and_then(|v| v.as_u64()) - .map(|i| i as u32), - signal: term_exit - .get("signal") - .and_then(|v| v.as_str().map(|s| s.to_string())), - meta: None, - }; + let terminal_id = acp::TerminalId::new(id_str); + let mut status = acp::TerminalExitStatus::new(); + if let Some(code) = term_exit.get("exit_code").and_then(|v| v.as_u64()) { + status = status.exit_code(code as u32) + } + if let Some(signal) = term_exit.get("signal").and_then(|v| v.as_str()) { + status = status.signal(signal); + } + let _ = session.thread.update(&mut self.cx.clone(), |thread, cx| { thread.on_terminal_provider_event( TerminalProviderEvent::Exit { - terminal_id: terminal_id.clone(), + terminal_id, status, }, cx, @@ -932,7 +886,7 @@ impl acp::Client for ClientDelegate { // Register with renderer let terminal_entity = thread.update(&mut self.cx.clone(), |thread, cx| { thread.register_terminal_created( - acp::TerminalId(uuid::Uuid::new_v4().to_string().into()), + acp::TerminalId::new(uuid::Uuid::new_v4().to_string()), format!("{} {}", args.command, args.args.join(" ")), args.cwd.clone(), args.output_byte_limit, @@ -942,10 +896,7 @@ impl acp::Client for ClientDelegate { })?; let terminal_id = terminal_entity.read_with(&self.cx, |terminal, _| terminal.id().clone())?; - Ok(acp::CreateTerminalResponse { - terminal_id, - meta: None, - }) + Ok(acp::CreateTerminalResponse::new(terminal_id)) } async fn kill_terminal_command( @@ -1006,10 +957,7 @@ impl acp::Client for ClientDelegate { })?? .await; - Ok(acp::WaitForTerminalExitResponse { - exit_status, - meta: None, - }) + Ok(acp::WaitForTerminalExitResponse::new(exit_status)) } } diff --git a/crates/agent_servers/src/claude.rs b/crates/agent_servers/src/claude.rs index ac79ab7484de90a84ce3d6720f54bcec6addc6b5..f49dce59c4282eb278e16ef664c75ed56652de2e 100644 --- a/crates/agent_servers/src/claude.rs +++ b/crates/agent_servers/src/claude.rs @@ -41,7 +41,7 @@ impl AgentServer for ClaudeCode { settings .as_ref() - .and_then(|s| s.default_mode.clone().map(|m| acp::SessionModeId(m.into()))) + .and_then(|s| s.default_mode.clone().map(acp::SessionModeId::new)) } fn set_default_mode(&self, mode_id: Option, fs: Arc, cx: &mut App) { @@ -62,7 +62,7 @@ impl AgentServer for ClaudeCode { settings .as_ref() - .and_then(|s| s.default_model.clone().map(|m| acp::ModelId(m.into()))) + .and_then(|s| s.default_model.clone().map(acp::ModelId::new)) } fn set_default_model(&self, model_id: Option, fs: Arc, cx: &mut App) { diff --git a/crates/agent_servers/src/codex.rs b/crates/agent_servers/src/codex.rs index ec01cd4e523b5696b2f09b5e51e7137fcfb16c91..d14d2f0c9aeb499624943962437821d571bc0299 100644 --- a/crates/agent_servers/src/codex.rs +++ b/crates/agent_servers/src/codex.rs @@ -42,7 +42,7 @@ impl AgentServer for Codex { settings .as_ref() - .and_then(|s| s.default_mode.clone().map(|m| acp::SessionModeId(m.into()))) + .and_then(|s| s.default_mode.clone().map(acp::SessionModeId::new)) } fn set_default_mode(&self, mode_id: Option, fs: Arc, cx: &mut App) { @@ -63,7 +63,7 @@ impl AgentServer for Codex { settings .as_ref() - .and_then(|s| s.default_model.clone().map(|m| acp::ModelId(m.into()))) + .and_then(|s| s.default_model.clone().map(acp::ModelId::new)) } fn set_default_model(&self, model_id: Option, fs: Arc, cx: &mut App) { diff --git a/crates/agent_servers/src/custom.rs b/crates/agent_servers/src/custom.rs index e7625c2cc06095c9a24a2537e4e83bced26d73f3..634b31e90267e064f0d0df9b6014d279a44a7986 100644 --- a/crates/agent_servers/src/custom.rs +++ b/crates/agent_servers/src/custom.rs @@ -44,7 +44,7 @@ impl crate::AgentServer for CustomAgentServer { settings .as_ref() - .and_then(|s| s.default_mode().map(|m| acp::SessionModeId(m.into()))) + .and_then(|s| s.default_mode().map(acp::SessionModeId::new)) } fn set_default_mode(&self, mode_id: Option, fs: Arc, cx: &mut App) { @@ -80,7 +80,7 @@ impl crate::AgentServer for CustomAgentServer { settings .as_ref() - .and_then(|s| s.default_model().map(|m| acp::ModelId(m.into()))) + .and_then(|s| s.default_model().map(acp::ModelId::new)) } fn set_default_model(&self, model_id: Option, fs: Arc, cx: &mut App) { diff --git a/crates/agent_servers/src/e2e_tests.rs b/crates/agent_servers/src/e2e_tests.rs index 824b999bdaff46cf3ad3a570b62fecd596612563..9db7535b5e55d88d6856774c20365bbac46fc81e 100644 --- a/crates/agent_servers/src/e2e_tests.rs +++ b/crates/agent_servers/src/e2e_tests.rs @@ -82,26 +82,9 @@ where .update(cx, |thread, cx| { thread.send( vec![ - acp::ContentBlock::Text(acp::TextContent { - text: "Read the file ".into(), - annotations: None, - meta: None, - }), - acp::ContentBlock::ResourceLink(acp::ResourceLink { - uri: "foo.rs".into(), - name: "foo.rs".into(), - annotations: None, - description: None, - mime_type: None, - size: None, - title: None, - meta: None, - }), - acp::ContentBlock::Text(acp::TextContent { - text: " and tell me what the content of the println! is".into(), - annotations: None, - meta: None, - }), + "Read the file ".into(), + acp::ContentBlock::ResourceLink(acp::ResourceLink::new("foo.rs", "foo.rs")), + " and tell me what the content of the println! is".into(), ], cx, ) @@ -429,7 +412,7 @@ macro_rules! common_e2e_tests { async fn tool_call_with_permission(cx: &mut ::gpui::TestAppContext) { $crate::e2e_tests::test_tool_call_with_permission( $server, - ::agent_client_protocol::PermissionOptionId($allow_option_id.into()), + ::agent_client_protocol::PermissionOptionId::new($allow_option_id), cx, ) .await; diff --git a/crates/agent_ui/src/acp/entry_view_state.rs b/crates/agent_ui/src/acp/entry_view_state.rs index 6fb94dfb6b84826d715e9b28163e9968fc2df3b9..53f24947658be8def877eb6b3a7d4e29b541d0c0 100644 --- a/crates/agent_ui/src/acp/entry_view_state.rs +++ b/crates/agent_ui/src/acp/entry_view_state.rs @@ -432,24 +432,11 @@ mod tests { let (workspace, cx) = cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx)); - let tool_call = acp::ToolCall { - id: acp::ToolCallId("tool".into()), - title: "Tool call".into(), - kind: acp::ToolKind::Other, - status: acp::ToolCallStatus::InProgress, - content: vec![acp::ToolCallContent::Diff { - diff: acp::Diff { - path: "/project/hello.txt".into(), - old_text: Some("hi world".into()), - new_text: "hello world".into(), - meta: None, - }, - }], - locations: vec![], - raw_input: None, - raw_output: None, - meta: None, - }; + let tool_call = acp::ToolCall::new("tool", "Tool call") + .status(acp::ToolCallStatus::InProgress) + .content(vec![acp::ToolCallContent::Diff( + acp::Diff::new("/project/hello.txt", "hello world").old_text("hi world"), + )]); let connection = Rc::new(StubAgentConnection::new()); let thread = cx .update(|_, cx| { diff --git a/crates/agent_ui/src/acp/message_editor.rs b/crates/agent_ui/src/acp/message_editor.rs index facb86f3b87e746d35d8b91f27550e351b10e8b6..ae634e45dc17cc471d9ac621faf5b98c0a754c2b 100644 --- a/crates/agent_ui/src/acp/message_editor.rs +++ b/crates/agent_ui/src/acp/message_editor.rs @@ -225,8 +225,13 @@ impl MessageEditor { .iter() .find(|command| command.name == command_name)?; - let acp::AvailableCommandInput::Unstructured { mut hint } = - available_command.input.clone()?; + let acp::AvailableCommandInput::Unstructured(acp::UnstructuredCommandInput { + mut hint, + .. + }) = available_command.input.clone()? + else { + return None; + }; let mut hint_pos = MultiBufferOffset(parsed_command.source_range.end) + 1usize; if hint_pos > snapshot.len() { @@ -403,34 +408,28 @@ impl MessageEditor { } => { all_tracked_buffers.extend(tracked_buffers.iter().cloned()); if supports_embedded_context { - acp::ContentBlock::Resource(acp::EmbeddedResource { - annotations: None, - resource: - acp::EmbeddedResourceResource::TextResourceContents( - acp::TextResourceContents { - mime_type: None, - text: content.clone(), - uri: uri.to_uri().to_string(), - meta: None, - }, + acp::ContentBlock::Resource(acp::EmbeddedResource::new( + acp::EmbeddedResourceResource::TextResourceContents( + acp::TextResourceContents::new( + content.clone(), + uri.to_uri().to_string(), ), - meta: None, - }) + ), + )) } else { - acp::ContentBlock::ResourceLink(acp::ResourceLink { - name: uri.name(), - uri: uri.to_uri().to_string(), - annotations: None, - description: None, - mime_type: None, - size: None, - title: None, - meta: None, - }) + acp::ContentBlock::ResourceLink(acp::ResourceLink::new( + uri.name(), + uri.to_uri().to_string(), + )) } } Mention::Image(mention_image) => { - let uri = match uri { + let mut image = acp::ImageContent::new( + mention_image.data.clone(), + mention_image.format.mime_type(), + ); + + if let Some(uri) = match uri { MentionUri::File { .. } => Some(uri.to_uri().to_string()), MentionUri::PastedImage => None, other => { @@ -440,25 +439,14 @@ impl MessageEditor { ); None } + } { + image = image.uri(uri) }; - acp::ContentBlock::Image(acp::ImageContent { - annotations: None, - data: mention_image.data.to_string(), - mime_type: mention_image.format.mime_type().into(), - uri, - meta: None, - }) + acp::ContentBlock::Image(image) } - Mention::Link => acp::ContentBlock::ResourceLink(acp::ResourceLink { - name: uri.name(), - uri: uri.to_uri().to_string(), - annotations: None, - description: None, - mime_type: None, - size: None, - title: None, - meta: None, - }), + Mention::Link => acp::ContentBlock::ResourceLink( + acp::ResourceLink::new(uri.name(), uri.to_uri().to_string()), + ), }; chunks.push(chunk); ix = crease_range.end.0; @@ -746,8 +734,7 @@ impl MessageEditor { uri, data, mime_type, - annotations: _, - meta: _, + .. }) => { let mention_uri = if let Some(uri) = uri { MentionUri::parse(&uri, path_style) @@ -773,7 +760,7 @@ impl MessageEditor { }), )); } - acp::ContentBlock::Audio(_) | acp::ContentBlock::Resource(_) => {} + _ => {} } } @@ -1092,12 +1079,7 @@ mod tests { assert!(error_message.contains("Available commands: none")); // Now simulate Claude providing its list of available commands (which doesn't include file) - available_commands.replace(vec![acp::AvailableCommand { - name: "help".to_string(), - description: "Get help".to_string(), - input: None, - meta: None, - }]); + available_commands.replace(vec![acp::AvailableCommand::new("help", "Get help")]); // Test that unsupported slash commands trigger an error when we have a list of available commands editor.update_in(cx, |editor, window, cx| { @@ -1211,20 +1193,12 @@ mod tests { let history_store = cx.new(|cx| HistoryStore::new(text_thread_store, cx)); let prompt_capabilities = Rc::new(RefCell::new(acp::PromptCapabilities::default())); let available_commands = Rc::new(RefCell::new(vec![ - acp::AvailableCommand { - name: "quick-math".to_string(), - description: "2 + 2 = 4 - 1 = 3".to_string(), - input: None, - meta: None, - }, - acp::AvailableCommand { - name: "say-hello".to_string(), - description: "Say hello to whoever you want".to_string(), - input: Some(acp::AvailableCommandInput::Unstructured { - hint: "".to_string(), - }), - meta: None, - }, + acp::AvailableCommand::new("quick-math", "2 + 2 = 4 - 1 = 3"), + acp::AvailableCommand::new("say-hello", "Say hello to whoever you want").input( + acp::AvailableCommandInput::Unstructured(acp::UnstructuredCommandInput::new( + "", + )), + ), ])); let editor = workspace.update_in(&mut cx, |workspace, window, cx| { @@ -1504,12 +1478,12 @@ mod tests { editor.set_text("", window, cx); }); - prompt_capabilities.replace(acp::PromptCapabilities { - image: true, - audio: true, - embedded_context: true, - meta: None, - }); + prompt_capabilities.replace( + acp::PromptCapabilities::new() + .image(true) + .audio(true) + .embedded_context(true), + ); cx.simulate_input("Lorem "); @@ -1960,11 +1934,9 @@ mod tests { cx, ); // Enable embedded context so files are actually included - editor.prompt_capabilities.replace(acp::PromptCapabilities { - embedded_context: true, - meta: None, - ..Default::default() - }); + editor + .prompt_capabilities + .replace(acp::PromptCapabilities::new().embedded_context(true)); editor }) }); @@ -2043,7 +2015,7 @@ mod tests { // Create a thread metadata to insert as summary let thread_metadata = agent::DbThreadMetadata { - id: acp::SessionId("thread-123".into()), + id: acp::SessionId::new("thread-123"), title: "Previous Conversation".into(), updated_at: chrono::Utc::now(), }; @@ -2150,14 +2122,7 @@ mod tests { .await .unwrap(); - assert_eq!( - content, - vec![acp::ContentBlock::Text(acp::TextContent { - text: "してhello world".into(), - annotations: None, - meta: None - })] - ); + assert_eq!(content, vec!["してhello world".into()]); } #[gpui::test] @@ -2236,38 +2201,24 @@ mod tests { .0; let main_rs_uri = if cfg!(windows) { - "file:///C:/project/src/main.rs".to_string() + "file:///C:/project/src/main.rs" } else { - "file:///project/src/main.rs".to_string() + "file:///project/src/main.rs" }; // When embedded context is `false` we should get a resource link pretty_assertions::assert_eq!( content, vec![ - acp::ContentBlock::Text(acp::TextContent { - text: "What is in ".to_string(), - annotations: None, - meta: None - }), - acp::ContentBlock::ResourceLink(acp::ResourceLink { - uri: main_rs_uri.clone(), - name: "main.rs".to_string(), - annotations: None, - meta: None, - description: None, - mime_type: None, - size: None, - title: None, - }) + "What is in ".into(), + acp::ContentBlock::ResourceLink(acp::ResourceLink::new("main.rs", main_rs_uri)) ] ); message_editor.update(cx, |editor, _cx| { - editor.prompt_capabilities.replace(acp::PromptCapabilities { - embedded_context: true, - ..Default::default() - }) + editor + .prompt_capabilities + .replace(acp::PromptCapabilities::new().embedded_context(true)) }); let content = message_editor @@ -2280,23 +2231,12 @@ mod tests { pretty_assertions::assert_eq!( content, vec![ - acp::ContentBlock::Text(acp::TextContent { - text: "What is in ".to_string(), - annotations: None, - meta: None - }), - acp::ContentBlock::Resource(acp::EmbeddedResource { - resource: acp::EmbeddedResourceResource::TextResourceContents( - acp::TextResourceContents { - text: file_content.to_string(), - uri: main_rs_uri, - mime_type: None, - meta: None - } - ), - annotations: None, - meta: None - }) + "What is in ".into(), + acp::ContentBlock::Resource(acp::EmbeddedResource::new( + acp::EmbeddedResourceResource::TextResourceContents( + acp::TextResourceContents::new(file_content, main_rs_uri) + ) + )) ] ); } diff --git a/crates/agent_ui/src/acp/model_selector.rs b/crates/agent_ui/src/acp/model_selector.rs index 8a0c3c9df90e73d0ef00ecd7232115729dd35347..f9710ad9b3aac29546dbe66a518a198d9b113385 100644 --- a/crates/agent_ui/src/acp/model_selector.rs +++ b/crates/agent_ui/src/acp/model_selector.rs @@ -464,7 +464,7 @@ mod tests { models .into_iter() .map(|model| acp_thread::AgentModelInfo { - id: acp::ModelId(model.to_string().into()), + id: acp::ModelId::new(model.to_string()), name: model.to_string().into(), description: None, icon: None, diff --git a/crates/agent_ui/src/acp/thread_view.rs b/crates/agent_ui/src/acp/thread_view.rs index 9c4717c5189eb3397ec153560156d9c77e5125ba..aedb96bb82f07723f934d0ec73aa1fd545461f00 100644 --- a/crates/agent_ui/src/acp/thread_view.rs +++ b/crates/agent_ui/src/acp/thread_view.rs @@ -1476,18 +1476,8 @@ impl AcpThreadView { .iter() .any(|method| method.id.0.as_ref() == "claude-login") { - available_commands.push(acp::AvailableCommand { - name: "login".to_owned(), - description: "Authenticate".to_owned(), - input: None, - meta: None, - }); - available_commands.push(acp::AvailableCommand { - name: "logout".to_owned(), - description: "Authenticate".to_owned(), - input: None, - meta: None, - }); + available_commands.push(acp::AvailableCommand::new("login", "Authenticate")); + available_commands.push(acp::AvailableCommand::new("logout", "Authenticate")); } let has_commands = !available_commands.is_empty(); @@ -2562,7 +2552,7 @@ impl AcpThreadView { acp::ToolKind::Think => IconName::ToolThink, acp::ToolKind::Fetch => IconName::ToolWeb, acp::ToolKind::SwitchMode => IconName::ArrowRightLeft, - acp::ToolKind::Other => IconName::ToolHammer, + acp::ToolKind::Other | _ => IconName::ToolHammer, }) } .size(IconSize::Small) @@ -2814,7 +2804,7 @@ impl AcpThreadView { }) .gap_0p5() .children(options.iter().map(move |option| { - let option_id = SharedString::from(option.id.0.clone()); + let option_id = SharedString::from(option.option_id.0.clone()); Button::new((option_id, entry_ix), option.name.clone()) .map(|this| { let (this, action) = match option.kind { @@ -2830,7 +2820,7 @@ impl AcpThreadView { this.icon(IconName::Close).icon_color(Color::Error), Some(&RejectOnce as &dyn Action), ), - acp::PermissionOptionKind::RejectAlways => { + acp::PermissionOptionKind::RejectAlways | _ => { (this.icon(IconName::Close).icon_color(Color::Error), None) } }; @@ -2855,7 +2845,7 @@ impl AcpThreadView { .label_size(LabelSize::Small) .on_click(cx.listener({ let tool_call_id = tool_call_id.clone(); - let option_id = option.id.clone(); + let option_id = option.option_id.clone(); let option_kind = option.kind; move |this, _, window, cx| { this.authorize_tool_call( @@ -3543,7 +3533,7 @@ impl AcpThreadView { ); this.authenticate( - acp::AuthMethodId(method_id.clone()), + acp::AuthMethodId::new(method_id.clone()), window, cx, ) @@ -3837,10 +3827,6 @@ impl AcpThreadView { .text_xs() .text_color(cx.theme().colors().text_muted) .child(match entry.status { - acp::PlanEntryStatus::Pending => Icon::new(IconName::TodoPending) - .size(IconSize::Small) - .color(Color::Muted) - .into_any_element(), acp::PlanEntryStatus::InProgress => { Icon::new(IconName::TodoProgress) .size(IconSize::Small) @@ -3854,6 +3840,12 @@ impl AcpThreadView { .color(Color::Success) .into_any_element() } + acp::PlanEntryStatus::Pending | _ => { + Icon::new(IconName::TodoPending) + .size(IconSize::Small) + .color(Color::Muted) + .into_any_element() + } }) .child(MarkdownElement::new( entry.content.clone(), @@ -4427,7 +4419,7 @@ impl AcpThreadView { self.authorize_tool_call( tool_call.id.clone(), - option.id.clone(), + option.option_id.clone(), option.kind, window, cx, @@ -6243,27 +6235,18 @@ pub(crate) mod tests { async fn test_notification_for_tool_authorization(cx: &mut TestAppContext) { init_test(cx); - let tool_call_id = acp::ToolCallId("1".into()); - let tool_call = acp::ToolCall { - id: tool_call_id.clone(), - title: "Label".into(), - kind: acp::ToolKind::Edit, - status: acp::ToolCallStatus::Pending, - content: vec!["hi".into()], - locations: vec![], - raw_input: None, - raw_output: None, - meta: None, - }; + let tool_call_id = acp::ToolCallId::new("1"); + let tool_call = acp::ToolCall::new(tool_call_id.clone(), "Label") + .kind(acp::ToolKind::Edit) + .content(vec!["hi".into()]); let connection = StubAgentConnection::new().with_permission_requests(HashMap::from_iter([( tool_call_id, - vec![acp::PermissionOption { - id: acp::PermissionOptionId("1".into()), - name: "Allow".into(), - kind: acp::PermissionOptionKind::AllowOnce, - meta: None, - }], + vec![acp::PermissionOption::new( + "1".into(), + "Allow", + acp::PermissionOptionKind::AllowOnce, + )], )])); connection.set_next_prompt_updates(vec![acp::SessionUpdate::ToolCall(tool_call)]); @@ -6482,10 +6465,7 @@ pub(crate) mod tests { fn default_response() -> Self { let conn = StubAgentConnection::new(); conn.set_next_prompt_updates(vec![acp::SessionUpdate::AgentMessageChunk( - acp::ContentChunk { - content: "Default response".into(), - meta: None, - }, + acp::ContentChunk::new("Default response".into()), )]); Self::new(conn) } @@ -6542,13 +6522,13 @@ pub(crate) mod tests { self, project, action_log, - SessionId("test".into()), - watch::Receiver::constant(acp::PromptCapabilities { - image: true, - audio: true, - embedded_context: true, - meta: None, - }), + SessionId::new("test"), + watch::Receiver::constant( + acp::PromptCapabilities::new() + .image(true) + .audio(true) + .embedded_context(true), + ), cx, ) }))) @@ -6606,13 +6586,13 @@ pub(crate) mod tests { self, project, action_log, - SessionId("test".into()), - watch::Receiver::constant(acp::PromptCapabilities { - image: true, - audio: true, - embedded_context: true, - meta: None, - }), + SessionId::new("test"), + watch::Receiver::constant( + acp::PromptCapabilities::new() + .image(true) + .audio(true) + .embedded_context(true), + ), cx, ) }))) @@ -6636,10 +6616,7 @@ pub(crate) mod tests { _params: acp::PromptRequest, _cx: &mut App, ) -> Task> { - Task::ready(Ok(acp::PromptResponse { - stop_reason: acp::StopReason::Refusal, - meta: None, - })) + Task::ready(Ok(acp::PromptResponse::new(acp::StopReason::Refusal))) } fn cancel(&self, _session_id: &acp::SessionId, _cx: &mut App) { @@ -6707,24 +6684,14 @@ pub(crate) mod tests { .unwrap(); // First user message - connection.set_next_prompt_updates(vec![acp::SessionUpdate::ToolCall(acp::ToolCall { - id: acp::ToolCallId("tool1".into()), - title: "Edit file 1".into(), - kind: acp::ToolKind::Edit, - status: acp::ToolCallStatus::Completed, - content: vec![acp::ToolCallContent::Diff { - diff: acp::Diff { - path: "/project/test1.txt".into(), - old_text: Some("old content 1".into()), - new_text: "new content 1".into(), - meta: None, - }, - }], - locations: vec![], - raw_input: None, - raw_output: None, - meta: None, - })]); + connection.set_next_prompt_updates(vec![acp::SessionUpdate::ToolCall( + acp::ToolCall::new("tool1", "Edit file 1") + .kind(acp::ToolKind::Edit) + .status(acp::ToolCallStatus::Completed) + .content(vec![acp::ToolCallContent::Diff( + acp::Diff::new("/project/test1.txt", "new content 1").old_text("old content 1"), + )]), + )]); thread .update(cx, |thread, cx| thread.send_raw("Give me a diff", cx)) @@ -6750,24 +6717,14 @@ pub(crate) mod tests { }); // Second user message - connection.set_next_prompt_updates(vec![acp::SessionUpdate::ToolCall(acp::ToolCall { - id: acp::ToolCallId("tool2".into()), - title: "Edit file 2".into(), - kind: acp::ToolKind::Edit, - status: acp::ToolCallStatus::Completed, - content: vec![acp::ToolCallContent::Diff { - diff: acp::Diff { - path: "/project/test2.txt".into(), - old_text: Some("old content 2".into()), - new_text: "new content 2".into(), - meta: None, - }, - }], - locations: vec![], - raw_input: None, - raw_output: None, - meta: None, - })]); + connection.set_next_prompt_updates(vec![acp::SessionUpdate::ToolCall( + acp::ToolCall::new("tool2", "Edit file 2") + .kind(acp::ToolKind::Edit) + .status(acp::ToolCallStatus::Completed) + .content(vec![acp::ToolCallContent::Diff( + acp::Diff::new("/project/test2.txt", "new content 2").old_text("old content 2"), + )]), + )]); thread .update(cx, |thread, cx| thread.send_raw("Another one", cx)) @@ -6841,14 +6798,7 @@ pub(crate) mod tests { let connection = StubAgentConnection::new(); connection.set_next_prompt_updates(vec![acp::SessionUpdate::AgentMessageChunk( - acp::ContentChunk { - content: acp::ContentBlock::Text(acp::TextContent { - text: "Response".into(), - annotations: None, - meta: None, - }), - meta: None, - }, + acp::ContentChunk::new("Response".into()), )]); let (thread_view, cx) = setup_thread_view(StubAgentServer::new(connection), cx).await; @@ -6934,14 +6884,7 @@ pub(crate) mod tests { let connection = StubAgentConnection::new(); connection.set_next_prompt_updates(vec![acp::SessionUpdate::AgentMessageChunk( - acp::ContentChunk { - content: acp::ContentBlock::Text(acp::TextContent { - text: "Response".into(), - annotations: None, - meta: None, - }), - meta: None, - }, + acp::ContentChunk::new("Response".into()), )]); let (thread_view, cx) = @@ -6981,14 +6924,7 @@ pub(crate) mod tests { // Send connection.set_next_prompt_updates(vec![acp::SessionUpdate::AgentMessageChunk( - acp::ContentChunk { - content: acp::ContentBlock::Text(acp::TextContent { - text: "New Response".into(), - annotations: None, - meta: None, - }), - meta: None, - }, + acp::ContentChunk::new("New Response".into()), )]); user_message_editor.update_in(cx, |_editor, window, cx| { @@ -7076,14 +7012,7 @@ pub(crate) mod tests { cx.update(|_, cx| { connection.send_update( session_id.clone(), - acp::SessionUpdate::AgentMessageChunk(acp::ContentChunk { - content: acp::ContentBlock::Text(acp::TextContent { - text: "Response".into(), - annotations: None, - meta: None, - }), - meta: None, - }), + acp::SessionUpdate::AgentMessageChunk(acp::ContentChunk::new("Response".into())), cx, ); connection.end_turn(session_id, acp::StopReason::EndTurn); @@ -7135,10 +7064,9 @@ pub(crate) mod tests { cx.update(|_, cx| { connection.send_update( session_id.clone(), - acp::SessionUpdate::AgentMessageChunk(acp::ContentChunk { - content: "Message 1 resp".into(), - meta: None, - }), + acp::SessionUpdate::AgentMessageChunk(acp::ContentChunk::new( + "Message 1 resp".into(), + )), cx, ); }); @@ -7172,10 +7100,7 @@ pub(crate) mod tests { // Simulate a response sent after beginning to cancel connection.send_update( session_id.clone(), - acp::SessionUpdate::AgentMessageChunk(acp::ContentChunk { - content: "onse".into(), - meta: None, - }), + acp::SessionUpdate::AgentMessageChunk(acp::ContentChunk::new("onse".into())), cx, ); }); @@ -7206,10 +7131,9 @@ pub(crate) mod tests { cx.update(|_, cx| { connection.send_update( session_id.clone(), - acp::SessionUpdate::AgentMessageChunk(acp::ContentChunk { - content: "Message 2 response".into(), - meta: None, - }), + acp::SessionUpdate::AgentMessageChunk(acp::ContentChunk::new( + "Message 2 response".into(), + )), cx, ); connection.end_turn(session_id.clone(), acp::StopReason::EndTurn); @@ -7248,14 +7172,7 @@ pub(crate) mod tests { let connection = StubAgentConnection::new(); connection.set_next_prompt_updates(vec![acp::SessionUpdate::AgentMessageChunk( - acp::ContentChunk { - content: acp::ContentBlock::Text(acp::TextContent { - text: "Response".into(), - annotations: None, - meta: None, - }), - meta: None, - }, + acp::ContentChunk::new("Response".into()), )]); let (thread_view, cx) = setup_thread_view(StubAgentServer::new(connection), cx).await; @@ -7334,14 +7251,7 @@ pub(crate) mod tests { let connection = StubAgentConnection::new(); connection.set_next_prompt_updates(vec![acp::SessionUpdate::AgentMessageChunk( - acp::ContentChunk { - content: acp::ContentBlock::Text(acp::TextContent { - text: "Response".into(), - annotations: None, - meta: None, - }), - meta: None, - }, + acp::ContentChunk::new("Response".into()), )]); let (thread_view, cx) = setup_thread_view(StubAgentServer::new(connection), cx).await; diff --git a/crates/eval/src/example.rs b/crates/eval/src/example.rs index 84c47766e96948bccfc01f3b4472b5100c4b7b64..c4d076037f637ffdf2b8d4c8bbed05349d9ea38e 100644 --- a/crates/eval/src/example.rs +++ b/crates/eval/src/example.rs @@ -261,7 +261,7 @@ impl ExampleContext { .expect("Unknown tool_name content in meta"); tool_uses_by_id.insert( - tool_call.id, + tool_call.tool_call_id, ToolUse { name: tool_name.to_string(), value: tool_call.raw_input.unwrap_or_default(), @@ -277,7 +277,9 @@ impl ExampleContext { ThreadEvent::ToolCallUpdate(tool_call_update) => { if let acp_thread::ToolCallUpdate::UpdateFields(update) = tool_call_update { if let Some(raw_input) = update.fields.raw_input { - if let Some(tool_use) = tool_uses_by_id.get_mut(&update.id) { + if let Some(tool_use) = + tool_uses_by_id.get_mut(&update.tool_call_id) + { tool_use.value = raw_input; } } @@ -290,7 +292,7 @@ impl ExampleContext { update.fields.status == Some(acp::ToolCallStatus::Completed); let tool_use = tool_uses_by_id - .remove(&update.id) + .remove(&update.tool_call_id) .expect("Unrecognized tool call completed"); let log_message = if succeeded { @@ -337,10 +339,7 @@ impl ExampleContext { acp::StopReason::MaxTurnRequests => { return Err(anyhow!("Exceeded maximum turn requests")); } - acp::StopReason::Refusal => { - return Err(anyhow!("Refusal")); - } - acp::StopReason::Cancelled => return Err(anyhow!("Cancelled")), + stop_reason => return Err(anyhow!("{stop_reason:?}")), }, } } diff --git a/crates/eval/src/instance.rs b/crates/eval/src/instance.rs index 99a8af053609b98efe29a179964a38137c4ba021..787d3372c8248a59e74fc67f347d5bf3b064890f 100644 --- a/crates/eval/src/instance.rs +++ b/crates/eval/src/instance.rs @@ -303,13 +303,12 @@ impl ExampleInstance { let context_server_registry = cx.new(|cx| ContextServerRegistry::new(project.read(cx).context_server_store(), cx)); let thread = if let Some(json) = &meta.existing_thread_json { - let session_id = acp::SessionId( + let session_id = acp::SessionId::new( rand::rng() .sample_iter(&distr::Alphanumeric) .take(7) .map(char::from) - .collect::() - .into(), + .collect::(), ); let db_thread = agent::DbThread::from_json(json.as_bytes()).expect("Can't read serialized thread"); @@ -640,7 +639,7 @@ impl agent::ThreadEnvironment for EvalThreadEnvironment { cx.spawn(async move |cx| { let language_registry = project.read_with(cx, |project, _cx| project.languages().clone())?; - let id = acp::TerminalId(uuid::Uuid::new_v4().to_string().into()); + let id = acp::TerminalId::new(uuid::Uuid::new_v4().to_string()); let terminal = acp_thread::create_terminal_entity(command, &[], vec![], cwd.clone(), &project, cx) .await?; From 4e8f6ddae974694f893e5a636a5d6b00cc05e775 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Wed, 3 Dec 2025 12:56:16 +0100 Subject: [PATCH 021/621] git: Fix unwrap in `git2::Index::get_path` (#44059) Fixes ZED-1VR Release Notes: - N/A *or* Added/Fixed/Improved ... --- crates/git/src/repository.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/crates/git/src/repository.rs b/crates/git/src/repository.rs index 4f11819f1097617a6b416fa8e991072d595db38a..23c5795209c1eda9acbf4fe9f48a4e3de898a89a 100644 --- a/crates/git/src/repository.rs +++ b/crates/git/src/repository.rs @@ -967,7 +967,15 @@ impl GitRepository for RealGitRepository { index.read(false)?; const STAGE_NORMAL: i32 = 0; - let oid = match index.get_path(path.as_std_path(), STAGE_NORMAL) { + let path = path.as_std_path(); + // `RepoPath` contains a `RelPath` which normalizes `.` into an empty path + // `get_path` unwraps on empty paths though, so undo that normalization here + let path = if path.components().next().is_none() { + ".".as_ref() + } else { + path + }; + let oid = match index.get_path(path, STAGE_NORMAL) { Some(entry) if entry.mode != GIT_MODE_SYMLINK => entry.id, _ => return Ok(None), }; From a6882391137bdcd03e93925153c61bf2d08584ef Mon Sep 17 00:00:00 2001 From: Alexander Andreev <117519751+alkasadist@users.noreply.github.com> Date: Wed, 3 Dec 2025 15:51:18 +0300 Subject: [PATCH 022/621] python: Fix autocomplete sorting (#44050) Closes: #38727 (Python autocompletion being sorted alphabetically) Release Notes: - Improve sort order of pyright/basedpyright code completions --- crates/languages/src/python.rs | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/crates/languages/src/python.rs b/crates/languages/src/python.rs index bcdc7969b4f2b22f5136c733afd477f7d0cf0187..db61d5902d3f18444988caa0596f998f61636cee 100644 --- a/crates/languages/src/python.rs +++ b/crates/languages/src/python.rs @@ -101,9 +101,41 @@ impl FromStr for TestRunner { /// The problem with it is that Pyright adjusts the sort text based on previous resolutions (items for which we've issued `completion/resolve` call have their sortText adjusted), /// which - long story short - makes completion items list non-stable. Pyright probably relies on VSCode's implementation detail. /// see https://github.com/microsoft/pyright/blob/95ef4e103b9b2f129c9320427e51b73ea7cf78bd/packages/pyright-internal/src/languageService/completionProvider.ts#LL2873 +/// +/// upd 02.12.25: +/// Decided to ignore Pyright's sortText() completely and to manually sort all entries fn process_pyright_completions(items: &mut [lsp::CompletionItem]) { for item in items { - item.sort_text.take(); + let is_dunder = item.label.starts_with("__") && item.label.ends_with("__"); + + let visibility_priority = if is_dunder { + '3' + } else if item.label.starts_with("__") { + '2' // private non-dunder + } else if item.label.starts_with('_') { + '1' // protected + } else { + '0' // public + }; + + // Kind priority within same visibility level + let kind_priority = match item.kind { + Some(lsp::CompletionItemKind::ENUM_MEMBER) => '0', + Some(lsp::CompletionItemKind::FIELD) => '1', + Some(lsp::CompletionItemKind::PROPERTY) => '2', + Some(lsp::CompletionItemKind::VARIABLE) => '3', + Some(lsp::CompletionItemKind::CONSTANT) => '4', + Some(lsp::CompletionItemKind::METHOD) => '5', + Some(lsp::CompletionItemKind::FUNCTION) => '5', + Some(lsp::CompletionItemKind::CLASS) => '6', + Some(lsp::CompletionItemKind::MODULE) => '7', + _ => '8', + }; + + item.sort_text = Some(format!( + "{}{}{}", + visibility_priority, kind_priority, item.label + )); } } From bf878e9a953f435311572b2b28c7b7beb32262fe Mon Sep 17 00:00:00 2001 From: "Joseph T. Lyons" Date: Wed, 3 Dec 2025 08:55:58 -0500 Subject: [PATCH 023/621] Remove unnecessary variable redeclaration (#44074) Release Notes: - N/A --- crates/git_ui/src/git_panel.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs index bd17788506faa62f33618d4450000af1e7b8aec9..1c9b817be2507f806eab505555163f72b2fd148a 100644 --- a/crates/git_ui/src/git_panel.rs +++ b/crates/git_ui/src/git_panel.rs @@ -4014,7 +4014,7 @@ impl GitPanel { context_menu.action("Add to .gitignore", git::AddToGitignore.boxed_clone()) } - let mut context_menu = context_menu + context_menu = context_menu .separator() .action("Open Diff", Confirm.boxed_clone()) .action("Open File", SecondaryConfirm.boxed_clone()); From 95a553ea9416338fdde84b6d52be751dbc4f4c9e Mon Sep 17 00:00:00 2001 From: Agus Zubiaga Date: Wed, 3 Dec 2025 11:26:40 -0300 Subject: [PATCH 024/621] Do not report rejected sweep predictions to cloud (#44075) Release Notes: - N/A Co-authored-by: MrSubidubi --- crates/zeta/src/zeta.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crates/zeta/src/zeta.rs b/crates/zeta/src/zeta.rs index dba90abbc839566781d18308e53c4b0faa96e1d7..33d37d9e3aa0c5c89830d5ec86663330da1daf77 100644 --- a/crates/zeta/src/zeta.rs +++ b/crates/zeta/src/zeta.rs @@ -998,6 +998,11 @@ impl Zeta { reason: EditPredictionRejectReason, was_shown: bool, ) { + match self.edit_prediction_model { + ZetaEditPredictionModel::Zeta1 | ZetaEditPredictionModel::Zeta2 => {} + ZetaEditPredictionModel::Sweep => return, + } + self.reject_predictions_tx .unbounded_send(EditPredictionRejection { request_id: prediction_id.to_string(), From 8ca2571367031b0da84dd9c22e628b78cb83a343 Mon Sep 17 00:00:00 2001 From: Finn Evers Date: Wed, 3 Dec 2025 16:05:15 +0100 Subject: [PATCH 025/621] extension_ci: Do not trigger version bump on workflow file changes (#44077) Release Notes: - N/A Co-authored-by: Agus Zubiaga --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- extensions/workflows/bump_version.yml | 3 +++ .../src/tasks/workflows/extensions/bump_version.rs | 12 +++++++++--- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3c535c27415b776e3b4210a236f39a6f6d376954..1f56fec38b0267d1fe920f8ed89af98644bdd5ef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6972,7 +6972,7 @@ dependencies = [ [[package]] name = "gh-workflow" version = "0.8.0" -source = "git+https://github.com/zed-industries/gh-workflow?rev=e5f883040530b4df36437f140084ee5cc7c1c9be#e5f883040530b4df36437f140084ee5cc7c1c9be" +source = "git+https://github.com/zed-industries/gh-workflow?rev=09acfdf2bd5c1d6254abefd609c808ff73547b2c#09acfdf2bd5c1d6254abefd609c808ff73547b2c" dependencies = [ "async-trait", "derive_more 2.0.1", @@ -6989,7 +6989,7 @@ dependencies = [ [[package]] name = "gh-workflow-macros" version = "0.8.0" -source = "git+https://github.com/zed-industries/gh-workflow?rev=e5f883040530b4df36437f140084ee5cc7c1c9be#e5f883040530b4df36437f140084ee5cc7c1c9be" +source = "git+https://github.com/zed-industries/gh-workflow?rev=09acfdf2bd5c1d6254abefd609c808ff73547b2c#09acfdf2bd5c1d6254abefd609c808ff73547b2c" dependencies = [ "heck 0.5.0", "quote", diff --git a/Cargo.toml b/Cargo.toml index 6cd80981ce62a245310e6e1a1d447bdc804aa32a..a6512c79093c197f5ed7a195f78bf7a170a15abe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -508,7 +508,7 @@ fork = "0.4.0" futures = "0.3" futures-batch = "0.6.1" futures-lite = "1.13" -gh-workflow = { git = "https://github.com/zed-industries/gh-workflow", rev = "e5f883040530b4df36437f140084ee5cc7c1c9be" } +gh-workflow = { git = "https://github.com/zed-industries/gh-workflow", rev = "09acfdf2bd5c1d6254abefd609c808ff73547b2c" } git2 = { version = "0.20.1", default-features = false } globset = "0.4" handlebars = "4.3" diff --git a/extensions/workflows/bump_version.yml b/extensions/workflows/bump_version.yml index ad231298ec3848b165d8fd07ee664cb88ba6430d..7f4318dcf54ad8c9360ae622354530b2b54c6a03 100644 --- a/extensions/workflows/bump_version.yml +++ b/extensions/workflows/bump_version.yml @@ -8,6 +8,9 @@ on: push: branches: - main + paths-ignore: + - .github/** + workflow_dispatch: {} jobs: determine_bump_type: runs-on: namespace-profile-16x32-ubuntu-2204 diff --git a/tooling/xtask/src/tasks/workflows/extensions/bump_version.rs b/tooling/xtask/src/tasks/workflows/extensions/bump_version.rs index 44c72a11648fb1392d78437113fdf72148b9abed..1564fef448fc305897b9edcd64245255b8e0b168 100644 --- a/tooling/xtask/src/tasks/workflows/extensions/bump_version.rs +++ b/tooling/xtask/src/tasks/workflows/extensions/bump_version.rs @@ -1,5 +1,6 @@ use gh_workflow::{ - Event, Expression, Input, Job, PullRequest, PullRequestType, Push, Run, Step, UsesJob, Workflow, + Event, Expression, Input, Job, PullRequest, PullRequestType, Push, Run, Step, UsesJob, + Workflow, WorkflowDispatch, }; use indexmap::IndexMap; use indoc::indoc; @@ -18,8 +19,13 @@ pub(crate) fn bump_version() -> Workflow { named::workflow() .on(Event::default() - .push(Push::default().add_branch("main")) - .pull_request(PullRequest::default().add_type(PullRequestType::Labeled))) + .push( + Push::default() + .add_branch("main") + .add_ignored_path(".github/**"), + ) + .pull_request(PullRequest::default().add_type(PullRequestType::Labeled)) + .workflow_dispatch(WorkflowDispatch::default())) .concurrency(one_workflow_per_non_main_branch_and_token("labels")) .add_job(determine_bump_type.name, determine_bump_type.job) .add_job(call_bump_version.name, call_bump_version.job) From 1e09cbfefab07184fdbf05a3d8399308a316c81a Mon Sep 17 00:00:00 2001 From: Xiaobo Liu Date: Wed, 3 Dec 2025 23:08:49 +0800 Subject: [PATCH 026/621] workspace: Scope tab tooltip to tab content only (#44076) Release Notes: - Fixed scope tab tooltip to tab content only Signed-off-by: Xiaobo Liu --- crates/workspace/src/pane.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/crates/workspace/src/pane.rs b/crates/workspace/src/pane.rs index 8182a7dd88ae2577b577ec0505638dcfcff0084c..5f0fb8ba9647f969b3bea4a83194dd600e1f84aa 100644 --- a/crates/workspace/src/pane.rs +++ b/crates/workspace/src/pane.rs @@ -2591,6 +2591,7 @@ impl Pane { let close_side = &settings.close_position; let show_close_button = &settings.show_close_button; let indicator = render_item_indicator(item.boxed_clone(), cx); + let tab_tooltip_content = item.tab_tooltip_content(cx); let item_id = item.item_id(); let is_first_item = ix == 0; let is_last_item = ix == self.items.len() - 1; @@ -2678,12 +2679,6 @@ impl Pane { this.drag_split_direction = None; this.handle_external_paths_drop(paths, window, cx) })) - .when_some(item.tab_tooltip_content(cx), |tab, content| match content { - TabTooltipContent::Text(text) => tab.tooltip(Tooltip::text(text)), - TabTooltipContent::Custom(element_fn) => { - tab.tooltip(move |window, cx| element_fn(window, cx)) - } - }) .start_slot::(indicator) .map(|this| { let end_slot_action: &'static dyn Action; @@ -2750,7 +2745,15 @@ impl Pane { }) .flatten(), ) - .child(label), + .child(label) + .id(("pane-tab-content", ix)) + .map(|this| match tab_tooltip_content { + Some(TabTooltipContent::Text(text)) => this.tooltip(Tooltip::text(text)), + Some(TabTooltipContent::Custom(element_fn)) => { + this.tooltip(move |window, cx| element_fn(window, cx)) + } + None => this, + }), ); let single_entry_to_resolve = (self.items[ix].buffer_kind(cx) == ItemBufferKind::Singleton) From 904d90bee71fe2f4a227f87920629c396a4cbde6 Mon Sep 17 00:00:00 2001 From: Finn Evers Date: Wed, 3 Dec 2025 16:13:15 +0100 Subject: [PATCH 027/621] extension_ci: Run tests on pushes to `main` (#44079) This seems sensible to do - it already was the case prior but indirectly, lets rather be explicit about this. Release Notes: - N/A Co-authored-by: Agus Zubiaga --- .github/workflows/extension_bump.yml | 29 ------------------- extensions/workflows/run_tests.yml | 3 ++ .../src/tasks/workflows/extension_bump.rs | 6 +--- .../tasks/workflows/extensions/run_tests.rs | 6 ++-- 4 files changed, 8 insertions(+), 36 deletions(-) diff --git a/.github/workflows/extension_bump.yml b/.github/workflows/extension_bump.yml index 4781014e32f01b473b3358f2a81a3613fe5cdce9..c7582378f1c9e87254e1a0b4e202d9f56b99877b 100644 --- a/.github/workflows/extension_bump.yml +++ b/.github/workflows/extension_bump.yml @@ -25,33 +25,6 @@ on: description: The app secret for the corresponding app ID required: true jobs: - check_extension: - if: (github.repository_owner == 'zed-industries' || github.repository_owner == 'zed-extensions') - runs-on: namespace-profile-2x4-ubuntu-2404 - steps: - - name: steps::checkout_repo - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 - with: - clean: false - - id: cache-zed-extension-cli - name: extension_tests::cache_zed_extension_cli - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 - with: - path: zed-extension - key: zed-extension-${{ env.ZED_EXTENSION_CLI_SHA }} - - name: extension_tests::download_zed_extension_cli - if: steps.cache-zed-extension-cli.outputs.cache-hit != 'true' - run: | - wget --quiet "https://zed-extension-cli.nyc3.digitaloceanspaces.com/$ZED_EXTENSION_CLI_SHA/x86_64-unknown-linux-gnu/zed-extension" - chmod +x zed-extension - shell: bash -euxo pipefail {0} - - name: extension_tests::check - run: | - mkdir -p /tmp/ext-scratch - mkdir -p /tmp/ext-output - ./zed-extension --source-dir . --scratch-dir /tmp/ext-scratch --output-dir /tmp/ext-output - shell: bash -euxo pipefail {0} - timeout-minutes: 2 check_bump_needed: if: (github.repository_owner == 'zed-industries' || github.repository_owner == 'zed-extensions') runs-on: namespace-profile-2x4-ubuntu-2404 @@ -89,7 +62,6 @@ jobs: timeout-minutes: 1 bump_extension_version: needs: - - check_extension - check_bump_needed if: |- (github.repository_owner == 'zed-industries' || github.repository_owner == 'zed-extensions') && @@ -144,7 +116,6 @@ jobs: timeout-minutes: 1 create_version_label: needs: - - check_extension - check_bump_needed if: (github.repository_owner == 'zed-industries' || github.repository_owner == 'zed-extensions') && github.event_name == 'push' && github.ref == 'refs/heads/main' && needs.check_bump_needed.outputs.needs_bump == 'false' runs-on: namespace-profile-8x16-ubuntu-2204 diff --git a/extensions/workflows/run_tests.yml b/extensions/workflows/run_tests.yml index 28cd288400643052011d4032f6c12b056ac4d301..81ba76c483479ed827f0a91181557a2387b40722 100644 --- a/extensions/workflows/run_tests.yml +++ b/extensions/workflows/run_tests.yml @@ -5,6 +5,9 @@ on: pull_request: branches: - '**' + push: + branches: + - main jobs: call_extension_tests: uses: zed-industries/zed/.github/workflows/extension_tests.yml@main diff --git a/tooling/xtask/src/tasks/workflows/extension_bump.rs b/tooling/xtask/src/tasks/workflows/extension_bump.rs index 356a3c6c782330528c165ebafb54ca23252e35b4..34fcf8099031ec9d5562c76f45073a9936c285ff 100644 --- a/tooling/xtask/src/tasks/workflows/extension_bump.rs +++ b/tooling/xtask/src/tasks/workflows/extension_bump.rs @@ -23,15 +23,12 @@ pub(crate) fn extension_bump() -> Workflow { let force_bump = WorkflowInput::bool("force-bump", None); let (app_id, app_secret) = extension_workflow_secrets(); - - let test_extension = extension_tests::check_extension(); let (check_bump_needed, needs_bump, current_version) = check_bump_needed(); let needs_bump = needs_bump.as_job_output(&check_bump_needed); let current_version = current_version.as_job_output(&check_bump_needed); - let dependencies = [&test_extension, &check_bump_needed]; - + let dependencies = [&check_bump_needed]; let bump_version = bump_extension_version( &dependencies, ¤t_version, @@ -72,7 +69,6 @@ pub(crate) fn extension_bump() -> Workflow { "ZED_EXTENSION_CLI_SHA", extension_tests::ZED_EXTENSION_CLI_SHA, )) - .add_job(test_extension.name, test_extension.job) .add_job(check_bump_needed.name, check_bump_needed.job) .add_job(bump_version.name, bump_version.job) .add_job(create_label.name, create_label.job) diff --git a/tooling/xtask/src/tasks/workflows/extensions/run_tests.rs b/tooling/xtask/src/tasks/workflows/extensions/run_tests.rs index 4e900e839d917bfa9920b12a4bd4a759fa1f31b7..885a8fd09fe0488c92162a9bccd0f70ed6c7fefd 100644 --- a/tooling/xtask/src/tasks/workflows/extensions/run_tests.rs +++ b/tooling/xtask/src/tasks/workflows/extensions/run_tests.rs @@ -1,4 +1,4 @@ -use gh_workflow::{Event, Job, PullRequest, UsesJob, Workflow}; +use gh_workflow::{Event, Job, PullRequest, Push, UsesJob, Workflow}; use crate::tasks::workflows::{ steps::{NamedJob, named}, @@ -8,7 +8,9 @@ use crate::tasks::workflows::{ pub(crate) fn run_tests() -> Workflow { let call_extension_tests = call_extension_tests(); named::workflow() - .on(Event::default().pull_request(PullRequest::default().add_branch("**"))) + .on(Event::default() + .pull_request(PullRequest::default().add_branch("**")) + .push(Push::default().add_branch("main"))) .concurrency(one_workflow_per_non_main_branch_and_token("pr")) .add_job(call_extension_tests.name, call_extension_tests.job) } From e39dd2af67c7669485463b5c3a90d07e9d680d40 Mon Sep 17 00:00:00 2001 From: "Joseph T. Lyons" Date: Wed, 3 Dec 2025 10:45:45 -0500 Subject: [PATCH 028/621] Bump Zed to v0.217 (#44080) Release Notes: - N/A --- Cargo.lock | 2 +- crates/zed/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1f56fec38b0267d1fe920f8ed89af98644bdd5ef..3e2f12a91c2b76a393f7f99f68bcd05933cb27f1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -21205,7 +21205,7 @@ dependencies = [ [[package]] name = "zed" -version = "0.216.0" +version = "0.217.0" dependencies = [ "acp_tools", "activity_indicator", diff --git a/crates/zed/Cargo.toml b/crates/zed/Cargo.toml index 9e6a6a0fbd10a7695270f2651418d9e2cdc31b4c..3358cc5d32bea308083ae1f6ee06268cf22d670a 100644 --- a/crates/zed/Cargo.toml +++ b/crates/zed/Cargo.toml @@ -2,7 +2,7 @@ description = "The fast, collaborative code editor." edition.workspace = true name = "zed" -version = "0.216.0" +version = "0.217.0" publish.workspace = true license = "GPL-3.0-or-later" authors = ["Zed Team "] From 7e177c496ccdb626f568d1c7a5e6dd352a373286 Mon Sep 17 00:00:00 2001 From: Remco Smits Date: Wed, 3 Dec 2025 16:49:40 +0100 Subject: [PATCH 029/621] markdown_preview: Fix markdown tables taking up the full width of the parent element (#43555) Closes #39152 This PR fixes an issue where we would render Markdown tables full width based on their container size. We now render tables based on their content min size, meaning you are still allowed to make the table render as it was before by making the columns `w_full`. I had to change the `div()` to `v_flex().items_start()` because this introduced a weird displaying behavior of the outside table border, because the grid container was not shrinking due to It was always taking up the full width of their container. **Before** Screenshot 2025-11-26 at 14 37 19 **After** Screenshot 2025-11-26 at 14 56 12 **Code example** ```markdown | Name | Age | Occupation | |:--------:|:-------:|:--------------:| | Alice | 28 | Engineer | | Bob | 34 | Designer | | Carol | 25 | Developer | | Syntax | Description | | ----------- | ----------- | | Header | Title | | Paragraph | Text | | City | Population (approx.) | Known For | |----------------|----------------------|------------------------------------| | New York | 8,500,000 | Statue of Liberty, Wall Street | | Los Angeles | 4,000,000 | Hollywood, film industry | | Chicago | 2,700,000 | Architecture, deep-dish pizza | | Houston | 2,300,000 | NASA, energy industry | | Miami | 470,000 | Beaches, Latin culture | | San Francisco | 800,000 | Golden Gate Bridge, Silicon Valley | | Las Vegas | 650,000 | Casinos, nightlife |
Table Caption
ID asjkfjaslkf jalksjflksajflka jlksdla k Name
1 Chris
2 Dennis
3 Sarah
4 Karen
``` cc @bennetbo Release Notes: - Markdown Preview: Markdown tables scale now based on their content size --- crates/gpui/src/taffy.rs | 7 ++++--- crates/markdown_preview/src/markdown_renderer.rs | 4 +--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/crates/gpui/src/taffy.rs b/crates/gpui/src/taffy.rs index 11cb0872861321c3c06c3f8a5bf79fdd30eb2275..c3113ad2cb91ad8c9e29360812716114a7427052 100644 --- a/crates/gpui/src/taffy.rs +++ b/crates/gpui/src/taffy.rs @@ -8,6 +8,7 @@ use std::{fmt::Debug, ops::Range}; use taffy::{ TaffyTree, TraversePartialTree as _, geometry::{Point as TaffyPoint, Rect as TaffyRect, Size as TaffySize}, + prelude::min_content, style::AvailableSpace as TaffyAvailableSpace, tree::NodeId, }; @@ -295,7 +296,7 @@ trait ToTaffy { impl ToTaffy for Style { fn to_taffy(&self, rem_size: Pixels, scale_factor: f32) -> taffy::style::Style { - use taffy::style_helpers::{fr, length, minmax, repeat}; + use taffy::style_helpers::{length, minmax, repeat}; fn to_grid_line( placement: &Range, @@ -309,8 +310,8 @@ impl ToTaffy for Style { fn to_grid_repeat( unit: &Option, ) -> Vec> { - // grid-template-columns: repeat(, minmax(0, 1fr)); - unit.map(|count| vec![repeat(count, vec![minmax(length(0.0), fr(1.0))])]) + // grid-template-columns: repeat(, minmax(0, min-content)); + unit.map(|count| vec![repeat(count, vec![minmax(length(0.0), min_content())])]) .unwrap_or_default() } diff --git a/crates/markdown_preview/src/markdown_renderer.rs b/crates/markdown_preview/src/markdown_renderer.rs index b229705692c0fade2b35b4dd9f66a27e2aba57bc..d9997b54274d53e4897b3a3810629054e5458275 100644 --- a/crates/markdown_preview/src/markdown_renderer.rs +++ b/crates/markdown_preview/src/markdown_renderer.rs @@ -520,7 +520,6 @@ fn render_markdown_table(parsed: &ParsedMarkdownTable, cx: &mut RenderContext) - .px_2() .py_1() .border_1() - .size_full() .border_color(cx.border_color) .when(cell.is_header, |this| { this.bg(cx.title_bar_background_color) @@ -551,7 +550,6 @@ fn render_markdown_table(parsed: &ParsedMarkdownTable, cx: &mut RenderContext) - let empty_cell = div() .border_1() - .size_full() .border_color(cx.border_color) .when(row_idx % 2 == 1, |this| this.bg(cx.panel_background_color)); @@ -560,7 +558,7 @@ fn render_markdown_table(parsed: &ParsedMarkdownTable, cx: &mut RenderContext) - } } - cx.with_common_p(div()) + cx.with_common_p(v_flex().items_start()) .when_some(parsed.caption.as_ref(), |this, caption| { this.children(render_markdown_text(caption, cx)) }) From c248a956e03b866f57544d45bde0efe2c1934c92 Mon Sep 17 00:00:00 2001 From: Arthur Schurhaus <95943247+artschur@users.noreply.github.com> Date: Wed, 3 Dec 2025 12:58:51 -0300 Subject: [PATCH 030/621] markdown: Fix rendering of inline HTML tags (#43513) Added support for rendering HTML ` `tags inside Markdown content. Previously, these tags were ignored by the renderer and displayed as raw text (inside LSP hover documentation). Closes: #43166 Release Notes: - Fixed styling of `` HTML tags in Markdown popovers. Before: image After: image --- crates/markdown/src/markdown.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/crates/markdown/src/markdown.rs b/crates/markdown/src/markdown.rs index dd0d726734173591cb9ed9f8cc965d06aaee7e89..3f7d8e0d29eca1fff4af2b34c0bac9f32b4d730d 100644 --- a/crates/markdown/src/markdown.rs +++ b/crates/markdown/src/markdown.rs @@ -1202,6 +1202,15 @@ impl Element for MarkdownElement { builder.push_text(html, range.clone()); } MarkdownEvent::InlineHtml => { + let html = &parsed_markdown.source[range.clone()]; + if html.starts_with("") { + builder.push_text_style(self.style.inline_code.clone()); + continue; + } + if html.trim_end().starts_with("") { + builder.pop_text_style(); + continue; + } builder.push_text(&parsed_markdown.source[range.clone()], range.clone()); } MarkdownEvent::Rule => { From 621ac16e35dfb57346ff9262531e2b1d43010579 Mon Sep 17 00:00:00 2001 From: Jeff Brennan <42007840+jeffbrennan@users.noreply.github.com> Date: Wed, 3 Dec 2025 11:32:51 -0500 Subject: [PATCH 031/621] go: Fix language injections (#43775) Closes #43730 ## Summary This modifies the existing injections.scm file for go by adding more specific prefix queries and *_content nodes to the existing `raw_string_literal` and `interpreted_string_literal` sections
This PR image image image
Current Release (0.214.7) image image image
Code ```go func test_sql() { // const assignment const _ = /* sql */ "SELECT * FROM users" const _ = /* sql */ `SELECT id, name FROM products` // var assignment var _ = /* sql */ `SELECT id, name FROM products` var _ = /* sql */ "SELECT id, name FROM products" // := assignment test := /* sql */ "SELECT * FROM users" test2 := /* sql */ `SELECT * FROM users` println(test) println(test2) // = assignment _ = /* sql */ "SELECT * FROM users WHERE id = 1" _ = /* sql */ `SELECT * FROM users WHERE id = 1` // literal elements _ = testStruct{Field: /* sql */ "SELECT * FROM users"} _ = testStruct{Field: /* sql */ `SELECT * FROM users`} testFunc(/* sql */ "SELECT * FROM users") testFunc(/* sql */ `SELECT * FROM users`) const backtickString = /* sql */ `SELECT * FROM users;` const quotedString = /* sql */ "SELECT * FROM users;" const backtickStringNoHighlight = `SELECT * FROM users;` const quotedStringNoHighlight = "SELECT * FROM users;" } func test_yaml() { // const assignment const _ = /* yaml */ ` settings: enabled: true port: 8080 ` // := assignment test := /* yaml */ ` settings: enabled: true port: 8080 ` println(test) // = assignment _ = /* yaml */ ` settings: enabled: true port: 8080 ` // literal elements in a struct _ = testStruct{Field: /* yaml */ ` settings: test: 1234 port: 8080 `} // function argument testFunc(/* yaml */ ` settings: enabled: true port: 8080 `) } func test_css() { // const assignment const _ = /* css */ "body { margin: 0; }" const _ = /* css */ `body { margin: 0; }` const cssCodes = /* css */ ` h1 { color: #333; } ` // := assignment test := /* css */ "body { margin: 0; }" println(test) // = assignment _ = /* css */ "body { margin: 0; }" _ = /* css */ `body { margin: 0; }` // literal elements _ = testStruct{Field: /* css */ "body { margin: 0; }"} _ = testStruct{Field: /* css */ `body { margin: 0; }`} testFunc(/* css */ "body { margin: 0; }") testFunc(/* css */ `body { margin: 0; }`) const backtickString = /* css */ `body { margin: 0; }` const quotedString = /* css */ "body { margin: 0; }" const backtickStringNoHighlight = `body { margin: 0; }` const quotedStringNoHighlight = "body { margin: 0; }" } ```
Release Notes: - Greatly improved the quality of comment-directed language injections in Go --- crates/languages/src/go/injections.scm | 959 +++++++++++++++++-------- 1 file changed, 658 insertions(+), 301 deletions(-) diff --git a/crates/languages/src/go/injections.scm b/crates/languages/src/go/injections.scm index 52edce417798bcc8cd9cbc38ba3443ff3fc561c6..58583f4d22c7db8016397d8e47cd817b7c240764 100644 --- a/crates/languages/src/go/injections.scm +++ b/crates/languages/src/go/injections.scm @@ -19,360 +19,717 @@ ; INJECT SQL ( - [ - ; var, const or short declaration of raw or interpreted string literal - ((comment) @comment - . - (expression_list - [ - (interpreted_string_literal) - (raw_string_literal) - ] @injection.content - )) - - ; when passing as a literal element (to struct field eg.) - ((comment) @comment - . - (literal_element - [ - (interpreted_string_literal) - (raw_string_literal) - ] @injection.content - )) - - ; when passing as a function parameter - ((comment) @comment - . - [ - (interpreted_string_literal) - (raw_string_literal) - ] @injection.content) - ] + [ + (const_spec + name: (identifier) + "=" + (comment) @_comment + value: (expression_list + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + )) + + (var_spec + name: (identifier) + "=" + (comment) @_comment + value: (expression_list + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + )) + + (assignment_statement + left: (expression_list) + "=" + (comment) @_comment + right: (expression_list + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + )) - (#match? @comment "^\\/\\*\\s*sql\\s*\\*\\/") ; /* sql */ or /*sql*/ - (#set! injection.language "sql") + (short_var_declaration + left: (expression_list) + ":=" + (comment) @_comment + right: (expression_list + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + )) + + (composite_literal + body: (literal_value + (keyed_element + (comment) @_comment + value: (literal_element + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + )))) + + (expression_statement + (call_expression + (argument_list + (comment) @_comment + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + ))) + ] + (#match? @_comment "^\\/\\*\\s*sql\\s*\\*\\/$") + (#set! injection.language "sql") ) ; INJECT JSON ( - [ - ; var, const or short declaration of raw or interpreted string literal - ((comment) @comment - . - (expression_list - [ - (interpreted_string_literal) - (raw_string_literal) - ] @injection.content - )) - - ; when passing as a literal element (to struct field eg.) - ((comment) @comment - . - (literal_element - [ - (interpreted_string_literal) - (raw_string_literal) - ] @injection.content - )) - - ; when passing as a function parameter - ((comment) @comment - . - [ - (interpreted_string_literal) - (raw_string_literal) - ] @injection.content) - ] + [ + (const_spec + name: (identifier) + "=" + (comment) @_comment + value: (expression_list + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + )) - (#match? @comment "^\\/\\*\\s*json\\s*\\*\\/") ; /* json */ or /*json*/ + (var_spec + name: (identifier) + "=" + (comment) @_comment + value: (expression_list + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + )) + + (assignment_statement + left: (expression_list) + "=" + (comment) @_comment + right: (expression_list + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + )) + + (short_var_declaration + left: (expression_list) + ":=" + (comment) @_comment + right: (expression_list + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + )) + + (composite_literal + body: (literal_value + (keyed_element + (comment) @_comment + value: (literal_element + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + )))) + + (expression_statement + (call_expression + (argument_list + (comment) @_comment + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + ))) + ] + (#match? @_comment "^\\/\\*\\s*json\\s*\\*\\/") ; /* json */ or /*json*/ (#set! injection.language "json") ) ; INJECT YAML ( - [ - ; var, const or short declaration of raw or interpreted string literal - ((comment) @comment - . - (expression_list - [ - (interpreted_string_literal) - (raw_string_literal) - ] @injection.content - )) - - ; when passing as a literal element (to struct field eg.) - ((comment) @comment - . - (literal_element - [ - (interpreted_string_literal) - (raw_string_literal) - ] @injection.content - )) - - ; when passing as a function parameter - ((comment) @comment - . - [ - (interpreted_string_literal) - (raw_string_literal) - ] @injection.content) - ] + [ + (const_spec + name: (identifier) + "=" + (comment) @_comment + value: (expression_list + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + )) + + (var_spec + name: (identifier) + "=" + (comment) @_comment + value: (expression_list + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + )) + + (assignment_statement + left: (expression_list) + "=" + (comment) @_comment + right: (expression_list + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + )) + + (short_var_declaration + left: (expression_list) + ":=" + (comment) @_comment + right: (expression_list + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + )) - (#match? @comment "^\\/\\*\\s*yaml\\s*\\*\\/") ; /* yaml */ or /*yaml*/ + (composite_literal + body: (literal_value + (keyed_element + (comment) @_comment + value: (literal_element + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + )))) + + (expression_statement + (call_expression + (argument_list + (comment) @_comment + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + ))) + ] + (#match? @_comment "^\\/\\*\\s*yaml\\s*\\*\\/") ; /* yaml */ or /*yaml*/ (#set! injection.language "yaml") ) ; INJECT XML ( - [ - ; var, const or short declaration of raw or interpreted string literal - ((comment) @comment - . - (expression_list - [ - (interpreted_string_literal) - (raw_string_literal) - ] @injection.content - )) - - ; when passing as a literal element (to struct field eg.) - ((comment) @comment - . - (literal_element - [ - (interpreted_string_literal) - (raw_string_literal) - ] @injection.content - )) - - ; when passing as a function parameter - ((comment) @comment - . - [ - (interpreted_string_literal) - (raw_string_literal) - ] @injection.content) - ] + [ + (const_spec + name: (identifier) + "=" + (comment) @_comment + value: (expression_list + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + )) + + (var_spec + name: (identifier) + "=" + (comment) @_comment + value: (expression_list + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + )) + + (assignment_statement + left: (expression_list) + "=" + (comment) @_comment + right: (expression_list + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + )) + + (short_var_declaration + left: (expression_list) + ":=" + (comment) @_comment + right: (expression_list + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + )) - (#match? @comment "^\\/\\*\\s*xml\\s*\\*\\/") ; /* xml */ or /*xml*/ + (composite_literal + body: (literal_value + (keyed_element + (comment) @_comment + value: (literal_element + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + )))) + + (expression_statement + (call_expression + (argument_list + (comment) @_comment + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + ))) + ] + (#match? @_comment "^\\/\\*\\s*xml\\s*\\*\\/") ; /* xml */ or /*xml*/ (#set! injection.language "xml") ) ; INJECT HTML ( - [ - ; var, const or short declaration of raw or interpreted string literal - ((comment) @comment - . - (expression_list - [ - (interpreted_string_literal) - (raw_string_literal) - ] @injection.content - )) - - ; when passing as a literal element (to struct field eg.) - ((comment) @comment - . - (literal_element - [ - (interpreted_string_literal) - (raw_string_literal) - ] @injection.content - )) - - ; when passing as a function parameter - ((comment) @comment - . - [ - (interpreted_string_literal) - (raw_string_literal) - ] @injection.content) - ] + [ + (const_spec + name: (identifier) + "=" + (comment) @_comment + value: (expression_list + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + )) - (#match? @comment "^\\/\\*\\s*html\\s*\\*\\/") ; /* html */ or /*html*/ + (var_spec + name: (identifier) + "=" + (comment) @_comment + value: (expression_list + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + )) + + (assignment_statement + left: (expression_list) + "=" + (comment) @_comment + right: (expression_list + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + )) + + (short_var_declaration + left: (expression_list) + ":=" + (comment) @_comment + right: (expression_list + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + )) + + (composite_literal + body: (literal_value + (keyed_element + (comment) @_comment + value: (literal_element + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + )))) + + (expression_statement + (call_expression + (argument_list + (comment) @_comment + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + ))) + ] + (#match? @_comment "^\\/\\*\\s*html\\s*\\*\\/") ; /* html */ or /*html*/ (#set! injection.language "html") ) ; INJECT JS ( - [ - ; var, const or short declaration of raw or interpreted string literal - ((comment) @comment - . - (expression_list - [ - (interpreted_string_literal) - (raw_string_literal) - ] @injection.content - )) - - ; when passing as a literal element (to struct field eg.) - ((comment) @comment - . - (literal_element - [ - (interpreted_string_literal) - (raw_string_literal) - ] @injection.content - )) - - ; when passing as a function parameter - ((comment) @comment - . - [ - (interpreted_string_literal) - (raw_string_literal) - ] @injection.content) - ] + [ + (const_spec + name: (identifier) + "=" + (comment) @_comment + value: (expression_list + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + )) + + (var_spec + name: (identifier) + "=" + (comment) @_comment + value: (expression_list + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + )) + + (assignment_statement + left: (expression_list) + "=" + (comment) @_comment + right: (expression_list + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + )) + + (short_var_declaration + left: (expression_list) + ":=" + (comment) @_comment + right: (expression_list + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + )) - (#match? @comment "^\\/\\*\\s*js\\s*\\*\\/") ; /* js */ or /*js*/ + (composite_literal + body: (literal_value + (keyed_element + (comment) @_comment + value: (literal_element + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + )))) + + (expression_statement + (call_expression + (argument_list + (comment) @_comment + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + ))) + ] + (#match? @_comment "^\\/\\*\\s*js\\s*\\*\\/") ; /* js */ or /*js*/ (#set! injection.language "javascript") ) + ; INJECT CSS ( - [ - ; var, const or short declaration of raw or interpreted string literal - ((comment) @comment - . - (expression_list - [ - (interpreted_string_literal) - (raw_string_literal) - ] @injection.content - )) - - ; when passing as a literal element (to struct field eg.) - ((comment) @comment - . - (literal_element - [ - (interpreted_string_literal) - (raw_string_literal) - ] @injection.content - )) - - ; when passing as a function parameter - ((comment) @comment - . - [ - (interpreted_string_literal) - (raw_string_literal) - ] @injection.content) - ] + [ + (const_spec + name: (identifier) + "=" + (comment) @_comment + value: (expression_list + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + )) + + (var_spec + name: (identifier) + "=" + (comment) @_comment + value: (expression_list + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + )) + + (assignment_statement + left: (expression_list) + "=" + (comment) @_comment + right: (expression_list + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + )) - (#match? @comment "^\\/\\*\\s*css\\s*\\*\\/") ; /* css */ or /*css*/ + (short_var_declaration + left: (expression_list) + ":=" + (comment) @_comment + right: (expression_list + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + )) + + (composite_literal + body: (literal_value + (keyed_element + (comment) @_comment + value: (literal_element + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + )))) + + (expression_statement + (call_expression + (argument_list + (comment) @_comment + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + ))) + ] + (#match? @_comment "^\\/\\*\\s*css\\s*\\*\\/") ; /* css */ or /*css*/ (#set! injection.language "css") ) + ; INJECT LUA ( - [ - ; var, const or short declaration of raw or interpreted string literal - ((comment) @comment - . - (expression_list - [ - (interpreted_string_literal) - (raw_string_literal) - ] @injection.content - )) - - ; when passing as a literal element (to struct field eg.) - ((comment) @comment - . - (literal_element - [ - (interpreted_string_literal) - (raw_string_literal) - ] @injection.content - )) - - ; when passing as a function parameter - ((comment) @comment - . - [ - (interpreted_string_literal) - (raw_string_literal) - ] @injection.content) - ] + [ + (const_spec + name: (identifier) + "=" + (comment) @_comment + value: (expression_list + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + )) + + (var_spec + name: (identifier) + "=" + (comment) @_comment + value: (expression_list + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + )) + + (assignment_statement + left: (expression_list) + "=" + (comment) @_comment + right: (expression_list + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + )) + + (short_var_declaration + left: (expression_list) + ":=" + (comment) @_comment + right: (expression_list + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + )) - (#match? @comment "^\\/\\*\\s*lua\\s*\\*\\/") ; /* lua */ or /*lua*/ + (composite_literal + body: (literal_value + (keyed_element + (comment) @_comment + value: (literal_element + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + )))) + + (expression_statement + (call_expression + (argument_list + (comment) @_comment + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + ))) + ] + (#match? @_comment "^\\/\\*\\s*lua\\s*\\*\\/") ; /* lua */ or /*lua*/ (#set! injection.language "lua") ) ; INJECT BASH ( - [ - ; var, const or short declaration of raw or interpreted string literal - ((comment) @comment - . - (expression_list - [ - (interpreted_string_literal) - (raw_string_literal) - ] @injection.content - )) - - ; when passing as a literal element (to struct field eg.) - ((comment) @comment - . - (literal_element - [ - (interpreted_string_literal) - (raw_string_literal) - ] @injection.content - )) - - ; when passing as a function parameter - ((comment) @comment - . - [ - (interpreted_string_literal) - (raw_string_literal) - ] @injection.content) - ] + [ + (const_spec + name: (identifier) + "=" + (comment) @_comment + value: (expression_list + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + )) + + (var_spec + name: (identifier) + "=" + (comment) @_comment + value: (expression_list + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + )) + + (assignment_statement + left: (expression_list) + "=" + (comment) @_comment + right: (expression_list + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + )) + + (short_var_declaration + left: (expression_list) + ":=" + (comment) @_comment + right: (expression_list + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + )) - (#match? @comment "^\\/\\*\\s*bash\\s*\\*\\/") ; /* bash */ or /*bash*/ + (composite_literal + body: (literal_value + (keyed_element + (comment) @_comment + value: (literal_element + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + )))) + + (expression_statement + (call_expression + (argument_list + (comment) @_comment + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + ))) + ] + (#match? @_comment "^\\/\\*\\s*bash\\s*\\*\\/") ; /* bash */ or /*bash*/ (#set! injection.language "bash") ) ; INJECT CSV ( - [ - ; var, const or short declaration of raw or interpreted string literal - ((comment) @comment - . - (expression_list - [ - (interpreted_string_literal) - (raw_string_literal) - ] @injection.content - )) - - ; when passing as a literal element (to struct field eg.) - ((comment) @comment - . - (literal_element - [ - (interpreted_string_literal) - (raw_string_literal) - ] @injection.content - )) - - ; when passing as a function parameter - ((comment) @comment - . - [ - (interpreted_string_literal) - (raw_string_literal) - ] @injection.content) - ] + [ + (const_spec + name: (identifier) + "=" + (comment) @_comment + value: (expression_list + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + )) - (#match? @comment "^\\/\\*\\s*csv\\s*\\*\\/") ; /* csv */ or /*csv*/ + (var_spec + name: (identifier) + "=" + (comment) @_comment + value: (expression_list + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + )) + + (assignment_statement + left: (expression_list) + "=" + (comment) @_comment + right: (expression_list + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + )) + + (short_var_declaration + left: (expression_list) + ":=" + (comment) @_comment + right: (expression_list + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + )) + + ((comment) @_comment + value: (literal_element + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + )) + + (argument_list + (comment) @_comment + [ + (interpreted_string_literal (interpreted_string_literal_content) @injection.content) + (raw_string_literal (raw_string_literal_content) @injection.content) + ] + ) + ] + (#match? @_comment "^\\/\\*\\s*csv\\s*\\*\\/") ; /* csv */ or /*csv */ (#set! injection.language "csv") ) From b168679c181bb50e68c8f37e41c6c969c210d379 Mon Sep 17 00:00:00 2001 From: Vitaly Slobodin Date: Wed, 3 Dec 2025 17:34:49 +0100 Subject: [PATCH 032/621] language: Remove old unused `HTML/ERB` language ID (#44081) The `HTML/ERB` language was renamed to `HTML+ERB` in https://github.com/zed-industries/zed/pull/40000 We can remove the old name safely now. Release Notes: - N/A --- crates/languages/src/lib.rs | 1 - crates/languages/src/tailwind.rs | 1 - 2 files changed, 2 deletions(-) diff --git a/crates/languages/src/lib.rs b/crates/languages/src/lib.rs index d27b5ece0d78b15e2207726ceb95114c05fbcbad..9df14fb162e2ed722f5ed7527e179f3aec9b0af6 100644 --- a/crates/languages/src/lib.rs +++ b/crates/languages/src/lib.rs @@ -283,7 +283,6 @@ pub fn init(languages: Arc, fs: Arc, node: NodeRuntime "CSS", "ERB", "HTML+ERB", - "HTML/ERB", "HEEX", "HTML", "JavaScript", diff --git a/crates/languages/src/tailwind.rs b/crates/languages/src/tailwind.rs index b0b9132a9ac64ef963463885811e2c23f8e7b5f9..3cf9dd05a165f04dd4be1d1b0a9cf30288db167a 100644 --- a/crates/languages/src/tailwind.rs +++ b/crates/languages/src/tailwind.rs @@ -186,7 +186,6 @@ impl LspAdapter for TailwindLspAdapter { (LanguageName::new("HEEX"), "phoenix-heex".to_string()), (LanguageName::new("ERB"), "erb".to_string()), (LanguageName::new("HTML+ERB"), "erb".to_string()), - (LanguageName::new("HTML/ERB"), "erb".to_string()), (LanguageName::new("PHP"), "php".to_string()), (LanguageName::new("Vue.js"), "vue".to_string()), ]) From 85ccd7c98b0b35381ef77c7383995e892db0689f Mon Sep 17 00:00:00 2001 From: Xipeng Jin <56369076+xipeng-jin@users.noreply.github.com> Date: Wed, 3 Dec 2025 11:59:56 -0500 Subject: [PATCH 033/621] Fix not able to navigate to files in git commit multibuffer (#42558) Closes #40851 Release Notes: - Fixed: Commit diff multibuffers now open real project files whenever possible, restoring navigation and annotations inside those excerpts. --------- Co-authored-by: Anthony Eid --- crates/editor/src/editor.rs | 25 ++++++++++++++++++------- crates/editor/src/items.rs | 13 +++++++++---- crates/git_ui/src/commit_view.rs | 14 +++++++++++++- 3 files changed, 40 insertions(+), 12 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 6f936a211d3b5eb308b26e4351350666e616bf6c..eba10e4ea2a3663191fc3739b3b2f7f73101b7f5 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -21936,10 +21936,17 @@ impl Editor { }; for (buffer, (ranges, scroll_offset)) in new_selections_by_buffer { - let editor = buffer - .read(cx) - .file() - .is_none() + let buffer_read = buffer.read(cx); + let (has_file, is_project_file) = if let Some(file) = buffer_read.file() { + (true, project::File::from_dyn(Some(file)).is_some()) + } else { + (false, false) + }; + + // If project file is none workspace.open_project_item will fail to open the excerpt + // in a pre existing workspace item if one exists, because Buffer entity_id will be None + // so we check if there's a tab match in that case first + let editor = (!has_file || !is_project_file) .then(|| { // Handle file-less buffers separately: those are not really the project items, so won't have a project path or entity id, // so `workspace.open_project_item` will never find them, always opening a new editor. @@ -21973,6 +21980,9 @@ impl Editor { }); editor.update(cx, |editor, cx| { + if has_file && !is_project_file { + editor.set_read_only(true); + } let autoscroll = match scroll_offset { Some(scroll_offset) => Autoscroll::top_relative(scroll_offset as usize), None => Autoscroll::newest(), @@ -21996,10 +22006,11 @@ impl Editor { }); } - // For now, don't allow opening excerpts in buffers that aren't backed by - // regular project files. + // Allow opening excerpts for buffers that either belong to the current project + // or represent synthetic/non-local files (e.g., git blobs). File-less buffers + // are also supported so tests and other in-memory views keep working. fn can_open_excerpts_in_file(file: Option<&Arc>) -> bool { - file.is_none_or(|file| project::File::from_dyn(Some(file)).is_some()) + file.is_none_or(|file| project::File::from_dyn(Some(file)).is_some() || !file.is_local()) } fn marked_text_ranges(&self, cx: &App) -> Option>> { diff --git a/crates/editor/src/items.rs b/crates/editor/src/items.rs index 8111c837e2ee5c35fdfb120999c2be49b09c468c..4e1305866ee9e4219295c02bdc519b4bc857cddf 100644 --- a/crates/editor/src/items.rs +++ b/crates/editor/src/items.rs @@ -1891,15 +1891,20 @@ fn path_for_buffer<'a>( cx: &'a App, ) -> Option> { let file = buffer.read(cx).as_singleton()?.read(cx).file()?; - path_for_file(file.as_ref(), height, include_filename, cx) + path_for_file(file, height, include_filename, cx) } fn path_for_file<'a>( - file: &'a dyn language::File, + file: &'a Arc, mut height: usize, include_filename: bool, cx: &'a App, ) -> Option> { + if project::File::from_dyn(Some(file)).is_none() { + return None; + } + + let file = file.as_ref(); // Ensure we always render at least the filename. height += 1; @@ -1946,11 +1951,11 @@ mod tests { #[gpui::test] fn test_path_for_file(cx: &mut App) { - let file = TestFile { + let file: Arc = Arc::new(TestFile { path: RelPath::empty().into(), root_name: String::new(), local_root: None, - }; + }); assert_eq!(path_for_file(&file, 0, false, cx), None); } diff --git a/crates/git_ui/src/commit_view.rs b/crates/git_ui/src/commit_view.rs index 4f6633a18c031b8f231f43f8b0efc13e7fd710a7..31ac8139a63be218f652204ebe29d43e526c5a02 100644 --- a/crates/git_ui/src/commit_view.rs +++ b/crates/git_ui/src/commit_view.rs @@ -68,6 +68,7 @@ struct GitBlob { path: RepoPath, worktree_id: WorktreeId, is_deleted: bool, + display_name: Arc, } const FILE_NAMESPACE_SORT_PREFIX: u64 = 1; @@ -157,6 +158,7 @@ impl CommitView { }); editor }); + let commit_sha = Arc::::from(commit.sha.as_ref()); let first_worktree_id = project .read(cx) @@ -180,10 +182,20 @@ impl CommitView { .or(first_worktree_id) })? .context("project has no worktrees")?; + let short_sha = commit_sha.get(0..7).unwrap_or(&commit_sha); + let file_name = file + .path + .file_name() + .map(|name| name.to_string()) + .unwrap_or_else(|| file.path.display(PathStyle::Posix).to_string()); + let display_name: Arc = + Arc::from(format!("{short_sha} - {file_name}").into_boxed_str()); + let file = Arc::new(GitBlob { path: file.path.clone(), is_deleted, worktree_id, + display_name, }) as Arc; let buffer = build_buffer(new_text, file, &language_registry, cx).await?; @@ -647,7 +659,7 @@ impl language::File for GitBlob { } fn file_name<'a>(&'a self, _: &'a App) -> &'a str { - self.path.file_name().unwrap() + self.display_name.as_ref() } fn worktree_id(&self, _: &App) -> WorktreeId { From 575ea49aade6a1224ae2f016678893d55a0ee1cf Mon Sep 17 00:00:00 2001 From: Ramon <55579979+van-sprundel@users.noreply.github.com> Date: Wed, 3 Dec 2025 18:11:53 +0100 Subject: [PATCH 034/621] Fix yank around paragraph missing newline (#43583) Use `MotionKind::LineWise` in both `vim::normal::change::Vim.change_object` and `vim::normal::yank::Vim.yank_object` when dealing with objects that target `Mode::VisualLine`, for example, paragraphs. This fixes an issue where yanking and changing paragraphs would not include the trailing newline character. Closes #28804 Release Notes: - Fixed linewise text object operations (`yap`, `cap`, etc.) omitting trailing blank line in vim mode --------- Co-authored-by: dino --- crates/vim/src/normal/change.rs | 6 +- crates/vim/src/normal/yank.rs | 6 +- crates/vim/src/test.rs | 73 +++++++++++++++++++ .../vim/test_data/test_change_paragraph.json | 8 ++ .../test_yank_paragraph_with_paste.json | 10 +++ 5 files changed, 101 insertions(+), 2 deletions(-) create mode 100644 crates/vim/test_data/test_change_paragraph.json create mode 100644 crates/vim/test_data/test_yank_paragraph_with_paste.json diff --git a/crates/vim/src/normal/change.rs b/crates/vim/src/normal/change.rs index 4735c64792f3639b2c0d6581e6179484e842f386..b0b0bddae19b27fa382d4c84c3fdd4df8ba83a43 100644 --- a/crates/vim/src/normal/change.rs +++ b/crates/vim/src/normal/change.rs @@ -121,7 +121,11 @@ impl Vim { }); }); if objects_found { - vim.copy_selections_content(editor, MotionKind::Exclusive, window, cx); + let kind = match object.target_visual_mode(vim.mode, around) { + Mode::VisualLine => MotionKind::Linewise, + _ => MotionKind::Exclusive, + }; + vim.copy_selections_content(editor, kind, window, cx); editor.insert("", window, cx); editor.refresh_edit_prediction(true, false, window, cx); } diff --git a/crates/vim/src/normal/yank.rs b/crates/vim/src/normal/yank.rs index d5a45fca544d61735f62a8f46e849db2c009847f..71ed0d44384a5ed8644f486aa16cdd704e9ce944 100644 --- a/crates/vim/src/normal/yank.rs +++ b/crates/vim/src/normal/yank.rs @@ -81,7 +81,11 @@ impl Vim { start_positions.insert(selection.id, start_position); }); }); - vim.yank_selections_content(editor, MotionKind::Exclusive, window, cx); + let kind = match object.target_visual_mode(vim.mode, around) { + Mode::VisualLine => MotionKind::Linewise, + _ => MotionKind::Exclusive, + }; + vim.yank_selections_content(editor, kind, window, cx); editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| { s.move_with(|_, selection| { let (head, goal) = start_positions.remove(&selection.id).unwrap(); diff --git a/crates/vim/src/test.rs b/crates/vim/src/test.rs index 5932a740945becae9d15025d358a52d5a4e279dd..4294b5e1dbdf1a287909bd3ab5770dfcd718f98d 100644 --- a/crates/vim/src/test.rs +++ b/crates/vim/src/test.rs @@ -2253,6 +2253,79 @@ async fn test_paragraph_multi_delete(cx: &mut gpui::TestAppContext) { cx.shared_state().await.assert_eq(indoc! {"ˇ"}); } +#[perf] +#[gpui::test] +async fn test_yank_paragraph_with_paste(cx: &mut gpui::TestAppContext) { + let mut cx = NeovimBackedTestContext::new(cx).await; + cx.set_shared_state(indoc! { + " + first paragraph + ˇstill first + + second paragraph + still second + + third paragraph + " + }) + .await; + + cx.simulate_shared_keystrokes("y a p").await; + cx.shared_clipboard() + .await + .assert_eq("first paragraph\nstill first\n\n"); + + cx.simulate_shared_keystrokes("j j p").await; + cx.shared_state().await.assert_eq(indoc! { + " + first paragraph + still first + + ˇfirst paragraph + still first + + second paragraph + still second + + third paragraph + " + }); +} + +#[perf] +#[gpui::test] +async fn test_change_paragraph(cx: &mut gpui::TestAppContext) { + let mut cx = NeovimBackedTestContext::new(cx).await; + cx.set_shared_state(indoc! { + " + first paragraph + ˇstill first + + second paragraph + still second + + third paragraph + " + }) + .await; + + cx.simulate_shared_keystrokes("c a p").await; + cx.shared_clipboard() + .await + .assert_eq("first paragraph\nstill first\n\n"); + + cx.simulate_shared_keystrokes("escape").await; + cx.shared_state().await.assert_eq(indoc! { + " + ˇ + second paragraph + still second + + third paragraph + " + }); +} + #[perf] #[gpui::test] async fn test_multi_cursor_replay(cx: &mut gpui::TestAppContext) { diff --git a/crates/vim/test_data/test_change_paragraph.json b/crates/vim/test_data/test_change_paragraph.json new file mode 100644 index 0000000000000000000000000000000000000000..6d235d9f367d5c375df59f3567b2ac1435f6a0a7 --- /dev/null +++ b/crates/vim/test_data/test_change_paragraph.json @@ -0,0 +1,8 @@ +{"Put":{"state":"first paragraph\nˇstill first\n\nsecond paragraph\nstill second\n\nthird paragraph\n"}} +{"Key":"c"} +{"Key":"a"} +{"Key":"p"} +{"Get":{"state":"ˇ\nsecond paragraph\nstill second\n\nthird paragraph\n","mode":"Insert"}} +{"ReadRegister":{"name":"\"","value":"first paragraph\nstill first\n\n"}} +{"Key":"escape"} +{"Get":{"state":"ˇ\nsecond paragraph\nstill second\n\nthird paragraph\n","mode":"Normal"}} diff --git a/crates/vim/test_data/test_yank_paragraph_with_paste.json b/crates/vim/test_data/test_yank_paragraph_with_paste.json new file mode 100644 index 0000000000000000000000000000000000000000..d73d1f6d3b36e7b1df17559dd525238f13606976 --- /dev/null +++ b/crates/vim/test_data/test_yank_paragraph_with_paste.json @@ -0,0 +1,10 @@ +{"Put":{"state":"first paragraph\nˇstill first\n\nsecond paragraph\nstill second\n\nthird paragraph\n"}} +{"Key":"y"} +{"Key":"a"} +{"Key":"p"} +{"Get":{"state":"ˇfirst paragraph\nstill first\n\nsecond paragraph\nstill second\n\nthird paragraph\n","mode":"Normal"}} +{"ReadRegister":{"name":"\"","value":"first paragraph\nstill first\n\n"}} +{"Key":"j"} +{"Key":"j"} +{"Key":"p"} +{"Get":{"state":"first paragraph\nstill first\n\nˇfirst paragraph\nstill first\n\nsecond paragraph\nstill second\n\nthird paragraph\n","mode":"Normal"}} From 6b46a71dd0f0cdd2238e954566a7728d23e3d74a Mon Sep 17 00:00:00 2001 From: Dino Date: Wed, 3 Dec 2025 17:12:04 +0000 Subject: [PATCH 035/621] tab_switcher: Fix bug where selected index after closing tab did not match pane's active item (#44006) Whenever an item is removed using the Tab Switcher, the list of matches is automatically updated, which can lead to the order of the elements being updated and changing in comparison to what the user was previously seeing. Unfortunately this can lead to a situation where the selected index, since it wasn't being updated, would end up in a different item than the one that was actually active in the pane. This Pull Request updates the handling of the `PaneEvent::RemovedItem` event so that the `TabSwitcherDelegate.selected_index` field is automatically updated to match the pane's new active item. Seeing as this is being updated, the `test_close_preserves_selected_position` test is also removed, as it no longer makes sense with the current implementation. I believe a better user experience would be to actually not update the order of the matches, simply removing the ones that no longer exist, and keep the selected index position, but will tackle that in a different Pull Request. Closes #44005 Release Notes: - Fixed a bug with the tab switcher where, after closing a tab, the selected entry would not match the pane's active item --- crates/tab_switcher/src/tab_switcher.rs | 40 +++++++++- crates/tab_switcher/src/tab_switcher_tests.rs | 79 ++++++------------- 2 files changed, 61 insertions(+), 58 deletions(-) diff --git a/crates/tab_switcher/src/tab_switcher.rs b/crates/tab_switcher/src/tab_switcher.rs index 8ffa33183126cd5578ed7305c3ece3f0821e8d5c..2b98f6c7e329e7f98edb6b6e994de444a8b835da 100644 --- a/crates/tab_switcher/src/tab_switcher.rs +++ b/crates/tab_switcher/src/tab_switcher.rs @@ -347,11 +347,23 @@ impl TabSwitcherDelegate { }; cx.subscribe_in(&pane, window, |tab_switcher, _, event, window, cx| { match event { - PaneEvent::AddItem { .. } - | PaneEvent::RemovedItem { .. } - | PaneEvent::Remove { .. } => tab_switcher.picker.update(cx, |picker, cx| { + PaneEvent::AddItem { .. } | PaneEvent::Remove { .. } => { + tab_switcher.picker.update(cx, |picker, cx| { + let query = picker.query(cx); + picker.delegate.update_matches(query, window, cx); + cx.notify(); + }) + } + PaneEvent::RemovedItem { .. } => tab_switcher.picker.update(cx, |picker, cx| { let query = picker.query(cx); picker.delegate.update_matches(query, window, cx); + + // When the Tab Switcher is being used and an item is + // removed, there's a chance that the new selected index + // will not match the actual tab that is now being displayed + // by the pane, as such, the selected index needs to be + // updated to match the pane's state. + picker.delegate.sync_selected_index(cx); cx.notify(); }), _ => {} @@ -540,11 +552,33 @@ impl TabSwitcherDelegate { let Some(pane) = tab_match.pane.upgrade() else { return; }; + pane.update(cx, |pane, cx| { pane.close_item_by_id(tab_match.item.item_id(), SaveIntent::Close, window, cx) .detach_and_log_err(cx); }); } + + /// Updates the selected index to ensure it matches the pane's active item, + /// as the pane's active item can be indirectly updated and this method + /// ensures that the picker can react to those changes. + fn sync_selected_index(&mut self, cx: &mut Context>) { + let Ok(Some(item)) = self.pane.read_with(cx, |pane, _cx| pane.active_item()) else { + return; + }; + + let item_id = item.item_id(); + let Some((index, _tab_match)) = self + .matches + .iter() + .enumerate() + .find(|(_index, tab_match)| tab_match.item.item_id() == item_id) + else { + return; + }; + + self.selected_index = index; + } } impl PickerDelegate for TabSwitcherDelegate { diff --git a/crates/tab_switcher/src/tab_switcher_tests.rs b/crates/tab_switcher/src/tab_switcher_tests.rs index 52c96225655d2717879a27f6e7f9bbbe9bc4e7cb..85177f29ed8f39527cdedb991db756bd5f8d08d5 100644 --- a/crates/tab_switcher/src/tab_switcher_tests.rs +++ b/crates/tab_switcher/src/tab_switcher_tests.rs @@ -5,7 +5,7 @@ use menu::SelectPrevious; use project::{Project, ProjectPath}; use serde_json::json; use util::{path, rel_path::rel_path}; -use workspace::{AppState, Workspace}; +use workspace::{ActivatePreviousItem, AppState, Workspace}; #[ctor::ctor] fn init_logger() { @@ -197,6 +197,8 @@ async fn test_close_selected_item(cx: &mut gpui::TestAppContext) { json!({ "1.txt": "First file", "2.txt": "Second file", + "3.txt": "Third file", + "4.txt": "Fourth file", }), ) .await; @@ -206,80 +208,47 @@ async fn test_close_selected_item(cx: &mut gpui::TestAppContext) { cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx)); let tab_1 = open_buffer("1.txt", &workspace, cx).await; + let tab_3 = open_buffer("3.txt", &workspace, cx).await; let tab_2 = open_buffer("2.txt", &workspace, cx).await; + let tab_4 = open_buffer("4.txt", &workspace, cx).await; + + // After opening all buffers, let's navigate to the previous item two times, finishing with: + // + // 1.txt | [3.txt] | 2.txt | 4.txt + // + // With 3.txt being the active item in the pane. + cx.dispatch_action(ActivatePreviousItem); + cx.dispatch_action(ActivatePreviousItem); + cx.run_until_parked(); cx.simulate_modifiers_change(Modifiers::control()); let tab_switcher = open_tab_switcher(false, &workspace, cx); tab_switcher.update(cx, |tab_switcher, _| { - assert_eq!(tab_switcher.delegate.matches.len(), 2); - assert_match_at_position(tab_switcher, 0, tab_2.boxed_clone()); - assert_match_selection(tab_switcher, 1, tab_1.boxed_clone()); + assert_eq!(tab_switcher.delegate.matches.len(), 4); + assert_match_at_position(tab_switcher, 0, tab_3.boxed_clone()); + assert_match_selection(tab_switcher, 1, tab_2.boxed_clone()); + assert_match_at_position(tab_switcher, 2, tab_4.boxed_clone()); + assert_match_at_position(tab_switcher, 3, tab_1.boxed_clone()); }); cx.simulate_modifiers_change(Modifiers::control()); cx.dispatch_action(CloseSelectedItem); tab_switcher.update(cx, |tab_switcher, _| { - assert_eq!(tab_switcher.delegate.matches.len(), 1); - assert_match_selection(tab_switcher, 0, tab_2); + assert_eq!(tab_switcher.delegate.matches.len(), 3); + assert_match_selection(tab_switcher, 0, tab_3); + assert_match_at_position(tab_switcher, 1, tab_4); + assert_match_at_position(tab_switcher, 2, tab_1); }); // Still switches tab on modifiers release cx.simulate_modifiers_change(Modifiers::none()); cx.read(|cx| { let active_editor = workspace.read(cx).active_item_as::(cx).unwrap(); - assert_eq!(active_editor.read(cx).title(cx), "2.txt"); + assert_eq!(active_editor.read(cx).title(cx), "3.txt"); }); assert_tab_switcher_is_closed(workspace, cx); } -#[gpui::test] -async fn test_close_preserves_selected_position(cx: &mut gpui::TestAppContext) { - let app_state = init_test(cx); - app_state - .fs - .as_fake() - .insert_tree( - path!("/root"), - json!({ - "1.txt": "First file", - "2.txt": "Second file", - "3.txt": "Third file", - }), - ) - .await; - - let project = Project::test(app_state.fs.clone(), [path!("/root").as_ref()], cx).await; - let (workspace, cx) = - cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx)); - - let tab_1 = open_buffer("1.txt", &workspace, cx).await; - let tab_2 = open_buffer("2.txt", &workspace, cx).await; - let tab_3 = open_buffer("3.txt", &workspace, cx).await; - - let tab_switcher = open_tab_switcher(false, &workspace, cx); - tab_switcher.update(cx, |tab_switcher, _| { - assert_eq!(tab_switcher.delegate.matches.len(), 3); - assert_match_at_position(tab_switcher, 0, tab_3.boxed_clone()); - assert_match_selection(tab_switcher, 1, tab_2.boxed_clone()); - assert_match_at_position(tab_switcher, 2, tab_1.boxed_clone()); - }); - - // Verify that if the selected tab was closed, tab at the same position is selected. - cx.dispatch_action(CloseSelectedItem); - tab_switcher.update(cx, |tab_switcher, _| { - assert_eq!(tab_switcher.delegate.matches.len(), 2); - assert_match_at_position(tab_switcher, 0, tab_3.boxed_clone()); - assert_match_selection(tab_switcher, 1, tab_1.boxed_clone()); - }); - - // But if the position is no longer valid, fall back to the position above. - cx.dispatch_action(CloseSelectedItem); - tab_switcher.update(cx, |tab_switcher, _| { - assert_eq!(tab_switcher.delegate.matches.len(), 1); - assert_match_selection(tab_switcher, 0, tab_3.boxed_clone()); - }); -} - fn init_test(cx: &mut TestAppContext) -> Arc { cx.update(|cx| { let state = AppState::test(cx); From 0818cedded624e770484a8fdd7063aabdcdba667 Mon Sep 17 00:00:00 2001 From: Mayank Verma Date: Wed, 3 Dec 2025 22:55:31 +0530 Subject: [PATCH 036/621] editor: Fix blame hover not working when inline git blame is disabled (#42992) Closes #42936 Release Notes: - Fixed editor blame hover not working when inline git blame is disabled Here's the before/after: https://github.com/user-attachments/assets/a3875011-4a27-45b3-b638-3e146c06f1fe --- crates/editor/src/editor.rs | 3 ++ crates/editor/src/element.rs | 66 +++++++++++++++++++++++++----------- 2 files changed, 50 insertions(+), 19 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index eba10e4ea2a3663191fc3739b3b2f7f73101b7f5..ae114b14ce04a405ddca95c0bda9cbaf28ccdadf 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -6810,6 +6810,9 @@ impl Editor { return; }; + if self.blame.is_none() { + self.start_git_blame(true, window, cx); + } let Some(blame) = self.blame.as_ref() else { return; }; diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index 89f9a6793d81e3de9ba27c97091fe446061c31ff..3319af92eb04015bd3bd01760235e3dba0047975 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -1227,7 +1227,13 @@ impl EditorElement { editor.hide_blame_popover(false, cx); } } else { - editor.hide_blame_popover(false, cx); + let keyboard_grace = editor + .inline_blame_popover + .as_ref() + .is_some_and(|state| state.keyboard_grace); + if !keyboard_grace { + editor.hide_blame_popover(false, cx); + } } let breakpoint_indicator = if gutter_hovered { @@ -2511,7 +2517,6 @@ impl EditorElement { scroll_position: gpui::Point, scroll_pixel_position: gpui::Point, line_height: Pixels, - text_hitbox: &Hitbox, window: &mut Window, cx: &mut App, ) -> Option { @@ -2580,16 +2585,6 @@ impl EditorElement { let size = element.layout_as_root(AvailableSpace::min_size(), window, cx); let bounds = Bounds::new(absolute_offset, size); - self.layout_blame_entry_popover( - entry.clone(), - blame, - line_height, - text_hitbox, - row_info.buffer_id?, - window, - cx, - ); - element.prepaint_as_root(absolute_offset, AvailableSpace::min_size(), window, cx); Some(InlineBlameLayout { @@ -2600,16 +2595,48 @@ impl EditorElement { }) } - fn layout_blame_entry_popover( + fn layout_blame_popover( &self, - blame_entry: BlameEntry, - blame: Entity, - line_height: Pixels, + editor_snapshot: &EditorSnapshot, text_hitbox: &Hitbox, - buffer: BufferId, + line_height: Pixels, window: &mut Window, cx: &mut App, ) { + if !self.editor.read(cx).inline_blame_popover.is_some() { + return; + } + + let Some(blame) = self.editor.read(cx).blame.clone() else { + return; + }; + let cursor_point = self + .editor + .read(cx) + .selections + .newest::(&editor_snapshot.display_snapshot) + .head(); + + let Some((buffer, buffer_point, _)) = editor_snapshot + .buffer_snapshot() + .point_to_buffer_point(cursor_point) + else { + return; + }; + + let row_info = RowInfo { + buffer_id: Some(buffer.remote_id()), + buffer_row: Some(buffer_point.row), + ..Default::default() + }; + + let Some((buffer_id, blame_entry)) = blame + .update(cx, |blame, cx| blame.blame_for_rows(&[row_info], cx).next()) + .flatten() + else { + return; + }; + let Some((popover_state, target_point)) = self.editor.read_with(cx, |editor, _| { editor .inline_blame_popover @@ -2631,7 +2658,7 @@ impl EditorElement { popover_state.markdown, workspace, &blame, - buffer, + buffer_id, window, cx, ) @@ -9813,7 +9840,6 @@ impl Element for EditorElement { scroll_position, scroll_pixel_position, line_height, - &text_hitbox, window, cx, ) { @@ -10011,6 +10037,8 @@ impl Element for EditorElement { window, cx, ); + + self.layout_blame_popover(&snapshot, &hitbox, line_height, window, cx); } let mouse_context_menu = self.layout_mouse_context_menu( From 493cfadb42e9d1df1a73c970de3f26e227feb93e Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Wed, 3 Dec 2025 11:40:47 -0700 Subject: [PATCH 037/621] Revert "http_client: Add integrity checks for GitHub binaries using digest checks (#43737)" (#44086) This reverts commit 05764e8af797b5abb8076bc78ce32d4130505e93. Internally we've seen a much higher incidence of macOS code-signing failing on the download rust analyzer than we did before this change. It's unclear why this would be a problem, but we want to try reverting to see if that fixes it. Release Notes: - Reverted a change that seemed to cause problems with code-signing on rust-analyzer --- crates/http_client/src/github_download.rs | 61 +--------------------- crates/languages/src/c.rs | 55 ++++++++++++++------ crates/languages/src/rust.rs | 62 +++++++++++++++++------ 3 files changed, 86 insertions(+), 92 deletions(-) diff --git a/crates/http_client/src/github_download.rs b/crates/http_client/src/github_download.rs index 3c16d5e692786282c32217108277faf2b42cf220..02dee08b215e547d632caaf5f94b0872aa6aa20d 100644 --- a/crates/http_client/src/github_download.rs +++ b/crates/http_client/src/github_download.rs @@ -1,4 +1,4 @@ -use std::{future::Future, path::Path, pin::Pin, task::Poll}; +use std::{path::Path, pin::Pin, task::Poll}; use anyhow::{Context, Result}; use async_compression::futures::bufread::GzipDecoder; @@ -85,65 +85,6 @@ pub async fn download_server_binary( Ok(()) } -pub async fn fetch_github_binary_with_digest_check( - binary_path: &Path, - metadata_path: &Path, - expected_digest: Option, - url: &str, - asset_kind: AssetKind, - download_destination: &Path, - http_client: &dyn HttpClient, - validity_check: ValidityCheck, -) -> Result<()> -where - ValidityCheck: FnOnce() -> ValidityCheckFuture, - ValidityCheckFuture: Future>, -{ - let metadata = GithubBinaryMetadata::read_from_file(metadata_path) - .await - .ok(); - - if let Some(metadata) = metadata { - let validity_check_result = validity_check().await; - - if let (Some(actual_digest), Some(expected_digest_ref)) = - (&metadata.digest, &expected_digest) - { - if actual_digest == expected_digest_ref { - if validity_check_result.is_ok() { - return Ok(()); - } - } else { - log::info!( - "SHA-256 mismatch for {binary_path:?} asset, downloading new asset. Expected: {expected_digest_ref}, Got: {actual_digest}" - ); - } - } else if validity_check_result.is_ok() { - return Ok(()); - } - } - - download_server_binary( - http_client, - url, - expected_digest.as_deref(), - download_destination, - asset_kind, - ) - .await?; - - GithubBinaryMetadata::write_to_file( - &GithubBinaryMetadata { - metadata_version: 1, - digest: expected_digest, - }, - metadata_path, - ) - .await?; - - Ok(()) -} - async fn stream_response_archive( response: impl AsyncRead + Unpin, url: &str, diff --git a/crates/languages/src/c.rs b/crates/languages/src/c.rs index eb33bca0222abb0e03987081470549619c8e976d..8fe2bae693d702346a1ecc96334d35b89d179b3b 100644 --- a/crates/languages/src/c.rs +++ b/crates/languages/src/c.rs @@ -3,7 +3,7 @@ use async_trait::async_trait; use futures::StreamExt; use gpui::{App, AsyncApp}; use http_client::github::{AssetKind, GitHubLspBinaryVersion, latest_github_release}; -use http_client::github_download::fetch_github_binary_with_digest_check; +use http_client::github_download::{GithubBinaryMetadata, download_server_binary}; pub use language::*; use lsp::{InitializeParams, LanguageServerBinary, LanguageServerName}; use project::lsp_store::clangd_ext; @@ -85,32 +85,55 @@ impl LspInstaller for CLspAdapter { }; let metadata_path = version_dir.join("metadata"); - - let binary_path_for_check = binary_path.clone(); - fetch_github_binary_with_digest_check( - &binary_path, - &metadata_path, - expected_digest, - &url, - AssetKind::Zip, - &container_dir, - &*delegate.http_client(), - || async move { + let metadata = GithubBinaryMetadata::read_from_file(&metadata_path) + .await + .ok(); + if let Some(metadata) = metadata { + let validity_check = async || { delegate .try_exec(LanguageServerBinary { - path: binary_path_for_check, + path: binary_path.clone(), arguments: vec!["--version".into()], env: None, }) .await .inspect_err(|err| { - log::warn!("Unable to run clangd asset, redownloading: {err:#}") + log::warn!("Unable to run {binary_path:?} asset, redownloading: {err:#}",) }) - }, + }; + if let (Some(actual_digest), Some(expected_digest)) = + (&metadata.digest, &expected_digest) + { + if actual_digest == expected_digest { + if validity_check().await.is_ok() { + return Ok(binary); + } + } else { + log::info!( + "SHA-256 mismatch for {binary_path:?} asset, downloading new asset. Expected: {expected_digest}, Got: {actual_digest}" + ); + } + } else if validity_check().await.is_ok() { + return Ok(binary); + } + } + download_server_binary( + &*delegate.http_client(), + &url, + expected_digest.as_deref(), + &container_dir, + AssetKind::Zip, ) .await?; - remove_matching(&container_dir, |entry| entry != version_dir).await; + GithubBinaryMetadata::write_to_file( + &GithubBinaryMetadata { + metadata_version: 1, + digest: expected_digest, + }, + &metadata_path, + ) + .await?; Ok(binary) } diff --git a/crates/languages/src/rust.rs b/crates/languages/src/rust.rs index 41f4969b7696696b9e66f320dc9ba567898f4b11..31d7448285969fbce005b9b7134f56c7d8362f73 100644 --- a/crates/languages/src/rust.rs +++ b/crates/languages/src/rust.rs @@ -5,7 +5,7 @@ use futures::StreamExt; use gpui::{App, AppContext, AsyncApp, SharedString, Task}; use http_client::github::AssetKind; use http_client::github::{GitHubLspBinaryVersion, latest_github_release}; -use http_client::github_download::fetch_github_binary_with_digest_check; +use http_client::github_download::{GithubBinaryMetadata, download_server_binary}; pub use language::*; use lsp::{InitializeParams, LanguageServerBinary}; use project::lsp_store::rust_analyzer_ext::CARGO_DIAGNOSTICS_SOURCE_NAME; @@ -574,34 +574,64 @@ impl LspInstaller for RustLspAdapter { AssetKind::Zip => destination_path.clone().join("rust-analyzer.exe"), // zip contains a .exe }; - let metadata_path = destination_path.with_extension("metadata"); + let binary = LanguageServerBinary { + path: server_path.clone(), + env: None, + arguments: Default::default(), + }; - let server_path_for_check = server_path.clone(); - fetch_github_binary_with_digest_check( - &server_path, - &metadata_path, - expected_digest, - &url, - Self::GITHUB_ASSET_KIND, - &destination_path, - &*delegate.http_client(), - || async move { + let metadata_path = destination_path.with_extension("metadata"); + let metadata = GithubBinaryMetadata::read_from_file(&metadata_path) + .await + .ok(); + if let Some(metadata) = metadata { + let validity_check = async || { delegate .try_exec(LanguageServerBinary { - path: server_path_for_check, + path: server_path.clone(), arguments: vec!["--version".into()], env: None, }) .await .inspect_err(|err| { - log::warn!("Unable to run rust-analyzer asset, redownloading: {err:#}") + log::warn!("Unable to run {server_path:?} asset, redownloading: {err:#}",) }) - }, + }; + if let (Some(actual_digest), Some(expected_digest)) = + (&metadata.digest, &expected_digest) + { + if actual_digest == expected_digest { + if validity_check().await.is_ok() { + return Ok(binary); + } + } else { + log::info!( + "SHA-256 mismatch for {destination_path:?} asset, downloading new asset. Expected: {expected_digest}, Got: {actual_digest}" + ); + } + } else if validity_check().await.is_ok() { + return Ok(binary); + } + } + + download_server_binary( + &*delegate.http_client(), + &url, + expected_digest.as_deref(), + &destination_path, + Self::GITHUB_ASSET_KIND, ) .await?; - make_file_executable(&server_path).await?; remove_matching(&container_dir, |path| path != destination_path).await; + GithubBinaryMetadata::write_to_file( + &GithubBinaryMetadata { + metadata_version: 1, + digest: expected_digest, + }, + &metadata_path, + ) + .await?; Ok(LanguageServerBinary { path: server_path, From a51e975b817336d5eaa13e549bbcf9f1194ec1a6 Mon Sep 17 00:00:00 2001 From: John Tur Date: Wed, 3 Dec 2025 13:47:43 -0500 Subject: [PATCH 038/621] Improve support for multiple registrations of `textDocument/diagnostic` (#43703) Closes https://github.com/zed-industries/zed/issues/41935 The registration ID responsible for generating each diagnostic is now tracked. This allows us to replace only the diagnostics from the same registration ID when a pull diagnostics report is applied. Additionally, various deficiencies in our support for pull diagnostics have been fixed: - Document pulls are issued for all open buffers, not just the edited one. A shorter debounce is used for the edited buffer. Workspace diagnostics are also now ignored for open buffers. - Tracking of `lastResultId` is improved. - Stored pull diagnostics are discarded when the corresponding buffer is closed. Release Notes: - Improved compatibility with language servers that use the "pull diagnostics" feature of Language Server Protocol. --------- Co-authored-by: Kirill Bulatov Co-authored-by: Kirill Bulatov --- crates/collab/src/tests/editor_tests.rs | 26 +- crates/editor/src/editor.rs | 128 ++++-- crates/editor/src/editor_tests.rs | 12 +- crates/language/src/buffer.rs | 3 + crates/language/src/proto.rs | 7 + crates/multi_buffer/src/multi_buffer.rs | 5 +- crates/project/src/lsp_command.rs | 76 +++- crates/project/src/lsp_store.rs | 499 ++++++++++++++------- crates/project/src/lsp_store/clangd_ext.rs | 1 + crates/project/src/project.rs | 6 +- crates/project/src/project_tests.rs | 18 +- crates/proto/proto/buffer.proto | 1 + crates/proto/proto/lsp.proto | 1 + 13 files changed, 522 insertions(+), 261 deletions(-) diff --git a/crates/collab/src/tests/editor_tests.rs b/crates/collab/src/tests/editor_tests.rs index e5d3661aaf1aa0c74a4204e0989018121f5eb64a..785a6457c8fdb57f84a8e7b5a8487f0ceae3d025 100644 --- a/crates/collab/src/tests/editor_tests.rs +++ b/crates/collab/src/tests/editor_tests.rs @@ -25,6 +25,7 @@ use gpui::{ use indoc::indoc; use language::FakeLspAdapter; use lsp::LSP_REQUEST_TIMEOUT; +use pretty_assertions::assert_eq; use project::{ ProgressToken, ProjectPath, SERVER_PROGRESS_THROTTLE_TIMEOUT, lsp_store::lsp_ext_command::{ExpandedMacro, LspExtExpandMacro}, @@ -3192,13 +3193,12 @@ async fn test_lsp_pull_diagnostics( .collect::>(); let expected_messages = [ expected_pull_diagnostic_lib_message, - // TODO bug: the pushed diagnostics are not being sent to the client when they open the corresponding buffer. - // expected_push_diagnostic_lib_message, + expected_push_diagnostic_lib_message, ]; assert_eq!( all_diagnostics.len(), - 1, - "Expected pull diagnostics, but got: {all_diagnostics:?}" + 2, + "Expected pull and push diagnostics, but got: {all_diagnostics:?}" ); for diagnostic in all_diagnostics { assert!( @@ -3258,14 +3258,15 @@ async fn test_lsp_pull_diagnostics( .diagnostics_in_range(MultiBufferOffset(0)..snapshot.len()) .collect::>(); let expected_messages = [ - expected_workspace_pull_diagnostics_lib_message, - // TODO bug: the pushed diagnostics are not being sent to the client when they open the corresponding buffer. - // expected_push_diagnostic_lib_message, + // Despite workspace diagnostics provided, + // the currently open file's diagnostics should be preferred, as LSP suggests. + expected_pull_diagnostic_lib_message, + expected_push_diagnostic_lib_message, ]; assert_eq!( all_diagnostics.len(), - 1, - "Expected pull diagnostics, but got: {all_diagnostics:?}" + 2, + "Expected pull and push diagnostics, but got: {all_diagnostics:?}" ); for diagnostic in all_diagnostics { assert!( @@ -3378,8 +3379,9 @@ async fn test_lsp_pull_diagnostics( "Another workspace diagnostics pull should happen after the diagnostics refresh server request" ); { - assert!( - diagnostics_pulls_result_ids.lock().await.len() == diagnostic_pulls_result_ids, + assert_eq!( + diagnostics_pulls_result_ids.lock().await.len(), + diagnostic_pulls_result_ids, "Pulls should not happen hence no extra ids should appear" ); assert!( @@ -3397,7 +3399,7 @@ async fn test_lsp_pull_diagnostics( expected_pull_diagnostic_lib_message, expected_push_diagnostic_lib_message, ]; - assert_eq!(all_diagnostics.len(), 1); + assert_eq!(all_diagnostics.len(), 2); for diagnostic in &all_diagnostics { assert!( expected_messages.contains(&diagnostic.diagnostic.message.as_str()), diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index ae114b14ce04a405ddca95c0bda9cbaf28ccdadf..f6489c8ffece51d581e3fb73d3f683ff1283c433 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -1172,6 +1172,7 @@ pub struct Editor { gutter_breakpoint_indicator: (Option, Option>), hovered_diff_hunk_row: Option, pull_diagnostics_task: Task<()>, + pull_diagnostics_background_task: Task<()>, in_project_search: bool, previous_search_ranges: Option]>>, breadcrumb_header: Option, @@ -2316,6 +2317,7 @@ impl Editor { .unwrap_or_default(), tasks_update_task: None, pull_diagnostics_task: Task::ready(()), + pull_diagnostics_background_task: Task::ready(()), colors: None, refresh_colors_task: Task::ready(()), inlay_hints: None, @@ -2492,7 +2494,6 @@ impl Editor { if let Some(buffer) = multi_buffer.read(cx).as_singleton() { editor.register_buffer(buffer.read(cx).remote_id(), cx); } - editor.update_lsp_data(None, window, cx); editor.report_editor_event(ReportEditorEvent::EditorOpened, None, cx); } @@ -18400,54 +18401,101 @@ impl Editor { return None; } let project = self.project()?.downgrade(); - let debounce = Duration::from_millis(pull_diagnostics_settings.debounce_ms); - let mut buffers = self.buffer.read(cx).all_buffers(); - buffers.retain(|buffer| { - let buffer_id_to_retain = buffer.read(cx).remote_id(); - buffer_id.is_none_or(|buffer_id| buffer_id == buffer_id_to_retain) - && self.registered_buffers.contains_key(&buffer_id_to_retain) - }); - if buffers.is_empty() { + + let mut edited_buffer_ids = HashSet::default(); + let mut edited_worktree_ids = HashSet::default(); + let edited_buffers = match buffer_id { + Some(buffer_id) => { + let buffer = self.buffer().read(cx).buffer(buffer_id)?; + let worktree_id = buffer.read(cx).file().map(|f| f.worktree_id(cx))?; + edited_buffer_ids.insert(buffer.read(cx).remote_id()); + edited_worktree_ids.insert(worktree_id); + vec![buffer] + } + None => self + .buffer() + .read(cx) + .all_buffers() + .into_iter() + .filter(|buffer| { + let buffer = buffer.read(cx); + match buffer.file().map(|f| f.worktree_id(cx)) { + Some(worktree_id) => { + edited_buffer_ids.insert(buffer.remote_id()); + edited_worktree_ids.insert(worktree_id); + true + } + None => false, + } + }) + .collect::>(), + }; + + if edited_buffers.is_empty() { self.pull_diagnostics_task = Task::ready(()); + self.pull_diagnostics_background_task = Task::ready(()); return None; } - self.pull_diagnostics_task = cx.spawn_in(window, async move |editor, cx| { - cx.background_executor().timer(debounce).await; + let mut already_used_buffers = HashSet::default(); + let related_open_buffers = self + .workspace + .as_ref() + .and_then(|(workspace, _)| workspace.upgrade()) + .into_iter() + .flat_map(|workspace| workspace.read(cx).panes()) + .flat_map(|pane| pane.read(cx).items_of_type::()) + .filter(|editor| editor != &cx.entity()) + .flat_map(|editor| editor.read(cx).buffer().read(cx).all_buffers()) + .filter(|buffer| { + let buffer = buffer.read(cx); + let buffer_id = buffer.remote_id(); + if already_used_buffers.insert(buffer_id) { + if let Some(worktree_id) = buffer.file().map(|f| f.worktree_id(cx)) { + return !edited_buffer_ids.contains(&buffer_id) + && !edited_worktree_ids.contains(&worktree_id); + } + } + false + }) + .collect::>(); + + let debounce = Duration::from_millis(pull_diagnostics_settings.debounce_ms); + let make_spawn = |buffers: Vec>, delay: Duration| { + if buffers.is_empty() { + return Task::ready(()); + } + let project_weak = project.clone(); + cx.spawn_in(window, async move |_, cx| { + cx.background_executor().timer(delay).await; - let Ok(mut pull_diagnostics_tasks) = cx.update(|_, cx| { - buffers - .into_iter() - .filter_map(|buffer| { - project - .update(cx, |project, cx| { - project.lsp_store().update(cx, |lsp_store, cx| { - lsp_store.pull_diagnostics_for_buffer(buffer, cx) + let Ok(mut pull_diagnostics_tasks) = cx.update(|_, cx| { + buffers + .into_iter() + .filter_map(|buffer| { + project_weak + .update(cx, |project, cx| { + project.lsp_store().update(cx, |lsp_store, cx| { + lsp_store.pull_diagnostics_for_buffer(buffer, cx) + }) }) - }) - .ok() - }) - .collect::>() - }) else { - return; - }; + .ok() + }) + .collect::>() + }) else { + return; + }; - while let Some(pull_task) = pull_diagnostics_tasks.next().await { - match pull_task { - Ok(()) => { - if editor - .update_in(cx, |editor, window, cx| { - editor.update_diagnostics_state(window, cx); - }) - .is_err() - { - return; - } + while let Some(pull_task) = pull_diagnostics_tasks.next().await { + if let Err(e) = pull_task { + log::error!("Failed to update project diagnostics: {e:#}"); } - Err(e) => log::error!("Failed to update project diagnostics: {e:#}"), } - } - }); + }) + }; + + self.pull_diagnostics_task = make_spawn(edited_buffers, debounce); + self.pull_diagnostics_background_task = make_spawn(related_open_buffers, debounce * 2); Some(()) } diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rs index 61d316e3915a740cb35b24a3afa445a34a608336..d95f0f78bf8acea8703bb7780ca842f037850d64 100644 --- a/crates/editor/src/editor_tests.rs +++ b/crates/editor/src/editor_tests.rs @@ -26589,7 +26589,7 @@ async fn test_pulling_diagnostics(cx: &mut TestAppContext) { } }); - let ensure_result_id = |expected: Option, cx: &mut TestAppContext| { + let ensure_result_id = |expected: Option, cx: &mut TestAppContext| { project.update(cx, |project, cx| { let buffer_id = editor .read(cx) @@ -26602,7 +26602,7 @@ async fn test_pulling_diagnostics(cx: &mut TestAppContext) { let buffer_result_id = project .lsp_store() .read(cx) - .result_id(server_id, buffer_id, cx); + .result_id_for_buffer_pull(server_id, buffer_id, &None, cx); assert_eq!(expected, buffer_result_id); }); }; @@ -26619,7 +26619,7 @@ async fn test_pulling_diagnostics(cx: &mut TestAppContext) { .next() .await .expect("should have sent the first diagnostics pull request"); - ensure_result_id(Some("1".to_string()), cx); + ensure_result_id(Some(SharedString::new("1")), cx); // Editing should trigger diagnostics editor.update_in(cx, |editor, window, cx| { @@ -26632,7 +26632,7 @@ async fn test_pulling_diagnostics(cx: &mut TestAppContext) { 2, "Editing should trigger diagnostic request" ); - ensure_result_id(Some("2".to_string()), cx); + ensure_result_id(Some(SharedString::new("2")), cx); // Moving cursor should not trigger diagnostic request editor.update_in(cx, |editor, window, cx| { @@ -26647,7 +26647,7 @@ async fn test_pulling_diagnostics(cx: &mut TestAppContext) { 2, "Cursor movement should not trigger diagnostic request" ); - ensure_result_id(Some("2".to_string()), cx); + ensure_result_id(Some(SharedString::new("2")), cx); // Multiple rapid edits should be debounced for _ in 0..5 { editor.update_in(cx, |editor, window, cx| { @@ -26662,7 +26662,7 @@ async fn test_pulling_diagnostics(cx: &mut TestAppContext) { final_requests <= 4, "Multiple rapid edits should be debounced (got {final_requests} requests)", ); - ensure_result_id(Some(final_requests.to_string()), cx); + ensure_result_id(Some(SharedString::new(final_requests.to_string())), cx); } #[gpui::test] diff --git a/crates/language/src/buffer.rs b/crates/language/src/buffer.rs index c6eb3ff66b08b03f39466af4a8b65805003a8bd3..a46f7cc35912d4c6da42ba69f7aee6d25caca2e7 100644 --- a/crates/language/src/buffer.rs +++ b/crates/language/src/buffer.rs @@ -237,6 +237,8 @@ struct SelectionSet { pub struct Diagnostic { /// The name of the service that produced this diagnostic. pub source: Option, + /// The ID provided by the dynamic registration that produced this diagnostic. + pub registration_id: Option, /// A machine-readable code that identifies this diagnostic. pub code: Option, pub code_description: Option, @@ -5390,6 +5392,7 @@ impl Default for Diagnostic { is_unnecessary: false, underline: true, data: None, + registration_id: None, } } } diff --git a/crates/language/src/proto.rs b/crates/language/src/proto.rs index 5c8200b84002c104ce1e2c3d1a42aff5876bd1ee..242cce1c64d1d45b71d615e444409298ec2205db 100644 --- a/crates/language/src/proto.rs +++ b/crates/language/src/proto.rs @@ -3,6 +3,7 @@ use crate::{CursorShape, Diagnostic, DiagnosticSourceKind, diagnostic_set::DiagnosticEntry}; use anyhow::{Context as _, Result}; use clock::ReplicaId; +use gpui::SharedString; use lsp::{DiagnosticSeverity, LanguageServerId}; use rpc::proto; use serde_json::Value; @@ -239,6 +240,11 @@ pub fn serialize_diagnostics<'a>( is_disk_based: entry.diagnostic.is_disk_based, is_unnecessary: entry.diagnostic.is_unnecessary, data: entry.diagnostic.data.as_ref().map(|data| data.to_string()), + registration_id: entry + .diagnostic + .registration_id + .as_ref() + .map(ToString::to_string), }) .collect() } @@ -457,6 +463,7 @@ pub fn deserialize_diagnostics( is_disk_based: diagnostic.is_disk_based, is_unnecessary: diagnostic.is_unnecessary, underline: diagnostic.underline, + registration_id: diagnostic.registration_id.map(SharedString::from), source_kind: match proto::diagnostic::SourceKind::from_i32( diagnostic.source_kind, )? { diff --git a/crates/multi_buffer/src/multi_buffer.rs b/crates/multi_buffer/src/multi_buffer.rs index 5fac7dd4587132cd532073e571991018e643faa6..02adb79e70452a524152d62a71138b75561f9f33 100644 --- a/crates/multi_buffer/src/multi_buffer.rs +++ b/crates/multi_buffer/src/multi_buffer.rs @@ -2283,6 +2283,7 @@ impl MultiBuffer { cx: &mut Context, ) { use language::BufferEvent; + let buffer_id = buffer.read(cx).remote_id(); cx.emit(match event { BufferEvent::Edited => Event::Edited { edited_buffer: Some(buffer), @@ -2291,8 +2292,8 @@ impl MultiBuffer { BufferEvent::Saved => Event::Saved, BufferEvent::FileHandleChanged => Event::FileHandleChanged, BufferEvent::Reloaded => Event::Reloaded, - BufferEvent::LanguageChanged => Event::LanguageChanged(buffer.read(cx).remote_id()), - BufferEvent::Reparsed => Event::Reparsed(buffer.read(cx).remote_id()), + BufferEvent::LanguageChanged => Event::LanguageChanged(buffer_id), + BufferEvent::Reparsed => Event::Reparsed(buffer_id), BufferEvent::DiagnosticsUpdated => Event::DiagnosticsUpdated, BufferEvent::CapabilityChanged => { self.capability = buffer.read(cx).capability(); diff --git a/crates/project/src/lsp_command.rs b/crates/project/src/lsp_command.rs index adea507f00eda72e715fe535da7016af44a4f723..05ee70bf66fe9e56a27c5a84044c49600590f469 100644 --- a/crates/project/src/lsp_command.rs +++ b/crates/project/src/lsp_command.rs @@ -14,7 +14,7 @@ use client::proto::{self, PeerId}; use clock::Global; use collections::{HashMap, HashSet}; use futures::future; -use gpui::{App, AsyncApp, Entity, Task}; +use gpui::{App, AsyncApp, Entity, SharedString, Task}; use language::{ Anchor, Bias, Buffer, BufferSnapshot, CachedLspAdapter, CharKind, CharScopeContext, OffsetRangeExt, PointUtf16, ToOffset, ToPointUtf16, Transaction, Unclipped, @@ -26,8 +26,8 @@ use language::{ use lsp::{ AdapterServerCapabilities, CodeActionKind, CodeActionOptions, CodeDescription, CompletionContext, CompletionListItemDefaultsEditRange, CompletionTriggerKind, - DiagnosticServerCapabilities, DocumentHighlightKind, LanguageServer, LanguageServerId, - LinkedEditingRangeServerCapabilities, OneOf, RenameOptions, ServerCapabilities, + DocumentHighlightKind, LanguageServer, LanguageServerId, LinkedEditingRangeServerCapabilities, + OneOf, RenameOptions, ServerCapabilities, }; use serde_json::Value; use signature_help::{lsp_to_proto_signature, proto_to_lsp_signature}; @@ -265,8 +265,9 @@ pub(crate) struct LinkedEditingRange { pub(crate) struct GetDocumentDiagnostics { /// We cannot blindly rely on server's capabilities.diagnostic_provider, as they're a singular field, whereas /// a server can register multiple diagnostic providers post-mortem. - pub dynamic_caps: DiagnosticServerCapabilities, - pub previous_result_id: Option, + pub registration_id: Option, + pub identifier: Option, + pub previous_result_id: Option, } #[async_trait(?Send)] @@ -3755,15 +3756,16 @@ impl GetDocumentDiagnostics { .into_iter() .filter_map(|diagnostics| { Some(LspPullDiagnostics::Response { + registration_id: diagnostics.registration_id.map(SharedString::from), server_id: LanguageServerId::from_proto(diagnostics.server_id), uri: lsp::Uri::from_str(diagnostics.uri.as_str()).log_err()?, diagnostics: if diagnostics.changed { PulledDiagnostics::Unchanged { - result_id: diagnostics.result_id?, + result_id: SharedString::new(diagnostics.result_id?), } } else { PulledDiagnostics::Changed { - result_id: diagnostics.result_id, + result_id: diagnostics.result_id.map(SharedString::new), diagnostics: diagnostics .diagnostics .into_iter() @@ -3927,6 +3929,7 @@ impl GetDocumentDiagnostics { pub fn deserialize_workspace_diagnostics_report( report: lsp::WorkspaceDiagnosticReportResult, server_id: LanguageServerId, + registration_id: Option, ) -> Vec { let mut pulled_diagnostics = HashMap::default(); match report { @@ -3938,6 +3941,7 @@ impl GetDocumentDiagnostics { &mut pulled_diagnostics, server_id, report, + registration_id.clone(), ) } lsp::WorkspaceDocumentDiagnosticReport::Unchanged(report) => { @@ -3945,6 +3949,7 @@ impl GetDocumentDiagnostics { &mut pulled_diagnostics, server_id, report, + registration_id.clone(), ) } } @@ -3960,6 +3965,7 @@ impl GetDocumentDiagnostics { &mut pulled_diagnostics, server_id, report, + registration_id.clone(), ) } lsp::WorkspaceDocumentDiagnosticReport::Unchanged(report) => { @@ -3967,6 +3973,7 @@ impl GetDocumentDiagnostics { &mut pulled_diagnostics, server_id, report, + registration_id.clone(), ) } } @@ -3987,6 +3994,7 @@ fn process_full_workspace_diagnostics_report( diagnostics: &mut HashMap, server_id: LanguageServerId, report: lsp::WorkspaceFullDocumentDiagnosticReport, + registration_id: Option, ) { let mut new_diagnostics = HashMap::default(); process_full_diagnostics_report( @@ -3994,6 +4002,7 @@ fn process_full_workspace_diagnostics_report( server_id, report.uri, report.full_document_diagnostic_report, + registration_id, ); diagnostics.extend(new_diagnostics.into_iter().map(|(uri, diagnostics)| { ( @@ -4010,6 +4019,7 @@ fn process_unchanged_workspace_diagnostics_report( diagnostics: &mut HashMap, server_id: LanguageServerId, report: lsp::WorkspaceUnchangedDocumentDiagnosticReport, + registration_id: Option, ) { let mut new_diagnostics = HashMap::default(); process_unchanged_diagnostics_report( @@ -4017,6 +4027,7 @@ fn process_unchanged_workspace_diagnostics_report( server_id, report.uri, report.unchanged_document_diagnostic_report, + registration_id, ); diagnostics.extend(new_diagnostics.into_iter().map(|(uri, diagnostics)| { ( @@ -4050,19 +4061,12 @@ impl LspCommand for GetDocumentDiagnostics { _: &Arc, _: &App, ) -> Result { - let identifier = match &self.dynamic_caps { - lsp::DiagnosticServerCapabilities::Options(options) => options.identifier.clone(), - lsp::DiagnosticServerCapabilities::RegistrationOptions(options) => { - options.diagnostic_options.identifier.clone() - } - }; - Ok(lsp::DocumentDiagnosticParams { text_document: lsp::TextDocumentIdentifier { uri: file_path_to_lsp_url(path)?, }, - identifier, - previous_result_id: self.previous_result_id.clone(), + identifier: self.identifier.clone(), + previous_result_id: self.previous_result_id.clone().map(|id| id.to_string()), partial_result_params: Default::default(), work_done_progress_params: Default::default(), }) @@ -4097,6 +4101,7 @@ impl LspCommand for GetDocumentDiagnostics { &mut pulled_diagnostics, server_id, related_documents, + self.registration_id.clone(), ); } process_full_diagnostics_report( @@ -4104,6 +4109,7 @@ impl LspCommand for GetDocumentDiagnostics { server_id, url, report.full_document_diagnostic_report, + self.registration_id, ); } lsp::DocumentDiagnosticReport::Unchanged(report) => { @@ -4112,6 +4118,7 @@ impl LspCommand for GetDocumentDiagnostics { &mut pulled_diagnostics, server_id, related_documents, + self.registration_id.clone(), ); } process_unchanged_diagnostics_report( @@ -4119,6 +4126,7 @@ impl LspCommand for GetDocumentDiagnostics { server_id, url, report.unchanged_document_diagnostic_report, + self.registration_id, ); } }, @@ -4128,6 +4136,7 @@ impl LspCommand for GetDocumentDiagnostics { &mut pulled_diagnostics, server_id, related_documents, + self.registration_id, ); } } @@ -4170,6 +4179,7 @@ impl LspCommand for GetDocumentDiagnostics { server_id, uri, diagnostics, + registration_id, } => { let mut changed = false; let (diagnostics, result_id) = match diagnostics { @@ -4184,7 +4194,7 @@ impl LspCommand for GetDocumentDiagnostics { }; Some(proto::PulledDiagnostics { changed, - result_id, + result_id: result_id.map(|id| id.to_string()), uri: uri.to_string(), server_id: server_id.to_proto(), diagnostics: diagnostics @@ -4195,6 +4205,7 @@ impl LspCommand for GetDocumentDiagnostics { .log_err() }) .collect(), + registration_id: registration_id.as_ref().map(ToString::to_string), }) } }) @@ -4365,14 +4376,25 @@ fn process_related_documents( diagnostics: &mut HashMap, server_id: LanguageServerId, documents: impl IntoIterator, + registration_id: Option, ) { for (url, report_kind) in documents { match report_kind { - lsp::DocumentDiagnosticReportKind::Full(report) => { - process_full_diagnostics_report(diagnostics, server_id, url, report) - } + lsp::DocumentDiagnosticReportKind::Full(report) => process_full_diagnostics_report( + diagnostics, + server_id, + url, + report, + registration_id.clone(), + ), lsp::DocumentDiagnosticReportKind::Unchanged(report) => { - process_unchanged_diagnostics_report(diagnostics, server_id, url, report) + process_unchanged_diagnostics_report( + diagnostics, + server_id, + url, + report, + registration_id.clone(), + ) } } } @@ -4383,8 +4405,9 @@ fn process_unchanged_diagnostics_report( server_id: LanguageServerId, uri: lsp::Uri, report: lsp::UnchangedDocumentDiagnosticReport, + registration_id: Option, ) { - let result_id = report.result_id; + let result_id = SharedString::new(report.result_id); match diagnostics.entry(uri.clone()) { hash_map::Entry::Occupied(mut o) => match o.get_mut() { LspPullDiagnostics::Default => { @@ -4392,12 +4415,14 @@ fn process_unchanged_diagnostics_report( server_id, uri, diagnostics: PulledDiagnostics::Unchanged { result_id }, + registration_id, }); } LspPullDiagnostics::Response { server_id: existing_server_id, uri: existing_uri, diagnostics: existing_diagnostics, + .. } => { if server_id != *existing_server_id || &uri != existing_uri { debug_panic!( @@ -4417,6 +4442,7 @@ fn process_unchanged_diagnostics_report( server_id, uri, diagnostics: PulledDiagnostics::Unchanged { result_id }, + registration_id, }); } } @@ -4427,8 +4453,9 @@ fn process_full_diagnostics_report( server_id: LanguageServerId, uri: lsp::Uri, report: lsp::FullDocumentDiagnosticReport, + registration_id: Option, ) { - let result_id = report.result_id; + let result_id = report.result_id.map(SharedString::new); match diagnostics.entry(uri.clone()) { hash_map::Entry::Occupied(mut o) => match o.get_mut() { LspPullDiagnostics::Default => { @@ -4439,12 +4466,14 @@ fn process_full_diagnostics_report( result_id, diagnostics: report.items, }, + registration_id, }); } LspPullDiagnostics::Response { server_id: existing_server_id, uri: existing_uri, diagnostics: existing_diagnostics, + .. } => { if server_id != *existing_server_id || &uri != existing_uri { debug_panic!( @@ -4478,6 +4507,7 @@ fn process_full_diagnostics_report( result_id, diagnostics: report.items, }, + registration_id, }); } } diff --git a/crates/project/src/lsp_store.rs b/crates/project/src/lsp_store.rs index bd8b512bbca6b0725f4d9a7ae4ce07d6681d48db..59b7a6932d4733a78959e9e4f481a63589811a52 100644 --- a/crates/project/src/lsp_store.rs +++ b/crates/project/src/lsp_store.rs @@ -116,6 +116,7 @@ use std::{ atomic::{self, AtomicUsize}, }, time::{Duration, Instant}, + vec, }; use sum_tree::Dimensions; use text::{Anchor, BufferId, LineEnding, OffsetRangeExt, ToPoint as _}; @@ -229,7 +230,8 @@ struct LanguageServerSeed { #[derive(Debug)] pub struct DocumentDiagnosticsUpdate<'a, D> { pub diagnostics: D, - pub result_id: Option, + pub result_id: Option, + pub registration_id: Option, pub server_id: LanguageServerId, pub disk_based_sources: Cow<'a, [String]>, } @@ -283,7 +285,14 @@ pub struct LocalLspStore { lsp_tree: LanguageServerTree, registered_buffers: HashMap, buffers_opened_in_servers: HashMap>, - buffer_pull_diagnostics_result_ids: HashMap>>, + buffer_pull_diagnostics_result_ids: HashMap< + LanguageServerId, + HashMap, HashMap>>, + >, + workspace_pull_diagnostics_result_ids: HashMap< + LanguageServerId, + HashMap, HashMap>>, + >, } impl LocalLspStore { @@ -685,6 +694,7 @@ impl LocalLspStore { disk_based_sources: Cow::Borrowed( &adapter.disk_based_diagnostic_sources, ), + registration_id: None, }], |_, diagnostic, cx| match diagnostic.source_kind { DiagnosticSourceKind::Other | DiagnosticSourceKind::Pushed => { @@ -2256,8 +2266,9 @@ impl LocalLspStore { server_id, None, None, - diagnostics, + None, Vec::new(), + diagnostics, cx, ) .log_err(); @@ -2335,7 +2346,8 @@ impl LocalLspStore { &mut self, buffer: &Entity, server_id: LanguageServerId, - result_id: Option, + registration_id: Option>, + result_id: Option, version: Option, new_diagnostics: Vec>>, reused_diagnostics: Vec>>, @@ -2408,11 +2420,15 @@ impl LocalLspStore { let set = DiagnosticSet::new(sanitized_diagnostics, &snapshot); buffer.update(cx, |buffer, cx| { - if let Some(abs_path) = File::from_dyn(buffer.file()).map(|f| f.abs_path(cx)) { - self.buffer_pull_diagnostics_result_ids - .entry(server_id) - .or_default() - .insert(abs_path, result_id); + if let Some(registration_id) = registration_id { + if let Some(abs_path) = File::from_dyn(buffer.file()).map(|f| f.abs_path(cx)) { + self.buffer_pull_diagnostics_result_ids + .entry(server_id) + .or_default() + .entry(registration_id) + .or_default() + .insert(abs_path, result_id); + } } buffer.update_diagnostics(server_id, set, cx) @@ -3266,6 +3282,8 @@ impl LocalLspStore { self.language_servers.remove(server_id_to_remove); self.buffer_pull_diagnostics_result_ids .remove(server_id_to_remove); + self.workspace_pull_diagnostics_result_ids + .remove(server_id_to_remove); for buffer_servers in self.buffers_opened_in_servers.values_mut() { buffer_servers.remove(server_id_to_remove); } @@ -3952,6 +3970,7 @@ impl LspStore { registered_buffers: HashMap::default(), buffers_opened_in_servers: HashMap::default(), buffer_pull_diagnostics_result_ids: HashMap::default(), + workspace_pull_diagnostics_result_ids: HashMap::default(), watched_manifest_filenames: ManifestProvidersStore::global(cx) .manifest_file_names(), }), @@ -4225,9 +4244,50 @@ impl LspStore { lsp_store.lsp_data.remove(&buffer_id); let local = lsp_store.as_local_mut().unwrap(); local.registered_buffers.remove(&buffer_id); + local.buffers_opened_in_servers.remove(&buffer_id); if let Some(file) = File::from_dyn(buffer.read(cx).file()).cloned() { local.unregister_old_buffer_from_language_servers(buffer, &file, cx); + + let buffer_abs_path = file.abs_path(cx); + for (_, buffer_pull_diagnostics_result_ids) in + &mut local.buffer_pull_diagnostics_result_ids + { + buffer_pull_diagnostics_result_ids.retain( + |_, buffer_result_ids| { + buffer_result_ids.remove(&buffer_abs_path); + !buffer_result_ids.is_empty() + }, + ); + } + + let diagnostic_updates = local + .language_servers + .keys() + .cloned() + .map(|server_id| DocumentDiagnosticsUpdate { + diagnostics: DocumentDiagnostics { + document_abs_path: buffer_abs_path.clone(), + version: None, + diagnostics: Vec::new(), + }, + result_id: None, + registration_id: None, + server_id: server_id, + disk_based_sources: Cow::Borrowed(&[]), + }) + .collect::>(); + + lsp_store + .merge_diagnostic_entries( + diagnostic_updates, + |_, diagnostic, _| { + diagnostic.source_kind != DiagnosticSourceKind::Pulled + }, + cx, + ) + .context("Clearing diagnostics for the closed buffer") + .log_err(); } } }) @@ -6700,9 +6760,11 @@ impl LspStore { }; assert!(any_server_has_diagnostics_provider); + let identifier = buffer_diagnostic_identifier(&dynamic_caps); let request = GetDocumentDiagnostics { previous_result_id: None, - dynamic_caps, + identifier, + registration_id: None, }; let request_task = client.request_lsp( upstream_project_id, @@ -6735,19 +6797,27 @@ impl LspStore { .language_server_dynamic_registrations .get(&server_id) .into_iter() - .flat_map(|registrations| registrations.diagnostics.values().cloned()) + .flat_map(|registrations| registrations.diagnostics.clone()) .collect::>(); Some( providers_with_identifiers .into_iter() - .map(|dynamic_caps| { - let result_id = self.result_id(server_id, buffer_id, cx); + .map(|(registration_id, dynamic_caps)| { + let identifier = buffer_diagnostic_identifier(&dynamic_caps); + let registration_id = registration_id.map(SharedString::from); + let result_id = self.result_id_for_buffer_pull( + server_id, + buffer_id, + ®istration_id, + cx, + ); self.request_lsp( buffer.clone(), LanguageServerToQuery::Other(server_id), GetDocumentDiagnostics { previous_result_id: result_id, - dynamic_caps, + registration_id, + identifier, }, cx, ) @@ -7112,8 +7182,7 @@ impl LspStore { return; } - let mut unchanged_buffers = HashSet::default(); - let mut changed_buffers = HashSet::default(); + let mut unchanged_buffers = HashMap::default(); let server_diagnostics_updates = diagnostics .into_iter() .filter_map(|diagnostics_set| match diagnostics_set { @@ -7121,24 +7190,25 @@ impl LspStore { server_id, uri, diagnostics, - } => Some((server_id, uri, diagnostics)), + registration_id, + } => Some((server_id, uri, diagnostics, registration_id)), LspPullDiagnostics::Default => None, }) .fold( HashMap::default(), - |mut acc, (server_id, uri, diagnostics)| { + |mut acc, (server_id, uri, diagnostics, new_registration_id)| { let (result_id, diagnostics) = match diagnostics { PulledDiagnostics::Unchanged { result_id } => { - unchanged_buffers.insert(uri.clone()); + unchanged_buffers + .entry(new_registration_id.clone()) + .or_insert_with(HashSet::default) + .insert(uri.clone()); (Some(result_id), Vec::new()) } PulledDiagnostics::Changed { result_id, diagnostics, - } => { - changed_buffers.insert(uri.clone()); - (result_id, diagnostics) - } + } => (result_id, diagnostics), }; let disk_based_sources = Cow::Owned( lsp_store @@ -7148,8 +7218,11 @@ impl LspStore { .unwrap_or(&[]) .to_vec(), ); - acc.entry(server_id).or_insert_with(Vec::new).push( - DocumentDiagnosticsUpdate { + acc.entry(server_id) + .or_insert_with(HashMap::default) + .entry(new_registration_id.clone()) + .or_insert_with(Vec::new) + .push(DocumentDiagnosticsUpdate { server_id, diagnostics: lsp::PublishDiagnosticsParams { uri, @@ -7158,37 +7231,35 @@ impl LspStore { }, result_id, disk_based_sources, - }, - ); + registration_id: new_registration_id, + }); acc }, ); for diagnostic_updates in server_diagnostics_updates.into_values() { - lsp_store - .merge_lsp_diagnostics( - DiagnosticSourceKind::Pulled, - diagnostic_updates, - |buffer, old_diagnostic, cx| { - File::from_dyn(buffer.file()) - .and_then(|file| { - let abs_path = file.as_local()?.abs_path(cx); - lsp::Uri::from_file_path(abs_path).ok() - }) - .is_none_or(|buffer_uri| { - unchanged_buffers.contains(&buffer_uri) - || match old_diagnostic.source_kind { - DiagnosticSourceKind::Pulled => { - !changed_buffers.contains(&buffer_uri) - } - DiagnosticSourceKind::Other - | DiagnosticSourceKind::Pushed => true, - } - }) - }, - cx, - ) - .log_err(); + for (registration_id, diagnostic_updates) in diagnostic_updates { + lsp_store + .merge_lsp_diagnostics( + DiagnosticSourceKind::Pulled, + diagnostic_updates, + |document_uri, old_diagnostic, _| match old_diagnostic.source_kind { + DiagnosticSourceKind::Pulled => { + old_diagnostic.registration_id != registration_id + || unchanged_buffers + .get(&old_diagnostic.registration_id) + .is_some_and(|unchanged_buffers| { + unchanged_buffers.contains(&document_uri) + }) + } + DiagnosticSourceKind::Other | DiagnosticSourceKind::Pushed => { + true + } + }, + cx, + ) + .log_err(); + } } }) }) @@ -8195,7 +8266,7 @@ impl LspStore { &mut self, server_id: LanguageServerId, abs_path: PathBuf, - result_id: Option, + result_id: Option, version: Option, diagnostics: Vec>>, cx: &mut Context, @@ -8210,6 +8281,7 @@ impl LspStore { result_id, server_id, disk_based_sources: Cow::Borrowed(&[]), + registration_id: None, }], |_, _, _| false, cx, @@ -8220,7 +8292,7 @@ impl LspStore { pub fn merge_diagnostic_entries<'a>( &mut self, diagnostic_updates: Vec>, - merge: impl Fn(&Buffer, &Diagnostic, &App) -> bool + Clone, + merge: impl Fn(&lsp::Uri, &Diagnostic, &App) -> bool + Clone, cx: &mut Context, ) -> anyhow::Result<()> { let mut diagnostics_summary = None::; @@ -8241,13 +8313,15 @@ impl LspStore { path: relative_path, }; + let document_uri = lsp::Uri::from_file_path(abs_path) + .map_err(|()| anyhow!("Failed to convert buffer path {abs_path:?} to lsp Uri"))?; if let Some(buffer_handle) = self.buffer_store.read(cx).get_by_path(&project_path) { let snapshot = buffer_handle.read(cx).snapshot(); let buffer = buffer_handle.read(cx); let reused_diagnostics = buffer .buffer_diagnostics(Some(server_id)) .iter() - .filter(|v| merge(buffer, &v.diagnostic, cx)) + .filter(|v| merge(&document_uri, &v.diagnostic, cx)) .map(|v| { let start = Unclipped(v.range.start.to_point_utf16(&snapshot)); let end = Unclipped(v.range.end.to_point_utf16(&snapshot)); @@ -8263,6 +8337,7 @@ impl LspStore { .update_buffer_diagnostics( &buffer_handle, server_id, + Some(update.registration_id), update.result_id, update.diagnostics.version, update.diagnostics.diagnostics.clone(), @@ -8271,6 +8346,25 @@ impl LspStore { )?; update.diagnostics.diagnostics.extend(reused_diagnostics); + } else if let Some(local) = self.as_local() { + let reused_diagnostics = local + .diagnostics + .get(&worktree_id) + .and_then(|diagnostics_for_tree| diagnostics_for_tree.get(&project_path.path)) + .and_then(|diagnostics_by_server_id| { + diagnostics_by_server_id + .binary_search_by_key(&server_id, |e| e.0) + .ok() + .map(|ix| &diagnostics_by_server_id[ix].1) + }) + .into_iter() + .flatten() + .filter(|v| merge(&document_uri, &v.diagnostic, cx)); + + update + .diagnostics + .diagnostics + .extend(reused_diagnostics.cloned()); } let updated = worktree.update(cx, |worktree, cx| { @@ -8355,7 +8449,7 @@ impl LspStore { .unwrap_or_default(); let new_summary = DiagnosticSummary::new(&diagnostics); - if new_summary.is_empty() { + if diagnostics.is_empty() { if let Some(diagnostics_by_server_id) = diagnostics_for_tree.get_mut(&path_in_worktree) { if let Ok(ix) = diagnostics_by_server_id.binary_search_by_key(&server_id, |e| e.0) { @@ -9665,7 +9759,7 @@ impl LspStore { ); } lsp::ProgressParamsValue::WorkspaceDiagnostic(report) => { - let identifier = match progress_params.token { + let registration_id = match progress_params.token { lsp::NumberOrString::Number(_) => None, lsp::NumberOrString::String(token) => token .split_once(WORKSPACE_DIAGNOSTICS_TOKEN_START) @@ -9678,10 +9772,15 @@ impl LspStore { .as_local_mut() .and_then(|local| local.language_servers.get_mut(&language_server_id)) && let Some(workspace_diagnostics) = - workspace_diagnostics_refresh_tasks.get_mut(&identifier) + workspace_diagnostics_refresh_tasks.get_mut(®istration_id) { workspace_diagnostics.progress_tx.try_send(()).ok(); - self.apply_workspace_diagnostic_report(language_server_id, report, cx) + self.apply_workspace_diagnostic_report( + language_server_id, + report, + registration_id.map(SharedString::from), + cx, + ) } } } @@ -10941,7 +11040,7 @@ impl LspStore { &mut self, server_id: LanguageServerId, diagnostics: lsp::PublishDiagnosticsParams, - result_id: Option, + result_id: Option, source_kind: DiagnosticSourceKind, disk_based_sources: &[String], cx: &mut Context, @@ -10953,6 +11052,7 @@ impl LspStore { result_id, server_id, disk_based_sources: Cow::Borrowed(disk_based_sources), + registration_id: None, }], |_, _, _| false, cx, @@ -10963,7 +11063,7 @@ impl LspStore { &mut self, source_kind: DiagnosticSourceKind, lsp_diagnostics: Vec>, - merge: impl Fn(&Buffer, &Diagnostic, &App) -> bool + Clone, + merge: impl Fn(&lsp::Uri, &Diagnostic, &App) -> bool + Clone, cx: &mut Context, ) -> Result<()> { anyhow::ensure!(self.mode.is_local(), "called update_diagnostics on remote"); @@ -10978,10 +11078,12 @@ impl LspStore { update.server_id, update.diagnostics, &update.disk_based_sources, + update.registration_id.clone(), ), result_id: update.result_id, server_id: update.server_id, disk_based_sources: update.disk_based_sources, + registration_id: update.registration_id, }) }) .collect(); @@ -10996,6 +11098,7 @@ impl LspStore { server_id: LanguageServerId, mut lsp_diagnostics: lsp::PublishDiagnosticsParams, disk_based_sources: &[String], + registration_id: Option, ) -> DocumentDiagnostics { let mut diagnostics = Vec::default(); let mut primary_diagnostic_group_ids = HashMap::default(); @@ -11069,6 +11172,7 @@ impl LspStore { is_unnecessary, underline, data: diagnostic.data.clone(), + registration_id: registration_id.clone(), }, }); if let Some(infos) = &diagnostic.related_information { @@ -11096,6 +11200,7 @@ impl LspStore { is_unnecessary: false, underline, data: diagnostic.data.clone(), + registration_id: registration_id.clone(), }, }); } @@ -11845,18 +11950,22 @@ impl LspStore { } if let Some(local) = self.as_local_mut() { local.buffer_pull_diagnostics_result_ids.remove(&for_server); + local + .workspace_pull_diagnostics_result_ids + .remove(&for_server); for buffer_servers in local.buffers_opened_in_servers.values_mut() { buffer_servers.remove(&for_server); } } } - pub fn result_id( + pub fn result_id_for_buffer_pull( &self, server_id: LanguageServerId, buffer_id: BufferId, + registration_id: &Option, cx: &App, - ) -> Option { + ) -> Option { let abs_path = self .buffer_store .read(cx) @@ -11866,20 +11975,40 @@ impl LspStore { self.as_local()? .buffer_pull_diagnostics_result_ids .get(&server_id)? + .get(registration_id)? .get(&abs_path)? .clone() } - pub fn all_result_ids(&self, server_id: LanguageServerId) -> HashMap { + /// Gets all result_ids for a workspace diagnostics pull request. + /// First, it tries to find buffer's result_id retrieved via the diagnostics pull; if it fails, it falls back to the workspace disagnostics pull result_id. + /// The latter is supposed to be of lower priority as we keep on pulling diagnostics for open buffers eagerly. + pub fn result_ids_for_workspace_refresh( + &self, + server_id: LanguageServerId, + registration_id: &Option, + ) -> HashMap { let Some(local) = self.as_local() else { return HashMap::default(); }; local - .buffer_pull_diagnostics_result_ids + .workspace_pull_diagnostics_result_ids .get(&server_id) .into_iter() + .filter_map(|diagnostics| diagnostics.get(registration_id)) .flatten() - .filter_map(|(abs_path, result_id)| Some((abs_path.clone(), result_id.clone()?))) + .filter_map(|(abs_path, result_id)| { + let result_id = local + .buffer_pull_diagnostics_result_ids + .get(&server_id) + .and_then(|buffer_ids_result_ids| { + buffer_ids_result_ids.get(registration_id)?.get(abs_path) + }) + .cloned() + .flatten() + .or_else(|| result_id.clone())?; + Some((abs_path.clone(), result_id)) + }) .collect() } @@ -11924,12 +12053,16 @@ impl LspStore { &mut self, server_id: LanguageServerId, report: lsp::WorkspaceDiagnosticReportResult, + registration_id: Option, cx: &mut Context, ) { let workspace_diagnostics = - GetDocumentDiagnostics::deserialize_workspace_diagnostics_report(report, server_id); - let mut unchanged_buffers = HashSet::default(); - let mut changed_buffers = HashSet::default(); + GetDocumentDiagnostics::deserialize_workspace_diagnostics_report( + report, + server_id, + registration_id, + ); + let mut unchanged_buffers = HashMap::default(); let workspace_diagnostics_updates = workspace_diagnostics .into_iter() .filter_map( @@ -11938,25 +12071,32 @@ impl LspStore { server_id, uri, diagnostics, - } => Some((server_id, uri, diagnostics, workspace_diagnostics.version)), + registration_id, + } => Some(( + server_id, + uri, + diagnostics, + workspace_diagnostics.version, + registration_id, + )), LspPullDiagnostics::Default => None, }, ) .fold( HashMap::default(), - |mut acc, (server_id, uri, diagnostics, version)| { + |mut acc, (server_id, uri, diagnostics, version, new_registration_id)| { let (result_id, diagnostics) = match diagnostics { PulledDiagnostics::Unchanged { result_id } => { - unchanged_buffers.insert(uri.clone()); + unchanged_buffers + .entry(new_registration_id.clone()) + .or_insert_with(HashSet::default) + .insert(uri.clone()); (Some(result_id), Vec::new()) } PulledDiagnostics::Changed { result_id, diagnostics, - } => { - changed_buffers.insert(uri.clone()); - (result_id, diagnostics) - } + } => (result_id, diagnostics), }; let disk_based_sources = Cow::Owned( self.language_server_adapter_for_id(server_id) @@ -11965,47 +12105,68 @@ impl LspStore { .unwrap_or(&[]) .to_vec(), ); - acc.entry(server_id) - .or_insert_with(Vec::new) - .push(DocumentDiagnosticsUpdate { - server_id, - diagnostics: lsp::PublishDiagnosticsParams { - uri, - diagnostics, - version, - }, - result_id, - disk_based_sources, - }); + + let Some(abs_path) = uri.to_file_path().ok() else { + return acc; + }; + let Some((worktree, relative_path)) = + self.worktree_store.read(cx).find_worktree(abs_path.clone(), cx) + else { + log::warn!("skipping workspace diagnostics update, no worktree found for path {abs_path:?}"); + return acc; + }; + let worktree_id = worktree.read(cx).id(); + let project_path = ProjectPath { + worktree_id, + path: relative_path, + }; + if let Some(local_lsp_store) = self.as_local_mut() { + local_lsp_store.workspace_pull_diagnostics_result_ids.entry(server_id) + .or_default().entry(new_registration_id.clone()).or_default().insert(abs_path, result_id.clone()); + } + // The LSP spec recommends that "diagnostics from a document pull should win over diagnostics from a workspace pull." + // Since we actively pull diagnostics for documents with open buffers, we ignore contents of workspace pulls for these documents. + if self.buffer_store.read(cx).get_by_path(&project_path).is_none() { + acc.entry(server_id) + .or_insert_with(HashMap::default) + .entry(new_registration_id.clone()) + .or_insert_with(Vec::new) + .push(DocumentDiagnosticsUpdate { + server_id, + diagnostics: lsp::PublishDiagnosticsParams { + uri, + diagnostics, + version, + }, + result_id, + disk_based_sources, + registration_id: new_registration_id, + }); + } acc }, ); for diagnostic_updates in workspace_diagnostics_updates.into_values() { - self.merge_lsp_diagnostics( - DiagnosticSourceKind::Pulled, - diagnostic_updates, - |buffer, old_diagnostic, cx| { - File::from_dyn(buffer.file()) - .and_then(|file| { - let abs_path = file.as_local()?.abs_path(cx); - lsp::Uri::from_file_path(abs_path).ok() - }) - .is_none_or(|buffer_uri| { - unchanged_buffers.contains(&buffer_uri) - || match old_diagnostic.source_kind { - DiagnosticSourceKind::Pulled => { - !changed_buffers.contains(&buffer_uri) - } - DiagnosticSourceKind::Other | DiagnosticSourceKind::Pushed => { - true - } - } - }) - }, - cx, - ) - .log_err(); + for (registration_id, diagnostic_updates) in diagnostic_updates { + self.merge_lsp_diagnostics( + DiagnosticSourceKind::Pulled, + diagnostic_updates, + |document_uri, old_diagnostic, _| match old_diagnostic.source_kind { + DiagnosticSourceKind::Pulled => { + old_diagnostic.registration_id != registration_id + || unchanged_buffers + .get(&old_diagnostic.registration_id) + .is_some_and(|unchanged_buffers| { + unchanged_buffers.contains(&document_uri) + }) + } + DiagnosticSourceKind::Other | DiagnosticSourceKind::Pushed => true, + }, + cx, + ) + .log_err(); + } } } @@ -12284,54 +12445,41 @@ impl LspStore { .diagnostics .insert(Some(reg.id.clone()), caps.clone()); - if let LanguageServerState::Running { - workspace_diagnostics_refresh_tasks, - .. - } = state - && let Some(task) = lsp_workspace_diagnostics_refresh( - Some(reg.id.clone()), - caps.clone(), - server.clone(), - cx, - ) - { - workspace_diagnostics_refresh_tasks.insert(Some(reg.id), task); + let supports_workspace_diagnostics = + |capabilities: &DiagnosticServerCapabilities| match capabilities { + DiagnosticServerCapabilities::Options(diagnostic_options) => { + diagnostic_options.workspace_diagnostics + } + DiagnosticServerCapabilities::RegistrationOptions( + diagnostic_registration_options, + ) => { + diagnostic_registration_options + .diagnostic_options + .workspace_diagnostics + } + }; + + if supports_workspace_diagnostics(&caps) { + if let LanguageServerState::Running { + workspace_diagnostics_refresh_tasks, + .. + } = state + && let Some(task) = lsp_workspace_diagnostics_refresh( + Some(reg.id.clone()), + caps.clone(), + server.clone(), + cx, + ) + { + workspace_diagnostics_refresh_tasks.insert(Some(reg.id), task); + } } - let mut did_update_caps = false; server.update_capabilities(|capabilities| { - if capabilities.diagnostic_provider.as_ref().is_none_or( - |current_caps| { - let supports_workspace_diagnostics = - |capabilities: &DiagnosticServerCapabilities| { - match capabilities { - DiagnosticServerCapabilities::Options( - diagnostic_options, - ) => diagnostic_options.workspace_diagnostics, - DiagnosticServerCapabilities::RegistrationOptions( - diagnostic_registration_options, - ) => { - diagnostic_registration_options - .diagnostic_options - .workspace_diagnostics - } - } - }; - // We don't actually care about capabilities.diagnostic_provider, but it IS relevant for the remote peer - // to know that there's at least one provider. Otherwise, it will never ask us to issue documentdiagnostic calls on their behalf, - // as it'll think that they're not supported. - // If we did not support any workspace diagnostics up to this point but now do, let's update. - !supports_workspace_diagnostics(current_caps) - & supports_workspace_diagnostics(&caps) - }, - ) { - did_update_caps = true; - capabilities.diagnostic_provider = Some(caps); - } + capabilities.diagnostic_provider = Some(caps); }); - if did_update_caps { - notify_server_capabilities_updated(&server, cx); - } + + notify_server_capabilities_updated(&server, cx); } } "textDocument/documentColor" => { @@ -12499,7 +12647,7 @@ impl LspStore { .language_servers .get_mut(&server_id) .context("Could not obtain Language Servers state")?; - let options = local + local .language_server_dynamic_registrations .get_mut(&server_id) .with_context(|| { @@ -12512,13 +12660,12 @@ impl LspStore { )?; let mut has_any_diagnostic_providers_still = true; - if let Some(identifier) = diagnostic_identifier(&options) - && let LanguageServerState::Running { - workspace_diagnostics_refresh_tasks, - .. - } = state + if let LanguageServerState::Running { + workspace_diagnostics_refresh_tasks, + .. + } = state { - workspace_diagnostics_refresh_tasks.remove(&identifier); + workspace_diagnostics_refresh_tasks.remove(&Some(unreg.id.clone())); has_any_diagnostic_providers_still = !workspace_diagnostics_refresh_tasks.is_empty(); } @@ -12822,7 +12969,8 @@ fn lsp_workspace_diagnostics_refresh( server: Arc, cx: &mut Context<'_, LspStore>, ) -> Option { - let identifier = diagnostic_identifier(&options)?; + let identifier = workspace_diagnostic_identifier(&options)?; + let registration_id_shared = registration_id.as_ref().map(SharedString::from); let (progress_tx, mut progress_rx) = mpsc::channel(1); let (mut refresh_tx, mut refresh_rx) = mpsc::channel(1); @@ -12854,13 +13002,13 @@ fn lsp_workspace_diagnostics_refresh( let Ok(previous_result_ids) = lsp_store.update(cx, |lsp_store, _| { lsp_store - .all_result_ids(server.server_id()) + .result_ids_for_workspace_refresh(server.server_id(), ®istration_id_shared) .into_iter() .filter_map(|(abs_path, result_id)| { let uri = file_path_to_lsp_url(&abs_path).ok()?; Some(lsp::PreviousResultId { uri, - value: result_id, + value: result_id.to_string(), }) }) .collect() @@ -12868,9 +13016,9 @@ fn lsp_workspace_diagnostics_refresh( return; }; - let token = if let Some(identifier) = ®istration_id { + let token = if let Some(registration_id) = ®istration_id { format!( - "workspace/diagnostic/{}/{requests}/{WORKSPACE_DIAGNOSTICS_TOKEN_START}{identifier}", + "workspace/diagnostic/{}/{requests}/{WORKSPACE_DIAGNOSTICS_TOKEN_START}{registration_id}", server.server_id(), ) } else { @@ -12920,6 +13068,7 @@ fn lsp_workspace_diagnostics_refresh( lsp_store.apply_workspace_diagnostic_report( server.server_id(), pulled_diagnostics, + registration_id_shared.clone(), cx, ) }) @@ -12941,7 +13090,21 @@ fn lsp_workspace_diagnostics_refresh( }) } -fn diagnostic_identifier(options: &DiagnosticServerCapabilities) -> Option> { +fn buffer_diagnostic_identifier(options: &DiagnosticServerCapabilities) -> Option { + match &options { + lsp::DiagnosticServerCapabilities::Options(diagnostic_options) => { + diagnostic_options.identifier.clone() + } + lsp::DiagnosticServerCapabilities::RegistrationOptions(registration_options) => { + let diagnostic_options = ®istration_options.diagnostic_options; + diagnostic_options.identifier.clone() + } + } +} + +fn workspace_diagnostic_identifier( + options: &DiagnosticServerCapabilities, +) -> Option> { match &options { lsp::DiagnosticServerCapabilities::Options(diagnostic_options) => { if !diagnostic_options.workspace_diagnostics { diff --git a/crates/project/src/lsp_store/clangd_ext.rs b/crates/project/src/lsp_store/clangd_ext.rs index b02f68dd4d1271ca9a8fa97e9ef41e03fdfe9763..466d0c6e2a0a37667854490433bb97265948d83e 100644 --- a/crates/project/src/lsp_store/clangd_ext.rs +++ b/crates/project/src/lsp_store/clangd_ext.rs @@ -90,6 +90,7 @@ pub fn register_notifications( disk_based_sources: Cow::Borrowed( &adapter.disk_based_diagnostic_sources, ), + registration_id: None, }], |_, diag, _| !is_inactive_region(diag), cx, diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index afc854bceb59f88a496b6fcb99e840184277c894..f1060ee2560c82c540497133c046eed67d9f8eed 100644 --- a/crates/project/src/project.rs +++ b/crates/project/src/project.rs @@ -984,6 +984,8 @@ pub enum LspPullDiagnostics { server_id: LanguageServerId, /// URI of the resource, uri: lsp::Uri, + /// The ID provided by the dynamic registration that produced diagnostics. + registration_id: Option, /// The diagnostics produced by this language server. diagnostics: PulledDiagnostics, }, @@ -994,10 +996,10 @@ pub enum PulledDiagnostics { Unchanged { /// An ID the current pulled batch for this file. /// If given, can be used to query workspace diagnostics partially. - result_id: String, + result_id: SharedString, }, Changed { - result_id: Option, + result_id: Option, diagnostics: Vec, }, } diff --git a/crates/project/src/project_tests.rs b/crates/project/src/project_tests.rs index 3117c0f5944d05a08524608a82587226a735550e..8adba2dea16391c35096c487c4eff0098d52df56 100644 --- a/crates/project/src/project_tests.rs +++ b/crates/project/src/project_tests.rs @@ -2750,11 +2750,13 @@ async fn test_empty_diagnostic_ranges(cx: &mut gpui::TestAppContext) { ); let fs = FakeFs::new(cx.executor()); - fs.insert_tree("/dir", json!({ "a.rs": text })).await; + fs.insert_tree(path!("/dir"), json!({ "a.rs": text })).await; - let project = Project::test(fs, ["/dir".as_ref()], cx).await; + let project = Project::test(fs, [Path::new(path!("/dir"))], cx).await; let buffer = project - .update(cx, |project, cx| project.open_local_buffer("/dir/a.rs", cx)) + .update(cx, |project, cx| { + project.open_local_buffer(path!("/dir/a.rs"), cx) + }) .await .unwrap(); @@ -2763,7 +2765,7 @@ async fn test_empty_diagnostic_ranges(cx: &mut gpui::TestAppContext) { lsp_store .update_diagnostic_entries( LanguageServerId(0), - PathBuf::from("/dir/a.rs"), + PathBuf::from(path!("/dir/a.rs")), None, None, vec![ @@ -2820,17 +2822,17 @@ async fn test_diagnostics_from_multiple_language_servers(cx: &mut gpui::TestAppC init_test(cx); let fs = FakeFs::new(cx.executor()); - fs.insert_tree("/dir", json!({ "a.rs": "one two three" })) + fs.insert_tree(path!("/dir"), json!({ "a.rs": "one two three" })) .await; - let project = Project::test(fs, ["/dir".as_ref()], cx).await; + let project = Project::test(fs, [Path::new(path!("/dir"))], cx).await; let lsp_store = project.read_with(cx, |project, _| project.lsp_store.clone()); lsp_store.update(cx, |lsp_store, cx| { lsp_store .update_diagnostic_entries( LanguageServerId(0), - Path::new("/dir/a.rs").to_owned(), + Path::new(path!("/dir/a.rs")).to_owned(), None, None, vec![DiagnosticEntry { @@ -2849,7 +2851,7 @@ async fn test_diagnostics_from_multiple_language_servers(cx: &mut gpui::TestAppC lsp_store .update_diagnostic_entries( LanguageServerId(1), - Path::new("/dir/a.rs").to_owned(), + Path::new(path!("/dir/a.rs")).to_owned(), None, None, vec![DiagnosticEntry { diff --git a/crates/proto/proto/buffer.proto b/crates/proto/proto/buffer.proto index 4580fd8e9db80e7dc54b1c997f8df108e3bf9330..486716b36a221911ddf5abe1336a1e6cc3808769 100644 --- a/crates/proto/proto/buffer.proto +++ b/crates/proto/proto/buffer.proto @@ -258,6 +258,7 @@ message Diagnostic { Anchor start = 1; Anchor end = 2; optional string source = 3; + optional string registration_id = 17; enum SourceKind { Pulled = 0; diff --git a/crates/proto/proto/lsp.proto b/crates/proto/proto/lsp.proto index fa44528e2ed6009e6f18b6b5b9702b5228f10f05..7717cacdef70914c697e1a2a0e0234cd63970267 100644 --- a/crates/proto/proto/lsp.proto +++ b/crates/proto/proto/lsp.proto @@ -949,6 +949,7 @@ message PulledDiagnostics { optional string result_id = 3; bool changed = 4; repeated LspDiagnostic diagnostics = 5; + optional string registration_id = 6; } message PullWorkspaceDiagnostics { From 4ef8433396245ba38f5a4406551def1265abbe0d Mon Sep 17 00:00:00 2001 From: Cole Miller Date: Wed, 3 Dec 2025 14:33:40 -0500 Subject: [PATCH 039/621] Run `git2::Repository::find_remote` in the background (#44092) We were seeing this hog the main thread. Release Notes: - N/A --------- Co-authored-by: cameron --- crates/fs/src/fake_git_repo.rs | 4 +- crates/git/src/repository.rs | 53 ++++++++++++------- .../src/git_hosting_providers.rs | 4 +- crates/project/src/git_store.rs | 8 +-- crates/project/src/telemetry_snapshot.rs | 2 +- 5 files changed, 43 insertions(+), 28 deletions(-) diff --git a/crates/fs/src/fake_git_repo.rs b/crates/fs/src/fake_git_repo.rs index c641988ab891889b8ebb63c7e9414d69d3107558..b6beb9fc6ecb470b30c6ed4edca06be479db11c0 100644 --- a/crates/fs/src/fake_git_repo.rs +++ b/crates/fs/src/fake_git_repo.rs @@ -152,8 +152,8 @@ impl GitRepository for FakeGitRepository { }) } - fn remote_url(&self, _name: &str) -> Option { - None + fn remote_url(&self, _name: &str) -> BoxFuture<'_, Option> { + async move { None }.boxed() } fn diff_tree(&self, _request: DiffTreeType) -> BoxFuture<'_, Result> { diff --git a/crates/git/src/repository.rs b/crates/git/src/repository.rs index 23c5795209c1eda9acbf4fe9f48a4e3de898a89a..e49b1715901f3dcc463bee0e7870d69073fa0561 100644 --- a/crates/git/src/repository.rs +++ b/crates/git/src/repository.rs @@ -420,7 +420,7 @@ pub trait GitRepository: Send + Sync { ) -> BoxFuture<'_, anyhow::Result<()>>; /// Returns the URL of the remote with the given name. - fn remote_url(&self, name: &str) -> Option; + fn remote_url(&self, name: &str) -> BoxFuture<'_, Option>; /// Resolve a list of refs to SHAs. fn revparse_batch(&self, revs: Vec) -> BoxFuture<'_, Result>>>; @@ -1085,10 +1085,16 @@ impl GitRepository for RealGitRepository { .boxed() } - fn remote_url(&self, name: &str) -> Option { - let repo = self.repository.lock(); - let remote = repo.find_remote(name).ok()?; - remote.url().map(|url| url.to_string()) + fn remote_url(&self, name: &str) -> BoxFuture<'_, Option> { + let repo = self.repository.clone(); + let name = name.to_owned(); + self.executor + .spawn(async move { + let repo = repo.lock(); + let remote = repo.find_remote(&name).ok()?; + remote.url().map(|url| url.to_string()) + }) + .boxed() } fn revparse_batch(&self, revs: Vec) -> BoxFuture<'_, Result>>> { @@ -1465,23 +1471,30 @@ impl GitRepository for RealGitRepository { fn blame(&self, path: RepoPath, content: Rope) -> BoxFuture<'_, Result> { let working_directory = self.working_directory(); let git_binary_path = self.any_git_binary_path.clone(); + let executor = self.executor.clone(); - let remote_url = self - .remote_url("upstream") - .or_else(|| self.remote_url("origin")); - - self.executor - .spawn(async move { - crate::blame::Blame::for_path( - &git_binary_path, - &working_directory?, - &path, - &content, - remote_url, - ) + async move { + let remote_url = if let Some(remote_url) = self.remote_url("upstream").await { + Some(remote_url) + } else if let Some(remote_url) = self.remote_url("origin").await { + Some(remote_url) + } else { + None + }; + executor + .spawn(async move { + crate::blame::Blame::for_path( + &git_binary_path, + &working_directory?, + &path, + &content, + remote_url, + ) + .await + }) .await - }) - .boxed() + } + .boxed() } fn file_history(&self, path: RepoPath) -> BoxFuture<'_, Result> { diff --git a/crates/git_hosting_providers/src/git_hosting_providers.rs b/crates/git_hosting_providers/src/git_hosting_providers.rs index 6940ea382a1a21dbb3e97b55d74ee2489a1691ba..98ea301ec984298df54ec8bca7e28f9474e373bd 100644 --- a/crates/git_hosting_providers/src/git_hosting_providers.rs +++ b/crates/git_hosting_providers/src/git_hosting_providers.rs @@ -33,11 +33,11 @@ pub fn init(cx: &mut App) { /// /// These require information from the Git repository to construct, so their /// registration is deferred until we have a Git repository initialized. -pub fn register_additional_providers( +pub async fn register_additional_providers( provider_registry: Arc, repository: Arc, ) { - let Some(origin_url) = repository.remote_url("origin") else { + let Some(origin_url) = repository.remote_url("origin").await else { return; }; diff --git a/crates/project/src/git_store.rs b/crates/project/src/git_store.rs index 58181e20e961685f34c3298add113f847c3d93c5..5bc3f4ee43493ee9d07ab2c3a1025214007a653d 100644 --- a/crates/project/src/git_store.rs +++ b/crates/project/src/git_store.rs @@ -1130,6 +1130,7 @@ impl GitStore { RepositoryState::Local(LocalRepositoryState { backend, .. }) => { let origin_url = backend .remote_url(&remote) + .await .with_context(|| format!("remote \"{remote}\" not found"))?; let sha = backend.head_sha().await.context("reading HEAD SHA")?; @@ -5447,7 +5448,8 @@ impl Repository { git_hosting_providers::register_additional_providers( git_hosting_provider_registry, state.backend.clone(), - ); + ) + .await; } let state = RepositoryState::Local(state); let mut jobs = VecDeque::new(); @@ -6052,8 +6054,8 @@ async fn compute_snapshot( } // Used by edit prediction data collection - let remote_origin_url = backend.remote_url("origin"); - let remote_upstream_url = backend.remote_url("upstream"); + let remote_origin_url = backend.remote_url("origin").await; + let remote_upstream_url = backend.remote_url("upstream").await; let snapshot = RepositorySnapshot { id, diff --git a/crates/project/src/telemetry_snapshot.rs b/crates/project/src/telemetry_snapshot.rs index d12481ae5e7abdeca9e9fdd693fc9721dbeb49dd..5f9155371d74887af25d6e7481848444c6f25112 100644 --- a/crates/project/src/telemetry_snapshot.rs +++ b/crates/project/src/telemetry_snapshot.rs @@ -96,7 +96,7 @@ impl TelemetryWorktreeSnapshot { }; }; - let remote_url = backend.remote_url("origin"); + let remote_url = backend.remote_url("origin").await; let head_sha = backend.head_sha().await; let diff = backend.diff(DiffType::HeadToWorktree).await.ok(); From 92dcfdef7657a80761837837d0f8cc54ace8aae9 Mon Sep 17 00:00:00 2001 From: feeiyu <158308373+feeiyu@users.noreply.github.com> Date: Thu, 4 Dec 2025 03:34:01 +0800 Subject: [PATCH 040/621] Fix circular reference issue around PopoverMenu again (#44084) Follow up to https://github.com/zed-industries/zed/pull/42351 Release Notes: - N/A --- crates/agent_ui/src/acp/mode_selector.rs | 5 +++-- crates/extensions_ui/src/extensions_ui.rs | 18 ++++++++++-------- crates/language_tools/src/lsp_log_view.rs | 4 ++-- crates/language_tools/src/syntax_tree_view.rs | 14 +++++++++----- 4 files changed, 24 insertions(+), 17 deletions(-) diff --git a/crates/agent_ui/src/acp/mode_selector.rs b/crates/agent_ui/src/acp/mode_selector.rs index 2db031cafeb8a66e43120be9766debe3c16eb2d0..1f50ce74321d393ba6c7f5083bd889bc3dc2c0e1 100644 --- a/crates/agent_ui/src/acp/mode_selector.rs +++ b/crates/agent_ui/src/acp/mode_selector.rs @@ -161,7 +161,7 @@ impl Render for ModeSelector { .map(|mode| mode.name.clone()) .unwrap_or_else(|| "Unknown".into()); - let this = cx.entity(); + let this = cx.weak_entity(); let icon = if self.menu_handle.is_deployed() { IconName::ChevronUp @@ -222,7 +222,8 @@ impl Render for ModeSelector { y: px(-2.0), }) .menu(move |window, cx| { - Some(this.update(cx, |this, cx| this.build_context_menu(window, cx))) + this.update(cx, |this, cx| this.build_context_menu(window, cx)) + .ok() }) } } diff --git a/crates/extensions_ui/src/extensions_ui.rs b/crates/extensions_ui/src/extensions_ui.rs index 11a5d1797a7173a9b5d23e2eae19bf028f37d7ed..89247ae5a49a99b2a4f2261892b2656e14bb8674 100644 --- a/crates/extensions_ui/src/extensions_ui.rs +++ b/crates/extensions_ui/src/extensions_ui.rs @@ -739,7 +739,7 @@ impl ExtensionsPage { extension: &ExtensionMetadata, cx: &mut Context, ) -> ExtensionCard { - let this = cx.entity(); + let this = cx.weak_entity(); let status = Self::extension_status(&extension.id, cx); let has_dev_extension = Self::dev_extension_exists(&extension.id, cx); @@ -889,13 +889,15 @@ impl ExtensionsPage { y: px(2.0), }) .menu(move |window, cx| { - Some(Self::render_remote_extension_context_menu( - &this, - extension_id.clone(), - authors.clone(), - window, - cx, - )) + this.upgrade().map(|this| { + Self::render_remote_extension_context_menu( + &this, + extension_id.clone(), + authors.clone(), + window, + cx, + ) + }) }), ), ), diff --git a/crates/language_tools/src/lsp_log_view.rs b/crates/language_tools/src/lsp_log_view.rs index df24f469495a2396410408a68f7310d1546eefde..4295985b5f846cbf1ff87a1012042ee6b6608945 100644 --- a/crates/language_tools/src/lsp_log_view.rs +++ b/crates/language_tools/src/lsp_log_view.rs @@ -937,7 +937,7 @@ impl Render for LspLogToolbarItemView { }) .collect(); - let log_toolbar_view = cx.entity(); + let log_toolbar_view = cx.weak_entity(); let lsp_menu = PopoverMenu::new("LspLogView") .anchor(Corner::TopLeft) @@ -1021,7 +1021,7 @@ impl Render for LspLogToolbarItemView { .icon_color(Color::Muted), ) .menu(move |window, cx| { - let log_toolbar_view = log_toolbar_view.clone(); + let log_toolbar_view = log_toolbar_view.upgrade()?; let log_view = log_view.clone(); Some(ContextMenu::build(window, cx, move |this, window, _| { this.entry( diff --git a/crates/language_tools/src/syntax_tree_view.rs b/crates/language_tools/src/syntax_tree_view.rs index 3ac007c134657ff33259f961f170d5a7d732a22c..c06ecd21e7f2eb86b4114ec2671f38297fd5fa25 100644 --- a/crates/language_tools/src/syntax_tree_view.rs +++ b/crates/language_tools/src/syntax_tree_view.rs @@ -614,13 +614,14 @@ impl SyntaxTreeToolbarItemView { let active_layer = buffer_state.active_layer.clone()?; let active_buffer = buffer_state.buffer.read(cx).snapshot(); - let view = cx.entity(); + let view = cx.weak_entity(); Some( PopoverMenu::new("Syntax Tree") .trigger(Self::render_header(&active_layer)) .menu(move |window, cx| { - ContextMenu::build(window, cx, |mut menu, window, _| { + ContextMenu::build(window, cx, |mut menu, _, _| { for (layer_ix, layer) in active_buffer.syntax_layers().enumerate() { + let view = view.clone(); menu = menu.entry( format!( "{} {}", @@ -628,9 +629,12 @@ impl SyntaxTreeToolbarItemView { format_node_range(layer.node()) ), None, - window.handler_for(&view, move |view, window, cx| { - view.select_layer(layer_ix, window, cx); - }), + move |window, cx| { + view.update(cx, |view, cx| { + view.select_layer(layer_ix, window, cx); + }) + .ok(); + }, ); } menu From 290a1550aaeab663b3aecead176bd1add68c8adb Mon Sep 17 00:00:00 2001 From: Michael Benfield Date: Wed, 3 Dec 2025 12:32:25 -0800 Subject: [PATCH 041/621] ai: Add an eval for the inline assistant (#43291) Release Notes: - N/A --------- Co-authored-by: Mikayla Maki --- Cargo.lock | 14 + Cargo.toml | 2 + crates/agent/Cargo.toml | 1 + crates/agent/src/edit_agent/evals.rs | 718 +++++++++++------------- crates/agent_ui/Cargo.toml | 8 +- crates/agent_ui/src/agent_panel.rs | 5 +- crates/agent_ui/src/agent_ui.rs | 2 + crates/agent_ui/src/buffer_codegen.rs | 1 + crates/agent_ui/src/evals.rs | 89 +++ crates/agent_ui/src/inline_assistant.rs | 196 ++++++- crates/eval_utils/Cargo.toml | 18 + crates/eval_utils/LICENSE-GPL | 1 + crates/eval_utils/README.md | 3 + crates/eval_utils/src/eval_utils.rs | 128 +++++ crates/gpui/src/app.rs | 28 + crates/gpui/src/app/test_context.rs | 12 +- crates/gpui/src/window.rs | 4 +- crates/http_client/src/http_client.rs | 2 + crates/language_model/src/registry.rs | 5 + 19 files changed, 836 insertions(+), 401 deletions(-) create mode 100644 crates/agent_ui/src/evals.rs create mode 100644 crates/eval_utils/Cargo.toml create mode 120000 crates/eval_utils/LICENSE-GPL create mode 100644 crates/eval_utils/README.md create mode 100644 crates/eval_utils/src/eval_utils.rs diff --git a/Cargo.lock b/Cargo.lock index 3e2f12a91c2b76a393f7f99f68bcd05933cb27f1..03b7339856a9adba3538152ac3874fd0dec859b5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -159,6 +159,7 @@ dependencies = [ "derive_more 0.99.20", "editor", "env_logger 0.11.8", + "eval_utils", "fs", "futures 0.3.31", "git", @@ -327,6 +328,7 @@ dependencies = [ "buffer_diff", "chrono", "client", + "clock", "cloud_llm_client", "collections", "command_palette_hooks", @@ -334,6 +336,7 @@ dependencies = [ "context_server", "db", "editor", + "eval_utils", "extension", "extension_host", "feature_flags", @@ -342,6 +345,7 @@ dependencies = [ "futures 0.3.31", "fuzzy", "gpui", + "gpui_tokio", "html_to_markdown", "http_client", "image", @@ -369,6 +373,7 @@ dependencies = [ "proto", "rand 0.9.2", "release_channel", + "reqwest_client", "rope", "rules_library", "schemars", @@ -5775,6 +5780,15 @@ dependencies = [ "watch", ] +[[package]] +name = "eval_utils" +version = "0.1.0" +dependencies = [ + "gpui", + "serde", + "smol", +] + [[package]] name = "event-listener" version = "2.5.3" diff --git a/Cargo.toml b/Cargo.toml index a6512c79093c197f5ed7a195f78bf7a170a15abe..e81e53426fc9ee47000e14cb8141ce4e4b6d8b30 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -59,6 +59,7 @@ members = [ "crates/zeta2_tools", "crates/editor", "crates/eval", + "crates/eval_utils", "crates/explorer_command_injector", "crates/extension", "crates/extension_api", @@ -288,6 +289,7 @@ deepseek = { path = "crates/deepseek" } derive_refineable = { path = "crates/refineable/derive_refineable" } diagnostics = { path = "crates/diagnostics" } editor = { path = "crates/editor" } +eval_utils = { path = "crates/eval_utils" } extension = { path = "crates/extension" } extension_host = { path = "crates/extension_host" } extensions_ui = { path = "crates/extensions_ui" } diff --git a/crates/agent/Cargo.toml b/crates/agent/Cargo.toml index cacbbd6e4e4423e2560fb963ef59daddce2309dc..667033a1bb33ea0372b8a9d8b0bfb00b23f59347 100644 --- a/crates/agent/Cargo.toml +++ b/crates/agent/Cargo.toml @@ -83,6 +83,7 @@ ctor.workspace = true db = { workspace = true, "features" = ["test-support"] } editor = { workspace = true, "features" = ["test-support"] } env_logger.workspace = true +eval_utils.workspace = true fs = { workspace = true, "features" = ["test-support"] } git = { workspace = true, "features" = ["test-support"] } gpui = { workspace = true, "features" = ["test-support"] } diff --git a/crates/agent/src/edit_agent/evals.rs b/crates/agent/src/edit_agent/evals.rs index 81dce33d0394b5757be4934031f31b6f17233e9c..edf8a0f671d231b3bfbd29526c256388fd41f85a 100644 --- a/crates/agent/src/edit_agent/evals.rs +++ b/crates/agent/src/edit_agent/evals.rs @@ -4,7 +4,7 @@ use crate::{ }; use Role::*; use client::{Client, UserStore}; -use collections::HashMap; +use eval_utils::{EvalOutput, EvalOutputProcessor, OutcomeKind}; use fs::FakeFs; use futures::{FutureExt, future::LocalBoxFuture}; use gpui::{AppContext, TestAppContext, Timer}; @@ -20,16 +20,62 @@ use rand::prelude::*; use reqwest_client::ReqwestClient; use serde_json::json; use std::{ - cmp::Reverse, fmt::{self, Display}, - io::Write as _, path::Path, str::FromStr, - sync::mpsc, time::Duration, }; use util::path; +#[derive(Default, Clone, Debug)] +struct EditAgentOutputProcessor { + mismatched_tag_threshold: f32, + cumulative_tags: usize, + cumulative_mismatched_tags: usize, + eval_outputs: Vec>, +} + +fn mismatched_tag_threshold(mismatched_tag_threshold: f32) -> EditAgentOutputProcessor { + EditAgentOutputProcessor { + mismatched_tag_threshold, + cumulative_tags: 0, + cumulative_mismatched_tags: 0, + eval_outputs: Vec::new(), + } +} + +#[derive(Clone, Debug)] +struct EditEvalMetadata { + tags: usize, + mismatched_tags: usize, +} + +impl EvalOutputProcessor for EditAgentOutputProcessor { + type Metadata = EditEvalMetadata; + + fn process(&mut self, output: &EvalOutput) { + if matches!(output.outcome, OutcomeKind::Passed | OutcomeKind::Failed) { + self.cumulative_mismatched_tags += output.metadata.mismatched_tags; + self.cumulative_tags += output.metadata.tags; + self.eval_outputs.push(output.clone()); + } + } + + fn assert(&mut self) { + let mismatched_tag_ratio = + self.cumulative_mismatched_tags as f32 / self.cumulative_tags as f32; + if mismatched_tag_ratio > self.mismatched_tag_threshold { + for eval_output in &self.eval_outputs { + println!("{}", eval_output.data); + } + panic!( + "Too many mismatched tags: {:?}", + self.cumulative_mismatched_tags + ); + } + } +} + #[test] #[cfg_attr(not(feature = "unit-eval"), ignore)] fn eval_extract_handle_command_output() { @@ -55,22 +101,19 @@ fn eval_extract_handle_command_output() { include_str!("evals/fixtures/extract_handle_command_output/possible-07.diff"), ]; let edit_description = "Extract `handle_command_output` method from `run_git_blame`."; - eval( - 100, - 0.95, - 0.05, - EvalInput::from_conversation( + eval_utils::eval(100, 0.95, mismatched_tag_threshold(0.05), move || { + run_eval(EvalInput::from_conversation( vec![ message( User, [text(formatdoc! {" - Read the `{input_file_path}` file and extract a method in - the final stanza of `run_git_blame` to deal with command failures, - call it `handle_command_output` and take the std::process::Output as the only parameter. - Do not document the method and do not add any comments. + Read the `{input_file_path}` file and extract a method in + the final stanza of `run_git_blame` to deal with command failures, + call it `handle_command_output` and take the std::process::Output as the only parameter. + Do not document the method and do not add any comments. - Add it right next to `run_git_blame` and copy it verbatim from `run_git_blame`. - "})], + Add it right next to `run_git_blame` and copy it verbatim from `run_git_blame`. + "})], ), message( Assistant, @@ -102,9 +145,9 @@ fn eval_extract_handle_command_output() { ), ], Some(input_file_content.into()), - EvalAssertion::assert_diff_any(possible_diffs), - ), - ); + EvalAssertion::assert_diff_any(possible_diffs.clone()), + )) + }); } #[test] @@ -122,18 +165,16 @@ fn eval_delete_run_git_blame() { let input_file_content = include_str!("evals/fixtures/delete_run_git_blame/before.rs"); let output_file_content = include_str!("evals/fixtures/delete_run_git_blame/after.rs"); let edit_description = "Delete the `run_git_blame` function."; - eval( - 100, - 0.95, - 0.05, - EvalInput::from_conversation( + + eval_utils::eval(100, 0.95, mismatched_tag_threshold(0.05), move || { + run_eval(EvalInput::from_conversation( vec![ message( User, [text(formatdoc! {" - Read the `{input_file_path}` file and delete `run_git_blame`. Just that - one function, not its usages. - "})], + Read the `{input_file_path}` file and delete `run_git_blame`. Just that + one function, not its usages. + "})], ), message( Assistant, @@ -166,8 +207,8 @@ fn eval_delete_run_git_blame() { ], Some(input_file_content.into()), EvalAssertion::assert_eq(output_file_content), - ), - ); + )) + }); } #[test] @@ -185,18 +226,16 @@ fn eval_translate_doc_comments() { let input_file_path = "root/canvas.rs"; let input_file_content = include_str!("evals/fixtures/translate_doc_comments/before.rs"); let edit_description = "Translate all doc comments to Italian"; - eval( - 200, - 1., - 0.05, - EvalInput::from_conversation( + + eval_utils::eval(200, 1., mismatched_tag_threshold(0.05), move || { + run_eval(EvalInput::from_conversation( vec![ message( User, [text(formatdoc! {" - Read the {input_file_path} file and edit it (without overwriting it), - translating all the doc comments to italian. - "})], + Read the {input_file_path} file and edit it (without overwriting it), + translating all the doc comments to italian. + "})], ), message( Assistant, @@ -229,8 +268,8 @@ fn eval_translate_doc_comments() { ], Some(input_file_content.into()), EvalAssertion::judge_diff("Doc comments were translated to Italian"), - ), - ); + )) + }); } #[test] @@ -249,33 +288,31 @@ fn eval_use_wasi_sdk_in_compile_parser_to_wasm() { let input_file_content = include_str!("evals/fixtures/use_wasi_sdk_in_compile_parser_to_wasm/before.rs"); let edit_description = "Update compile_parser_to_wasm to use wasi-sdk instead of emscripten"; - eval( - 100, - 0.95, - 0.05, - EvalInput::from_conversation( + + eval_utils::eval(100, 0.95, mismatched_tag_threshold(0.05), move || { + run_eval(EvalInput::from_conversation( vec![ message( User, [text(formatdoc! {" - Read the `{input_file_path}` file and change `compile_parser_to_wasm` to use `wasi-sdk` instead of emscripten. - Use `ureq` to download the SDK for the current platform and architecture. - Extract the archive into a sibling of `lib` inside the `tree-sitter` directory in the cache_dir. - Compile the parser to wasm using the `bin/clang` executable (or `bin/clang.exe` on windows) - that's inside of the archive. - Don't re-download the SDK if that executable already exists. - - Use these clang flags: -fPIC -shared -Os -Wl,--export=tree_sitter_{{language_name}} - - Here are the available wasi-sdk assets: - - wasi-sdk-25.0-x86_64-macos.tar.gz - - wasi-sdk-25.0-arm64-macos.tar.gz - - wasi-sdk-25.0-x86_64-linux.tar.gz - - wasi-sdk-25.0-arm64-linux.tar.gz - - wasi-sdk-25.0-x86_64-linux.tar.gz - - wasi-sdk-25.0-arm64-linux.tar.gz - - wasi-sdk-25.0-x86_64-windows.tar.gz - "})], + Read the `{input_file_path}` file and change `compile_parser_to_wasm` to use `wasi-sdk` instead of emscripten. + Use `ureq` to download the SDK for the current platform and architecture. + Extract the archive into a sibling of `lib` inside the `tree-sitter` directory in the cache_dir. + Compile the parser to wasm using the `bin/clang` executable (or `bin/clang.exe` on windows) + that's inside of the archive. + Don't re-download the SDK if that executable already exists. + + Use these clang flags: -fPIC -shared -Os -Wl,--export=tree_sitter_{{language_name}} + + Here are the available wasi-sdk assets: + - wasi-sdk-25.0-x86_64-macos.tar.gz + - wasi-sdk-25.0-arm64-macos.tar.gz + - wasi-sdk-25.0-x86_64-linux.tar.gz + - wasi-sdk-25.0-arm64-linux.tar.gz + - wasi-sdk-25.0-x86_64-linux.tar.gz + - wasi-sdk-25.0-arm64-linux.tar.gz + - wasi-sdk-25.0-x86_64-windows.tar.gz + "})], ), message( Assistant, @@ -352,11 +389,11 @@ fn eval_use_wasi_sdk_in_compile_parser_to_wasm() { ], Some(input_file_content.into()), EvalAssertion::judge_diff(indoc! {" - - The compile_parser_to_wasm method has been changed to use wasi-sdk - - ureq is used to download the SDK for current platform and architecture - "}), - ), - ); + - The compile_parser_to_wasm method has been changed to use wasi-sdk + - ureq is used to download the SDK for current platform and architecture + "}), + )) + }); } #[test] @@ -380,11 +417,8 @@ fn eval_disable_cursor_blinking() { include_str!("evals/fixtures/disable_cursor_blinking/possible-03.diff"), include_str!("evals/fixtures/disable_cursor_blinking/possible-04.diff"), ]; - eval( - 100, - 0.51, - 0.05, - EvalInput::from_conversation( + eval_utils::eval(100, 0.51, mismatched_tag_threshold(0.05), move || { + run_eval(EvalInput::from_conversation( vec![ message(User, [text("Let's research how to cursor blinking works.")]), message( @@ -421,10 +455,10 @@ fn eval_disable_cursor_blinking() { message( User, [text(indoc! {" - Comment out the lines that interact with the BlinkManager. - Keep the outer `update` blocks, but comments everything that's inside (including if statements). - Don't add additional comments. - "})], + Comment out the lines that interact with the BlinkManager. + Keep the outer `update` blocks, but comments everything that's inside (including if statements). + Don't add additional comments. + "})], ), message( Assistant, @@ -440,9 +474,9 @@ fn eval_disable_cursor_blinking() { ), ], Some(input_file_content.into()), - EvalAssertion::assert_diff_any(possible_diffs), - ), - ); + EvalAssertion::assert_diff_any(possible_diffs.clone()), + )) + }); } #[test] @@ -467,20 +501,16 @@ fn eval_from_pixels_constructor() { let input_file_path = "root/canvas.rs"; let input_file_content = include_str!("evals/fixtures/from_pixels_constructor/before.rs"); let edit_description = "Implement from_pixels constructor and add tests."; - eval( - 100, - 0.95, - // For whatever reason, this eval produces more mismatched tags. - // Increasing for now, let's see if we can bring this down. - 0.25, - EvalInput::from_conversation( + + eval_utils::eval(100, 0.95, mismatched_tag_threshold(0.25), move || { + run_eval(EvalInput::from_conversation( vec![ message( User, [text(indoc! {" - Introduce a new `from_pixels` constructor in Canvas and - also add tests for it in the same file. - "})], + Introduce a new `from_pixels` constructor in Canvas and + also add tests for it in the same file. + "})], ), message( Assistant, @@ -545,92 +575,92 @@ fn eval_from_pixels_constructor() { "tool_4", "grep", indoc! {" - Found 6 matches: + Found 6 matches: - ## Matches in font-kit/src/loaders/core_text.rs + ## Matches in font-kit/src/loaders/core_text.rs - ### mod test › L926-936 - ``` - mod test { - use super::Font; - use crate::properties::{Stretch, Weight}; + ### mod test › L926-936 + ``` + mod test { + use super::Font; + use crate::properties::{Stretch, Weight}; - #[cfg(feature = \"source\")] - use crate::source::SystemSource; + #[cfg(feature = \"source\")] + use crate::source::SystemSource; - static TEST_FONT_POSTSCRIPT_NAME: &'static str = \"ArialMT\"; + static TEST_FONT_POSTSCRIPT_NAME: &'static str = \"ArialMT\"; - #[cfg(feature = \"source\")] - #[test] - ``` + #[cfg(feature = \"source\")] + #[test] + ``` - 55 lines remaining in ancestor node. Read the file to see all. + 55 lines remaining in ancestor node. Read the file to see all. - ### mod test › L947-951 - ``` - } + ### mod test › L947-951 + ``` + } - #[test] - fn test_core_text_to_css_font_weight() { - // Exact matches - ``` + #[test] + fn test_core_text_to_css_font_weight() { + // Exact matches + ``` - ### mod test › L959-963 - ``` - } + ### mod test › L959-963 + ``` + } - #[test] - fn test_core_text_to_css_font_stretch() { - // Exact matches - ``` + #[test] + fn test_core_text_to_css_font_stretch() { + // Exact matches + ``` - ## Matches in font-kit/src/loaders/freetype.rs + ## Matches in font-kit/src/loaders/freetype.rs - ### mod test › L1238-1248 - ``` - mod test { - use crate::loaders::freetype::Font; + ### mod test › L1238-1248 + ``` + mod test { + use crate::loaders::freetype::Font; - static PCF_FONT_PATH: &str = \"resources/tests/times-roman-pcf/timR12.pcf\"; - static PCF_FONT_POSTSCRIPT_NAME: &str = \"Times-Roman\"; + static PCF_FONT_PATH: &str = \"resources/tests/times-roman-pcf/timR12.pcf\"; + static PCF_FONT_POSTSCRIPT_NAME: &str = \"Times-Roman\"; - #[test] - fn get_pcf_postscript_name() { - let font = Font::from_path(PCF_FONT_PATH, 0).unwrap(); - assert_eq!(font.postscript_name().unwrap(), PCF_FONT_POSTSCRIPT_NAME); - } - ``` + #[test] + fn get_pcf_postscript_name() { + let font = Font::from_path(PCF_FONT_PATH, 0).unwrap(); + assert_eq!(font.postscript_name().unwrap(), PCF_FONT_POSTSCRIPT_NAME); + } + ``` - 1 lines remaining in ancestor node. Read the file to see all. + 1 lines remaining in ancestor node. Read the file to see all. - ## Matches in font-kit/src/sources/core_text.rs + ## Matches in font-kit/src/sources/core_text.rs - ### mod test › L265-275 - ``` - mod test { - use crate::properties::{Stretch, Weight}; + ### mod test › L265-275 + ``` + mod test { + use crate::properties::{Stretch, Weight}; - #[test] - fn test_css_to_core_text_font_weight() { - // Exact matches - assert_eq!(super::css_to_core_text_font_weight(Weight(100.0)), -0.7); - assert_eq!(super::css_to_core_text_font_weight(Weight(400.0)), 0.0); - assert_eq!(super::css_to_core_text_font_weight(Weight(700.0)), 0.4); - assert_eq!(super::css_to_core_text_font_weight(Weight(900.0)), 0.8); + #[test] + fn test_css_to_core_text_font_weight() { + // Exact matches + assert_eq!(super::css_to_core_text_font_weight(Weight(100.0)), -0.7); + assert_eq!(super::css_to_core_text_font_weight(Weight(400.0)), 0.0); + assert_eq!(super::css_to_core_text_font_weight(Weight(700.0)), 0.4); + assert_eq!(super::css_to_core_text_font_weight(Weight(900.0)), 0.8); - ``` + ``` - 27 lines remaining in ancestor node. Read the file to see all. + 27 lines remaining in ancestor node. Read the file to see all. - ### mod test › L278-282 - ``` - } + ### mod test › L278-282 + ``` + } - #[test] - fn test_css_to_core_text_font_stretch() { - // Exact matches - ``` - "}, + #[test] + fn test_css_to_core_text_font_stretch() { + // Exact matches + ``` + "}, )], ), message( @@ -648,11 +678,11 @@ fn eval_from_pixels_constructor() { ], Some(input_file_content.into()), EvalAssertion::judge_diff(indoc! {" - - The diff contains a new `from_pixels` constructor - - The diff contains new tests for the `from_pixels` constructor - "}), - ), - ); + - The diff contains a new `from_pixels` constructor + - The diff contains new tests for the `from_pixels` constructor + "}), + )) + }); } #[test] @@ -670,11 +700,9 @@ fn eval_zode() { let input_file_path = "root/zode.py"; let input_content = None; let edit_description = "Create the main Zode CLI script"; - eval( - 50, - 1., - 0.05, - EvalInput::from_conversation( + + eval_utils::eval(50, 1., mismatched_tag_threshold(0.05), move || { + run_eval(EvalInput::from_conversation( vec![ message(User, [text(include_str!("evals/fixtures/zode/prompt.md"))]), message( @@ -733,7 +761,7 @@ fn eval_zode() { ], ), ], - input_content, + input_content.clone(), EvalAssertion::new(async move |sample, _, _cx| { let invalid_starts = [' ', '`', '\n']; let mut message = String::new(); @@ -758,8 +786,8 @@ fn eval_zode() { }) } }), - ), - ); + )) + }); } #[test] @@ -777,19 +805,17 @@ fn eval_add_overwrite_test() { let input_file_path = "root/action_log.rs"; let input_file_content = include_str!("evals/fixtures/add_overwrite_test/before.rs"); let edit_description = "Add a new test for overwriting a file in action_log.rs"; - eval( - 200, - 0.5, // TODO: make this eval better - 0.05, - EvalInput::from_conversation( + + eval_utils::eval(200, 0.5, mismatched_tag_threshold(0.05), move || { + run_eval(EvalInput::from_conversation( vec![ message( User, [text(indoc! {" - Introduce a new test in `action_log.rs` to test overwriting a file. - That is, a file already exists, but we call `buffer_created` as if the file were new. - Take inspiration from all the other tests in the file. - "})], + Introduce a new test in `action_log.rs` to test overwriting a file. + That is, a file already exists, but we call `buffer_created` as if the file were new. + Take inspiration from all the other tests in the file. + "})], ), message( Assistant, @@ -809,81 +835,81 @@ fn eval_add_overwrite_test() { "tool_1", "read_file", indoc! {" - pub struct ActionLog [L13-20] - tracked_buffers [L15] - edited_since_project_diagnostics_check [L17] - project [L19] - impl ActionLog [L22-498] - pub fn new [L24-30] - pub fn project [L32-34] - pub fn checked_project_diagnostics [L37-39] - pub fn has_edited_files_since_project_diagnostics_check [L42-44] - fn track_buffer_internal [L46-101] - fn handle_buffer_event [L103-116] - fn handle_buffer_edited [L118-123] - fn handle_buffer_file_changed [L125-158] - async fn maintain_diff [L160-264] - pub fn buffer_read [L267-269] - pub fn buffer_created [L272-276] - pub fn buffer_edited [L279-287] - pub fn will_delete_buffer [L289-304] - pub fn keep_edits_in_range [L306-364] - pub fn reject_edits_in_ranges [L366-459] - pub fn keep_all_edits [L461-473] - pub fn changed_buffers [L476-482] - pub fn stale_buffers [L485-497] - fn apply_non_conflicting_edits [L500-561] - fn diff_snapshots [L563-585] - fn point_to_row_edit [L587-614] - enum ChangeAuthor [L617-620] - User [L618] - Agent [L619] - enum TrackedBufferStatus [L623-627] - Created [L624] - Modified [L625] - Deleted [L626] - struct TrackedBuffer [L629-641] - buffer [L630] - base_text [L631] - unreviewed_changes [L632] - status [L633] - version [L634] - diff [L635] - snapshot [L636] - diff_update [L637] - _open_lsp_handle [L638] - _maintain_diff [L639] - _subscription [L640] - impl TrackedBuffer [L643-657] - fn has_changes [L644-650] - fn schedule_diff_update [L652-656] - pub struct ChangedBuffer [L659-661] - pub diff [L660] - mod tests [L664-1574] - fn init_logger [L678-682] - fn init_test [L684-691] - async fn test_keep_edits [L694-769] - async fn test_deletions [L772-854] - async fn test_overlapping_user_edits [L857-951] - async fn test_creating_files [L954-1010] - async fn test_deleting_files [L1013-1120] - async fn test_reject_edits [L1123-1255] - async fn test_reject_multiple_edits [L1258-1331] - async fn test_reject_deleted_file [L1334-1388] - async fn test_reject_created_file [L1391-1443] - async fn test_random_diffs [L1446-1535] - fn quiesce [L1510-1534] - struct HunkStatus [L1538-1542] - range [L1539] - diff_status [L1540] - old_text [L1541] - fn unreviewed_hunks [L1544-1573] - - Showing symbols 1-69 (total symbols: 69) - - Using the line numbers in this outline, you can call this tool again while specifying - the start_line and end_line fields to see the implementations of symbols in the outline. - "}, + pub struct ActionLog [L13-20] + tracked_buffers [L15] + edited_since_project_diagnostics_check [L17] + project [L19] + impl ActionLog [L22-498] + pub fn new [L24-30] + pub fn project [L32-34] + pub fn checked_project_diagnostics [L37-39] + pub fn has_edited_files_since_project_diagnostics_check [L42-44] + fn track_buffer_internal [L46-101] + fn handle_buffer_event [L103-116] + fn handle_buffer_edited [L118-123] + fn handle_buffer_file_changed [L125-158] + async fn maintain_diff [L160-264] + pub fn buffer_read [L267-269] + pub fn buffer_created [L272-276] + pub fn buffer_edited [L279-287] + pub fn will_delete_buffer [L289-304] + pub fn keep_edits_in_range [L306-364] + pub fn reject_edits_in_ranges [L366-459] + pub fn keep_all_edits [L461-473] + pub fn changed_buffers [L476-482] + pub fn stale_buffers [L485-497] + fn apply_non_conflicting_edits [L500-561] + fn diff_snapshots [L563-585] + fn point_to_row_edit [L587-614] + enum ChangeAuthor [L617-620] + User [L618] + Agent [L619] + enum TrackedBufferStatus [L623-627] + Created [L624] + Modified [L625] + Deleted [L626] + struct TrackedBuffer [L629-641] + buffer [L630] + base_text [L631] + unreviewed_changes [L632] + status [L633] + version [L634] + diff [L635] + snapshot [L636] + diff_update [L637] + _open_lsp_handle [L638] + _maintain_diff [L639] + _subscription [L640] + impl TrackedBuffer [L643-657] + fn has_changes [L644-650] + fn schedule_diff_update [L652-656] + pub struct ChangedBuffer [L659-661] + pub diff [L660] + mod tests [L664-1574] + fn init_logger [L678-682] + fn init_test [L684-691] + async fn test_keep_edits [L694-769] + async fn test_deletions [L772-854] + async fn test_overlapping_user_edits [L857-951] + async fn test_creating_files [L954-1010] + async fn test_deleting_files [L1013-1120] + async fn test_reject_edits [L1123-1255] + async fn test_reject_multiple_edits [L1258-1331] + async fn test_reject_deleted_file [L1334-1388] + async fn test_reject_created_file [L1391-1443] + async fn test_random_diffs [L1446-1535] + fn quiesce [L1510-1534] + struct HunkStatus [L1538-1542] + range [L1539] + diff_status [L1540] + old_text [L1541] + fn unreviewed_hunks [L1544-1573] + + Showing symbols 1-69 (total symbols: 69) + + Using the line numbers in this outline, you can call this tool again while specifying + the start_line and end_line fields to see the implementations of symbols in the outline. + "}, )], ), message( @@ -963,17 +989,17 @@ fn eval_add_overwrite_test() { Assistant, [ text(indoc! {" - Based on my understanding of the existing tests and code, I'll now create a new test for overwriting a file. In this test, we'll: + Based on my understanding of the existing tests and code, I'll now create a new test for overwriting a file. In this test, we'll: - 1. Create a file - 2. Open a buffer for it - 3. Track it in the action log - 4. Modify the buffer - 5. Call `buffer_created` again as if the file were new - 6. Check that the changes are properly tracked + 1. Create a file + 2. Open a buffer for it + 3. Track it in the action log + 4. Modify the buffer + 5. Call `buffer_created` again as if the file were new + 6. Check that the changes are properly tracked - Let's write the test: - "}), + Let's write the test: + "}), tool_use( "tool_5", "edit_file", @@ -990,8 +1016,8 @@ fn eval_add_overwrite_test() { EvalAssertion::judge_diff( "A new test for overwritten files was created, without changing any previous test", ), - ), - ); + )) + }); } #[test] @@ -1016,20 +1042,18 @@ fn eval_create_empty_file() { let input_file_content = None; let expected_output_content = String::new(); - eval( - 100, - 0.99, - 0.05, - EvalInput::from_conversation( + + eval_utils::eval(100, 0.99, mismatched_tag_threshold(0.05), move || { + run_eval(EvalInput::from_conversation( vec![ message(User, [text("Create a second empty todo file ")]), message( Assistant, [ text(formatdoc! {" - I'll help you create a second empty todo file. - First, let me examine the project structure to see if there's already a todo file, which will help me determine the appropriate name and location for the second one. - "}), + I'll help you create a second empty todo file. + First, let me examine the project structure to see if there's already a todo file, which will help me determine the appropriate name and location for the second one. + "}), tool_use( "toolu_01GAF8TtsgpjKxCr8fgQLDgR", "list_directory", @@ -1051,8 +1075,8 @@ fn eval_create_empty_file() { Assistant, [ text(formatdoc! {" - I can see there's already a `TODO` file in the `root` directory. Let me create a second empty todo file called `TODO3` in the same directory: - "}), + I can see there's already a `TODO` file in the `root` directory. Let me create a second empty todo file called `TODO3` in the same directory: + "}), tool_use( "toolu_01Tb3iQ9griqSYMmVuykQPWU", "edit_file", @@ -1065,12 +1089,12 @@ fn eval_create_empty_file() { ], ), ], - input_file_content, + input_file_content.clone(), // Bad behavior is to write something like // "I'll create an empty TODO3 file as requested." - EvalAssertion::assert_eq(expected_output_content), - ), - ); + EvalAssertion::assert_eq(expected_output_content.clone()), + )) + }); } fn message( @@ -1312,115 +1336,44 @@ impl EvalAssertion { } } -fn eval( - iterations: usize, - expected_pass_ratio: f32, - mismatched_tag_threshold: f32, - mut eval: EvalInput, -) { - let mut evaluated_count = 0; - let mut failed_count = 0; - report_progress(evaluated_count, failed_count, iterations); - - let (tx, rx) = mpsc::channel(); - - // Cache the last message in the conversation, and run one instance of the eval so that - // all the next ones are cached. - eval.conversation.last_mut().unwrap().cache = true; - run_eval(eval.clone(), tx.clone()); - - let executor = gpui::background_executor(); - let semaphore = Arc::new(smol::lock::Semaphore::new(32)); - for _ in 1..iterations { - let eval = eval.clone(); - let tx = tx.clone(); - let semaphore = semaphore.clone(); - executor - .spawn(async move { - let _guard = semaphore.acquire().await; - run_eval(eval, tx) - }) - .detach(); - } - drop(tx); - - let mut failed_evals = HashMap::default(); - let mut errored_evals = HashMap::default(); - let mut eval_outputs = Vec::new(); - let mut cumulative_parser_metrics = EditParserMetrics::default(); - while let Ok(output) = rx.recv() { - match output { - Ok(output) => { - cumulative_parser_metrics += output.sample.edit_output.parser_metrics.clone(); - eval_outputs.push(output.clone()); - if output.assertion.score < 80 { - failed_count += 1; - failed_evals - .entry(output.sample.text_after.clone()) - .or_insert(Vec::new()) - .push(output); - } - } - Err(error) => { - failed_count += 1; - *errored_evals.entry(format!("{:?}", error)).or_insert(0) += 1; - } - } - - evaluated_count += 1; - report_progress(evaluated_count, failed_count, iterations); - } - - let actual_pass_ratio = (iterations - failed_count) as f32 / iterations as f32; - println!("Actual pass ratio: {}\n", actual_pass_ratio); - if actual_pass_ratio < expected_pass_ratio { - let mut errored_evals = errored_evals.into_iter().collect::>(); - errored_evals.sort_by_key(|(_, count)| Reverse(*count)); - for (error, count) in errored_evals { - println!("Eval errored {} times. Error: {}", count, error); - } - - let mut failed_evals = failed_evals.into_iter().collect::>(); - failed_evals.sort_by_key(|(_, evals)| Reverse(evals.len())); - for (_buffer_output, failed_evals) in failed_evals { - let eval_output = failed_evals.first().unwrap(); - println!("Eval failed {} times", failed_evals.len()); - println!("{}", eval_output); - } - - panic!( - "Actual pass ratio: {}\nExpected pass ratio: {}", - actual_pass_ratio, expected_pass_ratio - ); - } - - let mismatched_tag_ratio = - cumulative_parser_metrics.mismatched_tags as f32 / cumulative_parser_metrics.tags as f32; - if mismatched_tag_ratio > mismatched_tag_threshold { - for eval_output in eval_outputs { - println!("{}", eval_output); - } - panic!("Too many mismatched tags: {:?}", cumulative_parser_metrics); - } -} - -fn run_eval(eval: EvalInput, tx: mpsc::Sender>) { +fn run_eval(eval: EvalInput) -> eval_utils::EvalOutput { let dispatcher = gpui::TestDispatcher::new(StdRng::from_os_rng()); let mut cx = TestAppContext::build(dispatcher, None); - let output = cx.executor().block_test(async { + let result = cx.executor().block_test(async { let test = EditAgentTest::new(&mut cx).await; test.eval(eval, &mut cx).await }); - tx.send(output).unwrap(); + match result { + Ok(output) => eval_utils::EvalOutput { + data: output.to_string(), + outcome: if output.assertion.score < 80 { + eval_utils::OutcomeKind::Failed + } else { + eval_utils::OutcomeKind::Passed + }, + metadata: EditEvalMetadata { + tags: output.sample.edit_output.parser_metrics.tags, + mismatched_tags: output.sample.edit_output.parser_metrics.mismatched_tags, + }, + }, + Err(e) => eval_utils::EvalOutput { + data: format!("{e:?}"), + outcome: eval_utils::OutcomeKind::Error, + metadata: EditEvalMetadata { + tags: 0, + mismatched_tags: 0, + }, + }, + } } #[derive(Clone)] -struct EvalOutput { +struct EditEvalOutput { sample: EvalSample, assertion: EvalAssertionOutcome, } -impl Display for EvalOutput { +impl Display for EditEvalOutput { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { writeln!(f, "Score: {:?}", self.assertion.score)?; if let Some(message) = self.assertion.message.as_ref() { @@ -1439,22 +1392,6 @@ impl Display for EvalOutput { } } -fn report_progress(evaluated_count: usize, failed_count: usize, iterations: usize) { - let passed_count = evaluated_count - failed_count; - let passed_ratio = if evaluated_count == 0 { - 0.0 - } else { - passed_count as f64 / evaluated_count as f64 - }; - print!( - "\r\x1b[KEvaluated {}/{} ({:.2}% passed)", - evaluated_count, - iterations, - passed_ratio * 100.0 - ); - std::io::stdout().flush().unwrap(); -} - struct EditAgentTest { agent: EditAgent, project: Entity, @@ -1550,7 +1487,10 @@ impl EditAgentTest { }) } - async fn eval(&self, eval: EvalInput, cx: &mut TestAppContext) -> Result { + async fn eval(&self, mut eval: EvalInput, cx: &mut TestAppContext) -> Result { + // Make sure the last message in the conversation is cached. + eval.conversation.last_mut().unwrap().cache = true; + let path = self .project .read_with(cx, |project, cx| { @@ -1656,7 +1596,7 @@ impl EditAgentTest { .run(&sample, self.judge_model.clone(), cx) .await?; - Ok(EvalOutput { assertion, sample }) + Ok(EditEvalOutput { assertion, sample }) } } diff --git a/crates/agent_ui/Cargo.toml b/crates/agent_ui/Cargo.toml index 0f52c07078f447c9d8a95312ccd96561516907a1..048ffab9b72bdecce3754320bf34f1702f021554 100644 --- a/crates/agent_ui/Cargo.toml +++ b/crates/agent_ui/Cargo.toml @@ -13,7 +13,8 @@ path = "src/agent_ui.rs" doctest = false [features] -test-support = ["gpui/test-support", "language/test-support"] +test-support = ["gpui/test-support", "language/test-support", "reqwest_client"] +unit-eval = [] [dependencies] acp_thread.workspace = true @@ -47,6 +48,7 @@ fs.workspace = true futures.workspace = true fuzzy.workspace = true gpui.workspace = true +gpui_tokio.workspace = true html_to_markdown.workspace = true http_client.workspace = true indoc.workspace = true @@ -98,14 +100,17 @@ workspace.workspace = true zed_actions.workspace = true image.workspace = true async-fs.workspace = true +reqwest_client = { workspace = true, optional = true } [dev-dependencies] acp_thread = { workspace = true, features = ["test-support"] } agent = { workspace = true, features = ["test-support"] } assistant_text_thread = { workspace = true, features = ["test-support"] } buffer_diff = { workspace = true, features = ["test-support"] } +clock.workspace = true db = { workspace = true, features = ["test-support"] } editor = { workspace = true, features = ["test-support"] } +eval_utils.workspace = true gpui = { workspace = true, "features" = ["test-support"] } indoc.workspace = true language = { workspace = true, "features" = ["test-support"] } @@ -115,5 +120,6 @@ pretty_assertions.workspace = true project = { workspace = true, features = ["test-support"] } semver.workspace = true rand.workspace = true +reqwest_client.workspace = true tree-sitter-md.workspace = true unindent.workspace = true diff --git a/crates/agent_ui/src/agent_panel.rs b/crates/agent_ui/src/agent_panel.rs index 9dd77774ff4e6f00bdfd26d024e9ee4b389b7f7e..18e8f1e731defa82e865dd45e66389634992037c 100644 --- a/crates/agent_ui/src/agent_panel.rs +++ b/crates/agent_ui/src/agent_panel.rs @@ -2685,16 +2685,17 @@ impl rules_library::InlineAssistDelegate for PromptLibraryInlineAssist { return; }; let project = workspace.read(cx).project().downgrade(); + let thread_store = panel.read(cx).thread_store().clone(); assistant.assist( prompt_editor, self.workspace.clone(), project, - panel.read(cx).thread_store().clone(), + thread_store, None, initial_prompt, window, cx, - ) + ); }) } diff --git a/crates/agent_ui/src/agent_ui.rs b/crates/agent_ui/src/agent_ui.rs index 5f5682b7dcc90d2b779744ba353380987a5907a1..f7b07b7bd393b8d3efffc3757eaf6025d5c651cd 100644 --- a/crates/agent_ui/src/agent_ui.rs +++ b/crates/agent_ui/src/agent_ui.rs @@ -7,6 +7,8 @@ mod buffer_codegen; mod completion_provider; mod context; mod context_server_configuration; +#[cfg(test)] +mod evals; mod inline_assistant; mod inline_prompt_editor; mod language_model_selector; diff --git a/crates/agent_ui/src/buffer_codegen.rs b/crates/agent_ui/src/buffer_codegen.rs index 1ac3ec1aec38c8d44d7557e1cf1e3ff09832c9d9..972ead664464876e57d7830b18db3f2b0c49629c 100644 --- a/crates/agent_ui/src/buffer_codegen.rs +++ b/crates/agent_ui/src/buffer_codegen.rs @@ -719,6 +719,7 @@ impl CodegenAlternative { output_tokens = usage.output_tokens, ) } + cx.emit(CodegenEvent::Finished); cx.notify(); }) diff --git a/crates/agent_ui/src/evals.rs b/crates/agent_ui/src/evals.rs new file mode 100644 index 0000000000000000000000000000000000000000..e82d21bd1fdb02a666c61bdf4754f27e79f92fda --- /dev/null +++ b/crates/agent_ui/src/evals.rs @@ -0,0 +1,89 @@ +use std::str::FromStr; + +use crate::inline_assistant::test::run_inline_assistant_test; + +use eval_utils::{EvalOutput, NoProcessor}; +use gpui::TestAppContext; +use language_model::{LanguageModelRegistry, SelectedModel}; +use rand::{SeedableRng as _, rngs::StdRng}; + +#[test] +#[cfg_attr(not(feature = "unit-eval"), ignore)] +fn eval_single_cursor_edit() { + eval_utils::eval(20, 1.0, NoProcessor, move || { + run_eval( + &EvalInput { + prompt: "Rename this variable to buffer_text".to_string(), + buffer: indoc::indoc! {" + struct EvalExampleStruct { + text: Strˇing, + prompt: String, + } + "} + .to_string(), + }, + &|_, output| { + let expected = indoc::indoc! {" + struct EvalExampleStruct { + buffer_text: String, + prompt: String, + } + "}; + if output == expected { + EvalOutput { + outcome: eval_utils::OutcomeKind::Passed, + data: "Passed!".to_string(), + metadata: (), + } + } else { + EvalOutput { + outcome: eval_utils::OutcomeKind::Failed, + data: format!("Failed to rename variable, output: {}", output), + metadata: (), + } + } + }, + ) + }); +} + +struct EvalInput { + buffer: String, + prompt: String, +} + +fn run_eval( + input: &EvalInput, + judge: &dyn Fn(&EvalInput, &str) -> eval_utils::EvalOutput<()>, +) -> eval_utils::EvalOutput<()> { + let dispatcher = gpui::TestDispatcher::new(StdRng::from_os_rng()); + let mut cx = TestAppContext::build(dispatcher, None); + cx.skip_drawing(); + + let buffer_text = run_inline_assistant_test( + input.buffer.clone(), + input.prompt.clone(), + |cx| { + // Reconfigure to use a real model instead of the fake one + let model_name = std::env::var("ZED_AGENT_MODEL") + .unwrap_or("anthropic/claude-sonnet-4-latest".into()); + + let selected_model = SelectedModel::from_str(&model_name) + .expect("Invalid model format. Use 'provider/model-id'"); + + log::info!("Selected model: {selected_model:?}"); + + cx.update(|_, cx| { + LanguageModelRegistry::global(cx).update(cx, |registry, cx| { + registry.select_inline_assistant_model(Some(&selected_model), cx); + }); + }); + }, + |_cx| { + log::info!("Waiting for actual response from the LLM..."); + }, + &mut cx, + ); + + judge(input, &buffer_text) +} diff --git a/crates/agent_ui/src/inline_assistant.rs b/crates/agent_ui/src/inline_assistant.rs index 3f27d0985991f19148cc852c44bfa60c57eaf750..cbc5891036fdf03ee04cca6b77820748faed2d0a 100644 --- a/crates/agent_ui/src/inline_assistant.rs +++ b/crates/agent_ui/src/inline_assistant.rs @@ -32,7 +32,7 @@ use editor::{ }, }; use fs::Fs; -use futures::FutureExt; +use futures::{FutureExt, channel::mpsc}; use gpui::{ App, Context, Entity, Focusable, Global, HighlightStyle, Subscription, Task, UpdateGlobal, WeakEntity, Window, point, @@ -102,6 +102,7 @@ pub struct InlineAssistant { prompt_builder: Arc, telemetry: Arc, fs: Arc, + _inline_assistant_completions: Option>>, } impl Global for InlineAssistant {} @@ -123,9 +124,18 @@ impl InlineAssistant { prompt_builder, telemetry, fs, + _inline_assistant_completions: None, } } + #[cfg(any(test, feature = "test-support"))] + pub fn set_completion_receiver( + &mut self, + sender: mpsc::UnboundedSender>, + ) { + self._inline_assistant_completions = Some(sender); + } + pub fn register_workspace( &mut self, workspace: &Entity, @@ -287,7 +297,7 @@ impl InlineAssistant { action.prompt.clone(), window, cx, - ) + ); }) } InlineAssistTarget::Terminal(active_terminal) => { @@ -301,8 +311,8 @@ impl InlineAssistant { action.prompt.clone(), window, cx, - ) - }) + ); + }); } }; @@ -598,13 +608,13 @@ impl InlineAssistant { initial_prompt: Option, window: &mut Window, cx: &mut App, - ) { + ) -> Option { let snapshot = editor.update(cx, |editor, cx| editor.snapshot(window, cx)); let Some((codegen_ranges, newest_selection)) = self.codegen_ranges(editor, &snapshot, window, cx) else { - return; + return None; }; let assist_to_focus = self.batch_assist( @@ -624,6 +634,8 @@ impl InlineAssistant { if let Some(assist_id) = assist_to_focus { self.focus_assist(assist_id, window, cx); } + + assist_to_focus } pub fn suggest_assist( @@ -1740,6 +1752,16 @@ impl InlineAssist { && assist.decorations.is_none() && let Some(workspace) = assist.workspace.upgrade() { + #[cfg(any(test, feature = "test-support"))] + if let Some(sender) = &mut this._inline_assistant_completions { + sender + .unbounded_send(Err(anyhow::anyhow!( + "Inline assistant error: {}", + error + ))) + .ok(); + } + let error = format!("Inline assistant error: {}", error); workspace.update(cx, |workspace, cx| { struct InlineAssistantError; @@ -1750,6 +1772,11 @@ impl InlineAssist { workspace.show_toast(Toast::new(id, error), cx); }) + } else { + #[cfg(any(test, feature = "test-support"))] + if let Some(sender) = &mut this._inline_assistant_completions { + sender.unbounded_send(Ok(assist_id)).ok(); + } } if assist.decorations.is_none() { @@ -1943,3 +1970,160 @@ fn merge_ranges(ranges: &mut Vec>, buffer: &MultiBufferSnapshot) { } } } + +#[cfg(any(test, feature = "test-support"))] +pub mod test { + use std::sync::Arc; + + use agent::HistoryStore; + use assistant_text_thread::TextThreadStore; + use client::{Client, UserStore}; + use editor::{Editor, MultiBuffer, MultiBufferOffset}; + use fs::FakeFs; + use futures::channel::mpsc; + use gpui::{AppContext, TestAppContext, UpdateGlobal as _}; + use language::Buffer; + use language_model::LanguageModelRegistry; + use project::Project; + use prompt_store::PromptBuilder; + use smol::stream::StreamExt as _; + use util::test::marked_text_ranges; + use workspace::Workspace; + + use crate::InlineAssistant; + + pub fn run_inline_assistant_test( + base_buffer: String, + prompt: String, + setup: SetupF, + test: TestF, + cx: &mut TestAppContext, + ) -> String + where + SetupF: FnOnce(&mut gpui::VisualTestContext), + TestF: FnOnce(&mut gpui::VisualTestContext), + { + let fs = FakeFs::new(cx.executor()); + let app_state = cx.update(|cx| workspace::AppState::test(cx)); + let prompt_builder = Arc::new(PromptBuilder::new(None).unwrap()); + let http = Arc::new(reqwest_client::ReqwestClient::user_agent("agent tests").unwrap()); + let client = cx.update(|cx| { + cx.set_http_client(http); + Client::production(cx) + }); + let mut inline_assistant = + InlineAssistant::new(fs.clone(), prompt_builder, client.telemetry().clone()); + + let (tx, mut completion_rx) = mpsc::unbounded(); + inline_assistant.set_completion_receiver(tx); + + // Initialize settings and client + cx.update(|cx| { + gpui_tokio::init(cx); + settings::init(cx); + client::init(&client, cx); + workspace::init(app_state.clone(), cx); + let user_store = cx.new(|cx| UserStore::new(client.clone(), cx)); + language_model::init(client.clone(), cx); + language_models::init(user_store, client.clone(), cx); + + cx.set_global(inline_assistant); + }); + + let project = cx + .executor() + .block_test(async { Project::test(fs.clone(), [], cx).await }); + + // Create workspace with window + let (workspace, cx) = cx.add_window_view(|window, cx| { + window.activate_window(); + Workspace::new(None, project.clone(), app_state.clone(), window, cx) + }); + + setup(cx); + + let (_editor, buffer) = cx.update(|window, cx| { + let buffer = cx.new(|cx| Buffer::local("", cx)); + let multibuffer = cx.new(|cx| MultiBuffer::singleton(buffer.clone(), cx)); + let editor = cx.new(|cx| Editor::for_multibuffer(multibuffer, None, window, cx)); + editor.update(cx, |editor, cx| { + let (unmarked_text, selection_ranges) = marked_text_ranges(&base_buffer, true); + editor.set_text(unmarked_text, window, cx); + editor.change_selections(Default::default(), window, cx, |s| { + s.select_ranges( + selection_ranges.into_iter().map(|range| { + MultiBufferOffset(range.start)..MultiBufferOffset(range.end) + }), + ) + }) + }); + + let text_thread_store = cx.new(|cx| TextThreadStore::fake(project.clone(), cx)); + let history_store = cx.new(|cx| HistoryStore::new(text_thread_store, cx)); + + // Add editor to workspace + workspace.update(cx, |workspace, cx| { + workspace.add_item_to_active_pane(Box::new(editor.clone()), None, true, window, cx); + }); + + // Call assist method + InlineAssistant::update_global(cx, |inline_assistant, cx| { + let assist_id = inline_assistant + .assist( + &editor, + workspace.downgrade(), + project.downgrade(), + history_store, // thread_store + None, // prompt_store + Some(prompt), + window, + cx, + ) + .unwrap(); + + inline_assistant.start_assist(assist_id, window, cx); + }); + + (editor, buffer) + }); + + cx.run_until_parked(); + + test(cx); + + cx.executor() + .block_test(async { completion_rx.next().await }); + + buffer.read_with(cx, |buffer, _| buffer.text()) + } + + #[allow(unused)] + pub fn test_inline_assistant( + base_buffer: &'static str, + llm_output: &'static str, + cx: &mut TestAppContext, + ) -> String { + run_inline_assistant_test( + base_buffer.to_string(), + "Prompt doesn't matter because we're using a fake model".to_string(), + |cx| { + cx.update(|_, cx| LanguageModelRegistry::test(cx)); + }, + |cx| { + let fake_model = cx.update(|_, cx| { + LanguageModelRegistry::global(cx) + .update(cx, |registry, _| registry.fake_model()) + }); + let fake = fake_model.as_fake(); + + // let fake = fake_model; + fake.send_last_completion_stream_text_chunk(llm_output.to_string()); + fake.end_last_completion_stream(); + + // Run again to process the model's response + cx.run_until_parked(); + }, + cx, + ) + } +} diff --git a/crates/eval_utils/Cargo.toml b/crates/eval_utils/Cargo.toml new file mode 100644 index 0000000000000000000000000000000000000000..a512035f5d1754f0f6f942faa27d063e169a22ef --- /dev/null +++ b/crates/eval_utils/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "eval_utils" +version = "0.1.0" +edition.workspace = true +publish.workspace = true +license = "GPL-3.0-or-later" + +[lints] +workspace = true + +[lib] +path = "src/eval_utils.rs" +doctest = false + +[dependencies] +gpui.workspace = true +serde.workspace = true +smol.workspace = true diff --git a/crates/eval_utils/LICENSE-GPL b/crates/eval_utils/LICENSE-GPL new file mode 120000 index 0000000000000000000000000000000000000000..e0f9dbd5d63fef1630c297edc4ceba4790be6f02 --- /dev/null +++ b/crates/eval_utils/LICENSE-GPL @@ -0,0 +1 @@ +LICENSE-GPL \ No newline at end of file diff --git a/crates/eval_utils/README.md b/crates/eval_utils/README.md new file mode 100644 index 0000000000000000000000000000000000000000..617077a81524ff918e8b9b93aa970d636504479c --- /dev/null +++ b/crates/eval_utils/README.md @@ -0,0 +1,3 @@ +# eval_utils + +Utilities for evals of agents. diff --git a/crates/eval_utils/src/eval_utils.rs b/crates/eval_utils/src/eval_utils.rs new file mode 100644 index 0000000000000000000000000000000000000000..880b1a97e414bbc3219bdf8f7163dbf9b6c9c82b --- /dev/null +++ b/crates/eval_utils/src/eval_utils.rs @@ -0,0 +1,128 @@ +//! Utilities for evaluation and benchmarking. + +use std::{ + collections::HashMap, + sync::{Arc, mpsc}, +}; + +fn report_progress(evaluated_count: usize, failed_count: usize, iterations: usize) { + let passed_count = evaluated_count - failed_count; + let passed_ratio = if evaluated_count == 0 { + 0.0 + } else { + passed_count as f64 / evaluated_count as f64 + }; + println!( + "\r\x1b[KEvaluated {}/{} ({:.2}% passed)", + evaluated_count, + iterations, + passed_ratio * 100.0 + ) +} + +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum OutcomeKind { + Passed, + Failed, + Error, +} + +pub trait EvalOutputProcessor { + type Metadata: 'static + Send; + fn process(&mut self, output: &EvalOutput); + fn assert(&mut self); +} + +#[derive(Clone, Debug)] +pub struct EvalOutput { + pub outcome: OutcomeKind, + pub data: String, + pub metadata: M, +} + +pub struct NoProcessor; +impl EvalOutputProcessor for NoProcessor { + type Metadata = (); + + fn process(&mut self, _output: &EvalOutput) {} + + fn assert(&mut self) {} +} + +pub fn eval

( + iterations: usize, + expected_pass_ratio: f32, + mut processor: P, + evalf: impl Fn() -> EvalOutput + Send + Sync + 'static, +) where + P: EvalOutputProcessor, +{ + let mut evaluated_count = 0; + let mut failed_count = 0; + let evalf = Arc::new(evalf); + report_progress(evaluated_count, failed_count, iterations); + + let (tx, rx) = mpsc::channel(); + + let executor = gpui::background_executor(); + let semaphore = Arc::new(smol::lock::Semaphore::new(32)); + let evalf = Arc::new(evalf); + // Warm the cache once + let first_output = evalf(); + tx.send(first_output).ok(); + + for _ in 1..iterations { + let tx = tx.clone(); + let semaphore = semaphore.clone(); + let evalf = evalf.clone(); + executor + .spawn(async move { + let _guard = semaphore.acquire().await; + let output = evalf(); + tx.send(output).ok(); + }) + .detach(); + } + drop(tx); + + let mut failed_evals = Vec::new(); + let mut errored_evals = HashMap::new(); + while let Ok(output) = rx.recv() { + processor.process(&output); + + match output.outcome { + OutcomeKind::Passed => {} + OutcomeKind::Failed => { + failed_count += 1; + failed_evals.push(output); + } + OutcomeKind::Error => { + failed_count += 1; + *errored_evals.entry(output.data).or_insert(0) += 1; + } + } + + evaluated_count += 1; + report_progress(evaluated_count, failed_count, iterations); + } + + let actual_pass_ratio = (iterations - failed_count) as f32 / iterations as f32; + println!("Actual pass ratio: {}\n", actual_pass_ratio); + if actual_pass_ratio < expected_pass_ratio { + for (error, count) in errored_evals { + println!("Eval errored {} times. Error: {}", count, error); + } + + for failed in failed_evals { + println!("Eval failed"); + println!("{}", failed.data); + } + + panic!( + "Actual pass ratio: {}\nExpected pass ratio: {}", + actual_pass_ratio, expected_pass_ratio + ); + } + + processor.assert(); +} diff --git a/crates/gpui/src/app.rs b/crates/gpui/src/app.rs index c042d85a1239dc6723b6501b27690a9f593a021b..2f4c7611dcf9d24302b3dda1d05c4c2b8711a68d 100644 --- a/crates/gpui/src/app.rs +++ b/crates/gpui/src/app.rs @@ -551,12 +551,39 @@ impl SystemWindowTabController { } } +pub(crate) enum GpuiMode { + #[cfg(any(test, feature = "test-support"))] + Test { + skip_drawing: bool, + }, + Production, +} + +impl GpuiMode { + #[cfg(any(test, feature = "test-support"))] + pub fn test() -> Self { + GpuiMode::Test { + skip_drawing: false, + } + } + + #[inline] + pub(crate) fn skip_drawing(&self) -> bool { + match self { + #[cfg(any(test, feature = "test-support"))] + GpuiMode::Test { skip_drawing } => *skip_drawing, + GpuiMode::Production => false, + } + } +} + /// Contains the state of the full application, and passed as a reference to a variety of callbacks. /// Other [Context] derefs to this type. /// You need a reference to an `App` to access the state of a [Entity]. pub struct App { pub(crate) this: Weak, pub(crate) platform: Rc, + pub(crate) mode: GpuiMode, text_system: Arc, flushing_effects: bool, pending_updates: usize, @@ -635,6 +662,7 @@ impl App { this: this.clone(), platform: platform.clone(), text_system, + mode: GpuiMode::Production, actions: Rc::new(ActionRegistry::default()), flushing_effects: false, pending_updates: 0, diff --git a/crates/gpui/src/app/test_context.rs b/crates/gpui/src/app/test_context.rs index 4a7b73c359ed3dd55b136b22e9487dee1735e42e..5be2e394e8edfd26a25c70c79c321a7fb8fdc8ba 100644 --- a/crates/gpui/src/app/test_context.rs +++ b/crates/gpui/src/app/test_context.rs @@ -5,7 +5,7 @@ use crate::{ ModifiersChangedEvent, MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent, Pixels, Platform, Point, Render, Result, Size, Task, TestDispatcher, TestPlatform, TestScreenCaptureSource, TestWindow, TextSystem, VisualContext, Window, WindowBounds, - WindowHandle, WindowOptions, + WindowHandle, WindowOptions, app::GpuiMode, }; use anyhow::{anyhow, bail}; use futures::{Stream, StreamExt, channel::oneshot}; @@ -132,8 +132,11 @@ impl TestAppContext { let http_client = http_client::FakeHttpClient::with_404_response(); let text_system = Arc::new(TextSystem::new(platform.text_system())); + let mut app = App::new_app(platform.clone(), asset_source, http_client); + app.borrow_mut().mode = GpuiMode::test(); + Self { - app: App::new_app(platform.clone(), asset_source, http_client), + app, background_executor, foreground_executor, dispatcher, @@ -144,6 +147,11 @@ impl TestAppContext { } } + /// Skip all drawing operations for the duration of this test. + pub fn skip_drawing(&mut self) { + self.app.borrow_mut().mode = GpuiMode::Test { skip_drawing: true }; + } + /// Create a single TestAppContext, for non-multi-client tests pub fn single() -> Self { let dispatcher = TestDispatcher::new(StdRng::seed_from_u64(0)); diff --git a/crates/gpui/src/window.rs b/crates/gpui/src/window.rs index dabf7cf2b42cf57becb996e1f9360aaba0b6eead..2d525adb8f82a96c24ee3f524030782a7de3577c 100644 --- a/crates/gpui/src/window.rs +++ b/crates/gpui/src/window.rs @@ -2006,7 +2006,9 @@ impl Window { if let Some(input_handler) = self.platform_window.take_input_handler() { self.rendered_frame.input_handlers.push(Some(input_handler)); } - self.draw_roots(cx); + if !cx.mode.skip_drawing() { + self.draw_roots(cx); + } self.dirty_views.clear(); self.next_frame.window_active = self.active.get(); diff --git a/crates/http_client/src/http_client.rs b/crates/http_client/src/http_client.rs index 98c67f4e27a8e8b20489cc3c4ad4a1207e8b848f..f357e01da062398d18134df6625d30b8129bf875 100644 --- a/crates/http_client/src/http_client.rs +++ b/crates/http_client/src/http_client.rs @@ -408,6 +408,7 @@ impl FakeHttpClient { } pub fn with_404_response() -> Arc { + log::warn!("Using fake HTTP client with 404 response"); Self::create(|_| async move { Ok(Response::builder() .status(404) @@ -417,6 +418,7 @@ impl FakeHttpClient { } pub fn with_200_response() -> Arc { + log::warn!("Using fake HTTP client with 200 response"); Self::create(|_| async move { Ok(Response::builder() .status(200) diff --git a/crates/language_model/src/registry.rs b/crates/language_model/src/registry.rs index 6ed8bf07c4e976c88fecebd929843335333b1fa6..27b8309810962981d3c0ec78e6e67dfdfba122bf 100644 --- a/crates/language_model/src/registry.rs +++ b/crates/language_model/src/registry.rs @@ -135,6 +135,11 @@ impl LanguageModelRegistry { fake_provider } + #[cfg(any(test, feature = "test-support"))] + pub fn fake_model(&self) -> Arc { + self.default_model.as_ref().unwrap().model.clone() + } + pub fn register_provider( &mut self, provider: Arc, From 87976e91cf4b6e049563146085b0b0d9c4a017fb Mon Sep 17 00:00:00 2001 From: Andrew Farkas <6060305+HactarCE@users.noreply.github.com> Date: Wed, 3 Dec 2025 16:56:39 -0500 Subject: [PATCH 042/621] Add more preview tab settings and fix janky behavior (#43921) Closes #41495 Known issues: - File path links always open as non-preview tabs. Fixing this is not technically too difficult but requires more invasive changes and so should be done in a future PR. Release Notes: - Fixed strange behavior when reopening closed preview tabs - Overhauled preview tabs settings: - Added setting `preview_tabs.enable_preview_from_project_panel` (default `true`) - Kept setting `preview_tabs.enable_preview_from_file_finder` (default `false`) - Added setting `preview_tabs.enable_preview_from_multibuffer` (default `true`) - Added setting `preview_tabs.enable_preview_multibuffer_from_code_navigation` (default `false`) - Added setting `preview_tabs.enable_preview_file_from_code_navigation` (default `true`) - Renamed setting `preview_tabs.enable_preview_from_code_navigation` to `preview_tabs.enable_keep_preview_on_code_navigation` (default `false`) --------- Co-authored-by: Smit Barmase Co-authored-by: Cole Miller --- assets/settings/default.json | 15 ++- crates/editor/src/editor.rs | 87 +++++++------ crates/migrator/src/migrations.rs | 6 + .../src/migrations/m_2025_12_01/settings.rs | 55 ++++++++ crates/migrator/src/migrator.rs | 119 +++++++++++++----- crates/project_panel/src/project_panel.rs | 5 +- crates/project_symbols/src/project_symbols.rs | 5 +- .../src/settings_content/workspace.rs | 21 +++- crates/settings/src/vscode_import.rs | 6 +- crates/settings_ui/src/page_data.rs | 102 +++++++++++++-- crates/workspace/src/item.rs | 20 ++- crates/workspace/src/pane.rs | 89 +++++++------ crates/workspace/src/workspace.rs | 31 +++-- docs/src/configuring-zed.md | 52 +++++++- 14 files changed, 478 insertions(+), 135 deletions(-) create mode 100644 crates/migrator/src/migrations/m_2025_12_01/settings.rs diff --git a/assets/settings/default.json b/assets/settings/default.json index f53019744e72daa253e3ddfa96f48a0541186b61..f687778d7bd7fc0f6d66404199c34fac8d77e7a8 100644 --- a/assets/settings/default.json +++ b/assets/settings/default.json @@ -1100,13 +1100,22 @@ "preview_tabs": { // Whether preview tabs should be enabled. // Preview tabs allow you to open files in preview mode, where they close automatically - // when you switch to another file unless you explicitly pin them. + // when you open another preview tab. // This is useful for quickly viewing files without cluttering your workspace. "enabled": true, + // Whether to open tabs in preview mode when opened from the project panel with a single click. + "enable_preview_from_project_panel": true, // Whether to open tabs in preview mode when selected from the file finder. "enable_preview_from_file_finder": false, - // Whether a preview tab gets replaced when code navigation is used to navigate away from the tab. - "enable_preview_from_code_navigation": false + // Whether to open tabs in preview mode when opened from a multibuffer. + "enable_preview_from_multibuffer": true, + // Whether to open tabs in preview mode when code navigation is used to open a multibuffer. + "enable_preview_multibuffer_from_code_navigation": false, + // Whether to open tabs in preview mode when code navigation is used to open a single file. + "enable_preview_file_from_code_navigation": true, + // Whether to keep tabs in preview mode when code navigation is used to navigate away from them. + // If `enable_preview_file_from_code_navigation` or `enable_preview_multibuffer_from_code_navigation` is also true, the new tab may replace the existing one. + "enable_keep_preview_on_code_navigation": false }, // Settings related to the file finder. "file_finder": { diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index f6489c8ffece51d581e3fb73d3f683ff1283c433..f2d6e168fc9ed47cd3c490f3449bc856f90e79fd 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -17012,7 +17012,9 @@ impl Editor { }) .collect(); - let workspace = self.workspace(); + let Some(workspace) = self.workspace() else { + return Task::ready(Ok(Navigated::No)); + }; cx.spawn_in(window, async move |editor, cx| { let locations: Vec = future::join_all(definitions) @@ -17038,10 +17040,6 @@ impl Editor { } if num_locations > 1 { - let Some(workspace) = workspace else { - return Ok(Navigated::No); - }; - let tab_kind = match kind { Some(GotoDefinitionKind::Implementation) => "Implementations", Some(GotoDefinitionKind::Symbol) | None => "Definitions", @@ -17073,11 +17071,14 @@ impl Editor { let opened = workspace .update_in(cx, |workspace, window, cx| { + let allow_preview = PreviewTabsSettings::get_global(cx) + .enable_preview_multibuffer_from_code_navigation; Self::open_locations_in_multibuffer( workspace, locations, title, split, + allow_preview, MultibufferSelectionMode::First, window, cx, @@ -17094,10 +17095,9 @@ impl Editor { Ok(Navigated::Yes) } Some(Either::Right(path)) => { - let Some(workspace) = workspace else { - return Ok(Navigated::No); - }; - + // TODO(andrew): respect preview tab settings + // `enable_keep_preview_on_code_navigation` and + // `enable_preview_file_from_code_navigation` workspace .update_in(cx, |workspace, window, cx| { workspace.open_resolved_path(path, window, cx) @@ -17108,10 +17108,6 @@ impl Editor { None => Ok(Navigated::No), } } else { - let Some(workspace) = workspace else { - return Ok(Navigated::No); - }; - let (target_buffer, target_ranges) = locations.into_iter().next().unwrap(); let target_range = target_ranges.first().unwrap().clone(); @@ -17135,11 +17131,19 @@ impl Editor { workspace.active_pane().clone() }; + let preview_tabs_settings = PreviewTabsSettings::get_global(cx); + let keep_old_preview = preview_tabs_settings + .enable_keep_preview_on_code_navigation; + let allow_new_preview = preview_tabs_settings + .enable_preview_file_from_code_navigation; + workspace.open_project_item( pane, target_buffer.clone(), true, true, + keep_old_preview, + allow_new_preview, window, cx, ) @@ -17416,11 +17420,14 @@ impl Editor { } else { format!("References to {target}") }; + let allow_preview = PreviewTabsSettings::get_global(cx) + .enable_preview_multibuffer_from_code_navigation; Self::open_locations_in_multibuffer( workspace, locations, title, false, + allow_preview, MultibufferSelectionMode::First, window, cx, @@ -17436,6 +17443,7 @@ impl Editor { locations: std::collections::HashMap, Vec>>, title: String, split: bool, + allow_preview: bool, multibuffer_selection_mode: MultibufferSelectionMode, window: &mut Window, cx: &mut Context, @@ -17483,6 +17491,7 @@ impl Editor { .is_some_and(|it| *it == key) }) }); + let was_existing = existing.is_some(); let editor = existing.unwrap_or_else(|| { cx.new(|cx| { let mut editor = Editor::for_multibuffer( @@ -17523,29 +17532,23 @@ impl Editor { }); let item = Box::new(editor); - let item_id = item.item_id(); - - if split { - let pane = workspace.adjacent_pane(window, cx); - workspace.add_item(pane, item, None, true, true, window, cx); - } else if PreviewTabsSettings::get_global(cx).enable_preview_from_code_navigation { - let (preview_item_id, preview_item_idx) = - workspace.active_pane().read_with(cx, |pane, _| { - (pane.preview_item_id(), pane.preview_item_idx()) - }); - workspace.add_item_to_active_pane(item, preview_item_idx, true, window, cx); + let pane = if split { + workspace.adjacent_pane(window, cx) + } else { + workspace.active_pane().clone() + }; + let activate_pane = split; - if let Some(preview_item_id) = preview_item_id { - workspace.active_pane().update(cx, |pane, cx| { - pane.remove_item(preview_item_id, false, false, window, cx); - }); + let mut destination_index = None; + pane.update(cx, |pane, cx| { + if allow_preview && !was_existing { + destination_index = pane.replace_preview_item_id(item.item_id(), window, cx); } - } else { - workspace.add_item_to_active_pane(item, None, true, window, cx); - } - workspace.active_pane().update(cx, |pane, cx| { - pane.set_preview_item_id(Some(item_id), cx); + if was_existing && !allow_preview { + pane.unpreview_item_if_preview(item.item_id()); + } + pane.add_item(item, activate_pane, true, destination_index, window, cx); }); } @@ -20783,6 +20786,7 @@ impl Editor { locations, format!("Selections for '{title}'"), false, + false, MultibufferSelectionMode::All, window, cx, @@ -22002,29 +22006,40 @@ impl Editor { // Handle file-less buffers separately: those are not really the project items, so won't have a project path or entity id, // so `workspace.open_project_item` will never find them, always opening a new editor. // Instead, we try to activate the existing editor in the pane first. - let (editor, pane_item_index) = + let (editor, pane_item_index, pane_item_id) = pane.read(cx).items().enumerate().find_map(|(i, item)| { let editor = item.downcast::()?; let singleton_buffer = editor.read(cx).buffer().read(cx).as_singleton()?; if singleton_buffer == buffer { - Some((editor, i)) + Some((editor, i, item.item_id())) } else { None } })?; pane.update(cx, |pane, cx| { - pane.activate_item(pane_item_index, true, true, window, cx) + pane.activate_item(pane_item_index, true, true, window, cx); + if !PreviewTabsSettings::get_global(cx) + .enable_preview_from_multibuffer + { + pane.unpreview_item_if_preview(pane_item_id); + } }); Some(editor) }) .flatten() .unwrap_or_else(|| { + let keep_old_preview = PreviewTabsSettings::get_global(cx) + .enable_keep_preview_on_code_navigation; + let allow_new_preview = + PreviewTabsSettings::get_global(cx).enable_preview_from_multibuffer; workspace.open_project_item::( pane.clone(), buffer, true, true, + keep_old_preview, + allow_new_preview, window, cx, ) diff --git a/crates/migrator/src/migrations.rs b/crates/migrator/src/migrations.rs index 07b7d3f0afb141d4dde77b883ca97f4df67cdd6c..398d5aaf9405d34e8d8a4e93d5c9b9045ee49118 100644 --- a/crates/migrator/src/migrations.rs +++ b/crates/migrator/src/migrations.rs @@ -153,3 +153,9 @@ pub(crate) mod m_2025_11_25 { pub(crate) use settings::remove_context_server_source; } + +pub(crate) mod m_2025_12_01 { + mod settings; + + pub(crate) use settings::SETTINGS_PATTERNS; +} diff --git a/crates/migrator/src/migrations/m_2025_12_01/settings.rs b/crates/migrator/src/migrations/m_2025_12_01/settings.rs new file mode 100644 index 0000000000000000000000000000000000000000..2c3816dab3446b483f197575e9f602986eee7e47 --- /dev/null +++ b/crates/migrator/src/migrations/m_2025_12_01/settings.rs @@ -0,0 +1,55 @@ +use std::ops::Range; +use tree_sitter::{Query, QueryMatch}; + +use crate::MigrationPatterns; +use crate::patterns::SETTINGS_NESTED_KEY_VALUE_PATTERN; + +pub const SETTINGS_PATTERNS: MigrationPatterns = &[( + SETTINGS_NESTED_KEY_VALUE_PATTERN, + rename_enable_preview_from_code_navigation_setting, +)]; + +fn rename_enable_preview_from_code_navigation_setting( + contents: &str, + mat: &QueryMatch, + query: &Query, +) -> Option<(Range, String)> { + if !is_enable_preview_from_code_navigation(contents, mat, query) { + return None; + } + + let setting_name_ix = query.capture_index_for_name("setting_name")?; + let setting_name_range = mat + .nodes_for_capture_index(setting_name_ix) + .next()? + .byte_range(); + + Some(( + setting_name_range, + "enable_keep_preview_on_code_navigation".to_string(), + )) +} + +fn is_enable_preview_from_code_navigation(contents: &str, mat: &QueryMatch, query: &Query) -> bool { + let parent_key_ix = match query.capture_index_for_name("parent_key") { + Some(ix) => ix, + None => return false, + }; + let parent_range = match mat.nodes_for_capture_index(parent_key_ix).next() { + Some(node) => node.byte_range(), + None => return false, + }; + if contents.get(parent_range) != Some("preview_tabs") { + return false; + } + + let setting_name_ix = match query.capture_index_for_name("setting_name") { + Some(ix) => ix, + None => return false, + }; + let setting_name_range = match mat.nodes_for_capture_index(setting_name_ix).next() { + Some(node) => node.byte_range(), + None => return false, + }; + contents.get(setting_name_range) == Some("enable_preview_from_code_navigation") +} diff --git a/crates/migrator/src/migrator.rs b/crates/migrator/src/migrator.rs index 444ebadfb615628e91422ed62c351722d8cb9300..9fb6d8a1151719f350ea7877bfe2492d6b443c23 100644 --- a/crates/migrator/src/migrator.rs +++ b/crates/migrator/src/migrator.rs @@ -219,6 +219,10 @@ pub fn migrate_settings(text: &str) -> Result> { migrations::m_2025_11_12::SETTINGS_PATTERNS, &SETTINGS_QUERY_2025_11_12, ), + MigrationType::TreeSitter( + migrations::m_2025_12_01::SETTINGS_PATTERNS, + &SETTINGS_QUERY_2025_12_01, + ), MigrationType::TreeSitter( migrations::m_2025_11_20::SETTINGS_PATTERNS, &SETTINGS_QUERY_2025_11_20, @@ -346,6 +350,10 @@ define_query!( SETTINGS_QUERY_2025_11_12, migrations::m_2025_11_12::SETTINGS_PATTERNS ); +define_query!( + SETTINGS_QUERY_2025_12_01, + migrations::m_2025_12_01::SETTINGS_PATTERNS +); define_query!( SETTINGS_QUERY_2025_11_20, migrations::m_2025_11_20::SETTINGS_PATTERNS @@ -2262,6 +2270,54 @@ mod tests { ); } + #[test] + fn test_remove_context_server_source() { + assert_migrate_settings( + &r#" + { + "context_servers": { + "extension_server": { + "source": "extension", + "settings": { + "foo": "bar" + } + }, + "custom_server": { + "source": "custom", + "command": "foo", + "args": ["bar"], + "env": { + "FOO": "BAR" + } + }, + } + } + "# + .unindent(), + Some( + &r#" + { + "context_servers": { + "extension_server": { + "settings": { + "foo": "bar" + } + }, + "custom_server": { + "command": "foo", + "args": ["bar"], + "env": { + "FOO": "BAR" + } + }, + } + } + "# + .unindent(), + ), + ); + } + #[test] fn test_project_panel_open_file_on_paste_migration() { assert_migrate_settings( @@ -2308,25 +2364,14 @@ mod tests { } #[test] - fn test_remove_context_server_source() { + fn test_enable_preview_from_code_navigation_migration() { assert_migrate_settings( &r#" { - "context_servers": { - "extension_server": { - "source": "extension", - "settings": { - "foo": "bar" - } - }, - "custom_server": { - "source": "custom", - "command": "foo", - "args": ["bar"], - "env": { - "FOO": "BAR" - } - }, + "other_setting_1": 1, + "preview_tabs": { + "other_setting_2": 2, + "enable_preview_from_code_navigation": false } } "# @@ -2334,19 +2379,35 @@ mod tests { Some( &r#" { - "context_servers": { - "extension_server": { - "settings": { - "foo": "bar" - } - }, - "custom_server": { - "command": "foo", - "args": ["bar"], - "env": { - "FOO": "BAR" - } - }, + "other_setting_1": 1, + "preview_tabs": { + "other_setting_2": 2, + "enable_keep_preview_on_code_navigation": false + } + } + "# + .unindent(), + ), + ); + + assert_migrate_settings( + &r#" + { + "other_setting_1": 1, + "preview_tabs": { + "other_setting_2": 2, + "enable_preview_from_code_navigation": true + } + } + "# + .unindent(), + Some( + &r#" + { + "other_setting_1": 1, + "preview_tabs": { + "other_setting_2": 2, + "enable_keep_preview_on_code_navigation": true } } "# diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rs index d191b9f3fea5a7183bbcc89b751a71b00c1a31b7..e53be8cd33fa265dfadb201b2bcd613c54ffb9dd 100644 --- a/crates/project_panel/src/project_panel.rs +++ b/crates/project_panel/src/project_panel.rs @@ -1529,7 +1529,8 @@ impl ProjectPanel { } fn open(&mut self, _: &Open, window: &mut Window, cx: &mut Context) { - let preview_tabs_enabled = PreviewTabsSettings::get_global(cx).enabled; + let preview_tabs_enabled = + PreviewTabsSettings::get_global(cx).enable_preview_from_project_panel; self.open_internal(true, !preview_tabs_enabled, None, window, cx); } @@ -4819,7 +4820,7 @@ impl ProjectPanel { project_panel.toggle_expanded(entry_id, window, cx); } } else { - let preview_tabs_enabled = PreviewTabsSettings::get_global(cx).enabled; + let preview_tabs_enabled = PreviewTabsSettings::get_global(cx).enable_preview_from_project_panel; let click_count = event.click_count(); let focus_opened_item = click_count > 1; let allow_preview = preview_tabs_enabled && click_count == 1; diff --git a/crates/project_symbols/src/project_symbols.rs b/crates/project_symbols/src/project_symbols.rs index 61ed715ffd639c532257319d2165d530ae5c0513..d96de4b876030deb5a6083b1474a167f8cba81ad 100644 --- a/crates/project_symbols/src/project_symbols.rs +++ b/crates/project_symbols/src/project_symbols.rs @@ -133,8 +133,9 @@ impl PickerDelegate for ProjectSymbolsDelegate { workspace.active_pane().clone() }; - let editor = - workspace.open_project_item::(pane, buffer, true, true, window, cx); + let editor = workspace.open_project_item::( + pane, buffer, true, true, true, true, window, cx, + ); editor.update(cx, |editor, cx| { editor.change_selections( diff --git a/crates/settings/src/settings_content/workspace.rs b/crates/settings/src/settings_content/workspace.rs index 088d478e464bd0f4e9a92419440c16576005fc95..b809a8fa85a9b27da3f3af5242e99b280466a4bb 100644 --- a/crates/settings/src/settings_content/workspace.rs +++ b/crates/settings/src/settings_content/workspace.rs @@ -152,14 +152,31 @@ pub struct PreviewTabsSettingsContent { /// /// Default: true pub enabled: Option, + /// Whether to open tabs in preview mode when opened from the project panel with a single click. + /// + /// Default: true + pub enable_preview_from_project_panel: Option, /// Whether to open tabs in preview mode when selected from the file finder. /// /// Default: false pub enable_preview_from_file_finder: Option, - /// Whether a preview tab gets replaced when code navigation is used to navigate away from the tab. + /// Whether to open tabs in preview mode when opened from a multibuffer. + /// + /// Default: true + pub enable_preview_from_multibuffer: Option, + /// Whether to open tabs in preview mode when code navigation is used to open a multibuffer. + /// + /// Default: false + pub enable_preview_multibuffer_from_code_navigation: Option, + /// Whether to open tabs in preview mode when code navigation is used to open a single file. + /// + /// Default: true + pub enable_preview_file_from_code_navigation: Option, + /// Whether to keep tabs in preview mode when code navigation is used to navigate away from them. + /// If `enable_preview_file_from_code_navigation` or `enable_preview_multibuffer_from_code_navigation` is also true, the new tab may replace the existing one. /// /// Default: false - pub enable_preview_from_code_navigation: Option, + pub enable_keep_preview_on_code_navigation: Option, } #[derive( diff --git a/crates/settings/src/vscode_import.rs b/crates/settings/src/vscode_import.rs index 0a4e249d60c6888d9a950dcc5be4600d0047ce00..587850303f13649fcc4adf8cf4ddbb8dc7181dcb 100644 --- a/crates/settings/src/vscode_import.rs +++ b/crates/settings/src/vscode_import.rs @@ -619,9 +619,13 @@ impl VsCodeSettings { fn preview_tabs_settings_content(&self) -> Option { skip_default(PreviewTabsSettingsContent { enabled: self.read_bool("workbench.editor.enablePreview"), + enable_preview_from_project_panel: None, enable_preview_from_file_finder: self .read_bool("workbench.editor.enablePreviewFromQuickOpen"), - enable_preview_from_code_navigation: self + enable_preview_from_multibuffer: None, + enable_preview_multibuffer_from_code_navigation: None, + enable_preview_file_from_code_navigation: None, + enable_keep_preview_on_code_navigation: self .read_bool("workbench.editor.enablePreviewFromCodeNavigation"), }) } diff --git a/crates/settings_ui/src/page_data.rs b/crates/settings_ui/src/page_data.rs index 1525271a39776f4b8b456244f40e3dfbc43cbaac..0c383970c990c3ba19eab7aa5d3b7c699f8a195e 100644 --- a/crates/settings_ui/src/page_data.rs +++ b/crates/settings_ui/src/page_data.rs @@ -3145,7 +3145,7 @@ pub(crate) fn settings_data(cx: &App) -> Vec { SettingsPageItem::SectionHeader("Preview Tabs"), SettingsPageItem::SettingItem(SettingItem { title: "Preview Tabs Enabled", - description: "Show opened editors as Preview tabs.", + description: "Show opened editors as preview tabs.", field: Box::new(SettingField { json_path: Some("preview_tabs.enabled"), pick: |settings_content| { @@ -3161,9 +3161,31 @@ pub(crate) fn settings_data(cx: &App) -> Vec { metadata: None, files: USER, }), + SettingsPageItem::SettingItem(SettingItem { + title: "Enable Preview From Project Panel", + description: "Whether to open tabs in preview mode when opened from the project panel with a single click.", + field: Box::new(SettingField { + json_path: Some("preview_tabs.enable_preview_from_project_panel"), + pick: |settings_content| { + settings_content + .preview_tabs + .as_ref()? + .enable_preview_from_project_panel + .as_ref() + }, + write: |settings_content, value| { + settings_content + .preview_tabs + .get_or_insert_default() + .enable_preview_from_project_panel = value; + }, + }), + metadata: None, + files: USER, + }), SettingsPageItem::SettingItem(SettingItem { title: "Enable Preview From File Finder", - description: "Whether to open tabs in Preview mode when selected from the file finder.", + description: "Whether to open tabs in preview mode when selected from the file finder.", field: Box::new(SettingField { json_path: Some("preview_tabs.enable_preview_from_file_finder"), pick: |settings_content| { @@ -3184,22 +3206,88 @@ pub(crate) fn settings_data(cx: &App) -> Vec { files: USER, }), SettingsPageItem::SettingItem(SettingItem { - title: "Enable Preview From Code Navigation", - description: "Whether a preview tab gets replaced when code navigation is used to navigate away from the tab.", + title: "Enable Preview From Multibuffer", + description: "Whether to open tabs in preview mode when opened from a multibuffer.", + field: Box::new(SettingField { + json_path: Some("preview_tabs.enable_preview_from_multibuffer"), + pick: |settings_content| { + settings_content + .preview_tabs + .as_ref()? + .enable_preview_from_multibuffer + .as_ref() + }, + write: |settings_content, value| { + settings_content + .preview_tabs + .get_or_insert_default() + .enable_preview_from_multibuffer = value; + }, + }), + metadata: None, + files: USER, + }), + SettingsPageItem::SettingItem(SettingItem { + title: "Enable Preview Multibuffer From Code Navigation", + description: "Whether to open tabs in preview mode when code navigation is used to open a multibuffer.", + field: Box::new(SettingField { + json_path: Some("preview_tabs.enable_preview_multibuffer_from_code_navigation"), + pick: |settings_content| { + settings_content + .preview_tabs + .as_ref()? + .enable_preview_multibuffer_from_code_navigation + .as_ref() + }, + write: |settings_content, value| { + settings_content + .preview_tabs + .get_or_insert_default() + .enable_preview_multibuffer_from_code_navigation = value; + }, + }), + metadata: None, + files: USER, + }), + SettingsPageItem::SettingItem(SettingItem { + title: "Enable Preview File From Code Navigation", + description: "Whether to open tabs in preview mode when code navigation is used to open a single file.", + field: Box::new(SettingField { + json_path: Some("preview_tabs.enable_preview_file_from_code_navigation"), + pick: |settings_content| { + settings_content + .preview_tabs + .as_ref()? + .enable_preview_file_from_code_navigation + .as_ref() + }, + write: |settings_content, value| { + settings_content + .preview_tabs + .get_or_insert_default() + .enable_preview_file_from_code_navigation = value; + }, + }), + metadata: None, + files: USER, + }), + SettingsPageItem::SettingItem(SettingItem { + title: "Enable Keep Preview On Code Navigation", + description: "Whether to keep tabs in preview mode when code navigation is used to navigate away from them. If `enable_preview_file_from_code_navigation` or `enable_preview_multibuffer_from_code_navigation` is also true, the new tab may replace the existing one.", field: Box::new(SettingField { - json_path: Some("preview_tabs.enable_preview_from_code_navigation"), + json_path: Some("preview_tabs.enable_keep_preview_on_code_navigation"), pick: |settings_content| { settings_content .preview_tabs .as_ref()? - .enable_preview_from_code_navigation + .enable_keep_preview_on_code_navigation .as_ref() }, write: |settings_content, value| { settings_content .preview_tabs .get_or_insert_default() - .enable_preview_from_code_navigation = value; + .enable_keep_preview_on_code_navigation = value; }, }), metadata: None, diff --git a/crates/workspace/src/item.rs b/crates/workspace/src/item.rs index 8f459557270e7b4595e26e15f2aad3c33aea4cd8..42eb754c21347e7dced792f3e56cb9901bc70bd1 100644 --- a/crates/workspace/src/item.rs +++ b/crates/workspace/src/item.rs @@ -64,8 +64,12 @@ pub struct ItemSettings { #[derive(RegisterSetting)] pub struct PreviewTabsSettings { pub enabled: bool, + pub enable_preview_from_project_panel: bool, pub enable_preview_from_file_finder: bool, - pub enable_preview_from_code_navigation: bool, + pub enable_preview_from_multibuffer: bool, + pub enable_preview_multibuffer_from_code_navigation: bool, + pub enable_preview_file_from_code_navigation: bool, + pub enable_keep_preview_on_code_navigation: bool, } impl Settings for ItemSettings { @@ -87,9 +91,19 @@ impl Settings for PreviewTabsSettings { let preview_tabs = content.preview_tabs.as_ref().unwrap(); Self { enabled: preview_tabs.enabled.unwrap(), + enable_preview_from_project_panel: preview_tabs + .enable_preview_from_project_panel + .unwrap(), enable_preview_from_file_finder: preview_tabs.enable_preview_from_file_finder.unwrap(), - enable_preview_from_code_navigation: preview_tabs - .enable_preview_from_code_navigation + enable_preview_from_multibuffer: preview_tabs.enable_preview_from_multibuffer.unwrap(), + enable_preview_multibuffer_from_code_navigation: preview_tabs + .enable_preview_multibuffer_from_code_navigation + .unwrap(), + enable_preview_file_from_code_navigation: preview_tabs + .enable_preview_file_from_code_navigation + .unwrap(), + enable_keep_preview_on_code_navigation: preview_tabs + .enable_keep_preview_on_code_navigation .unwrap(), } } diff --git a/crates/workspace/src/pane.rs b/crates/workspace/src/pane.rs index 5f0fb8ba9647f969b3bea4a83194dd600e1f84aa..e99f8d1dc959def06deebae7c4acc454c9210933 100644 --- a/crates/workspace/src/pane.rs +++ b/crates/workspace/src/pane.rs @@ -873,10 +873,35 @@ impl Pane { self.preview_item_id == Some(item_id) } + /// Promotes the item with the given ID to not be a preview item. + /// This does nothing if it wasn't already a preview item. + pub fn unpreview_item_if_preview(&mut self, item_id: EntityId) { + if self.is_active_preview_item(item_id) { + self.preview_item_id = None; + } + } + + /// Marks the item with the given ID as the preview item. + /// This will be ignored if the global setting `preview_tabs` is disabled. + /// + /// The old preview item (if there was one) is closed and its index is returned. + pub fn replace_preview_item_id( + &mut self, + item_id: EntityId, + window: &mut Window, + cx: &mut Context, + ) -> Option { + let idx = self.close_current_preview_item(window, cx); + self.set_preview_item_id(Some(item_id), cx); + idx + } + /// Marks the item with the given ID as the preview item. /// This will be ignored if the global setting `preview_tabs` is disabled. - pub fn set_preview_item_id(&mut self, item_id: Option, cx: &App) { - if PreviewTabsSettings::get_global(cx).enabled { + /// + /// This is a low-level method. Prefer `unpreview_item_if_preview()` or `set_new_preview_item()`. + pub(crate) fn set_preview_item_id(&mut self, item_id: Option, cx: &App) { + if item_id.is_none() || PreviewTabsSettings::get_global(cx).enabled { self.preview_item_id = item_id; } } @@ -895,7 +920,7 @@ impl Pane { && preview_item.item_id() == item_id && !preview_item.preserve_preview(cx) { - self.set_preview_item_id(None, cx); + self.unpreview_item_if_preview(item_id); } } @@ -936,14 +961,8 @@ impl Pane { let set_up_existing_item = |index: usize, pane: &mut Self, window: &mut Window, cx: &mut Context| { - // If the item is already open, and the item is a preview item - // and we are not allowing items to open as preview, mark the item as persistent. - if let Some(preview_item_id) = pane.preview_item_id - && let Some(tab) = pane.items.get(index) - && tab.item_id() == preview_item_id - && !allow_preview - { - pane.set_preview_item_id(None, cx); + if !allow_preview && let Some(item) = pane.items.get(index) { + pane.unpreview_item_if_preview(item.item_id()); } if activate { pane.activate_item(index, focus_item, focus_item, window, cx); @@ -955,7 +974,7 @@ impl Pane { window: &mut Window, cx: &mut Context| { if allow_preview { - pane.set_preview_item_id(Some(new_item.item_id()), cx); + pane.replace_preview_item_id(new_item.item_id(), window, cx); } if let Some(text) = new_item.telemetry_event_text(cx) { @@ -1036,6 +1055,7 @@ impl Pane { ) -> Option { let item_idx = self.preview_item_idx()?; let id = self.preview_item_id()?; + self.set_preview_item_id(None, cx); let prev_active_item_index = self.active_item_index; self.remove_item(id, false, false, window, cx); @@ -1981,9 +2001,7 @@ impl Pane { item.on_removed(cx); self.nav_history.set_mode(mode); - if self.is_active_preview_item(item.item_id()) { - self.set_preview_item_id(None, cx); - } + self.unpreview_item_if_preview(item.item_id()); if let Some(path) = item.project_path(cx) { let abs_path = self @@ -2194,9 +2212,7 @@ impl Pane { if can_save { pane.update_in(cx, |pane, window, cx| { - if pane.is_active_preview_item(item.item_id()) { - pane.set_preview_item_id(None, cx); - } + pane.unpreview_item_if_preview(item.item_id()); item.save( SaveOptions { format: should_format, @@ -2450,8 +2466,8 @@ impl Pane { let id = self.item_for_index(ix)?.item_id(); let should_activate = ix == self.active_item_index; - if matches!(operation, PinOperation::Pin) && self.is_active_preview_item(id) { - self.set_preview_item_id(None, cx); + if matches!(operation, PinOperation::Pin) { + self.unpreview_item_if_preview(id); } match operation { @@ -2624,12 +2640,9 @@ impl Pane { ) .on_mouse_down( MouseButton::Left, - cx.listener(move |pane, event: &MouseDownEvent, _, cx| { - if let Some(id) = pane.preview_item_id - && id == item_id - && event.click_count > 1 - { - pane.set_preview_item_id(None, cx); + cx.listener(move |pane, event: &MouseDownEvent, _, _| { + if event.click_count > 1 { + pane.unpreview_item_if_preview(item_id); } }), ) @@ -3272,11 +3285,7 @@ impl Pane { let mut to_pane = cx.entity(); let split_direction = self.drag_split_direction; let item_id = dragged_tab.item.item_id(); - if let Some(preview_item_id) = self.preview_item_id - && item_id == preview_item_id - { - self.set_preview_item_id(None, cx); - } + self.unpreview_item_if_preview(item_id); let is_clone = cfg!(target_os = "macos") && window.modifiers().alt || cfg!(not(target_os = "macos")) && window.modifiers().control; @@ -3788,15 +3797,17 @@ impl Render for Pane { .on_action(cx.listener(Self::toggle_pin_tab)) .on_action(cx.listener(Self::unpin_all_tabs)) .when(PreviewTabsSettings::get_global(cx).enabled, |this| { - this.on_action(cx.listener(|pane: &mut Pane, _: &TogglePreviewTab, _, cx| { - if let Some(active_item_id) = pane.active_item().map(|i| i.item_id()) { - if pane.is_active_preview_item(active_item_id) { - pane.set_preview_item_id(None, cx); - } else { - pane.set_preview_item_id(Some(active_item_id), cx); + this.on_action( + cx.listener(|pane: &mut Pane, _: &TogglePreviewTab, window, cx| { + if let Some(active_item_id) = pane.active_item().map(|i| i.item_id()) { + if pane.is_active_preview_item(active_item_id) { + pane.unpreview_item_if_preview(active_item_id); + } else { + pane.replace_preview_item_id(active_item_id, window, cx); + } } - } - })) + }), + ) }) .on_action( cx.listener(|pane: &mut Self, action: &CloseActiveItem, window, cx| { diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index d5a1c3a291c8e337695b30c1e6e1f3b3b76a3a62..b1ad520493b4869d646a76df4a0e576646253117 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -3636,14 +3636,33 @@ impl Workspace { project_item: Entity, activate_pane: bool, focus_item: bool, + keep_old_preview: bool, + allow_new_preview: bool, window: &mut Window, cx: &mut Context, ) -> Entity where T: ProjectItem, { + let old_item_id = pane.read(cx).active_item().map(|item| item.item_id()); + if let Some(item) = self.find_project_item(&pane, &project_item, cx) { + if !keep_old_preview + && let Some(old_id) = old_item_id + && old_id != item.item_id() + { + // switching to a different item, so unpreview old active item + pane.update(cx, |pane, _| { + pane.unpreview_item_if_preview(old_id); + }); + } + self.activate_item(&item, activate_pane, focus_item, window, cx); + if !allow_new_preview { + pane.update(cx, |pane, _| { + pane.unpreview_item_if_preview(item.item_id()); + }); + } return item; } @@ -3652,16 +3671,14 @@ impl Workspace { T::for_project_item(self.project().clone(), Some(pane), project_item, window, cx) }) }); - let item_id = item.item_id(); let mut destination_index = None; pane.update(cx, |pane, cx| { - if PreviewTabsSettings::get_global(cx).enable_preview_from_code_navigation - && let Some(preview_item_id) = pane.preview_item_id() - && preview_item_id != item_id - { - destination_index = pane.close_current_preview_item(window, cx); + if !keep_old_preview && let Some(old_id) = old_item_id { + pane.unpreview_item_if_preview(old_id); + } + if allow_new_preview { + destination_index = pane.replace_preview_item_id(item.item_id(), window, cx); } - pane.set_preview_item_id(Some(item.item_id()), cx) }); self.add_item( diff --git a/docs/src/configuring-zed.md b/docs/src/configuring-zed.md index 3b90120407fe56643e4b3f279d88443b9740e154..477885a4537580aaf562aa596c1a06cae1c65bc8 100644 --- a/docs/src/configuring-zed.md +++ b/docs/src/configuring-zed.md @@ -2861,11 +2861,25 @@ Configuration object for defining settings profiles. Example: ```json [settings] "preview_tabs": { "enabled": true, + "enable_preview_from_project_panel": true, "enable_preview_from_file_finder": false, - "enable_preview_from_code_navigation": false, + "enable_preview_from_multibuffer": true, + "enable_preview_multibuffer_from_code_navigation": false, + "enable_preview_file_from_code_navigation": true, + "enable_keep_preview_on_code_navigation": false, } ``` +### Enable preview from project panel + +- Description: Determines whether to open files in preview mode when opened from the project panel with a single click. +- Setting: `enable_preview_from_project_panel` +- Default: `true` + +**Options** + +`boolean` values + ### Enable preview from file finder - Description: Determines whether to open files in preview mode when selected from the file finder. @@ -2876,10 +2890,40 @@ Configuration object for defining settings profiles. Example: `boolean` values -### Enable preview from code navigation +### Enable preview from multibuffer + +- Description: Determines whether to open files in preview mode when opened from a multibuffer. +- Setting: `enable_preview_from_multibuffer` +- Default: `true` + +**Options** + +`boolean` values + +### Enable preview multibuffer from code navigation + +- Description: Determines whether to open tabs in preview mode when code navigation is used to open a multibuffer. +- Setting: `enable_preview_multibuffer_from_code_navigation` +- Default: `false` + +**Options** + +`boolean` values + +### Enable preview file from code navigation + +- Description: Determines whether to open tabs in preview mode when code navigation is used to open a single file. +- Setting: `enable_preview_file_from_code_navigation` +- Default: `true` + +**Options** + +`boolean` values + +### Enable keep preview on code navigation -- Description: Determines whether a preview tab gets replaced when code navigation is used to navigate away from the tab. -- Setting: `enable_preview_from_code_navigation` +- Description: Determines whether to keep tabs in preview mode when code navigation is used to navigate away from them. If `enable_preview_file_from_code_navigation` or `enable_preview_multibuffer_from_code_navigation` is also true, the new tab may replace the existing one. +- Setting: `enable_keep_preview_on_code_navigation` - Default: `false` **Options** From 8ad3a150c8372d1e7b048f7eb3f0500e94a58ae8 Mon Sep 17 00:00:00 2001 From: Smit Barmase Date: Wed, 3 Dec 2025 14:25:04 -0800 Subject: [PATCH 043/621] editor: Add active match highlight for buffer and project search (#44098) Closes #28617 image Release Notes: - Improved visibility of the currently active match when browsing results in buffer or project search. --------- Co-authored-by: DarkMatter-999 --- assets/themes/ayu/ayu.json | 3 + assets/themes/gruvbox/gruvbox.json | 6 + assets/themes/one/one.json | 2 + crates/agent_ui/src/text_thread_editor.rs | 6 +- crates/debugger_tools/src/dap_log.rs | 6 +- .../src/session/running/console.rs | 3 +- crates/editor/src/editor.rs | 29 +- crates/editor/src/editor_tests.rs | 10 +- crates/editor/src/hover_popover.rs | 2 +- crates/editor/src/items.rs | 9 +- crates/language_tools/src/lsp_log_view.rs | 6 +- crates/language_tools/src/syntax_tree_view.rs | 2 +- crates/search/src/buffer_search.rs | 25 +- crates/search/src/project_search.rs | 326 ++++++++++++------ crates/settings/src/settings_content/theme.rs | 3 + crates/terminal_view/src/terminal_view.rs | 1 + crates/theme/src/default_colors.rs | 2 + crates/theme/src/fallback_themes.rs | 1 + crates/theme/src/schema.rs | 15 +- crates/theme/src/styles/colors.rs | 3 + crates/vim/src/normal/yank.rs | 2 +- crates/vim/src/replace.rs | 2 +- crates/workspace/src/searchable.rs | 19 +- 23 files changed, 338 insertions(+), 145 deletions(-) diff --git a/assets/themes/ayu/ayu.json b/assets/themes/ayu/ayu.json index 7c84c603bda7fd7590067ec9f566f3582ba6aefd..e2b7c3c91fca46ab0e4064719bea5c8793faaccc 100644 --- a/assets/themes/ayu/ayu.json +++ b/assets/themes/ayu/ayu.json @@ -45,6 +45,7 @@ "tab.inactive_background": "#1f2127ff", "tab.active_background": "#0d1016ff", "search.match_background": "#5ac2fe66", + "search.active_match_background": "#ea570166", "panel.background": "#1f2127ff", "panel.focused_border": "#5ac1feff", "pane.focused_border": null, @@ -436,6 +437,7 @@ "tab.inactive_background": "#ececedff", "tab.active_background": "#fcfcfcff", "search.match_background": "#3b9ee566", + "search.active_match_background": "#f88b3666", "panel.background": "#ececedff", "panel.focused_border": "#3b9ee5ff", "pane.focused_border": null, @@ -827,6 +829,7 @@ "tab.inactive_background": "#353944ff", "tab.active_background": "#242835ff", "search.match_background": "#73cffe66", + "search.active_match_background": "#fd722b66", "panel.background": "#353944ff", "panel.focused_border": null, "pane.focused_border": null, diff --git a/assets/themes/gruvbox/gruvbox.json b/assets/themes/gruvbox/gruvbox.json index a0f0a3ad637a4d212c8bf38f95f2e8424919d6bf..90973fd6c3469a1ef0e698d629376dfaaf3b5a76 100644 --- a/assets/themes/gruvbox/gruvbox.json +++ b/assets/themes/gruvbox/gruvbox.json @@ -46,6 +46,7 @@ "tab.inactive_background": "#3a3735ff", "tab.active_background": "#282828ff", "search.match_background": "#83a59866", + "search.active_match_background": "#c09f3f66", "panel.background": "#3a3735ff", "panel.focused_border": "#83a598ff", "pane.focused_border": null, @@ -452,6 +453,7 @@ "tab.inactive_background": "#393634ff", "tab.active_background": "#1d2021ff", "search.match_background": "#83a59866", + "search.active_match_background": "#c9653666", "panel.background": "#393634ff", "panel.focused_border": "#83a598ff", "pane.focused_border": null, @@ -858,6 +860,7 @@ "tab.inactive_background": "#3b3735ff", "tab.active_background": "#32302fff", "search.match_background": "#83a59866", + "search.active_match_background": "#aea85166", "panel.background": "#3b3735ff", "panel.focused_border": null, "pane.focused_border": null, @@ -1264,6 +1267,7 @@ "tab.inactive_background": "#ecddb4ff", "tab.active_background": "#fbf1c7ff", "search.match_background": "#0b667866", + "search.active_match_background": "#ba2d1166", "panel.background": "#ecddb4ff", "panel.focused_border": null, "pane.focused_border": null, @@ -1670,6 +1674,7 @@ "tab.inactive_background": "#ecddb5ff", "tab.active_background": "#f9f5d7ff", "search.match_background": "#0b667866", + "search.active_match_background": "#dc351466", "panel.background": "#ecddb5ff", "panel.focused_border": null, "pane.focused_border": null, @@ -2076,6 +2081,7 @@ "tab.inactive_background": "#ecdcb3ff", "tab.active_background": "#f2e5bcff", "search.match_background": "#0b667866", + "search.active_match_background": "#d7331466", "panel.background": "#ecdcb3ff", "panel.focused_border": null, "pane.focused_border": null, diff --git a/assets/themes/one/one.json b/assets/themes/one/one.json index d9d7a37e996053d6f7c6cb28ec7f0d3f92e3b394..c72c92471761c473bea05edc37b1f96f18b2f683 100644 --- a/assets/themes/one/one.json +++ b/assets/themes/one/one.json @@ -45,6 +45,7 @@ "tab.inactive_background": "#2f343eff", "tab.active_background": "#282c33ff", "search.match_background": "#74ade866", + "search.active_match_background": "#e8af7466", "panel.background": "#2f343eff", "panel.focused_border": null, "pane.focused_border": null, @@ -448,6 +449,7 @@ "tab.inactive_background": "#ebebecff", "tab.active_background": "#fafafaff", "search.match_background": "#5c79e266", + "search.active_match_background": "#d0a92366", "panel.background": "#ebebecff", "panel.focused_border": null, "pane.focused_border": null, diff --git a/crates/agent_ui/src/text_thread_editor.rs b/crates/agent_ui/src/text_thread_editor.rs index 6d5e226b6a5f1ae441314d45f2546a57c84ca664..161fad95e68c015f720df825b1f0ca32f5d79124 100644 --- a/crates/agent_ui/src/text_thread_editor.rs +++ b/crates/agent_ui/src/text_thread_editor.rs @@ -2622,11 +2622,13 @@ impl SearchableItem for TextThreadEditor { fn update_matches( &mut self, matches: &[Self::Match], + active_match_index: Option, window: &mut Window, cx: &mut Context, ) { - self.editor - .update(cx, |editor, cx| editor.update_matches(matches, window, cx)); + self.editor.update(cx, |editor, cx| { + editor.update_matches(matches, active_match_index, window, cx) + }); } fn query_suggestion(&mut self, window: &mut Window, cx: &mut Context) -> String { diff --git a/crates/debugger_tools/src/dap_log.rs b/crates/debugger_tools/src/dap_log.rs index 8841a3744a4452355e2b02c9dca969cab493796e..317ce8b4c65e441f1fc4041706989532aa150204 100644 --- a/crates/debugger_tools/src/dap_log.rs +++ b/crates/debugger_tools/src/dap_log.rs @@ -1017,11 +1017,13 @@ impl SearchableItem for DapLogView { fn update_matches( &mut self, matches: &[Self::Match], + active_match_index: Option, window: &mut Window, cx: &mut Context, ) { - self.editor - .update(cx, |e, cx| e.update_matches(matches, window, cx)) + self.editor.update(cx, |e, cx| { + e.update_matches(matches, active_match_index, window, cx) + }) } fn query_suggestion(&mut self, window: &mut Window, cx: &mut Context) -> String { diff --git a/crates/debugger_ui/src/session/running/console.rs b/crates/debugger_ui/src/session/running/console.rs index d20108b61205bacd3ea09af0ea34fabbec621c20..927a57dc8bdf956eb7f7ff63d3ea058500abf6c3 100644 --- a/crates/debugger_ui/src/session/running/console.rs +++ b/crates/debugger_ui/src/session/running/console.rs @@ -252,10 +252,11 @@ impl Console { let start_offset = range.start; let range = buffer.anchor_after(MultiBufferOffset(range.start)) ..buffer.anchor_before(MultiBufferOffset(range.end)); + let color_fn = color_fetcher(color); console.highlight_background_key::( start_offset, &[range], - color_fetcher(color), + move |_, theme| color_fn(theme), cx, ); } diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index f2d6e168fc9ed47cd3c490f3449bc856f90e79fd..f90400b2b1e07b14959d5b532c5926f7c3224dbe 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -726,7 +726,10 @@ impl EditorActionId { // type GetFieldEditorTheme = dyn Fn(&theme::Theme) -> theme::FieldEditor; // type OverrideTextStyle = dyn Fn(&EditorStyle) -> Option; -type BackgroundHighlight = (fn(&Theme) -> Hsla, Arc<[Range]>); +type BackgroundHighlight = ( + Arc Hsla + Send + Sync>, + Arc<[Range]>, +); type GutterHighlight = (fn(&App) -> Hsla, Vec>); #[derive(Default)] @@ -6610,7 +6613,7 @@ impl Editor { editor.update(cx, |editor, cx| { editor.highlight_background::( &ranges_to_highlight, - |theme| theme.colors().editor_highlighted_line_background, + |_, theme| theme.colors().editor_highlighted_line_background, cx, ); }); @@ -7012,12 +7015,12 @@ impl Editor { this.highlight_background::( &read_ranges, - |theme| theme.colors().editor_document_highlight_read_background, + |_, theme| theme.colors().editor_document_highlight_read_background, cx, ); this.highlight_background::( &write_ranges, - |theme| theme.colors().editor_document_highlight_write_background, + |_, theme| theme.colors().editor_document_highlight_write_background, cx, ); cx.notify(); @@ -7125,7 +7128,7 @@ impl Editor { if !match_ranges.is_empty() { editor.highlight_background::( &match_ranges, - |theme| theme.colors().editor_document_highlight_bracket_background, + |_, theme| theme.colors().editor_document_highlight_bracket_background, cx, ) } @@ -17519,7 +17522,7 @@ impl Editor { } editor.highlight_background::( &ranges, - |theme| theme.colors().editor_highlighted_line_background, + |_, theme| theme.colors().editor_highlighted_line_background, cx, ); } @@ -20989,7 +20992,7 @@ impl Editor { pub fn set_search_within_ranges(&mut self, ranges: &[Range], cx: &mut Context) { self.highlight_background::( ranges, - |colors| colors.colors().editor_document_highlight_read_background, + |_, colors| colors.colors().editor_document_highlight_read_background, cx, ) } @@ -21005,12 +21008,12 @@ impl Editor { pub fn highlight_background( &mut self, ranges: &[Range], - color_fetcher: fn(&Theme) -> Hsla, + color_fetcher: impl Fn(&usize, &Theme) -> Hsla + Send + Sync + 'static, cx: &mut Context, ) { self.background_highlights.insert( HighlightKey::Type(TypeId::of::()), - (color_fetcher, Arc::from(ranges)), + (Arc::new(color_fetcher), Arc::from(ranges)), ); self.scrollbar_marker_state.dirty = true; cx.notify(); @@ -21020,12 +21023,12 @@ impl Editor { &mut self, key: usize, ranges: &[Range], - color_fetcher: fn(&Theme) -> Hsla, + color_fetcher: impl Fn(&usize, &Theme) -> Hsla + Send + Sync + 'static, cx: &mut Context, ) { self.background_highlights.insert( HighlightKey::TypePlus(TypeId::of::(), key), - (color_fetcher, Arc::from(ranges)), + (Arc::new(color_fetcher), Arc::from(ranges)), ); self.scrollbar_marker_state.dirty = true; cx.notify(); @@ -21250,7 +21253,6 @@ impl Editor { ) -> Vec<(Range, Hsla)> { let mut results = Vec::new(); for (color_fetcher, ranges) in self.background_highlights.values() { - let color = color_fetcher(theme); let start_ix = match ranges.binary_search_by(|probe| { let cmp = probe .end @@ -21263,7 +21265,7 @@ impl Editor { }) { Ok(i) | Err(i) => i, }; - for range in &ranges[start_ix..] { + for (index, range) in ranges[start_ix..].iter().enumerate() { if range .start .cmp(&search_range.end, &display_snapshot.buffer_snapshot()) @@ -21272,6 +21274,7 @@ impl Editor { break; } + let color = color_fetcher(&(start_ix + index), theme); let start = range.start.to_display_point(display_snapshot); let end = range.end.to_display_point(display_snapshot); results.push((start..end, color)) diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rs index d95f0f78bf8acea8703bb7780ca842f037850d64..011715804665563b9588da28bad3137120f9c4c3 100644 --- a/crates/editor/src/editor_tests.rs +++ b/crates/editor/src/editor_tests.rs @@ -16978,7 +16978,7 @@ fn test_highlighted_ranges(cx: &mut TestAppContext) { anchor_range(Point::new(6, 3)..Point::new(6, 5)), anchor_range(Point::new(8, 4)..Point::new(8, 6)), ], - |_| Hsla::red(), + |_, _| Hsla::red(), cx, ); editor.highlight_background::( @@ -16988,7 +16988,7 @@ fn test_highlighted_ranges(cx: &mut TestAppContext) { anchor_range(Point::new(7, 4)..Point::new(7, 7)), anchor_range(Point::new(9, 5)..Point::new(9, 8)), ], - |_| Hsla::green(), + |_, _| Hsla::green(), cx, ); @@ -23973,7 +23973,7 @@ async fn test_rename_with_duplicate_edits(cx: &mut TestAppContext) { let highlight_range = highlight_range.to_anchors(&editor.buffer().read(cx).snapshot(cx)); editor.highlight_background::( &[highlight_range], - |theme| theme.colors().editor_document_highlight_read_background, + |_, theme| theme.colors().editor_document_highlight_read_background, cx, ); }); @@ -24051,7 +24051,7 @@ async fn test_rename_without_prepare(cx: &mut TestAppContext) { let highlight_range = highlight_range.to_anchors(&editor.buffer().read(cx).snapshot(cx)); editor.highlight_background::( &[highlight_range], - |theme| theme.colors().editor_document_highlight_read_background, + |_, theme| theme.colors().editor_document_highlight_read_background, cx, ); }); @@ -27299,7 +27299,7 @@ let result = variable * 2;", editor.highlight_background::( &anchor_ranges, - |theme| theme.colors().editor_document_highlight_read_background, + |_, theme| theme.colors().editor_document_highlight_read_background, cx, ); }); diff --git a/crates/editor/src/hover_popover.rs b/crates/editor/src/hover_popover.rs index 0b9a25d3ee0fcb1cb67497bf51fe41ed73a3692e..caabe6e6f5ab6ae80b3ead9d72fdcbec59937ff6 100644 --- a/crates/editor/src/hover_popover.rs +++ b/crates/editor/src/hover_popover.rs @@ -518,7 +518,7 @@ fn show_hover( // Highlight the selected symbol using a background highlight editor.highlight_background::( &hover_highlights, - |theme| theme.colors().element_hover, // todo update theme + |_, theme| theme.colors().element_hover, // todo update theme cx, ); } diff --git a/crates/editor/src/items.rs b/crates/editor/src/items.rs index 4e1305866ee9e4219295c02bdc519b4bc857cddf..ca8937bebe3d3578c7fe2fdec2c6252bdd395e6d 100644 --- a/crates/editor/src/items.rs +++ b/crates/editor/src/items.rs @@ -1487,6 +1487,7 @@ impl SearchableItem for Editor { fn update_matches( &mut self, matches: &[Range], + active_match_index: Option, _: &mut Window, cx: &mut Context, ) { @@ -1497,7 +1498,13 @@ impl SearchableItem for Editor { let updated = existing_range != Some(matches); self.highlight_background::( matches, - |theme| theme.colors().search_match_background, + move |index, theme| { + if active_match_index == Some(*index) { + theme.colors().search_active_match_background + } else { + theme.colors().search_match_background + } + }, cx, ); if updated { diff --git a/crates/language_tools/src/lsp_log_view.rs b/crates/language_tools/src/lsp_log_view.rs index 4295985b5f846cbf1ff87a1012042ee6b6608945..314dcc0b9bde998a0fec65b2847ae13641f0d011 100644 --- a/crates/language_tools/src/lsp_log_view.rs +++ b/crates/language_tools/src/lsp_log_view.rs @@ -805,11 +805,13 @@ impl SearchableItem for LspLogView { fn update_matches( &mut self, matches: &[Self::Match], + active_match_index: Option, window: &mut Window, cx: &mut Context, ) { - self.editor - .update(cx, |e, cx| e.update_matches(matches, window, cx)) + self.editor.update(cx, |e, cx| { + e.update_matches(matches, active_match_index, window, cx) + }) } fn query_suggestion(&mut self, window: &mut Window, cx: &mut Context) -> String { diff --git a/crates/language_tools/src/syntax_tree_view.rs b/crates/language_tools/src/syntax_tree_view.rs index c06ecd21e7f2eb86b4114ec2671f38297fd5fa25..0fbcdcca5eca80a01738888266389db5a678f3e8 100644 --- a/crates/language_tools/src/syntax_tree_view.rs +++ b/crates/language_tools/src/syntax_tree_view.rs @@ -459,7 +459,7 @@ impl SyntaxTreeView { editor.clear_background_highlights::(cx); editor.highlight_background::( &[range], - |theme| { + |_, theme| { theme .colors() .editor_document_highlight_write_background diff --git a/crates/search/src/buffer_search.rs b/crates/search/src/buffer_search.rs index d17efa635074f7898ab3ea829f3418e2ddd09934..a9c26ac9bad0f524acdb47d6f09c2bd67cb8dfc6 100644 --- a/crates/search/src/buffer_search.rs +++ b/crates/search/src/buffer_search.rs @@ -1031,7 +1031,7 @@ impl BufferSearchBar { let new_match_index = searchable_item .match_index_for_direction(matches, index, direction, count, window, cx); - searchable_item.update_matches(matches, window, cx); + searchable_item.update_matches(matches, Some(new_match_index), window, cx); searchable_item.activate_match(new_match_index, matches, window, cx); } } @@ -1045,7 +1045,7 @@ impl BufferSearchBar { if matches.is_empty() { return; } - searchable_item.update_matches(matches, window, cx); + searchable_item.update_matches(matches, Some(0), window, cx); searchable_item.activate_match(0, matches, window, cx); } } @@ -1060,7 +1060,7 @@ impl BufferSearchBar { return; } let new_match_index = matches.len() - 1; - searchable_item.update_matches(matches, window, cx); + searchable_item.update_matches(matches, Some(new_match_index), window, cx); searchable_item.activate_match(new_match_index, matches, window, cx); } } @@ -1300,7 +1300,12 @@ impl BufferSearchBar { if matches.is_empty() { active_searchable_item.clear_matches(window, cx); } else { - active_searchable_item.update_matches(matches, window, cx); + active_searchable_item.update_matches( + matches, + this.active_match_index, + window, + cx, + ); } let _ = done_tx.send(()); } @@ -1335,6 +1340,18 @@ impl BufferSearchBar { }); if new_index != self.active_match_index { self.active_match_index = new_index; + if !self.dismissed { + if let Some(searchable_item) = self.active_searchable_item.as_ref() { + if let Some(matches) = self + .searchable_items_with_matches + .get(&searchable_item.downgrade()) + { + if !matches.is_empty() { + searchable_item.update_matches(matches, new_index, window, cx); + } + } + } + } cx.notify(); } } diff --git a/crates/search/src/project_search.rs b/crates/search/src/project_search.rs index 2bd994754aa50ed01d4808455e40b5248bb11e19..41de3246532d6fcfe781f9c5c1d2c250f0cae93e 100644 --- a/crates/search/src/project_search.rs +++ b/crates/search/src/project_search.rs @@ -1444,6 +1444,7 @@ impl ProjectSearchView { s.select_ranges([range_to_select]) }); }); + self.highlight_matches(&match_ranges, Some(new_index), cx); } } @@ -1518,11 +1519,6 @@ impl ProjectSearchView { }); editor.scroll(Point::default(), Some(Axis::Vertical), window, cx); } - editor.highlight_background::( - &match_ranges, - |theme| theme.colors().search_match_background, - cx, - ); }); if is_new_search && self.query_editor.focus_handle(cx).is_focused(window) { self.focus_results_editor(window, cx); @@ -1535,18 +1531,41 @@ impl ProjectSearchView { fn update_match_index(&mut self, cx: &mut Context) { let results_editor = self.results_editor.read(cx); + let match_ranges = self.entity.read(cx).match_ranges.clone(); let new_index = active_match_index( Direction::Next, - &self.entity.read(cx).match_ranges, + &match_ranges, &results_editor.selections.newest_anchor().head(), &results_editor.buffer().read(cx).snapshot(cx), ); + self.highlight_matches(&match_ranges, new_index, cx); if self.active_match_index != new_index { self.active_match_index = new_index; cx.notify(); } } + fn highlight_matches( + &self, + match_ranges: &[Range], + active_index: Option, + cx: &mut Context, + ) { + self.results_editor.update(cx, |editor, cx| { + editor.highlight_background::( + match_ranges, + move |index, theme| { + if active_index == Some(*index) { + theme.colors().search_active_match_background + } else { + theme.colors().search_match_background + } + }, + cx, + ); + }); + } + pub fn has_matches(&self) -> bool { self.active_match_index.is_some() } @@ -2456,7 +2475,9 @@ pub mod tests { use pretty_assertions::assert_eq; use project::FakeFs; use serde_json::json; - use settings::{InlayHintSettingsContent, SettingsStore}; + use settings::{ + InlayHintSettingsContent, SettingsStore, ThemeColorsContent, ThemeStyleContent, + }; use util::{path, paths::PathStyle, rel_path::rel_path}; use util_macros::perf; use workspace::DeploySearch; @@ -2464,8 +2485,105 @@ pub mod tests { #[perf] #[gpui::test] async fn test_project_search(cx: &mut TestAppContext) { + fn dp(row: u32, col: u32) -> DisplayPoint { + DisplayPoint::new(DisplayRow(row), col) + } + + fn assert_active_match_index( + search_view: &WindowHandle, + cx: &mut TestAppContext, + expected_index: usize, + ) { + search_view + .update(cx, |search_view, _window, _cx| { + assert_eq!(search_view.active_match_index, Some(expected_index)); + }) + .unwrap(); + } + + fn assert_selection_range( + search_view: &WindowHandle, + cx: &mut TestAppContext, + expected_range: Range, + ) { + search_view + .update(cx, |search_view, _window, cx| { + assert_eq!( + search_view.results_editor.update(cx, |editor, cx| editor + .selections + .display_ranges(&editor.display_snapshot(cx))), + [expected_range] + ); + }) + .unwrap(); + } + + fn assert_highlights( + search_view: &WindowHandle, + cx: &mut TestAppContext, + expected_highlights: Vec<(Range, &str)>, + ) { + search_view + .update(cx, |search_view, window, cx| { + let match_bg = cx.theme().colors().search_match_background; + let active_match_bg = cx.theme().colors().search_active_match_background; + let selection_bg = cx + .theme() + .colors() + .editor_document_highlight_bracket_background; + + let highlights: Vec<_> = expected_highlights + .into_iter() + .map(|(range, color_type)| { + let color = match color_type { + "active" => active_match_bg, + "match" => match_bg, + "selection" => selection_bg, + _ => panic!("Unknown color type"), + }; + (range, color) + }) + .collect(); + + assert_eq!( + search_view.results_editor.update(cx, |editor, cx| editor + .all_text_background_highlights(window, cx)), + highlights.as_slice() + ); + }) + .unwrap(); + } + + fn select_match( + search_view: &WindowHandle, + cx: &mut TestAppContext, + direction: Direction, + ) { + search_view + .update(cx, |search_view, window, cx| { + search_view.select_match(direction, window, cx); + }) + .unwrap(); + } + init_test(cx); + // Override active search match color since the fallback theme uses the same color + // for normal search match and active one, which can make this test less robust. + cx.update(|cx| { + SettingsStore::update_global(cx, |settings, cx| { + settings.update_user_settings(cx, |settings| { + settings.theme.experimental_theme_overrides = Some(ThemeStyleContent { + colors: ThemeColorsContent { + search_active_match_background: Some("#ff0000ff".to_string()), + ..Default::default() + }, + ..Default::default() + }); + }); + }); + }); + let fs = FakeFs::new(cx.background_executor.clone()); fs.insert_tree( path!("/dir"), @@ -2486,113 +2604,113 @@ pub mod tests { }); perform_search(search_view, "TWO", cx); - search_view.update(cx, |search_view, window, cx| { - assert_eq!( - search_view - .results_editor - .update(cx, |editor, cx| editor.display_text(cx)), - "\n\nconst THREE: usize = one::ONE + two::TWO;\n\n\nconst TWO: usize = one::ONE + one::ONE;" - ); - let match_background_color = cx.theme().colors().search_match_background; - let selection_background_color = cx.theme().colors().editor_document_highlight_bracket_background; - assert_eq!( - search_view - .results_editor - .update(cx, |editor, cx| editor.all_text_background_highlights(window, cx)), - &[ - ( - DisplayPoint::new(DisplayRow(2), 32)..DisplayPoint::new(DisplayRow(2), 35), - match_background_color - ), - ( - DisplayPoint::new(DisplayRow(2), 37)..DisplayPoint::new(DisplayRow(2), 40), - selection_background_color - ), - ( - DisplayPoint::new(DisplayRow(2), 37)..DisplayPoint::new(DisplayRow(2), 40), - match_background_color - ), - ( - DisplayPoint::new(DisplayRow(5), 6)..DisplayPoint::new(DisplayRow(5), 9), - match_background_color - ), - - ] - ); - assert_eq!(search_view.active_match_index, Some(0)); - assert_eq!( - search_view - .results_editor - .update(cx, |editor, cx| editor.selections.display_ranges(&editor.display_snapshot(cx))), - [DisplayPoint::new(DisplayRow(2), 32)..DisplayPoint::new(DisplayRow(2), 35)] - ); - - search_view.select_match(Direction::Next, window, cx); - }).unwrap(); + cx.run_until_parked(); search_view - .update(cx, |search_view, window, cx| { - assert_eq!(search_view.active_match_index, Some(1)); + .update(cx, |search_view, _window, cx| { assert_eq!( - search_view.results_editor.update(cx, |editor, cx| editor - .selections - .display_ranges(&editor.display_snapshot(cx))), - [DisplayPoint::new(DisplayRow(2), 37)..DisplayPoint::new(DisplayRow(2), 40)] + search_view + .results_editor + .update(cx, |editor, cx| editor.display_text(cx)), + "\n\nconst THREE: usize = one::ONE + two::TWO;\n\n\nconst TWO: usize = one::ONE + one::ONE;" ); - search_view.select_match(Direction::Next, window, cx); }) .unwrap(); - search_view - .update(cx, |search_view, window, cx| { - assert_eq!(search_view.active_match_index, Some(2)); - assert_eq!( - search_view.results_editor.update(cx, |editor, cx| editor - .selections - .display_ranges(&editor.display_snapshot(cx))), - [DisplayPoint::new(DisplayRow(5), 6)..DisplayPoint::new(DisplayRow(5), 9)] - ); - search_view.select_match(Direction::Next, window, cx); - }) - .unwrap(); + assert_active_match_index(&search_view, cx, 0); + assert_selection_range(&search_view, cx, dp(2, 32)..dp(2, 35)); + assert_highlights( + &search_view, + cx, + vec![ + (dp(2, 32)..dp(2, 35), "active"), + (dp(2, 37)..dp(2, 40), "selection"), + (dp(2, 37)..dp(2, 40), "match"), + (dp(5, 6)..dp(5, 9), "match"), + // TODO: we should be getting selection highlight here after project search + // but for some reason we are not getting it here + ], + ); + select_match(&search_view, cx, Direction::Next); + cx.run_until_parked(); - search_view - .update(cx, |search_view, window, cx| { - assert_eq!(search_view.active_match_index, Some(0)); - assert_eq!( - search_view.results_editor.update(cx, |editor, cx| editor - .selections - .display_ranges(&editor.display_snapshot(cx))), - [DisplayPoint::new(DisplayRow(2), 32)..DisplayPoint::new(DisplayRow(2), 35)] - ); - search_view.select_match(Direction::Prev, window, cx); - }) - .unwrap(); + assert_active_match_index(&search_view, cx, 1); + assert_selection_range(&search_view, cx, dp(2, 37)..dp(2, 40)); + assert_highlights( + &search_view, + cx, + vec![ + (dp(2, 32)..dp(2, 35), "selection"), + (dp(2, 32)..dp(2, 35), "match"), + (dp(2, 37)..dp(2, 40), "active"), + (dp(5, 6)..dp(5, 9), "selection"), + (dp(5, 6)..dp(5, 9), "match"), + ], + ); + select_match(&search_view, cx, Direction::Next); + cx.run_until_parked(); - search_view - .update(cx, |search_view, window, cx| { - assert_eq!(search_view.active_match_index, Some(2)); - assert_eq!( - search_view.results_editor.update(cx, |editor, cx| editor - .selections - .display_ranges(&editor.display_snapshot(cx))), - [DisplayPoint::new(DisplayRow(5), 6)..DisplayPoint::new(DisplayRow(5), 9)] - ); - search_view.select_match(Direction::Prev, window, cx); - }) - .unwrap(); + assert_active_match_index(&search_view, cx, 2); + assert_selection_range(&search_view, cx, dp(5, 6)..dp(5, 9)); + assert_highlights( + &search_view, + cx, + vec![ + (dp(2, 32)..dp(2, 35), "selection"), + (dp(2, 32)..dp(2, 35), "match"), + (dp(2, 37)..dp(2, 40), "selection"), + (dp(2, 37)..dp(2, 40), "match"), + (dp(5, 6)..dp(5, 9), "active"), + ], + ); + select_match(&search_view, cx, Direction::Next); + cx.run_until_parked(); - search_view - .update(cx, |search_view, _, cx| { - assert_eq!(search_view.active_match_index, Some(1)); - assert_eq!( - search_view.results_editor.update(cx, |editor, cx| editor - .selections - .display_ranges(&editor.display_snapshot(cx))), - [DisplayPoint::new(DisplayRow(2), 37)..DisplayPoint::new(DisplayRow(2), 40)] - ); - }) - .unwrap(); + assert_active_match_index(&search_view, cx, 0); + assert_selection_range(&search_view, cx, dp(2, 32)..dp(2, 35)); + assert_highlights( + &search_view, + cx, + vec![ + (dp(2, 32)..dp(2, 35), "active"), + (dp(2, 37)..dp(2, 40), "selection"), + (dp(2, 37)..dp(2, 40), "match"), + (dp(5, 6)..dp(5, 9), "selection"), + (dp(5, 6)..dp(5, 9), "match"), + ], + ); + select_match(&search_view, cx, Direction::Prev); + cx.run_until_parked(); + + assert_active_match_index(&search_view, cx, 2); + assert_selection_range(&search_view, cx, dp(5, 6)..dp(5, 9)); + assert_highlights( + &search_view, + cx, + vec![ + (dp(2, 32)..dp(2, 35), "selection"), + (dp(2, 32)..dp(2, 35), "match"), + (dp(2, 37)..dp(2, 40), "selection"), + (dp(2, 37)..dp(2, 40), "match"), + (dp(5, 6)..dp(5, 9), "active"), + ], + ); + select_match(&search_view, cx, Direction::Prev); + cx.run_until_parked(); + + assert_active_match_index(&search_view, cx, 1); + assert_selection_range(&search_view, cx, dp(2, 37)..dp(2, 40)); + assert_highlights( + &search_view, + cx, + vec![ + (dp(2, 32)..dp(2, 35), "selection"), + (dp(2, 32)..dp(2, 35), "match"), + (dp(2, 37)..dp(2, 40), "active"), + (dp(5, 6)..dp(5, 9), "selection"), + (dp(5, 6)..dp(5, 9), "match"), + ], + ); } #[perf] diff --git a/crates/settings/src/settings_content/theme.rs b/crates/settings/src/settings_content/theme.rs index 49942634af3da9f7009ba02ca6cbf79c30ddaa13..94045b75a1112af64ed56de318d4e27c392a230e 100644 --- a/crates/settings/src/settings_content/theme.rs +++ b/crates/settings/src/settings_content/theme.rs @@ -570,6 +570,9 @@ pub struct ThemeColorsContent { #[serde(rename = "search.match_background")] pub search_match_background: Option, + #[serde(rename = "search.active_match_background")] + pub search_active_match_background: Option, + #[serde(rename = "panel.background")] pub panel_background: Option, diff --git a/crates/terminal_view/src/terminal_view.rs b/crates/terminal_view/src/terminal_view.rs index 2a5213ce7ebc3326c7f4a0b5a8291e098e65cd78..4d567d902ff4f9271a0bdcf6a4db94d0e3a34ec6 100644 --- a/crates/terminal_view/src/terminal_view.rs +++ b/crates/terminal_view/src/terminal_view.rs @@ -1434,6 +1434,7 @@ impl SearchableItem for TerminalView { fn update_matches( &mut self, matches: &[Self::Match], + _active_match_index: Option, _window: &mut Window, cx: &mut Context, ) { diff --git a/crates/theme/src/default_colors.rs b/crates/theme/src/default_colors.rs index 50da8c72b63443f2c70df59ccb9f5f5caf777ca8..82be2896c67f155ac61de1ca6afb058adbf5ea9c 100644 --- a/crates/theme/src/default_colors.rs +++ b/crates/theme/src/default_colors.rs @@ -91,6 +91,7 @@ impl ThemeColors { tab_inactive_background: neutral().light().step_2(), tab_active_background: neutral().light().step_1(), search_match_background: neutral().light().step_5(), + search_active_match_background: neutral().light().step_7(), panel_background: neutral().light().step_2(), panel_focused_border: blue().light().step_10(), panel_indent_guide: neutral().light_alpha().step_5(), @@ -228,6 +229,7 @@ impl ThemeColors { tab_inactive_background: neutral().dark().step_2(), tab_active_background: neutral().dark().step_1(), search_match_background: neutral().dark().step_5(), + search_active_match_background: neutral().dark().step_3(), panel_background: neutral().dark().step_2(), panel_focused_border: blue().dark().step_8(), panel_indent_guide: neutral().dark_alpha().step_4(), diff --git a/crates/theme/src/fallback_themes.rs b/crates/theme/src/fallback_themes.rs index 2351ed6bcbd2297ebb5a173d17c095d92bb27c20..6bfcb1c86811136388eb5a557458f88c65d0ac09 100644 --- a/crates/theme/src/fallback_themes.rs +++ b/crates/theme/src/fallback_themes.rs @@ -152,6 +152,7 @@ pub(crate) fn zed_default_dark() -> Theme { tab_inactive_background: bg, tab_active_background: editor, search_match_background: bg, + search_active_match_background: bg, editor_background: editor, editor_gutter_background: editor, diff --git a/crates/theme/src/schema.rs b/crates/theme/src/schema.rs index 9c9cfbffef681890a802d21b8bcff85d358a64b8..f52b2cf0e50bc5d8b26de9457432aba9218a17b9 100644 --- a/crates/theme/src/schema.rs +++ b/crates/theme/src/schema.rs @@ -287,6 +287,15 @@ pub fn theme_colors_refinement( .panel_background .as_ref() .and_then(|color| try_parse_color(color).ok()); + let search_match_background = this + .search_match_background + .as_ref() + .and_then(|color| try_parse_color(color).ok()); + let search_active_match_background = this + .search_active_match_background + .as_ref() + .and_then(|color| try_parse_color(color).ok()) + .or(search_match_background); ThemeColorsRefinement { border, border_variant: this @@ -442,10 +451,8 @@ pub fn theme_colors_refinement( .tab_active_background .as_ref() .and_then(|color| try_parse_color(color).ok()), - search_match_background: this - .search_match_background - .as_ref() - .and_then(|color| try_parse_color(color).ok()), + search_match_background: search_match_background, + search_active_match_background: search_active_match_background, panel_background, panel_focused_border: this .panel_focused_border diff --git a/crates/theme/src/styles/colors.rs b/crates/theme/src/styles/colors.rs index c6766ca955700e2b7c3cd0e86ab16535fca8d852..905f2245e03ad7a8ce7a4eb8be6799e5ded379c4 100644 --- a/crates/theme/src/styles/colors.rs +++ b/crates/theme/src/styles/colors.rs @@ -128,6 +128,7 @@ pub struct ThemeColors { pub tab_inactive_background: Hsla, pub tab_active_background: Hsla, pub search_match_background: Hsla, + pub search_active_match_background: Hsla, pub panel_background: Hsla, pub panel_focused_border: Hsla, pub panel_indent_guide: Hsla, @@ -352,6 +353,7 @@ pub enum ThemeColorField { TabInactiveBackground, TabActiveBackground, SearchMatchBackground, + SearchActiveMatchBackground, PanelBackground, PanelFocusedBorder, PanelIndentGuide, @@ -467,6 +469,7 @@ impl ThemeColors { ThemeColorField::TabInactiveBackground => self.tab_inactive_background, ThemeColorField::TabActiveBackground => self.tab_active_background, ThemeColorField::SearchMatchBackground => self.search_match_background, + ThemeColorField::SearchActiveMatchBackground => self.search_active_match_background, ThemeColorField::PanelBackground => self.panel_background, ThemeColorField::PanelFocusedBorder => self.panel_focused_border, ThemeColorField::PanelIndentGuide => self.panel_indent_guide, diff --git a/crates/vim/src/normal/yank.rs b/crates/vim/src/normal/yank.rs index 71ed0d44384a5ed8644f486aa16cdd704e9ce944..81350d780a507a6e1d2502cf0f05115dc19abcdf 100644 --- a/crates/vim/src/normal/yank.rs +++ b/crates/vim/src/normal/yank.rs @@ -227,7 +227,7 @@ impl Vim { editor.highlight_background::( &ranges_to_highlight, - |colors| colors.colors().editor_document_highlight_read_background, + |_, colors| colors.colors().editor_document_highlight_read_background, cx, ); cx.spawn(async move |this, cx| { diff --git a/crates/vim/src/replace.rs b/crates/vim/src/replace.rs index 93c30141daeac21805e8ea1aab610988a09a9635..63d452f84bfd5ee1cea8970698962169dc8fe94a 100644 --- a/crates/vim/src/replace.rs +++ b/crates/vim/src/replace.rs @@ -273,7 +273,7 @@ impl Vim { let ranges = [new_range]; editor.highlight_background::( &ranges, - |theme| theme.colors().editor_document_highlight_read_background, + |_, theme| theme.colors().editor_document_highlight_read_background, cx, ); } diff --git a/crates/workspace/src/searchable.rs b/crates/workspace/src/searchable.rs index 64dad0345fa323eb724b6b51656b841c8d433688..badfe7d2437424c1ce18a1afde19507e7d6e1d3b 100644 --- a/crates/workspace/src/searchable.rs +++ b/crates/workspace/src/searchable.rs @@ -96,6 +96,7 @@ pub trait SearchableItem: Item + EventEmitter { fn update_matches( &mut self, matches: &[Self::Match], + active_match_index: Option, window: &mut Window, cx: &mut Context, ); @@ -179,7 +180,13 @@ pub trait SearchableItemHandle: ItemHandle { handler: Box, ) -> Subscription; fn clear_matches(&self, window: &mut Window, cx: &mut App); - fn update_matches(&self, matches: &AnyVec, window: &mut Window, cx: &mut App); + fn update_matches( + &self, + matches: &AnyVec, + active_match_index: Option, + window: &mut Window, + cx: &mut App, + ); fn query_suggestion(&self, window: &mut Window, cx: &mut App) -> String; fn activate_match( &self, @@ -264,10 +271,16 @@ impl SearchableItemHandle for Entity { fn clear_matches(&self, window: &mut Window, cx: &mut App) { self.update(cx, |this, cx| this.clear_matches(window, cx)); } - fn update_matches(&self, matches: &AnyVec, window: &mut Window, cx: &mut App) { + fn update_matches( + &self, + matches: &AnyVec, + active_match_index: Option, + window: &mut Window, + cx: &mut App, + ) { let matches = matches.downcast_ref().unwrap(); self.update(cx, |this, cx| { - this.update_matches(matches.as_slice(), window, cx) + this.update_matches(matches.as_slice(), active_match_index, window, cx) }); } fn query_suggestion(&self, window: &mut Window, cx: &mut App) -> String { From 40a611bf34bf73f2149f133a6c332276f58d2248 Mon Sep 17 00:00:00 2001 From: Andrew Farkas <6060305+HactarCE@users.noreply.github.com> Date: Wed, 3 Dec 2025 17:49:44 -0500 Subject: [PATCH 044/621] tab_switcher: Subscribe to workspace events instead of pane events (#44101) Closes #43171 Previously the tab switcher only subscribed to events from a single pane so closing tabs in other panes wouldn't cause the tab switcher to update. This PR changes that so the tab switcher subscribes to the whole workspace and thus updates when tabs in other panes are closed. It also modifies the work in #44006 to sync selected index across the whole workspace instead of just the original pane in the case of the all-panes tab switcher. Release Notes: - Fixed all-panes tab switcher not updating in response to changes in other panes --- crates/tab_switcher/src/tab_switcher.rs | 49 +++++++++++++++---------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/crates/tab_switcher/src/tab_switcher.rs b/crates/tab_switcher/src/tab_switcher.rs index 2b98f6c7e329e7f98edb6b6e994de444a8b835da..85186ad504eb098264aae64ba3c2354d20d011a4 100644 --- a/crates/tab_switcher/src/tab_switcher.rs +++ b/crates/tab_switcher/src/tab_switcher.rs @@ -23,9 +23,9 @@ use ui::{ }; use util::ResultExt; use workspace::{ - ModalView, Pane, SaveIntent, Workspace, + Event as WorkspaceEvent, ModalView, Pane, SaveIntent, Workspace, item::{ItemHandle, ItemSettings, ShowDiagnostics, TabContentParams}, - pane::{Event as PaneEvent, render_item_indicator, tab_details}, + pane::{render_item_indicator, tab_details}, }; const PANEL_WIDTH_REMS: f32 = 28.; @@ -322,7 +322,7 @@ impl TabSwitcherDelegate { cx: &mut Context, original_items: Vec<(Entity, usize)>, ) -> Self { - Self::subscribe_to_updates(&pane, window, cx); + Self::subscribe_to_updates(&workspace, window, cx); Self { select_last, tab_switcher, @@ -338,34 +338,36 @@ impl TabSwitcherDelegate { } fn subscribe_to_updates( - pane: &WeakEntity, + workspace: &WeakEntity, window: &mut Window, cx: &mut Context, ) { - let Some(pane) = pane.upgrade() else { + let Some(workspace) = workspace.upgrade() else { return; }; - cx.subscribe_in(&pane, window, |tab_switcher, _, event, window, cx| { + cx.subscribe_in(&workspace, window, |tab_switcher, _, event, window, cx| { match event { - PaneEvent::AddItem { .. } | PaneEvent::Remove { .. } => { + WorkspaceEvent::ItemAdded { .. } | WorkspaceEvent::PaneRemoved => { tab_switcher.picker.update(cx, |picker, cx| { let query = picker.query(cx); picker.delegate.update_matches(query, window, cx); cx.notify(); }) } - PaneEvent::RemovedItem { .. } => tab_switcher.picker.update(cx, |picker, cx| { - let query = picker.query(cx); - picker.delegate.update_matches(query, window, cx); - - // When the Tab Switcher is being used and an item is - // removed, there's a chance that the new selected index - // will not match the actual tab that is now being displayed - // by the pane, as such, the selected index needs to be - // updated to match the pane's state. - picker.delegate.sync_selected_index(cx); - cx.notify(); - }), + WorkspaceEvent::ItemRemoved { .. } => { + tab_switcher.picker.update(cx, |picker, cx| { + let query = picker.query(cx); + picker.delegate.update_matches(query, window, cx); + + // When the Tab Switcher is being used and an item is + // removed, there's a chance that the new selected index + // will not match the actual tab that is now being displayed + // by the pane, as such, the selected index needs to be + // updated to match the pane's state. + picker.delegate.sync_selected_index(cx); + cx.notify(); + }) + } _ => {} }; }) @@ -563,7 +565,14 @@ impl TabSwitcherDelegate { /// as the pane's active item can be indirectly updated and this method /// ensures that the picker can react to those changes. fn sync_selected_index(&mut self, cx: &mut Context>) { - let Ok(Some(item)) = self.pane.read_with(cx, |pane, _cx| pane.active_item()) else { + let item = if self.is_all_panes { + self.workspace + .read_with(cx, |workspace, cx| workspace.active_item(cx)) + } else { + self.pane.read_with(cx, |pane, _cx| pane.active_item()) + }; + + let Ok(Some(item)) = item else { return; }; From f90d9d26a55eb4730cd700c6814c6cee73bd94d7 Mon Sep 17 00:00:00 2001 From: "Joseph T. Lyons" Date: Wed, 3 Dec 2025 17:56:51 -0500 Subject: [PATCH 045/621] Prefer to disable options over hiding (git panel entry context menu) (#44102) When adding the File History option here, I used the pattern to hide the option, since that's what another option was already doing here, but I see other menus in the git panel (`...`) that use disabling over hiding, which is what I think is a nicer experience (allows you to learn of actions, the full range of actions is always visible, don't have to worry about how multiple hidden items might interact in various configurations, etc). SCR-20251203-pnpy SCR-20251203-pobg In general, I think it would be good to move to being more consistent with disabling over hiding - there are other places in the app that are hiding - some might be valid, but others might just choices made on a whim. Release Notes: - N/A --- crates/git_ui/src/git_panel.rs | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs index 1c9b817be2507f806eab505555163f72b2fd148a..62bd118daf1751e32dd0b805a773be47e19e4357 100644 --- a/crates/git_ui/src/git_panel.rs +++ b/crates/git_ui/src/git_panel.rs @@ -4004,28 +4004,21 @@ impl GitPanel { "Restore File" }; let context_menu = ContextMenu::build(window, cx, |context_menu, _, _| { - let mut context_menu = context_menu + let is_created = entry.status.is_created(); + context_menu .context(self.focus_handle.clone()) .action(stage_title, ToggleStaged.boxed_clone()) - .action(restore_title, git::RestoreFile::default().boxed_clone()); - - if entry.status.is_created() { - context_menu = - context_menu.action("Add to .gitignore", git::AddToGitignore.boxed_clone()) - } - - context_menu = context_menu + .action(restore_title, git::RestoreFile::default().boxed_clone()) + .action_disabled_when( + !is_created, + "Add to .gitignore", + git::AddToGitignore.boxed_clone(), + ) .separator() .action("Open Diff", Confirm.boxed_clone()) - .action("Open File", SecondaryConfirm.boxed_clone()); - - if !entry.status.is_created() { - context_menu = context_menu - .separator() - .action("File History", Box::new(git::FileHistory)); - } - - context_menu + .action("Open File", SecondaryConfirm.boxed_clone()) + .separator() + .action_disabled_when(is_created, "File History", Box::new(git::FileHistory)) }); self.selected_entry = Some(ix); self.set_context_menu(context_menu, position, window, cx); From 1e4d80a21f6bce80aff18f6d2f1b2ae41f527dc0 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Thu, 4 Dec 2025 00:29:31 -0700 Subject: [PATCH 046/621] Update fancy-regex (#44120) Fancy regex has a max backtracking limit which defaults to 1,000,000 backtracks. This avoids spinning the CPU forever in the case that a match is taking a long time (though does mean that some matches may be missed). Unfortunately the verison we depended on causes an infinite loop when the backtracking limit is hit (https://github.com/fancy-regex/fancy-regex/issues/137), so we got the worse of both worlds: matches were missed *and* we spun the CPU forever. Updating fixes this. Excitingly regex may gain support for lookarounds (https://github.com/rust-lang/regex/pull/1315), which will make fancy-regex much less load bearing. Closes #43821 Release Notes: - Fix a bug where search regexes with look-around or backreferences could hang the CPU. They will now abort after a certain number of match attempts. --- Cargo.lock | 88 +++++++++++++++++++++++++----------------------------- Cargo.toml | 6 ++-- 2 files changed, 43 insertions(+), 51 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 03b7339856a9adba3538152ac3874fd0dec859b5..5078c79e21ce1a580a6e055a7ce8ab4295f56906 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2130,30 +2130,15 @@ dependencies = [ "syn 2.0.106", ] -[[package]] -name = "bit-set" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1" -dependencies = [ - "bit-vec 0.6.3", -] - [[package]] name = "bit-set" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08807e080ed7f9d5433fa9b275196cfc35414f66a0c79d864dc51a0d825231a3" dependencies = [ - "bit-vec 0.8.0", + "bit-vec", ] -[[package]] -name = "bit-vec" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" - [[package]] name = "bit-vec" version = "0.8.0" @@ -2332,9 +2317,9 @@ dependencies = [ [[package]] name = "borrow-or-share" -version = "0.2.2" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3eeab4423108c5d7c744f4d234de88d18d636100093ae04caf4825134b9c3a32" +checksum = "dc0b364ead1874514c8c2855ab558056ebfeb775653e7ae45ff72f28f8f3166c" [[package]] name = "borsh" @@ -6008,22 +5993,11 @@ checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a" [[package]] name = "fancy-regex" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "531e46835a22af56d1e3b66f04844bed63158bc094a628bec1d321d9b4c44bf2" -dependencies = [ - "bit-set 0.5.3", - "regex-automata", - "regex-syntax", -] - -[[package]] -name = "fancy-regex" -version = "0.14.0" +version = "0.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e24cb5a94bcae1e5408b0effca5cd7172ea3c5755049c5f3af4cd283a165298" +checksum = "998b056554fbe42e03ae0e152895cd1a7e1002aec800fdc6635d20270260c46f" dependencies = [ - "bit-set 0.8.0", + "bit-set", "regex-automata", "regex-syntax", ] @@ -6245,9 +6219,9 @@ checksum = "8bf7cc16383c4b8d58b9905a8509f02926ce3058053c056376248d958c9df1e8" [[package]] name = "fluent-uri" -version = "0.3.2" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1918b65d96df47d3591bed19c5cca17e3fa5d0707318e4b5ef2eae01764df7e5" +checksum = "bc74ac4d8359ae70623506d512209619e5cf8f347124910440dbc221714b328e" dependencies = [ "borrow-or-share", "ref-cast", @@ -7543,6 +7517,17 @@ dependencies = [ "serde", ] +[[package]] +name = "hashbrown" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" +dependencies = [ + "allocator-api2", + "equivalent", + "foldhash 0.2.0", +] + [[package]] name = "hashlink" version = "0.8.4" @@ -8632,21 +8617,21 @@ dependencies = [ [[package]] name = "jsonschema" -version = "0.30.0" +version = "0.37.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1b46a0365a611fbf1d2143104dcf910aada96fafd295bab16c60b802bf6fa1d" +checksum = "73c9ffb2b5c56d58030e1b532d8e8389da94590515f118cf35b5cb68e4764a7e" dependencies = [ "ahash 0.8.12", - "base64 0.22.1", "bytecount", + "data-encoding", "email_address", - "fancy-regex 0.14.0", + "fancy-regex", "fraction", + "getrandom 0.3.4", "idna", "itoa", "num-cmp", "num-traits", - "once_cell", "percent-encoding", "referencing", "regex", @@ -8654,6 +8639,7 @@ dependencies = [ "reqwest 0.12.24", "serde", "serde_json", + "unicode-general-category", "uuid-simd", ] @@ -10202,7 +10188,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b977c445f26e49757f9aca3631c3b8b836942cb278d69a92e7b80d3b24da632" dependencies = [ "arrayvec", - "bit-set 0.8.0", + "bit-set", "bitflags 2.9.4", "cfg_aliases 0.2.1", "codespan-reporting 0.12.0", @@ -13058,7 +13044,7 @@ dependencies = [ "dap", "dap_adapters", "extension", - "fancy-regex 0.14.0", + "fancy-regex", "fs", "futures 0.3.31", "fuzzy", @@ -13929,13 +13915,14 @@ dependencies = [ [[package]] name = "referencing" -version = "0.30.0" +version = "0.37.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8eff4fa778b5c2a57e85c5f2fe3a709c52f0e60d23146e2151cbef5893f420e" +checksum = "4283168a506f0dcbdce31c9f9cce3129c924da4c6bca46e46707fcb746d2d70c" dependencies = [ "ahash 0.8.12", "fluent-uri", - "once_cell", + "getrandom 0.3.4", + "hashbrown 0.16.1", "parking_lot", "percent-encoding", "serde_json", @@ -17129,7 +17116,7 @@ dependencies = [ "alacritty_terminal", "anyhow", "collections", - "fancy-regex 0.14.0", + "fancy-regex", "futures 0.3.31", "gpui", "itertools 0.14.0", @@ -17363,12 +17350,12 @@ dependencies = [ [[package]] name = "tiktoken-rs" version = "0.9.1" -source = "git+https://github.com/zed-industries/tiktoken-rs?rev=7249f999c5fdf9bf3cc5c288c964454e4dac0c00#7249f999c5fdf9bf3cc5c288c964454e4dac0c00" +source = "git+https://github.com/zed-industries/tiktoken-rs?rev=2570c4387a8505fb8f1d3f3557454b474f1e8271#2570c4387a8505fb8f1d3f3557454b474f1e8271" dependencies = [ "anyhow", "base64 0.22.1", "bstr", - "fancy-regex 0.13.0", + "fancy-regex", "lazy_static", "regex", "rustc-hash 1.1.0", @@ -18500,6 +18487,12 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce61d488bcdc9bc8b5d1772c404828b17fc481c0a582b5581e95fb233aef503e" +[[package]] +name = "unicode-general-category" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b993bddc193ae5bd0d623b49ec06ac3e9312875fdae725a975c51db1cc1677f" + [[package]] name = "unicode-ident" version = "1.0.19" @@ -18734,7 +18727,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23b082222b4f6619906941c17eb2297fff4c2fb96cb60164170522942a200bd8" dependencies = [ "outref", - "uuid", "vsimd", ] diff --git a/Cargo.toml b/Cargo.toml index e81e53426fc9ee47000e14cb8141ce4e4b6d8b30..59b9a53d4a60b28582625fb90b64b934079cdc40 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -505,7 +505,7 @@ ec4rs = "1.1" emojis = "0.6.1" env_logger = "0.11" exec = "0.3.1" -fancy-regex = "0.14.0" +fancy-regex = "0.16.0" fork = "0.4.0" futures = "0.3" futures-batch = "0.6.1" @@ -531,7 +531,7 @@ indoc = "2" inventory = "0.3.19" itertools = "0.14.0" json_dotpath = "1.1" -jsonschema = "0.30.0" +jsonschema = "0.37.0" jsonwebtoken = "9.3" jupyter-protocol = "0.10.0" jupyter-websocket-client = "0.15.0" @@ -658,7 +658,7 @@ sysinfo = "0.37.0" take-until = "0.2.0" tempfile = "3.20.0" thiserror = "2.0.12" -tiktoken-rs = { git = "https://github.com/zed-industries/tiktoken-rs", rev = "7249f999c5fdf9bf3cc5c288c964454e4dac0c00" } +tiktoken-rs = { git = "https://github.com/zed-industries/tiktoken-rs", rev = "2570c4387a8505fb8f1d3f3557454b474f1e8271" } time = { version = "0.3", features = [ "macros", "parsing", From 391c92b07ae3f5d6fb5137b6cb727bc096e04317 Mon Sep 17 00:00:00 2001 From: John Tur Date: Thu, 4 Dec 2025 02:45:36 -0500 Subject: [PATCH 047/621] Reduce priority of Windows thread pool work items (#44121) `WorkItemPriority::High` will enqueue the work items to threads with higher-than-normal priority. If the work items are very intensive, this can cause the system to become unresponsive. It's not clear what this gets us, so let's avoid the responsiveness issue by deleting this. Release Notes: - N/A --- crates/gpui/src/platform/windows/dispatcher.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/crates/gpui/src/platform/windows/dispatcher.rs b/crates/gpui/src/platform/windows/dispatcher.rs index dd53c86f5ed687c9b22a08779f262392f44a66ce..6214e60e5b4b178c20b1fff655f4ac8b49be3f4c 100644 --- a/crates/gpui/src/platform/windows/dispatcher.rs +++ b/crates/gpui/src/platform/windows/dispatcher.rs @@ -7,9 +7,7 @@ use std::{ use flume::Sender; use util::ResultExt; use windows::{ - System::Threading::{ - ThreadPool, ThreadPoolTimer, TimerElapsedHandler, WorkItemHandler, WorkItemPriority, - }, + System::Threading::{ThreadPool, ThreadPoolTimer, TimerElapsedHandler, WorkItemHandler}, Win32::{ Foundation::{LPARAM, WPARAM}, UI::WindowsAndMessaging::PostMessageW, @@ -55,7 +53,7 @@ impl WindowsDispatcher { Ok(()) }) }; - ThreadPool::RunWithPriorityAsync(&handler, WorkItemPriority::High).log_err(); + ThreadPool::RunAsync(&handler).log_err(); } fn dispatch_on_threadpool_after(&self, runnable: RunnableVariant, duration: Duration) { From db2e26f67bf0d71b8d23b1e3d0e6e16280c005f0 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Thu, 4 Dec 2025 12:21:37 +0200 Subject: [PATCH 048/621] Re-colorize the brackets when the theme changes (#44130) Closes https://github.com/zed-industries/zed/issues/44127 Release Notes: - Fixed brackets not re-colorizing on theme change --- crates/editor/src/editor.rs | 39 ++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index f90400b2b1e07b14959d5b532c5926f7c3224dbe..05287847190691221e6f948ba53efecc7269e9be 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -191,7 +191,7 @@ use std::{ use task::{ResolvedTask, RunnableTag, TaskTemplate, TaskVariables}; use text::{BufferId, FromAnchor, OffsetUtf16, Rope, ToOffset as _}; use theme::{ - ActiveTheme, PlayerColor, StatusColors, SyntaxTheme, Theme, ThemeSettings, + AccentColors, ActiveTheme, PlayerColor, StatusColors, SyntaxTheme, Theme, ThemeSettings, observe_buffer_font_size_adjustment, }; use ui::{ @@ -1206,11 +1206,17 @@ pub struct Editor { select_next_is_case_sensitive: Option, pub lookup_key: Option>, applicable_language_settings: HashMap, LanguageSettings>, - accent_overrides: Vec, + accent_data: Option, fetched_tree_sitter_chunks: HashMap>>, use_base_text_line_numbers: bool, } +#[derive(Debug, PartialEq)] +struct AccentData { + colors: AccentColors, + overrides: Vec, +} + fn debounce_value(debounce_ms: u64) -> Option { if debounce_ms > 0 { Some(Duration::from_millis(debounce_ms)) @@ -2354,7 +2360,7 @@ impl Editor { lookup_key: None, select_next_is_case_sensitive: None, applicable_language_settings: HashMap::default(), - accent_overrides: Vec::new(), + accent_data: None, fetched_tree_sitter_chunks: HashMap::default(), use_base_text_line_numbers: false, }; @@ -2364,7 +2370,7 @@ impl Editor { } editor.applicable_language_settings = editor.fetch_applicable_language_settings(cx); - editor.accent_overrides = editor.fetch_accent_overrides(cx); + editor.accent_data = editor.fetch_accent_data(cx); if let Some(breakpoints) = editor.breakpoint_store.as_ref() { editor @@ -21706,16 +21712,18 @@ impl Editor { cx.notify(); } - fn fetch_accent_overrides(&self, cx: &App) -> Vec { + fn fetch_accent_data(&self, cx: &App) -> Option { if !self.mode.is_full() { - return Vec::new(); + return None; } let theme_settings = theme::ThemeSettings::get_global(cx); + let theme = cx.theme(); + let accent_colors = theme.accents().clone(); - theme_settings + let accent_overrides = theme_settings .theme_overrides - .get(cx.theme().name.as_ref()) + .get(theme.name.as_ref()) .map(|theme_style| &theme_style.accents) .into_iter() .flatten() @@ -21728,7 +21736,12 @@ impl Editor { .flatten(), ) .flat_map(|accent| accent.0.clone()) - .collect() + .collect(); + + Some(AccentData { + colors: accent_colors, + overrides: accent_overrides, + }) } fn fetch_applicable_language_settings( @@ -21758,9 +21771,9 @@ impl Editor { let language_settings_changed = new_language_settings != self.applicable_language_settings; self.applicable_language_settings = new_language_settings; - let new_accent_overrides = self.fetch_accent_overrides(cx); - let accent_overrides_changed = new_accent_overrides != self.accent_overrides; - self.accent_overrides = new_accent_overrides; + let new_accents = self.fetch_accent_data(cx); + let accents_changed = new_accents != self.accent_data; + self.accent_data = new_accents; if self.diagnostics_enabled() { let new_severity = EditorSettings::get_global(cx) @@ -21834,7 +21847,7 @@ impl Editor { } } - if language_settings_changed || accent_overrides_changed { + if language_settings_changed || accents_changed { self.colorize_brackets(true, cx); } From b07389d9f3b1e1c2cf5c275302438061d372a226 Mon Sep 17 00:00:00 2001 From: Aero Date: Thu, 4 Dec 2025 18:38:10 +0800 Subject: [PATCH 049/621] macos: Add missing file access entitlements (#43609) Adds `com.apple.security.files.user-selected.read-write` and `com.apple.security.files.downloads.read-write` to zed.entitlements. This resolves an issue where the integrated terminal could not access external drives or user-selected files on macOS, even when "Full Disk Access" was granted. These entitlements are required for the application to properly inherit file access permissions. Release Notes: - Resolves an issue where the integrated terminal could not access external drives or user-selected files on macOS. --- crates/zed/resources/zed.entitlements | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/zed/resources/zed.entitlements b/crates/zed/resources/zed.entitlements index cb4cd3dc692160047ae5012489a350829c4a1ccf..2a16afe7551f433e3f835a2097df61a2e9e86ee1 100644 --- a/crates/zed/resources/zed.entitlements +++ b/crates/zed/resources/zed.entitlements @@ -22,5 +22,9 @@ com.apple.security.personal-information.photos-library + com.apple.security.files.user-selected.read-write + + com.apple.security.files.downloads.read-write + From 9db0d662518c0c56547e1330d4cd63ab86c8355e Mon Sep 17 00:00:00 2001 From: Agus Zubiaga Date: Thu, 4 Dec 2025 07:40:51 -0300 Subject: [PATCH 050/621] linux: Spawn at least two background threads (#44110) Related to https://github.com/zed-industries/zed/pull/44109, https://github.com/zed-industries/zed/issues/43884, https://github.com/zed-industries/zed/issues/43809. In the Linux dispatcher, we create one background thread per CPU, but when a single core is available, having a single background thread significantly hinders the perceived performance of Zed. This is particularly helpful when SSH remoting to low-resource servers. We may want to bump this to more than two threads actually, but I wanted to be conservative, and this seems to make a big difference already. Release Notes: - N/A --- crates/gpui/src/platform/linux/dispatcher.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/gpui/src/platform/linux/dispatcher.rs b/crates/gpui/src/platform/linux/dispatcher.rs index c300109ffe32b3537acbbca47b4c39674cad2fd1..d0c32140f3642e037df326f4e2beae16c59dd883 100644 --- a/crates/gpui/src/platform/linux/dispatcher.rs +++ b/crates/gpui/src/platform/linux/dispatcher.rs @@ -26,12 +26,13 @@ pub(crate) struct LinuxDispatcher { main_thread_id: thread::ThreadId, } +const MIN_THREADS: usize = 2; + impl LinuxDispatcher { pub fn new(main_sender: Sender) -> Self { let (background_sender, background_receiver) = flume::unbounded::(); - let thread_count = std::thread::available_parallelism() - .map(|i| i.get()) - .unwrap_or(1); + let thread_count = + std::thread::available_parallelism().map_or(MIN_THREADS, |i| i.get().max(MIN_THREADS)); let mut background_threads = (0..thread_count) .map(|i| { From 0f0017dc8e7dce1ab8cfbbac337e83d79b612289 Mon Sep 17 00:00:00 2001 From: Shardul Vaidya <31039336+5herlocked@users.noreply.github.com> Date: Thu, 4 Dec 2025 06:14:31 -0500 Subject: [PATCH 051/621] bedrock: Support global endpoints and new regional endpoints (#44103) Closes #43598 Release Notes: - bedrock: Added opt-in `allow_global` which enables global endpoints - bedrock: Updated cross-region-inference endpoint and model list - bedrock: Fixed Opus 4.5 access on Bedrock, now only accessible through the `allow_global` setting --- crates/bedrock/src/models.rs | 201 +++++++++++++----- .../language_models/src/provider/bedrock.rs | 14 +- crates/language_models/src/settings.rs | 1 + .../src/settings_content/language_model.rs | 1 + docs/src/ai/llm-providers.md | 28 ++- 5 files changed, 185 insertions(+), 60 deletions(-) diff --git a/crates/bedrock/src/models.rs b/crates/bedrock/src/models.rs index f3b276a8d2f30e8062931e76608bbc3a302ad734..51e1b29f9ad3cf953605c5c59090785f3ab45eac 100644 --- a/crates/bedrock/src/models.rs +++ b/crates/bedrock/src/models.rs @@ -584,41 +584,100 @@ impl Model { } } - pub fn cross_region_inference_id(&self, region: &str) -> anyhow::Result { + pub fn cross_region_inference_id( + &self, + region: &str, + allow_global: bool, + ) -> anyhow::Result { + // List derived from here: + // https://docs.aws.amazon.com/bedrock/latest/userguide/inference-profiles-support.html#inference-profiles-support-system + let model_id = self.request_id(); + + let supports_global = matches!( + self, + Model::ClaudeOpus4_5 + | Model::ClaudeOpus4_5Thinking + | Model::ClaudeHaiku4_5 + | Model::ClaudeSonnet4 + | Model::ClaudeSonnet4Thinking + | Model::ClaudeSonnet4_5 + | Model::ClaudeSonnet4_5Thinking + ); + let region_group = if region.starts_with("us-gov-") { "us-gov" - } else if region.starts_with("us-") { - "us" + } else if region.starts_with("us-") + || region.starts_with("ca-") + || region.starts_with("sa-") + { + if allow_global && supports_global { + "global" + } else { + "us" + } } else if region.starts_with("eu-") { - "eu" + if allow_global && supports_global { + "global" + } else { + "eu" + } } else if region.starts_with("ap-") || region == "me-central-1" || region == "me-south-1" { - "apac" - } else if region.starts_with("ca-") || region.starts_with("sa-") { - // Canada and South America regions - default to US profiles - "us" + if allow_global && supports_global { + "global" + } else { + "apac" + } } else { anyhow::bail!("Unsupported Region {region}"); }; - let model_id = self.request_id(); + match (self, region_group, region) { + (Model::Custom { .. }, _, _) => Ok(self.request_id().into()), - match (self, region_group) { - // Custom models can't have CRI IDs - (Model::Custom { .. }, _) => Ok(self.request_id().into()), + ( + Model::ClaudeOpus4_5 + | Model::ClaudeOpus4_5Thinking + | Model::ClaudeHaiku4_5 + | Model::ClaudeSonnet4 + | Model::ClaudeSonnet4Thinking + | Model::ClaudeSonnet4_5 + | Model::ClaudeSonnet4_5Thinking, + "global", + _, + ) => Ok(format!("{}.{}", region_group, model_id)), - // Models with US Gov only - (Model::Claude3_5Sonnet, "us-gov") | (Model::Claude3Haiku, "us-gov") => { - Ok(format!("{}.{}", region_group, model_id)) - } + ( + Model::Claude3Haiku + | Model::Claude3_5Sonnet + | Model::Claude3_7Sonnet + | Model::Claude3_7SonnetThinking + | Model::ClaudeSonnet4_5 + | Model::ClaudeSonnet4_5Thinking, + "us-gov", + _, + ) => Ok(format!("{}.{}", region_group, model_id)), - // Available everywhere - (Model::AmazonNovaLite | Model::AmazonNovaMicro | Model::AmazonNovaPro, _) => { - Ok(format!("{}.{}", region_group, model_id)) + ( + Model::ClaudeHaiku4_5 | Model::ClaudeSonnet4_5 | Model::ClaudeSonnet4_5Thinking, + "apac", + "ap-southeast-2" | "ap-southeast-4", + ) => Ok(format!("au.{}", model_id)), + + ( + Model::ClaudeHaiku4_5 | Model::ClaudeSonnet4_5 | Model::ClaudeSonnet4_5Thinking, + "apac", + "ap-northeast-1" | "ap-northeast-3", + ) => Ok(format!("jp.{}", model_id)), + + (Model::AmazonNovaLite, "us", r) if r.starts_with("ca-") => { + Ok(format!("ca.{}", model_id)) } - // Models in US ( Model::AmazonNovaPremier + | Model::AmazonNovaLite + | Model::AmazonNovaMicro + | Model::AmazonNovaPro | Model::Claude3_5Haiku | Model::ClaudeHaiku4_5 | Model::Claude3_5Sonnet @@ -655,16 +714,18 @@ impl Model { | Model::PalmyraWriterX4 | Model::PalmyraWriterX5, "us", + _, ) => Ok(format!("{}.{}", region_group, model_id)), - // Models available in EU ( - Model::Claude3_5Sonnet + Model::AmazonNovaLite + | Model::AmazonNovaMicro + | Model::AmazonNovaPro + | Model::Claude3_5Sonnet | Model::ClaudeHaiku4_5 | Model::Claude3_7Sonnet | Model::Claude3_7SonnetThinking | Model::ClaudeSonnet4 - | Model::ClaudeSonnet4Thinking | Model::ClaudeSonnet4_5 | Model::ClaudeSonnet4_5Thinking | Model::Claude3Haiku @@ -673,26 +734,26 @@ impl Model { | Model::MetaLlama323BInstructV1 | Model::MistralPixtralLarge2502V1, "eu", + _, ) => Ok(format!("{}.{}", region_group, model_id)), - // Models available in APAC ( - Model::Claude3_5Sonnet + Model::AmazonNovaLite + | Model::AmazonNovaMicro + | Model::AmazonNovaPro + | Model::Claude3_5Sonnet | Model::Claude3_5SonnetV2 | Model::ClaudeHaiku4_5 - | Model::Claude3Haiku - | Model::Claude3Sonnet | Model::Claude3_7Sonnet | Model::Claude3_7SonnetThinking | Model::ClaudeSonnet4 - | Model::ClaudeSonnet4Thinking - | Model::ClaudeSonnet4_5 - | Model::ClaudeSonnet4_5Thinking, + | Model::Claude3Haiku + | Model::Claude3Sonnet, "apac", + _, ) => Ok(format!("{}.{}", region_group, model_id)), - // Any other combination is not supported - _ => Ok(self.request_id().into()), + _ => Ok(model_id.into()), } } } @@ -705,15 +766,15 @@ mod tests { fn test_us_region_inference_ids() -> anyhow::Result<()> { // Test US regions assert_eq!( - Model::Claude3_5SonnetV2.cross_region_inference_id("us-east-1")?, + Model::Claude3_5SonnetV2.cross_region_inference_id("us-east-1", false)?, "us.anthropic.claude-3-5-sonnet-20241022-v2:0" ); assert_eq!( - Model::Claude3_5SonnetV2.cross_region_inference_id("us-west-2")?, + Model::Claude3_5SonnetV2.cross_region_inference_id("us-west-2", false)?, "us.anthropic.claude-3-5-sonnet-20241022-v2:0" ); assert_eq!( - Model::AmazonNovaPro.cross_region_inference_id("us-east-2")?, + Model::AmazonNovaPro.cross_region_inference_id("us-east-2", false)?, "us.amazon.nova-pro-v1:0" ); Ok(()) @@ -723,19 +784,19 @@ mod tests { fn test_eu_region_inference_ids() -> anyhow::Result<()> { // Test European regions assert_eq!( - Model::ClaudeSonnet4.cross_region_inference_id("eu-west-1")?, + Model::ClaudeSonnet4.cross_region_inference_id("eu-west-1", false)?, "eu.anthropic.claude-sonnet-4-20250514-v1:0" ); assert_eq!( - Model::ClaudeSonnet4_5.cross_region_inference_id("eu-west-1")?, + Model::ClaudeSonnet4_5.cross_region_inference_id("eu-west-1", false)?, "eu.anthropic.claude-sonnet-4-5-20250929-v1:0" ); assert_eq!( - Model::Claude3Sonnet.cross_region_inference_id("eu-west-1")?, + Model::Claude3Sonnet.cross_region_inference_id("eu-west-1", false)?, "eu.anthropic.claude-3-sonnet-20240229-v1:0" ); assert_eq!( - Model::AmazonNovaMicro.cross_region_inference_id("eu-north-1")?, + Model::AmazonNovaMicro.cross_region_inference_id("eu-north-1", false)?, "eu.amazon.nova-micro-v1:0" ); Ok(()) @@ -745,15 +806,15 @@ mod tests { fn test_apac_region_inference_ids() -> anyhow::Result<()> { // Test Asia-Pacific regions assert_eq!( - Model::Claude3_5SonnetV2.cross_region_inference_id("ap-northeast-1")?, + Model::Claude3_5SonnetV2.cross_region_inference_id("ap-northeast-1", false)?, "apac.anthropic.claude-3-5-sonnet-20241022-v2:0" ); assert_eq!( - Model::Claude3_5SonnetV2.cross_region_inference_id("ap-southeast-2")?, + Model::Claude3_5SonnetV2.cross_region_inference_id("ap-southeast-2", false)?, "apac.anthropic.claude-3-5-sonnet-20241022-v2:0" ); assert_eq!( - Model::AmazonNovaLite.cross_region_inference_id("ap-south-1")?, + Model::AmazonNovaLite.cross_region_inference_id("ap-south-1", false)?, "apac.amazon.nova-lite-v1:0" ); Ok(()) @@ -763,11 +824,11 @@ mod tests { fn test_gov_region_inference_ids() -> anyhow::Result<()> { // Test Government regions assert_eq!( - Model::Claude3_5Sonnet.cross_region_inference_id("us-gov-east-1")?, + Model::Claude3_5Sonnet.cross_region_inference_id("us-gov-east-1", false)?, "us-gov.anthropic.claude-3-5-sonnet-20240620-v1:0" ); assert_eq!( - Model::Claude3Haiku.cross_region_inference_id("us-gov-west-1")?, + Model::Claude3Haiku.cross_region_inference_id("us-gov-west-1", false)?, "us-gov.anthropic.claude-3-haiku-20240307-v1:0" ); Ok(()) @@ -777,15 +838,15 @@ mod tests { fn test_meta_models_inference_ids() -> anyhow::Result<()> { // Test Meta models assert_eq!( - Model::MetaLlama370BInstructV1.cross_region_inference_id("us-east-1")?, + Model::MetaLlama370BInstructV1.cross_region_inference_id("us-east-1", false)?, "meta.llama3-70b-instruct-v1:0" ); assert_eq!( - Model::MetaLlama3170BInstructV1.cross_region_inference_id("us-east-1")?, + Model::MetaLlama3170BInstructV1.cross_region_inference_id("us-east-1", false)?, "us.meta.llama3-1-70b-instruct-v1:0" ); assert_eq!( - Model::MetaLlama321BInstructV1.cross_region_inference_id("eu-west-1")?, + Model::MetaLlama321BInstructV1.cross_region_inference_id("eu-west-1", false)?, "eu.meta.llama3-2-1b-instruct-v1:0" ); Ok(()) @@ -796,11 +857,11 @@ mod tests { // Mistral models don't follow the regional prefix pattern, // so they should return their original IDs assert_eq!( - Model::MistralMistralLarge2402V1.cross_region_inference_id("us-east-1")?, + Model::MistralMistralLarge2402V1.cross_region_inference_id("us-east-1", false)?, "mistral.mistral-large-2402-v1:0" ); assert_eq!( - Model::MistralMixtral8x7BInstructV0.cross_region_inference_id("eu-west-1")?, + Model::MistralMixtral8x7BInstructV0.cross_region_inference_id("eu-west-1", false)?, "mistral.mixtral-8x7b-instruct-v0:1" ); Ok(()) @@ -811,11 +872,11 @@ mod tests { // AI21 models don't follow the regional prefix pattern, // so they should return their original IDs assert_eq!( - Model::AI21J2UltraV1.cross_region_inference_id("us-east-1")?, + Model::AI21J2UltraV1.cross_region_inference_id("us-east-1", false)?, "ai21.j2-ultra-v1" ); assert_eq!( - Model::AI21JambaInstructV1.cross_region_inference_id("eu-west-1")?, + Model::AI21JambaInstructV1.cross_region_inference_id("eu-west-1", false)?, "ai21.jamba-instruct-v1:0" ); Ok(()) @@ -826,11 +887,11 @@ mod tests { // Cohere models don't follow the regional prefix pattern, // so they should return their original IDs assert_eq!( - Model::CohereCommandRV1.cross_region_inference_id("us-east-1")?, + Model::CohereCommandRV1.cross_region_inference_id("us-east-1", false)?, "cohere.command-r-v1:0" ); assert_eq!( - Model::CohereCommandTextV14_4k.cross_region_inference_id("ap-southeast-1")?, + Model::CohereCommandTextV14_4k.cross_region_inference_id("ap-southeast-1", false)?, "cohere.command-text-v14:7:4k" ); Ok(()) @@ -850,10 +911,17 @@ mod tests { // Custom model should return its name unchanged assert_eq!( - custom_model.cross_region_inference_id("us-east-1")?, + custom_model.cross_region_inference_id("us-east-1", false)?, "custom.my-model-v1:0" ); + // Test that models without global support fall back to regional when allow_global is true + assert_eq!( + Model::AmazonNovaPro.cross_region_inference_id("us-east-1", true)?, + "us.amazon.nova-pro-v1:0", + "Nova Pro should fall back to regional profile even when allow_global is true" + ); + Ok(()) } @@ -892,3 +960,28 @@ mod tests { ); } } + +#[test] +fn test_global_inference_ids() -> anyhow::Result<()> { + // Test global inference for models that support it when allow_global is true + assert_eq!( + Model::ClaudeSonnet4.cross_region_inference_id("us-east-1", true)?, + "global.anthropic.claude-sonnet-4-20250514-v1:0" + ); + assert_eq!( + Model::ClaudeSonnet4_5.cross_region_inference_id("eu-west-1", true)?, + "global.anthropic.claude-sonnet-4-5-20250929-v1:0" + ); + assert_eq!( + Model::ClaudeHaiku4_5.cross_region_inference_id("ap-south-1", true)?, + "global.anthropic.claude-haiku-4-5-20251001-v1:0" + ); + + // Test that regional prefix is used when allow_global is false + assert_eq!( + Model::ClaudeSonnet4.cross_region_inference_id("us-east-1", false)?, + "us.anthropic.claude-sonnet-4-20250514-v1:0" + ); + + Ok(()) +} diff --git a/crates/language_models/src/provider/bedrock.rs b/crates/language_models/src/provider/bedrock.rs index 9672d61f90512be62ea58e77682d63cc8553710f..e478c193a27a9e30301ae9233ea666c8160b25f5 100644 --- a/crates/language_models/src/provider/bedrock.rs +++ b/crates/language_models/src/provider/bedrock.rs @@ -71,6 +71,7 @@ pub struct AmazonBedrockSettings { pub profile_name: Option, pub role_arn: Option, pub authentication_method: Option, + pub allow_global: Option, } #[derive(Clone, Debug, PartialEq, Serialize, Deserialize, EnumIter, IntoStaticStr, JsonSchema)] @@ -239,6 +240,13 @@ impl State { .or(settings_region) .unwrap_or(String::from("us-east-1")) } + + fn get_allow_global(&self) -> bool { + self.settings + .as_ref() + .and_then(|s| s.allow_global) + .unwrap_or(false) + } } pub struct BedrockLanguageModelProvider { @@ -545,11 +553,13 @@ impl LanguageModel for BedrockModel { LanguageModelCompletionError, >, > { - let Ok(region) = cx.read_entity(&self.state, |state, _cx| state.get_region()) else { + let Ok((region, allow_global)) = cx.read_entity(&self.state, |state, _cx| { + (state.get_region(), state.get_allow_global()) + }) else { return async move { Err(anyhow::anyhow!("App State Dropped").into()) }.boxed(); }; - let model_id = match self.model.cross_region_inference_id(®ion) { + let model_id = match self.model.cross_region_inference_id(®ion, allow_global) { Ok(s) => s, Err(e) => { return async move { Err(e.into()) }.boxed(); diff --git a/crates/language_models/src/settings.rs b/crates/language_models/src/settings.rs index edff1f768e9fc6d2ad9333133b20d88c7676c24d..43a8e7334a744c84d6edfae3ffc97115eb8f51b2 100644 --- a/crates/language_models/src/settings.rs +++ b/crates/language_models/src/settings.rs @@ -58,6 +58,7 @@ impl settings::Settings for AllLanguageModelSettings { profile_name: bedrock.profile, role_arn: None, // todo(was never a setting for this...) authentication_method: bedrock.authentication_method.map(Into::into), + allow_global: bedrock.allow_global, }, deepseek: DeepSeekSettings { api_url: deepseek.api_url.unwrap(), diff --git a/crates/settings/src/settings_content/language_model.rs b/crates/settings/src/settings_content/language_model.rs index 0a746c1284c1d981fdf95745952baacc74548d04..48f5a463a4b8d896885d9ba5b7d804d16ecb5b6b 100644 --- a/crates/settings/src/settings_content/language_model.rs +++ b/crates/settings/src/settings_content/language_model.rs @@ -61,6 +61,7 @@ pub struct AmazonBedrockSettingsContent { pub region: Option, pub profile: Option, pub authentication_method: Option, + pub allow_global: Option, } #[with_fallible_options] diff --git a/docs/src/ai/llm-providers.md b/docs/src/ai/llm-providers.md index 3e40d7ae0283b3dbd1c50ba1bef5ae410d969305..f13ece5d3eb6aac3af38a0046abddc474649f503 100644 --- a/docs/src/ai/llm-providers.md +++ b/docs/src/ai/llm-providers.md @@ -89,12 +89,32 @@ To do this: #### Cross-Region Inference -The Zed implementation of Amazon Bedrock uses [Cross-Region inference](https://docs.aws.amazon.com/bedrock/latest/userguide/cross-region-inference.html) for all the models and region combinations that support it. +The Zed implementation of Amazon Bedrock uses [Cross-Region inference](https://docs.aws.amazon.com/bedrock/latest/userguide/cross-region-inference.html) to improve availability and throughput. With Cross-Region inference, you can distribute traffic across multiple AWS Regions, enabling higher throughput. -For example, if you use `Claude Sonnet 3.7 Thinking` from `us-east-1`, it may be processed across the US regions, namely: `us-east-1`, `us-east-2`, or `us-west-2`. -Cross-Region inference requests are kept within the AWS Regions that are part of the geography where the data originally resides. -For example, a request made within the US is kept within the AWS Regions in the US. +##### Regional vs Global Inference Profiles + +Bedrock supports two types of cross-region inference profiles: + +- **Regional profiles** (default): Route requests within a specific geography (US, EU, APAC). For example, `us-east-1` uses the `us.*` profile which routes across `us-east-1`, `us-east-2`, and `us-west-2`. +- **Global profiles**: Route requests across all commercial AWS Regions for maximum availability and performance. + +By default, Zed uses **regional profiles** which keep your data within the same geography. You can opt into global profiles by adding `"allow_global": true` to your Bedrock configuration: + +```json [settings] +{ + "language_models": { + "bedrock": { + "authentication_method": "named_profile", + "region": "your-aws-region", + "profile": "your-profile-name", + "allow_global": true + } + } +} +``` + +**Note:** Only select newer models support global inference profiles. See the [AWS Bedrock supported models documentation](https://docs.aws.amazon.com/bedrock/latest/userguide/inference-profiles-support.html#inference-profiles-support-system) for the current list of models that support global inference. If you encounter availability issues with a model in your region, enabling `allow_global` may resolve them. Although the data remains stored only in the source Region, your input prompts and output results might move outside of your source Region during cross-Region inference. All data will be transmitted encrypted across Amazon's secure network. From 4ec2d04ad948f118b420bf00f74873ae058e043d Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Thu, 4 Dec 2025 12:21:02 +0100 Subject: [PATCH 052/621] search: Fix sort order not being maintained in presence of open buffers (#44135) In project search UI code we were seeing an issue where "Go to next match" would act up and behave weirdly. It would not wrap at times. Stuff would be weird, yo. It turned out that match ranges reported by core project search were sometimes out of sync with the state of the multi-buffer. As in, the sort order of `search::ProjectSearch::match_ranges` would not match up with multi-buffer's sort order. This is ~because multi-buffers maintain their own sort order. What happened within project search is that we were skipping straight from stage 1 (filtering paths) to stage 3 via an internal channel and in the process we've dropped the channel used to maintain result sorting. This made is so that, given 2 files to scan: - project/file1.rs <- not open, has to go through stage2 (FS scan) - project/file2.rs <- open, goes straight from stage1 (path filtering) to stage3 (finding all matches) We would report matches for project/file2.rs first, because we would notice that there's an existing language::Buffer for it. However, we should wait for project/file1.rs status to be reported first before we kick off project/file2.rs The fix is to use the sorting channel instead of an internal one, as that keeps the sorting worker "in the loop" about the state of the world. Closes #43672 Co-authored-by: Smit Barmase Release Notes: - Fixed "Select next match" in project search results misbehaving when some of the buffers within the search results were open before search was ran. - Fixed project search results being scrolled to the last file active prior to running the search. --------- Co-authored-by: Smit Barmase Co-authored-by: Smit --- crates/project/src/project_search.rs | 29 ++++++---------------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/crates/project/src/project_search.rs b/crates/project/src/project_search.rs index d3e24b47b3eab20391dd390c9b6a21b3fc2a1981..90687f247338750b2c1197037576098281083e36 100644 --- a/crates/project/src/project_search.rs +++ b/crates/project/src/project_search.rs @@ -93,9 +93,6 @@ enum FindSearchCandidates { /// based on disk contents of a buffer. This step is not performed for buffers we already have in memory. confirm_contents_will_match_tx: Sender, confirm_contents_will_match_rx: Receiver, - /// Of those that contain at least one match (or are already in memory), look for rest of matches (and figure out their ranges). - /// But wait - first, we need to go back to the main thread to open a buffer (& create an entity for it). - get_buffer_for_full_scan_tx: Sender, }, Remote, OpenBuffersOnly, @@ -226,7 +223,7 @@ impl Search { .boxed_local(), cx.background_spawn(Self::maintain_sorted_search_results( sorted_search_results_rx, - get_buffer_for_full_scan_tx.clone(), + get_buffer_for_full_scan_tx, self.limit, )) .boxed_local(), @@ -234,7 +231,6 @@ impl Search { ( FindSearchCandidates::Local { fs, - get_buffer_for_full_scan_tx, confirm_contents_will_match_tx, confirm_contents_will_match_rx, input_paths_rx, @@ -593,7 +589,6 @@ impl Worker<'_> { input_paths_rx, confirm_contents_will_match_rx, mut confirm_contents_will_match_tx, - mut get_buffer_for_full_scan_tx, fs, ) = match self.candidates { FindSearchCandidates::Local { @@ -601,21 +596,15 @@ impl Worker<'_> { input_paths_rx, confirm_contents_will_match_rx, confirm_contents_will_match_tx, - get_buffer_for_full_scan_tx, } => ( input_paths_rx, confirm_contents_will_match_rx, confirm_contents_will_match_tx, - get_buffer_for_full_scan_tx, Some(fs), ), - FindSearchCandidates::Remote | FindSearchCandidates::OpenBuffersOnly => ( - unbounded().1, - unbounded().1, - unbounded().0, - unbounded().0, - None, - ), + FindSearchCandidates::Remote | FindSearchCandidates::OpenBuffersOnly => { + (unbounded().1, unbounded().1, unbounded().0, None) + } }; // WorkerA: grabs a request for "find all matches in file/a" <- takes 5 minutes // right after: WorkerB: grabs a request for "find all matches in file/b" <- takes 5 seconds @@ -629,7 +618,6 @@ impl Worker<'_> { open_entries: &self.open_buffers, fs: fs.as_deref(), confirm_contents_will_match_tx: &confirm_contents_will_match_tx, - get_buffer_for_full_scan_tx: &get_buffer_for_full_scan_tx, }; // Whenever we notice that some step of a pipeline is closed, we don't want to close subsequent // steps straight away. Another worker might be about to produce a value that will @@ -645,10 +633,7 @@ impl Worker<'_> { find_first_match = find_first_match.next() => { if let Some(buffer_with_at_least_one_match) = find_first_match { handler.handle_find_first_match(buffer_with_at_least_one_match).await; - } else { - get_buffer_for_full_scan_tx = bounded(1).0; } - }, scan_path = scan_path.next() => { if let Some(path_to_scan) = scan_path { @@ -673,7 +658,6 @@ struct RequestHandler<'worker> { fs: Option<&'worker dyn Fs>, open_entries: &'worker HashSet, confirm_contents_will_match_tx: &'worker Sender, - get_buffer_for_full_scan_tx: &'worker Sender, } impl RequestHandler<'_> { @@ -729,9 +713,8 @@ impl RequestHandler<'_> { _ = maybe!(async move { let InputPath { entry, - snapshot, - should_scan_tx, + mut should_scan_tx, } = req; if entry.is_fifo || !entry.is_file() { @@ -754,7 +737,7 @@ impl RequestHandler<'_> { if self.open_entries.contains(&entry.id) { // The buffer is already in memory and that's the version we want to scan; // hence skip the dilly-dally and look for all matches straight away. - self.get_buffer_for_full_scan_tx + should_scan_tx .send(ProjectPath { worktree_id: snapshot.id(), path: entry.path.clone(), From bad6bde03a1789b80ffc13c5d8c066746017b013 Mon Sep 17 00:00:00 2001 From: John Gibb <32365131+JPGibb@users.noreply.github.com> Date: Thu, 4 Dec 2025 12:07:40 +0000 Subject: [PATCH 053/621] Use buffer language when formatting with Prettier (#43368) Set `prettier_parser` explicitly if the file extension for the buffer does not match a known one for the current language Release Notes: - N/A --------- Co-authored-by: Kirill Bulatov --- crates/editor/src/editor_tests.rs | 103 ++++++++++++++++++++++++++++++ crates/prettier/src/prettier.rs | 78 +++++++++++++++++----- 2 files changed, 165 insertions(+), 16 deletions(-) diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rs index 011715804665563b9588da28bad3137120f9c4c3..64c335e2e4b0dc660efe1b28bb87984fba8aafb4 100644 --- a/crates/editor/src/editor_tests.rs +++ b/crates/editor/src/editor_tests.rs @@ -19095,6 +19095,109 @@ async fn test_document_format_with_prettier(cx: &mut TestAppContext) { ); } +#[gpui::test] +async fn test_document_format_with_prettier_explicit_language(cx: &mut TestAppContext) { + init_test(cx, |settings| { + settings.defaults.formatter = Some(FormatterList::Single(Formatter::Prettier)) + }); + + let fs = FakeFs::new(cx.executor()); + fs.insert_file(path!("/file.settings"), Default::default()) + .await; + + let project = Project::test(fs, [path!("/file.settings").as_ref()], cx).await; + let language_registry = project.read_with(cx, |project, _| project.languages().clone()); + + let ts_lang = Arc::new(Language::new( + LanguageConfig { + name: "TypeScript".into(), + matcher: LanguageMatcher { + path_suffixes: vec!["ts".to_string()], + ..LanguageMatcher::default() + }, + prettier_parser_name: Some("typescript".to_string()), + ..LanguageConfig::default() + }, + Some(tree_sitter_typescript::LANGUAGE_TYPESCRIPT.into()), + )); + + language_registry.add(ts_lang.clone()); + + update_test_language_settings(cx, |settings| { + settings.defaults.prettier.get_or_insert_default().allowed = Some(true); + }); + + let test_plugin = "test_plugin"; + let _ = language_registry.register_fake_lsp( + "TypeScript", + FakeLspAdapter { + prettier_plugins: vec![test_plugin], + ..Default::default() + }, + ); + + let prettier_format_suffix = project::TEST_PRETTIER_FORMAT_SUFFIX; + let buffer = project + .update(cx, |project, cx| { + project.open_local_buffer(path!("/file.settings"), cx) + }) + .await + .unwrap(); + + project.update(cx, |project, cx| { + project.set_language_for_buffer(&buffer, ts_lang, cx) + }); + + let buffer_text = "one\ntwo\nthree\n"; + let buffer = cx.new(|cx| MultiBuffer::singleton(buffer, cx)); + let (editor, cx) = cx.add_window_view(|window, cx| build_editor(buffer, window, cx)); + editor.update_in(cx, |editor, window, cx| { + editor.set_text(buffer_text, window, cx) + }); + + editor + .update_in(cx, |editor, window, cx| { + editor.perform_format( + project.clone(), + FormatTrigger::Manual, + FormatTarget::Buffers(editor.buffer().read(cx).all_buffers()), + window, + cx, + ) + }) + .unwrap() + .await; + assert_eq!( + editor.update(cx, |editor, cx| editor.text(cx)), + buffer_text.to_string() + prettier_format_suffix + "\ntypescript", + "Test prettier formatting was not applied to the original buffer text", + ); + + update_test_language_settings(cx, |settings| { + settings.defaults.formatter = Some(FormatterList::default()) + }); + let format = editor.update_in(cx, |editor, window, cx| { + editor.perform_format( + project.clone(), + FormatTrigger::Manual, + FormatTarget::Buffers(editor.buffer().read(cx).all_buffers()), + window, + cx, + ) + }); + format.await.unwrap(); + + assert_eq!( + editor.update(cx, |editor, cx| editor.text(cx)), + buffer_text.to_string() + + prettier_format_suffix + + "\ntypescript\n" + + prettier_format_suffix + + "\ntypescript", + "Autoformatting (via test prettier) was not applied to the original buffer text", + ); +} + #[gpui::test] async fn test_addition_reverts(cx: &mut TestAppContext) { init_test(cx, |_| {}); diff --git a/crates/prettier/src/prettier.rs b/crates/prettier/src/prettier.rs index 381fdc2b2b35be53a0f07878c83cadd2862d06bf..bc4ce609a1fd39e4303c5fd048a0c8605b3a3ddc 100644 --- a/crates/prettier/src/prettier.rs +++ b/crates/prettier/src/prettier.rs @@ -2,7 +2,8 @@ use anyhow::Context as _; use collections::{HashMap, HashSet}; use fs::Fs; use gpui::{AsyncApp, Entity}; -use language::{Buffer, Diff, language_settings::language_settings}; +use language::language_settings::PrettierSettings; +use language::{Buffer, Diff, Language, language_settings::language_settings}; use lsp::{LanguageServer, LanguageServerId}; use node_runtime::NodeRuntime; use paths::default_prettier_dir; @@ -349,7 +350,7 @@ impl Prettier { Self::Real(local) => { let params = buffer .update(cx, |buffer, cx| { - let buffer_language = buffer.language(); + let buffer_language = buffer.language().map(|language| language.as_ref()); let language_settings = language_settings(buffer_language.map(|l| l.name()), buffer.file(), cx); let prettier_settings = &language_settings.prettier; anyhow::ensure!( @@ -449,15 +450,7 @@ impl Prettier { }) .collect(); - let mut prettier_parser = prettier_settings.parser.as_deref(); - if buffer_path.is_none() { - prettier_parser = prettier_parser.or_else(|| buffer_language.and_then(|language| language.prettier_parser_name())); - if prettier_parser.is_none() { - log::error!("Formatting unsaved file with prettier failed. No prettier parser configured for language {buffer_language:?}"); - anyhow::bail!("Cannot determine prettier parser for unsaved file"); - } - - } + let parser = prettier_parser_name(buffer_path.as_deref(), buffer_language, prettier_settings).context("getting prettier parser")?; let ignore_path = ignore_dir.and_then(|dir| { let ignore_file = dir.join(".prettierignore"); @@ -475,15 +468,15 @@ impl Prettier { anyhow::Ok(FormatParams { text: buffer.text(), options: FormatOptions { - parser: prettier_parser.map(ToOwned::to_owned), - plugins, path: buffer_path, + parser, + plugins, prettier_options, ignore_path, }, }) - })? - .context("building prettier request")?; + })? + .context("building prettier request")?; let response = local .server @@ -503,7 +496,26 @@ impl Prettier { { Some("rust") => anyhow::bail!("prettier does not support Rust"), Some(_other) => { - let formatted_text = buffer.text() + FORMAT_SUFFIX; + let mut formatted_text = buffer.text() + FORMAT_SUFFIX; + + let buffer_language = + buffer.language().map(|language| language.as_ref()); + let language_settings = language_settings( + buffer_language.map(|l| l.name()), + buffer.file(), + cx, + ); + let prettier_settings = &language_settings.prettier; + let parser = prettier_parser_name( + buffer_path.as_deref(), + buffer_language, + prettier_settings, + )?; + + if let Some(parser) = parser { + formatted_text = format!("{formatted_text}\n{parser}"); + } + Ok(buffer.diff(formatted_text, cx)) } None => panic!("Should not format buffer without a language with prettier"), @@ -551,6 +563,40 @@ impl Prettier { } } +fn prettier_parser_name( + buffer_path: Option<&Path>, + buffer_language: Option<&Language>, + prettier_settings: &PrettierSettings, +) -> anyhow::Result> { + let parser = if buffer_path.is_none() { + let parser = prettier_settings + .parser + .as_deref() + .or_else(|| buffer_language.and_then(|language| language.prettier_parser_name())); + if parser.is_none() { + log::error!( + "Formatting unsaved file with prettier failed. No prettier parser configured for language {buffer_language:?}" + ); + anyhow::bail!("Cannot determine prettier parser for unsaved file"); + } + parser + } else if let (Some(buffer_language), Some(buffer_path)) = (buffer_language, buffer_path) + && buffer_path.extension().is_some_and(|extension| { + !buffer_language + .config() + .matcher + .path_suffixes + .contains(&extension.to_string_lossy().into_owned()) + }) + { + buffer_language.prettier_parser_name() + } else { + prettier_settings.parser.as_deref() + }; + + Ok(parser.map(ToOwned::to_owned)) +} + async fn has_prettier_in_node_modules(fs: &dyn Fs, path: &Path) -> anyhow::Result { let possible_node_modules_location = path.join("node_modules").join(PRETTIER_PACKAGE_NAME); if let Some(node_modules_location_metadata) = fs From 0d80b452fb8c986d8ff060a34047e88dcbf10f1a Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Thu, 4 Dec 2025 13:33:13 +0100 Subject: [PATCH 054/621] python: Improve sorting order of toolchains to give higher precedence to project-local virtual environments that are within current subproject (#44141) Closes #44090 Co-authored-by: Smit Barmase Release Notes: - python: Improved sorting order of toolchains in monorepos with multiple local virtual environments. - python: Fixed toolchain selector not having an active toolchain selected on open. --------- Co-authored-by: Smit Barmase Co-authored-by: Smit --- crates/languages/src/python.rs | 41 ++++++++++++++---- .../src/toolchain_selector.rs | 24 ++++++----- crates/workspace/src/persistence.rs | 43 ------------------- 3 files changed, 45 insertions(+), 63 deletions(-) diff --git a/crates/languages/src/python.rs b/crates/languages/src/python.rs index db61d5902d3f18444988caa0596f998f61636cee..fc2f91121e96e0c0709b4d5e8d0666102ce9866d 100644 --- a/crates/languages/src/python.rs +++ b/crates/languages/src/python.rs @@ -23,7 +23,7 @@ use serde::{Deserialize, Serialize}; use serde_json::{Value, json}; use settings::Settings; use smol::lock::OnceCell; -use std::cmp::Ordering; +use std::cmp::{Ordering, Reverse}; use std::env::consts; use terminal::terminal_settings::TerminalSettings; use util::command::new_smol_command; @@ -1101,13 +1101,33 @@ fn get_venv_parent_dir(env: &PythonEnvironment) -> Option { venv.parent().map(|parent| parent.to_path_buf()) } -fn wr_distance(wr: &PathBuf, venv: Option<&PathBuf>) -> usize { +// How far is this venv from the root of our current project? +#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] +enum SubprojectDistance { + WithinSubproject(Reverse), + WithinWorktree(Reverse), + NotInWorktree, +} + +fn wr_distance( + wr: &PathBuf, + subroot_relative_path: &RelPath, + venv: Option<&PathBuf>, +) -> SubprojectDistance { if let Some(venv) = venv && let Ok(p) = venv.strip_prefix(wr) { - p.components().count() + if subroot_relative_path.components().next().is_some() + && let Ok(distance) = p + .strip_prefix(subroot_relative_path.as_std_path()) + .map(|p| p.components().count()) + { + SubprojectDistance::WithinSubproject(Reverse(distance)) + } else { + SubprojectDistance::WithinWorktree(Reverse(p.components().count())) + } } else { - usize::MAX + SubprojectDistance::NotInWorktree } } @@ -1170,11 +1190,14 @@ impl ToolchainLister for PythonToolchainProvider { }); // Compare project paths against worktree root - let proj_ordering = || { - let lhs_project = lhs.project.clone().or_else(|| get_venv_parent_dir(lhs)); - let rhs_project = rhs.project.clone().or_else(|| get_venv_parent_dir(rhs)); - wr_distance(&wr, lhs_project.as_ref()).cmp(&wr_distance(&wr, rhs_project.as_ref())) - }; + let proj_ordering = + || { + let lhs_project = lhs.project.clone().or_else(|| get_venv_parent_dir(lhs)); + let rhs_project = rhs.project.clone().or_else(|| get_venv_parent_dir(rhs)); + wr_distance(&wr, &subroot_relative_path, lhs_project.as_ref()).cmp( + &wr_distance(&wr, &subroot_relative_path, rhs_project.as_ref()), + ) + }; // Compare environment priorities let priority_ordering = || env_priority(lhs.kind).cmp(&env_priority(rhs.kind)); diff --git a/crates/toolchain_selector/src/toolchain_selector.rs b/crates/toolchain_selector/src/toolchain_selector.rs index 96f692694dcf6b1adaa6494a4c1cbf6905c57c7c..138f99066f0a80188837de49f6afc67d91d9eeb5 100644 --- a/crates/toolchain_selector/src/toolchain_selector.rs +++ b/crates/toolchain_selector/src/toolchain_selector.rs @@ -588,19 +588,20 @@ impl ToolchainSelector { .worktree_for_id(worktree_id, cx)? .read(cx) .abs_path(); - let workspace_id = workspace.database_id()?; let weak = workspace.weak_handle(); cx.spawn_in(window, async move |workspace, cx| { - let active_toolchain = workspace::WORKSPACE_DB - .toolchain( - workspace_id, - worktree_id, - relative_path.clone(), - language_name.clone(), - ) - .await - .ok() - .flatten(); + let active_toolchain = project + .read_with(cx, |this, cx| { + this.active_toolchain( + ProjectPath { + worktree_id, + path: relative_path.clone(), + }, + language_name.clone(), + cx, + ) + })? + .await; workspace .update_in(cx, |this, window, cx| { this.toggle_modal(window, cx, move |window, cx| { @@ -618,6 +619,7 @@ impl ToolchainSelector { }); }) .ok(); + anyhow::Ok(()) }) .detach(); diff --git a/crates/workspace/src/persistence.rs b/crates/workspace/src/persistence.rs index 3d7ddf5d2ceae40f19e4684b63f6b33c8b53b280..824a9be90b6dc33094f854a3a9672db692e2b592 100644 --- a/crates/workspace/src/persistence.rs +++ b/crates/workspace/src/persistence.rs @@ -1656,49 +1656,6 @@ impl WorkspaceDb { } } - pub async fn toolchain( - &self, - workspace_id: WorkspaceId, - worktree_id: WorktreeId, - relative_worktree_path: Arc, - language_name: LanguageName, - ) -> Result> { - self.write(move |this| { - let mut select = this - .select_bound(sql!( - SELECT - name, path, raw_json - FROM toolchains - WHERE - workspace_id = ? AND - language_name = ? AND - worktree_id = ? AND - relative_worktree_path = ? - )) - .context("select toolchain")?; - - let toolchain: Vec<(String, String, String)> = select(( - workspace_id, - language_name.as_ref().to_string(), - worktree_id.to_usize(), - relative_worktree_path.as_unix_str().to_string(), - ))?; - - Ok(toolchain - .into_iter() - .next() - .and_then(|(name, path, raw_json)| { - Some(Toolchain { - name: name.into(), - path: path.into(), - language_name, - as_json: serde_json::Value::from_str(&raw_json).ok()?, - }) - })) - }) - .await - } - pub(crate) async fn toolchains( &self, workspace_id: WorkspaceId, From 4c51fffbb59e89347d3bc7e7406f484773643aa6 Mon Sep 17 00:00:00 2001 From: Coenen Benjamin Date: Thu, 4 Dec 2025 14:23:36 +0100 Subject: [PATCH 055/621] Add support for git remotes (#42819) Follow up of #42486 Closes #26559 https://github.com/user-attachments/assets/e2f54dda-a78b-4d9b-a910-16d51f98a111 Release Notes: - Added support for git remotes --------- Signed-off-by: Benjamin <5719034+bnjjj@users.noreply.github.com> --- crates/collab/src/rpc.rs | 2 + crates/fs/src/fake_git_repo.rs | 43 +- crates/git/src/remote.rs | 3 +- crates/git/src/repository.rs | 70 +- crates/git_ui/src/branch_picker.rs | 1298 ++++++++++++++++++++++++---- crates/git_ui/src/git_panel.rs | 2 - crates/git_ui/src/remote_output.rs | 1 + crates/project/src/git_store.rs | 96 +- crates/proto/proto/git.proto | 13 + crates/proto/proto/zed.proto | 7 +- crates/proto/src/proto.rs | 6 + crates/zed_actions/src/lib.rs | 4 + 12 files changed, 1353 insertions(+), 192 deletions(-) diff --git a/crates/collab/src/rpc.rs b/crates/collab/src/rpc.rs index aa77ba25bfb687b6c5cb0da84e14c843f8a2a3bc..9511087af8887a3c799357d06050ce48431b38a6 100644 --- a/crates/collab/src/rpc.rs +++ b/crates/collab/src/rpc.rs @@ -469,6 +469,8 @@ impl Server { .add_request_handler(forward_mutating_project_request::) .add_request_handler(forward_mutating_project_request::) .add_request_handler(forward_mutating_project_request::) + .add_request_handler(forward_mutating_project_request::) + .add_request_handler(forward_mutating_project_request::) .add_request_handler(forward_mutating_project_request::) .add_message_handler(broadcast_project_message_from_host::) .add_message_handler(update_context) diff --git a/crates/fs/src/fake_git_repo.rs b/crates/fs/src/fake_git_repo.rs index b6beb9fc6ecb470b30c6ed4edca06be479db11c0..3bc411ff2d9b917fd409c29cca03d2191ee80978 100644 --- a/crates/fs/src/fake_git_repo.rs +++ b/crates/fs/src/fake_git_repo.rs @@ -50,6 +50,8 @@ pub struct FakeGitRepositoryState { pub blames: HashMap, pub current_branch_name: Option, pub branches: HashSet, + /// List of remotes, keys are names and values are URLs + pub remotes: HashMap, pub simulated_index_write_error_message: Option, pub refs: HashMap, } @@ -68,6 +70,7 @@ impl FakeGitRepositoryState { refs: HashMap::from_iter([("HEAD".into(), "abc".into())]), merge_base_contents: Default::default(), oids: Default::default(), + remotes: HashMap::default(), } } } @@ -432,8 +435,13 @@ impl GitRepository for FakeGitRepository { }) } - fn delete_branch(&self, _name: String) -> BoxFuture<'_, Result<()>> { - unimplemented!() + fn delete_branch(&self, name: String) -> BoxFuture<'_, Result<()>> { + self.with_state_async(true, move |state| { + if !state.branches.remove(&name) { + bail!("no such branch: {name}"); + } + Ok(()) + }) } fn blame(&self, path: RepoPath, _content: Rope) -> BoxFuture<'_, Result> { @@ -598,15 +606,24 @@ impl GitRepository for FakeGitRepository { unimplemented!() } - fn get_push_remote(&self, _branch: String) -> BoxFuture<'_, Result>> { - unimplemented!() + fn get_all_remotes(&self) -> BoxFuture<'_, Result>> { + self.with_state_async(false, move |state| { + let remotes = state + .remotes + .keys() + .map(|r| Remote { + name: r.clone().into(), + }) + .collect::>(); + Ok(remotes) + }) } - fn get_branch_remote(&self, _branch: String) -> BoxFuture<'_, Result>> { + fn get_push_remote(&self, _branch: String) -> BoxFuture<'_, Result>> { unimplemented!() } - fn get_all_remotes(&self) -> BoxFuture<'_, Result>> { + fn get_branch_remote(&self, _branch: String) -> BoxFuture<'_, Result>> { unimplemented!() } @@ -683,6 +700,20 @@ impl GitRepository for FakeGitRepository { fn default_branch(&self) -> BoxFuture<'_, Result>> { async { Ok(Some("main".into())) }.boxed() } + + fn create_remote(&self, name: String, url: String) -> BoxFuture<'_, Result<()>> { + self.with_state_async(true, move |state| { + state.remotes.insert(name, url); + Ok(()) + }) + } + + fn remove_remote(&self, name: String) -> BoxFuture<'_, Result<()>> { + self.with_state_async(true, move |state| { + state.remotes.remove(&name); + Ok(()) + }) + } } #[cfg(test)] diff --git a/crates/git/src/remote.rs b/crates/git/src/remote.rs index e9814afc51a4a24fd154d74d0be2387c28c59fa3..8fb44839848278a3a698d7f2562741f682f38e24 100644 --- a/crates/git/src/remote.rs +++ b/crates/git/src/remote.rs @@ -1,3 +1,4 @@ +use std::str::FromStr; use std::sync::LazyLock; use derive_more::Deref; @@ -11,7 +12,7 @@ pub struct RemoteUrl(Url); static USERNAME_REGEX: LazyLock = LazyLock::new(|| Regex::new(r"^[0-9a-zA-Z\-_]+@").expect("Failed to create USERNAME_REGEX")); -impl std::str::FromStr for RemoteUrl { +impl FromStr for RemoteUrl { type Err = url::ParseError; fn from_str(input: &str) -> Result { diff --git a/crates/git/src/repository.rs b/crates/git/src/repository.rs index e49b1715901f3dcc463bee0e7870d69073fa0561..f79bade2d6bc12553b173c4f4e86989a961e6d31 100644 --- a/crates/git/src/repository.rs +++ b/crates/git/src/repository.rs @@ -7,13 +7,15 @@ use collections::HashMap; use futures::future::BoxFuture; use futures::io::BufWriter; use futures::{AsyncWriteExt, FutureExt as _, select_biased}; -use git2::BranchType; +use git2::{BranchType, ErrorCode}; use gpui::{AppContext as _, AsyncApp, BackgroundExecutor, SharedString, Task}; use parking_lot::Mutex; use rope::Rope; use schemars::JsonSchema; use serde::Deserialize; use smol::io::{AsyncBufReadExt, AsyncReadExt, BufReader}; + +use std::collections::HashSet; use std::ffi::{OsStr, OsString}; use std::process::{ExitStatus, Stdio}; use std::{ @@ -55,6 +57,12 @@ impl Branch { self.ref_name.starts_with("refs/remotes/") } + pub fn remote_name(&self) -> Option<&str> { + self.ref_name + .strip_prefix("refs/remotes/") + .and_then(|stripped| stripped.split("/").next()) + } + pub fn tracking_status(&self) -> Option { self.upstream .as_ref() @@ -590,6 +598,10 @@ pub trait GitRepository: Send + Sync { fn get_all_remotes(&self) -> BoxFuture<'_, Result>>; + fn remove_remote(&self, name: String) -> BoxFuture<'_, Result<()>>; + + fn create_remote(&self, name: String, url: String) -> BoxFuture<'_, Result<()>>; + /// returns a list of remote branches that contain HEAD fn check_for_pushed_commit(&self) -> BoxFuture<'_, Result>>; @@ -1385,9 +1397,19 @@ impl GitRepository for RealGitRepository { branch } else if let Ok(revision) = repo.find_branch(&name, BranchType::Remote) { let (_, branch_name) = name.split_once("/").context("Unexpected branch format")?; + let revision = revision.get(); let branch_commit = revision.peel_to_commit()?; - let mut branch = repo.branch(&branch_name, &branch_commit, false)?; + let mut branch = match repo.branch(&branch_name, &branch_commit, false) { + Ok(branch) => branch, + Err(err) if err.code() == ErrorCode::Exists => { + repo.find_branch(&branch_name, BranchType::Local)? + } + Err(err) => { + return Err(err.into()); + } + }; + branch.set_upstream(Some(&name))?; branch } else { @@ -1403,7 +1425,6 @@ impl GitRepository for RealGitRepository { self.executor .spawn(async move { let branch = branch.await?; - GitBinary::new(git_binary_path, working_directory?, executor) .run(&["checkout", &branch]) .await?; @@ -1993,7 +2014,7 @@ impl GitRepository for RealGitRepository { let working_directory = working_directory?; let output = new_smol_command(&git_binary_path) .current_dir(&working_directory) - .args(["remote"]) + .args(["remote", "-v"]) .output() .await?; @@ -2002,14 +2023,43 @@ impl GitRepository for RealGitRepository { "Failed to get all remotes:\n{}", String::from_utf8_lossy(&output.stderr) ); - let remote_names = String::from_utf8_lossy(&output.stdout) - .split('\n') - .filter(|name| !name.is_empty()) - .map(|name| Remote { - name: name.trim().to_string().into(), + let remote_names: HashSet = String::from_utf8_lossy(&output.stdout) + .lines() + .filter(|line| !line.is_empty()) + .filter_map(|line| { + let mut split_line = line.split_whitespace(); + let remote_name = split_line.next()?; + + Some(Remote { + name: remote_name.trim().to_string().into(), + }) }) .collect(); - Ok(remote_names) + + Ok(remote_names.into_iter().collect()) + }) + .boxed() + } + + fn remove_remote(&self, name: String) -> BoxFuture<'_, Result<()>> { + let repo = self.repository.clone(); + self.executor + .spawn(async move { + let repo = repo.lock(); + repo.remote_delete(&name)?; + + Ok(()) + }) + .boxed() + } + + fn create_remote(&self, name: String, url: String) -> BoxFuture<'_, Result<()>> { + let repo = self.repository.clone(); + self.executor + .spawn(async move { + let repo = repo.lock(); + repo.remote(&name, url.as_ref())?; + Ok(()) }) .boxed() } diff --git a/crates/git_ui/src/branch_picker.rs b/crates/git_ui/src/branch_picker.rs index 92c2f92ca342be270aa25f9e1a7ee96f5e06a585..42e043cada2813126af3489c9769aca9c675999f 100644 --- a/crates/git_ui/src/branch_picker.rs +++ b/crates/git_ui/src/branch_picker.rs @@ -1,10 +1,12 @@ use anyhow::Context as _; +use editor::Editor; use fuzzy::StringMatchCandidate; use collections::HashSet; use git::repository::Branch; +use gpui::http_client::Url; use gpui::{ - Action, App, Context, DismissEvent, Entity, EventEmitter, FocusHandle, Focusable, + Action, App, AsyncApp, Context, DismissEvent, Entity, EventEmitter, FocusHandle, Focusable, InteractiveElement, IntoElement, Modifiers, ModifiersChangedEvent, ParentElement, Render, SharedString, Styled, Subscription, Task, WeakEntity, Window, actions, rems, }; @@ -14,7 +16,10 @@ use project::project_settings::ProjectSettings; use settings::Settings; use std::sync::Arc; use time::OffsetDateTime; -use ui::{HighlightedLabel, KeyBinding, ListItem, ListItemSpacing, Tooltip, prelude::*}; +use ui::{ + CommonAnimationExt, Divider, HighlightedLabel, KeyBinding, ListItem, ListItemSpacing, Tooltip, + prelude::*, +}; use util::ResultExt; use workspace::notifications::DetachAndPromptErr; use workspace::{ModalView, Workspace}; @@ -24,8 +29,10 @@ use crate::{branch_picker, git_panel::show_error_toast}; actions!( branch_picker, [ - /// Deletes the selected git branch. - DeleteBranch + /// Deletes the selected git branch or remote. + DeleteBranch, + /// Filter the list of remotes + FilterRemotes ] ); @@ -206,7 +213,7 @@ impl BranchList { .update(cx, |picker, _| picker.delegate.modifiers = ev.modifiers) } - fn handle_delete_branch( + fn handle_delete( &mut self, _: &branch_picker::DeleteBranch, window: &mut Window, @@ -215,9 +222,32 @@ impl BranchList { self.picker.update(cx, |picker, cx| { picker .delegate - .delete_branch_at(picker.delegate.selected_index, window, cx) + .delete_at(picker.delegate.selected_index, window, cx) }) } + + fn handle_filter( + &mut self, + _: &branch_picker::FilterRemotes, + window: &mut Window, + cx: &mut Context, + ) { + self.picker.update(cx, |this, cx| { + this.delegate.display_remotes = !this.delegate.display_remotes; + cx.spawn_in(window, async move |this, cx| { + this.update_in(cx, |picker, window, cx| { + let last_query = picker.delegate.last_query.clone(); + picker.delegate.update_matches(last_query, window, cx) + })? + .await; + + Result::Ok::<_, anyhow::Error>(()) + }) + .detach_and_log_err(cx); + }); + + cx.notify(); + } } impl ModalView for BranchList {} impl EventEmitter for BranchList {} @@ -234,7 +264,8 @@ impl Render for BranchList { .key_context("GitBranchSelector") .w(self.width) .on_modifiers_changed(cx.listener(Self::handle_modifiers_changed)) - .on_action(cx.listener(Self::handle_delete_branch)) + .on_action(cx.listener(Self::handle_delete)) + .on_action(cx.listener(Self::handle_filter)) .child(self.picker.clone()) .on_mouse_down_out({ cx.listener(move |this, _, window, cx| { @@ -246,16 +277,50 @@ impl Render for BranchList { } } -#[derive(Debug, Clone)] -struct BranchEntry { - branch: Branch, - positions: Vec, - is_new: bool, +#[derive(Debug, Clone, PartialEq)] +enum Entry { + Branch { + branch: Branch, + positions: Vec, + }, + NewUrl { + url: String, + }, + NewBranch { + name: String, + }, +} + +impl Entry { + fn as_branch(&self) -> Option<&Branch> { + match self { + Entry::Branch { branch, .. } => Some(branch), + _ => None, + } + } + + fn name(&self) -> &str { + match self { + Entry::Branch { branch, .. } => branch.name(), + Entry::NewUrl { url, .. } => url.as_str(), + Entry::NewBranch { name, .. } => name.as_str(), + } + } + + #[cfg(test)] + fn is_new_url(&self) -> bool { + matches!(self, Self::NewUrl { .. }) + } + + #[cfg(test)] + fn is_new_branch(&self) -> bool { + matches!(self, Self::NewBranch { .. }) + } } pub struct BranchListDelegate { workspace: Option>, - matches: Vec, + matches: Vec, all_branches: Option>, default_branch: Option, repo: Option>, @@ -263,9 +328,24 @@ pub struct BranchListDelegate { selected_index: usize, last_query: String, modifiers: Modifiers, + display_remotes: bool, + state: PickerState, + loading: bool, focus_handle: FocusHandle, } +#[derive(Debug)] +enum PickerState { + /// When we display list of branches/remotes + List, + /// When we set an url to create a new remote + NewRemote, + /// When we confirm the new remote url (after NewRemote) + CreateRemote(SharedString), + /// When we set a new branch to create + NewBranch, +} + impl BranchListDelegate { fn new( workspace: Option>, @@ -283,6 +363,9 @@ impl BranchListDelegate { selected_index: 0, last_query: Default::default(), modifiers: Default::default(), + display_remotes: false, + state: PickerState::List, + loading: false, focus_handle: cx.focus_handle(), } } @@ -313,8 +396,59 @@ impl BranchListDelegate { cx.emit(DismissEvent); } - fn delete_branch_at(&self, idx: usize, window: &mut Window, cx: &mut Context>) { - let Some(branch_entry) = self.matches.get(idx) else { + fn create_remote( + &self, + remote_name: String, + remote_url: String, + window: &mut Window, + cx: &mut Context>, + ) { + let Some(repo) = self.repo.clone() else { + return; + }; + cx.spawn(async move |this, cx| { + this.update(cx, |picker, cx| { + picker.delegate.loading = true; + cx.notify(); + }) + .log_err(); + + let stop_loader = |this: &WeakEntity>, cx: &mut AsyncApp| { + this.update(cx, |picker, cx| { + picker.delegate.loading = false; + cx.notify(); + }) + .log_err(); + }; + repo.update(cx, |repo, _| repo.create_remote(remote_name, remote_url)) + .inspect_err(|_err| { + stop_loader(&this, cx); + })? + .await + .inspect_err(|_err| { + stop_loader(&this, cx); + })? + .inspect_err(|_err| { + stop_loader(&this, cx); + })?; + stop_loader(&this, cx); + Ok(()) + }) + .detach_and_prompt_err("Failed to create remote", window, cx, |e, _, _cx| { + Some(e.to_string()) + }); + cx.emit(DismissEvent); + } + + fn loader(&self) -> AnyElement { + Icon::new(IconName::LoadCircle) + .size(IconSize::Small) + .with_rotate_animation(3) + .into_any_element() + } + + fn delete_at(&self, idx: usize, window: &mut Window, cx: &mut Context>) { + let Some(entry) = self.matches.get(idx).cloned() else { return; }; let Some(repo) = self.repo.clone() else { @@ -322,20 +456,51 @@ impl BranchListDelegate { }; let workspace = self.workspace.clone(); - let branch_name = branch_entry.branch.name().to_string(); - let branch_ref = branch_entry.branch.ref_name.clone(); cx.spawn_in(window, async move |picker, cx| { - let result = repo - .update(cx, |repo, _| repo.delete_branch(branch_name.clone()))? - .await?; + let mut is_remote = false; + let result = match &entry { + Entry::Branch { branch, .. } => match branch.remote_name() { + Some(remote_name) => { + is_remote = true; + repo.update(cx, |repo, _| repo.remove_remote(remote_name.to_string()))? + .await? + } + None => { + repo.update(cx, |repo, _| repo.delete_branch(branch.name().to_string()))? + .await? + } + }, + _ => { + log::error!("Failed to delete remote: wrong entry to delete"); + return Ok(()); + } + }; if let Err(e) = result { - log::error!("Failed to delete branch: {}", e); + if is_remote { + log::error!("Failed to delete remote: {}", e); + } else { + log::error!("Failed to delete branch: {}", e); + } if let Some(workspace) = workspace.and_then(|w| w.upgrade()) { cx.update(|_window, cx| { - show_error_toast(workspace, format!("branch -d {branch_name}"), e, cx) + if is_remote { + show_error_toast( + workspace, + format!("remote remove {}", entry.name()), + e, + cx, + ) + } else { + show_error_toast( + workspace, + format!("branch -d {}", entry.name()), + e, + cx, + ) + } })?; } @@ -343,13 +508,12 @@ impl BranchListDelegate { } picker.update_in(cx, |picker, _, cx| { - picker - .delegate - .matches - .retain(|entry| entry.branch.ref_name != branch_ref); + picker.delegate.matches.retain(|e| e != &entry); - if let Some(all_branches) = &mut picker.delegate.all_branches { - all_branches.retain(|branch| branch.ref_name != branch_ref); + if let Entry::Branch { branch, .. } = &entry { + if let Some(all_branches) = &mut picker.delegate.all_branches { + all_branches.retain(|e| e.ref_name != branch.ref_name); + } } if picker.delegate.matches.is_empty() { @@ -374,6 +538,45 @@ impl PickerDelegate for BranchListDelegate { "Select branch…".into() } + fn render_editor( + &self, + editor: &Entity, + window: &mut Window, + cx: &mut Context>, + ) -> Div { + cx.update_entity(editor, move |editor, cx| { + let placeholder = match self.state { + PickerState::List | PickerState::NewRemote | PickerState::NewBranch => { + if self.display_remotes { + "Select remote…" + } else { + "Select branch…" + } + } + PickerState::CreateRemote(_) => "Choose a name…", + }; + editor.set_placeholder_text(placeholder, window, cx); + }); + + v_flex() + .when( + self.editor_position() == PickerEditorPosition::End, + |this| this.child(Divider::horizontal()), + ) + .child( + h_flex() + .overflow_hidden() + .flex_none() + .h_9() + .px_2p5() + .child(editor.clone()), + ) + .when( + self.editor_position() == PickerEditorPosition::Start, + |this| this.child(Divider::horizontal()), + ) + } + fn editor_position(&self) -> PickerEditorPosition { match self.style { BranchListStyle::Modal => PickerEditorPosition::Start, @@ -409,20 +612,36 @@ impl PickerDelegate for BranchListDelegate { }; const RECENT_BRANCHES_COUNT: usize = 10; + let display_remotes = self.display_remotes; cx.spawn_in(window, async move |picker, cx| { - let mut matches: Vec = if query.is_empty() { + let mut matches: Vec = if query.is_empty() { all_branches .into_iter() - .filter(|branch| !branch.is_remote()) + .filter(|branch| { + if display_remotes { + branch.is_remote() + } else { + !branch.is_remote() + } + }) .take(RECENT_BRANCHES_COUNT) - .map(|branch| BranchEntry { + .map(|branch| Entry::Branch { branch, positions: Vec::new(), - is_new: false, }) .collect() } else { - let candidates = all_branches + let branches = all_branches + .iter() + .filter(|branch| { + if display_remotes { + branch.is_remote() + } else { + !branch.is_remote() + } + }) + .collect::>(); + let candidates = branches .iter() .enumerate() .map(|(ix, branch)| StringMatchCandidate::new(ix, branch.name())) @@ -438,31 +657,40 @@ impl PickerDelegate for BranchListDelegate { ) .await .into_iter() - .map(|candidate| BranchEntry { - branch: all_branches[candidate.candidate_id].clone(), + .map(|candidate| Entry::Branch { + branch: branches[candidate.candidate_id].clone(), positions: candidate.positions, - is_new: false, }) .collect() }; picker .update(cx, |picker, _| { + if matches!(picker.delegate.state, PickerState::CreateRemote(_)) { + picker.delegate.last_query = query; + picker.delegate.matches = Vec::new(); + picker.delegate.selected_index = 0; + + return; + } + if !query.is_empty() - && !matches - .first() - .is_some_and(|entry| entry.branch.name() == query) + && !matches.first().is_some_and(|entry| entry.name() == query) { let query = query.replace(' ', "-"); - matches.push(BranchEntry { - branch: Branch { - ref_name: format!("refs/heads/{query}").into(), - is_head: false, - upstream: None, - most_recent_commit: None, - }, - positions: Vec::new(), - is_new: true, - }) + let is_url = query.trim_start_matches("git@").parse::().is_ok(); + let entry = if is_url { + Entry::NewUrl { url: query } + } else { + Entry::NewBranch { name: query } + }; + picker.delegate.state = if is_url { + PickerState::NewRemote + } else { + PickerState::NewBranch + }; + matches.push(entry); + } else { + picker.delegate.state = PickerState::List; } let delegate = &mut picker.delegate; delegate.matches = matches; @@ -479,56 +707,78 @@ impl PickerDelegate for BranchListDelegate { } fn confirm(&mut self, secondary: bool, window: &mut Window, cx: &mut Context>) { - let Some(entry) = self.matches.get(self.selected_index()) else { - return; - }; - - if entry.is_new { - let from_branch = if secondary { - self.default_branch.clone() - } else { - None - }; - self.create_branch( - from_branch, - entry.branch.name().to_owned().into(), - window, - cx, - ); - return; - } - - let current_branch = self.repo.as_ref().map(|repo| { - repo.read_with(cx, |repo, _| { - repo.branch.as_ref().map(|branch| branch.ref_name.clone()) - }) - }); - - if current_branch - .flatten() - .is_some_and(|current_branch| current_branch == entry.branch.ref_name) - { - cx.emit(DismissEvent); + if let PickerState::CreateRemote(remote_url) = &self.state { + self.create_remote(self.last_query.clone(), remote_url.to_string(), window, cx); + self.state = PickerState::List; + cx.notify(); return; } - let Some(repo) = self.repo.clone() else { + let Some(entry) = self.matches.get(self.selected_index()) else { return; }; - let branch = entry.branch.clone(); - cx.spawn(async move |_, cx| { - repo.update(cx, |repo, _| repo.change_branch(branch.name().to_string()))? - .await??; + match entry { + Entry::Branch { branch, .. } => { + let current_branch = self.repo.as_ref().map(|repo| { + repo.read_with(cx, |repo, _| { + repo.branch.as_ref().map(|branch| branch.ref_name.clone()) + }) + }); + + if current_branch + .flatten() + .is_some_and(|current_branch| current_branch == branch.ref_name) + { + cx.emit(DismissEvent); + return; + } - anyhow::Ok(()) - }) - .detach_and_prompt_err("Failed to change branch", window, cx, |_, _, _| None); + let Some(repo) = self.repo.clone() else { + return; + }; + + let branch = branch.clone(); + cx.spawn(async move |_, cx| { + repo.update(cx, |repo, _| repo.change_branch(branch.name().to_string()))? + .await??; + + anyhow::Ok(()) + }) + .detach_and_prompt_err( + "Failed to change branch", + window, + cx, + |_, _, _| None, + ); + } + Entry::NewUrl { url } => { + self.state = PickerState::CreateRemote(url.clone().into()); + self.matches = Vec::new(); + self.selected_index = 0; + cx.spawn_in(window, async move |this, cx| { + this.update_in(cx, |picker, window, cx| { + picker.set_query("", window, cx); + }) + }) + .detach_and_log_err(cx); + cx.notify(); + } + Entry::NewBranch { name } => { + let from_branch = if secondary { + self.default_branch.clone() + } else { + None + }; + self.create_branch(from_branch, format!("refs/heads/{name}").into(), window, cx); + } + } cx.emit(DismissEvent); } fn dismissed(&mut self, _: &mut Window, cx: &mut Context>) { + self.state = PickerState::List; cx.emit(DismissEvent); } @@ -542,49 +792,60 @@ impl PickerDelegate for BranchListDelegate { let entry = &self.matches.get(ix)?; let (commit_time, author_name, subject) = entry - .branch - .most_recent_commit - .as_ref() - .map(|commit| { - let subject = commit.subject.clone(); - let commit_time = OffsetDateTime::from_unix_timestamp(commit.commit_timestamp) - .unwrap_or_else(|_| OffsetDateTime::now_utc()); - let local_offset = - time::UtcOffset::current_local_offset().unwrap_or(time::UtcOffset::UTC); - let formatted_time = time_format::format_localized_timestamp( - commit_time, - OffsetDateTime::now_utc(), - local_offset, - time_format::TimestampFormat::Relative, - ); - let author = commit.author_name.clone(); - (Some(formatted_time), Some(author), Some(subject)) + .as_branch() + .and_then(|branch| { + branch.most_recent_commit.as_ref().map(|commit| { + let subject = commit.subject.clone(); + let commit_time = OffsetDateTime::from_unix_timestamp(commit.commit_timestamp) + .unwrap_or_else(|_| OffsetDateTime::now_utc()); + let local_offset = + time::UtcOffset::current_local_offset().unwrap_or(time::UtcOffset::UTC); + let formatted_time = time_format::format_localized_timestamp( + commit_time, + OffsetDateTime::now_utc(), + local_offset, + time_format::TimestampFormat::Relative, + ); + let author = commit.author_name.clone(); + (Some(formatted_time), Some(author), Some(subject)) + }) }) .unwrap_or_else(|| (None, None, None)); - let icon = if let Some(default_branch) = self.default_branch.clone() - && entry.is_new - { - Some( - IconButton::new("branch-from-default", IconName::GitBranchAlt) + let icon = if let Some(default_branch) = self.default_branch.clone() { + let icon = match &entry { + Entry::Branch { .. } => Some(( + IconName::GitBranchAlt, + format!("Create branch based off default: {default_branch}"), + )), + Entry::NewUrl { url } => { + Some((IconName::Screen, format!("Create remote based off {url}"))) + } + Entry::NewBranch { .. } => None, + }; + + icon.map(|(icon, tooltip_text)| { + IconButton::new("branch-from-default", icon) .on_click(cx.listener(move |this, _, window, cx| { this.delegate.set_selected_index(ix, window, cx); this.delegate.confirm(true, window, cx); })) .tooltip(move |_window, cx| { - Tooltip::for_action( - format!("Create branch based off default: {default_branch}"), - &menu::SecondaryConfirm, - cx, - ) - }), - ) + Tooltip::for_action(tooltip_text.clone(), &menu::SecondaryConfirm, cx) + }) + }) } else { None }; - let branch_name = if entry.is_new { - h_flex() + let icon_element = if self.display_remotes { + Icon::new(IconName::Screen) + } else { + Icon::new(IconName::GitBranchAlt) + }; + + let entry_name = match entry { + Entry::NewUrl { .. } => h_flex() .gap_1() .child( Icon::new(IconName::Plus) @@ -592,19 +853,31 @@ impl PickerDelegate for BranchListDelegate { .color(Color::Muted), ) .child( - Label::new(format!("Create branch \"{}\"…", entry.branch.name())) + Label::new("Create remote repository".to_string()) .single_line() .truncate(), ) - .into_any_element() - } else { - h_flex() - .max_w_48() + .into_any_element(), + Entry::NewBranch { name } => h_flex() + .gap_1() .child( - HighlightedLabel::new(entry.branch.name().to_owned(), entry.positions.clone()) + Icon::new(IconName::Plus) + .size(IconSize::Small) + .color(Color::Muted), + ) + .child( + Label::new(format!("Create branch \"{name}\"…")) + .single_line() .truncate(), ) - .into_any_element() + .into_any_element(), + Entry::Branch { branch, positions } => h_flex() + .max_w_48() + .child(h_flex().mr_1().child(icon_element)) + .child( + HighlightedLabel::new(branch.name().to_string(), positions.clone()).truncate(), + ) + .into_any_element(), }; Some( @@ -613,11 +886,14 @@ impl PickerDelegate for BranchListDelegate { .spacing(ListItemSpacing::Sparse) .toggle_state(selected) .tooltip({ - let branch_name = entry.branch.name().to_string(); - if entry.is_new { - Tooltip::text(format!("Create branch \"{}\"", branch_name)) - } else { - Tooltip::text(branch_name) + match entry { + Entry::Branch { branch, .. } => Tooltip::text(branch.name().to_string()), + Entry::NewUrl { .. } => { + Tooltip::text("Create remote repository".to_string()) + } + Entry::NewBranch { name } => { + Tooltip::text(format!("Create branch \"{name}\"")) + } } }) .child( @@ -629,7 +905,7 @@ impl PickerDelegate for BranchListDelegate { .gap_6() .justify_between() .overflow_x_hidden() - .child(branch_name) + .child(entry_name) .when_some(commit_time, |label, commit_time| { label.child( Label::new(commit_time) @@ -641,30 +917,35 @@ impl PickerDelegate for BranchListDelegate { ) .when(self.style == BranchListStyle::Modal, |el| { el.child(div().max_w_96().child({ - let message = if entry.is_new { - if let Some(current_branch) = - self.repo.as_ref().and_then(|repo| { - repo.read(cx).branch.as_ref().map(|b| b.name()) - }) - { - format!("based off {}", current_branch) - } else { - "based off the current branch".to_string() - } - } else { - let show_author_name = ProjectSettings::get_global(cx) - .git - .branch_picker - .show_author_name; - - subject.map_or("no commits found".into(), |subject| { - if show_author_name && author_name.is_some() { - format!("{} • {}", author_name.unwrap(), subject) + let message = match entry { + Entry::NewUrl { url } => format!("based off {url}"), + Entry::NewBranch { .. } => { + if let Some(current_branch) = + self.repo.as_ref().and_then(|repo| { + repo.read(cx).branch.as_ref().map(|b| b.name()) + }) + { + format!("based off {}", current_branch) } else { - subject.to_string() + "based off the current branch".to_string() } - }) + } + Entry::Branch { .. } => { + let show_author_name = ProjectSettings::get_global(cx) + .git + .branch_picker + .show_author_name; + + subject.map_or("no commits found".into(), |subject| { + if show_author_name && author_name.is_some() { + format!("{} • {}", author_name.unwrap(), subject) + } else { + subject.to_string() + } + }) + } }; + Label::new(message) .size(LabelSize::Small) .truncate() @@ -676,40 +957,715 @@ impl PickerDelegate for BranchListDelegate { ) } - fn render_footer( + fn render_header( &self, _window: &mut Window, cx: &mut Context>, ) -> Option { - let focus_handle = self.focus_handle.clone(); - + if matches!( + self.state, + PickerState::CreateRemote(_) | PickerState::NewRemote | PickerState::NewBranch + ) { + return None; + } + let label = if self.display_remotes { + "Remote" + } else { + "Local" + }; Some( h_flex() .w_full() .p_1p5() - .gap_0p5() - .justify_end() + .gap_1() .border_t_1() .border_color(cx.theme().colors().border_variant) - .child( - Button::new("delete-branch", "Delete") - .key_binding( - KeyBinding::for_action_in( - &branch_picker::DeleteBranch, - &focus_handle, - cx, - ) - .map(|kb| kb.size(rems_from_px(12.))), - ) - .on_click(|_, window, cx| { - window.dispatch_action(branch_picker::DeleteBranch.boxed_clone(), cx); - }), - ) + .child(Label::new(label).size(LabelSize::Small).color(Color::Muted)) .into_any(), ) } + fn render_footer(&self, _: &mut Window, cx: &mut Context>) -> Option { + let focus_handle = self.focus_handle.clone(); + + if self.loading { + return Some( + h_flex() + .w_full() + .p_1p5() + .gap_1() + .justify_end() + .border_t_1() + .border_color(cx.theme().colors().border_variant) + .child(self.loader()) + .into_any(), + ); + } + match self.state { + PickerState::List => Some( + h_flex() + .w_full() + .p_1p5() + .gap_0p5() + .border_t_1() + .border_color(cx.theme().colors().border_variant) + .justify_between() + .child( + Button::new("filter-remotes", "Filter remotes") + .key_binding( + KeyBinding::for_action_in( + &branch_picker::FilterRemotes, + &focus_handle, + cx, + ) + .map(|kb| kb.size(rems_from_px(12.))), + ) + .on_click(|_click, window, cx| { + window.dispatch_action( + branch_picker::FilterRemotes.boxed_clone(), + cx, + ); + }) + .disabled(self.loading) + .style(ButtonStyle::Subtle) + .toggle_state(self.display_remotes), + ) + .child( + Button::new("delete-branch", "Delete") + .key_binding( + KeyBinding::for_action_in( + &branch_picker::DeleteBranch, + &focus_handle, + cx, + ) + .map(|kb| kb.size(rems_from_px(12.))), + ) + .disabled(self.loading) + .on_click(|_, window, cx| { + window + .dispatch_action(branch_picker::DeleteBranch.boxed_clone(), cx); + }), + ) + .when(self.loading, |this| this.child(self.loader())) + .into_any(), + ), + PickerState::CreateRemote(_) => Some( + h_flex() + .w_full() + .p_1p5() + .gap_1() + .border_t_1() + .border_color(cx.theme().colors().border_variant) + .child( + Label::new("Choose a name for this remote repository") + .size(LabelSize::Small) + .color(Color::Muted), + ) + .child( + h_flex().w_full().justify_end().child( + Label::new("Save") + .size(LabelSize::Small) + .color(Color::Muted), + ), + ) + .into_any(), + ), + PickerState::NewRemote | PickerState::NewBranch => None, + } + } + fn no_matches_text(&self, _window: &mut Window, _cx: &mut App) -> Option { None } } + +#[cfg(test)] +mod tests { + use std::collections::HashSet; + + use super::*; + use git::repository::{CommitSummary, Remote}; + use gpui::{TestAppContext, VisualTestContext}; + use project::{FakeFs, Project}; + use serde_json::json; + use settings::SettingsStore; + use util::path; + + fn init_test(cx: &mut TestAppContext) { + cx.update(|cx| { + let settings_store = SettingsStore::test(cx); + cx.set_global(settings_store); + theme::init(theme::LoadThemes::JustBase, cx); + }); + } + + fn create_test_branch( + name: &str, + is_head: bool, + remote_name: Option<&str>, + timestamp: Option, + ) -> Branch { + let ref_name = match remote_name { + Some(remote_name) => format!("refs/remotes/{remote_name}/{name}"), + None => format!("refs/heads/{name}"), + }; + + Branch { + is_head, + ref_name: ref_name.into(), + upstream: None, + most_recent_commit: timestamp.map(|ts| CommitSummary { + sha: "abc123".into(), + commit_timestamp: ts, + author_name: "Test Author".into(), + subject: "Test commit".into(), + has_parent: true, + }), + } + } + + fn create_test_branches() -> Vec { + vec![ + create_test_branch("main", true, None, Some(1000)), + create_test_branch("feature-auth", false, None, Some(900)), + create_test_branch("feature-ui", false, None, Some(800)), + create_test_branch("develop", false, None, Some(700)), + ] + } + + fn init_branch_list_test( + cx: &mut TestAppContext, + repository: Option>, + branches: Vec, + ) -> (VisualTestContext, Entity) { + let window = cx.add_window(|window, cx| { + let mut delegate = + BranchListDelegate::new(None, repository, BranchListStyle::Modal, cx); + delegate.all_branches = Some(branches); + let picker = cx.new(|cx| Picker::uniform_list(delegate, window, cx)); + let picker_focus_handle = picker.focus_handle(cx); + picker.update(cx, |picker, _| { + picker.delegate.focus_handle = picker_focus_handle.clone(); + }); + + let _subscription = cx.subscribe(&picker, |_, _, _, cx| { + cx.emit(DismissEvent); + }); + + BranchList { + picker, + picker_focus_handle, + width: rems(34.), + _subscription, + } + }); + + let branch_list = window.root(cx).unwrap(); + let cx = VisualTestContext::from_window(*window, cx); + + (cx, branch_list) + } + + async fn init_fake_repository(cx: &mut TestAppContext) -> Entity { + let fs = FakeFs::new(cx.executor()); + fs.insert_tree( + path!("/dir"), + json!({ + ".git": {}, + "file.txt": "buffer_text".to_string() + }), + ) + .await; + fs.set_head_for_repo( + path!("/dir/.git").as_ref(), + &[("file.txt", "test".to_string())], + "deadbeef", + ); + fs.set_index_for_repo( + path!("/dir/.git").as_ref(), + &[("file.txt", "index_text".to_string())], + ); + + let project = Project::test(fs.clone(), [path!("/dir").as_ref()], cx).await; + let repository = cx.read(|cx| project.read(cx).active_repository(cx)); + + repository.unwrap() + } + + #[gpui::test] + async fn test_update_branch_matches_with_query(cx: &mut TestAppContext) { + init_test(cx); + + let branches = create_test_branches(); + let (mut ctx, branch_list) = init_branch_list_test(cx, None, branches); + let cx = &mut ctx; + + branch_list + .update_in(cx, |branch_list, window, cx| { + let query = "feature".to_string(); + branch_list.picker.update(cx, |picker, cx| { + picker.delegate.update_matches(query, window, cx) + }) + }) + .await; + cx.run_until_parked(); + + branch_list.update(cx, |branch_list, cx| { + branch_list.picker.update(cx, |picker, _cx| { + // Should have 2 existing branches + 1 "create new branch" entry = 3 total + assert_eq!(picker.delegate.matches.len(), 3); + assert!( + picker + .delegate + .matches + .iter() + .any(|m| m.name() == "feature-auth") + ); + assert!( + picker + .delegate + .matches + .iter() + .any(|m| m.name() == "feature-ui") + ); + // Verify the last entry is the "create new branch" option + let last_match = picker.delegate.matches.last().unwrap(); + assert!(last_match.is_new_branch()); + }) + }); + } + + async fn update_branch_list_matches_with_empty_query( + branch_list: &Entity, + cx: &mut VisualTestContext, + ) { + branch_list + .update_in(cx, |branch_list, window, cx| { + branch_list.picker.update(cx, |picker, cx| { + picker.delegate.update_matches(String::new(), window, cx) + }) + }) + .await; + cx.run_until_parked(); + } + + #[gpui::test] + async fn test_delete_branch(cx: &mut TestAppContext) { + init_test(cx); + let repository = init_fake_repository(cx).await; + + let branches = create_test_branches(); + + let branch_names = branches + .iter() + .map(|branch| branch.name().to_string()) + .collect::>(); + let repo = repository.clone(); + cx.spawn(async move |mut cx| { + for branch in branch_names { + repo.update(&mut cx, |repo, _| repo.create_branch(branch, None)) + .unwrap() + .await + .unwrap() + .unwrap(); + } + }) + .await; + cx.run_until_parked(); + + let (mut ctx, branch_list) = init_branch_list_test(cx, repository.into(), branches); + let cx = &mut ctx; + + update_branch_list_matches_with_empty_query(&branch_list, cx).await; + + let branch_to_delete = branch_list.update_in(cx, |branch_list, window, cx| { + branch_list.picker.update(cx, |picker, cx| { + assert_eq!(picker.delegate.matches.len(), 4); + let branch_to_delete = picker.delegate.matches.get(1).unwrap().name().to_string(); + picker.delegate.delete_at(1, window, cx); + branch_to_delete + }) + }); + cx.run_until_parked(); + + branch_list.update(cx, move |branch_list, cx| { + branch_list.picker.update(cx, move |picker, _cx| { + assert_eq!(picker.delegate.matches.len(), 3); + let branches = picker + .delegate + .matches + .iter() + .map(|be| be.name()) + .collect::>(); + assert_eq!( + branches, + ["main", "feature-auth", "feature-ui", "develop"] + .into_iter() + .filter(|name| name != &branch_to_delete) + .collect::>() + ); + }) + }); + } + + #[gpui::test] + async fn test_delete_remote(cx: &mut TestAppContext) { + init_test(cx); + let repository = init_fake_repository(cx).await; + let branches = vec![ + create_test_branch("main", true, Some("origin"), Some(1000)), + create_test_branch("feature-auth", false, Some("origin"), Some(900)), + create_test_branch("feature-ui", false, Some("fork"), Some(800)), + create_test_branch("develop", false, Some("private"), Some(700)), + ]; + + let remote_names = branches + .iter() + .filter_map(|branch| branch.remote_name().map(|r| r.to_string())) + .collect::>(); + let repo = repository.clone(); + cx.spawn(async move |mut cx| { + for branch in remote_names { + repo.update(&mut cx, |repo, _| { + repo.create_remote(branch, String::from("test")) + }) + .unwrap() + .await + .unwrap() + .unwrap(); + } + }) + .await; + cx.run_until_parked(); + + let (mut ctx, branch_list) = init_branch_list_test(cx, repository.into(), branches); + let cx = &mut ctx; + // Enable remote filter + branch_list.update(cx, |branch_list, cx| { + branch_list.picker.update(cx, |picker, _cx| { + picker.delegate.display_remotes = true; + }); + }); + update_branch_list_matches_with_empty_query(&branch_list, cx).await; + + // Check matches, it should match all existing branches and no option to create new branch + let branch_to_delete = branch_list.update_in(cx, |branch_list, window, cx| { + branch_list.picker.update(cx, |picker, cx| { + assert_eq!(picker.delegate.matches.len(), 4); + let branch_to_delete = picker.delegate.matches.get(1).unwrap().name().to_string(); + picker.delegate.delete_at(1, window, cx); + branch_to_delete + }) + }); + cx.run_until_parked(); + + // Check matches, it should match one less branch than before + branch_list.update(cx, move |branch_list, cx| { + branch_list.picker.update(cx, move |picker, _cx| { + assert_eq!(picker.delegate.matches.len(), 3); + let branches = picker + .delegate + .matches + .iter() + .map(|be| be.name()) + .collect::>(); + assert_eq!( + branches, + [ + "origin/main", + "origin/feature-auth", + "fork/feature-ui", + "private/develop" + ] + .into_iter() + .filter(|name| name != &branch_to_delete) + .collect::>() + ); + }) + }); + } + + #[gpui::test] + async fn test_update_remote_matches_with_query(cx: &mut TestAppContext) { + init_test(cx); + + let branches = vec![ + create_test_branch("main", true, Some("origin"), Some(1000)), + create_test_branch("feature-auth", false, Some("fork"), Some(900)), + create_test_branch("feature-ui", false, None, Some(800)), + create_test_branch("develop", false, None, Some(700)), + ]; + + let (mut ctx, branch_list) = init_branch_list_test(cx, None, branches); + let cx = &mut ctx; + + update_branch_list_matches_with_empty_query(&branch_list, cx).await; + + // Check matches, it should match all existing branches and no option to create new branch + branch_list + .update_in(cx, |branch_list, window, cx| { + branch_list.picker.update(cx, |picker, cx| { + assert_eq!(picker.delegate.matches.len(), 2); + let branches = picker + .delegate + .matches + .iter() + .map(|be| be.name()) + .collect::>(); + assert_eq!( + branches, + ["feature-ui", "develop"] + .into_iter() + .collect::>() + ); + + // Verify the last entry is NOT the "create new branch" option + let last_match = picker.delegate.matches.last().unwrap(); + assert!(!last_match.is_new_branch()); + assert!(!last_match.is_new_url()); + picker.delegate.display_remotes = true; + picker.delegate.update_matches(String::new(), window, cx) + }) + }) + .await; + cx.run_until_parked(); + + branch_list + .update_in(cx, |branch_list, window, cx| { + branch_list.picker.update(cx, |picker, cx| { + assert_eq!(picker.delegate.matches.len(), 2); + let branches = picker + .delegate + .matches + .iter() + .map(|be| be.name()) + .collect::>(); + assert_eq!( + branches, + ["origin/main", "fork/feature-auth"] + .into_iter() + .collect::>() + ); + + // Verify the last entry is NOT the "create new branch" option + let last_match = picker.delegate.matches.last().unwrap(); + assert!(!last_match.is_new_url()); + picker.delegate.display_remotes = true; + picker + .delegate + .update_matches(String::from("fork"), window, cx) + }) + }) + .await; + cx.run_until_parked(); + + branch_list.update(cx, |branch_list, cx| { + branch_list.picker.update(cx, |picker, _cx| { + // Should have 1 existing branch + 1 "create new branch" entry = 2 total + assert_eq!(picker.delegate.matches.len(), 2); + assert!( + picker + .delegate + .matches + .iter() + .any(|m| m.name() == "fork/feature-auth") + ); + // Verify the last entry is the "create new branch" option + let last_match = picker.delegate.matches.last().unwrap(); + assert!(last_match.is_new_branch()); + }) + }); + } + + #[gpui::test] + async fn test_new_branch_creation_with_query(test_cx: &mut TestAppContext) { + init_test(test_cx); + let repository = init_fake_repository(test_cx).await; + + let branches = vec![ + create_test_branch("main", true, None, Some(1000)), + create_test_branch("feature", false, None, Some(900)), + ]; + + let (mut ctx, branch_list) = init_branch_list_test(test_cx, repository.into(), branches); + let cx = &mut ctx; + + branch_list + .update_in(cx, |branch_list, window, cx| { + branch_list.picker.update(cx, |picker, cx| { + let query = "new-feature-branch".to_string(); + picker.delegate.update_matches(query, window, cx) + }) + }) + .await; + + cx.run_until_parked(); + + branch_list.update_in(cx, |branch_list, window, cx| { + branch_list.picker.update(cx, |picker, cx| { + let last_match = picker.delegate.matches.last().unwrap(); + assert!(last_match.is_new_branch()); + assert_eq!(last_match.name(), "new-feature-branch"); + assert!(matches!(picker.delegate.state, PickerState::NewBranch)); + picker.delegate.confirm(false, window, cx); + }) + }); + cx.run_until_parked(); + + let branches = branch_list + .update(cx, |branch_list, cx| { + branch_list.picker.update(cx, |picker, cx| { + picker + .delegate + .repo + .as_ref() + .unwrap() + .update(cx, |repo, _cx| repo.branches()) + }) + }) + .await + .unwrap() + .unwrap(); + + assert!( + branches + .into_iter() + .any(|branch| branch.name() == "new-feature-branch") + ); + } + + #[gpui::test] + async fn test_remote_url_detection_https(cx: &mut TestAppContext) { + init_test(cx); + let repository = init_fake_repository(cx).await; + let branches = vec![create_test_branch("main", true, None, Some(1000))]; + + let (mut ctx, branch_list) = init_branch_list_test(cx, repository.into(), branches); + let cx = &mut ctx; + + branch_list + .update_in(cx, |branch_list, window, cx| { + branch_list.picker.update(cx, |picker, cx| { + let query = "https://github.com/user/repo.git".to_string(); + picker.delegate.update_matches(query, window, cx) + }) + }) + .await; + + cx.run_until_parked(); + + branch_list + .update_in(cx, |branch_list, window, cx| { + branch_list.picker.update(cx, |picker, cx| { + let last_match = picker.delegate.matches.last().unwrap(); + assert!(last_match.is_new_url()); + assert!(matches!(picker.delegate.state, PickerState::NewRemote)); + picker.delegate.confirm(false, window, cx); + assert_eq!(picker.delegate.matches.len(), 0); + if let PickerState::CreateRemote(remote_url) = &picker.delegate.state + && remote_url.as_ref() == "https://github.com/user/repo.git" + { + } else { + panic!("wrong picker state"); + } + picker + .delegate + .update_matches("my_new_remote".to_string(), window, cx) + }) + }) + .await; + + cx.run_until_parked(); + + branch_list.update_in(cx, |branch_list, window, cx| { + branch_list.picker.update(cx, |picker, cx| { + picker.delegate.confirm(false, window, cx); + assert_eq!(picker.delegate.matches.len(), 0); + }) + }); + cx.run_until_parked(); + + // List remotes + let remotes = branch_list + .update(cx, |branch_list, cx| { + branch_list.picker.update(cx, |picker, cx| { + picker + .delegate + .repo + .as_ref() + .unwrap() + .update(cx, |repo, _cx| repo.get_remotes(None, false)) + }) + }) + .await + .unwrap() + .unwrap(); + assert_eq!( + remotes, + vec![Remote { + name: SharedString::from("my_new_remote".to_string()) + }] + ); + } + + #[gpui::test] + async fn test_confirm_remote_url_transitions(cx: &mut TestAppContext) { + init_test(cx); + + let branches = vec![create_test_branch("main_branch", true, None, Some(1000))]; + let (mut ctx, branch_list) = init_branch_list_test(cx, None, branches); + let cx = &mut ctx; + + branch_list + .update_in(cx, |branch_list, window, cx| { + branch_list.picker.update(cx, |picker, cx| { + let query = "https://github.com/user/repo.git".to_string(); + picker.delegate.update_matches(query, window, cx) + }) + }) + .await; + cx.run_until_parked(); + + // Try to create a new remote but cancel in the middle of the process + branch_list + .update_in(cx, |branch_list, window, cx| { + branch_list.picker.update(cx, |picker, cx| { + picker.delegate.selected_index = picker.delegate.matches.len() - 1; + picker.delegate.confirm(false, window, cx); + + assert!(matches!( + picker.delegate.state, + PickerState::CreateRemote(_) + )); + if let PickerState::CreateRemote(ref url) = picker.delegate.state { + assert_eq!(url.as_ref(), "https://github.com/user/repo.git"); + } + assert_eq!(picker.delegate.matches.len(), 0); + picker.delegate.dismissed(window, cx); + assert!(matches!(picker.delegate.state, PickerState::List)); + let query = "main".to_string(); + picker.delegate.update_matches(query, window, cx) + }) + }) + .await; + cx.run_until_parked(); + + // Try to search a branch again to see if the state is restored properly + branch_list.update(cx, |branch_list, cx| { + branch_list.picker.update(cx, |picker, _cx| { + // Should have 1 existing branch + 1 "create new branch" entry = 2 total + assert_eq!(picker.delegate.matches.len(), 2); + assert!( + picker + .delegate + .matches + .iter() + .any(|m| m.name() == "main_branch") + ); + // Verify the last entry is the "create new branch" option + let last_match = picker.delegate.matches.last().unwrap(); + assert!(last_match.is_new_branch()); + }) + }); + } +} diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs index 62bd118daf1751e32dd0b805a773be47e19e4357..c6895f4c15d5afd3ef50ce796059956dd8653f8b 100644 --- a/crates/git_ui/src/git_panel.rs +++ b/crates/git_ui/src/git_panel.rs @@ -3463,7 +3463,6 @@ impl GitPanel { ) -> Option { let active_repository = self.active_repository.clone()?; let panel_editor_style = panel_editor_style(true, window, cx); - let enable_coauthors = self.render_co_authors(cx); let editor_focus_handle = self.commit_editor.focus_handle(cx); @@ -4772,7 +4771,6 @@ impl RenderOnce for PanelRepoFooter { const MAX_REPO_LEN: usize = 16; const LABEL_CHARACTER_BUDGET: usize = MAX_BRANCH_LEN + MAX_REPO_LEN; const MAX_SHORT_SHA_LEN: usize = 8; - let branch_name = self .branch .as_ref() diff --git a/crates/git_ui/src/remote_output.rs b/crates/git_ui/src/remote_output.rs index 8437bf0d0d37c2b2767624110fed056bbae25d05..7fe863ee29df20ca0f61cef5bf64cdae4b198c7a 100644 --- a/crates/git_ui/src/remote_output.rs +++ b/crates/git_ui/src/remote_output.rs @@ -1,4 +1,5 @@ use anyhow::Context as _; + use git::repository::{Remote, RemoteCommandOutput}; use linkify::{LinkFinder, LinkKind}; use ui::SharedString; diff --git a/crates/project/src/git_store.rs b/crates/project/src/git_store.rs index 5bc3f4ee43493ee9d07ab2c3a1025214007a653d..81511b21be3599b4686b9fd11aac5118711f11fa 100644 --- a/crates/project/src/git_store.rs +++ b/crates/project/src/git_store.rs @@ -472,6 +472,8 @@ impl GitStore { client.add_entity_request_handler(Self::handle_change_branch); client.add_entity_request_handler(Self::handle_create_branch); client.add_entity_request_handler(Self::handle_rename_branch); + client.add_entity_request_handler(Self::handle_create_remote); + client.add_entity_request_handler(Self::handle_remove_remote); client.add_entity_request_handler(Self::handle_delete_branch); client.add_entity_request_handler(Self::handle_git_init); client.add_entity_request_handler(Self::handle_push); @@ -2274,6 +2276,25 @@ impl GitStore { Ok(proto::Ack {}) } + async fn handle_create_remote( + this: Entity, + envelope: TypedEnvelope, + mut cx: AsyncApp, + ) -> Result { + let repository_id = RepositoryId::from_proto(envelope.payload.repository_id); + let repository_handle = Self::repository_for_request(&this, repository_id, &mut cx)?; + let remote_name = envelope.payload.remote_name; + let remote_url = envelope.payload.remote_url; + + repository_handle + .update(&mut cx, |repository_handle, _| { + repository_handle.create_remote(remote_name, remote_url) + })? + .await??; + + Ok(proto::Ack {}) + } + async fn handle_delete_branch( this: Entity, envelope: TypedEnvelope, @@ -2292,6 +2313,24 @@ impl GitStore { Ok(proto::Ack {}) } + async fn handle_remove_remote( + this: Entity, + envelope: TypedEnvelope, + mut cx: AsyncApp, + ) -> Result { + let repository_id = RepositoryId::from_proto(envelope.payload.repository_id); + let repository_handle = Self::repository_for_request(&this, repository_id, &mut cx)?; + let remote_name = envelope.payload.remote_name; + + repository_handle + .update(&mut cx, |repository_handle, _| { + repository_handle.remove_remote(remote_name) + })? + .await??; + + Ok(proto::Ack {}) + } + async fn handle_show( this: Entity, envelope: TypedEnvelope, @@ -4865,6 +4904,61 @@ impl Repository { ) } + pub fn create_remote( + &mut self, + remote_name: String, + remote_url: String, + ) -> oneshot::Receiver> { + let id = self.id; + self.send_job( + Some(format!("git remote add {remote_name} {remote_url}").into()), + move |repo, _cx| async move { + match repo { + RepositoryState::Local(LocalRepositoryState { backend, .. }) => { + backend.create_remote(remote_name, remote_url).await + } + RepositoryState::Remote(RemoteRepositoryState { project_id, client }) => { + client + .request(proto::GitCreateRemote { + project_id: project_id.0, + repository_id: id.to_proto(), + remote_name, + remote_url, + }) + .await?; + + Ok(()) + } + } + }, + ) + } + + pub fn remove_remote(&mut self, remote_name: String) -> oneshot::Receiver> { + let id = self.id; + self.send_job( + Some(format!("git remove remote {remote_name}").into()), + move |repo, _cx| async move { + match repo { + RepositoryState::Local(LocalRepositoryState { backend, .. }) => { + backend.remove_remote(remote_name).await + } + RepositoryState::Remote(RemoteRepositoryState { project_id, client }) => { + client + .request(proto::GitRemoveRemote { + project_id: project_id.0, + repository_id: id.to_proto(), + remote_name, + }) + .await?; + + Ok(()) + } + } + }, + ) + } + pub fn get_remotes( &mut self, branch_name: Option, @@ -4902,7 +4996,7 @@ impl Repository { let remotes = response .remotes .into_iter() - .map(|remotes| git::repository::Remote { + .map(|remotes| Remote { name: remotes.name.into(), }) .collect(); diff --git a/crates/proto/proto/git.proto b/crates/proto/proto/git.proto index de6a5f676df7332d0673d4e5bd75130bf7f0c400..aa0668ceabddc7627fcc3593b86ad2f4e40a6ac7 100644 --- a/crates/proto/proto/git.proto +++ b/crates/proto/proto/git.proto @@ -190,6 +190,19 @@ message GitRenameBranch { string new_name = 4; } +message GitCreateRemote { + uint64 project_id = 1; + uint64 repository_id = 2; + string remote_name = 3; + string remote_url = 4; +} + +message GitRemoveRemote { + uint64 project_id = 1; + uint64 repository_id = 2; + string remote_name = 3; +} + message GitDeleteBranch { uint64 project_id = 1; uint64 repository_id = 2; diff --git a/crates/proto/proto/zed.proto b/crates/proto/proto/zed.proto index 39faeeac88cfc49cbaba4a777da3fb8daa015a66..8e26a26a43ff8af5c1b676f5dc7f8fe49e67e19f 100644 --- a/crates/proto/proto/zed.proto +++ b/crates/proto/proto/zed.proto @@ -437,13 +437,18 @@ message Envelope { OpenImageResponse open_image_response = 392; CreateImageForPeer create_image_for_peer = 393; + GitFileHistory git_file_history = 397; GitFileHistoryResponse git_file_history_response = 398; RunGitHook run_git_hook = 399; GitDeleteBranch git_delete_branch = 400; - ExternalExtensionAgentsUpdated external_extension_agents_updated = 401; // current max + + ExternalExtensionAgentsUpdated external_extension_agents_updated = 401; + + GitCreateRemote git_create_remote = 402; + GitRemoveRemote git_remove_remote = 403;// current max } reserved 87 to 88, 396; diff --git a/crates/proto/src/proto.rs b/crates/proto/src/proto.rs index 38a994a37b6c62f7a1f078eb287f120c49b0ce82..455f94704663dcd96e37487b1a4243850634c18e 100644 --- a/crates/proto/src/proto.rs +++ b/crates/proto/src/proto.rs @@ -305,6 +305,8 @@ messages!( (RemoteMessageResponse, Background), (AskPassRequest, Background), (AskPassResponse, Background), + (GitCreateRemote, Background), + (GitRemoveRemote, Background), (GitCreateBranch, Background), (GitChangeBranch, Background), (GitRenameBranch, Background), @@ -504,6 +506,8 @@ request_messages!( (GetRemotes, GetRemotesResponse), (Pull, RemoteMessageResponse), (AskPassRequest, AskPassResponse), + (GitCreateRemote, Ack), + (GitRemoveRemote, Ack), (GitCreateBranch, Ack), (GitChangeBranch, Ack), (GitRenameBranch, Ack), @@ -676,6 +680,8 @@ entity_messages!( GitChangeBranch, GitRenameBranch, GitCreateBranch, + GitCreateRemote, + GitRemoveRemote, CheckForPushedCommits, GitDiff, GitInit, diff --git a/crates/zed_actions/src/lib.rs b/crates/zed_actions/src/lib.rs index 803fde3f8787b4f6489bd6390d289c35b1c96199..d4d28433d4c76dcab3df627789df82e99854fbc1 100644 --- a/crates/zed_actions/src/lib.rs +++ b/crates/zed_actions/src/lib.rs @@ -215,6 +215,10 @@ pub mod git { Switch, /// Selects a different repository. SelectRepo, + /// Filter remotes. + FilterRemotes, + /// Create a git remote. + CreateRemote, /// Opens the git branch selector. #[action(deprecated_aliases = ["branches::OpenRecent"])] Branch, From 2dad46c5c08dbe676c80a39cf9cf0ddac9562b64 Mon Sep 17 00:00:00 2001 From: Rawand Ahmed Shaswar Date: Thu, 4 Dec 2025 17:26:17 +0300 Subject: [PATCH 056/621] gpui: Fix division by zero when chars/sec = 0 on Wayland (#44151) Closes #44148 the existing rate == 0 check inside the timer callback already handles disabling repeat - it just drops the timer immediately. So the fix prevents the crash while preserving correct behavior. Release Notes: - Linux (Wayland): Fixed a crash that could occur when `characters_per_second` was zero --- crates/gpui/src/platform/linux/wayland/client.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/gpui/src/platform/linux/wayland/client.rs b/crates/gpui/src/platform/linux/wayland/client.rs index a2324648fbb332e75af7df74923806797d93a05a..2879925495e41fd37ea075f20a0de0b19625694e 100644 --- a/crates/gpui/src/platform/linux/wayland/client.rs +++ b/crates/gpui/src/platform/linux/wayland/client.rs @@ -1419,7 +1419,7 @@ impl Dispatch for WaylandClientStatePtr { state.repeat.current_keycode = Some(keycode); let rate = state.repeat.characters_per_second; - let repeat_interval = Duration::from_secs(1) / rate; + let repeat_interval = Duration::from_secs(1) / rate.max(1); let id = state.repeat.current_id; state .loop_handle From c978db8626584c96947405226b23483e50727bb0 Mon Sep 17 00:00:00 2001 From: Agus Zubiaga Date: Thu, 4 Dec 2025 11:30:16 -0300 Subject: [PATCH 057/621] Fix background scanner deadlock (#44109) Fixes a deadlock in the background scanner that occurs on single-core Linux devices. This happens because the background scanner would `block` on a background thread waiting for a future, but on single-core Linux devices there would be no other thread to pick it up. This mostly affects SSH remoting use cases where it's common for servers to have 1 vCPU. Closes #43884 Closes #43809 Release Notes: - Fix SSH remoting hang when connecting to 1 vCPU servers --- crates/worktree/src/worktree.rs | 62 ++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 24 deletions(-) diff --git a/crates/worktree/src/worktree.rs b/crates/worktree/src/worktree.rs index 152277af2e3f626aa0da608af275505b04d0af32..942e692a020049b102a0d810bfbf1a9074962611 100644 --- a/crates/worktree/src/worktree.rs +++ b/crates/worktree/src/worktree.rs @@ -52,7 +52,7 @@ use std::{ fmt, future::Future, mem::{self}, - ops::{Deref, DerefMut}, + ops::{Deref, DerefMut, Range}, path::{Path, PathBuf}, pin::Pin, sync::{ @@ -3877,29 +3877,35 @@ impl BackgroundScanner { abs_paths.dedup_by(|a, b| a.starts_with(b)); { let snapshot = &self.state.lock().await.snapshot; - abs_paths.retain(|abs_path| { - let abs_path = &SanitizedPath::new(abs_path); + let mut ranges_to_drop = SmallVec::<[Range; 4]>::new(); - { - let mut is_git_related = false; + fn skip_ix(ranges: &mut SmallVec<[Range; 4]>, ix: usize) { + if let Some(last_range) = ranges.last_mut() + && last_range.end == ix + { + last_range.end += 1; + } else { + ranges.push(ix..ix + 1); + } + } - let dot_git_paths = self.executor.block(maybe!(async { - let mut path = None; - for ancestor in abs_path.as_path().ancestors() { + for (ix, abs_path) in abs_paths.iter().enumerate() { + let abs_path = &SanitizedPath::new(&abs_path); + let mut is_git_related = false; + let mut dot_git_paths = None; + + for ancestor in abs_path.as_path().ancestors() { if is_git_dir(ancestor, self.fs.as_ref()).await { let path_in_git_dir = abs_path .as_path() .strip_prefix(ancestor) .expect("stripping off the ancestor"); - path = Some((ancestor.to_owned(), path_in_git_dir.to_owned())); - break; - } + dot_git_paths = Some((ancestor.to_owned(), path_in_git_dir.to_owned())); + break; } - path - - })); + } if let Some((dot_git_abs_path, path_in_git_dir)) = dot_git_paths { if skipped_files_in_dot_git @@ -3909,8 +3915,11 @@ impl BackgroundScanner { path_in_git_dir.starts_with(skipped_git_subdir) }) { - log::debug!("ignoring event {abs_path:?} as it's in the .git directory among skipped files or directories"); - return false; + log::debug!( + "ignoring event {abs_path:?} as it's in the .git directory among skipped files or directories" + ); + skip_ix(&mut ranges_to_drop, ix); + continue; } is_git_related = true; @@ -3919,8 +3928,7 @@ impl BackgroundScanner { } } - let relative_path = if let Ok(path) = - abs_path.strip_prefix(&root_canonical_path) + let relative_path = if let Ok(path) = abs_path.strip_prefix(&root_canonical_path) && let Ok(path) = RelPath::new(path, PathStyle::local()) { path @@ -3931,10 +3939,11 @@ impl BackgroundScanner { ); } else { log::error!( - "ignoring event {abs_path:?} outside of root path {root_canonical_path:?}", + "ignoring event {abs_path:?} outside of root path {root_canonical_path:?}", ); } - return false; + skip_ix(&mut ranges_to_drop, ix); + continue; }; if abs_path.file_name() == Some(OsStr::new(GITIGNORE)) { @@ -3958,21 +3967,26 @@ impl BackgroundScanner { }); if !parent_dir_is_loaded { log::debug!("ignoring event {relative_path:?} within unloaded directory"); - return false; + skip_ix(&mut ranges_to_drop, ix); + continue; } if self.settings.is_path_excluded(&relative_path) { if !is_git_related { log::debug!("ignoring FS event for excluded path {relative_path:?}"); } - return false; + skip_ix(&mut ranges_to_drop, ix); + continue; } relative_paths.push(relative_path.into_arc()); - true } - }); + + for range_to_drop in ranges_to_drop.into_iter().rev() { + abs_paths.drain(range_to_drop); + } } + if relative_paths.is_empty() && dot_git_abs_paths.is_empty() { return; } From a33e8819066331c12f2d025d1de789cb41375c8b Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Thu, 4 Dec 2025 15:42:26 +0100 Subject: [PATCH 058/621] remote: Recognize WSL interop to open browser for codex web login (#44136) Closes #41521 Release Notes: - Fixed codex web login not working on wsl remotes if no browser is installed Co-authored-by: Ben Brandt --- crates/client/src/client.rs | 4 ++++ crates/project/src/agent_server_store.rs | 10 ++++---- crates/remote/Cargo.toml | 1 - crates/remote/src/remote_client.rs | 30 ++++++++++++++++++++---- crates/remote/src/transport.rs | 6 +---- crates/remote/src/transport/ssh.rs | 4 ++++ crates/remote/src/transport/wsl.rs | 24 +++++++++++++++++++ crates/remote_server/src/unix.rs | 12 ++++++++-- crates/rpc/src/proto_client.rs | 5 ++++ 9 files changed, 79 insertions(+), 17 deletions(-) diff --git a/crates/client/src/client.rs b/crates/client/src/client.rs index 96b15dc9fb13deea3cdc706f1927c4d6f016b57a..6d6d229b940433ceac4c80f11891319550d269a2 100644 --- a/crates/client/src/client.rs +++ b/crates/client/src/client.rs @@ -1723,6 +1723,10 @@ impl ProtoClient for Client { fn is_via_collab(&self) -> bool { true } + + fn has_wsl_interop(&self) -> bool { + false + } } /// prefix for the zed:// url scheme diff --git a/crates/project/src/agent_server_store.rs b/crates/project/src/agent_server_store.rs index ef12e222009a59430a3396cae7971ac7593e82c3..95afdd09c15b9970d7eb637e6df99502d3bc3b67 100644 --- a/crates/project/src/agent_server_store.rs +++ b/crates/project/src/agent_server_store.rs @@ -453,7 +453,9 @@ impl AgentServerStore { .clone() .and_then(|settings| settings.custom_command()), http_client: http_client.clone(), - is_remote: downstream_client.is_some(), + no_browser: downstream_client + .as_ref() + .is_some_and(|(_, client)| !client.has_wsl_interop()), }), ); self.external_agents.insert( @@ -1355,7 +1357,7 @@ struct LocalCodex { project_environment: Entity, http_client: Arc, custom_command: Option, - is_remote: bool, + no_browser: bool, } impl ExternalAgentServer for LocalCodex { @@ -1375,7 +1377,7 @@ impl ExternalAgentServer for LocalCodex { .map(|root_dir| Path::new(root_dir)) .unwrap_or(paths::home_dir()) .into(); - let is_remote = self.is_remote; + let no_browser = self.no_browser; cx.spawn(async move |cx| { let mut env = project_environment @@ -1388,7 +1390,7 @@ impl ExternalAgentServer for LocalCodex { })? .await .unwrap_or_default(); - if is_remote { + if no_browser { env.insert("NO_BROWSER".to_owned(), "1".to_owned()); } diff --git a/crates/remote/Cargo.toml b/crates/remote/Cargo.toml index 07eb7d795e21c2f4b99817e301f6d8687c4aab60..ae32cd5cb10c2bf4c65b3b8ae51bf20e7e3ad15a 100644 --- a/crates/remote/Cargo.toml +++ b/crates/remote/Cargo.toml @@ -43,7 +43,6 @@ urlencoding.workspace = true util.workspace = true which.workspace = true - [dev-dependencies] gpui = { workspace = true, features = ["test-support"] } fs = { workspace = true, features = ["test-support"] } diff --git a/crates/remote/src/remote_client.rs b/crates/remote/src/remote_client.rs index 85b19ba25ca7187dfb400eb4716234bb3716ba9c..b0f9914c90545263a830ec034512a7e423109409 100644 --- a/crates/remote/src/remote_client.rs +++ b/crates/remote/src/remote_client.rs @@ -328,8 +328,15 @@ impl RemoteClient { let (incoming_tx, incoming_rx) = mpsc::unbounded::(); let (connection_activity_tx, connection_activity_rx) = mpsc::channel::<()>(1); - let client = - cx.update(|cx| ChannelClient::new(incoming_rx, outgoing_tx, cx, "client"))?; + let client = cx.update(|cx| { + ChannelClient::new( + incoming_rx, + outgoing_tx, + cx, + "client", + remote_connection.has_wsl_interop(), + ) + })?; let path_style = remote_connection.path_style(); let this = cx.new(|_| Self { @@ -420,8 +427,9 @@ impl RemoteClient { outgoing_tx: mpsc::UnboundedSender, cx: &App, name: &'static str, + has_wsl_interop: bool, ) -> AnyProtoClient { - ChannelClient::new(incoming_rx, outgoing_tx, cx, name).into() + ChannelClient::new(incoming_rx, outgoing_tx, cx, name, has_wsl_interop).into() } pub fn shutdown_processes( @@ -921,8 +929,8 @@ impl RemoteClient { }); let (outgoing_tx, _) = mpsc::unbounded::(); let (_, incoming_rx) = mpsc::unbounded::(); - let server_client = - server_cx.update(|cx| ChannelClient::new(incoming_rx, outgoing_tx, cx, "fake-server")); + let server_client = server_cx + .update(|cx| ChannelClient::new(incoming_rx, outgoing_tx, cx, "fake-server", false)); let connection: Arc = Arc::new(fake::FakeRemoteConnection { connection_options: opts.clone(), server_cx: fake::SendableCx::new(server_cx), @@ -1140,6 +1148,7 @@ pub trait RemoteConnection: Send + Sync { fn path_style(&self) -> PathStyle; fn shell(&self) -> String; fn default_system_shell(&self) -> String; + fn has_wsl_interop(&self) -> bool; #[cfg(any(test, feature = "test-support"))] fn simulate_disconnect(&self, _: &AsyncApp) {} @@ -1188,6 +1197,7 @@ struct ChannelClient { name: &'static str, task: Mutex>>, remote_started: Signal<()>, + has_wsl_interop: bool, } impl ChannelClient { @@ -1196,6 +1206,7 @@ impl ChannelClient { outgoing_tx: mpsc::UnboundedSender, cx: &App, name: &'static str, + has_wsl_interop: bool, ) -> Arc { Arc::new_cyclic(|this| Self { outgoing_tx: Mutex::new(outgoing_tx), @@ -1211,6 +1222,7 @@ impl ChannelClient { &cx.to_async(), )), remote_started: Signal::new(cx), + has_wsl_interop, }) } @@ -1489,6 +1501,10 @@ impl ProtoClient for ChannelClient { fn is_via_collab(&self) -> bool { false } + + fn has_wsl_interop(&self) -> bool { + self.has_wsl_interop + } } #[cfg(any(test, feature = "test-support"))] @@ -1652,6 +1668,10 @@ mod fake { fn default_system_shell(&self) -> String { "sh".to_owned() } + + fn has_wsl_interop(&self) -> bool { + false + } } pub(super) struct Delegate; diff --git a/crates/remote/src/transport.rs b/crates/remote/src/transport.rs index 211851c0629c13f1f79ce425cafc582899d1b58f..7441ede609dbfe0e4c74c3f3738bd07d209a37ec 100644 --- a/crates/remote/src/transport.rs +++ b/crates/remote/src/transport.rs @@ -131,11 +131,7 @@ async fn build_remote_server_from_source( let build_remote_server = std::env::var("ZED_BUILD_REMOTE_SERVER").unwrap_or("nocompress".into()); - if build_remote_server == "false" - || build_remote_server == "no" - || build_remote_server == "off" - || build_remote_server == "0" - { + if let "false" | "no" | "off" | "0" = &*build_remote_server { return Ok(None); } diff --git a/crates/remote/src/transport/ssh.rs b/crates/remote/src/transport/ssh.rs index bf537a3d6715eb8492fa87b802a26a111ec402b7..20cd0c5ff4b427d3a37882603ce2962db9e4e1e0 100644 --- a/crates/remote/src/transport/ssh.rs +++ b/crates/remote/src/transport/ssh.rs @@ -394,6 +394,10 @@ impl RemoteConnection for SshRemoteConnection { fn path_style(&self) -> PathStyle { self.ssh_path_style } + + fn has_wsl_interop(&self) -> bool { + false + } } impl SshRemoteConnection { diff --git a/crates/remote/src/transport/wsl.rs b/crates/remote/src/transport/wsl.rs index c6fa154ba09928efc04bb3ac15ad98b1db0671c0..670f122012ea1ab39b5905995f70c01d1dcf439c 100644 --- a/crates/remote/src/transport/wsl.rs +++ b/crates/remote/src/transport/wsl.rs @@ -47,6 +47,7 @@ pub(crate) struct WslRemoteConnection { shell: String, shell_kind: ShellKind, default_system_shell: String, + has_wsl_interop: bool, connection_options: WslConnectionOptions, } @@ -71,6 +72,7 @@ impl WslRemoteConnection { shell: String::new(), shell_kind: ShellKind::Posix, default_system_shell: String::from("/bin/sh"), + has_wsl_interop: false, }; delegate.set_status(Some("Detecting WSL environment"), cx); this.shell = this @@ -79,6 +81,15 @@ impl WslRemoteConnection { .context("failed detecting shell")?; log::info!("Remote shell discovered: {}", this.shell); this.shell_kind = ShellKind::new(&this.shell, false); + this.has_wsl_interop = this.detect_has_wsl_interop().await.unwrap_or_default(); + log::info!( + "Remote has wsl interop {}", + if this.has_wsl_interop { + "enabled" + } else { + "disabled" + } + ); this.platform = this .detect_platform() .await @@ -115,6 +126,14 @@ impl WslRemoteConnection { .unwrap_or_else(|| "/bin/sh".to_string())) } + async fn detect_has_wsl_interop(&self) -> Result { + Ok(self + .run_wsl_command_with_output("cat", &["/proc/sys/fs/binfmt_misc/WSLInterop"]) + .await + .inspect_err(|err| log::error!("Failed to detect wsl interop: {err}"))? + .contains("enabled")) + } + async fn windows_path_to_wsl_path(&self, source: &Path) -> Result { windows_path_to_wsl_path_impl(&self.connection_options, source).await } @@ -317,6 +336,7 @@ impl RemoteConnection for WslRemoteConnection { proxy_args.push(format!("{}={}", env_var, value)); } } + proxy_args.push(remote_binary_path.display(PathStyle::Posix).into_owned()); proxy_args.push("proxy".to_owned()); proxy_args.push("--identifier".to_owned()); @@ -489,6 +509,10 @@ impl RemoteConnection for WslRemoteConnection { fn default_system_shell(&self) -> String { self.default_system_shell.clone() } + + fn has_wsl_interop(&self) -> bool { + self.has_wsl_interop + } } /// `wslpath` is a executable available in WSL, it's a linux binary. diff --git a/crates/remote_server/src/unix.rs b/crates/remote_server/src/unix.rs index 0407539a4c131d92202e3177cc95137062b039ec..8adeaa594738aaddbcdd2dbe6454ead8485ca212 100644 --- a/crates/remote_server/src/unix.rs +++ b/crates/remote_server/src/unix.rs @@ -199,6 +199,7 @@ fn start_server( listeners: ServerListeners, log_rx: Receiver>, cx: &mut App, + is_wsl_interop: bool, ) -> AnyProtoClient { // This is the server idle timeout. If no connection comes in this timeout, the server will shut down. const IDLE_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(10 * 60); @@ -318,7 +319,7 @@ fn start_server( }) .detach(); - RemoteClient::proto_client_from_channels(incoming_rx, outgoing_tx, cx, "server") + RemoteClient::proto_client_from_channels(incoming_rx, outgoing_tx, cx, "server", is_wsl_interop) } fn init_paths() -> anyhow::Result<()> { @@ -407,8 +408,15 @@ pub fn execute_run( HeadlessProject::init(cx); + let is_wsl_interop = if cfg!(target_os = "linux") { + // See: https://learn.microsoft.com/en-us/windows/wsl/filesystems#disable-interoperability + matches!(std::fs::read_to_string("/proc/sys/fs/binfmt_misc/WSLInterop"), Ok(s) if s.contains("enabled")) + } else { + false + }; + log::info!("gpui app started, initializing server"); - let session = start_server(listeners, log_rx, cx); + let session = start_server(listeners, log_rx, cx, is_wsl_interop); GitHostingProviderRegistry::set_global(git_hosting_provider_registry, cx); git_hosting_providers::init(cx); diff --git a/crates/rpc/src/proto_client.rs b/crates/rpc/src/proto_client.rs index d7e3ba1e461b28ac264afcc05a8ae941e6da0c32..3850ff5820e6d73289b5714d6b880ecb584bf8d9 100644 --- a/crates/rpc/src/proto_client.rs +++ b/crates/rpc/src/proto_client.rs @@ -59,6 +59,7 @@ pub trait ProtoClient: Send + Sync { fn message_handler_set(&self) -> &parking_lot::Mutex; fn is_via_collab(&self) -> bool; + fn has_wsl_interop(&self) -> bool; } #[derive(Default)] @@ -510,6 +511,10 @@ impl AnyProtoClient { }, ); } + + pub fn has_wsl_interop(&self) -> bool { + self.0.client.has_wsl_interop() + } } fn to_any_envelope( From 93bc6616c697bee1ecf178e41597f0b294b0826b Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Thu, 4 Dec 2025 16:41:48 +0100 Subject: [PATCH 059/621] editor: Improve performance of `update_visible_edit_prediction` (#44161) One half of https://github.com/zed-industries/zed/issues/42861 This basically reduces the main thread work for large enough json (and other) files from multiple milliseconds (15ms was observed in that test case) down to microseconds (100ms here). Release Notes: - Improved cursor movement performance when edit predictions are enabled --- crates/editor/src/editor.rs | 15 ++++++++---- crates/multi_buffer/src/multi_buffer.rs | 32 +++++++++++++++++++------ 2 files changed, 36 insertions(+), 11 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 05287847190691221e6f948ba53efecc7269e9be..4b352e2d8298f3c9ae2c0d38bd6b443d62a61996 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -182,7 +182,7 @@ use std::{ iter::{self, Peekable}, mem, num::NonZeroU32, - ops::{Deref, DerefMut, Not, Range, RangeInclusive}, + ops::{ControlFlow, Deref, DerefMut, Not, Range, RangeInclusive}, path::{Path, PathBuf}, rc::Rc, sync::Arc, @@ -8073,10 +8073,17 @@ impl Editor { if self.edit_prediction_indent_conflict { let cursor_point = cursor.to_point(&multibuffer); + let mut suggested_indent = None; + multibuffer.suggested_indents_callback( + cursor_point.row..cursor_point.row + 1, + |_, indent| { + suggested_indent = Some(indent); + ControlFlow::Break(()) + }, + cx, + ); - let indents = multibuffer.suggested_indents(cursor_point.row..cursor_point.row + 1, cx); - - if let Some((_, indent)) = indents.iter().next() + if let Some(indent) = suggested_indent && indent.len == cursor_point.column { self.edit_prediction_indent_conflict = false; diff --git a/crates/multi_buffer/src/multi_buffer.rs b/crates/multi_buffer/src/multi_buffer.rs index 02adb79e70452a524152d62a71138b75561f9f33..af36aaadf02b53224c4ef0bcf0a17d3643ab8f0f 100644 --- a/crates/multi_buffer/src/multi_buffer.rs +++ b/crates/multi_buffer/src/multi_buffer.rs @@ -43,7 +43,7 @@ use std::{ io, iter::{self, FromIterator}, mem, - ops::{self, AddAssign, Range, RangeBounds, Sub, SubAssign}, + ops::{self, AddAssign, ControlFlow, Range, RangeBounds, Sub, SubAssign}, rc::Rc, str, sync::Arc, @@ -4618,7 +4618,24 @@ impl MultiBufferSnapshot { cx: &App, ) -> BTreeMap { let mut result = BTreeMap::new(); + self.suggested_indents_callback( + rows, + |row, indent| { + result.insert(row, indent); + ControlFlow::Continue(()) + }, + cx, + ); + result + } + // move this to be a generator once those are a thing + pub fn suggested_indents_callback( + &self, + rows: impl IntoIterator, + mut cb: impl FnMut(MultiBufferRow, IndentSize) -> ControlFlow<()>, + cx: &App, + ) { let mut rows_for_excerpt = Vec::new(); let mut cursor = self.cursor::(); let mut rows = rows.into_iter().peekable(); @@ -4662,16 +4679,17 @@ impl MultiBufferSnapshot { let buffer_indents = region .buffer .suggested_indents(buffer_rows, single_indent_size); - let multibuffer_indents = buffer_indents.into_iter().map(|(row, indent)| { - ( + for (row, indent) in buffer_indents { + if cb( MultiBufferRow(start_multibuffer_row + row - start_buffer_row), indent, ) - }); - result.extend(multibuffer_indents); + .is_break() + { + return; + } + } } - - result } pub fn indent_size_for_line(&self, row: MultiBufferRow) -> IndentSize { From c357dc25fc6e611016e1bee8a74f3f6f9e57bbdc Mon Sep 17 00:00:00 2001 From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Date: Thu, 4 Dec 2025 13:44:48 -0300 Subject: [PATCH 060/621] git_ui: Clean up the commit view UI (#44162) --- crates/editor/src/editor.rs | 5 + crates/editor/src/element.rs | 22 ++-- crates/git_ui/src/commit_view.rs | 205 +++++++++++++++++-------------- 3 files changed, 132 insertions(+), 100 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 4b352e2d8298f3c9ae2c0d38bd6b443d62a61996..0de2dc8423b39ab2b336adb3cb17f79cc4a8f6e7 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -20090,6 +20090,11 @@ impl Editor { self.show_indent_guides } + pub fn disable_indent_guides(&mut self) -> Option { + self.show_indent_guides = Some(false); + self.show_indent_guides + } + pub fn toggle_line_numbers( &mut self, _: &ToggleLineNumbers, diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index 3319af92eb04015bd3bd01760235e3dba0047975..fb9dc31a94441c81bccedfea66e2881acaf7ed82 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -3915,6 +3915,8 @@ impl EditorElement { ) -> impl IntoElement { let editor = self.editor.read(cx); let multi_buffer = editor.buffer.read(cx); + let is_read_only = self.editor.read(cx).read_only(cx); + let file_status = multi_buffer .all_diff_hunks_expanded() .then(|| editor.status_for_buffer_id(for_excerpt.buffer_id, cx)) @@ -3967,7 +3969,7 @@ impl EditorElement { .gap_1p5() .when(is_sticky, |el| el.shadow_md()) .border_1() - .map(|div| { + .map(|border| { let border_color = if is_selected && is_folded && focus_handle.contains_focused(window, cx) @@ -3976,7 +3978,7 @@ impl EditorElement { } else { colors.border }; - div.border_color(border_color) + border.border_color(border_color) }) .bg(colors.editor_subheader_background) .hover(|style| style.bg(colors.element_hover)) @@ -4056,13 +4058,15 @@ impl EditorElement { }) .take(1), ) - .child( - h_flex() - .size_3() - .justify_center() - .flex_shrink_0() - .children(indicator), - ) + .when(!is_read_only, |this| { + this.child( + h_flex() + .size_3() + .justify_center() + .flex_shrink_0() + .children(indicator), + ) + }) .child( h_flex() .cursor_pointer() diff --git a/crates/git_ui/src/commit_view.rs b/crates/git_ui/src/commit_view.rs index 31ac8139a63be218f652204ebe29d43e526c5a02..8a4504c1873193e81658c19c6b1115a9212e7760 100644 --- a/crates/git_ui/src/commit_view.rs +++ b/crates/git_ui/src/commit_view.rs @@ -1,7 +1,7 @@ use anyhow::{Context as _, Result}; use buffer_diff::{BufferDiff, BufferDiffSnapshot}; use editor::display_map::{BlockPlacement, BlockProperties, BlockStyle}; -use editor::{Addon, Editor, EditorEvent, ExcerptId, ExcerptRange, MultiBuffer}; +use editor::{Editor, EditorEvent, ExcerptId, ExcerptRange, MultiBuffer}; use git::repository::{CommitDetails, CommitDiff, RepoPath}; use git::{GitHostingProviderRegistry, GitRemote, parse_git_remote_url}; use gpui::{ @@ -11,9 +11,8 @@ use gpui::{ }; use language::{ Anchor, Buffer, Capability, DiskState, File, LanguageRegistry, LineEnding, ReplicaId, Rope, - TextBuffer, ToPoint, + TextBuffer, }; -use multi_buffer::ExcerptInfo; use multi_buffer::PathKey; use project::{Project, WorktreeId, git_store::Repository}; use std::{ @@ -22,11 +21,9 @@ use std::{ sync::Arc, }; use theme::ActiveTheme; -use ui::{ - Avatar, Button, ButtonCommon, Clickable, Color, Icon, IconName, IconSize, Label, - LabelCommon as _, LabelSize, SharedString, div, h_flex, v_flex, -}; +use ui::{Avatar, DiffStat, Tooltip, prelude::*}; use util::{ResultExt, paths::PathStyle, rel_path::RelPath, truncate_and_trailoff}; +use workspace::item::TabTooltipContent; use workspace::{ Item, ItemHandle, ItemNavHistory, ToolbarItemEvent, ToolbarItemLocation, ToolbarItemView, Workspace, @@ -151,11 +148,11 @@ impl CommitView { let editor = cx.new(|cx| { let mut editor = Editor::for_multibuffer(multibuffer.clone(), Some(project.clone()), window, cx); + editor.disable_inline_diagnostics(); + editor.disable_indent_guides(); editor.set_expand_all_diff_hunks(cx); - editor.register_addon(CommitViewAddon { - multibuffer: multibuffer.downgrade(), - }); + editor }); let commit_sha = Arc::::from(commit.sha.as_ref()); @@ -357,6 +354,41 @@ impl CommitView { .into_any() } + fn calculate_changed_lines(&self, cx: &App) -> (u32, u32) { + let snapshot = self.multibuffer.read(cx).snapshot(cx); + let mut total_additions = 0u32; + let mut total_deletions = 0u32; + + let mut seen_buffers = std::collections::HashSet::new(); + for (_, buffer, _) in snapshot.excerpts() { + let buffer_id = buffer.remote_id(); + if !seen_buffers.insert(buffer_id) { + continue; + } + + let Some(diff) = snapshot.diff_for_buffer_id(buffer_id) else { + continue; + }; + + let base_text = diff.base_text(); + + for hunk in diff.hunks_intersecting_range(Anchor::MIN..Anchor::MAX, buffer) { + let added_rows = hunk.range.end.row.saturating_sub(hunk.range.start.row); + total_additions += added_rows; + + let base_start = base_text + .offset_to_point(hunk.diff_base_byte_range.start) + .row; + let base_end = base_text.offset_to_point(hunk.diff_base_byte_range.end).row; + let deleted_rows = base_end.saturating_sub(base_start); + + total_deletions += deleted_rows; + } + } + + (total_additions, total_deletions) + } + fn render_header(&self, window: &mut Window, cx: &mut Context) -> impl IntoElement { let commit = &self.commit; let author_name = commit.author_name.clone(); @@ -380,46 +412,72 @@ impl CommitView { ) }); - v_flex() - .p_4() - .pl_0() - .gap_4() + let (additions, deletions) = self.calculate_changed_lines(cx); + + let commit_diff_stat = if additions > 0 || deletions > 0 { + Some(DiffStat::new( + "commit-diff-stat", + additions as usize, + deletions as usize, + )) + } else { + None + }; + + h_flex() .border_b_1() - .border_color(cx.theme().colors().border) + .border_color(cx.theme().colors().border_variant) + .child( + h_flex() + .w(self.editor.read(cx).last_gutter_dimensions().full_width()) + .justify_center() + .child(self.render_commit_avatar(&commit.sha, rems_from_px(48.), window, cx)), + ) .child( h_flex() + .py_4() + .pl_1() + .pr_4() + .w_full() .items_start() - .child( - h_flex() - .w(self.editor.read(cx).last_gutter_dimensions().full_width()) - .justify_center() - .child(self.render_commit_avatar( - &commit.sha, - gpui::rems(3.0), - window, - cx, - )), - ) + .justify_between() + .flex_wrap() .child( v_flex() - .gap_1() .child( h_flex() - .gap_3() - .items_baseline() + .gap_1() .child(Label::new(author_name).color(Color::Default)) .child( - Label::new(format!("commit {}", commit.sha)) - .color(Color::Muted), + Label::new(format!("Commit:{}", commit.sha)) + .color(Color::Muted) + .size(LabelSize::Small) + .truncate() + .buffer_font(cx), ), ) - .child(Label::new(date_string).color(Color::Muted)), + .child( + h_flex() + .gap_1p5() + .child( + Label::new(date_string) + .color(Color::Muted) + .size(LabelSize::Small), + ) + .child( + Label::new("•") + .color(Color::Ignored) + .size(LabelSize::Small), + ) + .children(commit_diff_stat), + ), ) - .child(div().flex_grow()) .children(github_url.map(|url| { Button::new("view_on_github", "View on GitHub") .icon(IconName::Github) - .style(ui::ButtonStyle::Subtle) + .icon_color(Color::Muted) + .icon_size(IconSize::Small) + .icon_position(IconPosition::Start) .on_click(move |_, _, cx| cx.open_url(&url)) })), ) @@ -714,55 +772,6 @@ impl language::File for GitBlob { // } // } -struct CommitViewAddon { - multibuffer: WeakEntity, -} - -impl Addon for CommitViewAddon { - fn render_buffer_header_controls( - &self, - excerpt: &ExcerptInfo, - _window: &Window, - cx: &App, - ) -> Option { - let multibuffer = self.multibuffer.upgrade()?; - let snapshot = multibuffer.read(cx).snapshot(cx); - let excerpts = snapshot.excerpts().collect::>(); - let current_idx = excerpts.iter().position(|(id, _, _)| *id == excerpt.id)?; - let (_, _, current_range) = &excerpts[current_idx]; - - let start_row = current_range.context.start.to_point(&excerpt.buffer).row; - - let prev_end_row = if current_idx > 0 { - let (_, prev_buffer, prev_range) = &excerpts[current_idx - 1]; - if prev_buffer.remote_id() == excerpt.buffer_id { - prev_range.context.end.to_point(&excerpt.buffer).row - } else { - 0 - } - } else { - 0 - }; - - let skipped_lines = start_row.saturating_sub(prev_end_row); - - if skipped_lines > 0 { - Some( - Label::new(format!("{} unchanged lines", skipped_lines)) - .color(Color::Muted) - .size(LabelSize::Small) - .into_any_element(), - ) - } else { - None - } - } - - fn to_any(&self) -> &dyn Any { - self - } -} - async fn build_buffer( mut text: String, blob: Arc, @@ -865,13 +874,28 @@ impl Item for CommitView { fn tab_content_text(&self, _detail: usize, _cx: &App) -> SharedString { let short_sha = self.commit.sha.get(0..7).unwrap_or(&*self.commit.sha); let subject = truncate_and_trailoff(self.commit.message.split('\n').next().unwrap(), 20); - format!("{short_sha} - {subject}").into() + format!("{short_sha} — {subject}").into() } - fn tab_tooltip_text(&self, _: &App) -> Option { + fn tab_tooltip_content(&self, _: &App) -> Option { let short_sha = self.commit.sha.get(0..16).unwrap_or(&*self.commit.sha); let subject = self.commit.message.split('\n').next().unwrap(); - Some(format!("{short_sha} - {subject}").into()) + + Some(TabTooltipContent::Custom(Box::new(Tooltip::element({ + let subject = subject.to_string(); + let short_sha = short_sha.to_string(); + + move |_, _| { + v_flex() + .child(Label::new(subject.clone())) + .child( + Label::new(short_sha.clone()) + .color(Color::Muted) + .size(LabelSize::Small), + ) + .into_any_element() + } + })))) } fn to_item_events(event: &EditorEvent, f: impl FnMut(ItemEvent)) { @@ -988,12 +1012,11 @@ impl Item for CommitView { impl Render for CommitView { fn render(&mut self, window: &mut Window, cx: &mut Context) -> impl IntoElement { let is_stash = self.stash.is_some(); - div() + + v_flex() .key_context(if is_stash { "StashDiff" } else { "CommitDiff" }) - .bg(cx.theme().colors().editor_background) - .flex() - .flex_col() .size_full() + .bg(cx.theme().colors().editor_background) .child(self.render_header(window, cx)) .child(div().flex_grow().child(self.editor.clone())) } @@ -1013,7 +1036,7 @@ impl EventEmitter for CommitViewToolbar {} impl Render for CommitViewToolbar { fn render(&mut self, _window: &mut Window, _cx: &mut Context) -> impl IntoElement { - div() + div().hidden() } } From 07af011eb447a1b8afc2ad490a77da33fa76fb33 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Thu, 4 Dec 2025 18:14:10 +0100 Subject: [PATCH 061/621] worktree: Fix git ignored directories dropping their contents when they are refreshed (#44143) Closes https://github.com/zed-industries/zed/issues/38653 Release Notes: - Fixed git ignored directories appearing as empty when their content changes on windows Co-authored by: Smit Barmase --- crates/worktree/src/worktree.rs | 44 +++++-- crates/worktree/src/worktree_tests.rs | 169 ++++++++++++++++++++++++++ 2 files changed, 201 insertions(+), 12 deletions(-) diff --git a/crates/worktree/src/worktree.rs b/crates/worktree/src/worktree.rs index 942e692a020049b102a0d810bfbf1a9074962611..5d1baceb2cebcadb54f5b47f357470861bb5b964 100644 --- a/crates/worktree/src/worktree.rs +++ b/crates/worktree/src/worktree.rs @@ -428,7 +428,7 @@ impl Worktree { let mut entry = Entry::new( RelPath::empty().into(), &metadata, - &next_entry_id, + ProjectEntryId::new(&next_entry_id), snapshot.root_char_bag, None, ); @@ -2736,13 +2736,30 @@ impl BackgroundScannerState { } } - async fn insert_entry( + fn entry_id_for( &mut self, - mut entry: Entry, - fs: &dyn Fs, - watcher: &dyn Watcher, - ) -> Entry { - self.reuse_entry_id(&mut entry); + next_entry_id: &AtomicUsize, + path: &RelPath, + metadata: &fs::Metadata, + ) -> ProjectEntryId { + // If an entry with the same inode was removed from the worktree during this scan, + // then it *might* represent the same file or directory. But the OS might also have + // re-used the inode for a completely different file or directory. + // + // Conditionally reuse the old entry's id: + // * if the mtime is the same, the file was probably been renamed. + // * if the path is the same, the file may just have been updated + if let Some(removed_entry) = self.removed_entries.remove(&metadata.inode) { + if removed_entry.mtime == Some(metadata.mtime) || *removed_entry.path == *path { + return removed_entry.id; + } + } else if let Some(existing_entry) = self.snapshot.entry_for_path(path) { + return existing_entry.id; + } + ProjectEntryId::new(next_entry_id) + } + + async fn insert_entry(&mut self, entry: Entry, fs: &dyn Fs, watcher: &dyn Watcher) -> Entry { let entry = self.snapshot.insert_entry(entry, fs); if entry.path.file_name() == Some(&DOT_GIT) { self.insert_git_repository(entry.path.clone(), fs, watcher) @@ -3389,13 +3406,13 @@ impl Entry { fn new( path: Arc, metadata: &fs::Metadata, - next_entry_id: &AtomicUsize, + id: ProjectEntryId, root_char_bag: CharBag, canonical_path: Option>, ) -> Self { let char_bag = char_bag_for_path(root_char_bag, &path); Self { - id: ProjectEntryId::new(next_entry_id), + id, kind: if metadata.is_dir { EntryKind::PendingDir } else { @@ -3682,8 +3699,10 @@ impl BackgroundScanner { .await; if ignore_stack.is_abs_path_ignored(root_abs_path.as_path(), true) { root_entry.is_ignored = true; + let mut root_entry = root_entry.clone(); + state.reuse_entry_id(&mut root_entry); state - .insert_entry(root_entry.clone(), self.fs.as_ref(), self.watcher.as_ref()) + .insert_entry(root_entry, self.fs.as_ref(), self.watcher.as_ref()) .await; } if root_entry.is_dir() { @@ -4289,7 +4308,7 @@ impl BackgroundScanner { let mut child_entry = Entry::new( child_path.clone(), &child_metadata, - &next_entry_id, + ProjectEntryId::new(&next_entry_id), root_char_bag, None, ); @@ -4476,10 +4495,11 @@ impl BackgroundScanner { .ignore_stack_for_abs_path(&abs_path, metadata.is_dir, self.fs.as_ref()) .await; let is_external = !canonical_path.starts_with(&root_canonical_path); + let entry_id = state.entry_id_for(self.next_entry_id.as_ref(), path, &metadata); let mut fs_entry = Entry::new( path.clone(), &metadata, - self.next_entry_id.as_ref(), + entry_id, state.snapshot.root_char_bag, if metadata.is_symlink { Some(canonical_path.as_path().to_path_buf().into()) diff --git a/crates/worktree/src/worktree_tests.rs b/crates/worktree/src/worktree_tests.rs index 50e2c6acae0013a75e346ba754f9c9f861196b58..08086118aacb37215227690532b927b3c7c46123 100644 --- a/crates/worktree/src/worktree_tests.rs +++ b/crates/worktree/src/worktree_tests.rs @@ -1533,6 +1533,175 @@ async fn test_create_dir_all_on_create_entry(cx: &mut TestAppContext) { }); } +#[gpui::test] +async fn test_create_file_in_expanded_gitignored_dir(cx: &mut TestAppContext) { + // Tests the behavior of our worktree refresh when a file in a gitignored directory + // is created. + init_test(cx); + let fs = FakeFs::new(cx.background_executor.clone()); + fs.insert_tree( + "/root", + json!({ + ".gitignore": "ignored_dir\n", + "ignored_dir": { + "existing_file.txt": "existing content", + "another_file.txt": "another content", + }, + }), + ) + .await; + + let tree = Worktree::local( + Path::new("/root"), + true, + fs.clone(), + Default::default(), + &mut cx.to_async(), + ) + .await + .unwrap(); + + cx.read(|cx| tree.read(cx).as_local().unwrap().scan_complete()) + .await; + + tree.read_with(cx, |tree, _| { + let ignored_dir = tree.entry_for_path(rel_path("ignored_dir")).unwrap(); + assert!(ignored_dir.is_ignored); + assert_eq!(ignored_dir.kind, EntryKind::UnloadedDir); + }); + + tree.update(cx, |tree, cx| { + tree.load_file(rel_path("ignored_dir/existing_file.txt"), cx) + }) + .await + .unwrap(); + + tree.read_with(cx, |tree, _| { + let ignored_dir = tree.entry_for_path(rel_path("ignored_dir")).unwrap(); + assert!(ignored_dir.is_ignored); + assert_eq!(ignored_dir.kind, EntryKind::Dir); + + assert!( + tree.entry_for_path(rel_path("ignored_dir/existing_file.txt")) + .is_some() + ); + assert!( + tree.entry_for_path(rel_path("ignored_dir/another_file.txt")) + .is_some() + ); + }); + + let entry = tree + .update(cx, |tree, cx| { + tree.create_entry(rel_path("ignored_dir/new_file.txt").into(), false, None, cx) + }) + .await + .unwrap(); + assert!(entry.into_included().is_some()); + + cx.executor().run_until_parked(); + + tree.read_with(cx, |tree, _| { + let ignored_dir = tree.entry_for_path(rel_path("ignored_dir")).unwrap(); + assert!(ignored_dir.is_ignored); + assert_eq!( + ignored_dir.kind, + EntryKind::Dir, + "ignored_dir should still be loaded, not UnloadedDir" + ); + + assert!( + tree.entry_for_path(rel_path("ignored_dir/existing_file.txt")) + .is_some(), + "existing_file.txt should still be visible" + ); + assert!( + tree.entry_for_path(rel_path("ignored_dir/another_file.txt")) + .is_some(), + "another_file.txt should still be visible" + ); + assert!( + tree.entry_for_path(rel_path("ignored_dir/new_file.txt")) + .is_some(), + "new_file.txt should be visible" + ); + }); +} + +#[gpui::test] +async fn test_fs_event_for_gitignored_dir_does_not_lose_contents(cx: &mut TestAppContext) { + // Tests the behavior of our worktree refresh when a directory modification for a gitignored directory + // is triggered. + init_test(cx); + let fs = FakeFs::new(cx.background_executor.clone()); + fs.insert_tree( + "/root", + json!({ + ".gitignore": "ignored_dir\n", + "ignored_dir": { + "file1.txt": "content1", + "file2.txt": "content2", + }, + }), + ) + .await; + + let tree = Worktree::local( + Path::new("/root"), + true, + fs.clone(), + Default::default(), + &mut cx.to_async(), + ) + .await + .unwrap(); + + cx.read(|cx| tree.read(cx).as_local().unwrap().scan_complete()) + .await; + + // Load a file to expand the ignored directory + tree.update(cx, |tree, cx| { + tree.load_file(rel_path("ignored_dir/file1.txt"), cx) + }) + .await + .unwrap(); + + tree.read_with(cx, |tree, _| { + let ignored_dir = tree.entry_for_path(rel_path("ignored_dir")).unwrap(); + assert_eq!(ignored_dir.kind, EntryKind::Dir); + assert!( + tree.entry_for_path(rel_path("ignored_dir/file1.txt")) + .is_some() + ); + assert!( + tree.entry_for_path(rel_path("ignored_dir/file2.txt")) + .is_some() + ); + }); + + fs.emit_fs_event("/root/ignored_dir", Some(fs::PathEventKind::Changed)); + tree.flush_fs_events(cx).await; + + tree.read_with(cx, |tree, _| { + let ignored_dir = tree.entry_for_path(rel_path("ignored_dir")).unwrap(); + assert_eq!( + ignored_dir.kind, + EntryKind::Dir, + "ignored_dir should still be loaded (Dir), not UnloadedDir" + ); + assert!( + tree.entry_for_path(rel_path("ignored_dir/file1.txt")) + .is_some(), + "file1.txt should still be visible after directory fs event" + ); + assert!( + tree.entry_for_path(rel_path("ignored_dir/file2.txt")) + .is_some(), + "file2.txt should still be visible after directory fs event" + ); + }); +} + #[gpui::test(iterations = 100)] async fn test_random_worktree_operations_during_initial_scan( cx: &mut TestAppContext, From 74a1b5d14db73d6bbf0524a2f67e425455bc801c Mon Sep 17 00:00:00 2001 From: Liffindra Angga Zaaldian <3760093+findrakecil@users.noreply.github.com> Date: Fri, 5 Dec 2025 01:04:06 +0700 Subject: [PATCH 062/621] Update PHP language server docs (#44001) Reformat document structure like other language docs, improve information flow, add missing requirements, and fix typos. Release Notes: - N/A --------- Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> --- docs/src/languages/php.md | 114 +++++++++++++++++++++++++++++--------- 1 file changed, 89 insertions(+), 25 deletions(-) diff --git a/docs/src/languages/php.md b/docs/src/languages/php.md index 73d5ecbf37eae6ab9b7e710c132025d217fe57bd..1a9f1cdadef394f1178fed87d4061eb0f3232cfd 100644 --- a/docs/src/languages/php.md +++ b/docs/src/languages/php.md @@ -2,34 +2,44 @@ PHP support is available through the [PHP extension](https://github.com/zed-extensions/php). -- Tree-sitter: https://github.com/tree-sitter/tree-sitter-php -- Language Servers: - - [phpactor](https://github.com/phpactor/phpactor) - - [intelephense](https://github.com/bmewburn/vscode-intelephense/) +- Tree-sitter: [tree-sitter/tree-sitter-php](https://github.com/tree-sitter/tree-sitter-php) +- Language Server: [phpactor/phpactor](https://github.com/phpactor/phpactor) +- Alternate Language Server: [bmewburn/vscode-intelephense](https://github.com/bmewburn/vscode-intelephense/) -## Choosing a language server +## Install PHP -The PHP extension offers both `phpactor` and `intelephense` language server support. +The PHP extension requires PHP to be installed and available in your `PATH`: -`phpactor` is enabled by default. +```sh +# macOS via Homebrew +brew install php -### Phpactor +# Debian/Ubuntu +sudo apt-get install php-cli -The Zed PHP Extension can install `phpactor` automatically but requires `php` to be installed and available in your path: +# CentOS 8+/RHEL +sudo dnf install php-cli -```sh -# brew install php # macOS -# sudo apt-get install php # Debian/Ubuntu -# yum install php # CentOS/RHEL -# pacman -S php # Arch Linux +# Arch Linux +sudo pacman -S php + +# check PHP path +## macOS and Linux which php + +## Windows +where php ``` +## Choosing a language server + +The PHP extension uses [LSP language servers](https://microsoft.github.io/language-server-protocol) with Phpactor as the default. If you want to use other language servers that support Zed (e.g. Intelephense or PHP Tools), make sure to follow the documentation on how to implement it. + ### Intelephense -[Intelephense](https://intelephense.com/) is a [proprietary](https://github.com/bmewburn/vscode-intelephense/blob/master/LICENSE.txt#L29) language server for PHP operating under a freemium model. Certain features require purchase of a [premium license](https://intelephense.com/). +[Intelephense](https://intelephense.com/) is a [proprietary](https://github.com/bmewburn/vscode-intelephense/blob/master/LICENSE.txt#L29) language server for PHP operating under a freemium model. Certain features require purchase of a [premium license](https://intelephense.com/buy). -To switch to `intelephense`, add the following to your `settings.json`: +To use Intelephense, add the following to your `settings.json`: ```json [settings] { @@ -41,7 +51,9 @@ To switch to `intelephense`, add the following to your `settings.json`: } ``` -To use the premium features, you can place your [licence.txt file](https://intelephense.com/faq.html) at `~/intelephense/licence.txt` inside your home directory. Alternatively, you can pass the licence key or a path to a file containing the licence key as an initialization option for the `intelephense` language server. To do this, add the following to your `settings.json`: +To use the premium features, you can place your license file inside your home directory at `~/intelephense/licence.txt` for macOS and Linux, or `%USERPROFILE%/intelephense/licence.txt` on Windows. + +Alternatively, you can pass the licence key or a path to a file containing the licence key as an initialization option. To do this, add the following to your `settings.json`: ```json [settings] { @@ -55,15 +67,67 @@ To use the premium features, you can place your [licence.txt file](https://intel } ``` +### PHP Tools + +[PHP Tools](https://www.devsense.com/) is a proprietary language server that offers free and premium features. You need to [purchase a license](https://www.devsense.com/en/purchase) to activate the premium features. + +To use PHP Tools, add the following to your `settings.json`: + +```json [settings] +{ + "languages": { + "PHP": { + "language_servers": ["phptools", "!intelephense", "!phpactor", "..."] + } + } +} +``` + +To use the premium features, you can add your license in `initialization_options` in your `settings.json`: + +```json [settings] +{ + "lsp": { + "phptools": { + "initialization_options": { + "0": "your_license_key" + } + } + } +} +``` + +or, set environment variable `DEVSENSE_PHP_LS_LICENSE` on `.env` file in your project. + +```env +DEVSENSE_PHP_LS_LICENSE="your_license_key" +``` + +Check out the documentation of [PHP Tools for Zed](https://docs.devsense.com/other/zed/) for more details. + +### Phpactor + +To use Phpactor instead of Intelephense or any other tools, add the following to your `settings.json`: + +```json [settings] +{ + "languages": { + "PHP": { + "language_servers": ["phpactor", "!intelephense", "!phptools", "..."] + } + } +} +``` + ## PHPDoc Zed supports syntax highlighting for PHPDoc comments. - Tree-sitter: [claytonrcarter/tree-sitter-phpdoc](https://github.com/claytonrcarter/tree-sitter-phpdoc) -## Setting up Xdebug +## Debugging -Zed’s PHP extension provides a debug adapter for PHP and Xdebug. The adapter name is `Xdebug`. Here a couple ways you can use it: +The PHP extension provides a debug adapter for PHP via Xdebug. There are several ways to use it: ```json [ @@ -83,10 +147,10 @@ Zed’s PHP extension provides a debug adapter for PHP and Xdebug. The adapter n ] ``` -In case you run into issues: +These are common troubleshooting tips, in case you run into issues: -- ensure that you have Xdebug installed for the version of PHP you’re running -- ensure that Xdebug is configured to run in `debug` mode -- ensure that Xdebug is actually starting a debugging session -- check that the host and port matches between Xdebug and Zed -- look at the diagnostics log by using the `xdebug_info()` function in the page you’re trying to debug +- Ensure that you have Xdebug installed for the version of PHP you’re running. +- Ensure that Xdebug is configured to run in `debug` mode. +- Ensure that Xdebug is actually starting a debugging session. +- Ensure that the host and port matches between Xdebug and Zed. +- Look at the diagnostics log by using the `xdebug_info()` function in the page you’re trying to debug. From d5ed9d3e3a96492c049a1ab50819f196ed255037 Mon Sep 17 00:00:00 2001 From: Cole Miller Date: Thu, 4 Dec 2025 13:25:30 -0500 Subject: [PATCH 063/621] git: Don't call `git2::Repository::find_remote` for every blamed buffer (#44107) We already store the remote URLs for `origin` and `upstream` in the `RepositorySnapshot`, so just use that data. Follow-up to #44092. Release Notes: - N/A --- .../20221109000000_test_schema.sql | 2 ++ ...dd_remote_urls_to_project_repositories.sql | 2 ++ crates/collab/src/db/queries/projects.rs | 6 ++++ crates/collab/src/db/queries/rooms.rs | 2 ++ .../src/db/tables/project_repository.rs | 2 ++ crates/collab/src/tests/editor_tests.rs | 5 --- crates/editor/src/git/blame.rs | 22 ++++++++----- crates/git/src/blame.rs | 8 +---- crates/git/src/repository.rs | 31 ++++++------------- crates/project/src/git_store.rs | 19 +++++------- crates/proto/proto/git.proto | 4 ++- 11 files changed, 51 insertions(+), 52 deletions(-) create mode 100644 crates/collab/migrations/20251203234258_add_remote_urls_to_project_repositories.sql diff --git a/crates/collab/migrations.sqlite/20221109000000_test_schema.sql b/crates/collab/migrations.sqlite/20221109000000_test_schema.sql index a736ddfd1fe3334b1b847e820bd1816cb625ddca..32a2ed2e1331fc7b16f859accd895a7bce055804 100644 --- a/crates/collab/migrations.sqlite/20221109000000_test_schema.sql +++ b/crates/collab/migrations.sqlite/20221109000000_test_schema.sql @@ -121,6 +121,8 @@ CREATE TABLE "project_repositories" ( "merge_message" VARCHAR, "branch_summary" VARCHAR, "head_commit_details" VARCHAR, + "remote_upstream_url" VARCHAR, + "remote_origin_url" VARCHAR, PRIMARY KEY (project_id, id) ); diff --git a/crates/collab/migrations/20251203234258_add_remote_urls_to_project_repositories.sql b/crates/collab/migrations/20251203234258_add_remote_urls_to_project_repositories.sql new file mode 100644 index 0000000000000000000000000000000000000000..e1396de27d90fb2c872197d25198743d19be86f8 --- /dev/null +++ b/crates/collab/migrations/20251203234258_add_remote_urls_to_project_repositories.sql @@ -0,0 +1,2 @@ +ALTER TABLE "project_repositories" ADD COLUMN "remote_upstream_url" VARCHAR; +ALTER TABLE "project_repositories" ADD COLUMN "remote_origin_url" VARCHAR; diff --git a/crates/collab/src/db/queries/projects.rs b/crates/collab/src/db/queries/projects.rs index 51a0ef83323ec70675283d2fdec7ca1ad791b12d..6f1d8b884d15041eadaa9073a5bd99e5ed352502 100644 --- a/crates/collab/src/db/queries/projects.rs +++ b/crates/collab/src/db/queries/projects.rs @@ -362,6 +362,8 @@ impl Database { entry_ids: ActiveValue::set("[]".into()), head_commit_details: ActiveValue::set(None), merge_message: ActiveValue::set(None), + remote_upstream_url: ActiveValue::set(None), + remote_origin_url: ActiveValue::set(None), } }), ) @@ -511,6 +513,8 @@ impl Database { serde_json::to_string(&update.current_merge_conflicts).unwrap(), )), merge_message: ActiveValue::set(update.merge_message.clone()), + remote_upstream_url: ActiveValue::set(update.remote_upstream_url.clone()), + remote_origin_url: ActiveValue::set(update.remote_origin_url.clone()), }) .on_conflict( OnConflict::columns([ @@ -1005,6 +1009,8 @@ impl Database { is_last_update: true, merge_message: db_repository_entry.merge_message, stash_entries: Vec::new(), + remote_upstream_url: db_repository_entry.remote_upstream_url.clone(), + remote_origin_url: db_repository_entry.remote_origin_url.clone(), }); } } diff --git a/crates/collab/src/db/queries/rooms.rs b/crates/collab/src/db/queries/rooms.rs index f020b99b5f1030cfe9391498512258e6db249bac..eafb5cac44a510bf4ced0434a9b4adfadff0ebbc 100644 --- a/crates/collab/src/db/queries/rooms.rs +++ b/crates/collab/src/db/queries/rooms.rs @@ -796,6 +796,8 @@ impl Database { is_last_update: true, merge_message: db_repository.merge_message, stash_entries: Vec::new(), + remote_upstream_url: db_repository.remote_upstream_url.clone(), + remote_origin_url: db_repository.remote_origin_url.clone(), }); } } diff --git a/crates/collab/src/db/tables/project_repository.rs b/crates/collab/src/db/tables/project_repository.rs index eb653ecee37d48ce79e26450eb85d87dec411c1e..190ae8d79c54bb78daef4a1568ec75683eb0b0f2 100644 --- a/crates/collab/src/db/tables/project_repository.rs +++ b/crates/collab/src/db/tables/project_repository.rs @@ -22,6 +22,8 @@ pub struct Model { pub branch_summary: Option, // A JSON object representing the current Head commit values pub head_commit_details: Option, + pub remote_upstream_url: Option, + pub remote_origin_url: Option, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] diff --git a/crates/collab/src/tests/editor_tests.rs b/crates/collab/src/tests/editor_tests.rs index 785a6457c8fdb57f84a8e7b5a8487f0ceae3d025..149a48db7439cc28e76fac5aae8b6e11f0837991 100644 --- a/crates/collab/src/tests/editor_tests.rs +++ b/crates/collab/src/tests/editor_tests.rs @@ -3518,7 +3518,6 @@ async fn test_git_blame_is_forwarded(cx_a: &mut TestAppContext, cx_b: &mut TestA .into_iter() .map(|(sha, message)| (sha.parse().unwrap(), message.into())) .collect(), - remote_url: Some("git@github.com:zed-industries/zed.git".to_string()), }; client_a.fs().set_blame_for_repo( Path::new(path!("/my-repo/.git")), @@ -3603,10 +3602,6 @@ async fn test_git_blame_is_forwarded(cx_a: &mut TestAppContext, cx_b: &mut TestA for (idx, (buffer, entry)) in entries.iter().flatten().enumerate() { let details = blame.details_for_entry(*buffer, entry).unwrap(); assert_eq!(details.message, format!("message for idx-{}", idx)); - assert_eq!( - details.permalink.unwrap().to_string(), - format!("https://github.com/zed-industries/zed/commit/{}", entry.sha) - ); } }); }); diff --git a/crates/editor/src/git/blame.rs b/crates/editor/src/git/blame.rs index 008630faef7cc1ccb3b9703e4b11c0b88b7cf17c..67df69aadab43a45c2941703e10bb81af2b8dd78 100644 --- a/crates/editor/src/git/blame.rs +++ b/crates/editor/src/git/blame.rs @@ -508,7 +508,19 @@ impl GitBlame { let buffer_edits = buffer.update(cx, |buffer, _| buffer.subscribe()); let blame_buffer = project.blame_buffer(&buffer, None, cx); - Some(async move { (id, snapshot, buffer_edits, blame_buffer.await) }) + let remote_url = project + .git_store() + .read(cx) + .repository_and_path_for_buffer_id(buffer.read(cx).remote_id(), cx) + .and_then(|(repo, _)| { + repo.read(cx) + .remote_upstream_url + .clone() + .or(repo.read(cx).remote_origin_url.clone()) + }); + Some( + async move { (id, snapshot, buffer_edits, blame_buffer.await, remote_url) }, + ) }) .collect::>() }); @@ -524,13 +536,9 @@ impl GitBlame { .await; let mut res = vec![]; let mut errors = vec![]; - for (id, snapshot, buffer_edits, blame) in blame { + for (id, snapshot, buffer_edits, blame, remote_url) in blame { match blame { - Ok(Some(Blame { - entries, - messages, - remote_url, - })) => { + Ok(Some(Blame { entries, messages })) => { let entries = build_blame_entry_sum_tree( entries, snapshot.max_point().row, diff --git a/crates/git/src/blame.rs b/crates/git/src/blame.rs index e58b9cb7e0427bf3af1c88f473debba0b6f94f59..6325eacc8201d812d14dfdf4853f4004e22c263e 100644 --- a/crates/git/src/blame.rs +++ b/crates/git/src/blame.rs @@ -19,7 +19,6 @@ pub use git2 as libgit; pub struct Blame { pub entries: Vec, pub messages: HashMap, - pub remote_url: Option, } #[derive(Clone, Debug, Default)] @@ -36,7 +35,6 @@ impl Blame { working_directory: &Path, path: &RepoPath, content: &Rope, - remote_url: Option, ) -> Result { let output = run_git_blame(git_binary, working_directory, path, content).await?; let mut entries = parse_git_blame(&output)?; @@ -53,11 +51,7 @@ impl Blame { .await .context("failed to get commit messages")?; - Ok(Self { - entries, - messages, - remote_url, - }) + Ok(Self { entries, messages }) } } diff --git a/crates/git/src/repository.rs b/crates/git/src/repository.rs index f79bade2d6bc12553b173c4f4e86989a961e6d31..70cbf6e3c58b7d8f6b690a554370d34262f541e3 100644 --- a/crates/git/src/repository.rs +++ b/crates/git/src/repository.rs @@ -1494,28 +1494,17 @@ impl GitRepository for RealGitRepository { let git_binary_path = self.any_git_binary_path.clone(); let executor = self.executor.clone(); - async move { - let remote_url = if let Some(remote_url) = self.remote_url("upstream").await { - Some(remote_url) - } else if let Some(remote_url) = self.remote_url("origin").await { - Some(remote_url) - } else { - None - }; - executor - .spawn(async move { - crate::blame::Blame::for_path( - &git_binary_path, - &working_directory?, - &path, - &content, - remote_url, - ) - .await - }) + executor + .spawn(async move { + crate::blame::Blame::for_path( + &git_binary_path, + &working_directory?, + &path, + &content, + ) .await - } - .boxed() + }) + .boxed() } fn file_history(&self, path: RepoPath) -> BoxFuture<'_, Result> { diff --git a/crates/project/src/git_store.rs b/crates/project/src/git_store.rs index 81511b21be3599b4686b9fd11aac5118711f11fa..0b74a04e1db5c0f2b7c8934d1bbe7d38b1d1ad1b 100644 --- a/crates/project/src/git_store.rs +++ b/crates/project/src/git_store.rs @@ -3296,6 +3296,8 @@ impl RepositorySnapshot { .iter() .map(stash_to_proto) .collect(), + remote_upstream_url: self.remote_upstream_url.clone(), + remote_origin_url: self.remote_origin_url.clone(), } } @@ -3365,6 +3367,8 @@ impl RepositorySnapshot { .iter() .map(stash_to_proto) .collect(), + remote_upstream_url: self.remote_upstream_url.clone(), + remote_origin_url: self.remote_origin_url.clone(), } } @@ -5395,6 +5399,8 @@ impl Repository { cx.emit(RepositoryEvent::StashEntriesChanged) } self.snapshot.stash_entries = new_stash_entries; + self.snapshot.remote_upstream_url = update.remote_upstream_url; + self.snapshot.remote_origin_url = update.remote_origin_url; let edits = update .removed_statuses @@ -5954,11 +5960,7 @@ fn serialize_blame_buffer_response(blame: Option) -> proto::B .collect::>(); proto::BlameBufferResponse { - blame_response: Some(proto::blame_buffer_response::BlameResponse { - entries, - messages, - remote_url: blame.remote_url, - }), + blame_response: Some(proto::blame_buffer_response::BlameResponse { entries, messages }), } } @@ -5995,11 +5997,7 @@ fn deserialize_blame_buffer_response( .filter_map(|message| Some((git::Oid::from_bytes(&message.oid).ok()?, message.message))) .collect::>(); - Some(Blame { - entries, - messages, - remote_url: response.remote_url, - }) + Some(Blame { entries, messages }) } fn branch_to_proto(branch: &git::repository::Branch) -> proto::Branch { @@ -6147,7 +6145,6 @@ async fn compute_snapshot( events.push(RepositoryEvent::BranchChanged); } - // Used by edit prediction data collection let remote_origin_url = backend.remote_url("origin").await; let remote_upstream_url = backend.remote_url("upstream").await; diff --git a/crates/proto/proto/git.proto b/crates/proto/proto/git.proto index aa0668ceabddc7627fcc3593b86ad2f4e40a6ac7..6e3573b91a690290b71e626f3bd67fc81d8d8e92 100644 --- a/crates/proto/proto/git.proto +++ b/crates/proto/proto/git.proto @@ -124,6 +124,8 @@ message UpdateRepository { optional GitCommitDetails head_commit_details = 11; optional string merge_message = 12; repeated StashEntry stash_entries = 13; + optional string remote_upstream_url = 14; + optional string remote_origin_url = 15; } message RemoveRepository { @@ -500,8 +502,8 @@ message BlameBufferResponse { message BlameResponse { repeated BlameEntry entries = 1; repeated CommitMessage messages = 2; - optional string remote_url = 4; reserved 3; + reserved 4; } optional BlameResponse blame_response = 5; From 9ae77ec3c9fb0c8d5fe85f370432487f5b8b22d6 Mon Sep 17 00:00:00 2001 From: vipex <101529155+vipexv@users.noreply.github.com> Date: Thu, 4 Dec 2025 19:48:06 +0100 Subject: [PATCH 064/621] markdown: Don't adjust indentation when inserting with multiple cursors (#40794) Closes #40757 ## Summary This PR addresses an issue where Zed incorrectly adjusts the indentation of Markdown lists when inserting text using multiple cursors. Currently: - Editing individual lines with a single cursor behaves correctly (no unwanted indentation changes). - Using multiple cursors, Zed automatically adjusts the indentation, unlike VS Code, which preserves the existing formatting. ## Tasks - [x] Implement a new test to verify correct Markdown indentation behavior with multiple cursors. - [x] Apply the fix to prevent Zed from adjusting indentation when inserting text on multiple cursors. ------------------------ Release Notes: - Fixed an issue where inserting text with multiple cursors inside a nested Markdown list would cause it to lose its indentation. --------- Co-authored-by: Smit Barmase --- Cargo.lock | 1 + crates/editor/Cargo.toml | 1 + crates/editor/src/editor_tests.rs | 59 +++++++++++++++++++++++ crates/languages/src/markdown/config.toml | 1 + crates/languages/src/markdown/indents.scm | 3 ++ 5 files changed, 65 insertions(+) create mode 100644 crates/languages/src/markdown/indents.scm diff --git a/Cargo.lock b/Cargo.lock index 5078c79e21ce1a580a6e055a7ce8ab4295f56906..87557afcb1b868cf9321bc0a4746e92687bb456d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5405,6 +5405,7 @@ dependencies = [ "tree-sitter-bash", "tree-sitter-c", "tree-sitter-html", + "tree-sitter-md", "tree-sitter-python", "tree-sitter-rust", "tree-sitter-typescript", diff --git a/crates/editor/Cargo.toml b/crates/editor/Cargo.toml index 2aa02e293dd44d5fdd920ac8cd98da48b9c1a912..736916ebbf74f20f11e8c03a0e584bd8ae92e07d 100644 --- a/crates/editor/Cargo.toml +++ b/crates/editor/Cargo.toml @@ -118,6 +118,7 @@ tree-sitter-rust.workspace = true tree-sitter-typescript.workspace = true tree-sitter-yaml.workspace = true tree-sitter-bash.workspace = true +tree-sitter-md.workspace = true unindent.workspace = true util = { workspace = true, features = ["test-support"] } workspace = { workspace = true, features = ["test-support"] } diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rs index 64c335e2e4b0dc660efe1b28bb87984fba8aafb4..7ab3dcc2345dd8a140b7c4762dc5afadb9cef484 100644 --- a/crates/editor/src/editor_tests.rs +++ b/crates/editor/src/editor_tests.rs @@ -27498,6 +27498,65 @@ async fn test_paste_url_from_other_app_creates_markdown_link_over_selected_text( )); } +#[gpui::test] +async fn test_markdown_list_indent_with_multi_cursor(cx: &mut gpui::TestAppContext) { + init_test(cx, |_| {}); + + let markdown_language = languages::language("markdown", tree_sitter_md::LANGUAGE.into()); + let mut cx = EditorTestContext::new(cx).await; + + cx.update_buffer(|buffer, cx| buffer.set_language(Some(markdown_language), cx)); + + cx.set_state(&indoc! {" + - [ ] Item 1 + - [ ] Item 1.a + - [ˇ] Item 2 + - [ˇ] Item 2.a + - [ˇ] Item 2.b + " + }); + + cx.update_editor(|editor, window, cx| { + editor.handle_input("X", window, cx); + }); + + cx.assert_editor_state(indoc! {" + - [ ] Item 1 + - [ ] Item 1.a + - [Xˇ] Item 2 + - [Xˇ] Item 2.a + - [Xˇ] Item 2.b + " + }); +} + +#[gpui::test] +async fn test_markdown_list_indent_with_newline(cx: &mut gpui::TestAppContext) { + init_test(cx, |_| {}); + + let markdown_language = languages::language("markdown", tree_sitter_md::LANGUAGE.into()); + let mut cx = EditorTestContext::new(cx).await; + + cx.update_buffer(|buffer, cx| buffer.set_language(Some(markdown_language), cx)); + + cx.set_state(indoc! {" + - [x] list item + - [x] sub list itemˇ + " + }); + + cx.update_editor(|editor, window, cx| { + editor.newline(&Newline, window, cx); + }); + + cx.assert_editor_state(indoc! {" + - [x] list item + - [x] sub list item + ˇ + " + }); +} + #[gpui::test] async fn test_paste_url_from_zed_copy_creates_markdown_link_over_selected_text( cx: &mut gpui::TestAppContext, diff --git a/crates/languages/src/markdown/config.toml b/crates/languages/src/markdown/config.toml index 36071cb5392462a51c10e0513b39979580ec67f5..2bbda0ef43e9a49b483dbe22cdf0473c8fbcf73c 100644 --- a/crates/languages/src/markdown/config.toml +++ b/crates/languages/src/markdown/config.toml @@ -24,4 +24,5 @@ rewrap_prefixes = [ auto_indent_on_paste = false auto_indent_using_last_non_empty_line = false tab_size = 2 +decrease_indent_pattern = "^\\s*$" prettier_parser_name = "markdown" diff --git a/crates/languages/src/markdown/indents.scm b/crates/languages/src/markdown/indents.scm new file mode 100644 index 0000000000000000000000000000000000000000..7fde3226bbbeb0fb9f0f7a1d90a328923a5228b3 --- /dev/null +++ b/crates/languages/src/markdown/indents.scm @@ -0,0 +1,3 @@ +(list (list_item) @indent) + +(list_item (list) @indent) From bdb8caa42e88c670be5278dab5819e770b92a133 Mon Sep 17 00:00:00 2001 From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Date: Thu, 4 Dec 2025 16:47:27 -0300 Subject: [PATCH 065/621] git_ui: Fix indent guides not showing for file buffers in the commit view (#44166) Follow up to https://github.com/zed-industries/zed/pull/44162 where my strategy for not displaying the indent guides only in the commit message was wrong given I ended up... disabling indent guides for all the buffers. This PR adds a new method to the editor where we can disable it for a specific buffer ID following the pattern of `disable_header_for_buffer`. Release Notes: - N/A --- crates/editor/src/editor.rs | 17 ++++++++++++++--- crates/editor/src/indent_guides.rs | 4 ++++ crates/git_ui/src/commit_view.rs | 3 ++- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 0de2dc8423b39ab2b336adb3cb17f79cc4a8f6e7..306d7a272b0b8c33e66803ccdbbd74194fde403a 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -1079,6 +1079,7 @@ pub struct Editor { show_breakpoints: Option, show_wrap_guides: Option, show_indent_guides: Option, + buffers_with_disabled_indent_guides: HashSet, highlight_order: usize, highlighted_rows: HashMap>, background_highlights: HashMap, @@ -2204,6 +2205,7 @@ impl Editor { show_breakpoints: None, show_wrap_guides: None, show_indent_guides, + buffers_with_disabled_indent_guides: HashSet::default(), highlight_order: 0, highlighted_rows: HashMap::default(), background_highlights: HashMap::default(), @@ -20090,9 +20092,18 @@ impl Editor { self.show_indent_guides } - pub fn disable_indent_guides(&mut self) -> Option { - self.show_indent_guides = Some(false); - self.show_indent_guides + pub fn disable_indent_guides_for_buffer( + &mut self, + buffer_id: BufferId, + cx: &mut Context, + ) { + self.buffers_with_disabled_indent_guides.insert(buffer_id); + cx.notify(); + } + + pub fn has_indent_guides_disabled_for_buffer(&self, buffer_id: BufferId) -> bool { + self.buffers_with_disabled_indent_guides + .contains(&buffer_id) } pub fn toggle_line_numbers( diff --git a/crates/editor/src/indent_guides.rs b/crates/editor/src/indent_guides.rs index 7c392d27531472a413ce4d32d09cce4eb722e462..f186f9da77aca5a0d34cdc05272032f93862b1d2 100644 --- a/crates/editor/src/indent_guides.rs +++ b/crates/editor/src/indent_guides.rs @@ -181,6 +181,10 @@ pub fn indent_guides_in_range( .buffer_snapshot() .indent_guides_in_range(start_anchor..end_anchor, ignore_disabled_for_language, cx) .filter(|indent_guide| { + if editor.has_indent_guides_disabled_for_buffer(indent_guide.buffer_id) { + return false; + } + if editor.is_buffer_folded(indent_guide.buffer_id, cx) { return false; } diff --git a/crates/git_ui/src/commit_view.rs b/crates/git_ui/src/commit_view.rs index 8a4504c1873193e81658c19c6b1115a9212e7760..7d191c1ae461ac36007dcbadc0b2e10f7dc53599 100644 --- a/crates/git_ui/src/commit_view.rs +++ b/crates/git_ui/src/commit_view.rs @@ -150,7 +150,6 @@ impl CommitView { Editor::for_multibuffer(multibuffer.clone(), Some(project.clone()), window, cx); editor.disable_inline_diagnostics(); - editor.disable_indent_guides(); editor.set_expand_all_diff_hunks(cx); editor @@ -259,6 +258,8 @@ impl CommitView { this.editor.update(cx, |editor, cx| { editor.disable_header_for_buffer(message_buffer.read(cx).remote_id(), cx); + editor + .disable_indent_guides_for_buffer(message_buffer.read(cx).remote_id(), cx); editor.insert_blocks( [BlockProperties { From 43f977c6b92411b82c757d1b168e72937b8d416a Mon Sep 17 00:00:00 2001 From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Date: Thu, 4 Dec 2025 16:48:03 -0300 Subject: [PATCH 066/621] terminal view: Use tooltip element for the tab tooltip (#44169) Just recently realized we don't need this custom component for it given we now have `Tooltip::element`. UI result is exactly the same; nothing changes. Release Notes: - N/A --- .../terminal_view/src/terminal_tab_tooltip.rs | 36 ------------------- crates/terminal_view/src/terminal_view.rs | 30 ++++++++++------ 2 files changed, 19 insertions(+), 47 deletions(-) delete mode 100644 crates/terminal_view/src/terminal_tab_tooltip.rs diff --git a/crates/terminal_view/src/terminal_tab_tooltip.rs b/crates/terminal_view/src/terminal_tab_tooltip.rs deleted file mode 100644 index 6324c0999a8231bb1e633ef39343944783029895..0000000000000000000000000000000000000000 --- a/crates/terminal_view/src/terminal_tab_tooltip.rs +++ /dev/null @@ -1,36 +0,0 @@ -use gpui::{IntoElement, Render}; -use ui::{Divider, prelude::*, tooltip_container}; - -pub struct TerminalTooltip { - title: SharedString, - pid: u32, -} - -impl TerminalTooltip { - pub fn new(title: impl Into, pid: u32) -> Self { - Self { - title: title.into(), - pid, - } - } -} - -impl Render for TerminalTooltip { - fn render(&mut self, _: &mut Window, cx: &mut Context) -> impl IntoElement { - tooltip_container(cx, move |this, _cx| { - this.occlude() - .on_mouse_move(|_, _window, cx| cx.stop_propagation()) - .child( - v_flex() - .gap_1() - .child(Label::new(self.title.clone())) - .child(Divider::horizontal()) - .child( - Label::new(format!("Process ID (PID): {}", self.pid)) - .color(Color::Muted) - .size(LabelSize::Small), - ), - ) - }) - } -} diff --git a/crates/terminal_view/src/terminal_view.rs b/crates/terminal_view/src/terminal_view.rs index 4d567d902ff4f9271a0bdcf6a4db94d0e3a34ec6..98f7a17a2778e05b258f2ab6135cb94ba91ba547 100644 --- a/crates/terminal_view/src/terminal_view.rs +++ b/crates/terminal_view/src/terminal_view.rs @@ -4,7 +4,6 @@ pub mod terminal_panel; mod terminal_path_like_target; pub mod terminal_scrollbar; mod terminal_slash_command; -pub mod terminal_tab_tooltip; use assistant_slash_command::SlashCommandRegistry; use editor::{EditorSettings, actions::SelectAll, blink_manager::BlinkManager}; @@ -32,9 +31,8 @@ use terminal_panel::TerminalPanel; use terminal_path_like_target::{hover_path_like_target, open_path_like_target}; use terminal_scrollbar::TerminalScrollHandle; use terminal_slash_command::TerminalSlashCommand; -use terminal_tab_tooltip::TerminalTooltip; use ui::{ - ContextMenu, Icon, IconName, Label, ScrollAxes, Scrollbars, Tooltip, WithScrollbar, h_flex, + ContextMenu, Divider, ScrollAxes, Scrollbars, Tooltip, WithScrollbar, prelude::*, scrollbars::{self, GlobalSetting, ScrollbarVisibility}, }; @@ -1140,14 +1138,24 @@ impl Item for TerminalView { type Event = ItemEvent; fn tab_tooltip_content(&self, cx: &App) -> Option { - let terminal = self.terminal().read(cx); - let title = terminal.title(false); - let pid = terminal.pid_getter()?.fallback_pid(); - - Some(TabTooltipContent::Custom(Box::new(move |_window, cx| { - cx.new(|_| TerminalTooltip::new(title.clone(), pid.as_u32())) - .into() - }))) + Some(TabTooltipContent::Custom(Box::new(Tooltip::element({ + let terminal = self.terminal().read(cx); + let title = terminal.title(false); + let pid = terminal.pid_getter()?.fallback_pid(); + + move |_, _| { + v_flex() + .gap_1() + .child(Label::new(title.clone())) + .child(h_flex().flex_grow().child(Divider::horizontal())) + .child( + Label::new(format!("Process ID (PID): {}", pid)) + .color(Color::Muted) + .size(LabelSize::Small), + ) + .into_any_element() + } + })))) } fn tab_content(&self, params: TabContentParams, _window: &Window, cx: &App) -> AnyElement { From cd8679e81a2d3c32b10bf65a3d583b6886d2a2f3 Mon Sep 17 00:00:00 2001 From: Ian Chamberlain Date: Thu, 4 Dec 2025 12:37:32 -0800 Subject: [PATCH 067/621] Allow trailing commas in builtin JSONC schemas (#43854) The JSON language server looks for a top-level `allowTrailingCommas` flag to decide whether it should warn for trailing commas. Since the JSONC parser for these builtin files can handles trailing commas, adding this flag to the schema also prevents a warning for those commas. I don't think there's an issue that is only for this specific issue, but it relates to *many* existing / older issues: - #18509 - #17487 - #40970 - #18509 - #21303 Release Notes: - Suppress warning for trailing commas in builtin JSON files (`settings.json`, `keymap.json`, etc.) --- crates/settings/src/keymap_file.rs | 5 ++++- crates/settings/src/settings_store.rs | 3 ++- crates/snippet_provider/src/format.rs | 3 ++- crates/task/src/debug_format.rs | 1 + crates/task/src/task_template.rs | 3 ++- crates/util/src/schemars.rs | 17 +++++++++++++++++ 6 files changed, 28 insertions(+), 4 deletions(-) diff --git a/crates/settings/src/keymap_file.rs b/crates/settings/src/keymap_file.rs index fc86afca2a1cbcd0a26777aa2ccb1fcb29b193a5..2ef1dfc5385592b9757eff5ec631af818ae1869c 100644 --- a/crates/settings/src/keymap_file.rs +++ b/crates/settings/src/keymap_file.rs @@ -15,6 +15,7 @@ use util::ResultExt as _; use util::{ asset_str, markdown::{MarkdownEscaped, MarkdownInlineCode, MarkdownString}, + schemars::AllowTrailingCommas, }; use crate::SettingsAssets; @@ -451,7 +452,9 @@ impl KeymapFile { /// Creates a JSON schema generator, suitable for generating json schemas /// for actions pub fn action_schema_generator() -> schemars::SchemaGenerator { - schemars::generate::SchemaSettings::draft2019_09().into_generator() + schemars::generate::SchemaSettings::draft2019_09() + .with_transform(AllowTrailingCommas) + .into_generator() } pub fn generate_json_schema_for_registered_actions(cx: &mut App) -> Value { diff --git a/crates/settings/src/settings_store.rs b/crates/settings/src/settings_store.rs index 181b8b417879be63fe85dbe6d08adca2d97929bd..72e2d3ef099659c5ad27e7f1aaafaee24354d4a9 100644 --- a/crates/settings/src/settings_store.rs +++ b/crates/settings/src/settings_store.rs @@ -25,7 +25,7 @@ use std::{ use util::{ ResultExt as _, rel_path::RelPath, - schemars::{DefaultDenyUnknownFields, replace_subschema}, + schemars::{AllowTrailingCommas, DefaultDenyUnknownFields, replace_subschema}, }; pub type EditorconfigProperties = ec4rs::Properties; @@ -1010,6 +1010,7 @@ impl SettingsStore { pub fn json_schema(&self, params: &SettingsJsonSchemaParams) -> Value { let mut generator = schemars::generate::SchemaSettings::draft2019_09() .with_transform(DefaultDenyUnknownFields) + .with_transform(AllowTrailingCommas) .into_generator(); UserSettingsContent::json_schema(&mut generator); diff --git a/crates/snippet_provider/src/format.rs b/crates/snippet_provider/src/format.rs index 0bbf137aed506f4cc7793f5dbe80ee144b620bf4..f9abb987d919b3a8bc7ab558e4bc86bac5e0b5a9 100644 --- a/crates/snippet_provider/src/format.rs +++ b/crates/snippet_provider/src/format.rs @@ -2,7 +2,7 @@ use collections::HashMap; use schemars::{JsonSchema, json_schema}; use serde::Deserialize; use std::borrow::Cow; -use util::schemars::DefaultDenyUnknownFields; +use util::schemars::{AllowTrailingCommas, DefaultDenyUnknownFields}; #[derive(Deserialize)] pub struct VsSnippetsFile { @@ -14,6 +14,7 @@ impl VsSnippetsFile { pub fn generate_json_schema() -> serde_json::Value { let schema = schemars::generate::SchemaSettings::draft2019_09() .with_transform(DefaultDenyUnknownFields) + .with_transform(AllowTrailingCommas) .into_generator() .root_schema_for::(); diff --git a/crates/task/src/debug_format.rs b/crates/task/src/debug_format.rs index 38089670e23f815221c274a2ccc4619b9e8bb327..5609e2565c8497ad2e92fb8b7d0e6738a1cb663c 100644 --- a/crates/task/src/debug_format.rs +++ b/crates/task/src/debug_format.rs @@ -357,6 +357,7 @@ impl DebugTaskFile { "$schema": meta_schema, "title": "Debug Configurations", "description": "Configuration for debug scenarios", + "allowTrailingCommas": true, "type": "array", "items": { "type": "object", diff --git a/crates/task/src/task_template.rs b/crates/task/src/task_template.rs index 33ff610b6e1ba509c75138ad4bf35478e69deaf1..0c319db0616862489b7b7d21912142a01ee89fcb 100644 --- a/crates/task/src/task_template.rs +++ b/crates/task/src/task_template.rs @@ -4,7 +4,7 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use sha2::{Digest, Sha256}; use std::path::PathBuf; -use util::schemars::DefaultDenyUnknownFields; +use util::schemars::{AllowTrailingCommas, DefaultDenyUnknownFields}; use util::serde::default_true; use util::{ResultExt, truncate_and_remove_front}; @@ -118,6 +118,7 @@ impl TaskTemplates { pub fn generate_json_schema() -> serde_json::Value { let schema = schemars::generate::SchemaSettings::draft2019_09() .with_transform(DefaultDenyUnknownFields) + .with_transform(AllowTrailingCommas) .into_generator() .root_schema_for::(); diff --git a/crates/util/src/schemars.rs b/crates/util/src/schemars.rs index 9314eda4ac4d5003d7186c3115137e2e54c66794..8124ca8cfef62cb4ea320da6423d7ad95a09eb78 100644 --- a/crates/util/src/schemars.rs +++ b/crates/util/src/schemars.rs @@ -53,3 +53,20 @@ impl schemars::transform::Transform for DefaultDenyUnknownFields { transform_subschemas(self, schema); } } + +/// Defaults `allowTrailingCommas` to `true`, for use with `json-language-server`. +/// This can be applied to any schema that will be treated as `jsonc`. +/// +/// Note that this is non-recursive and only applied to the root schema. +#[derive(Clone)] +pub struct AllowTrailingCommas; + +impl schemars::transform::Transform for AllowTrailingCommas { + fn transform(&mut self, schema: &mut schemars::Schema) { + if let Some(object) = schema.as_object_mut() + && !object.contains_key("allowTrailingCommas") + { + object.insert("allowTrailingCommas".to_string(), true.into()); + } + } +} From 76167109db7b2d899f2e88ffe04a84ca718dca03 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 4 Dec 2025 12:48:39 -0800 Subject: [PATCH 068/621] Add experimental LSP-based context retrieval system for edit prediction (#44036) To do * [x] Default to no context retrieval. Allow opting in to LSP-based retrieval via a setting (for users in `zeta2` feature flag) * [x] Feed this context to models when enabled * [x] Make the zeta2 context view work well with LSP retrieval * [x] Add a UI for the setting (for feature-flagged users) * [x] Ensure Zeta CLI `context` command is usable --- * [ ] Filter out LSP definitions that are too large / entire files (e.g. modules) * [ ] Introduce timeouts * [ ] Test with other LSPs * [ ] Figure out hangs Release Notes: - N/A --------- Co-authored-by: Ben Kunkle Co-authored-by: Agus Zubiaga --- Cargo.lock | 28 +- Cargo.toml | 2 + .../src/edit_prediction_button.rs | 28 +- crates/edit_prediction_context2/Cargo.toml | 42 + crates/edit_prediction_context2/LICENSE-GPL | 1 + .../src/assemble_excerpts.rs | 324 ++++++ .../src/edit_prediction_context2.rs | 465 +++++++++ .../src/edit_prediction_context_tests.rs | 360 +++++++ .../src/fake_definition_lsp.rs | 329 ++++++ .../src/extension_store_test.rs | 2 +- crates/language/src/buffer.rs | 14 + crates/language/src/buffer_tests.rs | 57 +- crates/language/src/language_registry.rs | 18 +- crates/language/src/language_settings.rs | 8 + crates/language/src/outline.rs | 50 +- crates/language/src/syntax_map.rs | 13 + .../remote_server/src/remote_editing_tests.rs | 6 +- .../settings/src/settings_content/language.rs | 2 + crates/text/src/anchor.rs | 8 +- crates/ui/src/components/data_table.rs | 22 +- crates/zeta/Cargo.toml | 1 + crates/zeta/src/assemble_excerpts.rs | 173 --- crates/zeta/src/retrieval_search.rs | 364 ++----- crates/zeta/src/sweep_ai.rs | 28 +- crates/zeta/src/zeta.rs | 984 ++++++++---------- crates/zeta2_tools/Cargo.toml | 1 - crates/zeta2_tools/src/zeta2_context_view.rs | 310 +++--- crates/zeta2_tools/src/zeta2_tools.rs | 12 + crates/zeta_cli/src/main.rs | 76 +- crates/zeta_cli/src/predict.rs | 61 +- crates/zeta_cli/src/util.rs | 28 +- 31 files changed, 2479 insertions(+), 1338 deletions(-) create mode 100644 crates/edit_prediction_context2/Cargo.toml create mode 120000 crates/edit_prediction_context2/LICENSE-GPL create mode 100644 crates/edit_prediction_context2/src/assemble_excerpts.rs create mode 100644 crates/edit_prediction_context2/src/edit_prediction_context2.rs create mode 100644 crates/edit_prediction_context2/src/edit_prediction_context_tests.rs create mode 100644 crates/edit_prediction_context2/src/fake_definition_lsp.rs delete mode 100644 crates/zeta/src/assemble_excerpts.rs diff --git a/Cargo.lock b/Cargo.lock index 87557afcb1b868cf9321bc0a4746e92687bb456d..6d41fbe96fac878f496e93461c180e1c184216d6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5342,6 +5342,32 @@ dependencies = [ "zlog", ] +[[package]] +name = "edit_prediction_context2" +version = "0.1.0" +dependencies = [ + "anyhow", + "collections", + "env_logger 0.11.8", + "futures 0.3.31", + "gpui", + "indoc", + "language", + "log", + "lsp", + "parking_lot", + "pretty_assertions", + "project", + "serde", + "serde_json", + "settings", + "smallvec", + "text", + "tree-sitter", + "util", + "zlog", +] + [[package]] name = "editor" version = "0.1.0" @@ -21693,6 +21719,7 @@ dependencies = [ "db", "edit_prediction", "edit_prediction_context", + "edit_prediction_context2", "editor", "feature_flags", "fs", @@ -21742,7 +21769,6 @@ dependencies = [ "clap", "client", "cloud_llm_client", - "cloud_zeta2_prompt", "collections", "edit_prediction_context", "editor", diff --git a/Cargo.toml b/Cargo.toml index 59b9a53d4a60b28582625fb90b64b934079cdc40..62a44dbf35fefbf02a1b570146b0bf24cea6dcd8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -56,6 +56,7 @@ members = [ "crates/edit_prediction", "crates/edit_prediction_button", "crates/edit_prediction_context", + "crates/edit_prediction_context2", "crates/zeta2_tools", "crates/editor", "crates/eval", @@ -316,6 +317,7 @@ image_viewer = { path = "crates/image_viewer" } edit_prediction = { path = "crates/edit_prediction" } edit_prediction_button = { path = "crates/edit_prediction_button" } edit_prediction_context = { path = "crates/edit_prediction_context" } +edit_prediction_context2 = { path = "crates/edit_prediction_context2" } zeta2_tools = { path = "crates/zeta2_tools" } inspector_ui = { path = "crates/inspector_ui" } install_cli = { path = "crates/install_cli" } diff --git a/crates/edit_prediction_button/src/edit_prediction_button.rs b/crates/edit_prediction_button/src/edit_prediction_button.rs index 8ce8441859b7cc747a2b566dedd913e58259969d..8b234497376aefdc972681c877a1122f3f9cee17 100644 --- a/crates/edit_prediction_button/src/edit_prediction_button.rs +++ b/crates/edit_prediction_button/src/edit_prediction_button.rs @@ -1105,9 +1105,33 @@ impl EditPredictionButton { .separator(); } - let menu = self.build_language_settings_menu(menu, window, cx); - let menu = self.add_provider_switching_section(menu, provider, cx); + menu = self.build_language_settings_menu(menu, window, cx); + + if cx.has_flag::() { + let settings = all_language_settings(None, cx); + let context_retrieval = settings.edit_predictions.use_context; + menu = menu.separator().header("Context Retrieval").item( + ContextMenuEntry::new("Enable Context Retrieval") + .toggleable(IconPosition::Start, context_retrieval) + .action(workspace::ToggleEditPrediction.boxed_clone()) + .handler({ + let fs = self.fs.clone(); + move |_, cx| { + update_settings_file(fs.clone(), cx, move |settings, _| { + settings + .project + .all_languages + .features + .get_or_insert_default() + .experimental_edit_prediction_context_retrieval = + Some(!context_retrieval) + }); + } + }), + ); + } + menu = self.add_provider_switching_section(menu, provider, cx); menu }) } diff --git a/crates/edit_prediction_context2/Cargo.toml b/crates/edit_prediction_context2/Cargo.toml new file mode 100644 index 0000000000000000000000000000000000000000..597884b44821e24a930c8730225be4c6bf1c90f6 --- /dev/null +++ b/crates/edit_prediction_context2/Cargo.toml @@ -0,0 +1,42 @@ +[package] +name = "edit_prediction_context2" +version = "0.1.0" +edition.workspace = true +publish.workspace = true +license = "GPL-3.0-or-later" + +[lints] +workspace = true + +[lib] +path = "src/edit_prediction_context2.rs" + +[dependencies] +parking_lot.workspace = true +anyhow.workspace = true +collections.workspace = true +futures.workspace = true +gpui.workspace = true +language.workspace = true +lsp.workspace = true +project.workspace = true +log.workspace = true +serde.workspace = true +smallvec.workspace = true +tree-sitter.workspace = true +util.workspace = true + +[dev-dependencies] +env_logger.workspace = true +indoc.workspace = true +futures.workspace = true +gpui = { workspace = true, features = ["test-support"] } +language = { workspace = true, features = ["test-support"] } +lsp = { workspace = true, features = ["test-support"] } +pretty_assertions.workspace = true +project = {workspace= true, features = ["test-support"]} +serde_json.workspace = true +settings = {workspace= true, features = ["test-support"]} +text = { workspace = true, features = ["test-support"] } +util = { workspace = true, features = ["test-support"] } +zlog.workspace = true diff --git a/crates/edit_prediction_context2/LICENSE-GPL b/crates/edit_prediction_context2/LICENSE-GPL new file mode 120000 index 0000000000000000000000000000000000000000..89e542f750cd3860a0598eff0dc34b56d7336dc4 --- /dev/null +++ b/crates/edit_prediction_context2/LICENSE-GPL @@ -0,0 +1 @@ +../../LICENSE-GPL \ No newline at end of file diff --git a/crates/edit_prediction_context2/src/assemble_excerpts.rs b/crates/edit_prediction_context2/src/assemble_excerpts.rs new file mode 100644 index 0000000000000000000000000000000000000000..b3b8d4f8bc480053a1e9ab9d498d5350039ed609 --- /dev/null +++ b/crates/edit_prediction_context2/src/assemble_excerpts.rs @@ -0,0 +1,324 @@ +use crate::RelatedExcerpt; +use language::{BufferSnapshot, OffsetRangeExt as _, Point}; +use std::ops::Range; + +#[cfg(not(test))] +const MAX_OUTLINE_ITEM_BODY_SIZE: usize = 512; +#[cfg(test)] +const MAX_OUTLINE_ITEM_BODY_SIZE: usize = 24; + +pub fn assemble_excerpts( + buffer: &BufferSnapshot, + mut input_ranges: Vec>, +) -> Vec { + merge_ranges(&mut input_ranges); + + let mut outline_ranges = Vec::new(); + let outline_items = buffer.outline_items_as_points_containing(0..buffer.len(), false, None); + let mut outline_ix = 0; + for input_range in &mut input_ranges { + *input_range = clip_range_to_lines(input_range, false, buffer); + + while let Some(outline_item) = outline_items.get(outline_ix) { + let item_range = clip_range_to_lines(&outline_item.range, false, buffer); + + if item_range.start > input_range.start { + break; + } + + if item_range.end > input_range.start { + let body_range = outline_item + .body_range(buffer) + .map(|body| clip_range_to_lines(&body, true, buffer)) + .filter(|body_range| { + body_range.to_offset(buffer).len() > MAX_OUTLINE_ITEM_BODY_SIZE + }); + + add_outline_item( + item_range.clone(), + body_range.clone(), + buffer, + &mut outline_ranges, + ); + + if let Some(body_range) = body_range + && input_range.start < body_range.start + { + let mut child_outline_ix = outline_ix + 1; + while let Some(next_outline_item) = outline_items.get(child_outline_ix) { + if next_outline_item.range.end > body_range.end { + break; + } + if next_outline_item.depth == outline_item.depth + 1 { + let next_item_range = + clip_range_to_lines(&next_outline_item.range, false, buffer); + + add_outline_item( + next_item_range, + next_outline_item + .body_range(buffer) + .map(|body| clip_range_to_lines(&body, true, buffer)), + buffer, + &mut outline_ranges, + ); + child_outline_ix += 1; + } + } + } + } + + outline_ix += 1; + } + } + + input_ranges.extend_from_slice(&outline_ranges); + merge_ranges(&mut input_ranges); + + input_ranges + .into_iter() + .map(|range| { + let offset_range = range.to_offset(buffer); + RelatedExcerpt { + point_range: range, + anchor_range: buffer.anchor_before(offset_range.start) + ..buffer.anchor_after(offset_range.end), + text: buffer.as_rope().slice(offset_range), + } + }) + .collect() +} + +fn clip_range_to_lines( + range: &Range, + inward: bool, + buffer: &BufferSnapshot, +) -> Range { + let mut range = range.clone(); + if inward { + if range.start.column > 0 { + range.start.column = buffer.line_len(range.start.row); + } + range.end.column = 0; + } else { + range.start.column = 0; + if range.end.column > 0 { + range.end.column = buffer.line_len(range.end.row); + } + } + range +} + +fn add_outline_item( + mut item_range: Range, + body_range: Option>, + buffer: &BufferSnapshot, + outline_ranges: &mut Vec>, +) { + if let Some(mut body_range) = body_range { + if body_range.start.column > 0 { + body_range.start.column = buffer.line_len(body_range.start.row); + } + body_range.end.column = 0; + + let head_range = item_range.start..body_range.start; + if head_range.start < head_range.end { + outline_ranges.push(head_range); + } + + let tail_range = body_range.end..item_range.end; + if tail_range.start < tail_range.end { + outline_ranges.push(tail_range); + } + } else { + item_range.start.column = 0; + item_range.end.column = buffer.line_len(item_range.end.row); + outline_ranges.push(item_range); + } +} + +pub fn merge_ranges(ranges: &mut Vec>) { + ranges.sort_unstable_by(|a, b| a.start.cmp(&b.start).then(b.end.cmp(&a.end))); + + let mut index = 1; + while index < ranges.len() { + let mut prev_range_end = ranges[index - 1].end; + if prev_range_end.column > 0 { + prev_range_end += Point::new(1, 0); + } + + if (prev_range_end + Point::new(1, 0)) + .cmp(&ranges[index].start) + .is_ge() + { + let removed = ranges.remove(index); + if removed.end.cmp(&ranges[index - 1].end).is_gt() { + ranges[index - 1].end = removed.end; + } + } else { + index += 1; + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + use gpui::{TestAppContext, prelude::*}; + use indoc::indoc; + use language::{Buffer, Language, LanguageConfig, LanguageMatcher, OffsetRangeExt}; + use pretty_assertions::assert_eq; + use std::{fmt::Write as _, sync::Arc}; + use util::test::marked_text_ranges; + + #[gpui::test] + fn test_rust(cx: &mut TestAppContext) { + let table = [ + ( + indoc! {r#" + struct User { + first_name: String, + «last_name»: String, + age: u32, + email: String, + create_at: Instant, + } + + impl User { + pub fn first_name(&self) -> String { + self.first_name.clone() + } + + pub fn full_name(&self) -> String { + « format!("{} {}", self.first_name, self.last_name) + » } + } + "#}, + indoc! {r#" + struct User { + first_name: String, + last_name: String, + … + } + + impl User { + … + pub fn full_name(&self) -> String { + format!("{} {}", self.first_name, self.last_name) + } + } + "#}, + ), + ( + indoc! {r#" + struct «User» { + first_name: String, + last_name: String, + age: u32, + } + + impl User { + // methods + } + "# + }, + indoc! {r#" + struct User { + first_name: String, + last_name: String, + age: u32, + } + … + "#}, + ), + ( + indoc! {r#" + trait «FooProvider» { + const NAME: &'static str; + + fn provide_foo(&self, id: usize) -> Foo; + + fn provide_foo_batched(&self, ids: &[usize]) -> Vec { + ids.iter() + .map(|id| self.provide_foo(*id)) + .collect() + } + + fn sync(&self); + } + "# + }, + indoc! {r#" + trait FooProvider { + const NAME: &'static str; + + fn provide_foo(&self, id: usize) -> Foo; + + fn provide_foo_batched(&self, ids: &[usize]) -> Vec { + … + } + + fn sync(&self); + } + "#}, + ), + ]; + + for (input, expected_output) in table { + let (input, ranges) = marked_text_ranges(&input, false); + let buffer = + cx.new(|cx| Buffer::local(input, cx).with_language(Arc::new(rust_lang()), cx)); + buffer.read_with(cx, |buffer, _cx| { + let ranges: Vec> = ranges + .into_iter() + .map(|range| range.to_point(&buffer)) + .collect(); + + let excerpts = assemble_excerpts(&buffer.snapshot(), ranges); + + let output = format_excerpts(buffer, &excerpts); + assert_eq!(output, expected_output); + }); + } + } + + fn format_excerpts(buffer: &Buffer, excerpts: &[RelatedExcerpt]) -> String { + let mut output = String::new(); + let file_line_count = buffer.max_point().row; + let mut current_row = 0; + for excerpt in excerpts { + if excerpt.text.is_empty() { + continue; + } + if current_row < excerpt.point_range.start.row { + writeln!(&mut output, "…").unwrap(); + } + current_row = excerpt.point_range.start.row; + + for line in excerpt.text.to_string().lines() { + output.push_str(line); + output.push('\n'); + current_row += 1; + } + } + if current_row < file_line_count { + writeln!(&mut output, "…").unwrap(); + } + output + } + + fn rust_lang() -> Language { + Language::new( + LanguageConfig { + name: "Rust".into(), + matcher: LanguageMatcher { + path_suffixes: vec!["rs".to_string()], + ..Default::default() + }, + ..Default::default() + }, + Some(language::tree_sitter_rust::LANGUAGE.into()), + ) + .with_outline_query(include_str!("../../languages/src/rust/outline.scm")) + .unwrap() + } +} diff --git a/crates/edit_prediction_context2/src/edit_prediction_context2.rs b/crates/edit_prediction_context2/src/edit_prediction_context2.rs new file mode 100644 index 0000000000000000000000000000000000000000..f8790478547ddb8b7b873015846f2af6c1bcbc2c --- /dev/null +++ b/crates/edit_prediction_context2/src/edit_prediction_context2.rs @@ -0,0 +1,465 @@ +use crate::assemble_excerpts::assemble_excerpts; +use anyhow::Result; +use collections::HashMap; +use futures::{FutureExt, StreamExt as _, channel::mpsc, future}; +use gpui::{App, AppContext, AsyncApp, Context, Entity, EventEmitter, Task, WeakEntity}; +use language::{Anchor, Buffer, BufferSnapshot, OffsetRangeExt as _, Point, Rope, ToOffset as _}; +use project::{LocationLink, Project, ProjectPath}; +use serde::{Serialize, Serializer}; +use smallvec::SmallVec; +use std::{ + collections::hash_map, + ops::Range, + sync::Arc, + time::{Duration, Instant}, +}; +use util::{RangeExt as _, ResultExt}; + +mod assemble_excerpts; +#[cfg(test)] +mod edit_prediction_context_tests; +#[cfg(test)] +mod fake_definition_lsp; + +pub struct RelatedExcerptStore { + project: WeakEntity, + related_files: Vec, + cache: HashMap>, + update_tx: mpsc::UnboundedSender<(Entity, Anchor)>, +} + +pub enum RelatedExcerptStoreEvent { + StartedRefresh, + FinishedRefresh { + cache_hit_count: usize, + cache_miss_count: usize, + mean_definition_latency: Duration, + max_definition_latency: Duration, + }, +} + +#[derive(Clone, Debug, PartialEq, Eq, Hash)] +struct Identifier { + pub name: String, + pub range: Range, +} + +enum DefinitionTask { + CacheHit(Arc), + CacheMiss(Task>>>), +} + +#[derive(Debug)] +struct CacheEntry { + definitions: SmallVec<[CachedDefinition; 1]>, +} + +#[derive(Clone, Debug)] +struct CachedDefinition { + path: ProjectPath, + buffer: Entity, + anchor_range: Range, +} + +#[derive(Clone, Debug, Serialize)] +pub struct RelatedFile { + #[serde(serialize_with = "serialize_project_path")] + pub path: ProjectPath, + #[serde(skip)] + pub buffer: WeakEntity, + pub excerpts: Vec, + pub max_row: u32, +} + +impl RelatedFile { + pub fn merge_excerpts(&mut self) { + self.excerpts.sort_unstable_by(|a, b| { + a.point_range + .start + .cmp(&b.point_range.start) + .then(b.point_range.end.cmp(&a.point_range.end)) + }); + + let mut index = 1; + while index < self.excerpts.len() { + if self.excerpts[index - 1] + .point_range + .end + .cmp(&self.excerpts[index].point_range.start) + .is_ge() + { + let removed = self.excerpts.remove(index); + if removed + .point_range + .end + .cmp(&self.excerpts[index - 1].point_range.end) + .is_gt() + { + self.excerpts[index - 1].point_range.end = removed.point_range.end; + self.excerpts[index - 1].anchor_range.end = removed.anchor_range.end; + } + } else { + index += 1; + } + } + } +} + +#[derive(Clone, Debug, Serialize)] +pub struct RelatedExcerpt { + #[serde(skip)] + pub anchor_range: Range, + #[serde(serialize_with = "serialize_point_range")] + pub point_range: Range, + #[serde(serialize_with = "serialize_rope")] + pub text: Rope, +} + +fn serialize_project_path( + project_path: &ProjectPath, + serializer: S, +) -> Result { + project_path.path.serialize(serializer) +} + +fn serialize_rope(rope: &Rope, serializer: S) -> Result { + rope.to_string().serialize(serializer) +} + +fn serialize_point_range( + range: &Range, + serializer: S, +) -> Result { + [ + [range.start.row, range.start.column], + [range.end.row, range.end.column], + ] + .serialize(serializer) +} + +const DEBOUNCE_DURATION: Duration = Duration::from_millis(100); + +impl EventEmitter for RelatedExcerptStore {} + +impl RelatedExcerptStore { + pub fn new(project: &Entity, cx: &mut Context) -> Self { + let (update_tx, mut update_rx) = mpsc::unbounded::<(Entity, Anchor)>(); + cx.spawn(async move |this, cx| { + let executor = cx.background_executor().clone(); + while let Some((mut buffer, mut position)) = update_rx.next().await { + let mut timer = executor.timer(DEBOUNCE_DURATION).fuse(); + loop { + futures::select_biased! { + next = update_rx.next() => { + if let Some((new_buffer, new_position)) = next { + buffer = new_buffer; + position = new_position; + timer = executor.timer(DEBOUNCE_DURATION).fuse(); + } else { + return anyhow::Ok(()); + } + } + _ = timer => break, + } + } + + Self::fetch_excerpts(this.clone(), buffer, position, cx).await?; + } + anyhow::Ok(()) + }) + .detach_and_log_err(cx); + + RelatedExcerptStore { + project: project.downgrade(), + update_tx, + related_files: Vec::new(), + cache: Default::default(), + } + } + + pub fn refresh(&mut self, buffer: Entity, position: Anchor, _: &mut Context) { + self.update_tx.unbounded_send((buffer, position)).ok(); + } + + pub fn related_files(&self) -> &[RelatedFile] { + &self.related_files + } + + async fn fetch_excerpts( + this: WeakEntity, + buffer: Entity, + position: Anchor, + cx: &mut AsyncApp, + ) -> Result<()> { + let (project, snapshot) = this.read_with(cx, |this, cx| { + (this.project.upgrade(), buffer.read(cx).snapshot()) + })?; + let Some(project) = project else { + return Ok(()); + }; + + let file = snapshot.file().cloned(); + if let Some(file) = &file { + log::debug!("retrieving_context buffer:{}", file.path().as_unix_str()); + } + + this.update(cx, |_, cx| { + cx.emit(RelatedExcerptStoreEvent::StartedRefresh); + })?; + + let identifiers = cx + .background_spawn(async move { identifiers_for_position(&snapshot, position) }) + .await; + + let async_cx = cx.clone(); + let start_time = Instant::now(); + let futures = this.update(cx, |this, cx| { + identifiers + .into_iter() + .filter_map(|identifier| { + let task = if let Some(entry) = this.cache.get(&identifier) { + DefinitionTask::CacheHit(entry.clone()) + } else { + DefinitionTask::CacheMiss( + this.project + .update(cx, |project, cx| { + project.definitions(&buffer, identifier.range.start, cx) + }) + .ok()?, + ) + }; + + let cx = async_cx.clone(); + let project = project.clone(); + Some(async move { + match task { + DefinitionTask::CacheHit(cache_entry) => { + Some((identifier, cache_entry, None)) + } + DefinitionTask::CacheMiss(task) => { + let locations = task.await.log_err()??; + let duration = start_time.elapsed(); + cx.update(|cx| { + ( + identifier, + Arc::new(CacheEntry { + definitions: locations + .into_iter() + .filter_map(|location| { + process_definition(location, &project, cx) + }) + .collect(), + }), + Some(duration), + ) + }) + .ok() + } + } + }) + }) + .collect::>() + })?; + + let mut cache_hit_count = 0; + let mut cache_miss_count = 0; + let mut mean_definition_latency = Duration::ZERO; + let mut max_definition_latency = Duration::ZERO; + let mut new_cache = HashMap::default(); + new_cache.reserve(futures.len()); + for (identifier, entry, duration) in future::join_all(futures).await.into_iter().flatten() { + new_cache.insert(identifier, entry); + if let Some(duration) = duration { + cache_miss_count += 1; + mean_definition_latency += duration; + max_definition_latency = max_definition_latency.max(duration); + } else { + cache_hit_count += 1; + } + } + mean_definition_latency /= cache_miss_count.max(1) as u32; + + let (new_cache, related_files) = rebuild_related_files(new_cache, cx).await?; + + if let Some(file) = &file { + log::debug!( + "finished retrieving context buffer:{}, latency:{:?}", + file.path().as_unix_str(), + start_time.elapsed() + ); + } + + this.update(cx, |this, cx| { + this.cache = new_cache; + this.related_files = related_files; + cx.emit(RelatedExcerptStoreEvent::FinishedRefresh { + cache_hit_count, + cache_miss_count, + mean_definition_latency, + max_definition_latency, + }); + })?; + + anyhow::Ok(()) + } +} + +async fn rebuild_related_files( + new_entries: HashMap>, + cx: &mut AsyncApp, +) -> Result<(HashMap>, Vec)> { + let mut snapshots = HashMap::default(); + for entry in new_entries.values() { + for definition in &entry.definitions { + if let hash_map::Entry::Vacant(e) = snapshots.entry(definition.buffer.entity_id()) { + definition + .buffer + .read_with(cx, |buffer, _| buffer.parsing_idle())? + .await; + e.insert( + definition + .buffer + .read_with(cx, |buffer, _| buffer.snapshot())?, + ); + } + } + } + + Ok(cx + .background_spawn(async move { + let mut files = Vec::::new(); + let mut ranges_by_buffer = HashMap::<_, Vec>>::default(); + let mut paths_by_buffer = HashMap::default(); + for entry in new_entries.values() { + for definition in &entry.definitions { + let Some(snapshot) = snapshots.get(&definition.buffer.entity_id()) else { + continue; + }; + paths_by_buffer.insert(definition.buffer.entity_id(), definition.path.clone()); + ranges_by_buffer + .entry(definition.buffer.clone()) + .or_default() + .push(definition.anchor_range.to_point(snapshot)); + } + } + + for (buffer, ranges) in ranges_by_buffer { + let Some(snapshot) = snapshots.get(&buffer.entity_id()) else { + continue; + }; + let Some(project_path) = paths_by_buffer.get(&buffer.entity_id()) else { + continue; + }; + let excerpts = assemble_excerpts(snapshot, ranges); + files.push(RelatedFile { + path: project_path.clone(), + buffer: buffer.downgrade(), + excerpts, + max_row: snapshot.max_point().row, + }); + } + + files.sort_by_key(|file| file.path.clone()); + (new_entries, files) + }) + .await) +} + +fn process_definition( + location: LocationLink, + project: &Entity, + cx: &mut App, +) -> Option { + let buffer = location.target.buffer.read(cx); + let anchor_range = location.target.range; + let file = buffer.file()?; + let worktree = project.read(cx).worktree_for_id(file.worktree_id(cx), cx)?; + if worktree.read(cx).is_single_file() { + return None; + } + Some(CachedDefinition { + path: ProjectPath { + worktree_id: file.worktree_id(cx), + path: file.path().clone(), + }, + buffer: location.target.buffer, + anchor_range, + }) +} + +/// Gets all of the identifiers that are present in the given line, and its containing +/// outline items. +fn identifiers_for_position(buffer: &BufferSnapshot, position: Anchor) -> Vec { + let offset = position.to_offset(buffer); + let point = buffer.offset_to_point(offset); + + let line_range = Point::new(point.row, 0)..Point::new(point.row + 1, 0).min(buffer.max_point()); + let mut ranges = vec![line_range.to_offset(&buffer)]; + + // Include the range of the outline item itself, but not its body. + let outline_items = buffer.outline_items_as_offsets_containing(offset..offset, false, None); + for item in outline_items { + if let Some(body_range) = item.body_range(&buffer) { + ranges.push(item.range.start..body_range.start.to_offset(&buffer)); + } else { + ranges.push(item.range.clone()); + } + } + + ranges.sort_by(|a, b| a.start.cmp(&b.start).then(b.end.cmp(&a.end))); + ranges.dedup_by(|a, b| { + if a.start <= b.end { + b.start = b.start.min(a.start); + b.end = b.end.max(a.end); + true + } else { + false + } + }); + + let mut identifiers = Vec::new(); + let outer_range = + ranges.first().map_or(0, |r| r.start)..ranges.last().map_or(buffer.len(), |r| r.end); + + let mut captures = buffer + .syntax + .captures(outer_range.clone(), &buffer.text, |grammar| { + grammar + .highlights_config + .as_ref() + .map(|config| &config.query) + }); + + for range in ranges { + captures.set_byte_range(range.start..outer_range.end); + + let mut last_range = None; + while let Some(capture) = captures.peek() { + let node_range = capture.node.byte_range(); + if node_range.start > range.end { + break; + } + let config = captures.grammars()[capture.grammar_index] + .highlights_config + .as_ref(); + + if let Some(config) = config + && config.identifier_capture_indices.contains(&capture.index) + && range.contains_inclusive(&node_range) + && Some(&node_range) != last_range.as_ref() + { + let name = buffer.text_for_range(node_range.clone()).collect(); + identifiers.push(Identifier { + range: buffer.anchor_after(node_range.start) + ..buffer.anchor_before(node_range.end), + name, + }); + last_range = Some(node_range); + } + + captures.advance(); + } + } + + identifiers +} diff --git a/crates/edit_prediction_context2/src/edit_prediction_context_tests.rs b/crates/edit_prediction_context2/src/edit_prediction_context_tests.rs new file mode 100644 index 0000000000000000000000000000000000000000..05d1becc2167837a5f9741d77e7bc96c2f5b8d34 --- /dev/null +++ b/crates/edit_prediction_context2/src/edit_prediction_context_tests.rs @@ -0,0 +1,360 @@ +use super::*; +use futures::channel::mpsc::UnboundedReceiver; +use gpui::TestAppContext; +use indoc::indoc; +use language::{Language, LanguageConfig, LanguageMatcher, Point, ToPoint as _, tree_sitter_rust}; +use lsp::FakeLanguageServer; +use project::{FakeFs, LocationLink, Project}; +use serde_json::json; +use settings::SettingsStore; +use std::sync::Arc; +use util::path; + +#[gpui::test] +async fn test_edit_prediction_context(cx: &mut TestAppContext) { + init_test(cx); + let fs = FakeFs::new(cx.executor()); + fs.insert_tree(path!("/root"), test_project_1()).await; + + let project = Project::test(fs.clone(), [path!("/root").as_ref()], cx).await; + let mut servers = setup_fake_lsp(&project, cx); + + let (buffer, _handle) = project + .update(cx, |project, cx| { + project.open_local_buffer_with_lsp(path!("/root/src/main.rs"), cx) + }) + .await + .unwrap(); + + let _server = servers.next().await.unwrap(); + cx.run_until_parked(); + + let related_excerpt_store = cx.new(|cx| RelatedExcerptStore::new(&project, cx)); + related_excerpt_store.update(cx, |store, cx| { + let position = { + let buffer = buffer.read(cx); + let offset = buffer.text().find("todo").unwrap(); + buffer.anchor_before(offset) + }; + + store.refresh(buffer.clone(), position, cx); + }); + + cx.executor().advance_clock(DEBOUNCE_DURATION); + related_excerpt_store.update(cx, |store, _| { + let excerpts = store.related_files(); + assert_related_files( + &excerpts, + &[ + ( + "src/company.rs", + &[indoc! {" + pub struct Company { + owner: Arc, + address: Address, + }"}], + ), + ( + "src/main.rs", + &[ + indoc! {" + pub struct Session { + company: Arc, + } + + impl Session { + pub fn set_company(&mut self, company: Arc) {"}, + indoc! {" + } + }"}, + ], + ), + ( + "src/person.rs", + &[ + indoc! {" + impl Person { + pub fn get_first_name(&self) -> &str { + &self.first_name + }"}, + "}", + ], + ), + ], + ); + }); +} + +#[gpui::test] +async fn test_fake_definition_lsp(cx: &mut TestAppContext) { + init_test(cx); + + let fs = FakeFs::new(cx.executor()); + fs.insert_tree(path!("/root"), test_project_1()).await; + + let project = Project::test(fs.clone(), [path!("/root").as_ref()], cx).await; + let mut servers = setup_fake_lsp(&project, cx); + + let (buffer, _handle) = project + .update(cx, |project, cx| { + project.open_local_buffer_with_lsp(path!("/root/src/main.rs"), cx) + }) + .await + .unwrap(); + + let _server = servers.next().await.unwrap(); + cx.run_until_parked(); + + let buffer_text = buffer.read_with(cx, |buffer, _| buffer.text()); + + let definitions = project + .update(cx, |project, cx| { + let offset = buffer_text.find("Address {").unwrap(); + project.definitions(&buffer, offset, cx) + }) + .await + .unwrap() + .unwrap(); + assert_definitions(&definitions, &["pub struct Address {"], cx); + + let definitions = project + .update(cx, |project, cx| { + let offset = buffer_text.find("State::CA").unwrap(); + project.definitions(&buffer, offset, cx) + }) + .await + .unwrap() + .unwrap(); + assert_definitions(&definitions, &["pub enum State {"], cx); + + let definitions = project + .update(cx, |project, cx| { + let offset = buffer_text.find("to_string()").unwrap(); + project.definitions(&buffer, offset, cx) + }) + .await + .unwrap() + .unwrap(); + assert_definitions(&definitions, &["pub fn to_string(&self) -> String {"], cx); +} + +fn init_test(cx: &mut TestAppContext) { + let settings_store = cx.update(|cx| SettingsStore::test(cx)); + cx.set_global(settings_store); + env_logger::try_init().ok(); +} + +fn setup_fake_lsp( + project: &Entity, + cx: &mut TestAppContext, +) -> UnboundedReceiver { + let (language_registry, fs) = project.read_with(cx, |project, _| { + (project.languages().clone(), project.fs().clone()) + }); + let language = rust_lang(); + language_registry.add(language.clone()); + fake_definition_lsp::register_fake_definition_server(&language_registry, language, fs) +} + +fn test_project_1() -> serde_json::Value { + let person_rs = indoc! {r#" + pub struct Person { + first_name: String, + last_name: String, + email: String, + age: u32, + } + + impl Person { + pub fn get_first_name(&self) -> &str { + &self.first_name + } + + pub fn get_last_name(&self) -> &str { + &self.last_name + } + + pub fn get_email(&self) -> &str { + &self.email + } + + pub fn get_age(&self) -> u32 { + self.age + } + } + "#}; + + let address_rs = indoc! {r#" + pub struct Address { + street: String, + city: String, + state: State, + zip: u32, + } + + pub enum State { + CA, + OR, + WA, + TX, + // ... + } + + impl Address { + pub fn get_street(&self) -> &str { + &self.street + } + + pub fn get_city(&self) -> &str { + &self.city + } + + pub fn get_state(&self) -> State { + self.state + } + + pub fn get_zip(&self) -> u32 { + self.zip + } + } + "#}; + + let company_rs = indoc! {r#" + use super::person::Person; + use super::address::Address; + + pub struct Company { + owner: Arc, + address: Address, + } + + impl Company { + pub fn get_owner(&self) -> &Person { + &self.owner + } + + pub fn get_address(&self) -> &Address { + &self.address + } + + pub fn to_string(&self) -> String { + format!("{} ({})", self.owner.first_name, self.address.city) + } + } + "#}; + + let main_rs = indoc! {r#" + use std::sync::Arc; + use super::person::Person; + use super::address::Address; + use super::company::Company; + + pub struct Session { + company: Arc, + } + + impl Session { + pub fn set_company(&mut self, company: Arc) { + self.company = company; + if company.owner != self.company.owner { + log("new owner", company.owner.get_first_name()); todo(); + } + } + } + + fn main() { + let company = Company { + owner: Arc::new(Person { + first_name: "John".to_string(), + last_name: "Doe".to_string(), + email: "john@example.com".to_string(), + age: 30, + }), + address: Address { + street: "123 Main St".to_string(), + city: "Anytown".to_string(), + state: State::CA, + zip: 12345, + }, + }; + + println!("Company: {}", company.to_string()); + } + "#}; + + json!({ + "src": { + "person.rs": person_rs, + "address.rs": address_rs, + "company.rs": company_rs, + "main.rs": main_rs, + }, + }) +} + +fn assert_related_files(actual_files: &[RelatedFile], expected_files: &[(&str, &[&str])]) { + let actual_files = actual_files + .iter() + .map(|file| { + let excerpts = file + .excerpts + .iter() + .map(|excerpt| excerpt.text.to_string()) + .collect::>(); + (file.path.path.as_unix_str(), excerpts) + }) + .collect::>(); + let expected_excerpts = expected_files + .iter() + .map(|(path, texts)| { + ( + *path, + texts + .iter() + .map(|line| line.to_string()) + .collect::>(), + ) + }) + .collect::>(); + pretty_assertions::assert_eq!(actual_files, expected_excerpts) +} + +fn assert_definitions(definitions: &[LocationLink], first_lines: &[&str], cx: &mut TestAppContext) { + let actual_first_lines = definitions + .iter() + .map(|definition| { + definition.target.buffer.read_with(cx, |buffer, _| { + let mut start = definition.target.range.start.to_point(&buffer); + start.column = 0; + let end = Point::new(start.row, buffer.line_len(start.row)); + buffer + .text_for_range(start..end) + .collect::() + .trim() + .to_string() + }) + }) + .collect::>(); + + assert_eq!(actual_first_lines, first_lines); +} + +pub(crate) fn rust_lang() -> Arc { + Arc::new( + Language::new( + LanguageConfig { + name: "Rust".into(), + matcher: LanguageMatcher { + path_suffixes: vec!["rs".to_string()], + first_line_pattern: None, + }, + ..Default::default() + }, + Some(tree_sitter_rust::LANGUAGE.into()), + ) + .with_highlights_query(include_str!("../../languages/src/rust/highlights.scm")) + .unwrap() + .with_outline_query(include_str!("../../languages/src/rust/outline.scm")) + .unwrap(), + ) +} diff --git a/crates/edit_prediction_context2/src/fake_definition_lsp.rs b/crates/edit_prediction_context2/src/fake_definition_lsp.rs new file mode 100644 index 0000000000000000000000000000000000000000..31fb681309c610a37c7f886390ef5adb92ee78ef --- /dev/null +++ b/crates/edit_prediction_context2/src/fake_definition_lsp.rs @@ -0,0 +1,329 @@ +use collections::HashMap; +use futures::channel::mpsc::UnboundedReceiver; +use language::{Language, LanguageRegistry}; +use lsp::{ + FakeLanguageServer, LanguageServerBinary, TextDocumentSyncCapability, TextDocumentSyncKind, Uri, +}; +use parking_lot::Mutex; +use project::Fs; +use std::{ops::Range, path::PathBuf, sync::Arc}; +use tree_sitter::{Parser, QueryCursor, StreamingIterator, Tree}; + +/// Registers a fake language server that implements go-to-definition using tree-sitter, +/// making the assumption that all names are unique, and all variables' types are +/// explicitly declared. +pub fn register_fake_definition_server( + language_registry: &Arc, + language: Arc, + fs: Arc, +) -> UnboundedReceiver { + let index = Arc::new(Mutex::new(DefinitionIndex::new(language.clone()))); + + language_registry.register_fake_lsp( + language.name(), + language::FakeLspAdapter { + name: "fake-definition-lsp", + initialization_options: None, + prettier_plugins: Vec::new(), + disk_based_diagnostics_progress_token: None, + disk_based_diagnostics_sources: Vec::new(), + language_server_binary: LanguageServerBinary { + path: PathBuf::from("fake-definition-lsp"), + arguments: Vec::new(), + env: None, + }, + capabilities: lsp::ServerCapabilities { + definition_provider: Some(lsp::OneOf::Left(true)), + text_document_sync: Some(TextDocumentSyncCapability::Kind( + TextDocumentSyncKind::FULL, + )), + ..Default::default() + }, + label_for_completion: None, + initializer: Some(Box::new({ + move |server| { + server.handle_notification::({ + let index = index.clone(); + move |params, _cx| { + index + .lock() + .open_buffer(params.text_document.uri, ¶ms.text_document.text); + } + }); + + server.handle_notification::({ + let index = index.clone(); + let fs = fs.clone(); + move |params, cx| { + let uri = params.text_document.uri; + let path = uri.to_file_path().ok(); + index.lock().mark_buffer_closed(&uri); + + if let Some(path) = path { + let index = index.clone(); + let fs = fs.clone(); + cx.spawn(async move |_cx| { + if let Ok(content) = fs.load(&path).await { + index.lock().index_file(uri, &content); + } + }) + .detach(); + } + } + }); + + server.handle_notification::({ + let index = index.clone(); + let fs = fs.clone(); + move |params, cx| { + let index = index.clone(); + let fs = fs.clone(); + cx.spawn(async move |_cx| { + for event in params.changes { + if index.lock().is_buffer_open(&event.uri) { + continue; + } + + match event.typ { + lsp::FileChangeType::DELETED => { + index.lock().remove_definitions_for_file(&event.uri); + } + lsp::FileChangeType::CREATED + | lsp::FileChangeType::CHANGED => { + if let Some(path) = event.uri.to_file_path().ok() { + if let Ok(content) = fs.load(&path).await { + index.lock().index_file(event.uri, &content); + } + } + } + _ => {} + } + } + }) + .detach(); + } + }); + + server.handle_notification::({ + let index = index.clone(); + move |params, _cx| { + if let Some(change) = params.content_changes.into_iter().last() { + index + .lock() + .index_file(params.text_document.uri, &change.text); + } + } + }); + + server.handle_notification::( + { + let index = index.clone(); + let fs = fs.clone(); + move |params, cx| { + let index = index.clone(); + let fs = fs.clone(); + let files = fs.as_fake().files(); + cx.spawn(async move |_cx| { + for folder in params.event.added { + let Ok(path) = folder.uri.to_file_path() else { + continue; + }; + for file in &files { + if let Some(uri) = Uri::from_file_path(&file).ok() + && file.starts_with(&path) + && let Ok(content) = fs.load(&file).await + { + index.lock().index_file(uri, &content); + } + } + } + }) + .detach(); + } + }, + ); + + server.set_request_handler::({ + let index = index.clone(); + move |params, _cx| { + let result = index.lock().get_definitions( + params.text_document_position_params.text_document.uri, + params.text_document_position_params.position, + ); + async move { Ok(result) } + } + }); + } + })), + }, + ) +} + +struct DefinitionIndex { + language: Arc, + definitions: HashMap>, + files: HashMap, +} + +#[derive(Debug)] +struct FileEntry { + contents: String, + is_open_in_buffer: bool, +} + +impl DefinitionIndex { + fn new(language: Arc) -> Self { + Self { + language, + definitions: HashMap::default(), + files: HashMap::default(), + } + } + + fn remove_definitions_for_file(&mut self, uri: &Uri) { + self.definitions.retain(|_, locations| { + locations.retain(|loc| &loc.uri != uri); + !locations.is_empty() + }); + self.files.remove(uri); + } + + fn open_buffer(&mut self, uri: Uri, content: &str) { + self.index_file_inner(uri, content, true); + } + + fn mark_buffer_closed(&mut self, uri: &Uri) { + if let Some(entry) = self.files.get_mut(uri) { + entry.is_open_in_buffer = false; + } + } + + fn is_buffer_open(&self, uri: &Uri) -> bool { + self.files + .get(uri) + .map(|entry| entry.is_open_in_buffer) + .unwrap_or(false) + } + + fn index_file(&mut self, uri: Uri, content: &str) { + self.index_file_inner(uri, content, false); + } + + fn index_file_inner(&mut self, uri: Uri, content: &str, is_open_in_buffer: bool) -> Option<()> { + self.remove_definitions_for_file(&uri); + let grammar = self.language.grammar()?; + let outline_config = grammar.outline_config.as_ref()?; + let mut parser = Parser::new(); + parser.set_language(&grammar.ts_language).ok()?; + let tree = parser.parse(content, None)?; + let declarations = extract_declarations_from_tree(&tree, content, outline_config); + for (name, byte_range) in declarations { + let range = byte_range_to_lsp_range(content, byte_range); + let location = lsp::Location { + uri: uri.clone(), + range, + }; + self.definitions + .entry(name) + .or_insert_with(Vec::new) + .push(location); + } + self.files.insert( + uri, + FileEntry { + contents: content.to_string(), + is_open_in_buffer, + }, + ); + + Some(()) + } + + fn get_definitions( + &mut self, + uri: Uri, + position: lsp::Position, + ) -> Option { + let entry = self.files.get(&uri)?; + let name = word_at_position(&entry.contents, position)?; + let locations = self.definitions.get(name).cloned()?; + Some(lsp::GotoDefinitionResponse::Array(locations)) + } +} + +fn extract_declarations_from_tree( + tree: &Tree, + content: &str, + outline_config: &language::OutlineConfig, +) -> Vec<(String, Range)> { + let mut cursor = QueryCursor::new(); + let mut declarations = Vec::new(); + let mut matches = cursor.matches(&outline_config.query, tree.root_node(), content.as_bytes()); + while let Some(query_match) = matches.next() { + let mut name_range: Option> = None; + let mut has_item_range = false; + + for capture in query_match.captures { + let range = capture.node.byte_range(); + if capture.index == outline_config.name_capture_ix { + name_range = Some(range); + } else if capture.index == outline_config.item_capture_ix { + has_item_range = true; + } + } + + if let Some(name_range) = name_range + && has_item_range + { + let name = content[name_range.clone()].to_string(); + if declarations.iter().any(|(n, _)| n == &name) { + continue; + } + declarations.push((name, name_range)); + } + } + declarations +} + +fn byte_range_to_lsp_range(content: &str, byte_range: Range) -> lsp::Range { + let start = byte_offset_to_position(content, byte_range.start); + let end = byte_offset_to_position(content, byte_range.end); + lsp::Range { start, end } +} + +fn byte_offset_to_position(content: &str, offset: usize) -> lsp::Position { + let mut line = 0; + let mut character = 0; + let mut current_offset = 0; + for ch in content.chars() { + if current_offset >= offset { + break; + } + if ch == '\n' { + line += 1; + character = 0; + } else { + character += 1; + } + current_offset += ch.len_utf8(); + } + lsp::Position { line, character } +} + +fn word_at_position(content: &str, position: lsp::Position) -> Option<&str> { + let mut lines = content.lines(); + let line = lines.nth(position.line as usize)?; + let column = position.character as usize; + if column > line.len() { + return None; + } + let start = line[..column] + .rfind(|c: char| !c.is_alphanumeric() && c != '_') + .map(|i| i + 1) + .unwrap_or(0); + let end = line[column..] + .find(|c: char| !c.is_alphanumeric() && c != '_') + .map(|i| i + column) + .unwrap_or(line.len()); + Some(&line[start..end]).filter(|word| !word.is_empty()) +} diff --git a/crates/extension_host/src/extension_store_test.rs b/crates/extension_host/src/extension_store_test.rs index 85a3a720ce8c62fc4317756ec264926c981864c4..6d3aadeb5ac498b3948d871a0a87f7ecf49b6bd8 100644 --- a/crates/extension_host/src/extension_store_test.rs +++ b/crates/extension_host/src/extension_store_test.rs @@ -705,7 +705,7 @@ async fn test_extension_store_with_test_extension(cx: &mut TestAppContext) { .await .unwrap(); - let mut fake_servers = language_registry.register_fake_language_server( + let mut fake_servers = language_registry.register_fake_lsp_server( LanguageServerName("gleam".into()), lsp::ServerCapabilities { completion_provider: Some(Default::default()), diff --git a/crates/language/src/buffer.rs b/crates/language/src/buffer.rs index a46f7cc35912d4c6da42ba69f7aee6d25caca2e7..7166a01ef64bff9e47c70cac47910f714ae2dc39 100644 --- a/crates/language/src/buffer.rs +++ b/crates/language/src/buffer.rs @@ -4022,6 +4022,20 @@ impl BufferSnapshot { }) } + pub fn outline_items_as_offsets_containing( + &self, + range: Range, + include_extra_context: bool, + theme: Option<&SyntaxTheme>, + ) -> Vec> { + self.outline_items_containing_internal( + range, + include_extra_context, + theme, + |buffer, range| range.to_offset(buffer), + ) + } + fn outline_items_containing_internal( &self, range: Range, diff --git a/crates/language/src/buffer_tests.rs b/crates/language/src/buffer_tests.rs index efef0a08127bc66f9c6d8f21fe5a545dbee20fb1..e95bc544a56ecf9d561936ca48b10ccffcb23e72 100644 --- a/crates/language/src/buffer_tests.rs +++ b/crates/language/src/buffer_tests.rs @@ -784,28 +784,48 @@ async fn test_outline(cx: &mut gpui::TestAppContext) { .unindent(); let buffer = cx.new(|cx| Buffer::local(text, cx).with_language(Arc::new(rust_lang()), cx)); - let outline = buffer.update(cx, |buffer, _| buffer.snapshot().outline(None)); + let snapshot = buffer.update(cx, |buffer, _| buffer.snapshot()); + let outline = snapshot.outline(None); - assert_eq!( + pretty_assertions::assert_eq!( outline .items .iter() - .map(|item| (item.text.as_str(), item.depth)) + .map(|item| ( + item.text.as_str(), + item.depth, + item.to_point(&snapshot).body_range(&snapshot) + .map(|range| minimize_space(&snapshot.text_for_range(range).collect::())) + )) .collect::>(), &[ - ("struct Person", 0), - ("name", 1), - ("age", 1), - ("mod module", 0), - ("enum LoginState", 1), - ("LoggedOut", 2), - ("LoggingOn", 2), - ("LoggedIn", 2), - ("person", 3), - ("time", 3), - ("impl Eq for Person", 0), - ("impl Drop for Person", 0), - ("fn drop", 1), + ("struct Person", 0, Some("name: String, age: usize,".to_string())), + ("name", 1, None), + ("age", 1, None), + ( + "mod module", + 0, + Some( + "enum LoginState { LoggedOut, LoggingOn, LoggedIn { person: Person, time: Instant, } }".to_string() + ) + ), + ( + "enum LoginState", + 1, + Some("LoggedOut, LoggingOn, LoggedIn { person: Person, time: Instant, }".to_string()) + ), + ("LoggedOut", 2, None), + ("LoggingOn", 2, None), + ("LoggedIn", 2, Some("person: Person, time: Instant,".to_string())), + ("person", 3, None), + ("time", 3, None), + ("impl Eq for Person", 0, None), + ( + "impl Drop for Person", + 0, + Some("fn drop(&mut self) { println!(\"bye\"); }".to_string()) + ), + ("fn drop", 1, Some("println!(\"bye\");".to_string())), ] ); @@ -840,6 +860,11 @@ async fn test_outline(cx: &mut gpui::TestAppContext) { ] ); + fn minimize_space(text: &str) -> String { + static WHITESPACE: LazyLock = LazyLock::new(|| Regex::new("[\\n\\s]+").unwrap()); + WHITESPACE.replace_all(text, " ").trim().to_string() + } + async fn search<'a>( outline: &'a Outline, query: &'a str, diff --git a/crates/language/src/language_registry.rs b/crates/language/src/language_registry.rs index 022eb89e6d2b378b8c4305c81887060d776bb411..a0b04efd1b1366a101812d8656965637c13769a5 100644 --- a/crates/language/src/language_registry.rs +++ b/crates/language/src/language_registry.rs @@ -437,26 +437,14 @@ impl LanguageRegistry { language_name: impl Into, mut adapter: crate::FakeLspAdapter, ) -> futures::channel::mpsc::UnboundedReceiver { - let language_name = language_name.into(); let adapter_name = LanguageServerName(adapter.name.into()); let capabilities = adapter.capabilities.clone(); let initializer = adapter.initializer.take(); - let adapter = CachedLspAdapter::new(Arc::new(adapter)); - { - let mut state = self.state.write(); - state - .lsp_adapters - .entry(language_name) - .or_default() - .push(adapter.clone()); - state.all_lsp_adapters.insert(adapter.name(), adapter); - } - - self.register_fake_language_server(adapter_name, capabilities, initializer) + self.register_fake_lsp_adapter(language_name, adapter); + self.register_fake_lsp_server(adapter_name, capabilities, initializer) } /// Register a fake lsp adapter (without the language server) - /// The returned channel receives a new instance of the language server every time it is started #[cfg(any(feature = "test-support", test))] pub fn register_fake_lsp_adapter( &self, @@ -479,7 +467,7 @@ impl LanguageRegistry { /// Register a fake language server (without the adapter) /// The returned channel receives a new instance of the language server every time it is started #[cfg(any(feature = "test-support", test))] - pub fn register_fake_language_server( + pub fn register_fake_lsp_server( &self, lsp_name: LanguageServerName, capabilities: lsp::ServerCapabilities, diff --git a/crates/language/src/language_settings.rs b/crates/language/src/language_settings.rs index 3bf4e35c6b5cfd7f2a1f221bde4cec181998ab6a..068f8e1aa39ca3422fda8eb5706c00de6f2f62ce 100644 --- a/crates/language/src/language_settings.rs +++ b/crates/language/src/language_settings.rs @@ -373,6 +373,8 @@ impl InlayHintSettings { pub struct EditPredictionSettings { /// The provider that supplies edit predictions. pub provider: settings::EditPredictionProvider, + /// Whether to use the experimental edit prediction context retrieval system. + pub use_context: bool, /// A list of globs representing files that edit predictions should be disabled for. /// This list adds to a pre-existing, sensible default set of globs. /// Any additional ones you add are combined with them. @@ -622,6 +624,11 @@ impl settings::Settings for AllLanguageSettings { .features .as_ref() .and_then(|f| f.edit_prediction_provider); + let use_edit_prediction_context = all_languages + .features + .as_ref() + .and_then(|f| f.experimental_edit_prediction_context_retrieval) + .unwrap_or_default(); let edit_predictions = all_languages.edit_predictions.clone().unwrap(); let edit_predictions_mode = edit_predictions.mode.unwrap(); @@ -668,6 +675,7 @@ impl settings::Settings for AllLanguageSettings { } else { EditPredictionProvider::None }, + use_context: use_edit_prediction_context, disabled_globs: disabled_globs .iter() .filter_map(|g| { diff --git a/crates/language/src/outline.rs b/crates/language/src/outline.rs index 2ce2b42734465a4710a7439f5e2225debc96b04a..875042bfc83ae42fb580ab848029902d68988511 100644 --- a/crates/language/src/outline.rs +++ b/crates/language/src/outline.rs @@ -1,4 +1,4 @@ -use crate::{BufferSnapshot, Point, ToPoint}; +use crate::{BufferSnapshot, Point, ToPoint, ToTreeSitterPoint}; use fuzzy::{StringMatch, StringMatchCandidate}; use gpui::{BackgroundExecutor, HighlightStyle}; use std::ops::Range; @@ -48,6 +48,54 @@ impl OutlineItem { .map(|r| r.start.to_point(buffer)..r.end.to_point(buffer)), } } + + pub fn body_range(&self, buffer: &BufferSnapshot) -> Option> { + if let Some(range) = self.body_range.as_ref() { + return Some(range.start.to_point(buffer)..range.end.to_point(buffer)); + } + + let range = self.range.start.to_point(buffer)..self.range.end.to_point(buffer); + let start_indent = buffer.indent_size_for_line(range.start.row); + let node = buffer.syntax_ancestor(range.clone())?; + + let mut cursor = node.walk(); + loop { + let node = cursor.node(); + if node.start_position() >= range.start.to_ts_point() + && node.end_position() <= range.end.to_ts_point() + { + break; + } + cursor.goto_first_child_for_point(range.start.to_ts_point()); + } + + if !cursor.goto_last_child() { + return None; + } + let body_node = loop { + let node = cursor.node(); + if node.child_count() > 0 { + break node; + } + if !cursor.goto_previous_sibling() { + return None; + } + }; + + let mut start_row = body_node.start_position().row as u32; + let mut end_row = body_node.end_position().row as u32; + + while start_row < end_row && buffer.indent_size_for_line(start_row) == start_indent { + start_row += 1; + } + while start_row < end_row && buffer.indent_size_for_line(end_row - 1) == start_indent { + end_row -= 1; + } + if start_row < end_row { + return Some(Point::new(start_row, 0)..Point::new(end_row, 0)); + } + None + } } impl Outline { diff --git a/crates/language/src/syntax_map.rs b/crates/language/src/syntax_map.rs index 8574d52ff900563ddfb733c09204caab5eb6ae44..17285ca315fb64dd518d00039d28266c0a7f51ab 100644 --- a/crates/language/src/syntax_map.rs +++ b/crates/language/src/syntax_map.rs @@ -1215,6 +1215,19 @@ impl<'a> SyntaxMapMatches<'a> { true } + + // pub fn set_byte_range(&mut self, range: Range) { + // for layer in &mut self.layers { + // layer.matches.set_byte_range(range.clone()); + // layer.advance(); + // } + // self.layers.sort_unstable_by_key(|layer| layer.sort_key()); + // self.active_layer_count = self + // .layers + // .iter() + // .position(|layer| !layer.has_next) + // .unwrap_or(self.layers.len()); + // } } impl SyntaxMapCapturesLayer<'_> { diff --git a/crates/remote_server/src/remote_editing_tests.rs b/crates/remote_server/src/remote_editing_tests.rs index 1e6ecddb5f2599a0ded0180f3afd3df0f197f037..a91d1d055d582eb2f2de4883314ad5984238103a 100644 --- a/crates/remote_server/src/remote_editing_tests.rs +++ b/crates/remote_server/src/remote_editing_tests.rs @@ -452,7 +452,7 @@ async fn test_remote_lsp(cx: &mut TestAppContext, server_cx: &mut TestAppContext }); let mut fake_lsp = server_cx.update(|cx| { - headless.read(cx).languages.register_fake_language_server( + headless.read(cx).languages.register_fake_lsp_server( LanguageServerName("rust-analyzer".into()), lsp::ServerCapabilities { completion_provider: Some(lsp::CompletionOptions::default()), @@ -476,7 +476,7 @@ async fn test_remote_lsp(cx: &mut TestAppContext, server_cx: &mut TestAppContext ..FakeLspAdapter::default() }, ); - headless.read(cx).languages.register_fake_language_server( + headless.read(cx).languages.register_fake_lsp_server( LanguageServerName("fake-analyzer".into()), lsp::ServerCapabilities { completion_provider: Some(lsp::CompletionOptions::default()), @@ -669,7 +669,7 @@ async fn test_remote_cancel_language_server_work( }); let mut fake_lsp = server_cx.update(|cx| { - headless.read(cx).languages.register_fake_language_server( + headless.read(cx).languages.register_fake_lsp_server( LanguageServerName("rust-analyzer".into()), Default::default(), None, diff --git a/crates/settings/src/settings_content/language.rs b/crates/settings/src/settings_content/language.rs index 6b8a372269d44935e20426a0b669fed96a33dadf..b466b4e0dd88bf41e0f77f67a38842305c11906f 100644 --- a/crates/settings/src/settings_content/language.rs +++ b/crates/settings/src/settings_content/language.rs @@ -62,6 +62,8 @@ impl merge_from::MergeFrom for AllLanguageSettingsContent { pub struct FeaturesContent { /// Determines which edit prediction provider to use. pub edit_prediction_provider: Option, + /// Enables the experimental edit prediction context retrieval system. + pub experimental_edit_prediction_context_retrieval: Option, } /// The provider that supplies edit predictions. diff --git a/crates/text/src/anchor.rs b/crates/text/src/anchor.rs index c6d47a1e233b2fdf58fbc73adb622fc801832335..bf660b1302466e2b244a86b3d1e58ea2b6991067 100644 --- a/crates/text/src/anchor.rs +++ b/crates/text/src/anchor.rs @@ -8,10 +8,14 @@ use sum_tree::{Bias, Dimensions}; /// A timestamped position in a buffer #[derive(Copy, Clone, Eq, PartialEq, Hash)] pub struct Anchor { + /// The timestamp of the operation that inserted the text + /// in which this anchor is located. pub timestamp: clock::Lamport, - /// The byte offset in the buffer + /// The byte offset into the text inserted in the operation + /// at `timestamp`. pub offset: usize, - /// Describes which character the anchor is biased towards + /// Whether this anchor stays attached to the character *before* or *after* + /// the offset. pub bias: Bias, pub buffer_id: Option, } diff --git a/crates/ui/src/components/data_table.rs b/crates/ui/src/components/data_table.rs index f7cce2b85ffa3aeb9f97634c6c0fa65c46f4a8e7..9cd2a5cb7a0d802d170fcfbe6a812027c779d942 100644 --- a/crates/ui/src/components/data_table.rs +++ b/crates/ui/src/components/data_table.rs @@ -485,6 +485,7 @@ pub struct Table { interaction_state: Option>, col_widths: Option>, map_row: Option), &mut Window, &mut App) -> AnyElement>>, + use_ui_font: bool, empty_table_callback: Option AnyElement>>, } @@ -498,6 +499,7 @@ impl Table { rows: TableContents::Vec(Vec::new()), interaction_state: None, map_row: None, + use_ui_font: true, empty_table_callback: None, col_widths: None, } @@ -590,6 +592,11 @@ impl Table { self } + pub fn no_ui_font(mut self) -> Self { + self.use_ui_font = false; + self + } + pub fn map_row( mut self, callback: impl Fn((usize, Stateful

), &mut Window, &mut App) -> AnyElement + 'static, @@ -618,8 +625,8 @@ fn base_cell_style(width: Option) -> Div { .overflow_hidden() } -fn base_cell_style_text(width: Option, cx: &App) -> Div { - base_cell_style(width).text_ui(cx) +fn base_cell_style_text(width: Option, use_ui_font: bool, cx: &App) -> Div { + base_cell_style(width).when(use_ui_font, |el| el.text_ui(cx)) } pub fn render_table_row( @@ -656,7 +663,12 @@ pub fn render_table_row( .map(IntoElement::into_any_element) .into_iter() .zip(column_widths) - .map(|(cell, width)| base_cell_style_text(width, cx).px_1().py_0p5().child(cell)), + .map(|(cell, width)| { + base_cell_style_text(width, table_context.use_ui_font, cx) + .px_1() + .py_0p5() + .child(cell) + }), ); let row = if let Some(map_row) = table_context.map_row { @@ -700,7 +712,7 @@ pub fn render_table_header( .border_color(cx.theme().colors().border) .children(headers.into_iter().enumerate().zip(column_widths).map( |((header_idx, h), width)| { - base_cell_style_text(width, cx) + base_cell_style_text(width, table_context.use_ui_font, cx) .child(h) .id(ElementId::NamedInteger( shared_element_id.clone(), @@ -739,6 +751,7 @@ pub struct TableRenderContext { pub total_row_count: usize, pub column_widths: Option<[Length; COLS]>, pub map_row: Option), &mut Window, &mut App) -> AnyElement>>, + pub use_ui_font: bool, } impl TableRenderContext { @@ -748,6 +761,7 @@ impl TableRenderContext { total_row_count: table.rows.len(), column_widths: table.col_widths.as_ref().map(|widths| widths.lengths(cx)), map_row: table.map_row.clone(), + use_ui_font: table.use_ui_font, } } } diff --git a/crates/zeta/Cargo.toml b/crates/zeta/Cargo.toml index 7429fcb8e8d5e4b485f69ea87c37d7d670c3b199..b90934e67c2a689e1f7bb9704ff28a408de3049a 100644 --- a/crates/zeta/Cargo.toml +++ b/crates/zeta/Cargo.toml @@ -30,6 +30,7 @@ credentials_provider.workspace = true db.workspace = true edit_prediction.workspace = true edit_prediction_context.workspace = true +edit_prediction_context2.workspace = true editor.workspace = true feature_flags.workspace = true fs.workspace = true diff --git a/crates/zeta/src/assemble_excerpts.rs b/crates/zeta/src/assemble_excerpts.rs deleted file mode 100644 index f2a5b5adb1fcffab945cd9bdb88153bc5e494138..0000000000000000000000000000000000000000 --- a/crates/zeta/src/assemble_excerpts.rs +++ /dev/null @@ -1,173 +0,0 @@ -use cloud_llm_client::predict_edits_v3::Excerpt; -use edit_prediction_context::Line; -use language::{BufferSnapshot, Point}; -use std::ops::Range; - -pub fn assemble_excerpts( - buffer: &BufferSnapshot, - merged_line_ranges: impl IntoIterator>, -) -> Vec { - let mut output = Vec::new(); - - let outline_items = buffer.outline_items_as_points_containing(0..buffer.len(), false, None); - let mut outline_items = outline_items.into_iter().peekable(); - - for range in merged_line_ranges { - let point_range = Point::new(range.start.0, 0)..Point::new(range.end.0, 0); - - while let Some(outline_item) = outline_items.peek() { - if outline_item.range.start >= point_range.start { - break; - } - if outline_item.range.end > point_range.start { - let mut point_range = outline_item.source_range_for_text.clone(); - point_range.start.column = 0; - point_range.end.column = buffer.line_len(point_range.end.row); - - output.push(Excerpt { - start_line: Line(point_range.start.row), - text: buffer - .text_for_range(point_range.clone()) - .collect::() - .into(), - }) - } - outline_items.next(); - } - - output.push(Excerpt { - start_line: Line(point_range.start.row), - text: buffer - .text_for_range(point_range.clone()) - .collect::() - .into(), - }) - } - - output -} - -#[cfg(test)] -mod tests { - use std::sync::Arc; - - use super::*; - use cloud_llm_client::predict_edits_v3; - use gpui::{TestAppContext, prelude::*}; - use indoc::indoc; - use language::{Buffer, Language, LanguageConfig, LanguageMatcher, OffsetRangeExt}; - use pretty_assertions::assert_eq; - use util::test::marked_text_ranges; - - #[gpui::test] - fn test_rust(cx: &mut TestAppContext) { - let table = [ - ( - indoc! {r#" - struct User { - first_name: String, - « last_name: String, - ageˇ: u32, - » email: String, - create_at: Instant, - } - - impl User { - pub fn first_name(&self) -> String { - self.first_name.clone() - } - - pub fn full_name(&self) -> String { - « format!("{} {}", self.first_name, self.last_name) - » } - } - "#}, - indoc! {r#" - 1|struct User { - … - 3| last_name: String, - 4| age<|cursor|>: u32, - … - 9|impl User { - … - 14| pub fn full_name(&self) -> String { - 15| format!("{} {}", self.first_name, self.last_name) - … - "#}, - ), - ( - indoc! {r#" - struct User { - first_name: String, - « last_name: String, - age: u32, - } - »"# - }, - indoc! {r#" - 1|struct User { - … - 3| last_name: String, - 4| age: u32, - 5|} - "#}, - ), - ]; - - for (input, expected_output) in table { - let input_without_ranges = input.replace(['«', '»'], ""); - let input_without_caret = input.replace('ˇ', ""); - let cursor_offset = input_without_ranges.find('ˇ'); - let (input, ranges) = marked_text_ranges(&input_without_caret, false); - let buffer = - cx.new(|cx| Buffer::local(input, cx).with_language(Arc::new(rust_lang()), cx)); - buffer.read_with(cx, |buffer, _cx| { - let insertions = cursor_offset - .map(|offset| { - let point = buffer.offset_to_point(offset); - vec![( - predict_edits_v3::Point { - line: Line(point.row), - column: point.column, - }, - "<|cursor|>", - )] - }) - .unwrap_or_default(); - let ranges: Vec> = ranges - .into_iter() - .map(|range| { - let point_range = range.to_point(&buffer); - Line(point_range.start.row)..Line(point_range.end.row) - }) - .collect(); - - let mut output = String::new(); - cloud_zeta2_prompt::write_excerpts( - assemble_excerpts(&buffer.snapshot(), ranges).iter(), - &insertions, - Line(buffer.max_point().row), - true, - &mut output, - ); - assert_eq!(output, expected_output); - }); - } - } - - fn rust_lang() -> Language { - Language::new( - LanguageConfig { - name: "Rust".into(), - matcher: LanguageMatcher { - path_suffixes: vec!["rs".to_string()], - ..Default::default() - }, - ..Default::default() - }, - Some(language::tree_sitter_rust::LANGUAGE.into()), - ) - .with_outline_query(include_str!("../../languages/src/rust/outline.scm")) - .unwrap() - } -} diff --git a/crates/zeta/src/retrieval_search.rs b/crates/zeta/src/retrieval_search.rs index bcc0233ff7e872a151ecddf2cf55a3cb434f02b3..f429f167744422c3641b5a68ca662af48c8e1614 100644 --- a/crates/zeta/src/retrieval_search.rs +++ b/crates/zeta/src/retrieval_search.rs @@ -1,6 +1,7 @@ use anyhow::Result; use cloud_zeta2_prompt::retrieval_prompt::SearchToolQuery; use collections::HashMap; +use edit_prediction_context2::{RelatedExcerpt, RelatedFile}; use futures::{ StreamExt, channel::mpsc::{self, UnboundedSender}, @@ -8,7 +9,7 @@ use futures::{ use gpui::{AppContext, AsyncApp, Entity}; use language::{Anchor, Buffer, BufferSnapshot, OffsetRangeExt, Point, ToOffset, ToPoint}; use project::{ - Project, WorktreeSettings, + Project, ProjectPath, WorktreeSettings, search::{SearchQuery, SearchResult}, }; use smol::channel; @@ -20,14 +21,14 @@ use util::{ use workspace::item::Settings as _; #[cfg(feature = "eval-support")] -type CachedSearchResults = std::collections::BTreeMap>>; +type CachedSearchResults = std::collections::BTreeMap>>; pub async fn run_retrieval_searches( queries: Vec, project: Entity, #[cfg(feature = "eval-support")] eval_cache: Option>, cx: &mut AsyncApp, -) -> Result, Vec>>> { +) -> Result> { #[cfg(feature = "eval-support")] let cache = if let Some(eval_cache) = eval_cache { use crate::EvalCacheEntryKind; @@ -54,24 +55,44 @@ pub async fn run_retrieval_searches( if let Some(cached_results) = eval_cache.read(key) { let file_results = serde_json::from_str::(&cached_results) .context("Failed to deserialize cached search results")?; - let mut results = HashMap::default(); + let mut results = Vec::new(); for (path, ranges) in file_results { + let project_path = project.update(cx, |project, cx| { + project.find_project_path(path, cx).unwrap() + })?; let buffer = project .update(cx, |project, cx| { - let project_path = project.find_project_path(path, cx).unwrap(); - project.open_buffer(project_path, cx) + project.open_buffer(project_path.clone(), cx) })? .await?; let snapshot = buffer.read_with(cx, |buffer, _| buffer.snapshot())?; let mut ranges: Vec<_> = ranges .into_iter() - .map(|range| { - snapshot.anchor_before(range.start)..snapshot.anchor_after(range.end) - }) + .map( + |Range { + start: (start_row, start_col), + end: (end_row, end_col), + }| { + snapshot.anchor_before(Point::new(start_row, start_col)) + ..snapshot.anchor_after(Point::new(end_row, end_col)) + }, + ) .collect(); merge_anchor_ranges(&mut ranges, &snapshot); - results.insert(buffer, ranges); + results.push(RelatedFile { + path: project_path, + buffer: buffer.downgrade(), + excerpts: ranges + .into_iter() + .map(|range| RelatedExcerpt { + point_range: range.to_point(&snapshot), + text: snapshot.as_rope().slice(range.to_offset(&snapshot)), + anchor_range: range, + }) + .collect(), + max_row: snapshot.max_point().row, + }); } return Ok(results); @@ -117,14 +138,29 @@ pub async fn run_retrieval_searches( #[cfg(feature = "eval-support")] let cache = cache.clone(); cx.background_spawn(async move { - let mut results: HashMap, Vec>> = HashMap::default(); + let mut results: Vec = Vec::default(); let mut snapshots = HashMap::default(); let mut total_bytes = 0; - 'outer: while let Some((buffer, snapshot, excerpts)) = results_rx.next().await { - snapshots.insert(buffer.entity_id(), snapshot); - let existing = results.entry(buffer).or_default(); - existing.reserve(excerpts.len()); + 'outer: while let Some((project_path, buffer, snapshot, excerpts)) = results_rx.next().await + { + let existing = results + .iter_mut() + .find(|related_file| related_file.buffer.entity_id() == buffer.entity_id()); + let existing = match existing { + Some(existing) => existing, + None => { + results.push(RelatedFile { + path: project_path, + buffer: buffer.downgrade(), + excerpts: Vec::new(), + max_row: snapshot.max_point().row, + }); + results.last_mut().unwrap() + } + }; + // let existing = results.entry(buffer).or_default(); + existing.excerpts.reserve(excerpts.len()); for (range, size) in excerpts { // Blunt trimming of the results until we have a proper algorithmic filtering step @@ -133,24 +169,34 @@ pub async fn run_retrieval_searches( break 'outer; } total_bytes += size; - existing.push(range); + existing.excerpts.push(RelatedExcerpt { + point_range: range.to_point(&snapshot), + text: snapshot.as_rope().slice(range.to_offset(&snapshot)), + anchor_range: range, + }); } + snapshots.insert(buffer.entity_id(), snapshot); } #[cfg(feature = "eval-support")] if let Some((cache, queries, key)) = cache { let cached_results: CachedSearchResults = results .iter() - .filter_map(|(buffer, ranges)| { - let snapshot = snapshots.get(&buffer.entity_id())?; - let path = snapshot.file().map(|f| f.path()); - let mut ranges = ranges + .map(|related_file| { + let mut ranges = related_file + .excerpts .iter() - .map(|range| range.to_offset(&snapshot)) + .map( + |RelatedExcerpt { + point_range: Range { start, end }, + .. + }| { + (start.row, start.column)..(end.row, end.column) + }, + ) .collect::>(); ranges.sort_unstable_by_key(|range| (range.start, range.end)); - - Some((path?.as_std_path().to_path_buf(), ranges)) + (related_file.path.path.as_std_path().to_path_buf(), ranges) }) .collect(); cache.write( @@ -160,10 +206,8 @@ pub async fn run_retrieval_searches( ); } - for (buffer, ranges) in results.iter_mut() { - if let Some(snapshot) = snapshots.get(&buffer.entity_id()) { - merge_anchor_ranges(ranges, snapshot); - } + for related_file in results.iter_mut() { + related_file.merge_excerpts(); } Ok(results) @@ -171,6 +215,7 @@ pub async fn run_retrieval_searches( .await } +#[cfg(feature = "eval-support")] pub(crate) fn merge_anchor_ranges(ranges: &mut Vec>, snapshot: &BufferSnapshot) { ranges.sort_unstable_by(|a, b| { a.start @@ -201,6 +246,7 @@ const MAX_RESULTS_LEN: usize = MAX_EXCERPT_LEN * 5; struct SearchJob { buffer: Entity, snapshot: BufferSnapshot, + project_path: ProjectPath, ranges: Vec>, query_ix: usize, jobs_tx: channel::Sender, @@ -208,7 +254,12 @@ struct SearchJob { async fn run_query( input_query: SearchToolQuery, - results_tx: UnboundedSender<(Entity, BufferSnapshot, Vec<(Range, usize)>)>, + results_tx: UnboundedSender<( + ProjectPath, + Entity, + BufferSnapshot, + Vec<(Range, usize)>, + )>, path_style: PathStyle, exclude_matcher: PathMatcher, project: &Entity, @@ -257,12 +308,21 @@ async fn run_query( .read_with(cx, |buffer, _| buffer.parsing_idle())? .await; let snapshot = buffer.read_with(cx, |buffer, _cx| buffer.snapshot())?; + let Some(file) = snapshot.file() else { + continue; + }; + + let project_path = cx.update(|cx| ProjectPath { + worktree_id: file.worktree_id(cx), + path: file.path().clone(), + })?; let expanded_ranges: Vec<_> = ranges .into_iter() .filter_map(|range| expand_to_parent_range(&range, &snapshot)) .collect(); jobs_tx .send(SearchJob { + project_path, buffer, snapshot, ranges: expanded_ranges, @@ -301,6 +361,13 @@ async fn run_query( while let Some(SearchResult::Buffer { buffer, ranges }) = results_rx.next().await { let snapshot = buffer.read_with(cx, |buffer, _cx| buffer.snapshot())?; + let Some(file) = snapshot.file() else { + continue; + }; + let project_path = cx.update(|cx| ProjectPath { + worktree_id: file.worktree_id(cx), + path: file.path().clone(), + })?; let ranges = ranges .into_iter() @@ -314,7 +381,8 @@ async fn run_query( }) .collect(); - let send_result = results_tx.unbounded_send((buffer.clone(), snapshot.clone(), ranges)); + let send_result = + results_tx.unbounded_send((project_path, buffer.clone(), snapshot.clone(), ranges)); if let Err(err) = send_result && !err.is_disconnected() @@ -330,7 +398,12 @@ async fn run_query( } async fn process_nested_search_job( - results_tx: &UnboundedSender<(Entity, BufferSnapshot, Vec<(Range, usize)>)>, + results_tx: &UnboundedSender<( + ProjectPath, + Entity, + BufferSnapshot, + Vec<(Range, usize)>, + )>, queries: &Vec, content_query: &Option, job: SearchJob, @@ -347,6 +420,7 @@ async fn process_nested_search_job( } job.jobs_tx .send(SearchJob { + project_path: job.project_path, buffer: job.buffer, snapshot: job.snapshot, ranges: subranges, @@ -382,7 +456,8 @@ async fn process_nested_search_job( }) .collect(); - let send_result = results_tx.unbounded_send((job.buffer, job.snapshot, matches)); + let send_result = + results_tx.unbounded_send((job.project_path, job.buffer, job.snapshot, matches)); if let Err(err) = send_result && !err.is_disconnected() @@ -413,230 +488,3 @@ fn expand_to_parent_range( let node = snapshot.syntax_ancestor(line_range)?; Some(node.byte_range()) } - -#[cfg(test)] -mod tests { - use super::*; - use crate::assemble_excerpts::assemble_excerpts; - use cloud_zeta2_prompt::write_codeblock; - use edit_prediction_context::Line; - use gpui::TestAppContext; - use indoc::indoc; - use language::{Language, LanguageConfig, LanguageMatcher, tree_sitter_rust}; - use pretty_assertions::assert_eq; - use project::FakeFs; - use serde_json::json; - use settings::SettingsStore; - use std::path::Path; - use util::path; - - #[gpui::test] - async fn test_retrieval(cx: &mut TestAppContext) { - init_test(cx); - let fs = FakeFs::new(cx.executor()); - fs.insert_tree( - path!("/root"), - json!({ - "user.rs": indoc!{" - pub struct Organization { - owner: Arc, - } - - pub struct User { - first_name: String, - last_name: String, - } - - impl Organization { - pub fn owner(&self) -> Arc { - self.owner.clone() - } - } - - impl User { - pub fn new(first_name: String, last_name: String) -> Self { - Self { - first_name, - last_name - } - } - - pub fn first_name(&self) -> String { - self.first_name.clone() - } - - pub fn last_name(&self) -> String { - self.last_name.clone() - } - } - "}, - "main.rs": indoc!{r#" - fn main() { - let user = User::new(FIRST_NAME.clone(), "doe".into()); - println!("user {:?}", user); - } - "#}, - }), - ) - .await; - - let project = Project::test(fs, vec![Path::new(path!("/root"))], cx).await; - project.update(cx, |project, _cx| { - project.languages().add(rust_lang().into()) - }); - - assert_results( - &project, - SearchToolQuery { - glob: "user.rs".into(), - syntax_node: vec!["impl\\s+User".into(), "pub\\s+fn\\s+first_name".into()], - content: None, - }, - indoc! {r#" - `````root/user.rs - … - impl User { - … - pub fn first_name(&self) -> String { - self.first_name.clone() - } - … - ````` - "#}, - cx, - ) - .await; - - assert_results( - &project, - SearchToolQuery { - glob: "user.rs".into(), - syntax_node: vec!["impl\\s+User".into()], - content: Some("\\.clone".into()), - }, - indoc! {r#" - `````root/user.rs - … - impl User { - … - pub fn first_name(&self) -> String { - self.first_name.clone() - … - pub fn last_name(&self) -> String { - self.last_name.clone() - … - ````` - "#}, - cx, - ) - .await; - - assert_results( - &project, - SearchToolQuery { - glob: "*.rs".into(), - syntax_node: vec![], - content: Some("\\.clone".into()), - }, - indoc! {r#" - `````root/main.rs - fn main() { - let user = User::new(FIRST_NAME.clone(), "doe".into()); - … - ````` - - `````root/user.rs - … - impl Organization { - pub fn owner(&self) -> Arc { - self.owner.clone() - … - impl User { - … - pub fn first_name(&self) -> String { - self.first_name.clone() - … - pub fn last_name(&self) -> String { - self.last_name.clone() - … - ````` - "#}, - cx, - ) - .await; - } - - async fn assert_results( - project: &Entity, - query: SearchToolQuery, - expected_output: &str, - cx: &mut TestAppContext, - ) { - let results = run_retrieval_searches( - vec![query], - project.clone(), - #[cfg(feature = "eval-support")] - None, - &mut cx.to_async(), - ) - .await - .unwrap(); - - let mut results = results.into_iter().collect::>(); - results.sort_by_key(|results| { - results - .0 - .read_with(cx, |buffer, _| buffer.file().unwrap().path().clone()) - }); - - let mut output = String::new(); - for (buffer, ranges) in results { - buffer.read_with(cx, |buffer, cx| { - let excerpts = ranges.into_iter().map(|range| { - let point_range = range.to_point(buffer); - if point_range.end.column > 0 { - Line(point_range.start.row)..Line(point_range.end.row + 1) - } else { - Line(point_range.start.row)..Line(point_range.end.row) - } - }); - - write_codeblock( - &buffer.file().unwrap().full_path(cx), - assemble_excerpts(&buffer.snapshot(), excerpts).iter(), - &[], - Line(buffer.max_point().row), - false, - &mut output, - ); - }); - } - output.pop(); - - assert_eq!(output, expected_output); - } - - fn rust_lang() -> Language { - Language::new( - LanguageConfig { - name: "Rust".into(), - matcher: LanguageMatcher { - path_suffixes: vec!["rs".to_string()], - ..Default::default() - }, - ..Default::default() - }, - Some(tree_sitter_rust::LANGUAGE.into()), - ) - .with_outline_query(include_str!("../../languages/src/rust/outline.scm")) - .unwrap() - } - - fn init_test(cx: &mut TestAppContext) { - cx.update(move |cx| { - let settings_store = SettingsStore::test(cx); - cx.set_global(settings_store); - zlog::init_test(); - }); - } -} diff --git a/crates/zeta/src/sweep_ai.rs b/crates/zeta/src/sweep_ai.rs index 8fd5398f3facc807d99951c48c749e9247fb5670..0bc0d1d41e2393212f865e402912f6d760aa252e 100644 --- a/crates/zeta/src/sweep_ai.rs +++ b/crates/zeta/src/sweep_ai.rs @@ -1,6 +1,7 @@ use anyhow::{Context as _, Result}; use cloud_llm_client::predict_edits_v3::Event; use credentials_provider::CredentialsProvider; +use edit_prediction_context2::RelatedFile; use futures::{AsyncReadExt as _, FutureExt, future::Shared}; use gpui::{ App, AppContext as _, Entity, Task, @@ -49,6 +50,7 @@ impl SweepAi { position: language::Anchor, events: Vec>, recent_paths: &VecDeque, + related_files: Vec, diagnostic_search_range: Range, cx: &mut App, ) -> Task>> { @@ -120,6 +122,19 @@ impl SweepAi { }) .collect::>(); + let retrieval_chunks = related_files + .iter() + .flat_map(|related_file| { + related_file.excerpts.iter().map(|excerpt| FileChunk { + file_path: related_file.path.path.as_unix_str().to_string(), + start_line: excerpt.point_range.start.row as usize, + end_line: excerpt.point_range.end.row as usize, + content: excerpt.text.to_string(), + timestamp: None, + }) + }) + .collect(); + let diagnostic_entries = snapshot.diagnostics_in_range(diagnostic_search_range, false); let mut diagnostic_content = String::new(); let mut diagnostic_count = 0; @@ -168,7 +183,7 @@ impl SweepAi { multiple_suggestions: false, branch: None, file_chunks, - retrieval_chunks: vec![], + retrieval_chunks, recent_user_actions: vec![], use_bytes: true, // TODO @@ -320,7 +335,7 @@ struct AutocompleteRequest { pub cursor_position: usize, pub original_file_contents: String, pub file_chunks: Vec, - pub retrieval_chunks: Vec, + pub retrieval_chunks: Vec, pub recent_user_actions: Vec, pub multiple_suggestions: bool, pub privacy_mode_enabled: bool, @@ -337,15 +352,6 @@ struct FileChunk { pub timestamp: Option, } -#[derive(Debug, Clone, Serialize)] -struct RetrievalChunk { - pub file_path: String, - pub start_line: usize, - pub end_line: usize, - pub content: String, - pub timestamp: u64, -} - #[derive(Debug, Clone, Serialize)] struct UserAction { pub action_type: ActionType, diff --git a/crates/zeta/src/zeta.rs b/crates/zeta/src/zeta.rs index 33d37d9e3aa0c5c89830d5ec86663330da1daf77..576067b9844cd668c69411d7a4098975db4a5d26 100644 --- a/crates/zeta/src/zeta.rs +++ b/crates/zeta/src/zeta.rs @@ -1,7 +1,7 @@ use anyhow::{Context as _, Result, anyhow, bail}; use arrayvec::ArrayVec; use client::{Client, EditPredictionUsage, UserStore}; -use cloud_llm_client::predict_edits_v3::{self, Event, PromptFormat, Signature}; +use cloud_llm_client::predict_edits_v3::{self, Event, PromptFormat}; use cloud_llm_client::{ AcceptEditPredictionBody, EXPIRED_LLM_TOKEN_HEADER_NAME, EditPredictionRejectReason, EditPredictionRejection, MAX_EDIT_PREDICTION_REJECTIONS_PER_REQUEST, @@ -14,31 +14,39 @@ use collections::{HashMap, HashSet}; use command_palette_hooks::CommandPaletteFilter; use db::kvp::{Dismissable, KEY_VALUE_STORE}; use edit_prediction_context::{ - DeclarationId, DeclarationStyle, EditPredictionContext, EditPredictionContextOptions, - EditPredictionExcerpt, EditPredictionExcerptOptions, EditPredictionScoreOptions, Line, - SyntaxIndex, SyntaxIndexState, + EditPredictionContextOptions, EditPredictionExcerpt, EditPredictionExcerptOptions, + EditPredictionScoreOptions, Line, SyntaxIndex, +}; +use edit_prediction_context2::{ + RelatedExcerpt, RelatedExcerptStore, RelatedExcerptStoreEvent, RelatedFile, }; use feature_flags::{FeatureFlag, FeatureFlagAppExt as _, PredictEditsRateCompletionsFeatureFlag}; -use futures::channel::mpsc::UnboundedReceiver; -use futures::channel::{mpsc, oneshot}; -use futures::{AsyncReadExt as _, FutureExt as _, StreamExt as _, select_biased}; +use futures::{ + AsyncReadExt as _, FutureExt as _, StreamExt as _, + channel::{ + mpsc::{self, UnboundedReceiver}, + oneshot, + }, + select_biased, +}; use gpui::BackgroundExecutor; use gpui::{ App, AsyncApp, Entity, EntityId, Global, SharedString, Subscription, Task, WeakEntity, actions, http_client::{self, AsyncBody, Method}, prelude::*, }; +use language::language_settings::all_language_settings; use language::{ Anchor, Buffer, DiagnosticSet, File, LanguageServerId, Point, ToOffset as _, ToPoint, }; use language::{BufferSnapshot, OffsetRangeExt}; use language_model::{LlmApiToken, RefreshLlmTokenListener}; use open_ai::FunctionDefinition; -use project::{DisableAiSettings, Project, ProjectPath, WorktreeId}; +use project::{DisableAiSettings, Project, ProjectItem as _, ProjectPath, WorktreeId}; use release_channel::AppVersion; use semver::Version; use serde::de::DeserializeOwned; -use settings::{EditPredictionProvider, Settings as _, SettingsStore, update_settings_file}; +use settings::{EditPredictionProvider, Settings, SettingsStore, update_settings_file}; use std::any::{Any as _, TypeId}; use std::collections::{VecDeque, hash_map}; use telemetry_events::EditPredictionRating; @@ -52,11 +60,9 @@ use std::sync::{Arc, LazyLock}; use std::time::{Duration, Instant}; use std::{env, mem}; use thiserror::Error; -use util::rel_path::RelPathBuf; use util::{LogErrorFuture, RangeExt as _, ResultExt as _, TryFutureExt}; use workspace::notifications::{ErrorMessagePrompt, NotificationId, show_app_notification}; -pub mod assemble_excerpts; mod license_detection; mod onboarding_modal; mod prediction; @@ -71,7 +77,6 @@ pub mod zeta1; #[cfg(test)] mod zeta_tests; -use crate::assemble_excerpts::assemble_excerpts; use crate::license_detection::LicenseDetectionWatcher; use crate::onboarding_modal::ZedPredictModal; pub use crate::prediction::EditPrediction; @@ -115,8 +120,7 @@ pub const DEFAULT_EXCERPT_OPTIONS: EditPredictionExcerptOptions = EditPrediction target_before_cursor_over_total_bytes: 0.5, }; -pub const DEFAULT_CONTEXT_OPTIONS: ContextMode = - ContextMode::Agentic(DEFAULT_AGENTIC_CONTEXT_OPTIONS); +pub const DEFAULT_CONTEXT_OPTIONS: ContextMode = ContextMode::Lsp(DEFAULT_EXCERPT_OPTIONS); pub const DEFAULT_AGENTIC_CONTEXT_OPTIONS: AgenticContextOptions = AgenticContextOptions { excerpt: DEFAULT_EXCERPT_OPTIONS, @@ -190,6 +194,7 @@ pub struct Zeta { llm_token: LlmApiToken, _llm_token_subscription: Subscription, projects: HashMap, + use_context: bool, options: ZetaOptions, update_required: bool, debug_tx: Option>, @@ -225,6 +230,7 @@ pub struct ZetaOptions { pub enum ContextMode { Agentic(AgenticContextOptions), Syntax(EditPredictionContextOptions), + Lsp(EditPredictionExcerptOptions), } #[derive(Debug, Clone, PartialEq)] @@ -237,6 +243,7 @@ impl ContextMode { match self { ContextMode::Agentic(options) => &options.excerpt, ContextMode::Syntax(options) => &options.excerpt, + ContextMode::Lsp(options) => &options, } } } @@ -244,23 +251,22 @@ impl ContextMode { #[derive(Debug)] pub enum ZetaDebugInfo { ContextRetrievalStarted(ZetaContextRetrievalStartedDebugInfo), - SearchQueriesGenerated(ZetaSearchQueryDebugInfo), - SearchQueriesExecuted(ZetaContextRetrievalDebugInfo), - ContextRetrievalFinished(ZetaContextRetrievalDebugInfo), + ContextRetrievalFinished(ZetaContextRetrievalFinishedDebugInfo), EditPredictionRequested(ZetaEditPredictionDebugInfo), } #[derive(Debug)] pub struct ZetaContextRetrievalStartedDebugInfo { - pub project: Entity, + pub project_entity_id: EntityId, pub timestamp: Instant, pub search_prompt: String, } #[derive(Debug)] -pub struct ZetaContextRetrievalDebugInfo { - pub project: Entity, +pub struct ZetaContextRetrievalFinishedDebugInfo { + pub project_entity_id: EntityId, pub timestamp: Instant, + pub metadata: Vec<(&'static str, SharedString)>, } #[derive(Debug)] @@ -273,17 +279,9 @@ pub struct ZetaEditPredictionDebugInfo { pub response_rx: oneshot::Receiver<(Result, Duration)>, } -#[derive(Debug)] -pub struct ZetaSearchQueryDebugInfo { - pub project: Entity, - pub timestamp: Instant, - pub search_queries: Vec, -} - pub type RequestDebugInfo = predict_edits_v3::DebugInfo; struct ZetaProject { - syntax_index: Option>, events: VecDeque>, last_event: Option, recent_paths: VecDeque, @@ -291,16 +289,26 @@ struct ZetaProject { current_prediction: Option, next_pending_prediction_id: usize, pending_predictions: ArrayVec, + context_updates_tx: smol::channel::Sender<()>, + context_updates_rx: smol::channel::Receiver<()>, last_prediction_refresh: Option<(EntityId, Instant)>, cancelled_predictions: HashSet, - context: Option, Vec>>>, - refresh_context_task: Option>>>, - refresh_context_debounce_task: Option>>, - refresh_context_timestamp: Option, + context: ZetaProjectContext, license_detection_watchers: HashMap>, _subscription: gpui::Subscription, } +enum ZetaProjectContext { + Syntax(Entity), + Lsp(Entity), + Agentic { + refresh_context_task: Option>>>, + refresh_context_debounce_task: Option>>, + refresh_context_timestamp: Option, + context: Vec, + }, +} + impl ZetaProject { pub fn events(&self, cx: &App) -> Vec> { self.events @@ -521,11 +529,12 @@ impl Zeta { }) .detach(); - Self { + let mut this = Self { projects: HashMap::default(), client, user_store, options: DEFAULT_OPTIONS, + use_context: false, llm_token, _llm_token_subscription: cx.subscribe( &refresh_llm_token_listener, @@ -549,7 +558,22 @@ impl Zeta { reject_predictions_tx: reject_tx, rated_predictions: Default::default(), shown_predictions: Default::default(), - } + }; + + this.enable_or_disable_context_retrieval(cx); + let weak_this = cx.weak_entity(); + cx.on_flags_ready(move |_, cx| { + weak_this + .update(cx, |this, cx| this.enable_or_disable_context_retrieval(cx)) + .ok(); + }) + .detach(); + cx.observe_global::(|this, cx| { + this.enable_or_disable_context_retrieval(cx); + }) + .detach(); + + this } pub fn set_edit_prediction_model(&mut self, model: ZetaEditPredictionModel) { @@ -584,29 +608,29 @@ impl Zeta { self.options = options; } + pub fn set_use_context(&mut self, use_context: bool) { + self.use_context = use_context; + } + pub fn clear_history(&mut self) { for zeta_project in self.projects.values_mut() { zeta_project.events.clear(); } } - pub fn context_for_project( - &self, + pub fn context_for_project<'a>( + &'a self, project: &Entity, - ) -> impl Iterator, &[Range])> { + cx: &'a App, + ) -> &'a [RelatedFile] { self.projects .get(&project.entity_id()) - .and_then(|project| { - Some( - project - .context - .as_ref()? - .iter() - .map(|(buffer, ranges)| (buffer.clone(), ranges.as_slice())), - ) + .and_then(|project| match &project.context { + ZetaProjectContext::Syntax(_) => None, + ZetaProjectContext::Lsp(store) => Some(store.read(cx).related_files()), + ZetaProjectContext::Agentic { context, .. } => Some(context.as_slice()), }) - .into_iter() - .flatten() + .unwrap_or(&[]) } pub fn usage(&self, cx: &App) -> Option { @@ -636,34 +660,122 @@ impl Zeta { project: &Entity, cx: &mut Context, ) -> &mut ZetaProject { + let entity_id = project.entity_id(); + let (context_updates_tx, context_updates_rx) = smol::channel::unbounded(); self.projects - .entry(project.entity_id()) + .entry(entity_id) .or_insert_with(|| ZetaProject { - syntax_index: if let ContextMode::Syntax(_) = &self.options.context { - Some(cx.new(|cx| { + context: match &self.options.context { + ContextMode::Agentic(_) => ZetaProjectContext::Agentic { + refresh_context_task: None, + refresh_context_debounce_task: None, + refresh_context_timestamp: None, + context: Vec::new(), + }, + ContextMode::Syntax(_) => ZetaProjectContext::Syntax(cx.new(|cx| { SyntaxIndex::new(project, self.options.file_indexing_parallelism, cx) - })) - } else { - None + })), + ContextMode::Lsp(_) => { + let related_excerpt_store = + cx.new(|cx| RelatedExcerptStore::new(project, cx)); + cx.subscribe( + &related_excerpt_store, + move |this, _, event, _| match event { + RelatedExcerptStoreEvent::StartedRefresh => { + if let Some(debug_tx) = this.debug_tx.clone() { + debug_tx + .unbounded_send(ZetaDebugInfo::ContextRetrievalStarted( + ZetaContextRetrievalStartedDebugInfo { + project_entity_id: entity_id, + timestamp: Instant::now(), + search_prompt: String::new(), + }, + )) + .ok(); + } + } + RelatedExcerptStoreEvent::FinishedRefresh { + cache_hit_count, + cache_miss_count, + mean_definition_latency, + max_definition_latency, + } => { + if let Some(debug_tx) = this.debug_tx.clone() { + debug_tx + .unbounded_send( + ZetaDebugInfo::ContextRetrievalFinished( + ZetaContextRetrievalFinishedDebugInfo { + project_entity_id: entity_id, + timestamp: Instant::now(), + metadata: vec![ + ( + "Cache Hits", + format!( + "{}/{}", + cache_hit_count, + cache_hit_count + + cache_miss_count + ) + .into(), + ), + ( + "Max LSP Time", + format!( + "{} ms", + max_definition_latency + .as_millis() + ) + .into(), + ), + ( + "Mean LSP Time", + format!( + "{} ms", + mean_definition_latency + .as_millis() + ) + .into(), + ), + ], + }, + ), + ) + .ok(); + } + if let Some(project_state) = this.projects.get(&entity_id) { + project_state.context_updates_tx.send_blocking(()).ok(); + } + } + }, + ) + .detach(); + ZetaProjectContext::Lsp(related_excerpt_store) + } }, events: VecDeque::new(), last_event: None, recent_paths: VecDeque::new(), + context_updates_rx, + context_updates_tx, registered_buffers: HashMap::default(), current_prediction: None, cancelled_predictions: HashSet::default(), pending_predictions: ArrayVec::new(), next_pending_prediction_id: 0, last_prediction_refresh: None, - context: None, - refresh_context_task: None, - refresh_context_debounce_task: None, - refresh_context_timestamp: None, license_detection_watchers: HashMap::default(), _subscription: cx.subscribe(&project, Self::handle_project_event), }) } + pub fn project_context_updates( + &self, + project: &Entity, + ) -> Option> { + let project_state = self.projects.get(&project.entity_id())?; + Some(project_state.context_updates_rx.clone()) + } + fn handle_project_event( &mut self, project: Entity, @@ -1349,6 +1461,11 @@ impl Zeta { position, events, &zeta_project.recent_paths, + if self.use_context { + self.context_for_project(&project, cx).to_vec() + } else { + Vec::new() + }, diagnostic_search_range.clone(), cx, ), @@ -1480,73 +1597,34 @@ impl Zeta { trigger: PredictEditsRequestTrigger, cx: &mut Context, ) -> Task>> { - let project_state = self.projects.get(&project.entity_id()); - - let index_state = project_state.and_then(|state| { - state - .syntax_index - .as_ref() - .map(|syntax_index| syntax_index.read_with(cx, |index, _cx| index.state().clone())) - }); let options = self.options.clone(); let buffer_snapshotted_at = Instant::now(); - let Some(excerpt_path) = active_snapshot + + let Some((excerpt_path, active_project_path)) = active_snapshot .file() - .map(|path| -> Arc { path.full_path(cx).into() }) + .map(|file| -> Arc { file.full_path(cx).into() }) + .zip(active_buffer.read(cx).project_path(cx)) else { return Task::ready(Err(anyhow!("No file path for excerpt"))); }; + let client = self.client.clone(); let llm_token = self.llm_token.clone(); let app_version = AppVersion::global(cx); - let worktree_snapshots = project - .read(cx) - .worktrees(cx) - .map(|worktree| worktree.read(cx).snapshot()) - .collect::>(); let debug_tx = self.debug_tx.clone(); let diagnostics = active_snapshot.diagnostic_sets().clone(); let file = active_buffer.read(cx).file(); - let parent_abs_path = project::File::from_dyn(file).and_then(|f| { - let mut path = f.worktree.read(cx).absolutize(&f.path); - if path.pop() { Some(path) } else { None } - }); + + let active_file_full_path = file.as_ref().map(|f| f.full_path(cx)); // TODO data collection let can_collect_data = file .as_ref() .map_or(false, |file| self.can_collect_file(project, file, cx)); - let empty_context_files = HashMap::default(); - let context_files = project_state - .and_then(|project_state| project_state.context.as_ref()) - .unwrap_or(&empty_context_files); - - #[cfg(feature = "eval-support")] - let parsed_fut = futures::future::join_all( - context_files - .keys() - .map(|buffer| buffer.read(cx).parsing_idle()), - ); - - let mut included_files = context_files - .iter() - .filter_map(|(buffer_entity, ranges)| { - let buffer = buffer_entity.read(cx); - Some(( - buffer_entity.clone(), - buffer.snapshot(), - buffer.file()?.full_path(cx).into(), - ranges.clone(), - )) - }) - .collect::>(); - - included_files.sort_by(|(_, _, path_a, ranges_a), (_, _, path_b, ranges_b)| { - (path_a, ranges_a.len()).cmp(&(path_b, ranges_b.len())) - }); + let mut included_files = self.context_for_project(project, cx).to_vec(); #[cfg(feature = "eval-support")] let eval_cache = self.eval_cache.clone(); @@ -1554,15 +1632,6 @@ impl Zeta { let request_task = cx.background_spawn({ let active_buffer = active_buffer.clone(); async move { - #[cfg(feature = "eval-support")] - parsed_fut.await; - - let index_state = if let Some(index_state) = index_state { - Some(index_state.lock_owned().await) - } else { - None - }; - let cursor_offset = position.to_offset(&active_snapshot); let cursor_point = cursor_offset.to_point(&active_snapshot); @@ -1576,110 +1645,84 @@ impl Zeta { options.max_diagnostic_bytes, ); - let cloud_request = match options.context { - ContextMode::Agentic(context_options) => { - let Some(excerpt) = EditPredictionExcerpt::select_from_buffer( - cursor_point, - &active_snapshot, - &context_options.excerpt, - index_state.as_deref(), - ) else { - return Ok((None, None)); - }; + let excerpt_options = options.context.excerpt(); - let excerpt_anchor_range = active_snapshot.anchor_after(excerpt.range.start) - ..active_snapshot.anchor_before(excerpt.range.end); + let Some(excerpt) = EditPredictionExcerpt::select_from_buffer( + cursor_point, + &active_snapshot, + &excerpt_options, + None, + ) else { + return Ok((None, None)); + }; - if let Some(buffer_ix) = - included_files.iter().position(|(_, snapshot, _, _)| { - snapshot.remote_id() == active_snapshot.remote_id() - }) - { - let (_, buffer, _, ranges) = &mut included_files[buffer_ix]; - ranges.push(excerpt_anchor_range); - retrieval_search::merge_anchor_ranges(ranges, buffer); - let last_ix = included_files.len() - 1; - included_files.swap(buffer_ix, last_ix); - } else { - included_files.push(( - active_buffer.clone(), - active_snapshot.clone(), - excerpt_path.clone(), - vec![excerpt_anchor_range], - )); - } + let excerpt_anchor_range = active_snapshot.anchor_after(excerpt.range.start) + ..active_snapshot.anchor_before(excerpt.range.end); + let related_excerpt = RelatedExcerpt { + anchor_range: excerpt_anchor_range.clone(), + point_range: Point::new(excerpt.line_range.start.0, 0) + ..Point::new(excerpt.line_range.end.0, 0), + text: active_snapshot.as_rope().slice(excerpt.range), + }; + + if let Some(buffer_ix) = included_files + .iter() + .position(|file| file.buffer.entity_id() == active_buffer.entity_id()) + { + let file = &mut included_files[buffer_ix]; + file.excerpts.push(related_excerpt); + file.merge_excerpts(); + let last_ix = included_files.len() - 1; + included_files.swap(buffer_ix, last_ix); + } else { + let active_file = RelatedFile { + path: active_project_path, + buffer: active_buffer.downgrade(), + excerpts: vec![related_excerpt], + max_row: active_snapshot.max_point().row, + }; + included_files.push(active_file); + } - let included_files = included_files + let included_files = included_files + .iter() + .map(|related_file| predict_edits_v3::IncludedFile { + path: Arc::from(related_file.path.path.as_std_path()), + max_row: Line(related_file.max_row), + excerpts: related_file + .excerpts .iter() - .map(|(_, snapshot, path, ranges)| { - let ranges = ranges - .iter() - .map(|range| { - let point_range = range.to_point(&snapshot); - Line(point_range.start.row)..Line(point_range.end.row) - }) - .collect::>(); - let excerpts = assemble_excerpts(&snapshot, ranges); - predict_edits_v3::IncludedFile { - path: path.clone(), - max_row: Line(snapshot.max_point().row), - excerpts, - } + .map(|excerpt| predict_edits_v3::Excerpt { + start_line: Line(excerpt.point_range.start.row), + text: excerpt.text.to_string().into(), }) - .collect::>(); - - predict_edits_v3::PredictEditsRequest { - excerpt_path, - excerpt: String::new(), - excerpt_line_range: Line(0)..Line(0), - excerpt_range: 0..0, - cursor_point: predict_edits_v3::Point { - line: predict_edits_v3::Line(cursor_point.row), - column: cursor_point.column, - }, - included_files, - referenced_declarations: vec![], - events, - can_collect_data, - diagnostic_groups, - diagnostic_groups_truncated, - debug_info: debug_tx.is_some(), - prompt_max_bytes: Some(options.max_prompt_bytes), - prompt_format: options.prompt_format, - // TODO [zeta2] - signatures: vec![], - excerpt_parent: None, - git_info: None, - trigger, - } - } - ContextMode::Syntax(context_options) => { - let Some(context) = EditPredictionContext::gather_context( - cursor_point, - &active_snapshot, - parent_abs_path.as_deref(), - &context_options, - index_state.as_deref(), - ) else { - return Ok((None, None)); - }; - - make_syntax_context_cloud_request( - excerpt_path, - context, - events, - can_collect_data, - diagnostic_groups, - diagnostic_groups_truncated, - None, - debug_tx.is_some(), - &worktree_snapshots, - index_state.as_deref(), - Some(options.max_prompt_bytes), - options.prompt_format, - trigger, - ) - } + .collect(), + }) + .collect::>(); + + let cloud_request = predict_edits_v3::PredictEditsRequest { + excerpt_path, + excerpt: String::new(), + excerpt_line_range: Line(0)..Line(0), + excerpt_range: 0..0, + cursor_point: predict_edits_v3::Point { + line: predict_edits_v3::Line(cursor_point.row), + column: cursor_point.column, + }, + included_files, + referenced_declarations: vec![], + events, + can_collect_data, + diagnostic_groups, + diagnostic_groups_truncated, + debug_info: debug_tx.is_some(), + prompt_max_bytes: Some(options.max_prompt_bytes), + prompt_format: options.prompt_format, + // TODO [zeta2] + signatures: vec![], + excerpt_parent: None, + git_info: None, + trigger, }; let prompt_result = cloud_zeta2_prompt::build_prompt(&cloud_request); @@ -1787,18 +1830,17 @@ impl Zeta { } let get_buffer_from_context = |path: &Path| { - included_files - .iter() - .find_map(|(_, buffer, probe_path, ranges)| { - if probe_path.as_ref() == path { - Some((buffer, ranges.as_slice())) - } else { - None - } - }) + if Some(path) == active_file_full_path.as_deref() { + Some(( + &active_snapshot, + std::slice::from_ref(&excerpt_anchor_range), + )) + } else { + None + } }; - let (edited_buffer_snapshot, edits) = match options.prompt_format { + let (_, edits) = match options.prompt_format { PromptFormat::NumLinesUniDiff => { // TODO: Implement parsing of multi-file diffs crate::udiff::parse_diff(&output_text, get_buffer_from_context).await? @@ -1822,24 +1864,13 @@ impl Zeta { } }; - let edited_buffer = included_files - .iter() - .find_map(|(buffer, snapshot, _, _)| { - if snapshot.remote_id() == edited_buffer_snapshot.remote_id() { - Some(buffer.clone()) - } else { - None - } - }) - .context("Failed to find buffer in included_buffers")?; - anyhow::Ok(( Some(( request_id, Some(( inputs, - edited_buffer, - edited_buffer_snapshot.clone(), + active_buffer, + active_snapshot.clone(), edits, received_response_at, )), @@ -2058,61 +2089,78 @@ impl Zeta { pub const CONTEXT_RETRIEVAL_IDLE_DURATION: Duration = Duration::from_secs(10); pub const CONTEXT_RETRIEVAL_DEBOUNCE_DURATION: Duration = Duration::from_secs(3); - // Refresh the related excerpts when the user just beguns editing after - // an idle period, and after they pause editing. - fn refresh_context_if_needed( + pub fn refresh_context_if_needed( &mut self, project: &Entity, buffer: &Entity, cursor_position: language::Anchor, cx: &mut Context, ) { - if !matches!(self.edit_prediction_model, ZetaEditPredictionModel::Zeta2) { + if !self.use_context { return; } - - if !matches!(&self.options().context, ContextMode::Agentic { .. }) { - return; - } - let Some(zeta_project) = self.projects.get_mut(&project.entity_id()) else { return; }; - let now = Instant::now(); - let was_idle = zeta_project - .refresh_context_timestamp - .map_or(true, |timestamp| { - now - timestamp > Self::CONTEXT_RETRIEVAL_IDLE_DURATION - }); - zeta_project.refresh_context_timestamp = Some(now); - zeta_project.refresh_context_debounce_task = Some(cx.spawn({ - let buffer = buffer.clone(); - let project = project.clone(); - async move |this, cx| { - if was_idle { - log::debug!("refetching edit prediction context after idle"); - } else { - cx.background_executor() - .timer(Self::CONTEXT_RETRIEVAL_DEBOUNCE_DURATION) - .await; - log::debug!("refetching edit prediction context after pause"); - } - this.update(cx, |this, cx| { - let task = this.refresh_context(project.clone(), buffer, cursor_position, cx); + match &mut zeta_project.context { + ZetaProjectContext::Syntax(_entity) => {} + ZetaProjectContext::Lsp(related_excerpt_store) => { + related_excerpt_store.update(cx, |store, cx| { + store.refresh(buffer.clone(), cursor_position, cx); + }); + } + ZetaProjectContext::Agentic { + refresh_context_debounce_task, + refresh_context_timestamp, + .. + } => { + let now = Instant::now(); + let was_idle = refresh_context_timestamp.map_or(true, |timestamp| { + now - timestamp > Self::CONTEXT_RETRIEVAL_IDLE_DURATION + }); + *refresh_context_timestamp = Some(now); + *refresh_context_debounce_task = Some(cx.spawn({ + let buffer = buffer.clone(); + let project = project.clone(); + async move |this, cx| { + if was_idle { + log::debug!("refetching edit prediction context after idle"); + } else { + cx.background_executor() + .timer(Self::CONTEXT_RETRIEVAL_DEBOUNCE_DURATION) + .await; + log::debug!("refetching edit prediction context after pause"); + } + this.update(cx, |this, cx| { + let task = this.refresh_context_with_agentic_retrieval( + project.clone(), + buffer, + cursor_position, + cx, + ); - if let Some(zeta_project) = this.projects.get_mut(&project.entity_id()) { - zeta_project.refresh_context_task = Some(task.log_err()); - }; - }) - .ok() + if let Some(zeta_project) = this.projects.get_mut(&project.entity_id()) + { + if let ZetaProjectContext::Agentic { + refresh_context_task, + .. + } = &mut zeta_project.context + { + *refresh_context_task = Some(task.log_err()); + } + }; + }) + .ok() + } + })); } - })); + } } // Refresh the related excerpts asynchronously. Ensure the task runs to completion, // and avoid spawning more than one concurrent task. - pub fn refresh_context( + pub fn refresh_context_with_agentic_retrieval( &mut self, project: Entity, buffer: Entity, @@ -2162,12 +2210,14 @@ impl Zeta { } }; + let retrieval_started_at = Instant::now(); + if let Some(debug_tx) = &debug_tx { debug_tx .unbounded_send(ZetaDebugInfo::ContextRetrievalStarted( ZetaContextRetrievalStartedDebugInfo { - project: project.clone(), - timestamp: Instant::now(), + project_entity_id: project.entity_id(), + timestamp: retrieval_started_at, search_prompt: prompt.clone(), }, )) @@ -2260,19 +2310,8 @@ impl Zeta { queries.extend(input.queries); } - if let Some(debug_tx) = &debug_tx { - debug_tx - .unbounded_send(ZetaDebugInfo::SearchQueriesGenerated( - ZetaSearchQueryDebugInfo { - project: project.clone(), - timestamp: Instant::now(), - search_queries: queries.clone(), - }, - )) - .ok(); - } - log::trace!("Running retrieval search: {queries:#?}"); + let query_generation_finished_at = Instant::now(); let related_excerpts_result = retrieval_search::run_retrieval_searches( queries, @@ -2284,54 +2323,62 @@ impl Zeta { .await; log::trace!("Search queries executed"); - - if let Some(debug_tx) = &debug_tx { - debug_tx - .unbounded_send(ZetaDebugInfo::SearchQueriesExecuted( - ZetaContextRetrievalDebugInfo { - project: project.clone(), - timestamp: Instant::now(), - }, - )) - .ok(); - } + let query_execution_finished_at = Instant::now(); this.update(cx, |this, _cx| { let Some(zeta_project) = this.projects.get_mut(&project.entity_id()) else { return Ok(()); }; - zeta_project.refresh_context_task.take(); - if let Some(debug_tx) = &this.debug_tx { - debug_tx - .unbounded_send(ZetaDebugInfo::ContextRetrievalFinished( - ZetaContextRetrievalDebugInfo { - project, - timestamp: Instant::now(), - }, - )) - .ok(); - } - match related_excerpts_result { - Ok(excerpts) => { - zeta_project.context = Some(excerpts); - Ok(()) + if let ZetaProjectContext::Agentic { + refresh_context_task, + context, + .. + } = &mut zeta_project.context + { + refresh_context_task.take(); + if let Some(debug_tx) = &this.debug_tx { + debug_tx + .unbounded_send(ZetaDebugInfo::ContextRetrievalFinished( + ZetaContextRetrievalFinishedDebugInfo { + project_entity_id: project.entity_id(), + timestamp: Instant::now(), + metadata: vec![ + ( + "query_generation", + format!( + "{:?}", + query_generation_finished_at - retrieval_started_at + ) + .into(), + ), + ( + "search_execution", + format!( + "{:?}", + query_execution_finished_at + - query_generation_finished_at + ) + .into(), + ), + ], + }, + )) + .ok(); + } + match related_excerpts_result { + Ok(excerpts) => { + *context = excerpts; + Ok(()) + } + Err(error) => Err(error), } - Err(error) => Err(error), + } else { + Ok(()) } })? }) } - pub fn set_context( - &mut self, - project: Entity, - context: HashMap, Vec>>, - ) { - if let Some(zeta_project) = self.projects.get_mut(&project.entity_id()) { - zeta_project.context = Some(context); - } - } - fn gather_nearby_diagnostics( cursor_offset: usize, diagnostic_sets: &[(LanguageServerId, DiagnosticSet)], @@ -2378,92 +2425,13 @@ impl Zeta { (results, diagnostic_groups_truncated) } - // TODO: Dedupe with similar code in request_prediction? - pub fn cloud_request_for_zeta_cli( - &mut self, - project: &Entity, - buffer: &Entity, - position: language::Anchor, - cx: &mut Context, - ) -> Task> { - let project_state = self.projects.get(&project.entity_id()); - - let index_state = project_state.and_then(|state| { - state - .syntax_index - .as_ref() - .map(|index| index.read_with(cx, |index, _cx| index.state().clone())) - }); - let options = self.options.clone(); - let snapshot = buffer.read(cx).snapshot(); - let Some(excerpt_path) = snapshot.file().map(|path| path.full_path(cx)) else { - return Task::ready(Err(anyhow!("No file path for excerpt"))); - }; - let worktree_snapshots = project - .read(cx) - .worktrees(cx) - .map(|worktree| worktree.read(cx).snapshot()) - .collect::>(); - - let parent_abs_path = project::File::from_dyn(buffer.read(cx).file()).and_then(|f| { - let mut path = f.worktree.read(cx).absolutize(&f.path); - if path.pop() { Some(path) } else { None } - }); - - cx.background_spawn(async move { - let index_state = if let Some(index_state) = index_state { - Some(index_state.lock_owned().await) - } else { - None - }; - - let cursor_point = position.to_point(&snapshot); - - let debug_info = true; - EditPredictionContext::gather_context( - cursor_point, - &snapshot, - parent_abs_path.as_deref(), - match &options.context { - ContextMode::Agentic(_) => { - // TODO - panic!("Llm mode not supported in zeta cli yet"); - } - ContextMode::Syntax(edit_prediction_context_options) => { - edit_prediction_context_options - } - }, - index_state.as_deref(), - ) - .context("Failed to select excerpt") - .map(|context| { - make_syntax_context_cloud_request( - excerpt_path.into(), - context, - // TODO pass everything - Vec::new(), - false, - Vec::new(), - false, - None, - debug_info, - &worktree_snapshots, - index_state.as_deref(), - Some(options.max_prompt_bytes), - options.prompt_format, - PredictEditsRequestTrigger::Other, - ) - }) - }) - } - pub fn wait_for_initial_indexing( &mut self, project: &Entity, cx: &mut Context, ) -> Task> { let zeta_project = self.get_or_init_zeta_project(project, cx); - if let Some(syntax_index) = &zeta_project.syntax_index { + if let ZetaProjectContext::Syntax(syntax_index) = &zeta_project.context { syntax_index.read(cx).wait_for_initial_file_indexing(cx) } else { Task::ready(Ok(())) @@ -2555,6 +2523,11 @@ impl Zeta { self.client.telemetry().flush_events().detach(); cx.notify(); } + + fn enable_or_disable_context_retrieval(&mut self, cx: &mut Context<'_, Zeta>) { + self.use_context = cx.has_flag::() + && all_language_settings(None, cx).edit_predictions.use_context; + } } pub fn text_from_response(mut res: open_ai::Response) -> Option { @@ -2597,131 +2570,6 @@ pub struct ZedUpdateRequiredError { minimum_version: Version, } -fn make_syntax_context_cloud_request( - excerpt_path: Arc, - context: EditPredictionContext, - events: Vec>, - can_collect_data: bool, - diagnostic_groups: Vec, - diagnostic_groups_truncated: bool, - git_info: Option, - debug_info: bool, - worktrees: &Vec, - index_state: Option<&SyntaxIndexState>, - prompt_max_bytes: Option, - prompt_format: PromptFormat, - trigger: PredictEditsRequestTrigger, -) -> predict_edits_v3::PredictEditsRequest { - let mut signatures = Vec::new(); - let mut declaration_to_signature_index = HashMap::default(); - let mut referenced_declarations = Vec::new(); - - for snippet in context.declarations { - let project_entry_id = snippet.declaration.project_entry_id(); - let Some(path) = worktrees.iter().find_map(|worktree| { - worktree.entry_for_id(project_entry_id).map(|entry| { - let mut full_path = RelPathBuf::new(); - full_path.push(worktree.root_name()); - full_path.push(&entry.path); - full_path - }) - }) else { - continue; - }; - - let parent_index = index_state.and_then(|index_state| { - snippet.declaration.parent().and_then(|parent| { - add_signature( - parent, - &mut declaration_to_signature_index, - &mut signatures, - index_state, - ) - }) - }); - - let (text, text_is_truncated) = snippet.declaration.item_text(); - referenced_declarations.push(predict_edits_v3::ReferencedDeclaration { - path: path.as_std_path().into(), - text: text.into(), - range: snippet.declaration.item_line_range(), - text_is_truncated, - signature_range: snippet.declaration.signature_range_in_item_text(), - parent_index, - signature_score: snippet.score(DeclarationStyle::Signature), - declaration_score: snippet.score(DeclarationStyle::Declaration), - score_components: snippet.components, - }); - } - - let excerpt_parent = index_state.and_then(|index_state| { - context - .excerpt - .parent_declarations - .last() - .and_then(|(parent, _)| { - add_signature( - *parent, - &mut declaration_to_signature_index, - &mut signatures, - index_state, - ) - }) - }); - - predict_edits_v3::PredictEditsRequest { - excerpt_path, - excerpt: context.excerpt_text.body, - excerpt_line_range: context.excerpt.line_range, - excerpt_range: context.excerpt.range, - cursor_point: predict_edits_v3::Point { - line: predict_edits_v3::Line(context.cursor_point.row), - column: context.cursor_point.column, - }, - referenced_declarations, - included_files: vec![], - signatures, - excerpt_parent, - events, - can_collect_data, - diagnostic_groups, - diagnostic_groups_truncated, - git_info, - debug_info, - prompt_max_bytes, - prompt_format, - trigger, - } -} - -fn add_signature( - declaration_id: DeclarationId, - declaration_to_signature_index: &mut HashMap, - signatures: &mut Vec, - index: &SyntaxIndexState, -) -> Option { - if let Some(signature_index) = declaration_to_signature_index.get(&declaration_id) { - return Some(*signature_index); - } - let Some(parent_declaration) = index.declaration(declaration_id) else { - log::error!("bug: missing parent declaration"); - return None; - }; - let parent_index = parent_declaration.parent().and_then(|parent| { - add_signature(parent, declaration_to_signature_index, signatures, index) - }); - let (text, text_is_truncated) = parent_declaration.signature_text(); - let signature_index = signatures.len(); - signatures.push(Signature { - text: text.into(), - text_is_truncated, - parent_index, - range: parent_declaration.signature_line_range(), - }); - declaration_to_signature_index.insert(declaration_id, signature_index); - Some(signature_index) -} - #[cfg(feature = "eval-support")] pub type EvalCacheKey = (EvalCacheEntryKind, u64); @@ -2917,7 +2765,6 @@ mod tests { use cloud_llm_client::{ EditPredictionRejectReason, EditPredictionRejection, RejectEditPredictionsBody, }; - use cloud_zeta2_prompt::retrieval_prompt::{SearchToolInput, SearchToolQuery}; use futures::{ AsyncReadExt, StreamExt, channel::{mpsc, oneshot}, @@ -2929,6 +2776,7 @@ mod tests { }; use indoc::indoc; use language::OffsetRangeExt as _; + use lsp::LanguageServerId; use open_ai::Usage; use pretty_assertions::{assert_eq, assert_matches}; use project::{FakeFs, Project}; @@ -2959,7 +2807,8 @@ mod tests { let buffer1 = project .update(cx, |project, cx| { - let path = project.find_project_path(path!("root/1.txt"), cx).unwrap(); + let path = project.find_project_path(path!("/root/1.txt"), cx).unwrap(); + project.set_active_path(Some(path.clone()), cx); project.open_buffer(path, cx) }) .await @@ -2995,58 +2844,38 @@ mod tests { assert_matches!(prediction, BufferEditPrediction::Local { .. }); }); - // Context refresh - let refresh_task = zeta.update(cx, |zeta, cx| { - zeta.refresh_context(project.clone(), buffer1.clone(), position, cx) - }); - let (_request, respond_tx) = requests.predict.next().await.unwrap(); - respond_tx - .send(open_ai::Response { - id: Uuid::new_v4().to_string(), - object: "response".into(), - created: 0, - model: "model".into(), - choices: vec![open_ai::Choice { - index: 0, - message: open_ai::RequestMessage::Assistant { - content: None, - tool_calls: vec![open_ai::ToolCall { - id: "search".into(), - content: open_ai::ToolCallContent::Function { - function: open_ai::FunctionContent { - name: cloud_zeta2_prompt::retrieval_prompt::TOOL_NAME - .to_string(), - arguments: serde_json::to_string(&SearchToolInput { - queries: Box::new([SearchToolQuery { - glob: "root/2.txt".to_string(), - syntax_node: vec![], - content: Some(".".into()), - }]), - }) - .unwrap(), - }, - }, - }], - }, - finish_reason: None, - }], - usage: Usage { - prompt_tokens: 0, - completion_tokens: 0, - total_tokens: 0, - }, - }) - .unwrap(); - refresh_task.await.unwrap(); - zeta.update(cx, |zeta, _cx| { zeta.reject_current_prediction(EditPredictionRejectReason::Discarded, &project); }); - // Prediction for another file - zeta.update(cx, |zeta, cx| { - zeta.refresh_prediction_from_buffer(project.clone(), buffer1.clone(), position, cx) + // Prediction for diagnostic in another file + + let diagnostic = lsp::Diagnostic { + range: lsp::Range::new(lsp::Position::new(1, 1), lsp::Position::new(1, 5)), + severity: Some(lsp::DiagnosticSeverity::ERROR), + message: "Sentence is incomplete".to_string(), + ..Default::default() + }; + + project.update(cx, |project, cx| { + project.lsp_store().update(cx, |lsp_store, cx| { + lsp_store + .update_diagnostics( + LanguageServerId(0), + lsp::PublishDiagnosticsParams { + uri: lsp::Uri::from_file_path(path!("/root/2.txt")).unwrap(), + diagnostics: vec![diagnostic], + version: None, + }, + None, + language::DiagnosticSourceKind::Pushed, + &[], + cx, + ) + .unwrap(); + }); }); + let (_request, respond_tx) = requests.predict.next().await.unwrap(); respond_tx .send(model_response(indoc! {r#" @@ -4018,7 +3847,6 @@ mod tests { let mut buf = Vec::new(); body.read_to_end(&mut buf).await.ok(); let req = serde_json::from_slice(&buf).unwrap(); - let (res_tx, res_rx) = oneshot::channel(); predict_req_tx.unbounded_send((req, res_tx)).unwrap(); serde_json::to_string(&res_rx.await?).unwrap() diff --git a/crates/zeta2_tools/Cargo.toml b/crates/zeta2_tools/Cargo.toml index 607e24c895d96de1464ff1bfa2a4dfa01c5d9669..8e20224736c658d4d80d678b29d4231ec7e4b2f5 100644 --- a/crates/zeta2_tools/Cargo.toml +++ b/crates/zeta2_tools/Cargo.toml @@ -15,7 +15,6 @@ path = "src/zeta2_tools.rs" anyhow.workspace = true client.workspace = true cloud_llm_client.workspace = true -cloud_zeta2_prompt.workspace = true collections.workspace = true edit_prediction_context.workspace = true editor.workspace = true diff --git a/crates/zeta2_tools/src/zeta2_context_view.rs b/crates/zeta2_tools/src/zeta2_context_view.rs index 54f1ea2d813f7c00d30b12e341fb3e5ac3f155dc..882846929a62f90f349d40f8f6b6996f83613ec7 100644 --- a/crates/zeta2_tools/src/zeta2_context_view.rs +++ b/crates/zeta2_tools/src/zeta2_context_view.rs @@ -8,26 +8,25 @@ use std::{ use anyhow::Result; use client::{Client, UserStore}; -use cloud_zeta2_prompt::retrieval_prompt::SearchToolQuery; use editor::{Editor, PathKey}; use futures::StreamExt as _; use gpui::{ Animation, AnimationExt, App, AppContext as _, Context, Entity, EventEmitter, FocusHandle, - Focusable, ParentElement as _, SharedString, Styled as _, Task, TextAlign, Window, actions, - pulsating_between, + Focusable, InteractiveElement as _, IntoElement as _, ParentElement as _, SharedString, + Styled as _, Task, TextAlign, Window, actions, div, pulsating_between, }; use multi_buffer::MultiBuffer; use project::Project; use text::OffsetRangeExt; use ui::{ - ButtonCommon, Clickable, Color, Disableable, FluentBuilder as _, Icon, IconButton, IconName, - IconSize, InteractiveElement, IntoElement, ListHeader, ListItem, StyledTypography, div, h_flex, - v_flex, + ButtonCommon, Clickable, Disableable, FluentBuilder as _, IconButton, IconName, + StyledTypography as _, h_flex, v_flex, }; + use workspace::Item; use zeta::{ - Zeta, ZetaContextRetrievalDebugInfo, ZetaContextRetrievalStartedDebugInfo, ZetaDebugInfo, - ZetaSearchQueryDebugInfo, + Zeta, ZetaContextRetrievalFinishedDebugInfo, ZetaContextRetrievalStartedDebugInfo, + ZetaDebugInfo, }; pub struct Zeta2ContextView { @@ -42,10 +41,8 @@ pub struct Zeta2ContextView { #[derive(Debug)] struct RetrievalRun { editor: Entity, - search_queries: Vec, started_at: Instant, - search_results_generated_at: Option, - search_results_executed_at: Option, + metadata: Vec<(&'static str, SharedString)>, finished_at: Option, } @@ -97,22 +94,12 @@ impl Zeta2ContextView { ) { match event { ZetaDebugInfo::ContextRetrievalStarted(info) => { - if info.project == self.project { + if info.project_entity_id == self.project.entity_id() { self.handle_context_retrieval_started(info, window, cx); } } - ZetaDebugInfo::SearchQueriesGenerated(info) => { - if info.project == self.project { - self.handle_search_queries_generated(info, window, cx); - } - } - ZetaDebugInfo::SearchQueriesExecuted(info) => { - if info.project == self.project { - self.handle_search_queries_executed(info, window, cx); - } - } ZetaDebugInfo::ContextRetrievalFinished(info) => { - if info.project == self.project { + if info.project_entity_id == self.project.entity_id() { self.handle_context_retrieval_finished(info, window, cx); } } @@ -129,7 +116,7 @@ impl Zeta2ContextView { if self .runs .back() - .is_some_and(|run| run.search_results_executed_at.is_none()) + .is_some_and(|run| run.finished_at.is_none()) { self.runs.pop_back(); } @@ -144,11 +131,9 @@ impl Zeta2ContextView { self.runs.push_back(RetrievalRun { editor, - search_queries: Vec::new(), started_at: info.timestamp, - search_results_generated_at: None, - search_results_executed_at: None, finished_at: None, + metadata: Vec::new(), }); cx.notify(); @@ -156,7 +141,7 @@ impl Zeta2ContextView { fn handle_context_retrieval_finished( &mut self, - info: ZetaContextRetrievalDebugInfo, + info: ZetaContextRetrievalFinishedDebugInfo, window: &mut Window, cx: &mut Context, ) { @@ -165,67 +150,72 @@ impl Zeta2ContextView { }; run.finished_at = Some(info.timestamp); + run.metadata = info.metadata; + + let project = self.project.clone(); + let related_files = self + .zeta + .read(cx) + .context_for_project(&self.project, cx) + .to_vec(); + let editor = run.editor.clone(); let multibuffer = run.editor.read(cx).buffer().clone(); - multibuffer.update(cx, |multibuffer, cx| { - multibuffer.clear(cx); - let context = self.zeta.read(cx).context_for_project(&self.project); - let mut paths = Vec::new(); - for (buffer, ranges) in context { - let path = PathKey::for_buffer(&buffer, cx); - let snapshot = buffer.read(cx).snapshot(); - let ranges = ranges - .iter() - .map(|range| range.to_point(&snapshot)) - .collect::>(); - paths.push((path, buffer, ranges)); - } + if self.current_ix + 2 == self.runs.len() { + self.current_ix += 1; + } - for (path, buffer, ranges) in paths { - multibuffer.set_excerpts_for_path(path, buffer, ranges, 0, cx); + cx.spawn_in(window, async move |this, cx| { + let mut paths = Vec::new(); + for related_file in related_files { + let (buffer, point_ranges): (_, Vec<_>) = + if let Some(buffer) = related_file.buffer.upgrade() { + let snapshot = buffer.read_with(cx, |buffer, _| buffer.snapshot())?; + + ( + buffer, + related_file + .excerpts + .iter() + .map(|excerpt| excerpt.anchor_range.to_point(&snapshot)) + .collect(), + ) + } else { + ( + project + .update(cx, |project, cx| { + project.open_buffer(related_file.path.clone(), cx) + })? + .await?, + related_file + .excerpts + .iter() + .map(|excerpt| excerpt.point_range.clone()) + .collect(), + ) + }; + cx.update(|_, cx| { + let path = PathKey::for_buffer(&buffer, cx); + paths.push((path, buffer, point_ranges)); + })?; } - }); - - run.editor.update(cx, |editor, cx| { - editor.move_to_beginning(&Default::default(), window, cx); - }); - - cx.notify(); - } - - fn handle_search_queries_generated( - &mut self, - info: ZetaSearchQueryDebugInfo, - _window: &mut Window, - cx: &mut Context, - ) { - let Some(run) = self.runs.back_mut() else { - return; - }; - run.search_results_generated_at = Some(info.timestamp); - run.search_queries = info.search_queries; - cx.notify(); - } + multibuffer.update(cx, |multibuffer, cx| { + multibuffer.clear(cx); - fn handle_search_queries_executed( - &mut self, - info: ZetaContextRetrievalDebugInfo, - _window: &mut Window, - cx: &mut Context, - ) { - if self.current_ix + 2 == self.runs.len() { - // Switch to latest when the queries are executed - self.current_ix += 1; - } + for (path, buffer, ranges) in paths { + multibuffer.set_excerpts_for_path(path, buffer, ranges, 0, cx); + } + })?; - let Some(run) = self.runs.back_mut() else { - return; - }; + editor.update_in(cx, |editor, window, cx| { + editor.move_to_beginning(&Default::default(), window, cx); + })?; - run.search_results_executed_at = Some(info.timestamp); - cx.notify(); + this.update(cx, |_, cx| cx.notify()) + }) + .detach(); } fn handle_go_back( @@ -254,8 +244,11 @@ impl Zeta2ContextView { } fn render_informational_footer(&self, cx: &mut Context<'_, Zeta2ContextView>) -> ui::Div { - let is_latest = self.runs.len() == self.current_ix + 1; let run = &self.runs[self.current_ix]; + let new_run_started = self + .runs + .back() + .map_or(false, |latest_run| latest_run.finished_at.is_none()); h_flex() .p_2() @@ -264,114 +257,65 @@ impl Zeta2ContextView { .text_xs() .border_t_1() .gap_2() + .child(v_flex().h_full().flex_1().child({ + let t0 = run.started_at; + let mut table = ui::Table::<2>::new().width(ui::px(300.)).no_ui_font(); + for (key, value) in &run.metadata { + table = table.row([key.into_any_element(), value.clone().into_any_element()]) + } + table = table.row([ + "Total Time".into_any_element(), + format!("{} ms", (run.finished_at.unwrap_or(t0) - t0).as_millis()) + .into_any_element(), + ]); + table + })) .child( - v_flex().h_full().flex_1().children( - run.search_queries - .iter() - .enumerate() - .flat_map(|(ix, query)| { - std::iter::once(ListHeader::new(query.glob.clone()).into_any_element()) - .chain(query.syntax_node.iter().enumerate().map( - move |(regex_ix, regex)| { - ListItem::new(ix * 100 + regex_ix) - .start_slot( - Icon::new(IconName::MagnifyingGlass) - .color(Color::Muted) - .size(IconSize::Small), - ) - .child(regex.clone()) - .into_any_element() - }, + v_flex().h_full().text_align(TextAlign::Right).child( + h_flex() + .justify_end() + .child( + IconButton::new("go-back", IconName::ChevronLeft) + .disabled(self.current_ix == 0 || self.runs.len() < 2) + .tooltip(ui::Tooltip::for_action_title( + "Go to previous run", + &Zeta2ContextGoBack, )) - .chain(query.content.as_ref().map(move |regex| { - ListItem::new(ix * 100 + query.syntax_node.len()) - .start_slot( - Icon::new(IconName::MagnifyingGlass) - .color(Color::Muted) - .size(IconSize::Small), + .on_click(cx.listener(|this, _, window, cx| { + this.handle_go_back(&Zeta2ContextGoBack, window, cx); + })), + ) + .child( + div() + .child(format!("{}/{}", self.current_ix + 1, self.runs.len())) + .map(|this| { + if new_run_started { + this.with_animation( + "pulsating-count", + Animation::new(Duration::from_secs(2)) + .repeat() + .with_easing(pulsating_between(0.4, 0.8)), + |label, delta| label.opacity(delta), ) - .child(regex.clone()) .into_any_element() - })) - }), + } else { + this.into_any_element() + } + }), + ) + .child( + IconButton::new("go-forward", IconName::ChevronRight) + .disabled(self.current_ix + 1 == self.runs.len()) + .tooltip(ui::Tooltip::for_action_title( + "Go to next run", + &Zeta2ContextGoBack, + )) + .on_click(cx.listener(|this, _, window, cx| { + this.handle_go_forward(&Zeta2ContextGoForward, window, cx); + })), + ), ), ) - .child( - v_flex() - .h_full() - .text_align(TextAlign::Right) - .child( - h_flex() - .justify_end() - .child( - IconButton::new("go-back", IconName::ChevronLeft) - .disabled(self.current_ix == 0 || self.runs.len() < 2) - .tooltip(ui::Tooltip::for_action_title( - "Go to previous run", - &Zeta2ContextGoBack, - )) - .on_click(cx.listener(|this, _, window, cx| { - this.handle_go_back(&Zeta2ContextGoBack, window, cx); - })), - ) - .child( - div() - .child(format!("{}/{}", self.current_ix + 1, self.runs.len())) - .map(|this| { - if self.runs.back().is_some_and(|back| { - back.search_results_executed_at.is_none() - }) { - this.with_animation( - "pulsating-count", - Animation::new(Duration::from_secs(2)) - .repeat() - .with_easing(pulsating_between(0.4, 0.8)), - |label, delta| label.opacity(delta), - ) - .into_any_element() - } else { - this.into_any_element() - } - }), - ) - .child( - IconButton::new("go-forward", IconName::ChevronRight) - .disabled(self.current_ix + 1 == self.runs.len()) - .tooltip(ui::Tooltip::for_action_title( - "Go to next run", - &Zeta2ContextGoBack, - )) - .on_click(cx.listener(|this, _, window, cx| { - this.handle_go_forward(&Zeta2ContextGoForward, window, cx); - })), - ), - ) - .map(|mut div| { - let pending_message = |div: ui::Div, msg: &'static str| { - if is_latest { - return div.child(msg); - } else { - return div.child("Canceled"); - } - }; - - let t0 = run.started_at; - let Some(t1) = run.search_results_generated_at else { - return pending_message(div, "Planning search..."); - }; - div = div.child(format!("Planned search: {:>5} ms", (t1 - t0).as_millis())); - - let Some(t2) = run.search_results_executed_at else { - return pending_message(div, "Running search..."); - }; - div = div.child(format!("Ran search: {:>5} ms", (t2 - t1).as_millis())); - - div.child(format!( - "Total: {:>5} ms", - (run.finished_at.unwrap_or(t0) - t0).as_millis() - )) - }), - ) } } diff --git a/crates/zeta2_tools/src/zeta2_tools.rs b/crates/zeta2_tools/src/zeta2_tools.rs index 4e650f2405d63feab010c5c9b73efc75bd576af6..26d68b075153557ab50ed0a231c5d45f0bb9646c 100644 --- a/crates/zeta2_tools/src/zeta2_tools.rs +++ b/crates/zeta2_tools/src/zeta2_tools.rs @@ -108,6 +108,7 @@ pub struct Zeta2Inspector { pub enum ContextModeState { Llm, + Lsp, Syntax { max_retrieved_declarations: Entity, }, @@ -222,6 +223,9 @@ impl Zeta2Inspector { ), }; } + ContextMode::Lsp(_) => { + self.context_mode = ContextModeState::Lsp; + } } cx.notify(); } @@ -302,6 +306,9 @@ impl Zeta2Inspector { ContextModeState::Syntax { max_retrieved_declarations, } => number_input_value(max_retrieved_declarations, cx), + ContextModeState::Lsp => { + zeta::DEFAULT_SYNTAX_CONTEXT_OPTIONS.max_retrieved_declarations + } }; ContextMode::Syntax(EditPredictionContextOptions { @@ -310,6 +317,7 @@ impl Zeta2Inspector { ..context_options }) } + ContextMode::Lsp(excerpt_options) => ContextMode::Lsp(excerpt_options), }; this.set_zeta_options( @@ -656,6 +664,7 @@ impl Zeta2Inspector { ContextModeState::Syntax { max_retrieved_declarations, } => Some(max_retrieved_declarations.clone()), + ContextModeState::Lsp => None, }) .child(self.max_prompt_bytes_input.clone()) .child(self.render_prompt_format_dropdown(window, cx)), @@ -679,6 +688,7 @@ impl Zeta2Inspector { match &self.context_mode { ContextModeState::Llm => "LLM-based", ContextModeState::Syntax { .. } => "Syntax", + ContextModeState::Lsp => "LSP-based", }, ContextMenu::build(window, cx, move |menu, _window, _cx| { menu.item( @@ -695,6 +705,7 @@ impl Zeta2Inspector { this.zeta.read(cx).options().clone(); match current_options.context.clone() { ContextMode::Agentic(_) => {} + ContextMode::Lsp(_) => {} ContextMode::Syntax(context_options) => { let options = ZetaOptions { context: ContextMode::Agentic( @@ -739,6 +750,7 @@ impl Zeta2Inspector { this.set_zeta_options(options, cx); } ContextMode::Syntax(_) => {} + ContextMode::Lsp(_) => {} } }) .ok(); diff --git a/crates/zeta_cli/src/main.rs b/crates/zeta_cli/src/main.rs index a9c8b5998cdd32a94a71f1894dfbdc40c22abaed..42c0ea185f4401a11c2798f9402a59829f8463df 100644 --- a/crates/zeta_cli/src/main.rs +++ b/crates/zeta_cli/src/main.rs @@ -21,15 +21,12 @@ use ::util::paths::PathStyle; use anyhow::{Result, anyhow}; use clap::{Args, Parser, Subcommand, ValueEnum}; use cloud_llm_client::predict_edits_v3; -use edit_prediction_context::{ - EditPredictionContextOptions, EditPredictionExcerptOptions, EditPredictionScoreOptions, -}; +use edit_prediction_context::EditPredictionExcerptOptions; use gpui::{Application, AsyncApp, Entity, prelude::*}; use language::{Bias, Buffer, BufferSnapshot, Point}; use metrics::delta_chr_f; -use project::{Project, Worktree}; +use project::{Project, Worktree, lsp_store::OpenLspBufferHandle}; use reqwest_client::ReqwestClient; -use serde_json::json; use std::io::{self}; use std::time::Duration; use std::{collections::HashSet, path::PathBuf, str::FromStr, sync::Arc}; @@ -97,7 +94,7 @@ struct ContextArgs { enum ContextProvider { Zeta1, #[default] - Syntax, + Zeta2, } #[derive(Clone, Debug, Args)] @@ -204,19 +201,12 @@ enum PredictionProvider { Sweep, } -fn zeta2_args_to_options(args: &Zeta2Args, omit_excerpt_overlaps: bool) -> zeta::ZetaOptions { +fn zeta2_args_to_options(args: &Zeta2Args) -> zeta::ZetaOptions { zeta::ZetaOptions { - context: ContextMode::Syntax(EditPredictionContextOptions { - max_retrieved_declarations: args.max_retrieved_definitions, - use_imports: !args.disable_imports_gathering, - excerpt: EditPredictionExcerptOptions { - max_bytes: args.max_excerpt_bytes, - min_bytes: args.min_excerpt_bytes, - target_before_cursor_over_total_bytes: args.target_before_cursor_over_total_bytes, - }, - score: EditPredictionScoreOptions { - omit_excerpt_overlaps, - }, + context: ContextMode::Lsp(EditPredictionExcerptOptions { + max_bytes: args.max_excerpt_bytes, + min_bytes: args.min_excerpt_bytes, + target_before_cursor_over_total_bytes: args.target_before_cursor_over_total_bytes, }), max_diagnostic_bytes: args.max_diagnostic_bytes, max_prompt_bytes: args.max_prompt_bytes, @@ -295,6 +285,7 @@ struct LoadedContext { worktree: Entity, project: Entity, buffer: Entity, + lsp_open_handle: Option, } async fn load_context( @@ -330,7 +321,7 @@ async fn load_context( .await?; let mut ready_languages = HashSet::default(); - let (_lsp_open_handle, buffer) = if *use_language_server { + let (lsp_open_handle, buffer) = if *use_language_server { let (lsp_open_handle, _, buffer) = open_buffer_with_language_server( project.clone(), worktree.clone(), @@ -377,10 +368,11 @@ async fn load_context( worktree, project, buffer, + lsp_open_handle, }) } -async fn zeta2_syntax_context( +async fn zeta2_context( args: ContextArgs, app_state: &Arc, cx: &mut AsyncApp, @@ -390,6 +382,7 @@ async fn zeta2_syntax_context( project, buffer, clipped_cursor, + lsp_open_handle: _handle, .. } = load_context(&args, app_state, cx).await?; @@ -406,30 +399,26 @@ async fn zeta2_syntax_context( zeta::Zeta::new(app_state.client.clone(), app_state.user_store.clone(), cx) }); let indexing_done_task = zeta.update(cx, |zeta, cx| { - zeta.set_options(zeta2_args_to_options(&args.zeta2_args, true)); + zeta.set_options(zeta2_args_to_options(&args.zeta2_args)); zeta.register_buffer(&buffer, &project, cx); zeta.wait_for_initial_indexing(&project, cx) }); cx.spawn(async move |cx| { indexing_done_task.await?; - let request = zeta - .update(cx, |zeta, cx| { - let cursor = buffer.read(cx).snapshot().anchor_before(clipped_cursor); - zeta.cloud_request_for_zeta_cli(&project, &buffer, cursor, cx) - })? - .await?; - - let (prompt_string, section_labels) = cloud_zeta2_prompt::build_prompt(&request)?; - - match args.zeta2_args.output_format { - OutputFormat::Prompt => anyhow::Ok(prompt_string), - OutputFormat::Request => anyhow::Ok(serde_json::to_string_pretty(&request)?), - OutputFormat::Full => anyhow::Ok(serde_json::to_string_pretty(&json!({ - "request": request, - "prompt": prompt_string, - "section_labels": section_labels, - }))?), - } + let updates_rx = zeta.update(cx, |zeta, cx| { + let cursor = buffer.read(cx).snapshot().anchor_before(clipped_cursor); + zeta.set_use_context(true); + zeta.refresh_context_if_needed(&project, &buffer, cursor, cx); + zeta.project_context_updates(&project).unwrap() + })?; + + updates_rx.recv().await.ok(); + + let context = zeta.update(cx, |zeta, cx| { + zeta.context_for_project(&project, cx).to_vec() + })?; + + anyhow::Ok(serde_json::to_string_pretty(&context).unwrap()) }) })? .await?; @@ -482,7 +471,6 @@ fn main() { None => { if args.printenv { ::util::shell_env::print_env(); - return; } else { panic!("Expected a command"); } @@ -494,7 +482,7 @@ fn main() { arguments.extension, arguments.limit, arguments.skip, - zeta2_args_to_options(&arguments.zeta2_args, false), + zeta2_args_to_options(&arguments.zeta2_args), cx, ) .await; @@ -507,10 +495,8 @@ fn main() { zeta1_context(context_args, &app_state, cx).await.unwrap(); serde_json::to_string_pretty(&context.body).unwrap() } - ContextProvider::Syntax => { - zeta2_syntax_context(context_args, &app_state, cx) - .await - .unwrap() + ContextProvider::Zeta2 => { + zeta2_context(context_args, &app_state, cx).await.unwrap() } }; println!("{}", result); diff --git a/crates/zeta_cli/src/predict.rs b/crates/zeta_cli/src/predict.rs index 99fe65cfa3221a1deb18e767e8faa8e1a1fca0ac..9fefc5ce97672796f79482e23acca3599aa1ff44 100644 --- a/crates/zeta_cli/src/predict.rs +++ b/crates/zeta_cli/src/predict.rs @@ -136,8 +136,7 @@ pub async fn perform_predict( let result = result.clone(); async move { let mut start_time = None; - let mut search_queries_generated_at = None; - let mut search_queries_executed_at = None; + let mut retrieval_finished_at = None; while let Some(event) = debug_rx.next().await { match event { zeta::ZetaDebugInfo::ContextRetrievalStarted(info) => { @@ -147,17 +146,17 @@ pub async fn perform_predict( &info.search_prompt, )?; } - zeta::ZetaDebugInfo::SearchQueriesGenerated(info) => { - search_queries_generated_at = Some(info.timestamp); - fs::write( - example_run_dir.join("search_queries.json"), - serde_json::to_string_pretty(&info.search_queries).unwrap(), - )?; - } - zeta::ZetaDebugInfo::SearchQueriesExecuted(info) => { - search_queries_executed_at = Some(info.timestamp); + zeta::ZetaDebugInfo::ContextRetrievalFinished(info) => { + retrieval_finished_at = Some(info.timestamp); + for (key, value) in &info.metadata { + if *key == "search_queries" { + fs::write( + example_run_dir.join("search_queries.json"), + value.as_bytes(), + )?; + } + } } - zeta::ZetaDebugInfo::ContextRetrievalFinished(_info) => {} zeta::ZetaDebugInfo::EditPredictionRequested(request) => { let prediction_started_at = Instant::now(); start_time.get_or_insert(prediction_started_at); @@ -200,13 +199,8 @@ pub async fn perform_predict( let mut result = result.lock().unwrap(); result.generated_len = response.chars().count(); - - result.planning_search_time = - Some(search_queries_generated_at.unwrap() - start_time.unwrap()); - result.running_search_time = Some( - search_queries_executed_at.unwrap() - - search_queries_generated_at.unwrap(), - ); + result.retrieval_time = + retrieval_finished_at.unwrap() - start_time.unwrap(); result.prediction_time = prediction_finished_at - prediction_started_at; result.total_time = prediction_finished_at - start_time.unwrap(); @@ -219,7 +213,12 @@ pub async fn perform_predict( }); zeta.update(cx, |zeta, cx| { - zeta.refresh_context(project.clone(), cursor_buffer.clone(), cursor_anchor, cx) + zeta.refresh_context_with_agentic_retrieval( + project.clone(), + cursor_buffer.clone(), + cursor_anchor, + cx, + ) })? .await?; } @@ -321,8 +320,7 @@ pub struct PredictionDetails { pub diff: String, pub excerpts: Vec, pub excerpts_text: String, // TODO: contains the worktree root path. Drop this field and compute it on the fly - pub planning_search_time: Option, - pub running_search_time: Option, + pub retrieval_time: Duration, pub prediction_time: Duration, pub total_time: Duration, pub run_example_dir: PathBuf, @@ -336,8 +334,7 @@ impl PredictionDetails { diff: Default::default(), excerpts: Default::default(), excerpts_text: Default::default(), - planning_search_time: Default::default(), - running_search_time: Default::default(), + retrieval_time: Default::default(), prediction_time: Default::default(), total_time: Default::default(), run_example_dir, @@ -357,28 +354,20 @@ impl PredictionDetails { } pub fn to_markdown(&self) -> String { - let inference_time = self.planning_search_time.unwrap_or_default() + self.prediction_time; - format!( "## Excerpts\n\n\ {}\n\n\ ## Prediction\n\n\ {}\n\n\ ## Time\n\n\ - Planning searches: {}ms\n\ - Running searches: {}ms\n\ - Making Prediction: {}ms\n\n\ - -------------------\n\n\ - Total: {}ms\n\ - Inference: {}ms ({:.2}%)\n", + Retrieval: {}ms\n\ + Prediction: {}ms\n\n\ + Total: {}ms\n", self.excerpts_text, self.diff, - self.planning_search_time.unwrap_or_default().as_millis(), - self.running_search_time.unwrap_or_default().as_millis(), + self.retrieval_time.as_millis(), self.prediction_time.as_millis(), self.total_time.as_millis(), - inference_time.as_millis(), - (inference_time.as_millis() as f64 / self.total_time.as_millis() as f64) * 100. ) } } diff --git a/crates/zeta_cli/src/util.rs b/crates/zeta_cli/src/util.rs index 699c1c743f67e09ef5ca7211c385114802d4ab32..f4a51d94585f82da008ac832dc62392c365738fd 100644 --- a/crates/zeta_cli/src/util.rs +++ b/crates/zeta_cli/src/util.rs @@ -2,7 +2,8 @@ use anyhow::{Result, anyhow}; use futures::channel::mpsc; use futures::{FutureExt as _, StreamExt as _}; use gpui::{AsyncApp, Entity, Task}; -use language::{Buffer, LanguageId, LanguageServerId, ParseStatus}; +use language::{Buffer, LanguageId, LanguageNotFound, LanguageServerId, ParseStatus}; +use project::lsp_store::OpenLspBufferHandle; use project::{Project, ProjectPath, Worktree}; use std::collections::HashSet; use std::sync::Arc; @@ -40,7 +41,7 @@ pub async fn open_buffer_with_language_server( path: Arc, ready_languages: &mut HashSet, cx: &mut AsyncApp, -) -> Result<(Entity>, LanguageServerId, Entity)> { +) -> Result<(OpenLspBufferHandle, LanguageServerId, Entity)> { let buffer = open_buffer(project.clone(), worktree, path.clone(), cx).await?; let (lsp_open_handle, path_style) = project.update(cx, |project, cx| { @@ -50,6 +51,17 @@ pub async fn open_buffer_with_language_server( ) })?; + let language_registry = project.read_with(cx, |project, _| project.languages().clone())?; + let result = language_registry + .load_language_for_file_path(path.as_std_path()) + .await; + + if let Err(error) = result + && !error.is::() + { + anyhow::bail!(error); + } + let Some(language_id) = buffer.read_with(cx, |buffer, _cx| { buffer.language().map(|language| language.id()) })? @@ -57,9 +69,9 @@ pub async fn open_buffer_with_language_server( return Err(anyhow!("No language for {}", path.display(path_style))); }; - let log_prefix = path.display(path_style); + let log_prefix = format!("{} | ", path.display(path_style)); if !ready_languages.contains(&language_id) { - wait_for_lang_server(&project, &buffer, log_prefix.into_owned(), cx).await?; + wait_for_lang_server(&project, &buffer, log_prefix, cx).await?; ready_languages.insert(language_id); } @@ -95,7 +107,7 @@ pub fn wait_for_lang_server( log_prefix: String, cx: &mut AsyncApp, ) -> Task> { - println!("{}⏵ Waiting for language server", log_prefix); + eprintln!("{}⏵ Waiting for language server", log_prefix); let (mut tx, mut rx) = mpsc::channel(1); @@ -137,7 +149,7 @@ pub fn wait_for_lang_server( .. } = event { - println!("{}⟲ {message}", log_prefix) + eprintln!("{}⟲ {message}", log_prefix) } } }), @@ -162,7 +174,7 @@ pub fn wait_for_lang_server( cx.spawn(async move |cx| { if !has_lang_server { // some buffers never have a language server, so this aborts quickly in that case. - let timeout = cx.background_executor().timer(Duration::from_secs(5)); + let timeout = cx.background_executor().timer(Duration::from_secs(500)); futures::select! { _ = added_rx.next() => {}, _ = timeout.fuse() => { @@ -173,7 +185,7 @@ pub fn wait_for_lang_server( let timeout = cx.background_executor().timer(Duration::from_secs(60 * 5)); let result = futures::select! { _ = rx.next() => { - println!("{}⚑ Language server idle", log_prefix); + eprintln!("{}⚑ Language server idle", log_prefix); anyhow::Ok(()) }, _ = timeout.fuse() => { From 42583c1141b68f655335769f4770b3ceea84c263 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 4 Dec 2025 15:56:57 -0800 Subject: [PATCH 069/621] Reorganize edit prediction code and remove old experiments (#44187) Release Notes: - N/A --------- Co-authored-by: Agus Zubiaga Co-authored-by: Ben Kunkle --- Cargo.lock | 1272 +----- Cargo.toml | 18 +- assets/keymaps/default-linux.json | 16 +- assets/keymaps/default-macos.json | 16 +- assets/keymaps/default-windows.json | 14 +- .../cloud_llm_client/src/predict_edits_v3.rs | 88 +- crates/cloud_zeta2_prompt/Cargo.toml | 5 - .../src/cloud_zeta2_prompt.rs | 680 +-- .../src/retrieval_prompt.rs | 244 -- crates/codestral/Cargo.toml | 2 +- crates/codestral/src/codestral.rs | 13 +- crates/copilot/Cargo.toml | 2 +- crates/copilot/src/copilot.rs | 4 +- ...rs => copilot_edit_prediction_delegate.rs} | 22 +- crates/edit_prediction/Cargo.toml | 62 + .../license_examples/0bsd.txt | 0 .../license_examples/apache-2.0-ex0.txt | 0 .../license_examples/apache-2.0-ex1.txt | 0 .../license_examples/apache-2.0-ex2.txt | 0 .../license_examples/apache-2.0-ex3.txt | 0 .../license_examples/apache-2.0-ex4.txt | 0 .../license_examples/bsd-1-clause.txt | 0 .../license_examples/bsd-2-clause-ex0.txt | 0 .../license_examples/bsd-3-clause-ex0.txt | 0 .../license_examples/bsd-3-clause-ex1.txt | 0 .../license_examples/bsd-3-clause-ex2.txt | 0 .../license_examples/bsd-3-clause-ex3.txt | 0 .../license_examples/bsd-3-clause-ex4.txt | 0 .../license_examples/isc.txt | 0 .../license_examples/mit-ex0.txt | 0 .../license_examples/mit-ex1.txt | 0 .../license_examples/mit-ex2.txt | 0 .../license_examples/mit-ex3.txt | 0 .../license_examples/upl-1.0.txt | 0 .../license_examples/zlib-ex0.txt | 0 .../license_patterns/0bsd-pattern | 0 .../license_patterns/apache-2.0-pattern | 0 .../apache-2.0-reference-pattern | 0 .../license_patterns/bsd-pattern | 0 .../license_patterns/isc-pattern | 0 .../license_patterns/mit-pattern | 0 .../license_patterns/upl-1.0-pattern | 0 .../license_patterns/zlib-pattern | 0 crates/edit_prediction/src/edit_prediction.rs | 2041 ++++++++- .../src/edit_prediction_tests.rs | 1806 ++++++++ .../src/license_detection.rs | 0 .../src/onboarding_modal.rs | 0 .../src/prediction.rs | 2 +- .../{zeta => edit_prediction}/src/sweep_ai.rs | 4 +- crates/{zeta => edit_prediction}/src/udiff.rs | 0 .../src/xml_edits.rs | 0 .../src/zed_edit_prediction_delegate.rs} | 114 +- crates/{zeta => edit_prediction}/src/zeta1.rs | 20 +- .../src/zeta1/input_excerpt.rs | 0 crates/edit_prediction/src/zeta2.rs | 358 ++ .../Cargo.toml | 11 +- .../LICENSE-GPL | 0 .../build.rs | 0 .../src/evaluate.rs | 14 +- .../src/example.rs | 4 +- .../src/headless.rs | 0 .../src/main.rs | 83 +- .../src/metrics.rs | 4 +- .../src/paths.rs | 0 .../src/predict.rs | 76 +- .../src/source_location.rs | 0 .../src/util.rs | 0 crates/edit_prediction_context/Cargo.toml | 23 +- .../src/assemble_excerpts.rs | 0 .../src/declaration.rs | 350 -- .../src/declaration_scoring.rs | 539 --- .../src/edit_prediction_context.rs | 736 ++-- .../src/edit_prediction_context_tests.rs | 0 crates/edit_prediction_context/src/excerpt.rs | 73 +- .../src/fake_definition_lsp.rs | 0 crates/edit_prediction_context/src/imports.rs | 1319 ------ crates/edit_prediction_context/src/outline.rs | 126 - .../edit_prediction_context/src/reference.rs | 173 - .../src/syntax_index.rs | 1069 ----- .../src/text_similarity.rs | 314 -- crates/edit_prediction_context2/Cargo.toml | 42 - .../src/edit_prediction_context2.rs | 465 -- crates/edit_prediction_types/Cargo.toml | 17 + .../LICENSE-GPL | 0 .../src/edit_prediction_types.rs | 298 ++ .../Cargo.toml | 16 +- .../{zeta => edit_prediction_ui}/LICENSE-GPL | 0 .../src/edit_prediction_button.rs | 50 +- .../src/edit_prediction_context_view.rs} | 73 +- .../src/edit_prediction_ui.rs | 128 + .../src/rate_prediction_modal.rs | 59 +- .../src/sweep_api_token_modal.rs | 9 +- crates/editor/Cargo.toml | 2 +- crates/editor/src/edit_prediction_tests.rs | 64 +- crates/editor/src/editor.rs | 24 +- crates/editor/src/editor_tests.rs | 6 +- crates/feature_flags/src/flags.rs | 6 - crates/supermaven/Cargo.toml | 2 +- crates/supermaven/src/supermaven.rs | 4 +- ...=> supermaven_edit_prediction_delegate.rs} | 14 +- crates/zed/Cargo.toml | 5 +- crates/zed/src/main.rs | 4 +- crates/zed/src/zed.rs | 8 +- .../zed/src/zed/edit_prediction_registry.rs | 46 +- crates/zeta/Cargo.toml | 85 - crates/zeta/src/retrieval_search.rs | 490 --- crates/zeta/src/zeta.rs | 3890 ----------------- crates/zeta/src/zeta_tests.rs | 671 --- crates/zeta2_tools/Cargo.toml | 48 - crates/zeta2_tools/LICENSE-GPL | 1 - crates/zeta2_tools/src/zeta2_tools.rs | 1035 ----- crates/zeta_cli/LICENSE-GPL | 1 - crates/zeta_cli/src/syntax_retrieval_stats.rs | 1260 ------ 113 files changed, 5529 insertions(+), 15011 deletions(-) delete mode 100644 crates/cloud_zeta2_prompt/src/retrieval_prompt.rs rename crates/copilot/src/{copilot_completion_provider.rs => copilot_edit_prediction_delegate.rs} (98%) rename crates/{zeta => edit_prediction}/license_examples/0bsd.txt (100%) rename crates/{zeta => edit_prediction}/license_examples/apache-2.0-ex0.txt (100%) rename crates/{zeta => edit_prediction}/license_examples/apache-2.0-ex1.txt (100%) rename crates/{zeta => edit_prediction}/license_examples/apache-2.0-ex2.txt (100%) rename crates/{zeta => edit_prediction}/license_examples/apache-2.0-ex3.txt (100%) rename crates/{zeta => edit_prediction}/license_examples/apache-2.0-ex4.txt (100%) rename crates/{zeta => edit_prediction}/license_examples/bsd-1-clause.txt (100%) rename crates/{zeta => edit_prediction}/license_examples/bsd-2-clause-ex0.txt (100%) rename crates/{zeta => edit_prediction}/license_examples/bsd-3-clause-ex0.txt (100%) rename crates/{zeta => edit_prediction}/license_examples/bsd-3-clause-ex1.txt (100%) rename crates/{zeta => edit_prediction}/license_examples/bsd-3-clause-ex2.txt (100%) rename crates/{zeta => edit_prediction}/license_examples/bsd-3-clause-ex3.txt (100%) rename crates/{zeta => edit_prediction}/license_examples/bsd-3-clause-ex4.txt (100%) rename crates/{zeta => edit_prediction}/license_examples/isc.txt (100%) rename crates/{zeta => edit_prediction}/license_examples/mit-ex0.txt (100%) rename crates/{zeta => edit_prediction}/license_examples/mit-ex1.txt (100%) rename crates/{zeta => edit_prediction}/license_examples/mit-ex2.txt (100%) rename crates/{zeta => edit_prediction}/license_examples/mit-ex3.txt (100%) rename crates/{zeta => edit_prediction}/license_examples/upl-1.0.txt (100%) rename crates/{zeta => edit_prediction}/license_examples/zlib-ex0.txt (100%) rename crates/{zeta => edit_prediction}/license_patterns/0bsd-pattern (100%) rename crates/{zeta => edit_prediction}/license_patterns/apache-2.0-pattern (100%) rename crates/{zeta => edit_prediction}/license_patterns/apache-2.0-reference-pattern (100%) rename crates/{zeta => edit_prediction}/license_patterns/bsd-pattern (100%) rename crates/{zeta => edit_prediction}/license_patterns/isc-pattern (100%) rename crates/{zeta => edit_prediction}/license_patterns/mit-pattern (100%) rename crates/{zeta => edit_prediction}/license_patterns/upl-1.0-pattern (100%) rename crates/{zeta => edit_prediction}/license_patterns/zlib-pattern (100%) create mode 100644 crates/edit_prediction/src/edit_prediction_tests.rs rename crates/{zeta => edit_prediction}/src/license_detection.rs (100%) rename crates/{zeta => edit_prediction}/src/onboarding_modal.rs (100%) rename crates/{zeta => edit_prediction}/src/prediction.rs (99%) rename crates/{zeta => edit_prediction}/src/sweep_ai.rs (99%) rename crates/{zeta => edit_prediction}/src/udiff.rs (100%) rename crates/{zeta => edit_prediction}/src/xml_edits.rs (100%) rename crates/{zeta/src/provider.rs => edit_prediction/src/zed_edit_prediction_delegate.rs} (58%) rename crates/{zeta => edit_prediction}/src/zeta1.rs (96%) rename crates/{zeta => edit_prediction}/src/zeta1/input_excerpt.rs (100%) create mode 100644 crates/edit_prediction/src/zeta2.rs rename crates/{zeta_cli => edit_prediction_cli}/Cargo.toml (84%) rename crates/{edit_prediction_button => edit_prediction_cli}/LICENSE-GPL (100%) rename crates/{zeta_cli => edit_prediction_cli}/build.rs (100%) rename crates/{zeta_cli => edit_prediction_cli}/src/evaluate.rs (98%) rename crates/{zeta_cli => edit_prediction_cli}/src/example.rs (99%) rename crates/{zeta_cli => edit_prediction_cli}/src/headless.rs (100%) rename crates/{zeta_cli => edit_prediction_cli}/src/main.rs (84%) rename crates/{zeta_cli => edit_prediction_cli}/src/metrics.rs (99%) rename crates/{zeta_cli => edit_prediction_cli}/src/paths.rs (100%) rename crates/{zeta_cli => edit_prediction_cli}/src/predict.rs (85%) rename crates/{zeta_cli => edit_prediction_cli}/src/source_location.rs (100%) rename crates/{zeta_cli => edit_prediction_cli}/src/util.rs (100%) rename crates/{edit_prediction_context2 => edit_prediction_context}/src/assemble_excerpts.rs (100%) delete mode 100644 crates/edit_prediction_context/src/declaration.rs delete mode 100644 crates/edit_prediction_context/src/declaration_scoring.rs rename crates/{edit_prediction_context2 => edit_prediction_context}/src/edit_prediction_context_tests.rs (100%) rename crates/{edit_prediction_context2 => edit_prediction_context}/src/fake_definition_lsp.rs (100%) delete mode 100644 crates/edit_prediction_context/src/imports.rs delete mode 100644 crates/edit_prediction_context/src/outline.rs delete mode 100644 crates/edit_prediction_context/src/reference.rs delete mode 100644 crates/edit_prediction_context/src/syntax_index.rs delete mode 100644 crates/edit_prediction_context/src/text_similarity.rs delete mode 100644 crates/edit_prediction_context2/Cargo.toml delete mode 100644 crates/edit_prediction_context2/src/edit_prediction_context2.rs create mode 100644 crates/edit_prediction_types/Cargo.toml rename crates/{edit_prediction_context2 => edit_prediction_types}/LICENSE-GPL (100%) create mode 100644 crates/edit_prediction_types/src/edit_prediction_types.rs rename crates/{edit_prediction_button => edit_prediction_ui}/Cargo.toml (77%) rename crates/{zeta => edit_prediction_ui}/LICENSE-GPL (100%) rename crates/{edit_prediction_button => edit_prediction_ui}/src/edit_prediction_button.rs (97%) rename crates/{zeta2_tools/src/zeta2_context_view.rs => edit_prediction_ui/src/edit_prediction_context_view.rs} (85%) create mode 100644 crates/edit_prediction_ui/src/edit_prediction_ui.rs rename crates/{zeta => edit_prediction_ui}/src/rate_prediction_modal.rs (95%) rename crates/{edit_prediction_button => edit_prediction_ui}/src/sweep_api_token_modal.rs (92%) rename crates/supermaven/src/{supermaven_completion_provider.rs => supermaven_edit_prediction_delegate.rs} (95%) delete mode 100644 crates/zeta/Cargo.toml delete mode 100644 crates/zeta/src/retrieval_search.rs delete mode 100644 crates/zeta/src/zeta.rs delete mode 100644 crates/zeta/src/zeta_tests.rs delete mode 100644 crates/zeta2_tools/Cargo.toml delete mode 120000 crates/zeta2_tools/LICENSE-GPL delete mode 100644 crates/zeta2_tools/src/zeta2_tools.rs delete mode 120000 crates/zeta_cli/LICENSE-GPL delete mode 100644 crates/zeta_cli/src/syntax_retrieval_stats.rs diff --git a/Cargo.lock b/Cargo.lock index 6d41fbe96fac878f496e93461c180e1c184216d6..885fbe77fd17a90e4cc948d4c40166d41a26cd35 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -211,7 +211,7 @@ dependencies = [ "worktree", "zed_env_vars", "zlog", - "zstd 0.11.2+zstd.1.5.2", + "zstd", ] [[package]] @@ -680,21 +680,6 @@ dependencies = [ "syn 2.0.106", ] -[[package]] -name = "argminmax" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70f13d10a41ac8d2ec79ee34178d61e6f47a29c2edfe7ef1721c7383b0359e65" -dependencies = [ - "num-traits", -] - -[[package]] -name = "array-init-cursor" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed51fe0f224d1d4ea768be38c51f9f831dee9d05c163c11fba0b8c44387b1fc3" - [[package]] name = "arraydeque" version = "0.5.1" @@ -1278,15 +1263,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "atoi_simd" -version = "0.16.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2a49e05797ca52e312a0c658938b7d00693ef037799ef7187678f212d7684cf" -dependencies = [ - "debug_unsafe", -] - [[package]] name = "atomic" version = "0.5.3" @@ -2070,26 +2046,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bincode" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36eaf5d7b090263e8150820482d5d93cd964a81e4019913c972f4edcc6edb740" -dependencies = [ - "bincode_derive", - "serde", - "unty", -] - -[[package]] -name = "bincode_derive" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf95709a440f45e986983918d0e8a1f30a9b1df04918fc828670606804ac3c09" -dependencies = [ - "virtue", -] - [[package]] name = "bindgen" version = "0.71.1" @@ -2242,19 +2198,6 @@ dependencies = [ "profiling", ] -[[package]] -name = "blake3" -version = "1.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3888aaa89e4b2a40fca9848e400f6a658a5a3978de7be858e209cafa8be9a4a0" -dependencies = [ - "arrayref", - "arrayvec", - "cc", - "cfg-if", - "constant_time_eq 0.3.1", -] - [[package]] name = "block" version = "0.1.6" @@ -2344,12 +2287,6 @@ dependencies = [ "syn 2.0.106", ] -[[package]] -name = "boxcar" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36f64beae40a84da1b4b26ff2761a5b895c12adc41dc25aaee1c4f2bbfe97a6e" - [[package]] name = "breadcrumbs" version = "0.1.0" @@ -2516,9 +2453,6 @@ name = "bytes" version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" -dependencies = [ - "serde", -] [[package]] name = "bytes-utils" @@ -2805,15 +2739,6 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" -[[package]] -name = "castaway" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dec551ab6e7578819132c713a93c022a05d60159dc86e7a7050223577484c55a" -dependencies = [ - "rustversion", -] - [[package]] name = "cbc" version = "0.1.2" @@ -2942,16 +2867,6 @@ dependencies = [ "windows-link 0.2.1", ] -[[package]] -name = "chrono-tz" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6139a8597ed92cf816dfb33f5dd6cf0bb93a6adc938f11039f371bc5bcd26c3" -dependencies = [ - "chrono", - "phf 0.12.1", -] - [[package]] name = "chunked_transfer" version = "1.5.0" @@ -3201,12 +3116,7 @@ dependencies = [ "anyhow", "cloud_llm_client", "indoc", - "ordered-float 2.10.1", - "rustc-hash 2.1.1", - "schemars", "serde", - "serde_json", - "strum 0.27.2", ] [[package]] @@ -3314,8 +3224,8 @@ name = "codestral" version = "0.1.0" dependencies = [ "anyhow", - "edit_prediction", "edit_prediction_context", + "edit_prediction_types", "futures 0.3.31", "gpui", "http_client", @@ -3505,17 +3415,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "comfy-table" -version = "7.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b03b7db8e0b4b2fdad6c551e634134e99ec000e5c8c3b6856c65e8bbaded7a3b" -dependencies = [ - "crossterm", - "unicode-segmentation", - "unicode-width", -] - [[package]] name = "command-fds" version = "0.3.2" @@ -3569,21 +3468,6 @@ dependencies = [ "workspace", ] -[[package]] -name = "compact_str" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb1325a1cece981e8a296ab8f0f9b63ae357bd0784a9faaf548cc7b480707a" -dependencies = [ - "castaway", - "cfg-if", - "itoa", - "rustversion", - "ryu", - "serde", - "static_assertions", -] - [[package]] name = "component" version = "0.1.0" @@ -3689,12 +3573,6 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" -[[package]] -name = "constant_time_eq" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6" - [[package]] name = "context_server" version = "0.1.0" @@ -3747,7 +3625,7 @@ dependencies = [ "command_palette_hooks", "ctor", "dirs 4.0.0", - "edit_prediction", + "edit_prediction_types", "editor", "fs", "futures 0.3.31", @@ -4160,7 +4038,7 @@ dependencies = [ name = "crashes" version = "0.1.0" dependencies = [ - "bincode 1.3.3", + "bincode", "cfg-if", "crash-handler", "extension_host", @@ -4174,7 +4052,7 @@ dependencies = [ "smol", "system_specs", "windows 0.61.3", - "zstd 0.11.2+zstd.1.5.2", + "zstd", ] [[package]] @@ -4319,29 +4197,6 @@ version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" -[[package]] -name = "crossterm" -version = "0.29.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8b9f2e4c67f833b660cdb0a3523065869fb35570177239812ed4c905aeff87b" -dependencies = [ - "bitflags 2.9.4", - "crossterm_winapi", - "document-features", - "parking_lot", - "rustix 1.1.2", - "winapi", -] - -[[package]] -name = "crossterm_winapi" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acdd7c62a3665c7f6830a51635d9ac9b23ed385797f70a83bb8bafe9c572ab2b" -dependencies = [ - "winapi", -] - [[package]] name = "crunchy" version = "0.2.4" @@ -4696,12 +4551,6 @@ dependencies = [ "util", ] -[[package]] -name = "debug_unsafe" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85d3cef41d236720ed453e102153a53e4cc3d2fde848c0078a50cf249e8e3e5b" - [[package]] name = "debugger_tools" version = "0.1.0" @@ -5109,15 +4958,6 @@ dependencies = [ "zlog", ] -[[package]] -name = "document-features" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95249b50c6c185bee49034bcb378a49dc2b5dff0be90ff6616d31d64febab05d" -dependencies = [ - "litrs", -] - [[package]] name = "documented" version = "0.9.2" @@ -5267,86 +5107,112 @@ dependencies = [ name = "edit_prediction" version = "0.1.0" dependencies = [ - "client", - "gpui", - "language", -] - -[[package]] -name = "edit_prediction_button" -version = "0.1.0" -dependencies = [ + "ai_onboarding", "anyhow", + "arrayvec", + "brotli", "client", + "clock", + "cloud_api_types", "cloud_llm_client", - "codestral", + "cloud_zeta2_prompt", + "collections", "copilot", - "edit_prediction", - "editor", + "credentials_provider", + "ctor", + "db", + "edit_prediction_context", + "edit_prediction_types", "feature_flags", "fs", "futures 0.3.31", "gpui", "indoc", + "itertools 0.14.0", "language", + "language_model", + "log", "lsp", "menu", - "paths", + "open_ai", + "parking_lot", + "postage", + "pretty_assertions", "project", + "rand 0.9.2", "regex", + "release_channel", + "semver", + "serde", "serde_json", "settings", - "supermaven", + "smol", + "strsim", + "strum 0.27.2", "telemetry", - "theme", + "telemetry_events", + "thiserror 2.0.17", "ui", - "ui_input", "util", + "uuid", "workspace", + "worktree", "zed_actions", - "zeta", + "zlog", ] [[package]] -name = "edit_prediction_context" +name = "edit_prediction_cli" version = "0.1.0" dependencies = [ "anyhow", - "arrayvec", + "chrono", "clap", + "client", "cloud_llm_client", + "cloud_zeta2_prompt", "collections", + "debug_adapter_extension", + "edit_prediction", + "edit_prediction_context", + "extension", + "fs", "futures 0.3.31", "gpui", - "hashbrown 0.15.5", + "gpui_tokio", "indoc", - "itertools 0.14.0", "language", + "language_extension", + "language_model", + "language_models", + "languages", "log", - "ordered-float 2.10.1", - "postage", + "node_runtime", + "paths", "pretty_assertions", "project", - "regex", + "prompt_store", + "pulldown-cmark 0.12.2", + "release_channel", + "reqwest_client", "serde", "serde_json", "settings", - "slotmap", - "strum 0.27.2", - "text", - "tree-sitter", - "tree-sitter-c", - "tree-sitter-cpp", - "tree-sitter-go", + "shellexpand 2.1.2", + "smol", + "terminal_view", + "toml 0.8.23", "util", + "watch", "zlog", ] [[package]] -name = "edit_prediction_context2" +name = "edit_prediction_context" version = "0.1.0" dependencies = [ "anyhow", + "cloud_llm_client", "collections", "env_logger 0.11.8", "futures 0.3.31", @@ -5368,6 +5234,56 @@ dependencies = [ "zlog", ] +[[package]] +name = "edit_prediction_types" +version = "0.1.0" +dependencies = [ + "client", + "gpui", + "language", +] + +[[package]] +name = "edit_prediction_ui" +version = "0.1.0" +dependencies = [ + "anyhow", + "buffer_diff", + "client", + "cloud_llm_client", + "cloud_zeta2_prompt", + "codestral", + "command_palette_hooks", + "copilot", + "edit_prediction", + "edit_prediction_types", + "editor", + "feature_flags", + "fs", + "futures 0.3.31", + "gpui", + "indoc", + "language", + "lsp", + "markdown", + "menu", + "multi_buffer", + "paths", + "project", + "regex", + "serde_json", + "settings", + "supermaven", + "telemetry", + "text", + "theme", + "ui", + "ui_input", + "util", + "workspace", + "zed_actions", +] + [[package]] name = "editor" version = "0.1.0" @@ -5384,7 +5300,7 @@ dependencies = [ "ctor", "dap", "db", - "edit_prediction", + "edit_prediction_types", "emojis", "feature_flags", "file_icons", @@ -5723,14 +5639,8 @@ dependencies = [ ] [[package]] -name = "ethnum" -version = "1.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca81e6b4777c89fd810c25a4be2b1bd93ea034fbe58e6a75216a34c6b82c539b" - -[[package]] -name = "euclid" -version = "0.22.11" +name = "euclid" +version = "0.22.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ad9cdb4b747e485a12abb0e6566612956c7a1bafa3bdb8d682c5b6d403589e48" dependencies = [ @@ -6012,12 +5922,6 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649" -[[package]] -name = "fallible-streaming-iterator" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a" - [[package]] name = "fancy-regex" version = "0.16.2" @@ -6029,12 +5933,6 @@ dependencies = [ "regex-syntax", ] -[[package]] -name = "fast-float2" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8eb564c5c7423d25c886fb561d1e4ee69f72354d16918afa32c08811f6b6a55" - [[package]] name = "fast-srgb8" version = "1.0.0" @@ -6210,7 +6108,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc5a4e564e38c699f2880d3fda590bedc2e69f3f84cd48b457bd892ce61d0aa9" dependencies = [ "crc32fast", - "libz-rs-sys", "miniz_oxide", ] @@ -6467,16 +6364,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "fs4" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8640e34b88f7652208ce9e88b1a37a2ae95227d84abec377ccd3c5cfeb141ed4" -dependencies = [ - "rustix 1.1.2", - "windows-sys 0.59.0", -] - [[package]] name = "fs_benchmarks" version = "0.1.0" @@ -7540,7 +7427,6 @@ dependencies = [ "allocator-api2", "equivalent", "foldhash 0.1.5", - "rayon", "serde", ] @@ -7652,7 +7538,7 @@ version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13c255bdf46e07fb840d120a36dcc81f385140d7191c76a7391672675c01a55d" dependencies = [ - "bincode 1.3.3", + "bincode", "byteorder", "heed-traits", "serde", @@ -8412,7 +8298,7 @@ version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fb8251fb7bcd9ccd3725ed8deae9fe7db8e586495c9eb5b0c52e6233e5e75ea" dependencies = [ - "bincode 1.3.3", + "bincode", "crossbeam-channel", "fnv", "lazy_static", @@ -9256,15 +9142,6 @@ dependencies = [ "webrtc-sys", ] -[[package]] -name = "libz-rs-sys" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "840db8cf39d9ec4dd794376f38acc40d0fc65eec2a8f484f7fd375b84602becd" -dependencies = [ - "zlib-rs", -] - [[package]] name = "libz-sys" version = "1.1.22" @@ -9327,12 +9204,6 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "241eaef5fd12c88705a01fc1066c48c4b36e0dd4377dcdc7ec3942cea7a69956" -[[package]] -name = "litrs" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5e54036fe321fd421e10d732f155734c4e4afd610dd556d9a82833ab3ee0bed" - [[package]] name = "livekit" version = "0.7.8" @@ -9624,25 +9495,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "lz4" -version = "1.28.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a20b523e860d03443e98350ceaac5e71c6ba89aea7d960769ec3ce37f4de5af4" -dependencies = [ - "lz4-sys", -] - -[[package]] -name = "lz4-sys" -version = "1.11.1+lz4-1.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bd8c0d6c6ed0cd30b3652886bb8711dc4bb01d637a68105a3d5158039b418e6" -dependencies = [ - "cc", - "libc", -] - [[package]] name = "mac" version = "0.1.1" @@ -10505,15 +10357,6 @@ name = "notify-types" version = "2.0.0" source = "git+https://github.com/zed-industries/notify.git?rev=b4588b2e5aee68f4c0e100f140e808cbce7b1419#b4588b2e5aee68f4c0e100f140e808cbce7b1419" -[[package]] -name = "now" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d89e9874397a1f0a52fc1f197a8effd9735223cb2390e9dcc83ac6cd02923d0" -dependencies = [ - "chrono", -] - [[package]] name = "ntapi" version = "0.4.1" @@ -10909,41 +10752,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "object_store" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c1be0c6c22ec0817cdc77d3842f721a17fd30ab6965001415b5402a74e6b740" -dependencies = [ - "async-trait", - "base64 0.22.1", - "bytes 1.10.1", - "chrono", - "form_urlencoded", - "futures 0.3.31", - "http 1.3.1", - "http-body-util", - "humantime", - "hyper 1.7.0", - "itertools 0.14.0", - "parking_lot", - "percent-encoding", - "quick-xml 0.38.3", - "rand 0.9.2", - "reqwest 0.12.24", - "ring", - "serde", - "serde_json", - "serde_urlencoded", - "thiserror 2.0.17", - "tokio", - "tracing", - "url", - "walkdir", - "wasm-bindgen-futures", - "web-time", -] - [[package]] name = "ollama" version = "0.1.0" @@ -12184,16 +11992,6 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" -[[package]] -name = "planus" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3daf8e3d4b712abe1d690838f6e29fb76b76ea19589c4afa39ec30e12f62af71" -dependencies = [ - "array-init-cursor", - "hashbrown 0.15.5", -] - [[package]] name = "plist" version = "1.8.0" @@ -12261,520 +12059,6 @@ dependencies = [ "miniz_oxide", ] -[[package]] -name = "polars" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5f7feb5d56b954e691dff22a8b2d78d77433dcc93c35fe21c3777fdc121b697" -dependencies = [ - "getrandom 0.2.16", - "getrandom 0.3.4", - "polars-arrow", - "polars-core", - "polars-error", - "polars-io", - "polars-lazy", - "polars-ops", - "polars-parquet", - "polars-sql", - "polars-time", - "polars-utils", - "version_check", -] - -[[package]] -name = "polars-arrow" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32b4fed2343961b3eea3db2cee165540c3e1ad9d5782350cc55a9e76cf440148" -dependencies = [ - "atoi_simd", - "bitflags 2.9.4", - "bytemuck", - "chrono", - "chrono-tz", - "dyn-clone", - "either", - "ethnum", - "getrandom 0.2.16", - "getrandom 0.3.4", - "hashbrown 0.15.5", - "itoa", - "lz4", - "num-traits", - "polars-arrow-format", - "polars-error", - "polars-schema", - "polars-utils", - "serde", - "simdutf8", - "streaming-iterator", - "strum_macros 0.27.2", - "version_check", - "zstd 0.13.3", -] - -[[package]] -name = "polars-arrow-format" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a556ac0ee744e61e167f34c1eb0013ce740e0ee6cd8c158b2ec0b518f10e6675" -dependencies = [ - "planus", - "serde", -] - -[[package]] -name = "polars-compute" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138785beda4e4a90a025219f09d0d15a671b2be9091513ede58e05db6ad4413f" -dependencies = [ - "atoi_simd", - "bytemuck", - "chrono", - "either", - "fast-float2", - "hashbrown 0.15.5", - "itoa", - "num-traits", - "polars-arrow", - "polars-error", - "polars-utils", - "rand 0.9.2", - "ryu", - "serde", - "skiplist", - "strength_reduce", - "strum_macros 0.27.2", - "version_check", -] - -[[package]] -name = "polars-core" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e77b1f08ef6dbb032bb1d0d3365464be950df9905f6827a95b24c4ca5518901d" -dependencies = [ - "bitflags 2.9.4", - "boxcar", - "bytemuck", - "chrono", - "chrono-tz", - "comfy-table", - "either", - "hashbrown 0.15.5", - "indexmap", - "itoa", - "num-traits", - "polars-arrow", - "polars-compute", - "polars-dtype", - "polars-error", - "polars-row", - "polars-schema", - "polars-utils", - "rand 0.9.2", - "rand_distr", - "rayon", - "regex", - "serde", - "serde_json", - "strum_macros 0.27.2", - "uuid", - "version_check", - "xxhash-rust", -] - -[[package]] -name = "polars-dtype" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89c43d0ea57168be4546c4d8064479ed8b29a9c79c31a0c7c367ee734b9b7158" -dependencies = [ - "boxcar", - "hashbrown 0.15.5", - "polars-arrow", - "polars-error", - "polars-utils", - "serde", - "uuid", -] - -[[package]] -name = "polars-error" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9cb5d98f59f8b94673ee391840440ad9f0d2170afced95fc98aa86f895563c0" -dependencies = [ - "object_store", - "parking_lot", - "polars-arrow-format", - "regex", - "signal-hook", - "simdutf8", -] - -[[package]] -name = "polars-expr" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "343931b818cf136349135ba11dbc18c27683b52c3477b1ba8ca606cf5ab1965c" -dependencies = [ - "bitflags 2.9.4", - "hashbrown 0.15.5", - "num-traits", - "polars-arrow", - "polars-compute", - "polars-core", - "polars-io", - "polars-ops", - "polars-plan", - "polars-row", - "polars-time", - "polars-utils", - "rand 0.9.2", - "rayon", - "recursive", -] - -[[package]] -name = "polars-io" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10388c64b8155122488229a881d1c6f4fdc393bc988e764ab51b182fcb2307e4" -dependencies = [ - "async-trait", - "atoi_simd", - "blake3", - "bytes 1.10.1", - "chrono", - "fast-float2", - "fs4", - "futures 0.3.31", - "glob", - "hashbrown 0.15.5", - "home", - "itoa", - "memchr", - "memmap2", - "num-traits", - "object_store", - "percent-encoding", - "polars-arrow", - "polars-core", - "polars-error", - "polars-parquet", - "polars-schema", - "polars-time", - "polars-utils", - "rayon", - "regex", - "reqwest 0.12.24", - "ryu", - "serde", - "serde_json", - "simdutf8", - "tokio", - "tokio-util", - "url", -] - -[[package]] -name = "polars-lazy" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fb6e2c6c2fa4ea0c660df1c06cf56960c81e7c2683877995bae3d4e3d408147" -dependencies = [ - "bitflags 2.9.4", - "chrono", - "either", - "memchr", - "polars-arrow", - "polars-compute", - "polars-core", - "polars-expr", - "polars-io", - "polars-mem-engine", - "polars-ops", - "polars-plan", - "polars-stream", - "polars-time", - "polars-utils", - "rayon", - "version_check", -] - -[[package]] -name = "polars-mem-engine" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20a856e98e253587c28d8132a5e7e5a75cb2c44731ca090f1481d45f1d123771" -dependencies = [ - "futures 0.3.31", - "memmap2", - "polars-arrow", - "polars-core", - "polars-error", - "polars-expr", - "polars-io", - "polars-ops", - "polars-plan", - "polars-time", - "polars-utils", - "rayon", - "recursive", - "tokio", -] - -[[package]] -name = "polars-ops" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acf6062173fdc9ba05775548beb66e76643a148d9aeadc9984ed712bc4babd76" -dependencies = [ - "argminmax", - "base64 0.22.1", - "bytemuck", - "chrono", - "chrono-tz", - "either", - "hashbrown 0.15.5", - "hex", - "indexmap", - "libm", - "memchr", - "num-traits", - "polars-arrow", - "polars-compute", - "polars-core", - "polars-error", - "polars-schema", - "polars-utils", - "rayon", - "regex", - "regex-syntax", - "strum_macros 0.27.2", - "unicode-normalization", - "unicode-reverse", - "version_check", -] - -[[package]] -name = "polars-parquet" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc1d769180dec070df0dc4b89299b364bf2cfe32b218ecc4ddd8f1a49ae60669" -dependencies = [ - "async-stream", - "base64 0.22.1", - "brotli", - "bytemuck", - "ethnum", - "flate2", - "futures 0.3.31", - "hashbrown 0.15.5", - "lz4", - "num-traits", - "polars-arrow", - "polars-compute", - "polars-error", - "polars-parquet-format", - "polars-utils", - "serde", - "simdutf8", - "snap", - "streaming-decompression", - "zstd 0.13.3", -] - -[[package]] -name = "polars-parquet-format" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c025243dcfe8dbc57e94d9f82eb3bef10b565ab180d5b99bed87fd8aea319ce1" -dependencies = [ - "async-trait", - "futures 0.3.31", -] - -[[package]] -name = "polars-plan" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cd3a2e33ae4484fe407ab2d2ba5684f0889d1ccf3ad6b844103c03638e6d0a0" -dependencies = [ - "bitflags 2.9.4", - "bytemuck", - "bytes 1.10.1", - "chrono", - "chrono-tz", - "either", - "futures 0.3.31", - "hashbrown 0.15.5", - "memmap2", - "num-traits", - "percent-encoding", - "polars-arrow", - "polars-compute", - "polars-core", - "polars-error", - "polars-io", - "polars-ops", - "polars-parquet", - "polars-time", - "polars-utils", - "rayon", - "recursive", - "regex", - "sha2", - "strum_macros 0.27.2", - "version_check", -] - -[[package]] -name = "polars-row" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18734f17e0e348724df3ae65f3ee744c681117c04b041cac969dfceb05edabc0" -dependencies = [ - "bitflags 2.9.4", - "bytemuck", - "polars-arrow", - "polars-compute", - "polars-dtype", - "polars-error", - "polars-utils", -] - -[[package]] -name = "polars-schema" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e6c1ab13e04d5167661a9854ed1ea0482b2ed9b8a0f1118dabed7cd994a85e3" -dependencies = [ - "indexmap", - "polars-error", - "polars-utils", - "serde", - "version_check", -] - -[[package]] -name = "polars-sql" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4e7766da02cc1d464994404d3e88a7a0ccd4933df3627c325480fbd9bbc0a11" -dependencies = [ - "bitflags 2.9.4", - "hex", - "polars-core", - "polars-error", - "polars-lazy", - "polars-ops", - "polars-plan", - "polars-time", - "polars-utils", - "rand 0.9.2", - "regex", - "serde", - "sqlparser", -] - -[[package]] -name = "polars-stream" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31f6c6ca1ea01f9dea424d167e4f33f5ec44cd67fbfac9efd40575ed20521f14" -dependencies = [ - "async-channel 2.5.0", - "async-trait", - "atomic-waker", - "bitflags 2.9.4", - "crossbeam-channel", - "crossbeam-deque", - "crossbeam-queue", - "crossbeam-utils", - "futures 0.3.31", - "memmap2", - "parking_lot", - "percent-encoding", - "pin-project-lite", - "polars-arrow", - "polars-core", - "polars-error", - "polars-expr", - "polars-io", - "polars-mem-engine", - "polars-ops", - "polars-parquet", - "polars-plan", - "polars-utils", - "rand 0.9.2", - "rayon", - "recursive", - "slotmap", - "tokio", - "tokio-util", - "version_check", -] - -[[package]] -name = "polars-time" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6a3a6e279a7a984a0b83715660f9e880590c6129ec2104396bfa710bcd76dee" -dependencies = [ - "atoi_simd", - "bytemuck", - "chrono", - "chrono-tz", - "now", - "num-traits", - "polars-arrow", - "polars-compute", - "polars-core", - "polars-error", - "polars-ops", - "polars-utils", - "rayon", - "regex", - "strum_macros 0.27.2", -] - -[[package]] -name = "polars-utils" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57b267021b0e5422d7fbc70fd79e51b9f9a8466c585779373a18b0199e973f29" -dependencies = [ - "bincode 2.0.1", - "bytemuck", - "bytes 1.10.1", - "compact_str", - "either", - "flate2", - "foldhash 0.1.5", - "hashbrown 0.15.5", - "indexmap", - "libc", - "memmap2", - "num-traits", - "polars-error", - "rand 0.9.2", - "raw-cpuid 11.6.0", - "rayon", - "regex", - "rmp-serde", - "serde", - "serde_json", - "serde_stacker", - "slotmap", - "stacker", - "uuid", - "version_check", -] - [[package]] name = "polling" version = "3.11.0" @@ -13526,7 +12810,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42a232e7487fc2ef313d96dde7948e7a3c05101870d8985e4fd8d26aedd27b89" dependencies = [ "memchr", - "serde", ] [[package]] @@ -13860,26 +13143,6 @@ dependencies = [ "zed_actions", ] -[[package]] -name = "recursive" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0786a43debb760f491b1bc0269fe5e84155353c67482b9e60d0cfb596054b43e" -dependencies = [ - "recursive-proc-macro-impl", - "stacker", -] - -[[package]] -name = "recursive-proc-macro-impl" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76009fbe0614077fc1a2ce255e3a1881a2e3a3527097d5dc6d8212c585e7e38b" -dependencies = [ - "quote", - "syn 2.0.106", -] - [[package]] name = "redox_syscall" version = "0.2.16" @@ -14236,35 +13499,26 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", - "h2 0.4.12", "http 1.3.1", "http-body 1.0.1", "http-body-util", "hyper 1.7.0", - "hyper-rustls 0.27.7", "hyper-util", "js-sys", "log", "percent-encoding", "pin-project-lite", - "quinn", - "rustls 0.23.33", - "rustls-native-certs 0.8.2", - "rustls-pki-types", "serde", "serde_json", "serde_urlencoded", "sync_wrapper 1.0.2", "tokio", - "tokio-rustls 0.26.2", - "tokio-util", "tower 0.5.2", "tower-http 0.6.6", "tower-service", "url", "wasm-bindgen", "wasm-bindgen-futures", - "wasm-streams", "web-sys", ] @@ -14387,17 +13641,6 @@ dependencies = [ "paste", ] -[[package]] -name = "rmp-serde" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52e599a477cf9840e92f2cde9a7189e67b42c57532749bf90aea6ec10facd4db" -dependencies = [ - "byteorder", - "rmp", - "serde", -] - [[package]] name = "rmpv" version = "1.3.0" @@ -14467,7 +13710,7 @@ dependencies = [ "tracing", "util", "zlog", - "zstd 0.11.2+zstd.1.5.2", + "zstd", ] [[package]] @@ -15359,17 +14602,6 @@ dependencies = [ "serde_core", ] -[[package]] -name = "serde_stacker" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4936375d50c4be7eff22293a9344f8e46f323ed2b3c243e52f89138d9bb0f4a" -dependencies = [ - "serde", - "serde_core", - "stacker", -] - [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -15711,16 +14943,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" -[[package]] -name = "skiplist" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f354fd282d3177c2951004953e2fdc4cb342fa159bbee8b829852b6a081c8ea1" -dependencies = [ - "rand 0.9.2", - "thiserror 2.0.17", -] - [[package]] name = "skrifa" version = "0.37.0" @@ -15796,12 +15018,6 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd538fb6910ac1099850255cf94a94df6551fbdd602454387d0adb2d1ca6dead" -[[package]] -name = "snap" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b6b67fb9a61334225b5b790716f609cd58395f895b3fe8b328786812a40bc3b" - [[package]] name = "snippet" version = "0.1.0" @@ -15848,26 +15064,6 @@ dependencies = [ "workspace", ] -[[package]] -name = "soa-rs" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b75ae4668062b095fda87ba54118697bed601f07f6c68bf50289a25ca0c8c935" -dependencies = [ - "soa-rs-derive", -] - -[[package]] -name = "soa-rs-derive" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c09121507da587d3434e5929ce3321162f36bd3eff403873cb163c06b176913" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.106", -] - [[package]] name = "socket2" version = "0.5.10" @@ -15987,15 +15183,6 @@ dependencies = [ "unicode_categories", ] -[[package]] -name = "sqlparser" -version = "0.53.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05a528114c392209b3264855ad491fcce534b94a38771b0a0b97a79379275ce8" -dependencies = [ - "log", -] - [[package]] name = "sqlx" version = "0.8.6" @@ -16297,15 +15484,6 @@ dependencies = [ "ui", ] -[[package]] -name = "streaming-decompression" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf6cc3b19bfb128a8ad11026086e31d3ce9ad23f8ea37354b31383a187c44cf3" -dependencies = [ - "fallible-streaming-iterator", -] - [[package]] name = "streaming-iterator" version = "0.1.9" @@ -16447,7 +15625,7 @@ dependencies = [ "anyhow", "client", "collections", - "edit_prediction", + "edit_prediction_types", "editor", "env_logger 0.11.8", "futures 0.3.31", @@ -17691,7 +16869,6 @@ dependencies = [ "futures-core", "futures-io", "futures-sink", - "futures-util", "pin-project-lite", "tokio", ] @@ -18547,15 +17724,6 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e70f2a8b45122e719eb623c01822704c4e0907e7e426a05927e1a1cfff5b75d0" -[[package]] -name = "unicode-reverse" -version = "1.0.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b6f4888ebc23094adfb574fdca9fdc891826287a6397d2cd28802ffd6f20c76" -dependencies = [ - "unicode-segmentation", -] - [[package]] name = "unicode-script" version = "0.5.7" @@ -18616,12 +17784,6 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" -[[package]] -name = "unty" -version = "0.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d49784317cd0d1ee7ec5c716dd598ec5b4483ea832a2dced265471cc0f690ae" - [[package]] name = "url" version = "2.5.7" @@ -18897,12 +18059,6 @@ dependencies = [ "settings", ] -[[package]] -name = "virtue" -version = "0.0.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "051eb1abcf10076295e815102942cc58f9d5e3b4560e46e53c21e8ff6f3af7b1" - [[package]] name = "vscode_theme" version = "0.2.0" @@ -21058,12 +20214,6 @@ dependencies = [ "toml_edit 0.22.27", ] -[[package]] -name = "xxhash-rust" -version = "0.8.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdd20c5420375476fbd4394763288da7eb0cc0b8c11deed431a91562af7335d3" - [[package]] name = "yaml-rust2" version = "0.8.1" @@ -21251,7 +20401,7 @@ dependencies = [ "audio", "auto_update", "auto_update_ui", - "bincode 1.3.3", + "bincode", "breadcrumbs", "call", "channel", @@ -21273,7 +20423,8 @@ dependencies = [ "debugger_tools", "debugger_ui", "diagnostics", - "edit_prediction_button", + "edit_prediction", + "edit_prediction_ui", "editor", "env_logger 0.11.8", "extension", @@ -21384,8 +20535,6 @@ dependencies = [ "zed-reqwest", "zed_actions", "zed_env_vars", - "zeta", - "zeta2_tools", "zlog", "zlog_settings", ] @@ -21697,151 +20846,6 @@ dependencies = [ "syn 2.0.106", ] -[[package]] -name = "zeta" -version = "0.1.0" -dependencies = [ - "ai_onboarding", - "anyhow", - "arrayvec", - "brotli", - "buffer_diff", - "client", - "clock", - "cloud_api_types", - "cloud_llm_client", - "cloud_zeta2_prompt", - "collections", - "command_palette_hooks", - "copilot", - "credentials_provider", - "ctor", - "db", - "edit_prediction", - "edit_prediction_context", - "edit_prediction_context2", - "editor", - "feature_flags", - "fs", - "futures 0.3.31", - "gpui", - "indoc", - "itertools 0.14.0", - "language", - "language_model", - "log", - "lsp", - "markdown", - "menu", - "open_ai", - "parking_lot", - "postage", - "pretty_assertions", - "project", - "rand 0.9.2", - "regex", - "release_channel", - "semver", - "serde", - "serde_json", - "settings", - "smol", - "strsim", - "strum 0.27.2", - "telemetry", - "telemetry_events", - "theme", - "thiserror 2.0.17", - "ui", - "util", - "uuid", - "workspace", - "worktree", - "zed_actions", - "zlog", -] - -[[package]] -name = "zeta2_tools" -version = "0.1.0" -dependencies = [ - "anyhow", - "clap", - "client", - "cloud_llm_client", - "collections", - "edit_prediction_context", - "editor", - "feature_flags", - "futures 0.3.31", - "gpui", - "indoc", - "language", - "multi_buffer", - "pretty_assertions", - "project", - "serde", - "serde_json", - "settings", - "telemetry", - "text", - "ui", - "ui_input", - "util", - "workspace", - "zeta", - "zlog", -] - -[[package]] -name = "zeta_cli" -version = "0.1.0" -dependencies = [ - "anyhow", - "chrono", - "clap", - "client", - "cloud_llm_client", - "cloud_zeta2_prompt", - "collections", - "debug_adapter_extension", - "edit_prediction_context", - "extension", - "fs", - "futures 0.3.31", - "gpui", - "gpui_tokio", - "indoc", - "language", - "language_extension", - "language_model", - "language_models", - "languages", - "log", - "node_runtime", - "ordered-float 2.10.1", - "paths", - "polars", - "pretty_assertions", - "project", - "prompt_store", - "pulldown-cmark 0.12.2", - "release_channel", - "reqwest_client", - "serde", - "serde_json", - "settings", - "shellexpand 2.1.2", - "smol", - "soa-rs", - "terminal_view", - "toml 0.8.23", - "util", - "watch", - "zeta", - "zlog", -] - [[package]] name = "zip" version = "0.6.6" @@ -21851,7 +20855,7 @@ dependencies = [ "aes", "byteorder", "bzip2", - "constant_time_eq 0.1.5", + "constant_time_eq", "crc32fast", "crossbeam-utils", "flate2", @@ -21859,7 +20863,7 @@ dependencies = [ "pbkdf2 0.11.0", "sha1", "time", - "zstd 0.11.2+zstd.1.5.2", + "zstd", ] [[package]] @@ -21877,12 +20881,6 @@ dependencies = [ "thiserror 1.0.69", ] -[[package]] -name = "zlib-rs" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f06ae92f42f5e5c42443fd094f245eb656abf56dd7cce9b8b263236565e00f2" - [[package]] name = "zlog" version = "0.1.0" @@ -21910,16 +20908,7 @@ version = "0.11.2+zstd.1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4" dependencies = [ - "zstd-safe 5.0.2+zstd.1.5.2", -] - -[[package]] -name = "zstd" -version = "0.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91ee311a569c327171651566e07972200e76fcfe2242a4fa446149a3881c08a" -dependencies = [ - "zstd-safe 7.2.4", + "zstd-safe", ] [[package]] @@ -21932,15 +20921,6 @@ dependencies = [ "zstd-sys", ] -[[package]] -name = "zstd-safe" -version = "7.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f49c4d5f0abb602a93fb8736af2a4f4dd9512e36f7f570d66e65ff867ed3b9d" -dependencies = [ - "zstd-sys", -] - [[package]] name = "zstd-sys" version = "2.0.16+zstd.1.5.7" diff --git a/Cargo.toml b/Cargo.toml index 62a44dbf35fefbf02a1b570146b0bf24cea6dcd8..83bc42e353f6462148abe15327373a3d57a029e8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -54,10 +54,9 @@ members = [ "crates/diagnostics", "crates/docs_preprocessor", "crates/edit_prediction", - "crates/edit_prediction_button", + "crates/edit_prediction_types", + "crates/edit_prediction_ui", "crates/edit_prediction_context", - "crates/edit_prediction_context2", - "crates/zeta2_tools", "crates/editor", "crates/eval", "crates/eval_utils", @@ -202,8 +201,7 @@ members = [ "crates/zed", "crates/zed_actions", "crates/zed_env_vars", - "crates/zeta", - "crates/zeta_cli", + "crates/edit_prediction_cli", "crates/zlog", "crates/zlog_settings", @@ -314,11 +312,9 @@ http_client = { path = "crates/http_client" } http_client_tls = { path = "crates/http_client_tls" } icons = { path = "crates/icons" } image_viewer = { path = "crates/image_viewer" } -edit_prediction = { path = "crates/edit_prediction" } -edit_prediction_button = { path = "crates/edit_prediction_button" } +edit_prediction_types = { path = "crates/edit_prediction_types" } +edit_prediction_ui = { path = "crates/edit_prediction_ui" } edit_prediction_context = { path = "crates/edit_prediction_context" } -edit_prediction_context2 = { path = "crates/edit_prediction_context2" } -zeta2_tools = { path = "crates/zeta2_tools" } inspector_ui = { path = "crates/inspector_ui" } install_cli = { path = "crates/install_cli" } journal = { path = "crates/journal" } @@ -435,7 +431,7 @@ x_ai = { path = "crates/x_ai" } zed = { path = "crates/zed" } zed_actions = { path = "crates/zed_actions" } zed_env_vars = { path = "crates/zed_env_vars" } -zeta = { path = "crates/zeta" } +edit_prediction = { path = "crates/edit_prediction" } zlog = { path = "crates/zlog" } zlog_settings = { path = "crates/zlog_settings" } @@ -830,7 +826,7 @@ feature_flags = { codegen-units = 1 } file_icons = { codegen-units = 1 } fsevent = { codegen-units = 1 } image_viewer = { codegen-units = 1 } -edit_prediction_button = { codegen-units = 1 } +edit_prediction_ui = { codegen-units = 1 } install_cli = { codegen-units = 1 } journal = { codegen-units = 1 } json_schema_store = { codegen-units = 1 } diff --git a/assets/keymaps/default-linux.json b/assets/keymaps/default-linux.json index 5de5b9daae27113807cb6e97eda335a419f18ac9..0b001f31790c7f8211a6b44d227c15a6ff605ca4 100644 --- a/assets/keymaps/default-linux.json +++ b/assets/keymaps/default-linux.json @@ -41,7 +41,7 @@ "ctrl-f11": "debugger::StepInto", "shift-f11": "debugger::StepOut", "f11": "zed::ToggleFullScreen", - "ctrl-alt-z": "edit_prediction::RateCompletions", + "ctrl-alt-z": "edit_prediction::RatePredictions", "ctrl-alt-shift-i": "edit_prediction::ToggleMenu", "ctrl-alt-l": "lsp_tool::ToggleMenu" } @@ -1322,18 +1322,10 @@ } }, { - "context": "Zeta2Feedback > Editor", + "context": "EditPredictionContext > Editor", "bindings": { - "enter": "editor::Newline", - "ctrl-enter up": "dev::Zeta2RatePredictionPositive", - "ctrl-enter down": "dev::Zeta2RatePredictionNegative" - } - }, - { - "context": "Zeta2Context > Editor", - "bindings": { - "alt-left": "dev::Zeta2ContextGoBack", - "alt-right": "dev::Zeta2ContextGoForward" + "alt-left": "dev::EditPredictionContextGoBack", + "alt-right": "dev::EditPredictionContextGoForward" } }, { diff --git a/assets/keymaps/default-macos.json b/assets/keymaps/default-macos.json index 2fadafb6ca95f81de28165b23e4063dc7a0c38d8..e4595242d570628e2e70c43b66d14a0f9820512b 100644 --- a/assets/keymaps/default-macos.json +++ b/assets/keymaps/default-macos.json @@ -47,7 +47,7 @@ "cmd-m": "zed::Minimize", "fn-f": "zed::ToggleFullScreen", "ctrl-cmd-f": "zed::ToggleFullScreen", - "ctrl-cmd-z": "edit_prediction::RateCompletions", + "ctrl-cmd-z": "edit_prediction::RatePredictions", "ctrl-cmd-i": "edit_prediction::ToggleMenu", "ctrl-cmd-l": "lsp_tool::ToggleMenu", "ctrl-cmd-c": "editor::DisplayCursorNames" @@ -1427,18 +1427,10 @@ } }, { - "context": "Zeta2Feedback > Editor", + "context": "EditPredictionContext > Editor", "bindings": { - "enter": "editor::Newline", - "cmd-enter up": "dev::Zeta2RatePredictionPositive", - "cmd-enter down": "dev::Zeta2RatePredictionNegative" - } - }, - { - "context": "Zeta2Context > Editor", - "bindings": { - "alt-left": "dev::Zeta2ContextGoBack", - "alt-right": "dev::Zeta2ContextGoForward" + "alt-left": "dev::EditPredictionContextGoBack", + "alt-right": "dev::EditPredictionContextGoForward" } }, { diff --git a/assets/keymaps/default-windows.json b/assets/keymaps/default-windows.json index 8cf77f65813701fd42e3a6948b660368a24fd4e4..b625e7c7018c0f4c8277fcf3f739a8f06361c4df 100644 --- a/assets/keymaps/default-windows.json +++ b/assets/keymaps/default-windows.json @@ -1341,18 +1341,10 @@ } }, { - "context": "Zeta2Feedback > Editor", + "context": "EditPredictionContext > Editor", "bindings": { - "enter": "editor::Newline", - "ctrl-enter up": "dev::Zeta2RatePredictionPositive", - "ctrl-enter down": "dev::Zeta2RatePredictionNegative" - } - }, - { - "context": "Zeta2Context > Editor", - "bindings": { - "alt-left": "dev::Zeta2ContextGoBack", - "alt-right": "dev::Zeta2ContextGoForward" + "alt-left": "dev::EditPredictionContextGoBack", + "alt-right": "dev::EditPredictionContextGoForward" } }, { diff --git a/crates/cloud_llm_client/src/predict_edits_v3.rs b/crates/cloud_llm_client/src/predict_edits_v3.rs index de8d69dc14870c5583679753c9a75a477e0cc759..9e590dc4cf48a82ecdda8b007c38ab15f3b602be 100644 --- a/crates/cloud_llm_client/src/predict_edits_v3.rs +++ b/crates/cloud_llm_client/src/predict_edits_v3.rs @@ -31,18 +31,10 @@ pub struct PredictEditsRequest { /// Within `signatures` pub excerpt_parent: Option, #[serde(skip_serializing_if = "Vec::is_empty", default)] - pub included_files: Vec, - #[serde(skip_serializing_if = "Vec::is_empty", default)] - pub signatures: Vec, - #[serde(skip_serializing_if = "Vec::is_empty", default)] - pub referenced_declarations: Vec, + pub related_files: Vec, pub events: Vec>, #[serde(default)] pub can_collect_data: bool, - #[serde(skip_serializing_if = "Vec::is_empty", default)] - pub diagnostic_groups: Vec, - #[serde(skip_serializing_if = "is_default", default)] - pub diagnostic_groups_truncated: bool, /// Info about the git repository state, only present when can_collect_data is true. #[serde(skip_serializing_if = "Option::is_none", default)] pub git_info: Option, @@ -58,7 +50,7 @@ pub struct PredictEditsRequest { } #[derive(Debug, Clone, Serialize, Deserialize)] -pub struct IncludedFile { +pub struct RelatedFile { pub path: Arc, pub max_row: Line, pub excerpts: Vec, @@ -72,11 +64,9 @@ pub struct Excerpt { #[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, EnumIter)] pub enum PromptFormat { - MarkedExcerpt, - LabeledSections, - NumLinesUniDiff, + /// XML old_tex/new_text OldTextNewText, - /// Prompt format intended for use via zeta_cli + /// Prompt format intended for use via edit_prediction_cli OnlySnippets, /// One-sentence instructions used in fine-tuned models Minimal, @@ -87,7 +77,7 @@ pub enum PromptFormat { } impl PromptFormat { - pub const DEFAULT: PromptFormat = PromptFormat::NumLinesUniDiff; + pub const DEFAULT: PromptFormat = PromptFormat::Minimal; } impl Default for PromptFormat { @@ -105,10 +95,7 @@ impl PromptFormat { impl std::fmt::Display for PromptFormat { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - PromptFormat::MarkedExcerpt => write!(f, "Marked Excerpt"), - PromptFormat::LabeledSections => write!(f, "Labeled Sections"), PromptFormat::OnlySnippets => write!(f, "Only Snippets"), - PromptFormat::NumLinesUniDiff => write!(f, "Numbered Lines / Unified Diff"), PromptFormat::OldTextNewText => write!(f, "Old Text / New Text"), PromptFormat::Minimal => write!(f, "Minimal"), PromptFormat::MinimalQwen => write!(f, "Minimal + Qwen FIM"), @@ -178,67 +165,6 @@ impl<'a> std::fmt::Display for DiffPathFmt<'a> { } } -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct Signature { - pub text: String, - pub text_is_truncated: bool, - #[serde(skip_serializing_if = "Option::is_none", default)] - pub parent_index: Option, - /// Range of `text` within the file, possibly truncated according to `text_is_truncated`. The - /// file is implicitly the file that contains the descendant declaration or excerpt. - pub range: Range, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct ReferencedDeclaration { - pub path: Arc, - pub text: String, - pub text_is_truncated: bool, - /// Range of `text` within file, possibly truncated according to `text_is_truncated` - pub range: Range, - /// Range within `text` - pub signature_range: Range, - /// Index within `signatures`. - #[serde(skip_serializing_if = "Option::is_none", default)] - pub parent_index: Option, - pub score_components: DeclarationScoreComponents, - pub signature_score: f32, - pub declaration_score: f32, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct DeclarationScoreComponents { - pub is_same_file: bool, - pub is_referenced_nearby: bool, - pub is_referenced_in_breadcrumb: bool, - pub reference_count: usize, - pub same_file_declaration_count: usize, - pub declaration_count: usize, - pub reference_line_distance: u32, - pub declaration_line_distance: u32, - pub excerpt_vs_item_jaccard: f32, - pub excerpt_vs_signature_jaccard: f32, - pub adjacent_vs_item_jaccard: f32, - pub adjacent_vs_signature_jaccard: f32, - pub excerpt_vs_item_weighted_overlap: f32, - pub excerpt_vs_signature_weighted_overlap: f32, - pub adjacent_vs_item_weighted_overlap: f32, - pub adjacent_vs_signature_weighted_overlap: f32, - pub path_import_match_count: usize, - pub wildcard_path_import_match_count: usize, - pub import_similarity: f32, - pub max_import_similarity: f32, - pub normalized_import_similarity: f32, - pub wildcard_import_similarity: f32, - pub normalized_wildcard_import_similarity: f32, - pub included_by_others: usize, - pub includes_others: usize, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(transparent)] -pub struct DiagnosticGroup(pub Box); - #[derive(Debug, Clone, Serialize, Deserialize)] pub struct PredictEditsResponse { pub request_id: Uuid, @@ -262,10 +188,6 @@ pub struct Edit { pub content: String, } -fn is_default(value: &T) -> bool { - *value == T::default() -} - #[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, PartialOrd, Eq, Ord)] pub struct Point { pub line: Line, diff --git a/crates/cloud_zeta2_prompt/Cargo.toml b/crates/cloud_zeta2_prompt/Cargo.toml index fa8246950f8d03029388e0276954de946efc2346..a15e3fe43c28349920433272c4040ccc58ff4cb4 100644 --- a/crates/cloud_zeta2_prompt/Cargo.toml +++ b/crates/cloud_zeta2_prompt/Cargo.toml @@ -15,9 +15,4 @@ path = "src/cloud_zeta2_prompt.rs" anyhow.workspace = true cloud_llm_client.workspace = true indoc.workspace = true -ordered-float.workspace = true -rustc-hash.workspace = true -schemars.workspace = true serde.workspace = true -serde_json.workspace = true -strum.workspace = true diff --git a/crates/cloud_zeta2_prompt/src/cloud_zeta2_prompt.rs b/crates/cloud_zeta2_prompt/src/cloud_zeta2_prompt.rs index d67190c17556c5eb8b901e9baad73cc2691a9c78..62bfa45f47d0fdfefa9fbd72320c0ddee71cbc47 100644 --- a/crates/cloud_zeta2_prompt/src/cloud_zeta2_prompt.rs +++ b/crates/cloud_zeta2_prompt/src/cloud_zeta2_prompt.rs @@ -1,20 +1,12 @@ -//! Zeta2 prompt planning and generation code shared with cloud. -pub mod retrieval_prompt; - -use anyhow::{Context as _, Result, anyhow}; +use anyhow::Result; use cloud_llm_client::predict_edits_v3::{ - self, DiffPathFmt, Event, Excerpt, IncludedFile, Line, Point, PromptFormat, - ReferencedDeclaration, + self, DiffPathFmt, Event, Excerpt, Line, Point, PromptFormat, RelatedFile, }; use indoc::indoc; -use ordered_float::OrderedFloat; -use rustc_hash::{FxHashMap, FxHashSet}; -use serde::Serialize; use std::cmp; use std::fmt::Write; +use std::path::Path; use std::sync::Arc; -use std::{cmp::Reverse, collections::BinaryHeap, ops::Range, path::Path}; -use strum::{EnumIter, IntoEnumIterator}; pub const DEFAULT_MAX_PROMPT_BYTES: usize = 10 * 1024; @@ -24,69 +16,6 @@ pub const EDITABLE_REGION_START_MARKER_WITH_NEWLINE: &str = "<|editable_region_s /// NOTE: Differs from zed version of constant - includes a newline pub const EDITABLE_REGION_END_MARKER_WITH_NEWLINE: &str = "<|editable_region_end|>\n"; -// TODO: use constants for markers? -const MARKED_EXCERPT_INSTRUCTIONS: &str = indoc! {" - You are a code completion assistant and your task is to analyze user edits and then rewrite an excerpt that the user provides, suggesting the appropriate edits within the excerpt, taking into account the cursor location. - - The excerpt to edit will be wrapped in markers <|editable_region_start|> and <|editable_region_end|>. The cursor position is marked with <|user_cursor|>. Please respond with edited code for that region. - - Other code is provided for context, and `…` indicates when code has been skipped. - - ## Edit History - -"}; - -const LABELED_SECTIONS_INSTRUCTIONS: &str = indoc! {r#" - You are a code completion assistant and your task is to analyze user edits, and suggest an edit to one of the provided sections of code. - - Sections of code are grouped by file and then labeled by `<|section_N|>` (e.g `<|section_8|>`). - - The cursor position is marked with `<|user_cursor|>` and it will appear within a special section labeled `<|current_section|>`. Prefer editing the current section until no more changes are needed within it. - - Respond ONLY with the name of the section to edit on a single line, followed by all of the code that should replace that section. For example: - - <|current_section|> - for i in 0..16 { - println!("{i}"); - } - - ## Edit History - -"#}; - -const NUMBERED_LINES_INSTRUCTIONS: &str = indoc! {r#" - # Instructions - - You are an edit prediction agent in a code editor. - Your job is to predict the next edit that the user will make, - based on their last few edits and their current cursor location. - - ## Output Format - - You must briefly explain your understanding of the user's goal, in one - or two sentences, and then specify their next edit in the form of a - unified diff, like this: - - ``` - --- a/src/myapp/cli.py - +++ b/src/myapp/cli.py - @@ ... @@ - import os - import time - import sys - +from constants import LOG_LEVEL_WARNING - @@ ... @@ - config.headless() - config.set_interactive(false) - -config.set_log_level(LOG_L) - +config.set_log_level(LOG_LEVEL_WARNING) - config.set_use_color(True) - ``` - - ## Edit History - -"#}; - const STUDENT_MODEL_INSTRUCTIONS: &str = indoc! {r#" You are a code completion assistant that analyzes edit history to identify and systematically complete incomplete refactorings or patterns across the entire codebase. @@ -94,20 +23,6 @@ const STUDENT_MODEL_INSTRUCTIONS: &str = indoc! {r#" "#}; -const UNIFIED_DIFF_REMINDER: &str = indoc! {" - --- - - Analyze the edit history and the files, then provide the unified diff for your predicted edits. - Do not include the cursor marker in your output. - Your diff should include edited file paths in its file headers (lines beginning with `---` and `+++`). - Do not include line numbers in the hunk headers, use `@@ ... @@`. - Removed lines begin with `-`. - Added lines begin with `+`. - Context lines begin with an extra space. - Context and removed lines are used to match the target edit location, so make sure to include enough of them - to uniquely identify it amongst all excerpts of code provided. -"}; - const MINIMAL_PROMPT_REMINDER: &str = indoc! {" --- @@ -164,49 +79,25 @@ const OLD_TEXT_NEW_TEXT_REMINDER: &str = indoc! {r#" Remember that the edits in the edit history have already been applied. "#}; -pub fn build_prompt( - request: &predict_edits_v3::PredictEditsRequest, -) -> Result<(String, SectionLabels)> { - let mut section_labels = Default::default(); - +pub fn build_prompt(request: &predict_edits_v3::PredictEditsRequest) -> Result { let prompt_data = PromptData { events: request.events.clone(), cursor_point: request.cursor_point, cursor_path: request.excerpt_path.clone(), - included_files: request.included_files.clone(), + included_files: request.related_files.clone(), }; match request.prompt_format { PromptFormat::MinimalQwen => { - return Ok((MinimalQwenPrompt.render(&prompt_data), section_labels)); + return Ok(MinimalQwenPrompt.render(&prompt_data)); } PromptFormat::SeedCoder1120 => { - return Ok((SeedCoder1120Prompt.render(&prompt_data), section_labels)); + return Ok(SeedCoder1120Prompt.render(&prompt_data)); } _ => (), }; - let mut insertions = match request.prompt_format { - PromptFormat::MarkedExcerpt => vec![ - ( - Point { - line: request.excerpt_line_range.start, - column: 0, - }, - EDITABLE_REGION_START_MARKER_WITH_NEWLINE, - ), - (request.cursor_point, CURSOR_MARKER), - ( - Point { - line: request.excerpt_line_range.end, - column: 0, - }, - EDITABLE_REGION_END_MARKER_WITH_NEWLINE, - ), - ], - PromptFormat::LabeledSections - | PromptFormat::NumLinesUniDiff - | PromptFormat::Minimal - | PromptFormat::OldTextNewText => { + let insertions = match request.prompt_format { + PromptFormat::Minimal | PromptFormat::OldTextNewText => { vec![(request.cursor_point, CURSOR_MARKER)] } PromptFormat::OnlySnippets => vec![], @@ -215,9 +106,6 @@ pub fn build_prompt( }; let mut prompt = match request.prompt_format { - PromptFormat::MarkedExcerpt => MARKED_EXCERPT_INSTRUCTIONS.to_string(), - PromptFormat::LabeledSections => LABELED_SECTIONS_INSTRUCTIONS.to_string(), - PromptFormat::NumLinesUniDiff => NUMBERED_LINES_INSTRUCTIONS.to_string(), PromptFormat::OldTextNewText => XML_TAGS_INSTRUCTIONS.to_string(), PromptFormat::OnlySnippets => String::new(), PromptFormat::Minimal => STUDENT_MODEL_INSTRUCTIONS.to_string(), @@ -247,7 +135,7 @@ pub fn build_prompt( You can only edit exactly this part of the file. We prepend line numbers (e.g., `123|`); they are not part of the file.) "}, - PromptFormat::NumLinesUniDiff | PromptFormat::OldTextNewText => indoc! {" + PromptFormat::OldTextNewText => indoc! {" ## Code Excerpts Here is some excerpts of code that you should take into account to predict the next edit. @@ -263,64 +151,51 @@ pub fn build_prompt( Lines starting with `…` indicate omitted line ranges. These may appear inside multi-line code constructs. "}, - _ => indoc! {" + PromptFormat::OnlySnippets | PromptFormat::MinimalQwen | PromptFormat::SeedCoder1120 => { + indoc! {" ## Code Excerpts The cursor marker <|user_cursor|> indicates the current user cursor position. The file is in current state, edits from edit history have been applied. - "}, + "} + } }; prompt.push_str(excerpts_preamble); prompt.push('\n'); - if !request.referenced_declarations.is_empty() || !request.signatures.is_empty() { - let syntax_based_prompt = SyntaxBasedPrompt::populate(request)?; - section_labels = syntax_based_prompt.write(&mut insertions, &mut prompt)?; - } else { - if request.prompt_format == PromptFormat::LabeledSections { - anyhow::bail!("PromptFormat::LabeledSections cannot be used with ContextMode::Llm"); - } - - let include_line_numbers = matches!( - request.prompt_format, - PromptFormat::NumLinesUniDiff | PromptFormat::Minimal - ); - for related_file in &request.included_files { - if request.prompt_format == PromptFormat::Minimal { - write_codeblock_with_filename( - &related_file.path, - &related_file.excerpts, - if related_file.path == request.excerpt_path { - &insertions - } else { - &[] - }, - related_file.max_row, - include_line_numbers, - &mut prompt, - ); - } else { - write_codeblock( - &related_file.path, - &related_file.excerpts, - if related_file.path == request.excerpt_path { - &insertions - } else { - &[] - }, - related_file.max_row, - include_line_numbers, - &mut prompt, - ); - } + let include_line_numbers = matches!(request.prompt_format, PromptFormat::Minimal); + for related_file in &request.related_files { + if request.prompt_format == PromptFormat::Minimal { + write_codeblock_with_filename( + &related_file.path, + &related_file.excerpts, + if related_file.path == request.excerpt_path { + &insertions + } else { + &[] + }, + related_file.max_row, + include_line_numbers, + &mut prompt, + ); + } else { + write_codeblock( + &related_file.path, + &related_file.excerpts, + if related_file.path == request.excerpt_path { + &insertions + } else { + &[] + }, + related_file.max_row, + include_line_numbers, + &mut prompt, + ); } } match request.prompt_format { - PromptFormat::NumLinesUniDiff => { - prompt.push_str(UNIFIED_DIFF_REMINDER); - } PromptFormat::OldTextNewText => { prompt.push_str(OLD_TEXT_NEW_TEXT_REMINDER); } @@ -330,7 +205,7 @@ pub fn build_prompt( _ => {} } - Ok((prompt, section_labels)) + Ok(prompt) } pub fn generation_params(prompt_format: PromptFormat) -> GenerationParams { @@ -444,476 +319,11 @@ pub fn push_events(output: &mut String, events: &[Arc]) writeln!(output, "`````\n").unwrap(); } -pub struct SyntaxBasedPrompt<'a> { - request: &'a predict_edits_v3::PredictEditsRequest, - /// Snippets to include in the prompt. These may overlap - they are merged / deduplicated in - /// `to_prompt_string`. - snippets: Vec>, - budget_used: usize, -} - -#[derive(Clone, Debug)] -pub struct PlannedSnippet<'a> { - path: Arc, - range: Range, - text: &'a str, - // TODO: Indicate this in the output - #[allow(dead_code)] - text_is_truncated: bool, -} - -#[derive(EnumIter, Clone, Copy, PartialEq, Eq, Hash, Debug, PartialOrd, Ord)] -pub enum DeclarationStyle { - Signature, - Declaration, -} - -#[derive(Default, Clone, Debug, Serialize)] -pub struct SectionLabels { - pub excerpt_index: usize, - pub section_ranges: Vec<(Arc, Range)>, -} - -impl<'a> SyntaxBasedPrompt<'a> { - /// Greedy one-pass knapsack algorithm to populate the prompt plan. Does the following: - /// - /// Initializes a priority queue by populating it with each snippet, finding the - /// DeclarationStyle that minimizes `score_density = score / snippet.range(style).len()`. When a - /// "signature" snippet is popped, insert an entry for the "declaration" variant that reflects - /// the cost of upgrade. - /// - /// TODO: Implement an early halting condition. One option might be to have another priority - /// queue where the score is the size, and update it accordingly. Another option might be to - /// have some simpler heuristic like bailing after N failed insertions, or based on how much - /// budget is left. - /// - /// TODO: Has the current known sources of imprecision: - /// - /// * Does not consider snippet overlap when ranking. For example, it might add a field to the - /// plan even though the containing struct is already included. - /// - /// * Does not consider cost of signatures when ranking snippets - this is tricky since - /// signatures may be shared by multiple snippets. - /// - /// * Does not include file paths / other text when considering max_bytes. - pub fn populate(request: &'a predict_edits_v3::PredictEditsRequest) -> Result { - let mut this = Self { - request, - snippets: Vec::new(), - budget_used: request.excerpt.len(), - }; - let mut included_parents = FxHashSet::default(); - let additional_parents = this.additional_parent_signatures( - &request.excerpt_path, - request.excerpt_parent, - &included_parents, - )?; - this.add_parents(&mut included_parents, additional_parents); - - let max_bytes = request.prompt_max_bytes.unwrap_or(DEFAULT_MAX_PROMPT_BYTES); - - if this.budget_used > max_bytes { - return Err(anyhow!( - "Excerpt + signatures size of {} already exceeds budget of {}", - this.budget_used, - max_bytes - )); - } - - #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)] - struct QueueEntry { - score_density: OrderedFloat, - declaration_index: usize, - style: DeclarationStyle, - } - - // Initialize priority queue with the best score for each snippet. - let mut queue: BinaryHeap = BinaryHeap::new(); - for (declaration_index, declaration) in request.referenced_declarations.iter().enumerate() { - let (style, score_density) = DeclarationStyle::iter() - .map(|style| { - ( - style, - OrderedFloat(declaration_score_density(&declaration, style)), - ) - }) - .max_by_key(|(_, score_density)| *score_density) - .unwrap(); - queue.push(QueueEntry { - score_density, - declaration_index, - style, - }); - } - - // Knapsack selection loop - while let Some(queue_entry) = queue.pop() { - let Some(declaration) = request - .referenced_declarations - .get(queue_entry.declaration_index) - else { - return Err(anyhow!( - "Invalid declaration index {}", - queue_entry.declaration_index - )); - }; - - let mut additional_bytes = declaration_size(declaration, queue_entry.style); - if this.budget_used + additional_bytes > max_bytes { - continue; - } - - let additional_parents = this.additional_parent_signatures( - &declaration.path, - declaration.parent_index, - &mut included_parents, - )?; - additional_bytes += additional_parents - .iter() - .map(|(_, snippet)| snippet.text.len()) - .sum::(); - if this.budget_used + additional_bytes > max_bytes { - continue; - } - - this.budget_used += additional_bytes; - this.add_parents(&mut included_parents, additional_parents); - let planned_snippet = match queue_entry.style { - DeclarationStyle::Signature => { - let Some(text) = declaration.text.get(declaration.signature_range.clone()) - else { - return Err(anyhow!( - "Invalid declaration signature_range {:?} with text.len() = {}", - declaration.signature_range, - declaration.text.len() - )); - }; - let signature_start_line = declaration.range.start - + Line( - declaration.text[..declaration.signature_range.start] - .lines() - .count() as u32, - ); - let signature_end_line = signature_start_line - + Line( - declaration.text - [declaration.signature_range.start..declaration.signature_range.end] - .lines() - .count() as u32, - ); - let range = signature_start_line..signature_end_line; - - PlannedSnippet { - path: declaration.path.clone(), - range, - text, - text_is_truncated: declaration.text_is_truncated, - } - } - DeclarationStyle::Declaration => PlannedSnippet { - path: declaration.path.clone(), - range: declaration.range.clone(), - text: &declaration.text, - text_is_truncated: declaration.text_is_truncated, - }, - }; - this.snippets.push(planned_snippet); - - // When a Signature is consumed, insert an entry for Definition style. - if queue_entry.style == DeclarationStyle::Signature { - let signature_size = declaration_size(&declaration, DeclarationStyle::Signature); - let declaration_size = - declaration_size(&declaration, DeclarationStyle::Declaration); - let signature_score = declaration_score(&declaration, DeclarationStyle::Signature); - let declaration_score = - declaration_score(&declaration, DeclarationStyle::Declaration); - - let score_diff = declaration_score - signature_score; - let size_diff = declaration_size.saturating_sub(signature_size); - if score_diff > 0.0001 && size_diff > 0 { - queue.push(QueueEntry { - declaration_index: queue_entry.declaration_index, - score_density: OrderedFloat(score_diff / (size_diff as f32)), - style: DeclarationStyle::Declaration, - }); - } - } - } - - anyhow::Ok(this) - } - - fn add_parents( - &mut self, - included_parents: &mut FxHashSet, - snippets: Vec<(usize, PlannedSnippet<'a>)>, - ) { - for (parent_index, snippet) in snippets { - included_parents.insert(parent_index); - self.budget_used += snippet.text.len(); - self.snippets.push(snippet); - } - } - - fn additional_parent_signatures( - &self, - path: &Arc, - parent_index: Option, - included_parents: &FxHashSet, - ) -> Result)>> { - let mut results = Vec::new(); - self.additional_parent_signatures_impl(path, parent_index, included_parents, &mut results)?; - Ok(results) - } - - fn additional_parent_signatures_impl( - &self, - path: &Arc, - parent_index: Option, - included_parents: &FxHashSet, - results: &mut Vec<(usize, PlannedSnippet<'a>)>, - ) -> Result<()> { - let Some(parent_index) = parent_index else { - return Ok(()); - }; - if included_parents.contains(&parent_index) { - return Ok(()); - } - let Some(parent_signature) = self.request.signatures.get(parent_index) else { - return Err(anyhow!("Invalid parent index {}", parent_index)); - }; - results.push(( - parent_index, - PlannedSnippet { - path: path.clone(), - range: parent_signature.range.clone(), - text: &parent_signature.text, - text_is_truncated: parent_signature.text_is_truncated, - }, - )); - self.additional_parent_signatures_impl( - path, - parent_signature.parent_index, - included_parents, - results, - ) - } - - /// Renders the planned context. Each file starts with "```FILE_PATH\n` and ends with triple - /// backticks, with a newline after each file. Outputs a line with "..." between nonconsecutive - /// chunks. - pub fn write( - &'a self, - excerpt_file_insertions: &mut Vec<(Point, &'static str)>, - prompt: &mut String, - ) -> Result { - let mut file_to_snippets: FxHashMap<&'a std::path::Path, Vec<&PlannedSnippet<'a>>> = - FxHashMap::default(); - for snippet in &self.snippets { - file_to_snippets - .entry(&snippet.path) - .or_default() - .push(snippet); - } - - // Reorder so that file with cursor comes last - let mut file_snippets = Vec::new(); - let mut excerpt_file_snippets = Vec::new(); - for (file_path, snippets) in file_to_snippets { - if file_path == self.request.excerpt_path.as_ref() { - excerpt_file_snippets = snippets; - } else { - file_snippets.push((file_path, snippets, false)); - } - } - let excerpt_snippet = PlannedSnippet { - path: self.request.excerpt_path.clone(), - range: self.request.excerpt_line_range.clone(), - text: &self.request.excerpt, - text_is_truncated: false, - }; - excerpt_file_snippets.push(&excerpt_snippet); - file_snippets.push((&self.request.excerpt_path, excerpt_file_snippets, true)); - - let section_labels = - self.push_file_snippets(prompt, excerpt_file_insertions, file_snippets)?; - - Ok(section_labels) - } - - fn push_file_snippets( - &self, - output: &mut String, - excerpt_file_insertions: &mut Vec<(Point, &'static str)>, - file_snippets: Vec<(&'a Path, Vec<&'a PlannedSnippet>, bool)>, - ) -> Result { - let mut section_ranges = Vec::new(); - let mut excerpt_index = None; - - for (file_path, mut snippets, is_excerpt_file) in file_snippets { - snippets.sort_by_key(|s| (s.range.start, Reverse(s.range.end))); - - // TODO: What if the snippets get expanded too large to be editable? - let mut current_snippet: Option<(&PlannedSnippet, Range)> = None; - let mut disjoint_snippets: Vec<(&PlannedSnippet, Range)> = Vec::new(); - for snippet in snippets { - if let Some((_, current_snippet_range)) = current_snippet.as_mut() - && snippet.range.start <= current_snippet_range.end - { - current_snippet_range.end = current_snippet_range.end.max(snippet.range.end); - continue; - } - if let Some(current_snippet) = current_snippet.take() { - disjoint_snippets.push(current_snippet); - } - current_snippet = Some((snippet, snippet.range.clone())); - } - if let Some(current_snippet) = current_snippet.take() { - disjoint_snippets.push(current_snippet); - } - - writeln!(output, "`````path={}", file_path.display()).ok(); - let mut skipped_last_snippet = false; - for (snippet, range) in disjoint_snippets { - let section_index = section_ranges.len(); - - match self.request.prompt_format { - PromptFormat::MarkedExcerpt - | PromptFormat::OnlySnippets - | PromptFormat::OldTextNewText - | PromptFormat::Minimal - | PromptFormat::NumLinesUniDiff => { - if range.start.0 > 0 && !skipped_last_snippet { - output.push_str("…\n"); - } - } - PromptFormat::LabeledSections => { - if is_excerpt_file - && range.start <= self.request.excerpt_line_range.start - && range.end >= self.request.excerpt_line_range.end - { - writeln!(output, "<|current_section|>").ok(); - } else { - writeln!(output, "<|section_{}|>", section_index).ok(); - } - } - PromptFormat::MinimalQwen => unreachable!(), - PromptFormat::SeedCoder1120 => unreachable!(), - } - - let push_full_snippet = |output: &mut String| { - if self.request.prompt_format == PromptFormat::NumLinesUniDiff { - for (i, line) in snippet.text.lines().enumerate() { - writeln!(output, "{}|{}", i as u32 + range.start.0 + 1, line)?; - } - } else { - output.push_str(&snippet.text); - } - anyhow::Ok(()) - }; - - if is_excerpt_file { - if self.request.prompt_format == PromptFormat::OnlySnippets { - if range.start >= self.request.excerpt_line_range.start - && range.end <= self.request.excerpt_line_range.end - { - skipped_last_snippet = true; - } else { - skipped_last_snippet = false; - output.push_str(snippet.text); - } - } else if !excerpt_file_insertions.is_empty() { - let lines = snippet.text.lines().collect::>(); - let push_line = |output: &mut String, line_ix: usize| { - if self.request.prompt_format == PromptFormat::NumLinesUniDiff { - write!(output, "{}|", line_ix as u32 + range.start.0 + 1)?; - } - anyhow::Ok(writeln!(output, "{}", lines[line_ix])?) - }; - let mut last_line_ix = 0; - let mut insertion_ix = 0; - while insertion_ix < excerpt_file_insertions.len() { - let (point, insertion) = &excerpt_file_insertions[insertion_ix]; - let found = point.line >= range.start && point.line <= range.end; - if found { - excerpt_index = Some(section_index); - let insertion_line_ix = (point.line.0 - range.start.0) as usize; - for line_ix in last_line_ix..insertion_line_ix { - push_line(output, line_ix)?; - } - if let Some(next_line) = lines.get(insertion_line_ix) { - if self.request.prompt_format == PromptFormat::NumLinesUniDiff { - write!( - output, - "{}|", - insertion_line_ix as u32 + range.start.0 + 1 - )? - } - output.push_str(&next_line[..point.column as usize]); - output.push_str(insertion); - writeln!(output, "{}", &next_line[point.column as usize..])?; - } else { - writeln!(output, "{}", insertion)?; - } - last_line_ix = insertion_line_ix + 1; - excerpt_file_insertions.remove(insertion_ix); - continue; - } - insertion_ix += 1; - } - skipped_last_snippet = false; - for line_ix in last_line_ix..lines.len() { - push_line(output, line_ix)?; - } - } else { - skipped_last_snippet = false; - push_full_snippet(output)?; - } - } else { - skipped_last_snippet = false; - push_full_snippet(output)?; - } - - section_ranges.push((snippet.path.clone(), range)); - } - - output.push_str("`````\n\n"); - } - - Ok(SectionLabels { - // TODO: Clean this up - excerpt_index: match self.request.prompt_format { - PromptFormat::OnlySnippets => 0, - _ => excerpt_index.context("bug: no snippet found for excerpt")?, - }, - section_ranges, - }) - } -} - -fn declaration_score_density(declaration: &ReferencedDeclaration, style: DeclarationStyle) -> f32 { - declaration_score(declaration, style) / declaration_size(declaration, style) as f32 -} - -fn declaration_score(declaration: &ReferencedDeclaration, style: DeclarationStyle) -> f32 { - match style { - DeclarationStyle::Signature => declaration.signature_score, - DeclarationStyle::Declaration => declaration.declaration_score, - } -} - -fn declaration_size(declaration: &ReferencedDeclaration, style: DeclarationStyle) -> usize { - match style { - DeclarationStyle::Signature => declaration.signature_range.len(), - DeclarationStyle::Declaration => declaration.text.len(), - } -} - struct PromptData { events: Vec>, cursor_point: Point, cursor_path: Arc, // TODO: make a common struct with cursor_point - included_files: Vec, + included_files: Vec, } #[derive(Default)] @@ -1051,7 +461,7 @@ impl SeedCoder1120Prompt { context } - fn fmt_fim(&self, file: &IncludedFile, cursor_point: Point) -> String { + fn fmt_fim(&self, file: &RelatedFile, cursor_point: Point) -> String { let mut buf = String::new(); const FIM_SUFFIX: &str = "<[fim-suffix]>"; const FIM_PREFIX: &str = "<[fim-prefix]>"; diff --git a/crates/cloud_zeta2_prompt/src/retrieval_prompt.rs b/crates/cloud_zeta2_prompt/src/retrieval_prompt.rs deleted file mode 100644 index fd35f63f03ff967491a28d817852f6622e4919ca..0000000000000000000000000000000000000000 --- a/crates/cloud_zeta2_prompt/src/retrieval_prompt.rs +++ /dev/null @@ -1,244 +0,0 @@ -use anyhow::Result; -use cloud_llm_client::predict_edits_v3::{self, Excerpt}; -use indoc::indoc; -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; -use std::fmt::Write; - -use crate::{push_events, write_codeblock}; - -pub fn build_prompt(request: predict_edits_v3::PlanContextRetrievalRequest) -> Result { - let mut prompt = SEARCH_INSTRUCTIONS.to_string(); - - if !request.events.is_empty() { - writeln!(&mut prompt, "\n## User Edits\n\n")?; - push_events(&mut prompt, &request.events); - } - - writeln!(&mut prompt, "## Cursor context\n")?; - write_codeblock( - &request.excerpt_path, - &[Excerpt { - start_line: request.excerpt_line_range.start, - text: request.excerpt.into(), - }], - &[], - request.cursor_file_max_row, - true, - &mut prompt, - ); - - writeln!(&mut prompt, "{TOOL_USE_REMINDER}")?; - - Ok(prompt) -} - -/// Search for relevant code -/// -/// For the best results, run multiple queries at once with a single invocation of this tool. -#[derive(Clone, Deserialize, Serialize, JsonSchema)] -pub struct SearchToolInput { - /// An array of queries to run for gathering context relevant to the next prediction - #[schemars(length(max = 3))] - #[serde(deserialize_with = "deserialize_queries")] - pub queries: Box<[SearchToolQuery]>, -} - -fn deserialize_queries<'de, D>(deserializer: D) -> Result, D::Error> -where - D: serde::Deserializer<'de>, -{ - use serde::de::Error; - - #[derive(Deserialize)] - #[serde(untagged)] - enum QueryCollection { - Array(Box<[SearchToolQuery]>), - DoubleArray(Box<[Box<[SearchToolQuery]>]>), - Single(SearchToolQuery), - } - - #[derive(Deserialize)] - #[serde(untagged)] - enum MaybeDoubleEncoded { - SingleEncoded(QueryCollection), - DoubleEncoded(String), - } - - let result = MaybeDoubleEncoded::deserialize(deserializer)?; - - let normalized = match result { - MaybeDoubleEncoded::SingleEncoded(value) => value, - MaybeDoubleEncoded::DoubleEncoded(value) => { - serde_json::from_str(&value).map_err(D::Error::custom)? - } - }; - - Ok(match normalized { - QueryCollection::Array(items) => items, - QueryCollection::Single(search_tool_query) => Box::new([search_tool_query]), - QueryCollection::DoubleArray(double_array) => double_array.into_iter().flatten().collect(), - }) -} - -/// Search for relevant code by path, syntax hierarchy, and content. -#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, Hash)] -pub struct SearchToolQuery { - /// 1. A glob pattern to match file paths in the codebase to search in. - pub glob: String, - /// 2. Regular expressions to match syntax nodes **by their first line** and hierarchy. - /// - /// Subsequent regexes match nodes within the full content of the nodes matched by the previous regexes. - /// - /// Example: Searching for a `User` class - /// ["class\s+User"] - /// - /// Example: Searching for a `get_full_name` method under a `User` class - /// ["class\s+User", "def\sget_full_name"] - /// - /// Skip this field to match on content alone. - #[schemars(length(max = 3))] - #[serde(default)] - pub syntax_node: Vec, - /// 3. An optional regular expression to match the final content that should appear in the results. - /// - /// - Content will be matched within all lines of the matched syntax nodes. - /// - If syntax node regexes are provided, this field can be skipped to include as much of the node itself as possible. - /// - If no syntax node regexes are provided, the content will be matched within the entire file. - pub content: Option, -} - -pub const TOOL_NAME: &str = "search"; - -const SEARCH_INSTRUCTIONS: &str = indoc! {r#" - You are part of an edit prediction system in a code editor. - Your role is to search for code that will serve as context for predicting the next edit. - - - Analyze the user's recent edits and current cursor context - - Use the `search` tool to find code that is relevant for predicting the next edit - - Focus on finding: - - Code patterns that might need similar changes based on the recent edits - - Functions, variables, types, and constants referenced in the current cursor context - - Related implementations, usages, or dependencies that may require consistent updates - - How items defined in the cursor excerpt are used or altered - - You will not be able to filter results or perform subsequent queries, so keep searches as targeted as possible - - Use `syntax_node` parameter whenever you're looking for a particular type, class, or function - - Avoid using wildcard globs if you already know the file path of the content you're looking for -"#}; - -const TOOL_USE_REMINDER: &str = indoc! {" - -- - Analyze the user's intent in one to two sentences, then call the `search` tool. -"}; - -#[cfg(test)] -mod tests { - use serde_json::json; - - use super::*; - - #[test] - fn test_deserialize_queries() { - let single_query_json = indoc! {r#"{ - "queries": { - "glob": "**/*.rs", - "syntax_node": ["fn test"], - "content": "assert" - } - }"#}; - - let flat_input: SearchToolInput = serde_json::from_str(single_query_json).unwrap(); - assert_eq!(flat_input.queries.len(), 1); - assert_eq!(flat_input.queries[0].glob, "**/*.rs"); - assert_eq!(flat_input.queries[0].syntax_node, vec!["fn test"]); - assert_eq!(flat_input.queries[0].content, Some("assert".to_string())); - - let flat_json = indoc! {r#"{ - "queries": [ - { - "glob": "**/*.rs", - "syntax_node": ["fn test"], - "content": "assert" - }, - { - "glob": "**/*.ts", - "syntax_node": [], - "content": null - } - ] - }"#}; - - let flat_input: SearchToolInput = serde_json::from_str(flat_json).unwrap(); - assert_eq!(flat_input.queries.len(), 2); - assert_eq!(flat_input.queries[0].glob, "**/*.rs"); - assert_eq!(flat_input.queries[0].syntax_node, vec!["fn test"]); - assert_eq!(flat_input.queries[0].content, Some("assert".to_string())); - assert_eq!(flat_input.queries[1].glob, "**/*.ts"); - assert_eq!(flat_input.queries[1].syntax_node.len(), 0); - assert_eq!(flat_input.queries[1].content, None); - - let nested_json = indoc! {r#"{ - "queries": [ - [ - { - "glob": "**/*.rs", - "syntax_node": ["fn test"], - "content": "assert" - } - ], - [ - { - "glob": "**/*.ts", - "syntax_node": [], - "content": null - } - ] - ] - }"#}; - - let nested_input: SearchToolInput = serde_json::from_str(nested_json).unwrap(); - - assert_eq!(nested_input.queries.len(), 2); - - assert_eq!(nested_input.queries[0].glob, "**/*.rs"); - assert_eq!(nested_input.queries[0].syntax_node, vec!["fn test"]); - assert_eq!(nested_input.queries[0].content, Some("assert".to_string())); - assert_eq!(nested_input.queries[1].glob, "**/*.ts"); - assert_eq!(nested_input.queries[1].syntax_node.len(), 0); - assert_eq!(nested_input.queries[1].content, None); - - let double_encoded_queries = serde_json::to_string(&json!({ - "queries": serde_json::to_string(&json!([ - { - "glob": "**/*.rs", - "syntax_node": ["fn test"], - "content": "assert" - }, - { - "glob": "**/*.ts", - "syntax_node": [], - "content": null - } - ])).unwrap() - })) - .unwrap(); - - let double_encoded_input: SearchToolInput = - serde_json::from_str(&double_encoded_queries).unwrap(); - - assert_eq!(double_encoded_input.queries.len(), 2); - - assert_eq!(double_encoded_input.queries[0].glob, "**/*.rs"); - assert_eq!(double_encoded_input.queries[0].syntax_node, vec!["fn test"]); - assert_eq!( - double_encoded_input.queries[0].content, - Some("assert".to_string()) - ); - assert_eq!(double_encoded_input.queries[1].glob, "**/*.ts"); - assert_eq!(double_encoded_input.queries[1].syntax_node.len(), 0); - assert_eq!(double_encoded_input.queries[1].content, None); - - // ### ERROR Switching from var declarations to lexical declarations [RUN 073] - // invalid search json {"queries": ["express/lib/response.js", "var\\s+[a-zA-Z_][a-zA-Z0-9_]*\\s*=.*;", "function.*\\(.*\\).*\\{.*\\}"]} - } -} diff --git a/crates/codestral/Cargo.toml b/crates/codestral/Cargo.toml index b402274a33530424349081da764a4b6766e419e9..7f3bf3b22dda8f9dbde1923c76855342c6cbac4c 100644 --- a/crates/codestral/Cargo.toml +++ b/crates/codestral/Cargo.toml @@ -10,7 +10,7 @@ path = "src/codestral.rs" [dependencies] anyhow.workspace = true -edit_prediction.workspace = true +edit_prediction_types.workspace = true edit_prediction_context.workspace = true futures.workspace = true gpui.workspace = true diff --git a/crates/codestral/src/codestral.rs b/crates/codestral/src/codestral.rs index 6a500acbf6ec5eea63c35a8deb83a8545cee497e..9bf0296ac357937cd1ad1470dba9a98864911de9 100644 --- a/crates/codestral/src/codestral.rs +++ b/crates/codestral/src/codestral.rs @@ -1,6 +1,6 @@ use anyhow::{Context as _, Result}; -use edit_prediction::{Direction, EditPrediction, EditPredictionProvider}; use edit_prediction_context::{EditPredictionExcerpt, EditPredictionExcerptOptions}; +use edit_prediction_types::{Direction, EditPrediction, EditPredictionDelegate}; use futures::AsyncReadExt; use gpui::{App, Context, Entity, Task}; use http_client::HttpClient; @@ -43,17 +43,17 @@ impl CurrentCompletion { /// Attempts to adjust the edits based on changes made to the buffer since the completion was generated. /// Returns None if the user's edits conflict with the predicted edits. fn interpolate(&self, new_snapshot: &BufferSnapshot) -> Option, Arc)>> { - edit_prediction::interpolate_edits(&self.snapshot, new_snapshot, &self.edits) + edit_prediction_types::interpolate_edits(&self.snapshot, new_snapshot, &self.edits) } } -pub struct CodestralCompletionProvider { +pub struct CodestralEditPredictionDelegate { http_client: Arc, pending_request: Option>>, current_completion: Option, } -impl CodestralCompletionProvider { +impl CodestralEditPredictionDelegate { pub fn new(http_client: Arc) -> Self { Self { http_client, @@ -165,7 +165,7 @@ impl CodestralCompletionProvider { } } -impl EditPredictionProvider for CodestralCompletionProvider { +impl EditPredictionDelegate for CodestralEditPredictionDelegate { fn name() -> &'static str { "codestral" } @@ -174,7 +174,7 @@ impl EditPredictionProvider for CodestralCompletionProvider { "Codestral" } - fn show_completions_in_menu() -> bool { + fn show_predictions_in_menu() -> bool { true } @@ -239,7 +239,6 @@ impl EditPredictionProvider for CodestralCompletionProvider { cursor_point, &snapshot, &EXCERPT_OPTIONS, - None, ) .context("Line containing cursor doesn't fit in excerpt max bytes")?; diff --git a/crates/copilot/Cargo.toml b/crates/copilot/Cargo.toml index 0d3b19c0c7bd264f8ed10e53289376055f833307..459abda17573d66287e2c8ca0b995292acaf163b 100644 --- a/crates/copilot/Cargo.toml +++ b/crates/copilot/Cargo.toml @@ -33,7 +33,7 @@ fs.workspace = true futures.workspace = true gpui.workspace = true http_client.workspace = true -edit_prediction.workspace = true +edit_prediction_types.workspace = true language.workspace = true log.workspace = true lsp.workspace = true diff --git a/crates/copilot/src/copilot.rs b/crates/copilot/src/copilot.rs index ed18a199bf2c08c8c046a8ad3e7f945b1340643e..6fbdeff807b65d22193ba7fdcb8e990f7184f70e 100644 --- a/crates/copilot/src/copilot.rs +++ b/crates/copilot/src/copilot.rs @@ -1,5 +1,5 @@ pub mod copilot_chat; -mod copilot_completion_provider; +mod copilot_edit_prediction_delegate; pub mod copilot_responses; pub mod request; mod sign_in; @@ -46,7 +46,7 @@ use util::rel_path::RelPath; use util::{ResultExt, fs::remove_matching}; use workspace::Workspace; -pub use crate::copilot_completion_provider::CopilotCompletionProvider; +pub use crate::copilot_edit_prediction_delegate::CopilotEditPredictionDelegate; pub use crate::sign_in::{CopilotCodeVerification, initiate_sign_in, reinstall_and_sign_in}; actions!( diff --git a/crates/copilot/src/copilot_completion_provider.rs b/crates/copilot/src/copilot_edit_prediction_delegate.rs similarity index 98% rename from crates/copilot/src/copilot_completion_provider.rs rename to crates/copilot/src/copilot_edit_prediction_delegate.rs index e92f0c7d7dd7e51c4a8fdc19f34bd6eb4189c097..961154dbeecad007f026f25eeac25de95d751d9e 100644 --- a/crates/copilot/src/copilot_completion_provider.rs +++ b/crates/copilot/src/copilot_edit_prediction_delegate.rs @@ -1,6 +1,6 @@ use crate::{Completion, Copilot}; use anyhow::Result; -use edit_prediction::{Direction, EditPrediction, EditPredictionProvider}; +use edit_prediction_types::{Direction, EditPrediction, EditPredictionDelegate}; use gpui::{App, Context, Entity, EntityId, Task}; use language::{Buffer, OffsetRangeExt, ToOffset, language_settings::AllLanguageSettings}; use settings::Settings; @@ -8,7 +8,7 @@ use std::{path::Path, time::Duration}; pub const COPILOT_DEBOUNCE_TIMEOUT: Duration = Duration::from_millis(75); -pub struct CopilotCompletionProvider { +pub struct CopilotEditPredictionDelegate { cycled: bool, buffer_id: Option, completions: Vec, @@ -19,7 +19,7 @@ pub struct CopilotCompletionProvider { copilot: Entity, } -impl CopilotCompletionProvider { +impl CopilotEditPredictionDelegate { pub fn new(copilot: Entity) -> Self { Self { cycled: false, @@ -47,7 +47,7 @@ impl CopilotCompletionProvider { } } -impl EditPredictionProvider for CopilotCompletionProvider { +impl EditPredictionDelegate for CopilotEditPredictionDelegate { fn name() -> &'static str { "copilot" } @@ -56,7 +56,7 @@ impl EditPredictionProvider for CopilotCompletionProvider { "Copilot" } - fn show_completions_in_menu() -> bool { + fn show_predictions_in_menu() -> bool { true } @@ -314,7 +314,7 @@ mod tests { cx, ) .await; - let copilot_provider = cx.new(|_| CopilotCompletionProvider::new(copilot)); + let copilot_provider = cx.new(|_| CopilotEditPredictionDelegate::new(copilot)); cx.update_editor(|editor, window, cx| { editor.set_edit_prediction_provider(Some(copilot_provider), window, cx) }); @@ -546,7 +546,7 @@ mod tests { cx, ) .await; - let copilot_provider = cx.new(|_| CopilotCompletionProvider::new(copilot)); + let copilot_provider = cx.new(|_| CopilotEditPredictionDelegate::new(copilot)); cx.update_editor(|editor, window, cx| { editor.set_edit_prediction_provider(Some(copilot_provider), window, cx) }); @@ -670,7 +670,7 @@ mod tests { cx, ) .await; - let copilot_provider = cx.new(|_| CopilotCompletionProvider::new(copilot)); + let copilot_provider = cx.new(|_| CopilotEditPredictionDelegate::new(copilot)); cx.update_editor(|editor, window, cx| { editor.set_edit_prediction_provider(Some(copilot_provider), window, cx) }); @@ -753,7 +753,7 @@ mod tests { window.focus(&editor.focus_handle(cx)); }) .unwrap(); - let copilot_provider = cx.new(|_| CopilotCompletionProvider::new(copilot)); + let copilot_provider = cx.new(|_| CopilotEditPredictionDelegate::new(copilot)); editor .update(cx, |editor, window, cx| { editor.set_edit_prediction_provider(Some(copilot_provider), window, cx) @@ -848,7 +848,7 @@ mod tests { cx, ) .await; - let copilot_provider = cx.new(|_| CopilotCompletionProvider::new(copilot)); + let copilot_provider = cx.new(|_| CopilotEditPredictionDelegate::new(copilot)); cx.update_editor(|editor, window, cx| { editor.set_edit_prediction_provider(Some(copilot_provider), window, cx) }); @@ -1000,7 +1000,7 @@ mod tests { window.focus(&editor.focus_handle(cx)) }) .unwrap(); - let copilot_provider = cx.new(|_| CopilotCompletionProvider::new(copilot)); + let copilot_provider = cx.new(|_| CopilotEditPredictionDelegate::new(copilot)); editor .update(cx, |editor, window, cx| { editor.set_edit_prediction_provider(Some(copilot_provider), window, cx) diff --git a/crates/edit_prediction/Cargo.toml b/crates/edit_prediction/Cargo.toml index 2c6888d14be49c857e7805fb63f9f9335ac32c8e..6e62cfa6f038671d595c5671de147cdc2125064d 100644 --- a/crates/edit_prediction/Cargo.toml +++ b/crates/edit_prediction/Cargo.toml @@ -11,7 +11,69 @@ workspace = true [lib] path = "src/edit_prediction.rs" +[features] +eval-support = [] + [dependencies] +ai_onboarding.workspace = true +anyhow.workspace = true +arrayvec.workspace = true +brotli.workspace = true client.workspace = true +cloud_llm_client.workspace = true +cloud_zeta2_prompt.workspace = true +collections.workspace = true +copilot.workspace = true +credentials_provider.workspace = true +db.workspace = true +edit_prediction_types.workspace = true +edit_prediction_context.workspace = true +feature_flags.workspace = true +fs.workspace = true +futures.workspace = true gpui.workspace = true +indoc.workspace = true +itertools.workspace = true language.workspace = true +language_model.workspace = true +log.workspace = true +lsp.workspace = true +menu.workspace = true +open_ai.workspace = true +postage.workspace = true +pretty_assertions.workspace = true +project.workspace = true +rand.workspace = true +regex.workspace = true +release_channel.workspace = true +semver.workspace = true +serde.workspace = true +serde_json.workspace = true +settings.workspace = true +smol.workspace = true +strsim.workspace = true +strum.workspace = true +telemetry.workspace = true +telemetry_events.workspace = true +thiserror.workspace = true +ui.workspace = true +util.workspace = true +uuid.workspace = true +workspace.workspace = true +worktree.workspace = true +zed_actions.workspace = true + +[dev-dependencies] +clock = { workspace = true, features = ["test-support"] } +cloud_api_types.workspace = true +cloud_llm_client = { workspace = true, features = ["test-support"] } +ctor.workspace = true +gpui = { workspace = true, features = ["test-support"] } +indoc.workspace = true +language = { workspace = true, features = ["test-support"] } +language_model = { workspace = true, features = ["test-support"] } +lsp.workspace = true +parking_lot.workspace = true +project = { workspace = true, features = ["test-support"] } +settings = { workspace = true, features = ["test-support"] } +zlog.workspace = true diff --git a/crates/zeta/license_examples/0bsd.txt b/crates/edit_prediction/license_examples/0bsd.txt similarity index 100% rename from crates/zeta/license_examples/0bsd.txt rename to crates/edit_prediction/license_examples/0bsd.txt diff --git a/crates/zeta/license_examples/apache-2.0-ex0.txt b/crates/edit_prediction/license_examples/apache-2.0-ex0.txt similarity index 100% rename from crates/zeta/license_examples/apache-2.0-ex0.txt rename to crates/edit_prediction/license_examples/apache-2.0-ex0.txt diff --git a/crates/zeta/license_examples/apache-2.0-ex1.txt b/crates/edit_prediction/license_examples/apache-2.0-ex1.txt similarity index 100% rename from crates/zeta/license_examples/apache-2.0-ex1.txt rename to crates/edit_prediction/license_examples/apache-2.0-ex1.txt diff --git a/crates/zeta/license_examples/apache-2.0-ex2.txt b/crates/edit_prediction/license_examples/apache-2.0-ex2.txt similarity index 100% rename from crates/zeta/license_examples/apache-2.0-ex2.txt rename to crates/edit_prediction/license_examples/apache-2.0-ex2.txt diff --git a/crates/zeta/license_examples/apache-2.0-ex3.txt b/crates/edit_prediction/license_examples/apache-2.0-ex3.txt similarity index 100% rename from crates/zeta/license_examples/apache-2.0-ex3.txt rename to crates/edit_prediction/license_examples/apache-2.0-ex3.txt diff --git a/crates/zeta/license_examples/apache-2.0-ex4.txt b/crates/edit_prediction/license_examples/apache-2.0-ex4.txt similarity index 100% rename from crates/zeta/license_examples/apache-2.0-ex4.txt rename to crates/edit_prediction/license_examples/apache-2.0-ex4.txt diff --git a/crates/zeta/license_examples/bsd-1-clause.txt b/crates/edit_prediction/license_examples/bsd-1-clause.txt similarity index 100% rename from crates/zeta/license_examples/bsd-1-clause.txt rename to crates/edit_prediction/license_examples/bsd-1-clause.txt diff --git a/crates/zeta/license_examples/bsd-2-clause-ex0.txt b/crates/edit_prediction/license_examples/bsd-2-clause-ex0.txt similarity index 100% rename from crates/zeta/license_examples/bsd-2-clause-ex0.txt rename to crates/edit_prediction/license_examples/bsd-2-clause-ex0.txt diff --git a/crates/zeta/license_examples/bsd-3-clause-ex0.txt b/crates/edit_prediction/license_examples/bsd-3-clause-ex0.txt similarity index 100% rename from crates/zeta/license_examples/bsd-3-clause-ex0.txt rename to crates/edit_prediction/license_examples/bsd-3-clause-ex0.txt diff --git a/crates/zeta/license_examples/bsd-3-clause-ex1.txt b/crates/edit_prediction/license_examples/bsd-3-clause-ex1.txt similarity index 100% rename from crates/zeta/license_examples/bsd-3-clause-ex1.txt rename to crates/edit_prediction/license_examples/bsd-3-clause-ex1.txt diff --git a/crates/zeta/license_examples/bsd-3-clause-ex2.txt b/crates/edit_prediction/license_examples/bsd-3-clause-ex2.txt similarity index 100% rename from crates/zeta/license_examples/bsd-3-clause-ex2.txt rename to crates/edit_prediction/license_examples/bsd-3-clause-ex2.txt diff --git a/crates/zeta/license_examples/bsd-3-clause-ex3.txt b/crates/edit_prediction/license_examples/bsd-3-clause-ex3.txt similarity index 100% rename from crates/zeta/license_examples/bsd-3-clause-ex3.txt rename to crates/edit_prediction/license_examples/bsd-3-clause-ex3.txt diff --git a/crates/zeta/license_examples/bsd-3-clause-ex4.txt b/crates/edit_prediction/license_examples/bsd-3-clause-ex4.txt similarity index 100% rename from crates/zeta/license_examples/bsd-3-clause-ex4.txt rename to crates/edit_prediction/license_examples/bsd-3-clause-ex4.txt diff --git a/crates/zeta/license_examples/isc.txt b/crates/edit_prediction/license_examples/isc.txt similarity index 100% rename from crates/zeta/license_examples/isc.txt rename to crates/edit_prediction/license_examples/isc.txt diff --git a/crates/zeta/license_examples/mit-ex0.txt b/crates/edit_prediction/license_examples/mit-ex0.txt similarity index 100% rename from crates/zeta/license_examples/mit-ex0.txt rename to crates/edit_prediction/license_examples/mit-ex0.txt diff --git a/crates/zeta/license_examples/mit-ex1.txt b/crates/edit_prediction/license_examples/mit-ex1.txt similarity index 100% rename from crates/zeta/license_examples/mit-ex1.txt rename to crates/edit_prediction/license_examples/mit-ex1.txt diff --git a/crates/zeta/license_examples/mit-ex2.txt b/crates/edit_prediction/license_examples/mit-ex2.txt similarity index 100% rename from crates/zeta/license_examples/mit-ex2.txt rename to crates/edit_prediction/license_examples/mit-ex2.txt diff --git a/crates/zeta/license_examples/mit-ex3.txt b/crates/edit_prediction/license_examples/mit-ex3.txt similarity index 100% rename from crates/zeta/license_examples/mit-ex3.txt rename to crates/edit_prediction/license_examples/mit-ex3.txt diff --git a/crates/zeta/license_examples/upl-1.0.txt b/crates/edit_prediction/license_examples/upl-1.0.txt similarity index 100% rename from crates/zeta/license_examples/upl-1.0.txt rename to crates/edit_prediction/license_examples/upl-1.0.txt diff --git a/crates/zeta/license_examples/zlib-ex0.txt b/crates/edit_prediction/license_examples/zlib-ex0.txt similarity index 100% rename from crates/zeta/license_examples/zlib-ex0.txt rename to crates/edit_prediction/license_examples/zlib-ex0.txt diff --git a/crates/zeta/license_patterns/0bsd-pattern b/crates/edit_prediction/license_patterns/0bsd-pattern similarity index 100% rename from crates/zeta/license_patterns/0bsd-pattern rename to crates/edit_prediction/license_patterns/0bsd-pattern diff --git a/crates/zeta/license_patterns/apache-2.0-pattern b/crates/edit_prediction/license_patterns/apache-2.0-pattern similarity index 100% rename from crates/zeta/license_patterns/apache-2.0-pattern rename to crates/edit_prediction/license_patterns/apache-2.0-pattern diff --git a/crates/zeta/license_patterns/apache-2.0-reference-pattern b/crates/edit_prediction/license_patterns/apache-2.0-reference-pattern similarity index 100% rename from crates/zeta/license_patterns/apache-2.0-reference-pattern rename to crates/edit_prediction/license_patterns/apache-2.0-reference-pattern diff --git a/crates/zeta/license_patterns/bsd-pattern b/crates/edit_prediction/license_patterns/bsd-pattern similarity index 100% rename from crates/zeta/license_patterns/bsd-pattern rename to crates/edit_prediction/license_patterns/bsd-pattern diff --git a/crates/zeta/license_patterns/isc-pattern b/crates/edit_prediction/license_patterns/isc-pattern similarity index 100% rename from crates/zeta/license_patterns/isc-pattern rename to crates/edit_prediction/license_patterns/isc-pattern diff --git a/crates/zeta/license_patterns/mit-pattern b/crates/edit_prediction/license_patterns/mit-pattern similarity index 100% rename from crates/zeta/license_patterns/mit-pattern rename to crates/edit_prediction/license_patterns/mit-pattern diff --git a/crates/zeta/license_patterns/upl-1.0-pattern b/crates/edit_prediction/license_patterns/upl-1.0-pattern similarity index 100% rename from crates/zeta/license_patterns/upl-1.0-pattern rename to crates/edit_prediction/license_patterns/upl-1.0-pattern diff --git a/crates/zeta/license_patterns/zlib-pattern b/crates/edit_prediction/license_patterns/zlib-pattern similarity index 100% rename from crates/zeta/license_patterns/zlib-pattern rename to crates/edit_prediction/license_patterns/zlib-pattern diff --git a/crates/edit_prediction/src/edit_prediction.rs b/crates/edit_prediction/src/edit_prediction.rs index 1984383a9691ae9373973a3eb9f00db4e7e795f2..ddb29d0796a6c6b24ee3914533b29b967d224ac8 100644 --- a/crates/edit_prediction/src/edit_prediction.rs +++ b/crates/edit_prediction/src/edit_prediction.rs @@ -1,298 +1,1911 @@ -use std::{ops::Range, sync::Arc}; +use anyhow::Result; +use arrayvec::ArrayVec; +use client::{Client, EditPredictionUsage, UserStore}; +use cloud_llm_client::predict_edits_v3::{self, Event, PromptFormat}; +use cloud_llm_client::{ + AcceptEditPredictionBody, EXPIRED_LLM_TOKEN_HEADER_NAME, EditPredictionRejectReason, + EditPredictionRejection, MAX_EDIT_PREDICTION_REJECTIONS_PER_REQUEST, + MINIMUM_REQUIRED_VERSION_HEADER_NAME, PredictEditsRequestTrigger, RejectEditPredictionsBodyRef, + ZED_VERSION_HEADER_NAME, +}; +use cloud_zeta2_prompt::DEFAULT_MAX_PROMPT_BYTES; +use collections::{HashMap, HashSet}; +use db::kvp::{Dismissable, KEY_VALUE_STORE}; +use edit_prediction_context::EditPredictionExcerptOptions; +use edit_prediction_context::{RelatedExcerptStore, RelatedExcerptStoreEvent, RelatedFile}; +use feature_flags::{FeatureFlag, FeatureFlagAppExt as _}; +use futures::{ + AsyncReadExt as _, FutureExt as _, StreamExt as _, + channel::{ + mpsc::{self, UnboundedReceiver}, + oneshot, + }, + select_biased, +}; +use gpui::BackgroundExecutor; +use gpui::{ + App, AsyncApp, Entity, EntityId, Global, SharedString, Subscription, Task, WeakEntity, actions, + http_client::{self, AsyncBody, Method}, + prelude::*, +}; +use language::language_settings::all_language_settings; +use language::{Anchor, Buffer, File, Point, ToPoint}; +use language::{BufferSnapshot, OffsetRangeExt}; +use language_model::{LlmApiToken, RefreshLlmTokenListener}; +use project::{Project, ProjectPath, WorktreeId}; +use release_channel::AppVersion; +use semver::Version; +use serde::de::DeserializeOwned; +use settings::{EditPredictionProvider, SettingsStore, update_settings_file}; +use std::collections::{VecDeque, hash_map}; +use workspace::Workspace; + +use std::ops::Range; +use std::path::Path; +use std::rc::Rc; +use std::str::FromStr as _; +use std::sync::{Arc, LazyLock}; +use std::time::{Duration, Instant}; +use std::{env, mem}; +use thiserror::Error; +use util::{RangeExt as _, ResultExt as _}; +use workspace::notifications::{ErrorMessagePrompt, NotificationId, show_app_notification}; + +mod license_detection; +mod onboarding_modal; +mod prediction; +pub mod sweep_ai; +pub mod udiff; +mod xml_edits; +mod zed_edit_prediction_delegate; +pub mod zeta1; +pub mod zeta2; + +#[cfg(test)] +mod edit_prediction_tests; + +use crate::license_detection::LicenseDetectionWatcher; +use crate::onboarding_modal::ZedPredictModal; +pub use crate::prediction::EditPrediction; +pub use crate::prediction::EditPredictionId; +pub use crate::prediction::EditPredictionInputs; +use crate::prediction::EditPredictionResult; +pub use crate::sweep_ai::SweepAi; +pub use telemetry_events::EditPredictionRating; +pub use zed_edit_prediction_delegate::ZedEditPredictionDelegate; + +actions!( + edit_prediction, + [ + /// Resets the edit prediction onboarding state. + ResetOnboarding, + /// Clears the edit prediction history. + ClearHistory, + ] +); + +/// Maximum number of events to track. +const EVENT_COUNT_MAX: usize = 6; +const CHANGE_GROUPING_LINE_SPAN: u32 = 8; +const ZED_PREDICT_DATA_COLLECTION_CHOICE: &str = "zed_predict_data_collection_choice"; +const REJECT_REQUEST_DEBOUNCE: Duration = Duration::from_secs(15); -use client::EditPredictionUsage; -use gpui::{App, Context, Entity, SharedString}; -use language::{Anchor, Buffer, BufferSnapshot, OffsetRangeExt}; +pub struct SweepFeatureFlag; -// TODO: Find a better home for `Direction`. -// -// This should live in an ancestor crate of `editor` and `edit_prediction`, -// but at time of writing there isn't an obvious spot. -#[derive(Copy, Clone, PartialEq, Eq)] -pub enum Direction { - Prev, - Next, +impl FeatureFlag for SweepFeatureFlag { + const NAME: &str = "sweep-ai"; } -#[derive(Clone)] -pub enum EditPrediction { - /// Edits within the buffer that requested the prediction - Local { - id: Option, - edits: Vec<(Range, Arc)>, - edit_preview: Option, - }, - /// Jump to a different file from the one that requested the prediction - Jump { - id: Option, - snapshot: language::BufferSnapshot, - target: language::Anchor, +pub const DEFAULT_OPTIONS: ZetaOptions = ZetaOptions { + context: EditPredictionExcerptOptions { + max_bytes: 512, + min_bytes: 128, + target_before_cursor_over_total_bytes: 0.5, }, + max_prompt_bytes: DEFAULT_MAX_PROMPT_BYTES, + prompt_format: PromptFormat::DEFAULT, +}; + +static USE_OLLAMA: LazyLock = + LazyLock::new(|| env::var("ZED_ZETA2_OLLAMA").is_ok_and(|var| !var.is_empty())); + +static EDIT_PREDICTIONS_MODEL_ID: LazyLock = LazyLock::new(|| { + match env::var("ZED_ZETA2_MODEL").as_deref() { + Ok("zeta2-exp") => "4w5n28vw", // Fine-tuned model @ Baseten + Ok(model) => model, + Err(_) if *USE_OLLAMA => "qwen3-coder:30b", + Err(_) => "yqvev8r3", // Vanilla qwen3-coder @ Baseten + } + .to_string() +}); +static PREDICT_EDITS_URL: LazyLock> = LazyLock::new(|| { + env::var("ZED_PREDICT_EDITS_URL").ok().or_else(|| { + if *USE_OLLAMA { + Some("http://localhost:11434/v1/chat/completions".into()) + } else { + None + } + }) +}); + +pub struct Zeta2FeatureFlag; + +impl FeatureFlag for Zeta2FeatureFlag { + const NAME: &'static str = "zeta2"; + + fn enabled_for_staff() -> bool { + true + } } -pub enum DataCollectionState { - /// The provider doesn't support data collection. - Unsupported, - /// Data collection is enabled. - Enabled { is_project_open_source: bool }, - /// Data collection is disabled or unanswered. - Disabled { is_project_open_source: bool }, +#[derive(Clone)] +struct EditPredictionStoreGlobal(Entity); + +impl Global for EditPredictionStoreGlobal {} + +pub struct EditPredictionStore { + client: Arc, + user_store: Entity, + llm_token: LlmApiToken, + _llm_token_subscription: Subscription, + projects: HashMap, + use_context: bool, + options: ZetaOptions, + update_required: bool, + debug_tx: Option>, + #[cfg(feature = "eval-support")] + eval_cache: Option>, + edit_prediction_model: EditPredictionModel, + pub sweep_ai: SweepAi, + data_collection_choice: DataCollectionChoice, + reject_predictions_tx: mpsc::UnboundedSender, + shown_predictions: VecDeque, + rated_predictions: HashSet, +} + +#[derive(Copy, Clone, Default, PartialEq, Eq)] +pub enum EditPredictionModel { + #[default] + Zeta1, + Zeta2, + Sweep, } -impl DataCollectionState { - pub fn is_supported(&self) -> bool { - !matches!(self, DataCollectionState::Unsupported) +#[derive(Debug, Clone, PartialEq)] +pub struct ZetaOptions { + pub context: EditPredictionExcerptOptions, + pub max_prompt_bytes: usize, + pub prompt_format: predict_edits_v3::PromptFormat, +} + +#[derive(Debug)] +pub enum DebugEvent { + ContextRetrievalStarted(ContextRetrievalStartedDebugEvent), + ContextRetrievalFinished(ContextRetrievalFinishedDebugEvent), + EditPredictionRequested(EditPredictionRequestedDebugEvent), +} + +#[derive(Debug)] +pub struct ContextRetrievalStartedDebugEvent { + pub project_entity_id: EntityId, + pub timestamp: Instant, + pub search_prompt: String, +} + +#[derive(Debug)] +pub struct ContextRetrievalFinishedDebugEvent { + pub project_entity_id: EntityId, + pub timestamp: Instant, + pub metadata: Vec<(&'static str, SharedString)>, +} + +#[derive(Debug)] +pub struct EditPredictionRequestedDebugEvent { + pub inputs: EditPredictionInputs, + pub retrieval_time: Duration, + pub buffer: WeakEntity, + pub position: Anchor, + pub local_prompt: Result, + pub response_rx: oneshot::Receiver<(Result, Duration)>, +} + +pub type RequestDebugInfo = predict_edits_v3::DebugInfo; + +struct ProjectState { + events: VecDeque>, + last_event: Option, + recent_paths: VecDeque, + registered_buffers: HashMap, + current_prediction: Option, + next_pending_prediction_id: usize, + pending_predictions: ArrayVec, + context_updates_tx: smol::channel::Sender<()>, + context_updates_rx: smol::channel::Receiver<()>, + last_prediction_refresh: Option<(EntityId, Instant)>, + cancelled_predictions: HashSet, + context: Entity, + license_detection_watchers: HashMap>, + _subscription: gpui::Subscription, +} + +impl ProjectState { + pub fn events(&self, cx: &App) -> Vec> { + self.events + .iter() + .cloned() + .chain( + self.last_event + .as_ref() + .and_then(|event| event.finalize(&self.license_detection_watchers, cx)), + ) + .collect() } - pub fn is_enabled(&self) -> bool { - matches!(self, DataCollectionState::Enabled { .. }) + fn cancel_pending_prediction( + &mut self, + pending_prediction: PendingPrediction, + cx: &mut Context, + ) { + self.cancelled_predictions.insert(pending_prediction.id); + + cx.spawn(async move |this, cx| { + let Some(prediction_id) = pending_prediction.task.await else { + return; + }; + + this.update(cx, |this, _cx| { + this.reject_prediction(prediction_id, EditPredictionRejectReason::Canceled, false); + }) + .ok(); + }) + .detach() } +} + +#[derive(Debug, Clone)] +struct CurrentEditPrediction { + pub requested_by: PredictionRequestedBy, + pub prediction: EditPrediction, + pub was_shown: bool, +} + +impl CurrentEditPrediction { + fn should_replace_prediction(&self, old_prediction: &Self, cx: &App) -> bool { + let Some(new_edits) = self + .prediction + .interpolate(&self.prediction.buffer.read(cx)) + else { + return false; + }; - pub fn is_project_open_source(&self) -> bool { + if self.prediction.buffer != old_prediction.prediction.buffer { + return true; + } + + let Some(old_edits) = old_prediction + .prediction + .interpolate(&old_prediction.prediction.buffer.read(cx)) + else { + return true; + }; + + let requested_by_buffer_id = self.requested_by.buffer_id(); + + // This reduces the occurrence of UI thrash from replacing edits + // + // TODO: This is fairly arbitrary - should have a more general heuristic that handles multiple edits. + if requested_by_buffer_id == Some(self.prediction.buffer.entity_id()) + && requested_by_buffer_id == Some(old_prediction.prediction.buffer.entity_id()) + && old_edits.len() == 1 + && new_edits.len() == 1 + { + let (old_range, old_text) = &old_edits[0]; + let (new_range, new_text) = &new_edits[0]; + new_range == old_range && new_text.starts_with(old_text.as_ref()) + } else { + true + } + } +} + +#[derive(Debug, Clone)] +enum PredictionRequestedBy { + DiagnosticsUpdate, + Buffer(EntityId), +} + +impl PredictionRequestedBy { + pub fn buffer_id(&self) -> Option { match self { - Self::Enabled { - is_project_open_source, - } - | Self::Disabled { - is_project_open_source, - } => *is_project_open_source, - _ => false, + PredictionRequestedBy::DiagnosticsUpdate => None, + PredictionRequestedBy::Buffer(buffer_id) => Some(*buffer_id), } } } -pub trait EditPredictionProvider: 'static + Sized { - fn name() -> &'static str; - fn display_name() -> &'static str; - fn show_completions_in_menu() -> bool; - fn show_tab_accept_marker() -> bool { - false +#[derive(Debug)] +struct PendingPrediction { + id: usize, + task: Task>, +} + +/// A prediction from the perspective of a buffer. +#[derive(Debug)] +enum BufferEditPrediction<'a> { + Local { prediction: &'a EditPrediction }, + Jump { prediction: &'a EditPrediction }, +} + +#[cfg(test)] +impl std::ops::Deref for BufferEditPrediction<'_> { + type Target = EditPrediction; + + fn deref(&self) -> &Self::Target { + match self { + BufferEditPrediction::Local { prediction } => prediction, + BufferEditPrediction::Jump { prediction } => prediction, + } } - fn supports_jump_to_edit() -> bool { - true +} + +struct RegisteredBuffer { + snapshot: BufferSnapshot, + _subscriptions: [gpui::Subscription; 2], +} + +struct LastEvent { + old_snapshot: BufferSnapshot, + new_snapshot: BufferSnapshot, + end_edit_anchor: Option, +} + +impl LastEvent { + pub fn finalize( + &self, + license_detection_watchers: &HashMap>, + cx: &App, + ) -> Option> { + let path = buffer_path_with_id_fallback(&self.new_snapshot, cx); + let old_path = buffer_path_with_id_fallback(&self.old_snapshot, cx); + + let file = self.new_snapshot.file(); + let old_file = self.old_snapshot.file(); + + let in_open_source_repo = [file, old_file].iter().all(|file| { + file.is_some_and(|file| { + license_detection_watchers + .get(&file.worktree_id(cx)) + .is_some_and(|watcher| watcher.is_project_open_source()) + }) + }); + + let diff = language::unified_diff(&self.old_snapshot.text(), &self.new_snapshot.text()); + + if path == old_path && diff.is_empty() { + None + } else { + Some(Arc::new(predict_edits_v3::Event::BufferChange { + old_path, + path, + diff, + in_open_source_repo, + // TODO: Actually detect if this edit was predicted or not + predicted: false, + })) + } } +} - fn data_collection_state(&self, _cx: &App) -> DataCollectionState { - DataCollectionState::Unsupported +fn buffer_path_with_id_fallback(snapshot: &BufferSnapshot, cx: &App) -> Arc { + if let Some(file) = snapshot.file() { + file.full_path(cx).into() + } else { + Path::new(&format!("untitled-{}", snapshot.remote_id())).into() } +} - fn usage(&self, _cx: &App) -> Option { - None +impl EditPredictionStore { + pub fn try_global(cx: &App) -> Option> { + cx.try_global::() + .map(|global| global.0.clone()) } - fn toggle_data_collection(&mut self, _cx: &mut App) {} - fn is_enabled( - &self, + pub fn global( + client: &Arc, + user_store: &Entity, + cx: &mut App, + ) -> Entity { + cx.try_global::() + .map(|global| global.0.clone()) + .unwrap_or_else(|| { + let ep_store = cx.new(|cx| Self::new(client.clone(), user_store.clone(), cx)); + cx.set_global(EditPredictionStoreGlobal(ep_store.clone())); + ep_store + }) + } + + pub fn new(client: Arc, user_store: Entity, cx: &mut Context) -> Self { + let refresh_llm_token_listener = RefreshLlmTokenListener::global(cx); + let data_collection_choice = Self::load_data_collection_choice(); + + let llm_token = LlmApiToken::default(); + + let (reject_tx, reject_rx) = mpsc::unbounded(); + cx.background_spawn({ + let client = client.clone(); + let llm_token = llm_token.clone(); + let app_version = AppVersion::global(cx); + let background_executor = cx.background_executor().clone(); + async move { + Self::handle_rejected_predictions( + reject_rx, + client, + llm_token, + app_version, + background_executor, + ) + .await + } + }) + .detach(); + + let mut this = Self { + projects: HashMap::default(), + client, + user_store, + options: DEFAULT_OPTIONS, + use_context: false, + llm_token, + _llm_token_subscription: cx.subscribe( + &refresh_llm_token_listener, + |this, _listener, _event, cx| { + let client = this.client.clone(); + let llm_token = this.llm_token.clone(); + cx.spawn(async move |_this, _cx| { + llm_token.refresh(&client).await?; + anyhow::Ok(()) + }) + .detach_and_log_err(cx); + }, + ), + update_required: false, + debug_tx: None, + #[cfg(feature = "eval-support")] + eval_cache: None, + edit_prediction_model: EditPredictionModel::Zeta2, + sweep_ai: SweepAi::new(cx), + data_collection_choice, + reject_predictions_tx: reject_tx, + rated_predictions: Default::default(), + shown_predictions: Default::default(), + }; + + this.enable_or_disable_context_retrieval(cx); + let weak_this = cx.weak_entity(); + cx.on_flags_ready(move |_, cx| { + weak_this + .update(cx, |this, cx| this.enable_or_disable_context_retrieval(cx)) + .ok(); + }) + .detach(); + cx.observe_global::(|this, cx| { + this.enable_or_disable_context_retrieval(cx); + }) + .detach(); + + this + } + + pub fn set_edit_prediction_model(&mut self, model: EditPredictionModel) { + self.edit_prediction_model = model; + } + + pub fn has_sweep_api_token(&self) -> bool { + self.sweep_ai + .api_token + .clone() + .now_or_never() + .flatten() + .is_some() + } + + #[cfg(feature = "eval-support")] + pub fn with_eval_cache(&mut self, cache: Arc) { + self.eval_cache = Some(cache); + } + + pub fn debug_info(&mut self) -> mpsc::UnboundedReceiver { + let (debug_watch_tx, debug_watch_rx) = mpsc::unbounded(); + self.debug_tx = Some(debug_watch_tx); + debug_watch_rx + } + + pub fn options(&self) -> &ZetaOptions { + &self.options + } + + pub fn set_options(&mut self, options: ZetaOptions) { + self.options = options; + } + + pub fn set_use_context(&mut self, use_context: bool) { + self.use_context = use_context; + } + + pub fn clear_history(&mut self) { + for project_state in self.projects.values_mut() { + project_state.events.clear(); + } + } + + pub fn context_for_project<'a>( + &'a self, + project: &Entity, + cx: &'a App, + ) -> &'a [RelatedFile] { + self.projects + .get(&project.entity_id()) + .map(|project| project.context.read(cx).related_files()) + .unwrap_or(&[]) + } + + pub fn usage(&self, cx: &App) -> Option { + if self.edit_prediction_model == EditPredictionModel::Zeta2 { + self.user_store.read(cx).edit_prediction_usage() + } else { + None + } + } + + pub fn register_project(&mut self, project: &Entity, cx: &mut Context) { + self.get_or_init_project(project, cx); + } + + pub fn register_buffer( + &mut self, buffer: &Entity, - cursor_position: language::Anchor, - cx: &App, - ) -> bool; - fn is_refreshing(&self, cx: &App) -> bool; - fn refresh( + project: &Entity, + cx: &mut Context, + ) { + let project_state = self.get_or_init_project(project, cx); + Self::register_buffer_impl(project_state, buffer, project, cx); + } + + fn get_or_init_project( &mut self, - buffer: Entity, - cursor_position: language::Anchor, - debounce: bool, + project: &Entity, cx: &mut Context, - ); - fn cycle( + ) -> &mut ProjectState { + let entity_id = project.entity_id(); + let (context_updates_tx, context_updates_rx) = smol::channel::unbounded(); + self.projects + .entry(entity_id) + .or_insert_with(|| ProjectState { + context: { + let related_excerpt_store = cx.new(|cx| RelatedExcerptStore::new(project, cx)); + cx.subscribe( + &related_excerpt_store, + move |this, _, event, _| match event { + RelatedExcerptStoreEvent::StartedRefresh => { + if let Some(debug_tx) = this.debug_tx.clone() { + debug_tx + .unbounded_send(DebugEvent::ContextRetrievalStarted( + ContextRetrievalStartedDebugEvent { + project_entity_id: entity_id, + timestamp: Instant::now(), + search_prompt: String::new(), + }, + )) + .ok(); + } + } + RelatedExcerptStoreEvent::FinishedRefresh { + cache_hit_count, + cache_miss_count, + mean_definition_latency, + max_definition_latency, + } => { + if let Some(debug_tx) = this.debug_tx.clone() { + debug_tx + .unbounded_send(DebugEvent::ContextRetrievalFinished( + ContextRetrievalFinishedDebugEvent { + project_entity_id: entity_id, + timestamp: Instant::now(), + metadata: vec![ + ( + "Cache Hits", + format!( + "{}/{}", + cache_hit_count, + cache_hit_count + cache_miss_count + ) + .into(), + ), + ( + "Max LSP Time", + format!( + "{} ms", + max_definition_latency.as_millis() + ) + .into(), + ), + ( + "Mean LSP Time", + format!( + "{} ms", + mean_definition_latency.as_millis() + ) + .into(), + ), + ], + }, + )) + .ok(); + } + if let Some(project_state) = this.projects.get(&entity_id) { + project_state.context_updates_tx.send_blocking(()).ok(); + } + } + }, + ) + .detach(); + related_excerpt_store + }, + events: VecDeque::new(), + last_event: None, + recent_paths: VecDeque::new(), + context_updates_rx, + context_updates_tx, + registered_buffers: HashMap::default(), + current_prediction: None, + cancelled_predictions: HashSet::default(), + pending_predictions: ArrayVec::new(), + next_pending_prediction_id: 0, + last_prediction_refresh: None, + license_detection_watchers: HashMap::default(), + _subscription: cx.subscribe(&project, Self::handle_project_event), + }) + } + + pub fn project_context_updates( + &self, + project: &Entity, + ) -> Option> { + let project_state = self.projects.get(&project.entity_id())?; + Some(project_state.context_updates_rx.clone()) + } + + fn handle_project_event( &mut self, - buffer: Entity, - cursor_position: language::Anchor, - direction: Direction, + project: Entity, + event: &project::Event, cx: &mut Context, - ); - fn accept(&mut self, cx: &mut Context); - fn discard(&mut self, cx: &mut Context); - fn did_show(&mut self, _cx: &mut Context) {} - fn suggest( + ) { + // TODO [zeta2] init with recent paths + match event { + project::Event::ActiveEntryChanged(Some(active_entry_id)) => { + let Some(project_state) = self.projects.get_mut(&project.entity_id()) else { + return; + }; + let path = project.read(cx).path_for_entry(*active_entry_id, cx); + if let Some(path) = path { + if let Some(ix) = project_state + .recent_paths + .iter() + .position(|probe| probe == &path) + { + project_state.recent_paths.remove(ix); + } + project_state.recent_paths.push_front(path); + } + } + project::Event::DiagnosticsUpdated { .. } => { + if cx.has_flag::() { + self.refresh_prediction_from_diagnostics(project, cx); + } + } + _ => (), + } + } + + fn register_buffer_impl<'a>( + project_state: &'a mut ProjectState, + buffer: &Entity, + project: &Entity, + cx: &mut Context, + ) -> &'a mut RegisteredBuffer { + let buffer_id = buffer.entity_id(); + + if let Some(file) = buffer.read(cx).file() { + let worktree_id = file.worktree_id(cx); + if let Some(worktree) = project.read(cx).worktree_for_id(worktree_id, cx) { + project_state + .license_detection_watchers + .entry(worktree_id) + .or_insert_with(|| { + let project_entity_id = project.entity_id(); + cx.observe_release(&worktree, move |this, _worktree, _cx| { + let Some(project_state) = this.projects.get_mut(&project_entity_id) + else { + return; + }; + project_state + .license_detection_watchers + .remove(&worktree_id); + }) + .detach(); + Rc::new(LicenseDetectionWatcher::new(&worktree, cx)) + }); + } + } + + match project_state.registered_buffers.entry(buffer_id) { + hash_map::Entry::Occupied(entry) => entry.into_mut(), + hash_map::Entry::Vacant(entry) => { + let snapshot = buffer.read(cx).snapshot(); + let project_entity_id = project.entity_id(); + entry.insert(RegisteredBuffer { + snapshot, + _subscriptions: [ + cx.subscribe(buffer, { + let project = project.downgrade(); + move |this, buffer, event, cx| { + if let language::BufferEvent::Edited = event + && let Some(project) = project.upgrade() + { + this.report_changes_for_buffer(&buffer, &project, cx); + } + } + }), + cx.observe_release(buffer, move |this, _buffer, _cx| { + let Some(project_state) = this.projects.get_mut(&project_entity_id) + else { + return; + }; + project_state.registered_buffers.remove(&buffer_id); + }), + ], + }) + } + } + } + + fn report_changes_for_buffer( &mut self, buffer: &Entity, - cursor_position: language::Anchor, + project: &Entity, cx: &mut Context, - ) -> Option; -} + ) { + let project_state = self.get_or_init_project(project, cx); + let registered_buffer = Self::register_buffer_impl(project_state, buffer, project, cx); + + let new_snapshot = buffer.read(cx).snapshot(); + if new_snapshot.version == registered_buffer.snapshot.version { + return; + } + + let old_snapshot = mem::replace(&mut registered_buffer.snapshot, new_snapshot.clone()); + let end_edit_anchor = new_snapshot + .anchored_edits_since::(&old_snapshot.version) + .last() + .map(|(_, range)| range.end); + let events = &mut project_state.events; -pub trait EditPredictionProviderHandle { - fn name(&self) -> &'static str; - fn display_name(&self) -> &'static str; - fn is_enabled( + if let Some(LastEvent { + new_snapshot: last_new_snapshot, + end_edit_anchor: last_end_edit_anchor, + .. + }) = project_state.last_event.as_mut() + { + let is_next_snapshot_of_same_buffer = old_snapshot.remote_id() + == last_new_snapshot.remote_id() + && old_snapshot.version == last_new_snapshot.version; + + let should_coalesce = is_next_snapshot_of_same_buffer + && end_edit_anchor + .as_ref() + .zip(last_end_edit_anchor.as_ref()) + .is_some_and(|(a, b)| { + let a = a.to_point(&new_snapshot); + let b = b.to_point(&new_snapshot); + a.row.abs_diff(b.row) <= CHANGE_GROUPING_LINE_SPAN + }); + + if should_coalesce { + *last_end_edit_anchor = end_edit_anchor; + *last_new_snapshot = new_snapshot; + return; + } + } + + if events.len() + 1 >= EVENT_COUNT_MAX { + events.pop_front(); + } + + if let Some(event) = project_state.last_event.take() { + events.extend(event.finalize(&project_state.license_detection_watchers, cx)); + } + + project_state.last_event = Some(LastEvent { + old_snapshot, + new_snapshot, + end_edit_anchor, + }); + } + + fn current_prediction_for_buffer( &self, buffer: &Entity, - cursor_position: language::Anchor, + project: &Entity, cx: &App, - ) -> bool; - fn show_completions_in_menu(&self) -> bool; - fn show_tab_accept_marker(&self) -> bool; - fn supports_jump_to_edit(&self) -> bool; - fn data_collection_state(&self, cx: &App) -> DataCollectionState; - fn usage(&self, cx: &App) -> Option; - fn toggle_data_collection(&self, cx: &mut App); - fn is_refreshing(&self, cx: &App) -> bool; - fn refresh( - &self, - buffer: Entity, - cursor_position: language::Anchor, - debounce: bool, - cx: &mut App, - ); - fn cycle( - &self, - buffer: Entity, - cursor_position: language::Anchor, - direction: Direction, - cx: &mut App, - ); - fn did_show(&self, cx: &mut App); - fn accept(&self, cx: &mut App); - fn discard(&self, cx: &mut App); - fn suggest( - &self, - buffer: &Entity, - cursor_position: language::Anchor, - cx: &mut App, - ) -> Option; -} + ) -> Option> { + let project_state = self.projects.get(&project.entity_id())?; -impl EditPredictionProviderHandle for Entity -where - T: EditPredictionProvider, -{ - fn name(&self) -> &'static str { - T::name() - } + let CurrentEditPrediction { + requested_by, + prediction, + .. + } = project_state.current_prediction.as_ref()?; - fn display_name(&self) -> &'static str { - T::display_name() - } + if prediction.targets_buffer(buffer.read(cx)) { + Some(BufferEditPrediction::Local { prediction }) + } else { + let show_jump = match requested_by { + PredictionRequestedBy::Buffer(requested_by_buffer_id) => { + requested_by_buffer_id == &buffer.entity_id() + } + PredictionRequestedBy::DiagnosticsUpdate => true, + }; - fn show_completions_in_menu(&self) -> bool { - T::show_completions_in_menu() + if show_jump { + Some(BufferEditPrediction::Jump { prediction }) + } else { + None + } + } } - fn show_tab_accept_marker(&self) -> bool { - T::show_tab_accept_marker() - } + fn accept_current_prediction(&mut self, project: &Entity, cx: &mut Context) { + match self.edit_prediction_model { + EditPredictionModel::Zeta1 | EditPredictionModel::Zeta2 => {} + EditPredictionModel::Sweep => return, + } + + let Some(project_state) = self.projects.get_mut(&project.entity_id()) else { + return; + }; + + let Some(prediction) = project_state.current_prediction.take() else { + return; + }; + let request_id = prediction.prediction.id.to_string(); + for pending_prediction in mem::take(&mut project_state.pending_predictions) { + project_state.cancel_pending_prediction(pending_prediction, cx); + } + + let client = self.client.clone(); + let llm_token = self.llm_token.clone(); + let app_version = AppVersion::global(cx); + cx.spawn(async move |this, cx| { + let url = if let Ok(predict_edits_url) = env::var("ZED_ACCEPT_PREDICTION_URL") { + http_client::Url::parse(&predict_edits_url)? + } else { + client + .http_client() + .build_zed_llm_url("/predict_edits/accept", &[])? + }; + + let response = cx + .background_spawn(Self::send_api_request::<()>( + move |builder| { + let req = builder.uri(url.as_ref()).body( + serde_json::to_string(&AcceptEditPredictionBody { + request_id: request_id.clone(), + })? + .into(), + ); + Ok(req?) + }, + client, + llm_token, + app_version, + )) + .await; - fn supports_jump_to_edit(&self) -> bool { - T::supports_jump_to_edit() + Self::handle_api_response(&this, response, cx)?; + anyhow::Ok(()) + }) + .detach_and_log_err(cx); } - fn data_collection_state(&self, cx: &App) -> DataCollectionState { - self.read(cx).data_collection_state(cx) + async fn handle_rejected_predictions( + rx: UnboundedReceiver, + client: Arc, + llm_token: LlmApiToken, + app_version: Version, + background_executor: BackgroundExecutor, + ) { + let mut rx = std::pin::pin!(rx.peekable()); + let mut batched = Vec::new(); + + while let Some(rejection) = rx.next().await { + batched.push(rejection); + + if batched.len() < MAX_EDIT_PREDICTION_REJECTIONS_PER_REQUEST / 2 { + select_biased! { + next = rx.as_mut().peek().fuse() => { + if next.is_some() { + continue; + } + } + () = background_executor.timer(REJECT_REQUEST_DEBOUNCE).fuse() => {}, + } + } + + let url = client + .http_client() + .build_zed_llm_url("/predict_edits/reject", &[]) + .unwrap(); + + let flush_count = batched + .len() + // in case items have accumulated after failure + .min(MAX_EDIT_PREDICTION_REJECTIONS_PER_REQUEST); + let start = batched.len() - flush_count; + + let body = RejectEditPredictionsBodyRef { + rejections: &batched[start..], + }; + + let result = Self::send_api_request::<()>( + |builder| { + let req = builder + .uri(url.as_ref()) + .body(serde_json::to_string(&body)?.into()); + anyhow::Ok(req?) + }, + client.clone(), + llm_token.clone(), + app_version.clone(), + ) + .await; + + if result.log_err().is_some() { + batched.drain(start..); + } + } } - fn usage(&self, cx: &App) -> Option { - self.read(cx).usage(cx) + fn reject_current_prediction( + &mut self, + reason: EditPredictionRejectReason, + project: &Entity, + ) { + if let Some(project_state) = self.projects.get_mut(&project.entity_id()) { + project_state.pending_predictions.clear(); + if let Some(prediction) = project_state.current_prediction.take() { + self.reject_prediction(prediction.prediction.id, reason, prediction.was_shown); + } + }; } - fn toggle_data_collection(&self, cx: &mut App) { - self.update(cx, |this, cx| this.toggle_data_collection(cx)) + fn did_show_current_prediction(&mut self, project: &Entity, _cx: &mut Context) { + if let Some(project_state) = self.projects.get_mut(&project.entity_id()) { + if let Some(current_prediction) = project_state.current_prediction.as_mut() { + if !current_prediction.was_shown { + current_prediction.was_shown = true; + self.shown_predictions + .push_front(current_prediction.prediction.clone()); + if self.shown_predictions.len() > 50 { + let completion = self.shown_predictions.pop_back().unwrap(); + self.rated_predictions.remove(&completion.id); + } + } + } + } } - fn is_enabled( - &self, - buffer: &Entity, - cursor_position: language::Anchor, - cx: &App, - ) -> bool { - self.read(cx).is_enabled(buffer, cursor_position, cx) + fn reject_prediction( + &mut self, + prediction_id: EditPredictionId, + reason: EditPredictionRejectReason, + was_shown: bool, + ) { + match self.edit_prediction_model { + EditPredictionModel::Zeta1 | EditPredictionModel::Zeta2 => {} + EditPredictionModel::Sweep => return, + } + + self.reject_predictions_tx + .unbounded_send(EditPredictionRejection { + request_id: prediction_id.to_string(), + reason, + was_shown, + }) + .log_err(); } - fn is_refreshing(&self, cx: &App) -> bool { - self.read(cx).is_refreshing(cx) + fn is_refreshing(&self, project: &Entity) -> bool { + self.projects + .get(&project.entity_id()) + .is_some_and(|project_state| !project_state.pending_predictions.is_empty()) } - fn refresh( - &self, + pub fn refresh_prediction_from_buffer( + &mut self, + project: Entity, buffer: Entity, - cursor_position: language::Anchor, - debounce: bool, - cx: &mut App, + position: language::Anchor, + cx: &mut Context, ) { - self.update(cx, |this, cx| { - this.refresh(buffer, cursor_position, debounce, cx) + self.queue_prediction_refresh(project.clone(), buffer.entity_id(), cx, move |this, cx| { + let Some(request_task) = this + .update(cx, |this, cx| { + this.request_prediction( + &project, + &buffer, + position, + PredictEditsRequestTrigger::Other, + cx, + ) + }) + .log_err() + else { + return Task::ready(anyhow::Ok(None)); + }; + + cx.spawn(async move |_cx| { + request_task.await.map(|prediction_result| { + prediction_result.map(|prediction_result| { + ( + prediction_result, + PredictionRequestedBy::Buffer(buffer.entity_id()), + ) + }) + }) + }) }) } - fn cycle( - &self, - buffer: Entity, - cursor_position: language::Anchor, - direction: Direction, - cx: &mut App, + pub fn refresh_prediction_from_diagnostics( + &mut self, + project: Entity, + cx: &mut Context, ) { - self.update(cx, |this, cx| { - this.cycle(buffer, cursor_position, direction, cx) + let Some(project_state) = self.projects.get_mut(&project.entity_id()) else { + return; + }; + + // Prefer predictions from buffer + if project_state.current_prediction.is_some() { + return; + }; + + self.queue_prediction_refresh(project.clone(), project.entity_id(), cx, move |this, cx| { + let Some(open_buffer_task) = project + .update(cx, |project, cx| { + project + .active_entry() + .and_then(|entry| project.path_for_entry(entry, cx)) + .map(|path| project.open_buffer(path, cx)) + }) + .log_err() + .flatten() + else { + return Task::ready(anyhow::Ok(None)); + }; + + cx.spawn(async move |cx| { + let active_buffer = open_buffer_task.await?; + let snapshot = active_buffer.read_with(cx, |buffer, _cx| buffer.snapshot())?; + + let Some((jump_buffer, jump_position)) = Self::next_diagnostic_location( + active_buffer, + &snapshot, + Default::default(), + Default::default(), + &project, + cx, + ) + .await? + else { + return anyhow::Ok(None); + }; + + let Some(prediction_result) = this + .update(cx, |this, cx| { + this.request_prediction( + &project, + &jump_buffer, + jump_position, + PredictEditsRequestTrigger::Diagnostics, + cx, + ) + })? + .await? + else { + return anyhow::Ok(None); + }; + + this.update(cx, |this, cx| { + Some(( + if this + .get_or_init_project(&project, cx) + .current_prediction + .is_none() + { + prediction_result + } else { + EditPredictionResult { + id: prediction_result.id, + prediction: Err(EditPredictionRejectReason::CurrentPreferred), + } + }, + PredictionRequestedBy::DiagnosticsUpdate, + )) + }) + }) + }); + } + + #[cfg(not(test))] + pub const THROTTLE_TIMEOUT: Duration = Duration::from_millis(300); + #[cfg(test)] + pub const THROTTLE_TIMEOUT: Duration = Duration::ZERO; + + fn queue_prediction_refresh( + &mut self, + project: Entity, + throttle_entity: EntityId, + cx: &mut Context, + do_refresh: impl FnOnce( + WeakEntity, + &mut AsyncApp, + ) + -> Task>> + + 'static, + ) { + let project_state = self.get_or_init_project(&project, cx); + let pending_prediction_id = project_state.next_pending_prediction_id; + project_state.next_pending_prediction_id += 1; + let last_request = project_state.last_prediction_refresh; + + let task = cx.spawn(async move |this, cx| { + if let Some((last_entity, last_timestamp)) = last_request + && throttle_entity == last_entity + && let Some(timeout) = + (last_timestamp + Self::THROTTLE_TIMEOUT).checked_duration_since(Instant::now()) + { + cx.background_executor().timer(timeout).await; + } + + // If this task was cancelled before the throttle timeout expired, + // do not perform a request. + let mut is_cancelled = true; + this.update(cx, |this, cx| { + let project_state = this.get_or_init_project(&project, cx); + if !project_state + .cancelled_predictions + .remove(&pending_prediction_id) + { + project_state.last_prediction_refresh = Some((throttle_entity, Instant::now())); + is_cancelled = false; + } + }) + .ok(); + if is_cancelled { + return None; + } + + let new_prediction_result = do_refresh(this.clone(), cx).await.log_err().flatten(); + let new_prediction_id = new_prediction_result + .as_ref() + .map(|(prediction, _)| prediction.id.clone()); + + // When a prediction completes, remove it from the pending list, and cancel + // any pending predictions that were enqueued before it. + this.update(cx, |this, cx| { + let project_state = this.get_or_init_project(&project, cx); + + let is_cancelled = project_state + .cancelled_predictions + .remove(&pending_prediction_id); + + let new_current_prediction = if !is_cancelled + && let Some((prediction_result, requested_by)) = new_prediction_result + { + match prediction_result.prediction { + Ok(prediction) => { + let new_prediction = CurrentEditPrediction { + requested_by, + prediction, + was_shown: false, + }; + + if let Some(current_prediction) = + project_state.current_prediction.as_ref() + { + if new_prediction.should_replace_prediction(¤t_prediction, cx) + { + this.reject_current_prediction( + EditPredictionRejectReason::Replaced, + &project, + ); + + Some(new_prediction) + } else { + this.reject_prediction( + new_prediction.prediction.id, + EditPredictionRejectReason::CurrentPreferred, + false, + ); + None + } + } else { + Some(new_prediction) + } + } + Err(reject_reason) => { + this.reject_prediction(prediction_result.id, reject_reason, false); + None + } + } + } else { + None + }; + + let project_state = this.get_or_init_project(&project, cx); + + if let Some(new_prediction) = new_current_prediction { + project_state.current_prediction = Some(new_prediction); + } + + let mut pending_predictions = mem::take(&mut project_state.pending_predictions); + for (ix, pending_prediction) in pending_predictions.iter().enumerate() { + if pending_prediction.id == pending_prediction_id { + pending_predictions.remove(ix); + for pending_prediction in pending_predictions.drain(0..ix) { + project_state.cancel_pending_prediction(pending_prediction, cx) + } + break; + } + } + this.get_or_init_project(&project, cx).pending_predictions = pending_predictions; + cx.notify(); + }) + .ok(); + + new_prediction_id + }); + + if project_state.pending_predictions.len() <= 1 { + project_state.pending_predictions.push(PendingPrediction { + id: pending_prediction_id, + task, + }); + } else if project_state.pending_predictions.len() == 2 { + let pending_prediction = project_state.pending_predictions.pop().unwrap(); + project_state.pending_predictions.push(PendingPrediction { + id: pending_prediction_id, + task, + }); + project_state.cancel_pending_prediction(pending_prediction, cx); + } + } + + pub fn request_prediction( + &mut self, + project: &Entity, + active_buffer: &Entity, + position: language::Anchor, + trigger: PredictEditsRequestTrigger, + cx: &mut Context, + ) -> Task>> { + self.request_prediction_internal( + project.clone(), + active_buffer.clone(), + position, + trigger, + cx.has_flag::(), + cx, + ) + } + + fn request_prediction_internal( + &mut self, + project: Entity, + active_buffer: Entity, + position: language::Anchor, + trigger: PredictEditsRequestTrigger, + allow_jump: bool, + cx: &mut Context, + ) -> Task>> { + const DIAGNOSTIC_LINES_RANGE: u32 = 20; + + self.get_or_init_project(&project, cx); + let project_state = self.projects.get(&project.entity_id()).unwrap(); + let events = project_state.events(cx); + let has_events = !events.is_empty(); + + let snapshot = active_buffer.read(cx).snapshot(); + let cursor_point = position.to_point(&snapshot); + let diagnostic_search_start = cursor_point.row.saturating_sub(DIAGNOSTIC_LINES_RANGE); + let diagnostic_search_end = cursor_point.row + DIAGNOSTIC_LINES_RANGE; + let diagnostic_search_range = + Point::new(diagnostic_search_start, 0)..Point::new(diagnostic_search_end, 0); + + let related_files = if self.use_context { + self.context_for_project(&project, cx).to_vec() + } else { + Vec::new() + }; + + let task = match self.edit_prediction_model { + EditPredictionModel::Zeta1 => zeta1::request_prediction_with_zeta1( + self, + &project, + &active_buffer, + snapshot.clone(), + position, + events, + trigger, + cx, + ), + EditPredictionModel::Zeta2 => zeta2::request_prediction_with_zeta2( + self, + &project, + &active_buffer, + snapshot.clone(), + position, + events, + related_files, + trigger, + cx, + ), + EditPredictionModel::Sweep => self.sweep_ai.request_prediction_with_sweep( + &project, + &active_buffer, + snapshot.clone(), + position, + events, + &project_state.recent_paths, + related_files, + diagnostic_search_range.clone(), + cx, + ), + }; + + cx.spawn(async move |this, cx| { + let prediction = task.await?; + + if prediction.is_none() && allow_jump { + let cursor_point = position.to_point(&snapshot); + if has_events + && let Some((jump_buffer, jump_position)) = Self::next_diagnostic_location( + active_buffer.clone(), + &snapshot, + diagnostic_search_range, + cursor_point, + &project, + cx, + ) + .await? + { + return this + .update(cx, |this, cx| { + this.request_prediction_internal( + project, + jump_buffer, + jump_position, + trigger, + false, + cx, + ) + })? + .await; + } + + return anyhow::Ok(None); + } + + Ok(prediction) }) } - fn accept(&self, cx: &mut App) { - self.update(cx, |this, cx| this.accept(cx)) + async fn next_diagnostic_location( + active_buffer: Entity, + active_buffer_snapshot: &BufferSnapshot, + active_buffer_diagnostic_search_range: Range, + active_buffer_cursor_point: Point, + project: &Entity, + cx: &mut AsyncApp, + ) -> Result, language::Anchor)>> { + // find the closest diagnostic to the cursor that wasn't close enough to be included in the last request + let mut jump_location = active_buffer_snapshot + .diagnostic_groups(None) + .into_iter() + .filter_map(|(_, group)| { + let range = &group.entries[group.primary_ix] + .range + .to_point(&active_buffer_snapshot); + if range.overlaps(&active_buffer_diagnostic_search_range) { + None + } else { + Some(range.start) + } + }) + .min_by_key(|probe| probe.row.abs_diff(active_buffer_cursor_point.row)) + .map(|position| { + ( + active_buffer.clone(), + active_buffer_snapshot.anchor_before(position), + ) + }); + + if jump_location.is_none() { + let active_buffer_path = active_buffer.read_with(cx, |buffer, cx| { + let file = buffer.file()?; + + Some(ProjectPath { + worktree_id: file.worktree_id(cx), + path: file.path().clone(), + }) + })?; + + let buffer_task = project.update(cx, |project, cx| { + let (path, _, _) = project + .diagnostic_summaries(false, cx) + .filter(|(path, _, _)| Some(path) != active_buffer_path.as_ref()) + .max_by_key(|(path, _, _)| { + // find the buffer with errors that shares most parent directories + path.path + .components() + .zip( + active_buffer_path + .as_ref() + .map(|p| p.path.components()) + .unwrap_or_default(), + ) + .take_while(|(a, b)| a == b) + .count() + })?; + + Some(project.open_buffer(path, cx)) + })?; + + if let Some(buffer_task) = buffer_task { + let closest_buffer = buffer_task.await?; + + jump_location = closest_buffer + .read_with(cx, |buffer, _cx| { + buffer + .buffer_diagnostics(None) + .into_iter() + .min_by_key(|entry| entry.diagnostic.severity) + .map(|entry| entry.range.start) + })? + .map(|position| (closest_buffer, position)); + } + } + + anyhow::Ok(jump_location) } - fn discard(&self, cx: &mut App) { - self.update(cx, |this, cx| this.discard(cx)) + async fn send_raw_llm_request( + request: open_ai::Request, + client: Arc, + llm_token: LlmApiToken, + app_version: Version, + #[cfg(feature = "eval-support")] eval_cache: Option>, + #[cfg(feature = "eval-support")] eval_cache_kind: EvalCacheEntryKind, + ) -> Result<(open_ai::Response, Option)> { + let url = if let Some(predict_edits_url) = PREDICT_EDITS_URL.as_ref() { + http_client::Url::parse(&predict_edits_url)? + } else { + client + .http_client() + .build_zed_llm_url("/predict_edits/raw", &[])? + }; + + #[cfg(feature = "eval-support")] + let cache_key = if let Some(cache) = eval_cache { + use collections::FxHasher; + use std::hash::{Hash, Hasher}; + + let mut hasher = FxHasher::default(); + url.hash(&mut hasher); + let request_str = serde_json::to_string_pretty(&request)?; + request_str.hash(&mut hasher); + let hash = hasher.finish(); + + let key = (eval_cache_kind, hash); + if let Some(response_str) = cache.read(key) { + return Ok((serde_json::from_str(&response_str)?, None)); + } + + Some((cache, request_str, key)) + } else { + None + }; + + let (response, usage) = Self::send_api_request( + |builder| { + let req = builder + .uri(url.as_ref()) + .body(serde_json::to_string(&request)?.into()); + Ok(req?) + }, + client, + llm_token, + app_version, + ) + .await?; + + #[cfg(feature = "eval-support")] + if let Some((cache, request, key)) = cache_key { + cache.write(key, &request, &serde_json::to_string_pretty(&response)?); + } + + Ok((response, usage)) } - fn did_show(&self, cx: &mut App) { - self.update(cx, |this, cx| this.did_show(cx)) + fn handle_api_response( + this: &WeakEntity, + response: Result<(T, Option)>, + cx: &mut gpui::AsyncApp, + ) -> Result { + match response { + Ok((data, usage)) => { + if let Some(usage) = usage { + this.update(cx, |this, cx| { + this.user_store.update(cx, |user_store, cx| { + user_store.update_edit_prediction_usage(usage, cx); + }); + }) + .ok(); + } + Ok(data) + } + Err(err) => { + if err.is::() { + cx.update(|cx| { + this.update(cx, |this, _cx| { + this.update_required = true; + }) + .ok(); + + let error_message: SharedString = err.to_string().into(); + show_app_notification( + NotificationId::unique::(), + cx, + move |cx| { + cx.new(|cx| { + ErrorMessagePrompt::new(error_message.clone(), cx) + .with_link_button("Update Zed", "https://zed.dev/releases") + }) + }, + ); + }) + .ok(); + } + Err(err) + } + } } - fn suggest( - &self, - buffer: &Entity, - cursor_position: language::Anchor, - cx: &mut App, - ) -> Option { - self.update(cx, |this, cx| this.suggest(buffer, cursor_position, cx)) - } -} - -/// Returns edits updated based on user edits since the old snapshot. None is returned if any user -/// edit is not a prefix of a predicted insertion. -pub fn interpolate_edits( - old_snapshot: &BufferSnapshot, - new_snapshot: &BufferSnapshot, - current_edits: &[(Range, Arc)], -) -> Option, Arc)>> { - let mut edits = Vec::new(); - - let mut model_edits = current_edits.iter().peekable(); - for user_edit in new_snapshot.edits_since::(&old_snapshot.version) { - while let Some((model_old_range, _)) = model_edits.peek() { - let model_old_range = model_old_range.to_offset(old_snapshot); - if model_old_range.end < user_edit.old.start { - let (model_old_range, model_new_text) = model_edits.next().unwrap(); - edits.push((model_old_range.clone(), model_new_text.clone())); + async fn send_api_request( + build: impl Fn(http_client::http::request::Builder) -> Result>, + client: Arc, + llm_token: LlmApiToken, + app_version: Version, + ) -> Result<(Res, Option)> + where + Res: DeserializeOwned, + { + let http_client = client.http_client(); + let mut token = llm_token.acquire(&client).await?; + let mut did_retry = false; + + loop { + let request_builder = http_client::Request::builder().method(Method::POST); + + let request = build( + request_builder + .header("Content-Type", "application/json") + .header("Authorization", format!("Bearer {}", token)) + .header(ZED_VERSION_HEADER_NAME, app_version.to_string()), + )?; + + let mut response = http_client.send(request).await?; + + if let Some(minimum_required_version) = response + .headers() + .get(MINIMUM_REQUIRED_VERSION_HEADER_NAME) + .and_then(|version| Version::from_str(version.to_str().ok()?).ok()) + { + anyhow::ensure!( + app_version >= minimum_required_version, + ZedUpdateRequiredError { + minimum_version: minimum_required_version + } + ); + } + + if response.status().is_success() { + let usage = EditPredictionUsage::from_headers(response.headers()).ok(); + + let mut body = Vec::new(); + response.body_mut().read_to_end(&mut body).await?; + return Ok((serde_json::from_slice(&body)?, usage)); + } else if !did_retry + && response + .headers() + .get(EXPIRED_LLM_TOKEN_HEADER_NAME) + .is_some() + { + did_retry = true; + token = llm_token.refresh(&client).await?; } else { - break; + let mut body = String::new(); + response.body_mut().read_to_string(&mut body).await?; + anyhow::bail!( + "Request failed with status: {:?}\nBody: {}", + response.status(), + body + ); } } + } - if let Some((model_old_range, model_new_text)) = model_edits.peek() { - let model_old_offset_range = model_old_range.to_offset(old_snapshot); - if user_edit.old == model_old_offset_range { - let user_new_text = new_snapshot - .text_for_range(user_edit.new.clone()) - .collect::(); + pub fn refresh_context( + &mut self, + project: &Entity, + buffer: &Entity, + cursor_position: language::Anchor, + cx: &mut Context, + ) { + if self.use_context { + self.get_or_init_project(project, cx) + .context + .update(cx, |store, cx| { + store.refresh(buffer.clone(), cursor_position, cx); + }); + } + } - if let Some(model_suffix) = model_new_text.strip_prefix(&user_new_text) { - if !model_suffix.is_empty() { - let anchor = old_snapshot.anchor_after(user_edit.old.end); - edits.push((anchor..anchor, model_suffix.into())); - } + fn is_file_open_source( + &self, + project: &Entity, + file: &Arc, + cx: &App, + ) -> bool { + if !file.is_local() || file.is_private() { + return false; + } + let Some(project_state) = self.projects.get(&project.entity_id()) else { + return false; + }; + project_state + .license_detection_watchers + .get(&file.worktree_id(cx)) + .as_ref() + .is_some_and(|watcher| watcher.is_project_open_source()) + } - model_edits.next(); - continue; + fn can_collect_file(&self, project: &Entity, file: &Arc, cx: &App) -> bool { + self.data_collection_choice.is_enabled() && self.is_file_open_source(project, file, cx) + } + + fn can_collect_events(&self, events: &[Arc]) -> bool { + if !self.data_collection_choice.is_enabled() { + return false; + } + events.iter().all(|event| { + matches!( + event.as_ref(), + Event::BufferChange { + in_open_source_repo: true, + .. } + ) + }) + } + + fn load_data_collection_choice() -> DataCollectionChoice { + let choice = KEY_VALUE_STORE + .read_kvp(ZED_PREDICT_DATA_COLLECTION_CHOICE) + .log_err() + .flatten(); + + match choice.as_deref() { + Some("true") => DataCollectionChoice::Enabled, + Some("false") => DataCollectionChoice::Disabled, + Some(_) => { + log::error!("unknown value in '{ZED_PREDICT_DATA_COLLECTION_CHOICE}'"); + DataCollectionChoice::NotAnswered } + None => DataCollectionChoice::NotAnswered, + } + } + + fn toggle_data_collection_choice(&mut self, cx: &mut Context) { + self.data_collection_choice = self.data_collection_choice.toggle(); + let new_choice = self.data_collection_choice; + db::write_and_log(cx, move || { + KEY_VALUE_STORE.write_kvp( + ZED_PREDICT_DATA_COLLECTION_CHOICE.into(), + new_choice.is_enabled().to_string(), + ) + }); + } + + pub fn shown_predictions(&self) -> impl DoubleEndedIterator { + self.shown_predictions.iter() + } + + pub fn shown_completions_len(&self) -> usize { + self.shown_predictions.len() + } + + pub fn is_prediction_rated(&self, id: &EditPredictionId) -> bool { + self.rated_predictions.contains(id) + } + + pub fn rate_prediction( + &mut self, + prediction: &EditPrediction, + rating: EditPredictionRating, + feedback: String, + cx: &mut Context, + ) { + self.rated_predictions.insert(prediction.id.clone()); + telemetry::event!( + "Edit Prediction Rated", + rating, + inputs = prediction.inputs, + output = prediction.edit_preview.as_unified_diff(&prediction.edits), + feedback + ); + self.client.telemetry().flush_events().detach(); + cx.notify(); + } + + fn enable_or_disable_context_retrieval(&mut self, cx: &mut Context<'_, EditPredictionStore>) { + self.use_context = cx.has_flag::() + && all_language_settings(None, cx).edit_predictions.use_context; + } +} + +#[derive(Error, Debug)] +#[error( + "You must update to Zed version {minimum_version} or higher to continue using edit predictions." +)] +pub struct ZedUpdateRequiredError { + minimum_version: Version, +} + +#[cfg(feature = "eval-support")] +pub type EvalCacheKey = (EvalCacheEntryKind, u64); + +#[cfg(feature = "eval-support")] +#[derive(Debug, Clone, Copy, PartialEq)] +pub enum EvalCacheEntryKind { + Context, + Search, + Prediction, +} + +#[cfg(feature = "eval-support")] +impl std::fmt::Display for EvalCacheEntryKind { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + EvalCacheEntryKind::Search => write!(f, "search"), + EvalCacheEntryKind::Context => write!(f, "context"), + EvalCacheEntryKind::Prediction => write!(f, "prediction"), + } + } +} + +#[cfg(feature = "eval-support")] +pub trait EvalCache: Send + Sync { + fn read(&self, key: EvalCacheKey) -> Option; + fn write(&self, key: EvalCacheKey, input: &str, value: &str); +} + +#[derive(Debug, Clone, Copy)] +pub enum DataCollectionChoice { + NotAnswered, + Enabled, + Disabled, +} + +impl DataCollectionChoice { + pub fn is_enabled(self) -> bool { + match self { + Self::Enabled => true, + Self::NotAnswered | Self::Disabled => false, } + } - return None; + pub fn is_answered(self) -> bool { + match self { + Self::Enabled | Self::Disabled => true, + Self::NotAnswered => false, + } } - edits.extend(model_edits.cloned()); + #[must_use] + pub fn toggle(&self) -> DataCollectionChoice { + match self { + Self::Enabled => Self::Disabled, + Self::Disabled => Self::Enabled, + Self::NotAnswered => Self::Enabled, + } + } +} + +impl From for DataCollectionChoice { + fn from(value: bool) -> Self { + match value { + true => DataCollectionChoice::Enabled, + false => DataCollectionChoice::Disabled, + } + } +} + +struct ZedPredictUpsell; + +impl Dismissable for ZedPredictUpsell { + const KEY: &'static str = "dismissed-edit-predict-upsell"; + + fn dismissed() -> bool { + // To make this backwards compatible with older versions of Zed, we + // check if the user has seen the previous Edit Prediction Onboarding + // before, by checking the data collection choice which was written to + // the database once the user clicked on "Accept and Enable" + if KEY_VALUE_STORE + .read_kvp(ZED_PREDICT_DATA_COLLECTION_CHOICE) + .log_err() + .is_some_and(|s| s.is_some()) + { + return true; + } + + KEY_VALUE_STORE + .read_kvp(Self::KEY) + .log_err() + .is_some_and(|s| s.is_some()) + } +} + +pub fn should_show_upsell_modal() -> bool { + !ZedPredictUpsell::dismissed() +} + +pub fn init(cx: &mut App) { + cx.observe_new(move |workspace: &mut Workspace, _, _cx| { + workspace.register_action( + move |workspace, _: &zed_actions::OpenZedPredictOnboarding, window, cx| { + ZedPredictModal::toggle( + workspace, + workspace.user_store().clone(), + workspace.client().clone(), + window, + cx, + ) + }, + ); - if edits.is_empty() { None } else { Some(edits) } + workspace.register_action(|workspace, _: &ResetOnboarding, _window, cx| { + update_settings_file(workspace.app_state().fs.clone(), cx, move |settings, _| { + settings + .project + .all_languages + .features + .get_or_insert_default() + .edit_prediction_provider = Some(EditPredictionProvider::None) + }); + }); + }) + .detach(); } diff --git a/crates/edit_prediction/src/edit_prediction_tests.rs b/crates/edit_prediction/src/edit_prediction_tests.rs new file mode 100644 index 0000000000000000000000000000000000000000..8d5bad9ed8990769fd512ecfe523cf8d79aebca6 --- /dev/null +++ b/crates/edit_prediction/src/edit_prediction_tests.rs @@ -0,0 +1,1806 @@ +use super::*; +use crate::zeta1::MAX_EVENT_TOKENS; +use client::{UserStore, test::FakeServer}; +use clock::{FakeSystemClock, ReplicaId}; +use cloud_api_types::{CreateLlmTokenResponse, LlmToken}; +use cloud_llm_client::{ + EditPredictionRejectReason, EditPredictionRejection, PredictEditsBody, PredictEditsResponse, + RejectEditPredictionsBody, +}; +use edit_prediction_context::Line; +use futures::{ + AsyncReadExt, StreamExt, + channel::{mpsc, oneshot}, +}; +use gpui::{ + Entity, TestAppContext, + http_client::{FakeHttpClient, Response}, +}; +use indoc::indoc; +use language::{Point, ToOffset as _}; +use lsp::LanguageServerId; +use open_ai::Usage; +use parking_lot::Mutex; +use pretty_assertions::{assert_eq, assert_matches}; +use project::{FakeFs, Project}; +use serde_json::json; +use settings::SettingsStore; +use std::{path::Path, sync::Arc, time::Duration}; +use util::{path, rel_path::rel_path}; +use uuid::Uuid; + +use crate::{BufferEditPrediction, EditPredictionId, EditPredictionStore, REJECT_REQUEST_DEBOUNCE}; + +#[gpui::test] +async fn test_current_state(cx: &mut TestAppContext) { + let (ep_store, mut requests) = init_test_with_fake_client(cx); + let fs = FakeFs::new(cx.executor()); + fs.insert_tree( + "/root", + json!({ + "1.txt": "Hello!\nHow\nBye\n", + "2.txt": "Hola!\nComo\nAdios\n" + }), + ) + .await; + let project = Project::test(fs, vec![path!("/root").as_ref()], cx).await; + + ep_store.update(cx, |ep_store, cx| { + ep_store.register_project(&project, cx); + }); + + let buffer1 = project + .update(cx, |project, cx| { + let path = project.find_project_path(path!("/root/1.txt"), cx).unwrap(); + project.set_active_path(Some(path.clone()), cx); + project.open_buffer(path, cx) + }) + .await + .unwrap(); + let snapshot1 = buffer1.read_with(cx, |buffer, _cx| buffer.snapshot()); + let position = snapshot1.anchor_before(language::Point::new(1, 3)); + + // Prediction for current file + + ep_store.update(cx, |ep_store, cx| { + ep_store.refresh_prediction_from_buffer(project.clone(), buffer1.clone(), position, cx) + }); + let (_request, respond_tx) = requests.predict.next().await.unwrap(); + + respond_tx + .send(model_response(indoc! {r" + --- a/root/1.txt + +++ b/root/1.txt + @@ ... @@ + Hello! + -How + +How are you? + Bye + "})) + .unwrap(); + + cx.run_until_parked(); + + ep_store.read_with(cx, |ep_store, cx| { + let prediction = ep_store + .current_prediction_for_buffer(&buffer1, &project, cx) + .unwrap(); + assert_matches!(prediction, BufferEditPrediction::Local { .. }); + }); + + ep_store.update(cx, |ep_store, _cx| { + ep_store.reject_current_prediction(EditPredictionRejectReason::Discarded, &project); + }); + + // Prediction for diagnostic in another file + + let diagnostic = lsp::Diagnostic { + range: lsp::Range::new(lsp::Position::new(1, 1), lsp::Position::new(1, 5)), + severity: Some(lsp::DiagnosticSeverity::ERROR), + message: "Sentence is incomplete".to_string(), + ..Default::default() + }; + + project.update(cx, |project, cx| { + project.lsp_store().update(cx, |lsp_store, cx| { + lsp_store + .update_diagnostics( + LanguageServerId(0), + lsp::PublishDiagnosticsParams { + uri: lsp::Uri::from_file_path(path!("/root/2.txt")).unwrap(), + diagnostics: vec![diagnostic], + version: None, + }, + None, + language::DiagnosticSourceKind::Pushed, + &[], + cx, + ) + .unwrap(); + }); + }); + + let (_request, respond_tx) = requests.predict.next().await.unwrap(); + respond_tx + .send(model_response(indoc! {r#" + --- a/root/2.txt + +++ b/root/2.txt + Hola! + -Como + +Como estas? + Adios + "#})) + .unwrap(); + cx.run_until_parked(); + + ep_store.read_with(cx, |ep_store, cx| { + let prediction = ep_store + .current_prediction_for_buffer(&buffer1, &project, cx) + .unwrap(); + assert_matches!( + prediction, + BufferEditPrediction::Jump { prediction } if prediction.snapshot.file().unwrap().full_path(cx) == Path::new(path!("root/2.txt")) + ); + }); + + let buffer2 = project + .update(cx, |project, cx| { + let path = project.find_project_path(path!("root/2.txt"), cx).unwrap(); + project.open_buffer(path, cx) + }) + .await + .unwrap(); + + ep_store.read_with(cx, |ep_store, cx| { + let prediction = ep_store + .current_prediction_for_buffer(&buffer2, &project, cx) + .unwrap(); + assert_matches!(prediction, BufferEditPrediction::Local { .. }); + }); +} + +#[gpui::test] +async fn test_simple_request(cx: &mut TestAppContext) { + let (ep_store, mut requests) = init_test_with_fake_client(cx); + let fs = FakeFs::new(cx.executor()); + fs.insert_tree( + "/root", + json!({ + "foo.md": "Hello!\nHow\nBye\n" + }), + ) + .await; + let project = Project::test(fs, vec![path!("/root").as_ref()], cx).await; + + let buffer = project + .update(cx, |project, cx| { + let path = project.find_project_path(path!("root/foo.md"), cx).unwrap(); + project.open_buffer(path, cx) + }) + .await + .unwrap(); + let snapshot = buffer.read_with(cx, |buffer, _cx| buffer.snapshot()); + let position = snapshot.anchor_before(language::Point::new(1, 3)); + + let prediction_task = ep_store.update(cx, |ep_store, cx| { + ep_store.request_prediction(&project, &buffer, position, Default::default(), cx) + }); + + let (_, respond_tx) = requests.predict.next().await.unwrap(); + + // TODO Put back when we have a structured request again + // assert_eq!( + // request.excerpt_path.as_ref(), + // Path::new(path!("root/foo.md")) + // ); + // assert_eq!( + // request.cursor_point, + // Point { + // line: Line(1), + // column: 3 + // } + // ); + + respond_tx + .send(model_response(indoc! { r" + --- a/root/foo.md + +++ b/root/foo.md + @@ ... @@ + Hello! + -How + +How are you? + Bye + "})) + .unwrap(); + + let prediction = prediction_task.await.unwrap().unwrap().prediction.unwrap(); + + assert_eq!(prediction.edits.len(), 1); + assert_eq!( + prediction.edits[0].0.to_point(&snapshot).start, + language::Point::new(1, 3) + ); + assert_eq!(prediction.edits[0].1.as_ref(), " are you?"); +} + +#[gpui::test] +async fn test_request_events(cx: &mut TestAppContext) { + let (ep_store, mut requests) = init_test_with_fake_client(cx); + let fs = FakeFs::new(cx.executor()); + fs.insert_tree( + "/root", + json!({ + "foo.md": "Hello!\n\nBye\n" + }), + ) + .await; + let project = Project::test(fs, vec![path!("/root").as_ref()], cx).await; + + let buffer = project + .update(cx, |project, cx| { + let path = project.find_project_path(path!("root/foo.md"), cx).unwrap(); + project.open_buffer(path, cx) + }) + .await + .unwrap(); + + ep_store.update(cx, |ep_store, cx| { + ep_store.register_buffer(&buffer, &project, cx); + }); + + buffer.update(cx, |buffer, cx| { + buffer.edit(vec![(7..7, "How")], None, cx); + }); + + let snapshot = buffer.read_with(cx, |buffer, _cx| buffer.snapshot()); + let position = snapshot.anchor_before(language::Point::new(1, 3)); + + let prediction_task = ep_store.update(cx, |ep_store, cx| { + ep_store.request_prediction(&project, &buffer, position, Default::default(), cx) + }); + + let (request, respond_tx) = requests.predict.next().await.unwrap(); + + let prompt = prompt_from_request(&request); + assert!( + prompt.contains(indoc! {" + --- a/root/foo.md + +++ b/root/foo.md + @@ -1,3 +1,3 @@ + Hello! + - + +How + Bye + "}), + "{prompt}" + ); + + respond_tx + .send(model_response(indoc! {r#" + --- a/root/foo.md + +++ b/root/foo.md + @@ ... @@ + Hello! + -How + +How are you? + Bye + "#})) + .unwrap(); + + let prediction = prediction_task.await.unwrap().unwrap().prediction.unwrap(); + + assert_eq!(prediction.edits.len(), 1); + assert_eq!( + prediction.edits[0].0.to_point(&snapshot).start, + language::Point::new(1, 3) + ); + assert_eq!(prediction.edits[0].1.as_ref(), " are you?"); +} + +#[gpui::test] +async fn test_empty_prediction(cx: &mut TestAppContext) { + let (ep_store, mut requests) = init_test_with_fake_client(cx); + let fs = FakeFs::new(cx.executor()); + fs.insert_tree( + "/root", + json!({ + "foo.md": "Hello!\nHow\nBye\n" + }), + ) + .await; + let project = Project::test(fs, vec![path!("/root").as_ref()], cx).await; + + let buffer = project + .update(cx, |project, cx| { + let path = project.find_project_path(path!("root/foo.md"), cx).unwrap(); + project.open_buffer(path, cx) + }) + .await + .unwrap(); + let snapshot = buffer.read_with(cx, |buffer, _cx| buffer.snapshot()); + let position = snapshot.anchor_before(language::Point::new(1, 3)); + + ep_store.update(cx, |ep_store, cx| { + ep_store.refresh_prediction_from_buffer(project.clone(), buffer.clone(), position, cx); + }); + + const NO_OP_DIFF: &str = indoc! { r" + --- a/root/foo.md + +++ b/root/foo.md + @@ ... @@ + Hello! + -How + +How + Bye + "}; + + let (_, respond_tx) = requests.predict.next().await.unwrap(); + let response = model_response(NO_OP_DIFF); + let id = response.id.clone(); + respond_tx.send(response).unwrap(); + + cx.run_until_parked(); + + ep_store.read_with(cx, |ep_store, cx| { + assert!( + ep_store + .current_prediction_for_buffer(&buffer, &project, cx) + .is_none() + ); + }); + + // prediction is reported as rejected + let (reject_request, _) = requests.reject.next().await.unwrap(); + + assert_eq!( + &reject_request.rejections, + &[EditPredictionRejection { + request_id: id, + reason: EditPredictionRejectReason::Empty, + was_shown: false + }] + ); +} + +#[gpui::test] +async fn test_interpolated_empty(cx: &mut TestAppContext) { + let (ep_store, mut requests) = init_test_with_fake_client(cx); + let fs = FakeFs::new(cx.executor()); + fs.insert_tree( + "/root", + json!({ + "foo.md": "Hello!\nHow\nBye\n" + }), + ) + .await; + let project = Project::test(fs, vec![path!("/root").as_ref()], cx).await; + + let buffer = project + .update(cx, |project, cx| { + let path = project.find_project_path(path!("root/foo.md"), cx).unwrap(); + project.open_buffer(path, cx) + }) + .await + .unwrap(); + let snapshot = buffer.read_with(cx, |buffer, _cx| buffer.snapshot()); + let position = snapshot.anchor_before(language::Point::new(1, 3)); + + ep_store.update(cx, |ep_store, cx| { + ep_store.refresh_prediction_from_buffer(project.clone(), buffer.clone(), position, cx); + }); + + let (_, respond_tx) = requests.predict.next().await.unwrap(); + + buffer.update(cx, |buffer, cx| { + buffer.set_text("Hello!\nHow are you?\nBye", cx); + }); + + let response = model_response(SIMPLE_DIFF); + let id = response.id.clone(); + respond_tx.send(response).unwrap(); + + cx.run_until_parked(); + + ep_store.read_with(cx, |ep_store, cx| { + assert!( + ep_store + .current_prediction_for_buffer(&buffer, &project, cx) + .is_none() + ); + }); + + // prediction is reported as rejected + let (reject_request, _) = requests.reject.next().await.unwrap(); + + assert_eq!( + &reject_request.rejections, + &[EditPredictionRejection { + request_id: id, + reason: EditPredictionRejectReason::InterpolatedEmpty, + was_shown: false + }] + ); +} + +const SIMPLE_DIFF: &str = indoc! { r" + --- a/root/foo.md + +++ b/root/foo.md + @@ ... @@ + Hello! + -How + +How are you? + Bye +"}; + +#[gpui::test] +async fn test_replace_current(cx: &mut TestAppContext) { + let (ep_store, mut requests) = init_test_with_fake_client(cx); + let fs = FakeFs::new(cx.executor()); + fs.insert_tree( + "/root", + json!({ + "foo.md": "Hello!\nHow\nBye\n" + }), + ) + .await; + let project = Project::test(fs, vec![path!("/root").as_ref()], cx).await; + + let buffer = project + .update(cx, |project, cx| { + let path = project.find_project_path(path!("root/foo.md"), cx).unwrap(); + project.open_buffer(path, cx) + }) + .await + .unwrap(); + let snapshot = buffer.read_with(cx, |buffer, _cx| buffer.snapshot()); + let position = snapshot.anchor_before(language::Point::new(1, 3)); + + ep_store.update(cx, |ep_store, cx| { + ep_store.refresh_prediction_from_buffer(project.clone(), buffer.clone(), position, cx); + }); + + let (_, respond_tx) = requests.predict.next().await.unwrap(); + let first_response = model_response(SIMPLE_DIFF); + let first_id = first_response.id.clone(); + respond_tx.send(first_response).unwrap(); + + cx.run_until_parked(); + + ep_store.read_with(cx, |ep_store, cx| { + assert_eq!( + ep_store + .current_prediction_for_buffer(&buffer, &project, cx) + .unwrap() + .id + .0, + first_id + ); + }); + + // a second request is triggered + ep_store.update(cx, |ep_store, cx| { + ep_store.refresh_prediction_from_buffer(project.clone(), buffer.clone(), position, cx); + }); + + let (_, respond_tx) = requests.predict.next().await.unwrap(); + let second_response = model_response(SIMPLE_DIFF); + let second_id = second_response.id.clone(); + respond_tx.send(second_response).unwrap(); + + cx.run_until_parked(); + + ep_store.read_with(cx, |ep_store, cx| { + // second replaces first + assert_eq!( + ep_store + .current_prediction_for_buffer(&buffer, &project, cx) + .unwrap() + .id + .0, + second_id + ); + }); + + // first is reported as replaced + let (reject_request, _) = requests.reject.next().await.unwrap(); + + assert_eq!( + &reject_request.rejections, + &[EditPredictionRejection { + request_id: first_id, + reason: EditPredictionRejectReason::Replaced, + was_shown: false + }] + ); +} + +#[gpui::test] +async fn test_current_preferred(cx: &mut TestAppContext) { + let (ep_store, mut requests) = init_test_with_fake_client(cx); + let fs = FakeFs::new(cx.executor()); + fs.insert_tree( + "/root", + json!({ + "foo.md": "Hello!\nHow\nBye\n" + }), + ) + .await; + let project = Project::test(fs, vec![path!("/root").as_ref()], cx).await; + + let buffer = project + .update(cx, |project, cx| { + let path = project.find_project_path(path!("root/foo.md"), cx).unwrap(); + project.open_buffer(path, cx) + }) + .await + .unwrap(); + let snapshot = buffer.read_with(cx, |buffer, _cx| buffer.snapshot()); + let position = snapshot.anchor_before(language::Point::new(1, 3)); + + ep_store.update(cx, |ep_store, cx| { + ep_store.refresh_prediction_from_buffer(project.clone(), buffer.clone(), position, cx); + }); + + let (_, respond_tx) = requests.predict.next().await.unwrap(); + let first_response = model_response(SIMPLE_DIFF); + let first_id = first_response.id.clone(); + respond_tx.send(first_response).unwrap(); + + cx.run_until_parked(); + + ep_store.read_with(cx, |ep_store, cx| { + assert_eq!( + ep_store + .current_prediction_for_buffer(&buffer, &project, cx) + .unwrap() + .id + .0, + first_id + ); + }); + + // a second request is triggered + ep_store.update(cx, |ep_store, cx| { + ep_store.refresh_prediction_from_buffer(project.clone(), buffer.clone(), position, cx); + }); + + let (_, respond_tx) = requests.predict.next().await.unwrap(); + // worse than current prediction + let second_response = model_response(indoc! { r" + --- a/root/foo.md + +++ b/root/foo.md + @@ ... @@ + Hello! + -How + +How are + Bye + "}); + let second_id = second_response.id.clone(); + respond_tx.send(second_response).unwrap(); + + cx.run_until_parked(); + + ep_store.read_with(cx, |ep_store, cx| { + // first is preferred over second + assert_eq!( + ep_store + .current_prediction_for_buffer(&buffer, &project, cx) + .unwrap() + .id + .0, + first_id + ); + }); + + // second is reported as rejected + let (reject_request, _) = requests.reject.next().await.unwrap(); + + assert_eq!( + &reject_request.rejections, + &[EditPredictionRejection { + request_id: second_id, + reason: EditPredictionRejectReason::CurrentPreferred, + was_shown: false + }] + ); +} + +#[gpui::test] +async fn test_cancel_earlier_pending_requests(cx: &mut TestAppContext) { + let (ep_store, mut requests) = init_test_with_fake_client(cx); + let fs = FakeFs::new(cx.executor()); + fs.insert_tree( + "/root", + json!({ + "foo.md": "Hello!\nHow\nBye\n" + }), + ) + .await; + let project = Project::test(fs, vec![path!("/root").as_ref()], cx).await; + + let buffer = project + .update(cx, |project, cx| { + let path = project.find_project_path(path!("root/foo.md"), cx).unwrap(); + project.open_buffer(path, cx) + }) + .await + .unwrap(); + let snapshot = buffer.read_with(cx, |buffer, _cx| buffer.snapshot()); + let position = snapshot.anchor_before(language::Point::new(1, 3)); + + // start two refresh tasks + ep_store.update(cx, |ep_store, cx| { + ep_store.refresh_prediction_from_buffer(project.clone(), buffer.clone(), position, cx); + }); + + let (_, respond_first) = requests.predict.next().await.unwrap(); + + ep_store.update(cx, |ep_store, cx| { + ep_store.refresh_prediction_from_buffer(project.clone(), buffer.clone(), position, cx); + }); + + let (_, respond_second) = requests.predict.next().await.unwrap(); + + // wait for throttle + cx.run_until_parked(); + + // second responds first + let second_response = model_response(SIMPLE_DIFF); + let second_id = second_response.id.clone(); + respond_second.send(second_response).unwrap(); + + cx.run_until_parked(); + + ep_store.read_with(cx, |ep_store, cx| { + // current prediction is second + assert_eq!( + ep_store + .current_prediction_for_buffer(&buffer, &project, cx) + .unwrap() + .id + .0, + second_id + ); + }); + + let first_response = model_response(SIMPLE_DIFF); + let first_id = first_response.id.clone(); + respond_first.send(first_response).unwrap(); + + cx.run_until_parked(); + + ep_store.read_with(cx, |ep_store, cx| { + // current prediction is still second, since first was cancelled + assert_eq!( + ep_store + .current_prediction_for_buffer(&buffer, &project, cx) + .unwrap() + .id + .0, + second_id + ); + }); + + // first is reported as rejected + let (reject_request, _) = requests.reject.next().await.unwrap(); + + cx.run_until_parked(); + + assert_eq!( + &reject_request.rejections, + &[EditPredictionRejection { + request_id: first_id, + reason: EditPredictionRejectReason::Canceled, + was_shown: false + }] + ); +} + +#[gpui::test] +async fn test_cancel_second_on_third_request(cx: &mut TestAppContext) { + let (ep_store, mut requests) = init_test_with_fake_client(cx); + let fs = FakeFs::new(cx.executor()); + fs.insert_tree( + "/root", + json!({ + "foo.md": "Hello!\nHow\nBye\n" + }), + ) + .await; + let project = Project::test(fs, vec![path!("/root").as_ref()], cx).await; + + let buffer = project + .update(cx, |project, cx| { + let path = project.find_project_path(path!("root/foo.md"), cx).unwrap(); + project.open_buffer(path, cx) + }) + .await + .unwrap(); + let snapshot = buffer.read_with(cx, |buffer, _cx| buffer.snapshot()); + let position = snapshot.anchor_before(language::Point::new(1, 3)); + + // start two refresh tasks + ep_store.update(cx, |ep_store, cx| { + ep_store.refresh_prediction_from_buffer(project.clone(), buffer.clone(), position, cx); + }); + + let (_, respond_first) = requests.predict.next().await.unwrap(); + + ep_store.update(cx, |ep_store, cx| { + ep_store.refresh_prediction_from_buffer(project.clone(), buffer.clone(), position, cx); + }); + + let (_, respond_second) = requests.predict.next().await.unwrap(); + + // wait for throttle, so requests are sent + cx.run_until_parked(); + + ep_store.update(cx, |ep_store, cx| { + // start a third request + ep_store.refresh_prediction_from_buffer(project.clone(), buffer.clone(), position, cx); + + // 2 are pending, so 2nd is cancelled + assert_eq!( + ep_store + .get_or_init_project(&project, cx) + .cancelled_predictions + .iter() + .copied() + .collect::>(), + [1] + ); + }); + + // wait for throttle + cx.run_until_parked(); + + let (_, respond_third) = requests.predict.next().await.unwrap(); + + let first_response = model_response(SIMPLE_DIFF); + let first_id = first_response.id.clone(); + respond_first.send(first_response).unwrap(); + + cx.run_until_parked(); + + ep_store.read_with(cx, |ep_store, cx| { + // current prediction is first + assert_eq!( + ep_store + .current_prediction_for_buffer(&buffer, &project, cx) + .unwrap() + .id + .0, + first_id + ); + }); + + let cancelled_response = model_response(SIMPLE_DIFF); + let cancelled_id = cancelled_response.id.clone(); + respond_second.send(cancelled_response).unwrap(); + + cx.run_until_parked(); + + ep_store.read_with(cx, |ep_store, cx| { + // current prediction is still first, since second was cancelled + assert_eq!( + ep_store + .current_prediction_for_buffer(&buffer, &project, cx) + .unwrap() + .id + .0, + first_id + ); + }); + + let third_response = model_response(SIMPLE_DIFF); + let third_response_id = third_response.id.clone(); + respond_third.send(third_response).unwrap(); + + cx.run_until_parked(); + + ep_store.read_with(cx, |ep_store, cx| { + // third completes and replaces first + assert_eq!( + ep_store + .current_prediction_for_buffer(&buffer, &project, cx) + .unwrap() + .id + .0, + third_response_id + ); + }); + + // second is reported as rejected + let (reject_request, _) = requests.reject.next().await.unwrap(); + + cx.run_until_parked(); + + assert_eq!( + &reject_request.rejections, + &[ + EditPredictionRejection { + request_id: cancelled_id, + reason: EditPredictionRejectReason::Canceled, + was_shown: false + }, + EditPredictionRejection { + request_id: first_id, + reason: EditPredictionRejectReason::Replaced, + was_shown: false + } + ] + ); +} + +#[gpui::test] +async fn test_rejections_flushing(cx: &mut TestAppContext) { + let (ep_store, mut requests) = init_test_with_fake_client(cx); + + ep_store.update(cx, |ep_store, _cx| { + ep_store.reject_prediction( + EditPredictionId("test-1".into()), + EditPredictionRejectReason::Discarded, + false, + ); + ep_store.reject_prediction( + EditPredictionId("test-2".into()), + EditPredictionRejectReason::Canceled, + true, + ); + }); + + cx.executor().advance_clock(REJECT_REQUEST_DEBOUNCE); + cx.run_until_parked(); + + let (reject_request, respond_tx) = requests.reject.next().await.unwrap(); + respond_tx.send(()).unwrap(); + + // batched + assert_eq!(reject_request.rejections.len(), 2); + assert_eq!( + reject_request.rejections[0], + EditPredictionRejection { + request_id: "test-1".to_string(), + reason: EditPredictionRejectReason::Discarded, + was_shown: false + } + ); + assert_eq!( + reject_request.rejections[1], + EditPredictionRejection { + request_id: "test-2".to_string(), + reason: EditPredictionRejectReason::Canceled, + was_shown: true + } + ); + + // Reaching batch size limit sends without debounce + ep_store.update(cx, |ep_store, _cx| { + for i in 0..70 { + ep_store.reject_prediction( + EditPredictionId(format!("batch-{}", i).into()), + EditPredictionRejectReason::Discarded, + false, + ); + } + }); + + // First MAX/2 items are sent immediately + cx.run_until_parked(); + let (reject_request, respond_tx) = requests.reject.next().await.unwrap(); + respond_tx.send(()).unwrap(); + + assert_eq!(reject_request.rejections.len(), 50); + assert_eq!(reject_request.rejections[0].request_id, "batch-0"); + assert_eq!(reject_request.rejections[49].request_id, "batch-49"); + + // Remaining items are debounced with the next batch + cx.executor().advance_clock(Duration::from_secs(15)); + cx.run_until_parked(); + + let (reject_request, respond_tx) = requests.reject.next().await.unwrap(); + respond_tx.send(()).unwrap(); + + assert_eq!(reject_request.rejections.len(), 20); + assert_eq!(reject_request.rejections[0].request_id, "batch-50"); + assert_eq!(reject_request.rejections[19].request_id, "batch-69"); + + // Request failure + ep_store.update(cx, |ep_store, _cx| { + ep_store.reject_prediction( + EditPredictionId("retry-1".into()), + EditPredictionRejectReason::Discarded, + false, + ); + }); + + cx.executor().advance_clock(REJECT_REQUEST_DEBOUNCE); + cx.run_until_parked(); + + let (reject_request, _respond_tx) = requests.reject.next().await.unwrap(); + assert_eq!(reject_request.rejections.len(), 1); + assert_eq!(reject_request.rejections[0].request_id, "retry-1"); + // Simulate failure + drop(_respond_tx); + + // Add another rejection + ep_store.update(cx, |ep_store, _cx| { + ep_store.reject_prediction( + EditPredictionId("retry-2".into()), + EditPredictionRejectReason::Discarded, + false, + ); + }); + + cx.executor().advance_clock(REJECT_REQUEST_DEBOUNCE); + cx.run_until_parked(); + + // Retry should include both the failed item and the new one + let (reject_request, respond_tx) = requests.reject.next().await.unwrap(); + respond_tx.send(()).unwrap(); + + assert_eq!(reject_request.rejections.len(), 2); + assert_eq!(reject_request.rejections[0].request_id, "retry-1"); + assert_eq!(reject_request.rejections[1].request_id, "retry-2"); +} + +// Skipped until we start including diagnostics in prompt +// #[gpui::test] +// async fn test_request_diagnostics(cx: &mut TestAppContext) { +// let (ep_store, mut req_rx) = init_test_with_fake_client(cx); +// let fs = FakeFs::new(cx.executor()); +// fs.insert_tree( +// "/root", +// json!({ +// "foo.md": "Hello!\nBye" +// }), +// ) +// .await; +// let project = Project::test(fs, vec![path!("/root").as_ref()], cx).await; + +// let path_to_buffer_uri = lsp::Uri::from_file_path(path!("/root/foo.md")).unwrap(); +// let diagnostic = lsp::Diagnostic { +// range: lsp::Range::new(lsp::Position::new(1, 1), lsp::Position::new(1, 5)), +// severity: Some(lsp::DiagnosticSeverity::ERROR), +// message: "\"Hello\" deprecated. Use \"Hi\" instead".to_string(), +// ..Default::default() +// }; + +// project.update(cx, |project, cx| { +// project.lsp_store().update(cx, |lsp_store, cx| { +// // Create some diagnostics +// lsp_store +// .update_diagnostics( +// LanguageServerId(0), +// lsp::PublishDiagnosticsParams { +// uri: path_to_buffer_uri.clone(), +// diagnostics: vec![diagnostic], +// version: None, +// }, +// None, +// language::DiagnosticSourceKind::Pushed, +// &[], +// cx, +// ) +// .unwrap(); +// }); +// }); + +// let buffer = project +// .update(cx, |project, cx| { +// let path = project.find_project_path(path!("root/foo.md"), cx).unwrap(); +// project.open_buffer(path, cx) +// }) +// .await +// .unwrap(); + +// let snapshot = buffer.read_with(cx, |buffer, _cx| buffer.snapshot()); +// let position = snapshot.anchor_before(language::Point::new(0, 0)); + +// let _prediction_task = ep_store.update(cx, |ep_store, cx| { +// ep_store.request_prediction(&project, &buffer, position, cx) +// }); + +// let (request, _respond_tx) = req_rx.next().await.unwrap(); + +// assert_eq!(request.diagnostic_groups.len(), 1); +// let value = serde_json::from_str::(request.diagnostic_groups[0].0.get()) +// .unwrap(); +// // We probably don't need all of this. TODO define a specific diagnostic type in predict_edits_v3 +// assert_eq!( +// value, +// json!({ +// "entries": [{ +// "range": { +// "start": 8, +// "end": 10 +// }, +// "diagnostic": { +// "source": null, +// "code": null, +// "code_description": null, +// "severity": 1, +// "message": "\"Hello\" deprecated. Use \"Hi\" instead", +// "markdown": null, +// "group_id": 0, +// "is_primary": true, +// "is_disk_based": false, +// "is_unnecessary": false, +// "source_kind": "Pushed", +// "data": null, +// "underline": true +// } +// }], +// "primary_ix": 0 +// }) +// ); +// } + +fn model_response(text: &str) -> open_ai::Response { + open_ai::Response { + id: Uuid::new_v4().to_string(), + object: "response".into(), + created: 0, + model: "model".into(), + choices: vec![open_ai::Choice { + index: 0, + message: open_ai::RequestMessage::Assistant { + content: Some(open_ai::MessageContent::Plain(text.to_string())), + tool_calls: vec![], + }, + finish_reason: None, + }], + usage: Usage { + prompt_tokens: 0, + completion_tokens: 0, + total_tokens: 0, + }, + } +} + +fn prompt_from_request(request: &open_ai::Request) -> &str { + assert_eq!(request.messages.len(), 1); + let open_ai::RequestMessage::User { + content: open_ai::MessageContent::Plain(content), + .. + } = &request.messages[0] + else { + panic!( + "Request does not have single user message of type Plain. {:#?}", + request + ); + }; + content +} + +struct RequestChannels { + predict: mpsc::UnboundedReceiver<(open_ai::Request, oneshot::Sender)>, + reject: mpsc::UnboundedReceiver<(RejectEditPredictionsBody, oneshot::Sender<()>)>, +} + +fn init_test_with_fake_client( + cx: &mut TestAppContext, +) -> (Entity, RequestChannels) { + cx.update(move |cx| { + let settings_store = SettingsStore::test(cx); + cx.set_global(settings_store); + zlog::init_test(); + + let (predict_req_tx, predict_req_rx) = mpsc::unbounded(); + let (reject_req_tx, reject_req_rx) = mpsc::unbounded(); + + let http_client = FakeHttpClient::create({ + move |req| { + let uri = req.uri().path().to_string(); + let mut body = req.into_body(); + let predict_req_tx = predict_req_tx.clone(); + let reject_req_tx = reject_req_tx.clone(); + async move { + let resp = match uri.as_str() { + "/client/llm_tokens" => serde_json::to_string(&json!({ + "token": "test" + })) + .unwrap(), + "/predict_edits/raw" => { + let mut buf = Vec::new(); + body.read_to_end(&mut buf).await.ok(); + let req = serde_json::from_slice(&buf).unwrap(); + + let (res_tx, res_rx) = oneshot::channel(); + predict_req_tx.unbounded_send((req, res_tx)).unwrap(); + serde_json::to_string(&res_rx.await?).unwrap() + } + "/predict_edits/reject" => { + let mut buf = Vec::new(); + body.read_to_end(&mut buf).await.ok(); + let req = serde_json::from_slice(&buf).unwrap(); + + let (res_tx, res_rx) = oneshot::channel(); + reject_req_tx.unbounded_send((req, res_tx)).unwrap(); + serde_json::to_string(&res_rx.await?).unwrap() + } + _ => { + panic!("Unexpected path: {}", uri) + } + }; + + Ok(Response::builder().body(resp.into()).unwrap()) + } + } + }); + + let client = client::Client::new(Arc::new(FakeSystemClock::new()), http_client, cx); + client.cloud_client().set_credentials(1, "test".into()); + + language_model::init(client.clone(), cx); + + let user_store = cx.new(|cx| UserStore::new(client.clone(), cx)); + let ep_store = EditPredictionStore::global(&client, &user_store, cx); + + ( + ep_store, + RequestChannels { + predict: predict_req_rx, + reject: reject_req_rx, + }, + ) + }) +} + +const BSD_0_TXT: &str = include_str!("../license_examples/0bsd.txt"); + +#[gpui::test] +async fn test_edit_prediction_basic_interpolation(cx: &mut TestAppContext) { + let buffer = cx.new(|cx| Buffer::local("Lorem ipsum dolor", cx)); + let edits: Arc<[(Range, Arc)]> = cx.update(|cx| { + to_completion_edits([(2..5, "REM".into()), (9..11, "".into())], &buffer, cx).into() + }); + + let edit_preview = cx + .read(|cx| buffer.read(cx).preview_edits(edits.clone(), cx)) + .await; + + let completion = EditPrediction { + edits, + edit_preview, + buffer: buffer.clone(), + snapshot: cx.read(|cx| buffer.read(cx).snapshot()), + id: EditPredictionId("the-id".into()), + inputs: EditPredictionInputs { + events: Default::default(), + included_files: Default::default(), + cursor_point: cloud_llm_client::predict_edits_v3::Point { + line: Line(0), + column: 0, + }, + cursor_path: Path::new("").into(), + }, + buffer_snapshotted_at: Instant::now(), + response_received_at: Instant::now(), + }; + + cx.update(|cx| { + assert_eq!( + from_completion_edits( + &completion.interpolate(&buffer.read(cx).snapshot()).unwrap(), + &buffer, + cx + ), + vec![(2..5, "REM".into()), (9..11, "".into())] + ); + + buffer.update(cx, |buffer, cx| buffer.edit([(2..5, "")], None, cx)); + assert_eq!( + from_completion_edits( + &completion.interpolate(&buffer.read(cx).snapshot()).unwrap(), + &buffer, + cx + ), + vec![(2..2, "REM".into()), (6..8, "".into())] + ); + + buffer.update(cx, |buffer, cx| buffer.undo(cx)); + assert_eq!( + from_completion_edits( + &completion.interpolate(&buffer.read(cx).snapshot()).unwrap(), + &buffer, + cx + ), + vec![(2..5, "REM".into()), (9..11, "".into())] + ); + + buffer.update(cx, |buffer, cx| buffer.edit([(2..5, "R")], None, cx)); + assert_eq!( + from_completion_edits( + &completion.interpolate(&buffer.read(cx).snapshot()).unwrap(), + &buffer, + cx + ), + vec![(3..3, "EM".into()), (7..9, "".into())] + ); + + buffer.update(cx, |buffer, cx| buffer.edit([(3..3, "E")], None, cx)); + assert_eq!( + from_completion_edits( + &completion.interpolate(&buffer.read(cx).snapshot()).unwrap(), + &buffer, + cx + ), + vec![(4..4, "M".into()), (8..10, "".into())] + ); + + buffer.update(cx, |buffer, cx| buffer.edit([(4..4, "M")], None, cx)); + assert_eq!( + from_completion_edits( + &completion.interpolate(&buffer.read(cx).snapshot()).unwrap(), + &buffer, + cx + ), + vec![(9..11, "".into())] + ); + + buffer.update(cx, |buffer, cx| buffer.edit([(4..5, "")], None, cx)); + assert_eq!( + from_completion_edits( + &completion.interpolate(&buffer.read(cx).snapshot()).unwrap(), + &buffer, + cx + ), + vec![(4..4, "M".into()), (8..10, "".into())] + ); + + buffer.update(cx, |buffer, cx| buffer.edit([(8..10, "")], None, cx)); + assert_eq!( + from_completion_edits( + &completion.interpolate(&buffer.read(cx).snapshot()).unwrap(), + &buffer, + cx + ), + vec![(4..4, "M".into())] + ); + + buffer.update(cx, |buffer, cx| buffer.edit([(4..6, "")], None, cx)); + assert_eq!(completion.interpolate(&buffer.read(cx).snapshot()), None); + }) +} + +#[gpui::test] +async fn test_clean_up_diff(cx: &mut TestAppContext) { + init_test(cx); + + assert_eq!( + apply_edit_prediction( + indoc! {" + fn main() { + let word_1 = \"lorem\"; + let range = word.len()..word.len(); + } + "}, + indoc! {" + <|editable_region_start|> + fn main() { + let word_1 = \"lorem\"; + let range = word_1.len()..word_1.len(); + } + + <|editable_region_end|> + "}, + cx, + ) + .await, + indoc! {" + fn main() { + let word_1 = \"lorem\"; + let range = word_1.len()..word_1.len(); + } + "}, + ); + + assert_eq!( + apply_edit_prediction( + indoc! {" + fn main() { + let story = \"the quick\" + } + "}, + indoc! {" + <|editable_region_start|> + fn main() { + let story = \"the quick brown fox jumps over the lazy dog\"; + } + + <|editable_region_end|> + "}, + cx, + ) + .await, + indoc! {" + fn main() { + let story = \"the quick brown fox jumps over the lazy dog\"; + } + "}, + ); +} + +#[gpui::test] +async fn test_edit_prediction_end_of_buffer(cx: &mut TestAppContext) { + init_test(cx); + + let buffer_content = "lorem\n"; + let completion_response = indoc! {" + ```animals.js + <|start_of_file|> + <|editable_region_start|> + lorem + ipsum + <|editable_region_end|> + ```"}; + + assert_eq!( + apply_edit_prediction(buffer_content, completion_response, cx).await, + "lorem\nipsum" + ); +} + +#[gpui::test] +async fn test_can_collect_data(cx: &mut TestAppContext) { + init_test(cx); + + let fs = project::FakeFs::new(cx.executor()); + fs.insert_tree(path!("/project"), json!({ "LICENSE": BSD_0_TXT })) + .await; + + let project = Project::test(fs.clone(), [path!("/project").as_ref()], cx).await; + let buffer = project + .update(cx, |project, cx| { + project.open_local_buffer(path!("/project/src/main.rs"), cx) + }) + .await + .unwrap(); + + let (ep_store, captured_request, _) = make_test_ep_store(&project, cx).await; + ep_store.update(cx, |ep_store, _cx| { + ep_store.data_collection_choice = DataCollectionChoice::Enabled + }); + + run_edit_prediction(&buffer, &project, &ep_store, cx).await; + assert_eq!( + captured_request.lock().clone().unwrap().can_collect_data, + true + ); + + ep_store.update(cx, |ep_store, _cx| { + ep_store.data_collection_choice = DataCollectionChoice::Disabled + }); + + run_edit_prediction(&buffer, &project, &ep_store, cx).await; + assert_eq!( + captured_request.lock().clone().unwrap().can_collect_data, + false + ); +} + +#[gpui::test] +async fn test_no_data_collection_for_remote_file(cx: &mut TestAppContext) { + init_test(cx); + + let fs = project::FakeFs::new(cx.executor()); + let project = Project::test(fs.clone(), [], cx).await; + + let buffer = cx.new(|_cx| { + Buffer::remote( + language::BufferId::new(1).unwrap(), + ReplicaId::new(1), + language::Capability::ReadWrite, + "fn main() {\n println!(\"Hello\");\n}", + ) + }); + + let (ep_store, captured_request, _) = make_test_ep_store(&project, cx).await; + ep_store.update(cx, |ep_store, _cx| { + ep_store.data_collection_choice = DataCollectionChoice::Enabled + }); + + run_edit_prediction(&buffer, &project, &ep_store, cx).await; + assert_eq!( + captured_request.lock().clone().unwrap().can_collect_data, + false + ); +} + +#[gpui::test] +async fn test_no_data_collection_for_private_file(cx: &mut TestAppContext) { + init_test(cx); + + let fs = project::FakeFs::new(cx.executor()); + fs.insert_tree( + path!("/project"), + json!({ + "LICENSE": BSD_0_TXT, + ".env": "SECRET_KEY=secret" + }), + ) + .await; + + let project = Project::test(fs.clone(), [path!("/project").as_ref()], cx).await; + let buffer = project + .update(cx, |project, cx| { + project.open_local_buffer("/project/.env", cx) + }) + .await + .unwrap(); + + let (ep_store, captured_request, _) = make_test_ep_store(&project, cx).await; + ep_store.update(cx, |ep_store, _cx| { + ep_store.data_collection_choice = DataCollectionChoice::Enabled + }); + + run_edit_prediction(&buffer, &project, &ep_store, cx).await; + assert_eq!( + captured_request.lock().clone().unwrap().can_collect_data, + false + ); +} + +#[gpui::test] +async fn test_no_data_collection_for_untitled_buffer(cx: &mut TestAppContext) { + init_test(cx); + + let fs = project::FakeFs::new(cx.executor()); + let project = Project::test(fs.clone(), [], cx).await; + let buffer = cx.new(|cx| Buffer::local("", cx)); + + let (ep_store, captured_request, _) = make_test_ep_store(&project, cx).await; + ep_store.update(cx, |ep_store, _cx| { + ep_store.data_collection_choice = DataCollectionChoice::Enabled + }); + + run_edit_prediction(&buffer, &project, &ep_store, cx).await; + assert_eq!( + captured_request.lock().clone().unwrap().can_collect_data, + false + ); +} + +#[gpui::test] +async fn test_no_data_collection_when_closed_source(cx: &mut TestAppContext) { + init_test(cx); + + let fs = project::FakeFs::new(cx.executor()); + fs.insert_tree(path!("/project"), json!({ "main.rs": "fn main() {}" })) + .await; + + let project = Project::test(fs.clone(), [path!("/project").as_ref()], cx).await; + let buffer = project + .update(cx, |project, cx| { + project.open_local_buffer("/project/main.rs", cx) + }) + .await + .unwrap(); + + let (ep_store, captured_request, _) = make_test_ep_store(&project, cx).await; + ep_store.update(cx, |ep_store, _cx| { + ep_store.data_collection_choice = DataCollectionChoice::Enabled + }); + + run_edit_prediction(&buffer, &project, &ep_store, cx).await; + assert_eq!( + captured_request.lock().clone().unwrap().can_collect_data, + false + ); +} + +#[gpui::test] +async fn test_data_collection_status_changes_on_move(cx: &mut TestAppContext) { + init_test(cx); + + let fs = project::FakeFs::new(cx.executor()); + fs.insert_tree( + path!("/open_source_worktree"), + json!({ "LICENSE": BSD_0_TXT, "main.rs": "" }), + ) + .await; + fs.insert_tree(path!("/closed_source_worktree"), json!({ "main.rs": "" })) + .await; + + let project = Project::test( + fs.clone(), + [ + path!("/open_source_worktree").as_ref(), + path!("/closed_source_worktree").as_ref(), + ], + cx, + ) + .await; + let buffer = project + .update(cx, |project, cx| { + project.open_local_buffer(path!("/open_source_worktree/main.rs"), cx) + }) + .await + .unwrap(); + + let (ep_store, captured_request, _) = make_test_ep_store(&project, cx).await; + ep_store.update(cx, |ep_store, _cx| { + ep_store.data_collection_choice = DataCollectionChoice::Enabled + }); + + run_edit_prediction(&buffer, &project, &ep_store, cx).await; + assert_eq!( + captured_request.lock().clone().unwrap().can_collect_data, + true + ); + + let closed_source_file = project + .update(cx, |project, cx| { + let worktree2 = project + .worktree_for_root_name("closed_source_worktree", cx) + .unwrap(); + worktree2.update(cx, |worktree2, cx| { + worktree2.load_file(rel_path("main.rs"), cx) + }) + }) + .await + .unwrap() + .file; + + buffer.update(cx, |buffer, cx| { + buffer.file_updated(closed_source_file, cx); + }); + + run_edit_prediction(&buffer, &project, &ep_store, cx).await; + assert_eq!( + captured_request.lock().clone().unwrap().can_collect_data, + false + ); +} + +#[gpui::test] +async fn test_no_data_collection_for_events_in_uncollectable_buffers(cx: &mut TestAppContext) { + init_test(cx); + + let fs = project::FakeFs::new(cx.executor()); + fs.insert_tree( + path!("/worktree1"), + json!({ "LICENSE": BSD_0_TXT, "main.rs": "", "other.rs": "" }), + ) + .await; + fs.insert_tree(path!("/worktree2"), json!({ "private.rs": "" })) + .await; + + let project = Project::test( + fs.clone(), + [path!("/worktree1").as_ref(), path!("/worktree2").as_ref()], + cx, + ) + .await; + let buffer = project + .update(cx, |project, cx| { + project.open_local_buffer(path!("/worktree1/main.rs"), cx) + }) + .await + .unwrap(); + let private_buffer = project + .update(cx, |project, cx| { + project.open_local_buffer(path!("/worktree2/file.rs"), cx) + }) + .await + .unwrap(); + + let (ep_store, captured_request, _) = make_test_ep_store(&project, cx).await; + ep_store.update(cx, |ep_store, _cx| { + ep_store.data_collection_choice = DataCollectionChoice::Enabled + }); + + run_edit_prediction(&buffer, &project, &ep_store, cx).await; + assert_eq!( + captured_request.lock().clone().unwrap().can_collect_data, + true + ); + + // this has a side effect of registering the buffer to watch for edits + run_edit_prediction(&private_buffer, &project, &ep_store, cx).await; + assert_eq!( + captured_request.lock().clone().unwrap().can_collect_data, + false + ); + + private_buffer.update(cx, |private_buffer, cx| { + private_buffer.edit([(0..0, "An edit for the history!")], None, cx); + }); + + run_edit_prediction(&buffer, &project, &ep_store, cx).await; + assert_eq!( + captured_request.lock().clone().unwrap().can_collect_data, + false + ); + + // make an edit that uses too many bytes, causing private_buffer edit to not be able to be + // included + buffer.update(cx, |buffer, cx| { + buffer.edit( + [( + 0..0, + " ".repeat(MAX_EVENT_TOKENS * zeta1::BYTES_PER_TOKEN_GUESS), + )], + None, + cx, + ); + }); + + run_edit_prediction(&buffer, &project, &ep_store, cx).await; + assert_eq!( + captured_request.lock().clone().unwrap().can_collect_data, + true + ); +} + +fn init_test(cx: &mut TestAppContext) { + cx.update(|cx| { + let settings_store = SettingsStore::test(cx); + cx.set_global(settings_store); + }); +} + +async fn apply_edit_prediction( + buffer_content: &str, + completion_response: &str, + cx: &mut TestAppContext, +) -> String { + let fs = project::FakeFs::new(cx.executor()); + let project = Project::test(fs.clone(), [path!("/project").as_ref()], cx).await; + let buffer = cx.new(|cx| Buffer::local(buffer_content, cx)); + let (ep_store, _, response) = make_test_ep_store(&project, cx).await; + *response.lock() = completion_response.to_string(); + let edit_prediction = run_edit_prediction(&buffer, &project, &ep_store, cx).await; + buffer.update(cx, |buffer, cx| { + buffer.edit(edit_prediction.edits.iter().cloned(), None, cx) + }); + buffer.read_with(cx, |buffer, _| buffer.text()) +} + +async fn run_edit_prediction( + buffer: &Entity, + project: &Entity, + ep_store: &Entity, + cx: &mut TestAppContext, +) -> EditPrediction { + let cursor = buffer.read_with(cx, |buffer, _| buffer.anchor_before(Point::new(1, 0))); + ep_store.update(cx, |ep_store, cx| { + ep_store.register_buffer(buffer, &project, cx) + }); + cx.background_executor.run_until_parked(); + let prediction_task = ep_store.update(cx, |ep_store, cx| { + ep_store.request_prediction(&project, buffer, cursor, Default::default(), cx) + }); + prediction_task.await.unwrap().unwrap().prediction.unwrap() +} + +async fn make_test_ep_store( + project: &Entity, + cx: &mut TestAppContext, +) -> ( + Entity, + Arc>>, + Arc>, +) { + let default_response = indoc! {" + ```main.rs + <|start_of_file|> + <|editable_region_start|> + hello world + <|editable_region_end|> + ```" + }; + let captured_request: Arc>> = Arc::new(Mutex::new(None)); + let completion_response: Arc> = + Arc::new(Mutex::new(default_response.to_string())); + let http_client = FakeHttpClient::create({ + let captured_request = captured_request.clone(); + let completion_response = completion_response.clone(); + let mut next_request_id = 0; + move |req| { + let captured_request = captured_request.clone(); + let completion_response = completion_response.clone(); + async move { + match (req.method(), req.uri().path()) { + (&Method::POST, "/client/llm_tokens") => Ok(http_client::Response::builder() + .status(200) + .body( + serde_json::to_string(&CreateLlmTokenResponse { + token: LlmToken("the-llm-token".to_string()), + }) + .unwrap() + .into(), + ) + .unwrap()), + (&Method::POST, "/predict_edits/v2") => { + let mut request_body = String::new(); + req.into_body().read_to_string(&mut request_body).await?; + *captured_request.lock() = + Some(serde_json::from_str(&request_body).unwrap()); + next_request_id += 1; + Ok(http_client::Response::builder() + .status(200) + .body( + serde_json::to_string(&PredictEditsResponse { + request_id: format!("request-{next_request_id}"), + output_excerpt: completion_response.lock().clone(), + }) + .unwrap() + .into(), + ) + .unwrap()) + } + _ => Ok(http_client::Response::builder() + .status(404) + .body("Not Found".into()) + .unwrap()), + } + } + } + }); + + let client = cx.update(|cx| Client::new(Arc::new(FakeSystemClock::new()), http_client, cx)); + cx.update(|cx| { + RefreshLlmTokenListener::register(client.clone(), cx); + }); + let _server = FakeServer::for_client(42, &client, cx).await; + + let ep_store = cx.new(|cx| { + let mut ep_store = EditPredictionStore::new(client, project.read(cx).user_store(), cx); + ep_store.set_edit_prediction_model(EditPredictionModel::Zeta1); + + let worktrees = project.read(cx).worktrees(cx).collect::>(); + for worktree in worktrees { + let worktree_id = worktree.read(cx).id(); + ep_store + .get_or_init_project(project, cx) + .license_detection_watchers + .entry(worktree_id) + .or_insert_with(|| Rc::new(LicenseDetectionWatcher::new(&worktree, cx))); + } + + ep_store + }); + + (ep_store, captured_request, completion_response) +} + +fn to_completion_edits( + iterator: impl IntoIterator, Arc)>, + buffer: &Entity, + cx: &App, +) -> Vec<(Range, Arc)> { + let buffer = buffer.read(cx); + iterator + .into_iter() + .map(|(range, text)| { + ( + buffer.anchor_after(range.start)..buffer.anchor_before(range.end), + text, + ) + }) + .collect() +} + +fn from_completion_edits( + editor_edits: &[(Range, Arc)], + buffer: &Entity, + cx: &App, +) -> Vec<(Range, Arc)> { + let buffer = buffer.read(cx); + editor_edits + .iter() + .map(|(range, text)| { + ( + range.start.to_offset(buffer)..range.end.to_offset(buffer), + text.clone(), + ) + }) + .collect() +} + +#[ctor::ctor] +fn init_logger() { + zlog::init_test(); +} diff --git a/crates/zeta/src/license_detection.rs b/crates/edit_prediction/src/license_detection.rs similarity index 100% rename from crates/zeta/src/license_detection.rs rename to crates/edit_prediction/src/license_detection.rs diff --git a/crates/zeta/src/onboarding_modal.rs b/crates/edit_prediction/src/onboarding_modal.rs similarity index 100% rename from crates/zeta/src/onboarding_modal.rs rename to crates/edit_prediction/src/onboarding_modal.rs diff --git a/crates/zeta/src/prediction.rs b/crates/edit_prediction/src/prediction.rs similarity index 99% rename from crates/zeta/src/prediction.rs rename to crates/edit_prediction/src/prediction.rs index fd3241730030fe8bdd95e2cae9ee87b406ade735..d169cf26e1dc4477554bfe8821ff5eae083a6124 100644 --- a/crates/zeta/src/prediction.rs +++ b/crates/edit_prediction/src/prediction.rs @@ -99,7 +99,7 @@ pub struct EditPrediction { #[derive(Debug, Clone, Serialize)] pub struct EditPredictionInputs { pub events: Vec>, - pub included_files: Vec, + pub included_files: Vec, pub cursor_point: cloud_llm_client::predict_edits_v3::Point, pub cursor_path: Arc, } diff --git a/crates/zeta/src/sweep_ai.rs b/crates/edit_prediction/src/sweep_ai.rs similarity index 99% rename from crates/zeta/src/sweep_ai.rs rename to crates/edit_prediction/src/sweep_ai.rs index 0bc0d1d41e2393212f865e402912f6d760aa252e..4bb014c640cb489db29c800835a58febf91a7270 100644 --- a/crates/zeta/src/sweep_ai.rs +++ b/crates/edit_prediction/src/sweep_ai.rs @@ -1,7 +1,7 @@ use anyhow::{Context as _, Result}; use cloud_llm_client::predict_edits_v3::Event; use credentials_provider::CredentialsProvider; -use edit_prediction_context2::RelatedFile; +use edit_prediction_context::RelatedFile; use futures::{AsyncReadExt as _, FutureExt, future::Shared}; use gpui::{ App, AppContext as _, Entity, Task, @@ -197,7 +197,7 @@ impl SweepAi { let inputs = EditPredictionInputs { events, - included_files: vec![cloud_llm_client::predict_edits_v3::IncludedFile { + included_files: vec![cloud_llm_client::predict_edits_v3::RelatedFile { path: full_path.clone(), max_row: cloud_llm_client::predict_edits_v3::Line(snapshot.max_point().row), excerpts: vec![cloud_llm_client::predict_edits_v3::Excerpt { diff --git a/crates/zeta/src/udiff.rs b/crates/edit_prediction/src/udiff.rs similarity index 100% rename from crates/zeta/src/udiff.rs rename to crates/edit_prediction/src/udiff.rs diff --git a/crates/zeta/src/xml_edits.rs b/crates/edit_prediction/src/xml_edits.rs similarity index 100% rename from crates/zeta/src/xml_edits.rs rename to crates/edit_prediction/src/xml_edits.rs diff --git a/crates/zeta/src/provider.rs b/crates/edit_prediction/src/zed_edit_prediction_delegate.rs similarity index 58% rename from crates/zeta/src/provider.rs rename to crates/edit_prediction/src/zed_edit_prediction_delegate.rs index 019d780e579c079f745f56136bdbd3a4add76b50..91371d539beca012e2ded4e9ec8702c8db39bd8a 100644 --- a/crates/zeta/src/provider.rs +++ b/crates/edit_prediction/src/zed_edit_prediction_delegate.rs @@ -1,55 +1,56 @@ -use std::{cmp, sync::Arc, time::Duration}; +use std::{cmp, sync::Arc}; use client::{Client, UserStore}; use cloud_llm_client::EditPredictionRejectReason; -use edit_prediction::{DataCollectionState, Direction, EditPredictionProvider}; +use edit_prediction_types::{DataCollectionState, Direction, EditPredictionDelegate}; use gpui::{App, Entity, prelude::*}; -use language::ToPoint as _; +use language::{Buffer, ToPoint as _}; use project::Project; -use crate::{BufferEditPrediction, Zeta, ZetaEditPredictionModel}; +use crate::{BufferEditPrediction, EditPredictionModel, EditPredictionStore}; -pub struct ZetaEditPredictionProvider { - zeta: Entity, +pub struct ZedEditPredictionDelegate { + store: Entity, project: Entity, + singleton_buffer: Option>, } -impl ZetaEditPredictionProvider { - pub const THROTTLE_TIMEOUT: Duration = Duration::from_millis(300); - +impl ZedEditPredictionDelegate { pub fn new( project: Entity, + singleton_buffer: Option>, client: &Arc, user_store: &Entity, cx: &mut Context, ) -> Self { - let zeta = Zeta::global(client, user_store, cx); - zeta.update(cx, |zeta, cx| { - zeta.register_project(&project, cx); + let store = EditPredictionStore::global(client, user_store, cx); + store.update(cx, |store, cx| { + store.register_project(&project, cx); }); - cx.observe(&zeta, |_this, _zeta, cx| { + cx.observe(&store, |_this, _ep_store, cx| { cx.notify(); }) .detach(); Self { project: project, - zeta, + store: store, + singleton_buffer, } } } -impl EditPredictionProvider for ZetaEditPredictionProvider { +impl EditPredictionDelegate for ZedEditPredictionDelegate { fn name() -> &'static str { - "zed-predict2" + "zed-predict" } fn display_name() -> &'static str { - "Zed's Edit Predictions 2" + "Zed's Edit Predictions" } - fn show_completions_in_menu() -> bool { + fn show_predictions_in_menu() -> bool { true } @@ -57,17 +58,38 @@ impl EditPredictionProvider for ZetaEditPredictionProvider { true } - fn data_collection_state(&self, _cx: &App) -> DataCollectionState { - // TODO [zeta2] - DataCollectionState::Unsupported + fn data_collection_state(&self, cx: &App) -> DataCollectionState { + if let Some(buffer) = &self.singleton_buffer + && let Some(file) = buffer.read(cx).file() + { + let is_project_open_source = + self.store + .read(cx) + .is_file_open_source(&self.project, file, cx); + if self.store.read(cx).data_collection_choice.is_enabled() { + DataCollectionState::Enabled { + is_project_open_source, + } + } else { + DataCollectionState::Disabled { + is_project_open_source, + } + } + } else { + return DataCollectionState::Disabled { + is_project_open_source: false, + }; + } } - fn toggle_data_collection(&mut self, _cx: &mut App) { - // TODO [zeta2] + fn toggle_data_collection(&mut self, cx: &mut App) { + self.store.update(cx, |store, cx| { + store.toggle_data_collection_choice(cx); + }); } fn usage(&self, cx: &App) -> Option { - self.zeta.read(cx).usage(cx) + self.store.read(cx).usage(cx) } fn is_enabled( @@ -76,16 +98,16 @@ impl EditPredictionProvider for ZetaEditPredictionProvider { _cursor_position: language::Anchor, cx: &App, ) -> bool { - let zeta = self.zeta.read(cx); - if zeta.edit_prediction_model == ZetaEditPredictionModel::Sweep { - zeta.has_sweep_api_token() + let store = self.store.read(cx); + if store.edit_prediction_model == EditPredictionModel::Sweep { + store.has_sweep_api_token() } else { true } } fn is_refreshing(&self, cx: &App) -> bool { - self.zeta.read(cx).is_refreshing(&self.project) + self.store.read(cx).is_refreshing(&self.project) } fn refresh( @@ -95,24 +117,24 @@ impl EditPredictionProvider for ZetaEditPredictionProvider { _debounce: bool, cx: &mut Context, ) { - let zeta = self.zeta.read(cx); + let store = self.store.read(cx); - if zeta.user_store.read_with(cx, |user_store, _cx| { + if store.user_store.read_with(cx, |user_store, _cx| { user_store.account_too_young() || user_store.has_overdue_invoices() }) { return; } - if let Some(current) = zeta.current_prediction_for_buffer(&buffer, &self.project, cx) + if let Some(current) = store.current_prediction_for_buffer(&buffer, &self.project, cx) && let BufferEditPrediction::Local { prediction } = current && prediction.interpolate(buffer.read(cx)).is_some() { return; } - self.zeta.update(cx, |zeta, cx| { - zeta.refresh_context_if_needed(&self.project, &buffer, cursor_position, cx); - zeta.refresh_prediction_from_buffer(self.project.clone(), buffer, cursor_position, cx) + self.store.update(cx, |store, cx| { + store.refresh_context(&self.project, &buffer, cursor_position, cx); + store.refresh_prediction_from_buffer(self.project.clone(), buffer, cursor_position, cx) }); } @@ -126,20 +148,20 @@ impl EditPredictionProvider for ZetaEditPredictionProvider { } fn accept(&mut self, cx: &mut Context) { - self.zeta.update(cx, |zeta, cx| { - zeta.accept_current_prediction(&self.project, cx); + self.store.update(cx, |store, cx| { + store.accept_current_prediction(&self.project, cx); }); } fn discard(&mut self, cx: &mut Context) { - self.zeta.update(cx, |zeta, _cx| { - zeta.reject_current_prediction(EditPredictionRejectReason::Discarded, &self.project); + self.store.update(cx, |store, _cx| { + store.reject_current_prediction(EditPredictionRejectReason::Discarded, &self.project); }); } fn did_show(&mut self, cx: &mut Context) { - self.zeta.update(cx, |zeta, cx| { - zeta.did_show_current_prediction(&self.project, cx); + self.store.update(cx, |store, cx| { + store.did_show_current_prediction(&self.project, cx); }); } @@ -148,16 +170,16 @@ impl EditPredictionProvider for ZetaEditPredictionProvider { buffer: &Entity, cursor_position: language::Anchor, cx: &mut Context, - ) -> Option { + ) -> Option { let prediction = - self.zeta + self.store .read(cx) .current_prediction_for_buffer(buffer, &self.project, cx)?; let prediction = match prediction { BufferEditPrediction::Local { prediction } => prediction, BufferEditPrediction::Jump { prediction } => { - return Some(edit_prediction::EditPrediction::Jump { + return Some(edit_prediction_types::EditPrediction::Jump { id: Some(prediction.id.to_string().into()), snapshot: prediction.snapshot.clone(), target: prediction.edits.first().unwrap().0.start, @@ -169,8 +191,8 @@ impl EditPredictionProvider for ZetaEditPredictionProvider { let snapshot = buffer.snapshot(); let Some(edits) = prediction.interpolate(&snapshot) else { - self.zeta.update(cx, |zeta, _cx| { - zeta.reject_current_prediction( + self.store.update(cx, |store, _cx| { + store.reject_current_prediction( EditPredictionRejectReason::InterpolatedEmpty, &self.project, ); @@ -208,7 +230,7 @@ impl EditPredictionProvider for ZetaEditPredictionProvider { } } - Some(edit_prediction::EditPrediction::Local { + Some(edit_prediction_types::EditPrediction::Local { id: Some(prediction.id.to_string().into()), edits: edits[edit_start_ix..edit_end_ix].to_vec(), edit_preview: Some(prediction.edit_preview.clone()), diff --git a/crates/zeta/src/zeta1.rs b/crates/edit_prediction/src/zeta1.rs similarity index 96% rename from crates/zeta/src/zeta1.rs rename to crates/edit_prediction/src/zeta1.rs index 0be5fad301242c51c4ad58c60a6d2fcb3441ea08..06248603464563db12fa55a90c9c0bccf153c5f4 100644 --- a/crates/zeta/src/zeta1.rs +++ b/crates/edit_prediction/src/zeta1.rs @@ -3,7 +3,7 @@ mod input_excerpt; use std::{fmt::Write, ops::Range, path::Path, sync::Arc, time::Instant}; use crate::{ - EditPredictionId, ZedUpdateRequiredError, Zeta, + EditPredictionId, EditPredictionStore, ZedUpdateRequiredError, prediction::{EditPredictionInputs, EditPredictionResult}, }; use anyhow::{Context as _, Result}; @@ -30,23 +30,23 @@ pub(crate) const MAX_REWRITE_TOKENS: usize = 350; pub(crate) const MAX_EVENT_TOKENS: usize = 500; pub(crate) fn request_prediction_with_zeta1( - zeta: &mut Zeta, + store: &mut EditPredictionStore, project: &Entity, buffer: &Entity, snapshot: BufferSnapshot, position: language::Anchor, events: Vec>, trigger: PredictEditsRequestTrigger, - cx: &mut Context, + cx: &mut Context, ) -> Task>> { let buffer = buffer.clone(); let buffer_snapshotted_at = Instant::now(); - let client = zeta.client.clone(); - let llm_token = zeta.llm_token.clone(); + let client = store.client.clone(); + let llm_token = store.llm_token.clone(); let app_version = AppVersion::global(cx); let (git_info, can_collect_file) = if let Some(file) = snapshot.file() { - let can_collect_file = zeta.can_collect_file(project, file, cx); + let can_collect_file = store.can_collect_file(project, file, cx); let git_info = if can_collect_file { git_info_for_file(project, &ProjectPath::from_file(file.as_ref(), cx), cx) } else { @@ -102,7 +102,7 @@ pub(crate) fn request_prediction_with_zeta1( let http_client = client.http_client(); - let response = Zeta::send_api_request::( + let response = EditPredictionStore::send_api_request::( |request| { let uri = if let Ok(predict_edits_url) = std::env::var("ZED_PREDICT_EDITS_URL") { predict_edits_url @@ -124,7 +124,7 @@ pub(crate) fn request_prediction_with_zeta1( let inputs = EditPredictionInputs { events: included_events.into(), - included_files: vec![cloud_llm_client::predict_edits_v3::IncludedFile { + included_files: vec![cloud_llm_client::predict_edits_v3::RelatedFile { path: full_path.clone(), max_row: cloud_llm_client::predict_edits_v3::Line(snapshot.max_point().row), excerpts: vec![cloud_llm_client::predict_edits_v3::Excerpt { @@ -155,8 +155,8 @@ pub(crate) fn request_prediction_with_zeta1( Err(err) => { if err.is::() { cx.update(|cx| { - this.update(cx, |zeta, _cx| { - zeta.update_required = true; + this.update(cx, |ep_store, _cx| { + ep_store.update_required = true; }) .ok(); diff --git a/crates/zeta/src/zeta1/input_excerpt.rs b/crates/edit_prediction/src/zeta1/input_excerpt.rs similarity index 100% rename from crates/zeta/src/zeta1/input_excerpt.rs rename to crates/edit_prediction/src/zeta1/input_excerpt.rs diff --git a/crates/edit_prediction/src/zeta2.rs b/crates/edit_prediction/src/zeta2.rs new file mode 100644 index 0000000000000000000000000000000000000000..4808f38fc529b1c34212dd0198d15fb03a0baddf --- /dev/null +++ b/crates/edit_prediction/src/zeta2.rs @@ -0,0 +1,358 @@ +#[cfg(feature = "eval-support")] +use crate::EvalCacheEntryKind; +use crate::prediction::EditPredictionResult; +use crate::{ + DebugEvent, EDIT_PREDICTIONS_MODEL_ID, EditPredictionId, EditPredictionInputs, + EditPredictionRequestedDebugEvent, EditPredictionStore, +}; +use anyhow::{Result, anyhow, bail}; +use cloud_llm_client::predict_edits_v3::{self, Event, PromptFormat}; +use cloud_llm_client::{EditPredictionRejectReason, PredictEditsRequestTrigger}; +use cloud_zeta2_prompt::CURSOR_MARKER; +use edit_prediction_context::{EditPredictionExcerpt, Line}; +use edit_prediction_context::{RelatedExcerpt, RelatedFile}; +use futures::channel::oneshot; +use gpui::{Entity, Task, prelude::*}; +use language::{Anchor, BufferSnapshot}; +use language::{Buffer, Point, ToOffset as _, ToPoint}; +use project::{Project, ProjectItem as _}; +use release_channel::AppVersion; +use std::{ + env, + path::Path, + sync::Arc, + time::{Duration, Instant}, +}; + +pub fn request_prediction_with_zeta2( + store: &mut EditPredictionStore, + project: &Entity, + active_buffer: &Entity, + active_snapshot: BufferSnapshot, + position: Anchor, + events: Vec>, + mut included_files: Vec, + trigger: PredictEditsRequestTrigger, + cx: &mut Context, +) -> Task>> { + let options = store.options.clone(); + let buffer_snapshotted_at = Instant::now(); + + let Some((excerpt_path, active_project_path)) = active_snapshot + .file() + .map(|file| -> Arc { file.full_path(cx).into() }) + .zip(active_buffer.read(cx).project_path(cx)) + else { + return Task::ready(Err(anyhow!("No file path for excerpt"))); + }; + + let client = store.client.clone(); + let llm_token = store.llm_token.clone(); + let app_version = AppVersion::global(cx); + let debug_tx = store.debug_tx.clone(); + + let file = active_buffer.read(cx).file(); + + let active_file_full_path = file.as_ref().map(|f| f.full_path(cx)); + + // TODO data collection + let can_collect_data = file + .as_ref() + .map_or(false, |file| store.can_collect_file(project, file, cx)); + + #[cfg(feature = "eval-support")] + let eval_cache = store.eval_cache.clone(); + + let request_task = cx.background_spawn({ + let active_buffer = active_buffer.clone(); + async move { + let cursor_offset = position.to_offset(&active_snapshot); + let cursor_point = cursor_offset.to_point(&active_snapshot); + + let before_retrieval = Instant::now(); + + let excerpt_options = options.context; + + let Some(excerpt) = EditPredictionExcerpt::select_from_buffer( + cursor_point, + &active_snapshot, + &excerpt_options, + ) else { + return Ok((None, None)); + }; + + let excerpt_anchor_range = active_snapshot.anchor_after(excerpt.range.start) + ..active_snapshot.anchor_before(excerpt.range.end); + let related_excerpt = RelatedExcerpt { + anchor_range: excerpt_anchor_range.clone(), + point_range: Point::new(excerpt.line_range.start.0, 0) + ..Point::new(excerpt.line_range.end.0, 0), + text: active_snapshot.as_rope().slice(excerpt.range), + }; + + if let Some(buffer_ix) = included_files + .iter() + .position(|file| file.buffer.entity_id() == active_buffer.entity_id()) + { + let file = &mut included_files[buffer_ix]; + file.excerpts.push(related_excerpt); + file.merge_excerpts(); + let last_ix = included_files.len() - 1; + included_files.swap(buffer_ix, last_ix); + } else { + let active_file = RelatedFile { + path: active_project_path, + buffer: active_buffer.downgrade(), + excerpts: vec![related_excerpt], + max_row: active_snapshot.max_point().row, + }; + included_files.push(active_file); + } + + let included_files = included_files + .iter() + .map(|related_file| predict_edits_v3::RelatedFile { + path: Arc::from(related_file.path.path.as_std_path()), + max_row: Line(related_file.max_row), + excerpts: related_file + .excerpts + .iter() + .map(|excerpt| predict_edits_v3::Excerpt { + start_line: Line(excerpt.point_range.start.row), + text: excerpt.text.to_string().into(), + }) + .collect(), + }) + .collect::>(); + + let cloud_request = predict_edits_v3::PredictEditsRequest { + excerpt_path, + excerpt: String::new(), + excerpt_line_range: Line(0)..Line(0), + excerpt_range: 0..0, + cursor_point: predict_edits_v3::Point { + line: predict_edits_v3::Line(cursor_point.row), + column: cursor_point.column, + }, + related_files: included_files, + events, + can_collect_data, + debug_info: debug_tx.is_some(), + prompt_max_bytes: Some(options.max_prompt_bytes), + prompt_format: options.prompt_format, + excerpt_parent: None, + git_info: None, + trigger, + }; + + let prompt_result = cloud_zeta2_prompt::build_prompt(&cloud_request); + + let inputs = EditPredictionInputs { + included_files: cloud_request.related_files, + events: cloud_request.events, + cursor_point: cloud_request.cursor_point, + cursor_path: cloud_request.excerpt_path, + }; + + let retrieval_time = Instant::now() - before_retrieval; + + let debug_response_tx = if let Some(debug_tx) = &debug_tx { + let (response_tx, response_rx) = oneshot::channel(); + + debug_tx + .unbounded_send(DebugEvent::EditPredictionRequested( + EditPredictionRequestedDebugEvent { + inputs: inputs.clone(), + retrieval_time, + buffer: active_buffer.downgrade(), + local_prompt: match prompt_result.as_ref() { + Ok(prompt) => Ok(prompt.clone()), + Err(err) => Err(err.to_string()), + }, + position, + response_rx, + }, + )) + .ok(); + Some(response_tx) + } else { + None + }; + + if cfg!(debug_assertions) && env::var("ZED_ZETA2_SKIP_REQUEST").is_ok() { + if let Some(debug_response_tx) = debug_response_tx { + debug_response_tx + .send((Err("Request skipped".to_string()), Duration::ZERO)) + .ok(); + } + anyhow::bail!("Skipping request because ZED_ZETA2_SKIP_REQUEST is set") + } + + let prompt = prompt_result?; + let generation_params = + cloud_zeta2_prompt::generation_params(cloud_request.prompt_format); + let request = open_ai::Request { + model: EDIT_PREDICTIONS_MODEL_ID.clone(), + messages: vec![open_ai::RequestMessage::User { + content: open_ai::MessageContent::Plain(prompt), + }], + stream: false, + max_completion_tokens: None, + stop: generation_params.stop.unwrap_or_default(), + temperature: generation_params.temperature.unwrap_or(0.7), + tool_choice: None, + parallel_tool_calls: None, + tools: vec![], + prompt_cache_key: None, + reasoning_effort: None, + }; + + log::trace!("Sending edit prediction request"); + + let before_request = Instant::now(); + let response = EditPredictionStore::send_raw_llm_request( + request, + client, + llm_token, + app_version, + #[cfg(feature = "eval-support")] + eval_cache, + #[cfg(feature = "eval-support")] + EvalCacheEntryKind::Prediction, + ) + .await; + let received_response_at = Instant::now(); + let request_time = received_response_at - before_request; + + log::trace!("Got edit prediction response"); + + if let Some(debug_response_tx) = debug_response_tx { + debug_response_tx + .send(( + response + .as_ref() + .map_err(|err| err.to_string()) + .map(|response| response.0.clone()), + request_time, + )) + .ok(); + } + + let (res, usage) = response?; + let request_id = EditPredictionId(res.id.clone().into()); + let Some(mut output_text) = text_from_response(res) else { + return Ok((Some((request_id, None)), usage)); + }; + + if output_text.contains(CURSOR_MARKER) { + log::trace!("Stripping out {CURSOR_MARKER} from response"); + output_text = output_text.replace(CURSOR_MARKER, ""); + } + + let get_buffer_from_context = |path: &Path| { + if Some(path) == active_file_full_path.as_deref() { + Some(( + &active_snapshot, + std::slice::from_ref(&excerpt_anchor_range), + )) + } else { + None + } + }; + + let (_, edits) = match options.prompt_format { + PromptFormat::Minimal | PromptFormat::MinimalQwen | PromptFormat::SeedCoder1120 => { + if output_text.contains("--- a/\n+++ b/\nNo edits") { + let edits = vec![]; + (&active_snapshot, edits) + } else { + crate::udiff::parse_diff(&output_text, get_buffer_from_context).await? + } + } + PromptFormat::OldTextNewText => { + crate::xml_edits::parse_xml_edits(&output_text, get_buffer_from_context).await? + } + _ => { + bail!("unsupported prompt format {}", options.prompt_format) + } + }; + + anyhow::Ok(( + Some(( + request_id, + Some(( + inputs, + active_buffer, + active_snapshot.clone(), + edits, + received_response_at, + )), + )), + usage, + )) + } + }); + + cx.spawn(async move |this, cx| { + let Some((id, prediction)) = + EditPredictionStore::handle_api_response(&this, request_task.await, cx)? + else { + return Ok(None); + }; + + let Some((inputs, edited_buffer, edited_buffer_snapshot, edits, received_response_at)) = + prediction + else { + return Ok(Some(EditPredictionResult { + id, + prediction: Err(EditPredictionRejectReason::Empty), + })); + }; + + Ok(Some( + EditPredictionResult::new( + id, + &edited_buffer, + &edited_buffer_snapshot, + edits.into(), + buffer_snapshotted_at, + received_response_at, + inputs, + cx, + ) + .await, + )) + }) +} + +pub fn text_from_response(mut res: open_ai::Response) -> Option { + let choice = res.choices.pop()?; + let output_text = match choice.message { + open_ai::RequestMessage::Assistant { + content: Some(open_ai::MessageContent::Plain(content)), + .. + } => content, + open_ai::RequestMessage::Assistant { + content: Some(open_ai::MessageContent::Multipart(mut content)), + .. + } => { + if content.is_empty() { + log::error!("No output from Baseten completion response"); + return None; + } + + match content.remove(0) { + open_ai::MessagePart::Text { text } => text, + open_ai::MessagePart::Image { .. } => { + log::error!("Expected text, got an image"); + return None; + } + } + } + _ => { + log::error!("Invalid response message: {:?}", choice.message); + return None; + } + }; + Some(output_text) +} diff --git a/crates/zeta_cli/Cargo.toml b/crates/edit_prediction_cli/Cargo.toml similarity index 84% rename from crates/zeta_cli/Cargo.toml rename to crates/edit_prediction_cli/Cargo.toml index 2dbca537f55377e84f306e13649dfb71ccf2f181..d1b0b3f912ed2143b6c75ae39e94c2f7780ec4fe 100644 --- a/crates/zeta_cli/Cargo.toml +++ b/crates/edit_prediction_cli/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "zeta_cli" +name = "edit_prediction_cli" version = "0.1.0" edition.workspace = true publish.workspace = true @@ -9,7 +9,7 @@ license = "GPL-3.0-or-later" workspace = true [[bin]] -name = "zeta" +name = "ep_cli" path = "src/main.rs" [dependencies] @@ -19,7 +19,7 @@ chrono.workspace = true clap.workspace = true client.workspace = true cloud_llm_client.workspace= true -cloud_zeta2_prompt.workspace= true +cloud_zeta2_prompt.workspace = true collections.workspace = true debug_adapter_extension.workspace = true edit_prediction_context.workspace = true @@ -35,9 +35,7 @@ language_models.workspace = true languages = { workspace = true, features = ["load-grammars"] } log.workspace = true node_runtime.workspace = true -ordered-float.workspace = true paths.workspace = true -polars = { version = "0.51", features = ["lazy", "dtype-struct", "parquet"] } project.workspace = true prompt_store.workspace = true pulldown-cmark.workspace = true @@ -48,12 +46,11 @@ serde_json.workspace = true settings.workspace = true shellexpand.workspace = true smol.workspace = true -soa-rs = "0.8.1" terminal_view.workspace = true toml.workspace = true util.workspace = true watch.workspace = true -zeta = { workspace = true, features = ["eval-support"] } +edit_prediction = { workspace = true, features = ["eval-support"] } zlog.workspace = true [dev-dependencies] diff --git a/crates/edit_prediction_button/LICENSE-GPL b/crates/edit_prediction_cli/LICENSE-GPL similarity index 100% rename from crates/edit_prediction_button/LICENSE-GPL rename to crates/edit_prediction_cli/LICENSE-GPL diff --git a/crates/zeta_cli/build.rs b/crates/edit_prediction_cli/build.rs similarity index 100% rename from crates/zeta_cli/build.rs rename to crates/edit_prediction_cli/build.rs diff --git a/crates/zeta_cli/src/evaluate.rs b/crates/edit_prediction_cli/src/evaluate.rs similarity index 98% rename from crates/zeta_cli/src/evaluate.rs rename to crates/edit_prediction_cli/src/evaluate.rs index 043844768557ad46f61d5fd0d809e1e85c62574f..686c8ce7e7865f265d6bf17e51ca9477194e5252 100644 --- a/crates/zeta_cli/src/evaluate.rs +++ b/crates/edit_prediction_cli/src/evaluate.rs @@ -6,17 +6,17 @@ use std::{ }; use anyhow::Result; +use edit_prediction::{EditPredictionStore, udiff::DiffLine}; use gpui::{AsyncApp, Entity}; use project::Project; use util::ResultExt as _; -use zeta::{Zeta, udiff::DiffLine}; use crate::{ EvaluateArguments, PredictionOptions, example::{Example, NamedExample}, headless::ZetaCliAppState, paths::print_run_data_dir, - predict::{PredictionDetails, perform_predict, setup_zeta}, + predict::{PredictionDetails, perform_predict, setup_store}, }; #[derive(Debug)] @@ -45,7 +45,7 @@ pub async fn run_evaluate( let project = example.setup_project(&app_state, cx).await.unwrap(); let providers = (0..args.repetitions) - .map(|_| setup_zeta(args.options.provider, &project, &app_state, cx).unwrap()) + .map(|_| setup_store(args.options.provider, &project, &app_state, cx).unwrap()) .collect::>(); let _edited_buffers = example.apply_edit_history(&project, cx).await.unwrap(); @@ -53,7 +53,7 @@ pub async fn run_evaluate( let tasks = providers .into_iter() .enumerate() - .map(move |(repetition_ix, zeta)| { + .map(move |(repetition_ix, store)| { let repetition_ix = (args.repetitions > 1).then(|| repetition_ix as u16); let example = example.clone(); let project = project.clone(); @@ -65,7 +65,7 @@ pub async fn run_evaluate( example, repetition_ix, project, - zeta, + store, options, !args.skip_prediction, cx, @@ -154,7 +154,7 @@ pub async fn run_evaluate_one( example: NamedExample, repetition_ix: Option, project: Entity, - zeta: Entity, + store: Entity, prediction_options: PredictionOptions, predict: bool, cx: &mut AsyncApp, @@ -162,7 +162,7 @@ pub async fn run_evaluate_one( let predict_result = perform_predict( example.clone(), project, - zeta, + store, repetition_ix, prediction_options, cx, diff --git a/crates/zeta_cli/src/example.rs b/crates/edit_prediction_cli/src/example.rs similarity index 99% rename from crates/zeta_cli/src/example.rs rename to crates/edit_prediction_cli/src/example.rs index a9d4c4f47c5a05d4198b1cffaee51e14a122e88d..2f52b89c552b65072f753432eb63b656624fdf61 100644 --- a/crates/zeta_cli/src/example.rs +++ b/crates/edit_prediction_cli/src/example.rs @@ -14,6 +14,7 @@ use anyhow::{Context as _, Result, anyhow}; use clap::ValueEnum; use cloud_zeta2_prompt::CURSOR_MARKER; use collections::HashMap; +use edit_prediction::udiff::OpenedBuffers; use futures::{ AsyncWriteExt as _, lock::{Mutex, OwnedMutexGuard}, @@ -25,7 +26,6 @@ use project::{Project, ProjectPath}; use pulldown_cmark::CowStr; use serde::{Deserialize, Serialize}; use util::{paths::PathStyle, rel_path::RelPath}; -use zeta::udiff::OpenedBuffers; use crate::paths::{REPOS_DIR, WORKTREES_DIR}; @@ -481,7 +481,7 @@ impl NamedExample { project: &Entity, cx: &mut AsyncApp, ) -> Result> { - zeta::udiff::apply_diff(&self.example.edit_history, project, cx).await + edit_prediction::udiff::apply_diff(&self.example.edit_history, project, cx).await } } diff --git a/crates/zeta_cli/src/headless.rs b/crates/edit_prediction_cli/src/headless.rs similarity index 100% rename from crates/zeta_cli/src/headless.rs rename to crates/edit_prediction_cli/src/headless.rs diff --git a/crates/zeta_cli/src/main.rs b/crates/edit_prediction_cli/src/main.rs similarity index 84% rename from crates/zeta_cli/src/main.rs rename to crates/edit_prediction_cli/src/main.rs index 42c0ea185f4401a11c2798f9402a59829f8463df..f2887b98a0ce829a58374fdd10c3e346b6f5d16a 100644 --- a/crates/zeta_cli/src/main.rs +++ b/crates/edit_prediction_cli/src/main.rs @@ -5,7 +5,6 @@ mod metrics; mod paths; mod predict; mod source_location; -mod syntax_retrieval_stats; mod util; use crate::{ @@ -14,13 +13,13 @@ use crate::{ headless::ZetaCliAppState, predict::run_predict, source_location::SourceLocation, - syntax_retrieval_stats::retrieval_stats, util::{open_buffer, open_buffer_with_language_server}, }; use ::util::paths::PathStyle; use anyhow::{Result, anyhow}; use clap::{Args, Parser, Subcommand, ValueEnum}; use cloud_llm_client::predict_edits_v3; +use edit_prediction::udiff::DiffLine; use edit_prediction_context::EditPredictionExcerptOptions; use gpui::{Application, AsyncApp, Entity, prelude::*}; use language::{Bias, Buffer, BufferSnapshot, Point}; @@ -28,10 +27,7 @@ use metrics::delta_chr_f; use project::{Project, Worktree, lsp_store::OpenLspBufferHandle}; use reqwest_client::ReqwestClient; use std::io::{self}; -use std::time::Duration; use std::{collections::HashSet, path::PathBuf, str::FromStr, sync::Arc}; -use zeta::ContextMode; -use zeta::udiff::DiffLine; #[derive(Parser, Debug)] #[command(name = "zeta")] @@ -45,7 +41,6 @@ struct ZetaCliArgs { #[derive(Subcommand, Debug)] enum Command { Context(ContextArgs), - ContextStats(ContextStatsArgs), Predict(PredictArguments), Eval(EvaluateArguments), ConvertExample { @@ -60,20 +55,6 @@ enum Command { Clean, } -#[derive(Debug, Args)] -struct ContextStatsArgs { - #[arg(long)] - worktree: PathBuf, - #[arg(long)] - extension: Option, - #[arg(long)] - limit: Option, - #[arg(long)] - skip: Option, - #[clap(flatten)] - zeta2_args: Zeta2Args, -} - #[derive(Debug, Args)] struct ContextArgs { #[arg(long)] @@ -201,28 +182,22 @@ enum PredictionProvider { Sweep, } -fn zeta2_args_to_options(args: &Zeta2Args) -> zeta::ZetaOptions { - zeta::ZetaOptions { - context: ContextMode::Lsp(EditPredictionExcerptOptions { +fn zeta2_args_to_options(args: &Zeta2Args) -> edit_prediction::ZetaOptions { + edit_prediction::ZetaOptions { + context: EditPredictionExcerptOptions { max_bytes: args.max_excerpt_bytes, min_bytes: args.min_excerpt_bytes, target_before_cursor_over_total_bytes: args.target_before_cursor_over_total_bytes, - }), - max_diagnostic_bytes: args.max_diagnostic_bytes, + }, max_prompt_bytes: args.max_prompt_bytes, prompt_format: args.prompt_format.into(), - file_indexing_parallelism: args.file_indexing_parallelism, - buffer_change_grouping_interval: Duration::ZERO, } } #[derive(clap::ValueEnum, Default, Debug, Clone, Copy)] enum PromptFormat { - MarkedExcerpt, - LabeledSections, OnlySnippets, #[default] - NumberedLines, OldTextNewText, Minimal, MinimalQwen, @@ -232,10 +207,7 @@ enum PromptFormat { impl Into for PromptFormat { fn into(self) -> predict_edits_v3::PromptFormat { match self { - Self::MarkedExcerpt => predict_edits_v3::PromptFormat::MarkedExcerpt, - Self::LabeledSections => predict_edits_v3::PromptFormat::LabeledSections, Self::OnlySnippets => predict_edits_v3::PromptFormat::OnlySnippets, - Self::NumberedLines => predict_edits_v3::PromptFormat::NumLinesUniDiff, Self::OldTextNewText => predict_edits_v3::PromptFormat::OldTextNewText, Self::Minimal => predict_edits_v3::PromptFormat::Minimal, Self::MinimalQwen => predict_edits_v3::PromptFormat::MinimalQwen, @@ -395,27 +367,29 @@ async fn zeta2_context( .await; let output = cx .update(|cx| { - let zeta = cx.new(|cx| { - zeta::Zeta::new(app_state.client.clone(), app_state.user_store.clone(), cx) + let store = cx.new(|cx| { + edit_prediction::EditPredictionStore::new( + app_state.client.clone(), + app_state.user_store.clone(), + cx, + ) }); - let indexing_done_task = zeta.update(cx, |zeta, cx| { - zeta.set_options(zeta2_args_to_options(&args.zeta2_args)); - zeta.register_buffer(&buffer, &project, cx); - zeta.wait_for_initial_indexing(&project, cx) + store.update(cx, |store, cx| { + store.set_options(zeta2_args_to_options(&args.zeta2_args)); + store.register_buffer(&buffer, &project, cx); }); cx.spawn(async move |cx| { - indexing_done_task.await?; - let updates_rx = zeta.update(cx, |zeta, cx| { + let updates_rx = store.update(cx, |store, cx| { let cursor = buffer.read(cx).snapshot().anchor_before(clipped_cursor); - zeta.set_use_context(true); - zeta.refresh_context_if_needed(&project, &buffer, cursor, cx); - zeta.project_context_updates(&project).unwrap() + store.set_use_context(true); + store.refresh_context(&project, &buffer, cursor, cx); + store.project_context_updates(&project).unwrap() })?; updates_rx.recv().await.ok(); - let context = zeta.update(cx, |zeta, cx| { - zeta.context_for_project(&project, cx).to_vec() + let context = store.update(cx, |store, cx| { + store.context_for_project(&project, cx).to_vec() })?; anyhow::Ok(serde_json::to_string_pretty(&context).unwrap()) @@ -430,7 +404,7 @@ async fn zeta1_context( args: ContextArgs, app_state: &Arc, cx: &mut AsyncApp, -) -> Result { +) -> Result { let LoadedContext { full_path_str, snapshot, @@ -445,7 +419,7 @@ async fn zeta1_context( let prompt_for_events = move || (events, 0); cx.update(|cx| { - zeta::zeta1::gather_context( + edit_prediction::zeta1::gather_context( full_path_str, &snapshot, clipped_cursor, @@ -475,19 +449,6 @@ fn main() { panic!("Expected a command"); } } - Some(Command::ContextStats(arguments)) => { - let result = retrieval_stats( - arguments.worktree, - app_state, - arguments.extension, - arguments.limit, - arguments.skip, - zeta2_args_to_options(&arguments.zeta2_args), - cx, - ) - .await; - println!("{}", result.unwrap()); - } Some(Command::Context(context_args)) => { let result = match context_args.provider { ContextProvider::Zeta1 => { diff --git a/crates/zeta_cli/src/metrics.rs b/crates/edit_prediction_cli/src/metrics.rs similarity index 99% rename from crates/zeta_cli/src/metrics.rs rename to crates/edit_prediction_cli/src/metrics.rs index dd08459678eef6d04a6b656d19a4572d51a5b5c1..0fdb7fb535df12d00341997a64a96b97867f6f28 100644 --- a/crates/zeta_cli/src/metrics.rs +++ b/crates/edit_prediction_cli/src/metrics.rs @@ -1,5 +1,5 @@ use collections::{HashMap, HashSet}; -use zeta::udiff::DiffLine; +use edit_prediction::udiff::DiffLine; type Counts = HashMap; type CountsDelta = HashMap; @@ -287,7 +287,7 @@ fn count_ngrams(text: &str, n: usize) -> Counts { #[cfg(test)] mod test { use super::*; - use zeta::udiff::DiffLine; + use edit_prediction::udiff::DiffLine; #[test] fn test_delta_chr_f_perfect_match() { diff --git a/crates/zeta_cli/src/paths.rs b/crates/edit_prediction_cli/src/paths.rs similarity index 100% rename from crates/zeta_cli/src/paths.rs rename to crates/edit_prediction_cli/src/paths.rs diff --git a/crates/zeta_cli/src/predict.rs b/crates/edit_prediction_cli/src/predict.rs similarity index 85% rename from crates/zeta_cli/src/predict.rs rename to crates/edit_prediction_cli/src/predict.rs index 9fefc5ce97672796f79482e23acca3599aa1ff44..db1fed70d82a1a19713dfe54dfd6cea2bfa03d5d 100644 --- a/crates/zeta_cli/src/predict.rs +++ b/crates/edit_prediction_cli/src/predict.rs @@ -7,6 +7,7 @@ use crate::{ use ::serde::Serialize; use anyhow::{Context, Result, anyhow}; use cloud_zeta2_prompt::{CURSOR_MARKER, write_codeblock}; +use edit_prediction::{EditPredictionStore, EvalCache, EvalCacheEntryKind, EvalCacheKey}; use futures::StreamExt as _; use gpui::{AppContext, AsyncApp, Entity}; use project::Project; @@ -18,7 +19,6 @@ use std::path::PathBuf; use std::sync::Arc; use std::sync::Mutex; use std::time::{Duration, Instant}; -use zeta::{EvalCache, EvalCacheEntryKind, EvalCacheKey, Zeta}; pub async fn run_predict( args: PredictArguments, @@ -27,9 +27,9 @@ pub async fn run_predict( ) { let example = NamedExample::load(args.example_path).unwrap(); let project = example.setup_project(app_state, cx).await.unwrap(); - let zeta = setup_zeta(args.options.provider, &project, app_state, cx).unwrap(); + let store = setup_store(args.options.provider, &project, app_state, cx).unwrap(); let _edited_buffers = example.apply_edit_history(&project, cx).await.unwrap(); - let result = perform_predict(example, project, zeta, None, args.options, cx) + let result = perform_predict(example, project, store, None, args.options, cx) .await .unwrap(); result.write(args.format, std::io::stdout()).unwrap(); @@ -37,45 +37,50 @@ pub async fn run_predict( print_run_data_dir(true, std::io::stdout().is_terminal()); } -pub fn setup_zeta( +pub fn setup_store( provider: PredictionProvider, project: &Entity, app_state: &Arc, cx: &mut AsyncApp, -) -> Result> { - let zeta = - cx.new(|cx| zeta::Zeta::new(app_state.client.clone(), app_state.user_store.clone(), cx))?; +) -> Result> { + let store = cx.new(|cx| { + edit_prediction::EditPredictionStore::new( + app_state.client.clone(), + app_state.user_store.clone(), + cx, + ) + })?; - zeta.update(cx, |zeta, _cx| { + store.update(cx, |store, _cx| { let model = match provider { - PredictionProvider::Zeta1 => zeta::ZetaEditPredictionModel::Zeta1, - PredictionProvider::Zeta2 => zeta::ZetaEditPredictionModel::Zeta2, - PredictionProvider::Sweep => zeta::ZetaEditPredictionModel::Sweep, + PredictionProvider::Zeta1 => edit_prediction::EditPredictionModel::Zeta1, + PredictionProvider::Zeta2 => edit_prediction::EditPredictionModel::Zeta2, + PredictionProvider::Sweep => edit_prediction::EditPredictionModel::Sweep, }; - zeta.set_edit_prediction_model(model); + store.set_edit_prediction_model(model); })?; let buffer_store = project.read_with(cx, |project, _| project.buffer_store().clone())?; cx.subscribe(&buffer_store, { let project = project.clone(); - let zeta = zeta.clone(); + let store = store.clone(); move |_, event, cx| match event { BufferStoreEvent::BufferAdded(buffer) => { - zeta.update(cx, |zeta, cx| zeta.register_buffer(&buffer, &project, cx)); + store.update(cx, |store, cx| store.register_buffer(&buffer, &project, cx)); } _ => {} } })? .detach(); - anyhow::Ok(zeta) + anyhow::Ok(store) } pub async fn perform_predict( example: NamedExample, project: Entity, - zeta: Entity, + store: Entity, repetition_ix: Option, options: PredictionOptions, cx: &mut AsyncApp, @@ -108,8 +113,8 @@ pub async fn perform_predict( std::os::windows::fs::symlink_dir(&example_run_dir, &*LATEST_EXAMPLE_RUN_DIR) .context("creating latest link")?; - zeta.update(cx, |zeta, _cx| { - zeta.with_eval_cache(Arc::new(RunCache { + store.update(cx, |store, _cx| { + store.with_eval_cache(Arc::new(RunCache { example_run_dir: example_run_dir.clone(), cache_mode, })); @@ -121,16 +126,16 @@ pub async fn perform_predict( let prompt_format = options.zeta2.prompt_format; - zeta.update(cx, |zeta, _cx| { - let mut options = zeta.options().clone(); + store.update(cx, |store, _cx| { + let mut options = store.options().clone(); options.prompt_format = prompt_format.into(); - zeta.set_options(options); + store.set_options(options); })?; let mut debug_task = gpui::Task::ready(Ok(())); if options.provider == crate::PredictionProvider::Zeta2 { - let mut debug_rx = zeta.update(cx, |zeta, _| zeta.debug_info())?; + let mut debug_rx = store.update(cx, |store, _| store.debug_info())?; debug_task = cx.background_spawn({ let result = result.clone(); @@ -139,14 +144,14 @@ pub async fn perform_predict( let mut retrieval_finished_at = None; while let Some(event) = debug_rx.next().await { match event { - zeta::ZetaDebugInfo::ContextRetrievalStarted(info) => { + edit_prediction::DebugEvent::ContextRetrievalStarted(info) => { start_time = Some(info.timestamp); fs::write( example_run_dir.join("search_prompt.md"), &info.search_prompt, )?; } - zeta::ZetaDebugInfo::ContextRetrievalFinished(info) => { + edit_prediction::DebugEvent::ContextRetrievalFinished(info) => { retrieval_finished_at = Some(info.timestamp); for (key, value) in &info.metadata { if *key == "search_queries" { @@ -157,7 +162,7 @@ pub async fn perform_predict( } } } - zeta::ZetaDebugInfo::EditPredictionRequested(request) => { + edit_prediction::DebugEvent::EditPredictionRequested(request) => { let prediction_started_at = Instant::now(); start_time.get_or_insert(prediction_started_at); let prompt = request.local_prompt.unwrap_or_default(); @@ -193,7 +198,8 @@ pub async fn perform_predict( let response = request.response_rx.await?.0.map_err(|err| anyhow!(err))?; - let response = zeta::text_from_response(response).unwrap_or_default(); + let response = edit_prediction::zeta2::text_from_response(response) + .unwrap_or_default(); let prediction_finished_at = Instant::now(); fs::write(example_run_dir.join("prediction_response.md"), &response)?; @@ -212,20 +218,14 @@ pub async fn perform_predict( } }); - zeta.update(cx, |zeta, cx| { - zeta.refresh_context_with_agentic_retrieval( - project.clone(), - cursor_buffer.clone(), - cursor_anchor, - cx, - ) - })? - .await?; + store.update(cx, |store, cx| { + store.refresh_context(&project, &cursor_buffer, cursor_anchor, cx) + })?; } - let prediction = zeta - .update(cx, |zeta, cx| { - zeta.request_prediction( + let prediction = store + .update(cx, |store, cx| { + store.request_prediction( &project, &cursor_buffer, cursor_anchor, diff --git a/crates/zeta_cli/src/source_location.rs b/crates/edit_prediction_cli/src/source_location.rs similarity index 100% rename from crates/zeta_cli/src/source_location.rs rename to crates/edit_prediction_cli/src/source_location.rs diff --git a/crates/zeta_cli/src/util.rs b/crates/edit_prediction_cli/src/util.rs similarity index 100% rename from crates/zeta_cli/src/util.rs rename to crates/edit_prediction_cli/src/util.rs diff --git a/crates/edit_prediction_context/Cargo.toml b/crates/edit_prediction_context/Cargo.toml index 6976831b8cbbe2b998f713ff65f1585f28fc3005..f113c3c46075ca70e61d8d07947d37502e8528e8 100644 --- a/crates/edit_prediction_context/Cargo.toml +++ b/crates/edit_prediction_context/Cargo.toml @@ -12,41 +12,32 @@ workspace = true path = "src/edit_prediction_context.rs" [dependencies] +parking_lot.workspace = true anyhow.workspace = true -arrayvec.workspace = true cloud_llm_client.workspace = true collections.workspace = true futures.workspace = true gpui.workspace = true -hashbrown.workspace = true -indoc.workspace = true -itertools.workspace = true language.workspace = true -log.workspace = true -ordered-float.workspace = true -postage.workspace = true +lsp.workspace = true project.workspace = true -regex.workspace = true +log.workspace = true serde.workspace = true -slotmap.workspace = true -strum.workspace = true -text.workspace = true +smallvec.workspace = true tree-sitter.workspace = true util.workspace = true [dev-dependencies] -clap.workspace = true +env_logger.workspace = true +indoc.workspace = true futures.workspace = true gpui = { workspace = true, features = ["test-support"] } -indoc.workspace = true language = { workspace = true, features = ["test-support"] } +lsp = { workspace = true, features = ["test-support"] } pretty_assertions.workspace = true project = {workspace= true, features = ["test-support"]} serde_json.workspace = true settings = {workspace= true, features = ["test-support"]} text = { workspace = true, features = ["test-support"] } -tree-sitter-c.workspace = true -tree-sitter-cpp.workspace = true -tree-sitter-go.workspace = true util = { workspace = true, features = ["test-support"] } zlog.workspace = true diff --git a/crates/edit_prediction_context2/src/assemble_excerpts.rs b/crates/edit_prediction_context/src/assemble_excerpts.rs similarity index 100% rename from crates/edit_prediction_context2/src/assemble_excerpts.rs rename to crates/edit_prediction_context/src/assemble_excerpts.rs diff --git a/crates/edit_prediction_context/src/declaration.rs b/crates/edit_prediction_context/src/declaration.rs deleted file mode 100644 index cc32640425ecc563b1f24a6c695be1c13199cd73..0000000000000000000000000000000000000000 --- a/crates/edit_prediction_context/src/declaration.rs +++ /dev/null @@ -1,350 +0,0 @@ -use cloud_llm_client::predict_edits_v3::{self, Line}; -use language::{Language, LanguageId}; -use project::ProjectEntryId; -use std::ops::Range; -use std::sync::Arc; -use std::{borrow::Cow, path::Path}; -use text::{Bias, BufferId, Rope}; -use util::paths::{path_ends_with, strip_path_suffix}; -use util::rel_path::RelPath; - -use crate::outline::OutlineDeclaration; - -#[derive(Debug, Clone, Eq, PartialEq, Hash)] -pub struct Identifier { - pub name: Arc, - pub language_id: LanguageId, -} - -slotmap::new_key_type! { - pub struct DeclarationId; -} - -#[derive(Debug, Clone)] -pub enum Declaration { - File { - project_entry_id: ProjectEntryId, - declaration: FileDeclaration, - cached_path: CachedDeclarationPath, - }, - Buffer { - project_entry_id: ProjectEntryId, - buffer_id: BufferId, - rope: Rope, - declaration: BufferDeclaration, - cached_path: CachedDeclarationPath, - }, -} - -const ITEM_TEXT_TRUNCATION_LENGTH: usize = 1024; - -impl Declaration { - pub fn identifier(&self) -> &Identifier { - match self { - Declaration::File { declaration, .. } => &declaration.identifier, - Declaration::Buffer { declaration, .. } => &declaration.identifier, - } - } - - pub fn parent(&self) -> Option { - match self { - Declaration::File { declaration, .. } => declaration.parent, - Declaration::Buffer { declaration, .. } => declaration.parent, - } - } - - pub fn as_buffer(&self) -> Option<&BufferDeclaration> { - match self { - Declaration::File { .. } => None, - Declaration::Buffer { declaration, .. } => Some(declaration), - } - } - - pub fn as_file(&self) -> Option<&FileDeclaration> { - match self { - Declaration::Buffer { .. } => None, - Declaration::File { declaration, .. } => Some(declaration), - } - } - - pub fn project_entry_id(&self) -> ProjectEntryId { - match self { - Declaration::File { - project_entry_id, .. - } => *project_entry_id, - Declaration::Buffer { - project_entry_id, .. - } => *project_entry_id, - } - } - - pub fn cached_path(&self) -> &CachedDeclarationPath { - match self { - Declaration::File { cached_path, .. } => cached_path, - Declaration::Buffer { cached_path, .. } => cached_path, - } - } - - pub fn item_range(&self) -> Range { - match self { - Declaration::File { declaration, .. } => declaration.item_range.clone(), - Declaration::Buffer { declaration, .. } => declaration.item_range.clone(), - } - } - - pub fn item_line_range(&self) -> Range { - match self { - Declaration::File { declaration, .. } => declaration.item_line_range.clone(), - Declaration::Buffer { - declaration, rope, .. - } => { - Line(rope.offset_to_point(declaration.item_range.start).row) - ..Line(rope.offset_to_point(declaration.item_range.end).row) - } - } - } - - pub fn item_text(&self) -> (Cow<'_, str>, bool) { - match self { - Declaration::File { declaration, .. } => ( - declaration.text.as_ref().into(), - declaration.text_is_truncated, - ), - Declaration::Buffer { - rope, declaration, .. - } => ( - rope.chunks_in_range(declaration.item_range.clone()) - .collect::>(), - declaration.item_range_is_truncated, - ), - } - } - - pub fn signature_text(&self) -> (Cow<'_, str>, bool) { - match self { - Declaration::File { declaration, .. } => ( - declaration.text[self.signature_range_in_item_text()].into(), - declaration.signature_is_truncated, - ), - Declaration::Buffer { - rope, declaration, .. - } => ( - rope.chunks_in_range(declaration.signature_range.clone()) - .collect::>(), - declaration.signature_range_is_truncated, - ), - } - } - - pub fn signature_range(&self) -> Range { - match self { - Declaration::File { declaration, .. } => declaration.signature_range.clone(), - Declaration::Buffer { declaration, .. } => declaration.signature_range.clone(), - } - } - - pub fn signature_line_range(&self) -> Range { - match self { - Declaration::File { declaration, .. } => declaration.signature_line_range.clone(), - Declaration::Buffer { - declaration, rope, .. - } => { - Line(rope.offset_to_point(declaration.signature_range.start).row) - ..Line(rope.offset_to_point(declaration.signature_range.end).row) - } - } - } - - pub fn signature_range_in_item_text(&self) -> Range { - let signature_range = self.signature_range(); - let item_range = self.item_range(); - signature_range.start.saturating_sub(item_range.start) - ..(signature_range.end.saturating_sub(item_range.start)).min(item_range.len()) - } -} - -fn expand_range_to_line_boundaries_and_truncate( - range: &Range, - limit: usize, - rope: &Rope, -) -> (Range, Range, bool) { - let mut point_range = rope.offset_to_point(range.start)..rope.offset_to_point(range.end); - point_range.start.column = 0; - point_range.end.row += 1; - point_range.end.column = 0; - - let mut item_range = - rope.point_to_offset(point_range.start)..rope.point_to_offset(point_range.end); - let is_truncated = item_range.len() > limit; - if is_truncated { - item_range.end = item_range.start + limit; - } - item_range.end = rope.clip_offset(item_range.end, Bias::Left); - - let line_range = - predict_edits_v3::Line(point_range.start.row)..predict_edits_v3::Line(point_range.end.row); - (item_range, line_range, is_truncated) -} - -#[derive(Debug, Clone)] -pub struct FileDeclaration { - pub parent: Option, - pub identifier: Identifier, - /// offset range of the declaration in the file, expanded to line boundaries and truncated - pub item_range: Range, - /// line range of the declaration in the file, potentially truncated - pub item_line_range: Range, - /// text of `item_range` - pub text: Arc, - /// whether `text` was truncated - pub text_is_truncated: bool, - /// offset range of the signature in the file, expanded to line boundaries and truncated - pub signature_range: Range, - /// line range of the signature in the file, truncated - pub signature_line_range: Range, - /// whether `signature` was truncated - pub signature_is_truncated: bool, -} - -impl FileDeclaration { - pub fn from_outline(declaration: OutlineDeclaration, rope: &Rope) -> FileDeclaration { - let (item_range_in_file, item_line_range_in_file, text_is_truncated) = - expand_range_to_line_boundaries_and_truncate( - &declaration.item_range, - ITEM_TEXT_TRUNCATION_LENGTH, - rope, - ); - - let (mut signature_range_in_file, signature_line_range, mut signature_is_truncated) = - expand_range_to_line_boundaries_and_truncate( - &declaration.signature_range, - ITEM_TEXT_TRUNCATION_LENGTH, - rope, - ); - - if signature_range_in_file.start < item_range_in_file.start { - signature_range_in_file.start = item_range_in_file.start; - signature_is_truncated = true; - } - if signature_range_in_file.end > item_range_in_file.end { - signature_range_in_file.end = item_range_in_file.end; - signature_is_truncated = true; - } - - FileDeclaration { - parent: None, - identifier: declaration.identifier, - signature_range: signature_range_in_file, - signature_line_range, - signature_is_truncated, - text: rope - .chunks_in_range(item_range_in_file.clone()) - .collect::() - .into(), - text_is_truncated, - item_range: item_range_in_file, - item_line_range: item_line_range_in_file, - } - } -} - -#[derive(Debug, Clone)] -pub struct BufferDeclaration { - pub parent: Option, - pub identifier: Identifier, - pub item_range: Range, - pub item_range_is_truncated: bool, - pub signature_range: Range, - pub signature_range_is_truncated: bool, -} - -impl BufferDeclaration { - pub fn from_outline(declaration: OutlineDeclaration, rope: &Rope) -> Self { - let (item_range, _item_line_range, item_range_is_truncated) = - expand_range_to_line_boundaries_and_truncate( - &declaration.item_range, - ITEM_TEXT_TRUNCATION_LENGTH, - rope, - ); - let (signature_range, _signature_line_range, signature_range_is_truncated) = - expand_range_to_line_boundaries_and_truncate( - &declaration.signature_range, - ITEM_TEXT_TRUNCATION_LENGTH, - rope, - ); - Self { - parent: None, - identifier: declaration.identifier, - item_range, - item_range_is_truncated, - signature_range, - signature_range_is_truncated, - } - } -} - -#[derive(Debug, Clone)] -pub struct CachedDeclarationPath { - pub worktree_abs_path: Arc, - pub rel_path: Arc, - /// The relative path of the file, possibly stripped according to `import_path_strip_regex`. - pub rel_path_after_regex_stripping: Arc, -} - -impl CachedDeclarationPath { - pub fn new( - worktree_abs_path: Arc, - path: &Arc, - language: Option<&Arc>, - ) -> Self { - let rel_path = path.clone(); - let rel_path_after_regex_stripping = if let Some(language) = language - && let Some(strip_regex) = language.config().import_path_strip_regex.as_ref() - && let Ok(stripped) = RelPath::unix(&Path::new( - strip_regex.replace_all(rel_path.as_unix_str(), "").as_ref(), - )) { - Arc::from(stripped) - } else { - rel_path.clone() - }; - CachedDeclarationPath { - worktree_abs_path, - rel_path, - rel_path_after_regex_stripping, - } - } - - #[cfg(test)] - pub fn new_for_test(worktree_abs_path: &str, rel_path: &str) -> Self { - let rel_path: Arc = util::rel_path::rel_path(rel_path).into(); - CachedDeclarationPath { - worktree_abs_path: std::path::PathBuf::from(worktree_abs_path).into(), - rel_path_after_regex_stripping: rel_path.clone(), - rel_path, - } - } - - pub fn ends_with_posix_path(&self, path: &Path) -> bool { - if path.as_os_str().len() <= self.rel_path_after_regex_stripping.as_unix_str().len() { - path_ends_with(self.rel_path_after_regex_stripping.as_std_path(), path) - } else { - if let Some(remaining) = - strip_path_suffix(path, self.rel_path_after_regex_stripping.as_std_path()) - { - path_ends_with(&self.worktree_abs_path, remaining) - } else { - false - } - } - } - - pub fn equals_absolute_path(&self, path: &Path) -> bool { - if let Some(remaining) = - strip_path_suffix(path, &self.rel_path_after_regex_stripping.as_std_path()) - { - self.worktree_abs_path.as_ref() == remaining - } else { - false - } - } -} diff --git a/crates/edit_prediction_context/src/declaration_scoring.rs b/crates/edit_prediction_context/src/declaration_scoring.rs deleted file mode 100644 index 48a823362769770c836b44e7d8a6c1942d3a1196..0000000000000000000000000000000000000000 --- a/crates/edit_prediction_context/src/declaration_scoring.rs +++ /dev/null @@ -1,539 +0,0 @@ -use cloud_llm_client::predict_edits_v3::DeclarationScoreComponents; -use collections::HashMap; -use language::BufferSnapshot; -use ordered_float::OrderedFloat; -use project::ProjectEntryId; -use serde::Serialize; -use std::{cmp::Reverse, ops::Range, path::Path, sync::Arc}; -use strum::EnumIter; -use text::{Point, ToPoint}; -use util::RangeExt as _; - -use crate::{ - CachedDeclarationPath, Declaration, EditPredictionExcerpt, Identifier, - imports::{Import, Imports, Module}, - reference::{Reference, ReferenceRegion}, - syntax_index::SyntaxIndexState, - text_similarity::{Occurrences, jaccard_similarity, weighted_overlap_coefficient}, -}; - -const MAX_IDENTIFIER_DECLARATION_COUNT: usize = 16; - -#[derive(Clone, Debug, PartialEq, Eq)] -pub struct EditPredictionScoreOptions { - pub omit_excerpt_overlaps: bool, -} - -#[derive(Clone, Debug)] -pub struct ScoredDeclaration { - /// identifier used by the local reference - pub identifier: Identifier, - pub declaration: Declaration, - pub components: DeclarationScoreComponents, -} - -#[derive(EnumIter, Clone, Copy, PartialEq, Eq, Hash, Debug)] -pub enum DeclarationStyle { - Signature, - Declaration, -} - -#[derive(Clone, Debug, Serialize, Default)] -pub struct DeclarationScores { - pub signature: f32, - pub declaration: f32, - pub retrieval: f32, -} - -impl ScoredDeclaration { - /// Returns the score for this declaration with the specified style. - pub fn score(&self, style: DeclarationStyle) -> f32 { - // TODO: handle truncation - - // Score related to how likely this is the correct declaration, range 0 to 1 - let retrieval = self.retrieval_score(); - - // Score related to the distance between the reference and cursor, range 0 to 1 - let distance_score = if self.components.is_referenced_nearby { - 1.0 / (1.0 + self.components.reference_line_distance as f32 / 10.0).powf(2.0) - } else { - // same score as ~14 lines away, rationale is to not overly penalize references from parent signatures - 0.5 - }; - - // For now instead of linear combination, the scores are just multiplied together. - let combined_score = 10.0 * retrieval * distance_score; - - match style { - DeclarationStyle::Signature => { - combined_score * self.components.excerpt_vs_signature_weighted_overlap - } - DeclarationStyle::Declaration => { - 2.0 * combined_score * self.components.excerpt_vs_item_weighted_overlap - } - } - } - - pub fn retrieval_score(&self) -> f32 { - let mut score = if self.components.is_same_file { - 10.0 / self.components.same_file_declaration_count as f32 - } else if self.components.path_import_match_count > 0 { - 3.0 - } else if self.components.wildcard_path_import_match_count > 0 { - 1.0 - } else if self.components.normalized_import_similarity > 0.0 { - self.components.normalized_import_similarity - } else if self.components.normalized_wildcard_import_similarity > 0.0 { - 0.5 * self.components.normalized_wildcard_import_similarity - } else { - 1.0 / self.components.declaration_count as f32 - }; - score *= 1. + self.components.included_by_others as f32 / 2.; - score *= 1. + self.components.includes_others as f32 / 4.; - score - } - - pub fn size(&self, style: DeclarationStyle) -> usize { - match &self.declaration { - Declaration::File { declaration, .. } => match style { - DeclarationStyle::Signature => declaration.signature_range.len(), - DeclarationStyle::Declaration => declaration.text.len(), - }, - Declaration::Buffer { declaration, .. } => match style { - DeclarationStyle::Signature => declaration.signature_range.len(), - DeclarationStyle::Declaration => declaration.item_range.len(), - }, - } - } - - pub fn score_density(&self, style: DeclarationStyle) -> f32 { - self.score(style) / self.size(style) as f32 - } -} - -pub fn scored_declarations( - options: &EditPredictionScoreOptions, - index: &SyntaxIndexState, - excerpt: &EditPredictionExcerpt, - excerpt_occurrences: &Occurrences, - adjacent_occurrences: &Occurrences, - imports: &Imports, - identifier_to_references: HashMap>, - cursor_offset: usize, - current_buffer: &BufferSnapshot, -) -> Vec { - let cursor_point = cursor_offset.to_point(¤t_buffer); - - let mut wildcard_import_occurrences = Vec::new(); - let mut wildcard_import_paths = Vec::new(); - for wildcard_import in imports.wildcard_modules.iter() { - match wildcard_import { - Module::Namespace(namespace) => { - wildcard_import_occurrences.push(namespace.occurrences()) - } - Module::SourceExact(path) => wildcard_import_paths.push(path), - Module::SourceFuzzy(path) => { - wildcard_import_occurrences.push(Occurrences::from_path(&path)) - } - } - } - - let mut scored_declarations = Vec::new(); - let mut project_entry_id_to_outline_ranges: HashMap>> = - HashMap::default(); - for (identifier, references) in identifier_to_references { - let mut import_occurrences = Vec::new(); - let mut import_paths = Vec::new(); - let mut found_external_identifier: Option<&Identifier> = None; - - if let Some(imports) = imports.identifier_to_imports.get(&identifier) { - // only use alias when it's the only import, could be generalized if some language - // has overlapping aliases - // - // TODO: when an aliased declaration is included in the prompt, should include the - // aliasing in the prompt. - // - // TODO: For SourceFuzzy consider having componentwise comparison that pays - // attention to ordering. - if let [ - Import::Alias { - module, - external_identifier, - }, - ] = imports.as_slice() - { - match module { - Module::Namespace(namespace) => { - import_occurrences.push(namespace.occurrences()) - } - Module::SourceExact(path) => import_paths.push(path), - Module::SourceFuzzy(path) => { - import_occurrences.push(Occurrences::from_path(&path)) - } - } - found_external_identifier = Some(&external_identifier); - } else { - for import in imports { - match import { - Import::Direct { module } => match module { - Module::Namespace(namespace) => { - import_occurrences.push(namespace.occurrences()) - } - Module::SourceExact(path) => import_paths.push(path), - Module::SourceFuzzy(path) => { - import_occurrences.push(Occurrences::from_path(&path)) - } - }, - Import::Alias { .. } => {} - } - } - } - } - - let identifier_to_lookup = found_external_identifier.unwrap_or(&identifier); - // TODO: update this to be able to return more declarations? Especially if there is the - // ability to quickly filter a large list (based on imports) - let identifier_declarations = index - .declarations_for_identifier::(&identifier_to_lookup); - let declaration_count = identifier_declarations.len(); - - if declaration_count == 0 { - continue; - } - - // TODO: option to filter out other candidates when same file / import match - let mut checked_declarations = Vec::with_capacity(declaration_count); - for (declaration_id, declaration) in identifier_declarations { - match declaration { - Declaration::Buffer { - buffer_id, - declaration: buffer_declaration, - .. - } => { - if buffer_id == ¤t_buffer.remote_id() { - let already_included_in_prompt = - range_intersection(&buffer_declaration.item_range, &excerpt.range) - .is_some() - || excerpt - .parent_declarations - .iter() - .any(|(excerpt_parent, _)| excerpt_parent == &declaration_id); - if !options.omit_excerpt_overlaps || !already_included_in_prompt { - let declaration_line = buffer_declaration - .item_range - .start - .to_point(current_buffer) - .row; - let declaration_line_distance = - (cursor_point.row as i32 - declaration_line as i32).unsigned_abs(); - checked_declarations.push(CheckedDeclaration { - declaration, - same_file_line_distance: Some(declaration_line_distance), - path_import_match_count: 0, - wildcard_path_import_match_count: 0, - }); - } - continue; - } else { - } - } - Declaration::File { .. } => {} - } - let declaration_path = declaration.cached_path(); - let path_import_match_count = import_paths - .iter() - .filter(|import_path| { - declaration_path_matches_import(&declaration_path, import_path) - }) - .count(); - let wildcard_path_import_match_count = wildcard_import_paths - .iter() - .filter(|import_path| { - declaration_path_matches_import(&declaration_path, import_path) - }) - .count(); - checked_declarations.push(CheckedDeclaration { - declaration, - same_file_line_distance: None, - path_import_match_count, - wildcard_path_import_match_count, - }); - } - - let mut max_import_similarity = 0.0; - let mut max_wildcard_import_similarity = 0.0; - - let mut scored_declarations_for_identifier = Vec::with_capacity(checked_declarations.len()); - for checked_declaration in checked_declarations { - let same_file_declaration_count = - index.file_declaration_count(checked_declaration.declaration); - - let declaration = score_declaration( - &identifier, - &references, - checked_declaration, - same_file_declaration_count, - declaration_count, - &excerpt_occurrences, - &adjacent_occurrences, - &import_occurrences, - &wildcard_import_occurrences, - cursor_point, - current_buffer, - ); - - if declaration.components.import_similarity > max_import_similarity { - max_import_similarity = declaration.components.import_similarity; - } - - if declaration.components.wildcard_import_similarity > max_wildcard_import_similarity { - max_wildcard_import_similarity = declaration.components.wildcard_import_similarity; - } - - project_entry_id_to_outline_ranges - .entry(declaration.declaration.project_entry_id()) - .or_default() - .push(declaration.declaration.item_range()); - scored_declarations_for_identifier.push(declaration); - } - - if max_import_similarity > 0.0 || max_wildcard_import_similarity > 0.0 { - for declaration in scored_declarations_for_identifier.iter_mut() { - if max_import_similarity > 0.0 { - declaration.components.max_import_similarity = max_import_similarity; - declaration.components.normalized_import_similarity = - declaration.components.import_similarity / max_import_similarity; - } - if max_wildcard_import_similarity > 0.0 { - declaration.components.normalized_wildcard_import_similarity = - declaration.components.wildcard_import_similarity - / max_wildcard_import_similarity; - } - } - } - - scored_declarations.extend(scored_declarations_for_identifier); - } - - // TODO: Inform this via import / retrieval scores of outline items - // TODO: Consider using a sweepline - for scored_declaration in scored_declarations.iter_mut() { - let project_entry_id = scored_declaration.declaration.project_entry_id(); - let Some(ranges) = project_entry_id_to_outline_ranges.get(&project_entry_id) else { - continue; - }; - for range in ranges { - if range.contains_inclusive(&scored_declaration.declaration.item_range()) { - scored_declaration.components.included_by_others += 1 - } else if scored_declaration - .declaration - .item_range() - .contains_inclusive(range) - { - scored_declaration.components.includes_others += 1 - } - } - } - - scored_declarations.sort_unstable_by_key(|declaration| { - Reverse(OrderedFloat( - declaration.score(DeclarationStyle::Declaration), - )) - }); - - scored_declarations -} - -struct CheckedDeclaration<'a> { - declaration: &'a Declaration, - same_file_line_distance: Option, - path_import_match_count: usize, - wildcard_path_import_match_count: usize, -} - -fn declaration_path_matches_import( - declaration_path: &CachedDeclarationPath, - import_path: &Arc, -) -> bool { - if import_path.is_absolute() { - declaration_path.equals_absolute_path(import_path) - } else { - declaration_path.ends_with_posix_path(import_path) - } -} - -fn range_intersection(a: &Range, b: &Range) -> Option> { - let start = a.start.clone().max(b.start.clone()); - let end = a.end.clone().min(b.end.clone()); - if start < end { - Some(Range { start, end }) - } else { - None - } -} - -fn score_declaration( - identifier: &Identifier, - references: &[Reference], - checked_declaration: CheckedDeclaration, - same_file_declaration_count: usize, - declaration_count: usize, - excerpt_occurrences: &Occurrences, - adjacent_occurrences: &Occurrences, - import_occurrences: &[Occurrences], - wildcard_import_occurrences: &[Occurrences], - cursor: Point, - current_buffer: &BufferSnapshot, -) -> ScoredDeclaration { - let CheckedDeclaration { - declaration, - same_file_line_distance, - path_import_match_count, - wildcard_path_import_match_count, - } = checked_declaration; - - let is_referenced_nearby = references - .iter() - .any(|r| r.region == ReferenceRegion::Nearby); - let is_referenced_in_breadcrumb = references - .iter() - .any(|r| r.region == ReferenceRegion::Breadcrumb); - let reference_count = references.len(); - let reference_line_distance = references - .iter() - .map(|r| { - let reference_line = r.range.start.to_point(current_buffer).row as i32; - (cursor.row as i32 - reference_line).unsigned_abs() - }) - .min() - .unwrap(); - - let is_same_file = same_file_line_distance.is_some(); - let declaration_line_distance = same_file_line_distance.unwrap_or(u32::MAX); - - let item_source_occurrences = Occurrences::within_string(&declaration.item_text().0); - let item_signature_occurrences = Occurrences::within_string(&declaration.signature_text().0); - let excerpt_vs_item_jaccard = jaccard_similarity(excerpt_occurrences, &item_source_occurrences); - let excerpt_vs_signature_jaccard = - jaccard_similarity(excerpt_occurrences, &item_signature_occurrences); - let adjacent_vs_item_jaccard = - jaccard_similarity(adjacent_occurrences, &item_source_occurrences); - let adjacent_vs_signature_jaccard = - jaccard_similarity(adjacent_occurrences, &item_signature_occurrences); - - let excerpt_vs_item_weighted_overlap = - weighted_overlap_coefficient(excerpt_occurrences, &item_source_occurrences); - let excerpt_vs_signature_weighted_overlap = - weighted_overlap_coefficient(excerpt_occurrences, &item_signature_occurrences); - let adjacent_vs_item_weighted_overlap = - weighted_overlap_coefficient(adjacent_occurrences, &item_source_occurrences); - let adjacent_vs_signature_weighted_overlap = - weighted_overlap_coefficient(adjacent_occurrences, &item_signature_occurrences); - - let mut import_similarity = 0f32; - let mut wildcard_import_similarity = 0f32; - if !import_occurrences.is_empty() || !wildcard_import_occurrences.is_empty() { - let cached_path = declaration.cached_path(); - let path_occurrences = Occurrences::from_worktree_path( - cached_path - .worktree_abs_path - .file_name() - .map(|f| f.to_string_lossy()), - &cached_path.rel_path, - ); - import_similarity = import_occurrences - .iter() - .map(|namespace_occurrences| { - OrderedFloat(jaccard_similarity(namespace_occurrences, &path_occurrences)) - }) - .max() - .map(|similarity| similarity.into_inner()) - .unwrap_or_default(); - - // TODO: Consider something other than max - wildcard_import_similarity = wildcard_import_occurrences - .iter() - .map(|namespace_occurrences| { - OrderedFloat(jaccard_similarity(namespace_occurrences, &path_occurrences)) - }) - .max() - .map(|similarity| similarity.into_inner()) - .unwrap_or_default(); - } - - // TODO: Consider adding declaration_file_count - let score_components = DeclarationScoreComponents { - is_same_file, - is_referenced_nearby, - is_referenced_in_breadcrumb, - reference_line_distance, - declaration_line_distance, - reference_count, - same_file_declaration_count, - declaration_count, - excerpt_vs_item_jaccard, - excerpt_vs_signature_jaccard, - adjacent_vs_item_jaccard, - adjacent_vs_signature_jaccard, - excerpt_vs_item_weighted_overlap, - excerpt_vs_signature_weighted_overlap, - adjacent_vs_item_weighted_overlap, - adjacent_vs_signature_weighted_overlap, - path_import_match_count, - wildcard_path_import_match_count, - import_similarity, - max_import_similarity: 0.0, - normalized_import_similarity: 0.0, - wildcard_import_similarity, - normalized_wildcard_import_similarity: 0.0, - included_by_others: 0, - includes_others: 0, - }; - - ScoredDeclaration { - identifier: identifier.clone(), - declaration: declaration.clone(), - components: score_components, - } -} - -#[cfg(test)] -mod test { - use super::*; - - #[test] - fn test_declaration_path_matches() { - let declaration_path = - CachedDeclarationPath::new_for_test("/home/user/project", "src/maths.ts"); - - assert!(declaration_path_matches_import( - &declaration_path, - &Path::new("maths.ts").into() - )); - - assert!(declaration_path_matches_import( - &declaration_path, - &Path::new("project/src/maths.ts").into() - )); - - assert!(declaration_path_matches_import( - &declaration_path, - &Path::new("user/project/src/maths.ts").into() - )); - - assert!(declaration_path_matches_import( - &declaration_path, - &Path::new("/home/user/project/src/maths.ts").into() - )); - - assert!(!declaration_path_matches_import( - &declaration_path, - &Path::new("other.ts").into() - )); - - assert!(!declaration_path_matches_import( - &declaration_path, - &Path::new("/home/user/project/src/other.ts").into() - )); - } -} diff --git a/crates/edit_prediction_context/src/edit_prediction_context.rs b/crates/edit_prediction_context/src/edit_prediction_context.rs index 65623a825c2f7e2db42b98174748e5f04fb91d2a..e316c5a052acd241e7d33356bd0d5dfa5fd075bd 100644 --- a/crates/edit_prediction_context/src/edit_prediction_context.rs +++ b/crates/edit_prediction_context/src/edit_prediction_context.rs @@ -1,335 +1,469 @@ -mod declaration; -mod declaration_scoring; +use crate::assemble_excerpts::assemble_excerpts; +use anyhow::Result; +use collections::HashMap; +use futures::{FutureExt, StreamExt as _, channel::mpsc, future}; +use gpui::{App, AppContext, AsyncApp, Context, Entity, EventEmitter, Task, WeakEntity}; +use language::{Anchor, Buffer, BufferSnapshot, OffsetRangeExt as _, Point, Rope, ToOffset as _}; +use project::{LocationLink, Project, ProjectPath}; +use serde::{Serialize, Serializer}; +use smallvec::SmallVec; +use std::{ + collections::hash_map, + ops::Range, + sync::Arc, + time::{Duration, Instant}, +}; +use util::{RangeExt as _, ResultExt}; + +mod assemble_excerpts; +#[cfg(test)] +mod edit_prediction_context_tests; mod excerpt; -mod imports; -mod outline; -mod reference; -mod syntax_index; -pub mod text_similarity; +#[cfg(test)] +mod fake_definition_lsp; -use std::{path::Path, sync::Arc}; +pub use cloud_llm_client::predict_edits_v3::Line; +pub use excerpt::{EditPredictionExcerpt, EditPredictionExcerptOptions, EditPredictionExcerptText}; -use cloud_llm_client::predict_edits_v3; -use collections::HashMap; -use gpui::{App, AppContext as _, Entity, Task}; -use language::BufferSnapshot; -use text::{Point, ToOffset as _}; - -pub use declaration::*; -pub use declaration_scoring::*; -pub use excerpt::*; -pub use imports::*; -pub use reference::*; -pub use syntax_index::*; - -pub use predict_edits_v3::Line; - -#[derive(Clone, Debug, PartialEq)] -pub struct EditPredictionContextOptions { - pub use_imports: bool, - pub excerpt: EditPredictionExcerptOptions, - pub score: EditPredictionScoreOptions, - pub max_retrieved_declarations: u8, +pub struct RelatedExcerptStore { + project: WeakEntity, + related_files: Vec, + cache: HashMap>, + update_tx: mpsc::UnboundedSender<(Entity, Anchor)>, +} + +pub enum RelatedExcerptStoreEvent { + StartedRefresh, + FinishedRefresh { + cache_hit_count: usize, + cache_miss_count: usize, + mean_definition_latency: Duration, + max_definition_latency: Duration, + }, +} + +#[derive(Clone, Debug, PartialEq, Eq, Hash)] +struct Identifier { + pub name: String, + pub range: Range, +} + +enum DefinitionTask { + CacheHit(Arc), + CacheMiss(Task>>>), +} + +#[derive(Debug)] +struct CacheEntry { + definitions: SmallVec<[CachedDefinition; 1]>, } #[derive(Clone, Debug)] -pub struct EditPredictionContext { - pub excerpt: EditPredictionExcerpt, - pub excerpt_text: EditPredictionExcerptText, - pub cursor_point: Point, - pub declarations: Vec, +struct CachedDefinition { + path: ProjectPath, + buffer: Entity, + anchor_range: Range, +} + +#[derive(Clone, Debug, Serialize)] +pub struct RelatedFile { + #[serde(serialize_with = "serialize_project_path")] + pub path: ProjectPath, + #[serde(skip)] + pub buffer: WeakEntity, + pub excerpts: Vec, + pub max_row: u32, } -impl EditPredictionContext { - pub fn gather_context_in_background( - cursor_point: Point, - buffer: BufferSnapshot, - options: EditPredictionContextOptions, - syntax_index: Option>, - cx: &mut App, - ) -> Task> { - let parent_abs_path = project::File::from_dyn(buffer.file()).and_then(|f| { - let mut path = f.worktree.read(cx).absolutize(&f.path); - if path.pop() { Some(path) } else { None } +impl RelatedFile { + pub fn merge_excerpts(&mut self) { + self.excerpts.sort_unstable_by(|a, b| { + a.point_range + .start + .cmp(&b.point_range.start) + .then(b.point_range.end.cmp(&a.point_range.end)) }); - if let Some(syntax_index) = syntax_index { - let index_state = - syntax_index.read_with(cx, |index, _cx| Arc::downgrade(index.state())); - cx.background_spawn(async move { - let parent_abs_path = parent_abs_path.as_deref(); - let index_state = index_state.upgrade()?; - let index_state = index_state.lock().await; - Self::gather_context( - cursor_point, - &buffer, - parent_abs_path, - &options, - Some(&index_state), - ) - }) - } else { - cx.background_spawn(async move { - let parent_abs_path = parent_abs_path.as_deref(); - Self::gather_context(cursor_point, &buffer, parent_abs_path, &options, None) - }) + let mut index = 1; + while index < self.excerpts.len() { + if self.excerpts[index - 1] + .point_range + .end + .cmp(&self.excerpts[index].point_range.start) + .is_ge() + { + let removed = self.excerpts.remove(index); + if removed + .point_range + .end + .cmp(&self.excerpts[index - 1].point_range.end) + .is_gt() + { + self.excerpts[index - 1].point_range.end = removed.point_range.end; + self.excerpts[index - 1].anchor_range.end = removed.anchor_range.end; + } + } else { + index += 1; + } } } +} - pub fn gather_context( - cursor_point: Point, - buffer: &BufferSnapshot, - parent_abs_path: Option<&Path>, - options: &EditPredictionContextOptions, - index_state: Option<&SyntaxIndexState>, - ) -> Option { - let imports = if options.use_imports { - Imports::gather(&buffer, parent_abs_path) - } else { - Imports::default() - }; - Self::gather_context_with_references_fn( - cursor_point, - buffer, - &imports, - options, - index_state, - references_in_excerpt, - ) - } +#[derive(Clone, Debug, Serialize)] +pub struct RelatedExcerpt { + #[serde(skip)] + pub anchor_range: Range, + #[serde(serialize_with = "serialize_point_range")] + pub point_range: Range, + #[serde(serialize_with = "serialize_rope")] + pub text: Rope, +} - pub fn gather_context_with_references_fn( - cursor_point: Point, - buffer: &BufferSnapshot, - imports: &Imports, - options: &EditPredictionContextOptions, - index_state: Option<&SyntaxIndexState>, - get_references: impl FnOnce( - &EditPredictionExcerpt, - &EditPredictionExcerptText, - &BufferSnapshot, - ) -> HashMap>, - ) -> Option { - let excerpt = EditPredictionExcerpt::select_from_buffer( - cursor_point, - buffer, - &options.excerpt, - index_state, - )?; - let excerpt_text = excerpt.text(buffer); - - let declarations = if options.max_retrieved_declarations > 0 - && let Some(index_state) = index_state - { - let excerpt_occurrences = - text_similarity::Occurrences::within_string(&excerpt_text.body); - - let adjacent_start = Point::new(cursor_point.row.saturating_sub(2), 0); - let adjacent_end = Point::new(cursor_point.row + 1, 0); - let adjacent_occurrences = text_similarity::Occurrences::within_string( - &buffer - .text_for_range(adjacent_start..adjacent_end) - .collect::(), - ); +fn serialize_project_path( + project_path: &ProjectPath, + serializer: S, +) -> Result { + project_path.path.serialize(serializer) +} - let cursor_offset_in_file = cursor_point.to_offset(buffer); +fn serialize_rope(rope: &Rope, serializer: S) -> Result { + rope.to_string().serialize(serializer) +} - let references = get_references(&excerpt, &excerpt_text, buffer); +fn serialize_point_range( + range: &Range, + serializer: S, +) -> Result { + [ + [range.start.row, range.start.column], + [range.end.row, range.end.column], + ] + .serialize(serializer) +} - let mut declarations = scored_declarations( - &options.score, - &index_state, - &excerpt, - &excerpt_occurrences, - &adjacent_occurrences, - &imports, - references, - cursor_offset_in_file, - buffer, - ); - // TODO [zeta2] if we need this when we ship, we should probably do it in a smarter way - declarations.truncate(options.max_retrieved_declarations as usize); - declarations - } else { - vec![] - }; +const DEBOUNCE_DURATION: Duration = Duration::from_millis(100); + +impl EventEmitter for RelatedExcerptStore {} + +impl RelatedExcerptStore { + pub fn new(project: &Entity, cx: &mut Context) -> Self { + let (update_tx, mut update_rx) = mpsc::unbounded::<(Entity, Anchor)>(); + cx.spawn(async move |this, cx| { + let executor = cx.background_executor().clone(); + while let Some((mut buffer, mut position)) = update_rx.next().await { + let mut timer = executor.timer(DEBOUNCE_DURATION).fuse(); + loop { + futures::select_biased! { + next = update_rx.next() => { + if let Some((new_buffer, new_position)) = next { + buffer = new_buffer; + position = new_position; + timer = executor.timer(DEBOUNCE_DURATION).fuse(); + } else { + return anyhow::Ok(()); + } + } + _ = timer => break, + } + } - Some(Self { - excerpt, - excerpt_text, - cursor_point, - declarations, + Self::fetch_excerpts(this.clone(), buffer, position, cx).await?; + } + anyhow::Ok(()) }) + .detach_and_log_err(cx); + + RelatedExcerptStore { + project: project.downgrade(), + update_tx, + related_files: Vec::new(), + cache: Default::default(), + } } -} -#[cfg(test)] -mod tests { - use super::*; - use std::sync::Arc; - - use gpui::{Entity, TestAppContext}; - use indoc::indoc; - use language::{Language, LanguageConfig, LanguageId, LanguageMatcher, tree_sitter_rust}; - use project::{FakeFs, Project}; - use serde_json::json; - use settings::SettingsStore; - use util::path; - - use crate::{EditPredictionExcerptOptions, SyntaxIndex}; - - #[gpui::test] - async fn test_call_site(cx: &mut TestAppContext) { - let (project, index, _rust_lang_id) = init_test(cx).await; - - let buffer = project - .update(cx, |project, cx| { - let project_path = project.find_project_path("c.rs", cx).unwrap(); - project.open_buffer(project_path, cx) - }) - .await - .unwrap(); - - cx.run_until_parked(); - - // first process_data call site - let cursor_point = language::Point::new(8, 21); - let buffer_snapshot = buffer.read_with(cx, |buffer, _| buffer.snapshot()); - - let context = cx - .update(|cx| { - EditPredictionContext::gather_context_in_background( - cursor_point, - buffer_snapshot, - EditPredictionContextOptions { - use_imports: true, - excerpt: EditPredictionExcerptOptions { - max_bytes: 60, - min_bytes: 10, - target_before_cursor_over_total_bytes: 0.5, - }, - score: EditPredictionScoreOptions { - omit_excerpt_overlaps: true, - }, - max_retrieved_declarations: u8::MAX, - }, - Some(index.clone()), - cx, - ) - }) - .await - .unwrap(); - - let mut snippet_identifiers = context - .declarations - .iter() - .map(|snippet| snippet.identifier.name.as_ref()) - .collect::>(); - snippet_identifiers.sort(); - assert_eq!(snippet_identifiers, vec!["main", "process_data"]); - drop(buffer); + pub fn refresh(&mut self, buffer: Entity, position: Anchor, _: &mut Context) { + self.update_tx.unbounded_send((buffer, position)).ok(); } - async fn init_test( - cx: &mut TestAppContext, - ) -> (Entity, Entity, LanguageId) { - cx.update(|cx| { - let settings_store = SettingsStore::test(cx); - cx.set_global(settings_store); - }); + pub fn related_files(&self) -> &[RelatedFile] { + &self.related_files + } - let fs = FakeFs::new(cx.executor()); - fs.insert_tree( - path!("/root"), - json!({ - "a.rs": indoc! {r#" - fn main() { - let x = 1; - let y = 2; - let z = add(x, y); - println!("Result: {}", z); - } + async fn fetch_excerpts( + this: WeakEntity, + buffer: Entity, + position: Anchor, + cx: &mut AsyncApp, + ) -> Result<()> { + let (project, snapshot) = this.read_with(cx, |this, cx| { + (this.project.upgrade(), buffer.read(cx).snapshot()) + })?; + let Some(project) = project else { + return Ok(()); + }; - fn add(a: i32, b: i32) -> i32 { - a + b - } - "#}, - "b.rs": indoc! {" - pub struct Config { - pub name: String, - pub value: i32, - } + let file = snapshot.file().cloned(); + if let Some(file) = &file { + log::debug!("retrieving_context buffer:{}", file.path().as_unix_str()); + } - impl Config { - pub fn new(name: String, value: i32) -> Self { - Config { name, value } + this.update(cx, |_, cx| { + cx.emit(RelatedExcerptStoreEvent::StartedRefresh); + })?; + + let identifiers = cx + .background_spawn(async move { identifiers_for_position(&snapshot, position) }) + .await; + + let async_cx = cx.clone(); + let start_time = Instant::now(); + let futures = this.update(cx, |this, cx| { + identifiers + .into_iter() + .filter_map(|identifier| { + let task = if let Some(entry) = this.cache.get(&identifier) { + DefinitionTask::CacheHit(entry.clone()) + } else { + DefinitionTask::CacheMiss( + this.project + .update(cx, |project, cx| { + project.definitions(&buffer, identifier.range.start, cx) + }) + .ok()?, + ) + }; + + let cx = async_cx.clone(); + let project = project.clone(); + Some(async move { + match task { + DefinitionTask::CacheHit(cache_entry) => { + Some((identifier, cache_entry, None)) + } + DefinitionTask::CacheMiss(task) => { + let locations = task.await.log_err()??; + let duration = start_time.elapsed(); + cx.update(|cx| { + ( + identifier, + Arc::new(CacheEntry { + definitions: locations + .into_iter() + .filter_map(|location| { + process_definition(location, &project, cx) + }) + .collect(), + }), + Some(duration), + ) + }) + .ok() + } } - } - "}, - "c.rs": indoc! {r#" - use std::collections::HashMap; - - fn main() { - let args: Vec = std::env::args().collect(); - let data: Vec = args[1..] - .iter() - .filter_map(|s| s.parse().ok()) - .collect(); - let result = process_data(data); - println!("{:?}", result); - } + }) + }) + .collect::>() + })?; + + let mut cache_hit_count = 0; + let mut cache_miss_count = 0; + let mut mean_definition_latency = Duration::ZERO; + let mut max_definition_latency = Duration::ZERO; + let mut new_cache = HashMap::default(); + new_cache.reserve(futures.len()); + for (identifier, entry, duration) in future::join_all(futures).await.into_iter().flatten() { + new_cache.insert(identifier, entry); + if let Some(duration) = duration { + cache_miss_count += 1; + mean_definition_latency += duration; + max_definition_latency = max_definition_latency.max(duration); + } else { + cache_hit_count += 1; + } + } + mean_definition_latency /= cache_miss_count.max(1) as u32; - fn process_data(data: Vec) -> HashMap { - let mut counts = HashMap::new(); - for value in data { - *counts.entry(value).or_insert(0) += 1; - } - counts - } + let (new_cache, related_files) = rebuild_related_files(new_cache, cx).await?; - #[cfg(test)] - mod tests { - use super::*; + if let Some(file) = &file { + log::debug!( + "finished retrieving context buffer:{}, latency:{:?}", + file.path().as_unix_str(), + start_time.elapsed() + ); + } - #[test] - fn test_process_data() { - let data = vec![1, 2, 2, 3]; - let result = process_data(data); - assert_eq!(result.get(&2), Some(&2)); - } - } - "#} - }), - ) - .await; - let project = Project::test(fs.clone(), [path!("/root").as_ref()], cx).await; - let language_registry = project.read_with(cx, |project, _| project.languages().clone()); - let lang = rust_lang(); - let lang_id = lang.id(); - language_registry.add(Arc::new(lang)); - - let file_indexing_parallelism = 2; - let index = cx.new(|cx| SyntaxIndex::new(&project, file_indexing_parallelism, cx)); - cx.run_until_parked(); - - (project, index, lang_id) + this.update(cx, |this, cx| { + this.cache = new_cache; + this.related_files = related_files; + cx.emit(RelatedExcerptStoreEvent::FinishedRefresh { + cache_hit_count, + cache_miss_count, + mean_definition_latency, + max_definition_latency, + }); + })?; + + anyhow::Ok(()) } +} - fn rust_lang() -> Language { - Language::new( - LanguageConfig { - name: "Rust".into(), - matcher: LanguageMatcher { - path_suffixes: vec!["rs".to_string()], - ..Default::default() - }, - ..Default::default() - }, - Some(tree_sitter_rust::LANGUAGE.into()), - ) - .with_highlights_query(include_str!("../../languages/src/rust/highlights.scm")) - .unwrap() - .with_outline_query(include_str!("../../languages/src/rust/outline.scm")) - .unwrap() +async fn rebuild_related_files( + new_entries: HashMap>, + cx: &mut AsyncApp, +) -> Result<(HashMap>, Vec)> { + let mut snapshots = HashMap::default(); + for entry in new_entries.values() { + for definition in &entry.definitions { + if let hash_map::Entry::Vacant(e) = snapshots.entry(definition.buffer.entity_id()) { + definition + .buffer + .read_with(cx, |buffer, _| buffer.parsing_idle())? + .await; + e.insert( + definition + .buffer + .read_with(cx, |buffer, _| buffer.snapshot())?, + ); + } + } } + + Ok(cx + .background_spawn(async move { + let mut files = Vec::::new(); + let mut ranges_by_buffer = HashMap::<_, Vec>>::default(); + let mut paths_by_buffer = HashMap::default(); + for entry in new_entries.values() { + for definition in &entry.definitions { + let Some(snapshot) = snapshots.get(&definition.buffer.entity_id()) else { + continue; + }; + paths_by_buffer.insert(definition.buffer.entity_id(), definition.path.clone()); + ranges_by_buffer + .entry(definition.buffer.clone()) + .or_default() + .push(definition.anchor_range.to_point(snapshot)); + } + } + + for (buffer, ranges) in ranges_by_buffer { + let Some(snapshot) = snapshots.get(&buffer.entity_id()) else { + continue; + }; + let Some(project_path) = paths_by_buffer.get(&buffer.entity_id()) else { + continue; + }; + let excerpts = assemble_excerpts(snapshot, ranges); + files.push(RelatedFile { + path: project_path.clone(), + buffer: buffer.downgrade(), + excerpts, + max_row: snapshot.max_point().row, + }); + } + + files.sort_by_key(|file| file.path.clone()); + (new_entries, files) + }) + .await) +} + +fn process_definition( + location: LocationLink, + project: &Entity, + cx: &mut App, +) -> Option { + let buffer = location.target.buffer.read(cx); + let anchor_range = location.target.range; + let file = buffer.file()?; + let worktree = project.read(cx).worktree_for_id(file.worktree_id(cx), cx)?; + if worktree.read(cx).is_single_file() { + return None; + } + Some(CachedDefinition { + path: ProjectPath { + worktree_id: file.worktree_id(cx), + path: file.path().clone(), + }, + buffer: location.target.buffer, + anchor_range, + }) +} + +/// Gets all of the identifiers that are present in the given line, and its containing +/// outline items. +fn identifiers_for_position(buffer: &BufferSnapshot, position: Anchor) -> Vec { + let offset = position.to_offset(buffer); + let point = buffer.offset_to_point(offset); + + let line_range = Point::new(point.row, 0)..Point::new(point.row + 1, 0).min(buffer.max_point()); + let mut ranges = vec![line_range.to_offset(&buffer)]; + + // Include the range of the outline item itself, but not its body. + let outline_items = buffer.outline_items_as_offsets_containing(offset..offset, false, None); + for item in outline_items { + if let Some(body_range) = item.body_range(&buffer) { + ranges.push(item.range.start..body_range.start.to_offset(&buffer)); + } else { + ranges.push(item.range.clone()); + } + } + + ranges.sort_by(|a, b| a.start.cmp(&b.start).then(b.end.cmp(&a.end))); + ranges.dedup_by(|a, b| { + if a.start <= b.end { + b.start = b.start.min(a.start); + b.end = b.end.max(a.end); + true + } else { + false + } + }); + + let mut identifiers = Vec::new(); + let outer_range = + ranges.first().map_or(0, |r| r.start)..ranges.last().map_or(buffer.len(), |r| r.end); + + let mut captures = buffer + .syntax + .captures(outer_range.clone(), &buffer.text, |grammar| { + grammar + .highlights_config + .as_ref() + .map(|config| &config.query) + }); + + for range in ranges { + captures.set_byte_range(range.start..outer_range.end); + + let mut last_range = None; + while let Some(capture) = captures.peek() { + let node_range = capture.node.byte_range(); + if node_range.start > range.end { + break; + } + let config = captures.grammars()[capture.grammar_index] + .highlights_config + .as_ref(); + + if let Some(config) = config + && config.identifier_capture_indices.contains(&capture.index) + && range.contains_inclusive(&node_range) + && Some(&node_range) != last_range.as_ref() + { + let name = buffer.text_for_range(node_range.clone()).collect(); + identifiers.push(Identifier { + range: buffer.anchor_after(node_range.start) + ..buffer.anchor_before(node_range.end), + name, + }); + last_range = Some(node_range); + } + + captures.advance(); + } + } + + identifiers } diff --git a/crates/edit_prediction_context2/src/edit_prediction_context_tests.rs b/crates/edit_prediction_context/src/edit_prediction_context_tests.rs similarity index 100% rename from crates/edit_prediction_context2/src/edit_prediction_context_tests.rs rename to crates/edit_prediction_context/src/edit_prediction_context_tests.rs diff --git a/crates/edit_prediction_context/src/excerpt.rs b/crates/edit_prediction_context/src/excerpt.rs index 7a4bb73edfa131b620a930d7f0e1c0da77e0afe6..55a3d8f03b277d0ce40f1d2ac947c55abf93f1c9 100644 --- a/crates/edit_prediction_context/src/excerpt.rs +++ b/crates/edit_prediction_context/src/excerpt.rs @@ -1,11 +1,9 @@ -use language::{BufferSnapshot, LanguageId}; +use cloud_llm_client::predict_edits_v3::Line; +use language::{BufferSnapshot, LanguageId, Point, ToOffset as _, ToPoint as _}; use std::ops::Range; -use text::{Point, ToOffset as _, ToPoint as _}; use tree_sitter::{Node, TreeCursor}; use util::RangeExt; -use crate::{BufferDeclaration, Line, declaration::DeclarationId, syntax_index::SyntaxIndexState}; - // TODO: // // - Test parent signatures @@ -31,19 +29,16 @@ pub struct EditPredictionExcerptOptions { pub target_before_cursor_over_total_bytes: f32, } -// TODO: consider merging these #[derive(Debug, Clone)] pub struct EditPredictionExcerpt { pub range: Range, pub line_range: Range, - pub parent_declarations: Vec<(DeclarationId, Range)>, pub size: usize, } #[derive(Debug, Clone)] pub struct EditPredictionExcerptText { pub body: String, - pub parent_signatures: Vec, pub language_id: Option, } @@ -52,17 +47,8 @@ impl EditPredictionExcerpt { let body = buffer .text_for_range(self.range.clone()) .collect::(); - let parent_signatures = self - .parent_declarations - .iter() - .map(|(_, range)| buffer.text_for_range(range.clone()).collect::()) - .collect(); let language_id = buffer.language().map(|l| l.id()); - EditPredictionExcerptText { - body, - parent_signatures, - language_id, - } + EditPredictionExcerptText { body, language_id } } /// Selects an excerpt around a buffer position, attempting to choose logical boundaries based @@ -79,7 +65,6 @@ impl EditPredictionExcerpt { query_point: Point, buffer: &BufferSnapshot, options: &EditPredictionExcerptOptions, - syntax_index: Option<&SyntaxIndexState>, ) -> Option { if buffer.len() <= options.max_bytes { log::debug!( @@ -89,11 +74,7 @@ impl EditPredictionExcerpt { ); let offset_range = 0..buffer.len(); let line_range = Line(0)..Line(buffer.max_point().row); - return Some(EditPredictionExcerpt::new( - offset_range, - line_range, - Vec::new(), - )); + return Some(EditPredictionExcerpt::new(offset_range, line_range)); } let query_offset = query_point.to_offset(buffer); @@ -104,19 +85,10 @@ impl EditPredictionExcerpt { return None; } - let parent_declarations = if let Some(syntax_index) = syntax_index { - syntax_index - .buffer_declarations_containing_range(buffer.remote_id(), query_range.clone()) - .collect() - } else { - Vec::new() - }; - let excerpt_selector = ExcerptSelector { query_offset, query_range, query_line_range: Line(query_line_range.start)..Line(query_line_range.end), - parent_declarations: &parent_declarations, buffer, options, }; @@ -139,20 +111,10 @@ impl EditPredictionExcerpt { excerpt_selector.select_lines() } - fn new( - range: Range, - line_range: Range, - parent_declarations: Vec<(DeclarationId, Range)>, - ) -> Self { - let size = range.len() - + parent_declarations - .iter() - .map(|(_, range)| range.len()) - .sum::(); + fn new(range: Range, line_range: Range) -> Self { Self { + size: range.len(), range, - parent_declarations, - size, line_range, } } @@ -162,14 +124,7 @@ impl EditPredictionExcerpt { // this is an issue because parent_signature_ranges may be incorrect log::error!("bug: with_expanded_range called with disjoint range"); } - let mut parent_declarations = Vec::with_capacity(self.parent_declarations.len()); - for (declaration_id, range) in &self.parent_declarations { - if !range.contains_inclusive(&new_range) { - break; - } - parent_declarations.push((*declaration_id, range.clone())); - } - Self::new(new_range, new_line_range, parent_declarations) + Self::new(new_range, new_line_range) } fn parent_signatures_size(&self) -> usize { @@ -181,7 +136,6 @@ struct ExcerptSelector<'a> { query_offset: usize, query_range: Range, query_line_range: Range, - parent_declarations: &'a [(DeclarationId, &'a BufferDeclaration)], buffer: &'a BufferSnapshot, options: &'a EditPredictionExcerptOptions, } @@ -409,13 +363,7 @@ impl<'a> ExcerptSelector<'a> { } fn make_excerpt(&self, range: Range, line_range: Range) -> EditPredictionExcerpt { - let parent_declarations = self - .parent_declarations - .iter() - .filter(|(_, declaration)| declaration.item_range.contains_inclusive(&range)) - .map(|(id, declaration)| (*id, declaration.signature_range.clone())) - .collect(); - EditPredictionExcerpt::new(range, line_range, parent_declarations) + EditPredictionExcerpt::new(range, line_range) } /// Returns `true` if the `forward` excerpt is a better choice than the `backward` excerpt. @@ -506,9 +454,8 @@ mod tests { let buffer = create_buffer(&text, cx); let cursor_point = cursor.to_point(&buffer); - let excerpt = - EditPredictionExcerpt::select_from_buffer(cursor_point, &buffer, &options, None) - .expect("Should select an excerpt"); + let excerpt = EditPredictionExcerpt::select_from_buffer(cursor_point, &buffer, &options) + .expect("Should select an excerpt"); pretty_assertions::assert_eq!( generate_marked_text(&text, std::slice::from_ref(&excerpt.range), false), generate_marked_text(&text, &[expected_excerpt], false) diff --git a/crates/edit_prediction_context2/src/fake_definition_lsp.rs b/crates/edit_prediction_context/src/fake_definition_lsp.rs similarity index 100% rename from crates/edit_prediction_context2/src/fake_definition_lsp.rs rename to crates/edit_prediction_context/src/fake_definition_lsp.rs diff --git a/crates/edit_prediction_context/src/imports.rs b/crates/edit_prediction_context/src/imports.rs deleted file mode 100644 index 70f175159340ddb9a6f26f23db0c1b3c843e7b96..0000000000000000000000000000000000000000 --- a/crates/edit_prediction_context/src/imports.rs +++ /dev/null @@ -1,1319 +0,0 @@ -use collections::HashMap; -use language::BufferSnapshot; -use language::ImportsConfig; -use language::Language; -use std::ops::Deref; -use std::path::Path; -use std::sync::Arc; -use std::{borrow::Cow, ops::Range}; -use text::OffsetRangeExt as _; -use util::RangeExt; -use util::paths::PathStyle; - -use crate::Identifier; -use crate::text_similarity::Occurrences; - -// TODO: Write documentation for extension authors. The @import capture must match before or in the -// same pattern as all all captures it contains - -// Future improvements to consider: -// -// * Distinguish absolute vs relative paths in captures. `#include "maths.h"` is relative whereas -// `#include ` is not. -// -// * Provide the name used when importing whole modules (see tests with "named_module" in the name). -// To be useful, will require parsing of identifier qualification. -// -// * Scoping for imports that aren't at the top level -// -// * Only scan a prefix of the file, when possible. This could look like having query matches that -// indicate it reached a declaration that is not allowed in the import section. -// -// * Support directly parsing to occurrences instead of storing namespaces / paths. Types should be -// generic on this, so that tests etc can still use strings. Could do similar in syntax index. -// -// * Distinguish different types of namespaces when known. E.g. "name.type" capture. Once capture -// names are more open-ended like this may make sense to build and cache a jump table (direct -// dispatch from capture index). -// -// * There are a few "Language specific:" comments on behavior that gets applied to all languages. -// Would be cleaner to be conditional on the language or otherwise configured. - -#[derive(Debug, Clone, Default)] -pub struct Imports { - pub identifier_to_imports: HashMap>, - pub wildcard_modules: Vec, -} - -#[derive(Debug, Clone)] -pub enum Import { - Direct { - module: Module, - }, - Alias { - module: Module, - external_identifier: Identifier, - }, -} - -#[derive(Debug, Clone)] -pub enum Module { - SourceExact(Arc), - SourceFuzzy(Arc), - Namespace(Namespace), -} - -impl Module { - fn empty() -> Self { - Module::Namespace(Namespace::default()) - } - - fn push_range( - &mut self, - range: &ModuleRange, - snapshot: &BufferSnapshot, - language: &Language, - parent_abs_path: Option<&Path>, - ) -> usize { - if range.is_empty() { - return 0; - } - - match range { - ModuleRange::Source(range) => { - if let Self::Namespace(namespace) = self - && namespace.0.is_empty() - { - let path = snapshot.text_for_range(range.clone()).collect::>(); - - let path = if let Some(strip_regex) = - language.config().import_path_strip_regex.as_ref() - { - strip_regex.replace_all(&path, "") - } else { - path - }; - - let path = Path::new(path.as_ref()); - if (path.starts_with(".") || path.starts_with("..")) - && let Some(parent_abs_path) = parent_abs_path - && let Ok(abs_path) = - util::paths::normalize_lexically(&parent_abs_path.join(path)) - { - *self = Self::SourceExact(abs_path.into()); - } else { - *self = Self::SourceFuzzy(path.into()); - }; - } else if matches!(self, Self::SourceExact(_)) - || matches!(self, Self::SourceFuzzy(_)) - { - log::warn!("bug in imports query: encountered multiple @source matches"); - } else { - log::warn!( - "bug in imports query: encountered both @namespace and @source match" - ); - } - } - ModuleRange::Namespace(range) => { - if let Self::Namespace(namespace) = self { - let segment = range_text(snapshot, range); - if language.config().ignored_import_segments.contains(&segment) { - return 0; - } else { - namespace.0.push(segment); - return 1; - } - } else { - log::warn!( - "bug in imports query: encountered both @namespace and @source match" - ); - } - } - } - 0 - } -} - -#[derive(Debug, Clone)] -enum ModuleRange { - Source(Range), - Namespace(Range), -} - -impl Deref for ModuleRange { - type Target = Range; - - fn deref(&self) -> &Self::Target { - match self { - ModuleRange::Source(range) => range, - ModuleRange::Namespace(range) => range, - } - } -} - -#[derive(Debug, Clone, PartialEq, Eq, Default)] -pub struct Namespace(pub Vec>); - -impl Namespace { - pub fn occurrences(&self) -> Occurrences { - Occurrences::from_identifiers(&self.0) - } -} - -impl Imports { - pub fn gather(snapshot: &BufferSnapshot, parent_abs_path: Option<&Path>) -> Self { - // Query to match different import patterns - let mut matches = snapshot - .syntax - .matches(0..snapshot.len(), &snapshot.text, |grammar| { - grammar.imports_config().map(|imports| &imports.query) - }); - - let mut detached_nodes: Vec = Vec::new(); - let mut identifier_to_imports = HashMap::default(); - let mut wildcard_modules = Vec::new(); - let mut import_range = None; - - while let Some(query_match) = matches.peek() { - let ImportsConfig { - query: _, - import_ix, - name_ix, - namespace_ix, - source_ix, - list_ix, - wildcard_ix, - alias_ix, - } = matches.grammars()[query_match.grammar_index] - .imports_config() - .unwrap(); - - let mut new_import_range = None; - let mut alias_range = None; - let mut modules = Vec::new(); - let mut content: Option<(Range, ContentKind)> = None; - for capture in query_match.captures { - let capture_range = capture.node.byte_range(); - - if capture.index == *import_ix { - new_import_range = Some(capture_range); - } else if Some(capture.index) == *namespace_ix { - modules.push(ModuleRange::Namespace(capture_range)); - } else if Some(capture.index) == *source_ix { - modules.push(ModuleRange::Source(capture_range)); - } else if Some(capture.index) == *alias_ix { - alias_range = Some(capture_range); - } else { - let mut found_content = None; - if Some(capture.index) == *name_ix { - found_content = Some((capture_range, ContentKind::Name)); - } else if Some(capture.index) == *list_ix { - found_content = Some((capture_range, ContentKind::List)); - } else if Some(capture.index) == *wildcard_ix { - found_content = Some((capture_range, ContentKind::Wildcard)); - } - if let Some((found_content_range, found_kind)) = found_content { - if let Some((_, old_kind)) = content { - let point = found_content_range.to_point(snapshot); - log::warn!( - "bug in {} imports query: unexpected multiple captures of {} and {} ({}:{}:{})", - query_match.language.name(), - old_kind.capture_name(), - found_kind.capture_name(), - snapshot - .file() - .map(|p| p.path().display(PathStyle::Posix)) - .unwrap_or_default(), - point.start.row + 1, - point.start.column + 1 - ); - } - content = Some((found_content_range, found_kind)); - } - } - } - - if let Some(new_import_range) = new_import_range { - log::trace!("starting new import {:?}", new_import_range); - Self::gather_from_import_statement( - &detached_nodes, - &snapshot, - parent_abs_path, - &mut identifier_to_imports, - &mut wildcard_modules, - ); - detached_nodes.clear(); - import_range = Some(new_import_range.clone()); - } - - if let Some((content, content_kind)) = content { - if import_range - .as_ref() - .is_some_and(|import_range| import_range.contains_inclusive(&content)) - { - detached_nodes.push(DetachedNode { - modules, - content: content.clone(), - content_kind, - alias: alias_range.unwrap_or(0..0), - language: query_match.language.clone(), - }); - } else { - log::trace!( - "filtered out match not inside import range: {content_kind:?} at {content:?}" - ); - } - } - - matches.advance(); - } - - Self::gather_from_import_statement( - &detached_nodes, - &snapshot, - parent_abs_path, - &mut identifier_to_imports, - &mut wildcard_modules, - ); - - Imports { - identifier_to_imports, - wildcard_modules, - } - } - - fn gather_from_import_statement( - detached_nodes: &[DetachedNode], - snapshot: &BufferSnapshot, - parent_abs_path: Option<&Path>, - identifier_to_imports: &mut HashMap>, - wildcard_modules: &mut Vec, - ) { - let mut trees = Vec::new(); - - for detached_node in detached_nodes { - if let Some(node) = Self::attach_node(detached_node.into(), &mut trees) { - trees.push(node); - } - log::trace!( - "Attached node to tree\n{:#?}\nAttach result:\n{:#?}", - detached_node, - trees - .iter() - .map(|tree| tree.debug(snapshot)) - .collect::>() - ); - } - - for tree in &trees { - let mut module = Module::empty(); - Self::gather_from_tree( - tree, - snapshot, - parent_abs_path, - &mut module, - identifier_to_imports, - wildcard_modules, - ); - } - } - - fn attach_node(mut node: ImportTree, trees: &mut Vec) -> Option { - let mut tree_index = 0; - while tree_index < trees.len() { - let tree = &mut trees[tree_index]; - if !node.content.is_empty() && node.content == tree.content { - // multiple matches can apply to the same name/list/wildcard. This keeps the queries - // simpler by combining info from these matches. - if tree.module.is_empty() { - tree.module = node.module; - tree.module_children = node.module_children; - } - if tree.alias.is_empty() { - tree.alias = node.alias; - } - return None; - } else if !node.module.is_empty() && node.module.contains_inclusive(&tree.range()) { - node.module_children.push(trees.remove(tree_index)); - continue; - } else if !node.content.is_empty() && node.content.contains_inclusive(&tree.content) { - node.content_children.push(trees.remove(tree_index)); - continue; - } else if !tree.content.is_empty() && tree.content.contains_inclusive(&node.content) { - if let Some(node) = Self::attach_node(node, &mut tree.content_children) { - tree.content_children.push(node); - } - return None; - } - tree_index += 1; - } - Some(node) - } - - fn gather_from_tree( - tree: &ImportTree, - snapshot: &BufferSnapshot, - parent_abs_path: Option<&Path>, - current_module: &mut Module, - identifier_to_imports: &mut HashMap>, - wildcard_modules: &mut Vec, - ) { - let mut pop_count = 0; - - if tree.module_children.is_empty() { - pop_count += - current_module.push_range(&tree.module, snapshot, &tree.language, parent_abs_path); - } else { - for child in &tree.module_children { - pop_count += Self::extend_namespace_from_tree( - child, - snapshot, - parent_abs_path, - current_module, - ); - } - }; - - if tree.content_children.is_empty() && !tree.content.is_empty() { - match tree.content_kind { - ContentKind::Name | ContentKind::List => { - if tree.alias.is_empty() { - identifier_to_imports - .entry(Identifier { - language_id: tree.language.id(), - name: range_text(snapshot, &tree.content), - }) - .or_default() - .push(Import::Direct { - module: current_module.clone(), - }); - } else { - let alias_name: Arc = range_text(snapshot, &tree.alias); - let external_name = range_text(snapshot, &tree.content); - // Language specific: skip "_" aliases for Rust - if alias_name.as_ref() != "_" { - identifier_to_imports - .entry(Identifier { - language_id: tree.language.id(), - name: alias_name, - }) - .or_default() - .push(Import::Alias { - module: current_module.clone(), - external_identifier: Identifier { - language_id: tree.language.id(), - name: external_name, - }, - }); - } - } - } - ContentKind::Wildcard => wildcard_modules.push(current_module.clone()), - } - } else { - for child in &tree.content_children { - Self::gather_from_tree( - child, - snapshot, - parent_abs_path, - current_module, - identifier_to_imports, - wildcard_modules, - ); - } - } - - if pop_count > 0 { - match current_module { - Module::SourceExact(_) | Module::SourceFuzzy(_) => { - log::warn!( - "bug in imports query: encountered both @namespace and @source match" - ); - } - Module::Namespace(namespace) => { - namespace.0.drain(namespace.0.len() - pop_count..); - } - } - } - } - - fn extend_namespace_from_tree( - tree: &ImportTree, - snapshot: &BufferSnapshot, - parent_abs_path: Option<&Path>, - module: &mut Module, - ) -> usize { - let mut pop_count = 0; - if tree.module_children.is_empty() { - pop_count += module.push_range(&tree.module, snapshot, &tree.language, parent_abs_path); - } else { - for child in &tree.module_children { - pop_count += - Self::extend_namespace_from_tree(child, snapshot, parent_abs_path, module); - } - } - if tree.content_children.is_empty() { - pop_count += module.push_range( - &ModuleRange::Namespace(tree.content.clone()), - snapshot, - &tree.language, - parent_abs_path, - ); - } else { - for child in &tree.content_children { - pop_count += - Self::extend_namespace_from_tree(child, snapshot, parent_abs_path, module); - } - } - pop_count - } -} - -fn range_text(snapshot: &BufferSnapshot, range: &Range) -> Arc { - snapshot - .text_for_range(range.clone()) - .collect::>() - .into() -} - -#[derive(Debug)] -struct DetachedNode { - modules: Vec, - content: Range, - content_kind: ContentKind, - alias: Range, - language: Arc, -} - -#[derive(Debug, Clone, Copy)] -enum ContentKind { - Name, - Wildcard, - List, -} - -impl ContentKind { - fn capture_name(&self) -> &'static str { - match self { - ContentKind::Name => "name", - ContentKind::Wildcard => "wildcard", - ContentKind::List => "list", - } - } -} - -#[derive(Debug)] -struct ImportTree { - module: ModuleRange, - /// When non-empty, provides namespace / source info which should be used instead of `module`. - module_children: Vec, - content: Range, - /// When non-empty, provides content which should be used instead of `content`. - content_children: Vec, - content_kind: ContentKind, - alias: Range, - language: Arc, -} - -impl ImportTree { - fn range(&self) -> Range { - self.module.start.min(self.content.start)..self.module.end.max(self.content.end) - } - - #[allow(dead_code)] - fn debug<'a>(&'a self, snapshot: &'a BufferSnapshot) -> ImportTreeDebug<'a> { - ImportTreeDebug { - tree: self, - snapshot, - } - } - - fn from_module_range(module: &ModuleRange, language: Arc) -> Self { - ImportTree { - module: module.clone(), - module_children: Vec::new(), - content: 0..0, - content_children: Vec::new(), - content_kind: ContentKind::Name, - alias: 0..0, - language, - } - } -} - -impl From<&DetachedNode> for ImportTree { - fn from(value: &DetachedNode) -> Self { - let module; - let module_children; - match value.modules.len() { - 0 => { - module = ModuleRange::Namespace(0..0); - module_children = Vec::new(); - } - 1 => { - module = value.modules[0].clone(); - module_children = Vec::new(); - } - _ => { - module = ModuleRange::Namespace( - value.modules.first().unwrap().start..value.modules.last().unwrap().end, - ); - module_children = value - .modules - .iter() - .map(|module| ImportTree::from_module_range(module, value.language.clone())) - .collect(); - } - } - - ImportTree { - module, - module_children, - content: value.content.clone(), - content_children: Vec::new(), - content_kind: value.content_kind, - alias: value.alias.clone(), - language: value.language.clone(), - } - } -} - -struct ImportTreeDebug<'a> { - tree: &'a ImportTree, - snapshot: &'a BufferSnapshot, -} - -impl std::fmt::Debug for ImportTreeDebug<'_> { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.debug_struct("ImportTree") - .field("module_range", &self.tree.module) - .field("module_text", &range_text(self.snapshot, &self.tree.module)) - .field( - "module_children", - &self - .tree - .module_children - .iter() - .map(|child| child.debug(&self.snapshot)) - .collect::>(), - ) - .field("content_range", &self.tree.content) - .field( - "content_text", - &range_text(self.snapshot, &self.tree.content), - ) - .field( - "content_children", - &self - .tree - .content_children - .iter() - .map(|child| child.debug(&self.snapshot)) - .collect::>(), - ) - .field("content_kind", &self.tree.content_kind) - .field("alias_range", &self.tree.alias) - .field("alias_text", &range_text(self.snapshot, &self.tree.alias)) - .finish() - } -} - -#[cfg(test)] -mod test { - use std::path::PathBuf; - use std::sync::{Arc, LazyLock}; - - use super::*; - use collections::HashSet; - use gpui::{TestAppContext, prelude::*}; - use indoc::indoc; - use language::{ - Buffer, Language, LanguageConfig, tree_sitter_python, tree_sitter_rust, - tree_sitter_typescript, - }; - use regex::Regex; - - #[gpui::test] - fn test_rust_simple(cx: &mut TestAppContext) { - check_imports( - &RUST, - "use std::collections::HashMap;", - &[&["std", "collections", "HashMap"]], - cx, - ); - - check_imports( - &RUST, - "pub use std::collections::HashMap;", - &[&["std", "collections", "HashMap"]], - cx, - ); - - check_imports( - &RUST, - "use std::collections::{HashMap, HashSet};", - &[ - &["std", "collections", "HashMap"], - &["std", "collections", "HashSet"], - ], - cx, - ); - } - - #[gpui::test] - fn test_rust_nested(cx: &mut TestAppContext) { - check_imports( - &RUST, - "use std::{any::TypeId, collections::{HashMap, HashSet}};", - &[ - &["std", "any", "TypeId"], - &["std", "collections", "HashMap"], - &["std", "collections", "HashSet"], - ], - cx, - ); - - check_imports( - &RUST, - "use a::b::c::{d::e::F, g::h::I};", - &[ - &["a", "b", "c", "d", "e", "F"], - &["a", "b", "c", "g", "h", "I"], - ], - cx, - ); - } - - #[gpui::test] - fn test_rust_multiple_imports(cx: &mut TestAppContext) { - check_imports( - &RUST, - indoc! {" - use std::collections::HashMap; - use std::any::{TypeId, Any}; - "}, - &[ - &["std", "collections", "HashMap"], - &["std", "any", "TypeId"], - &["std", "any", "Any"], - ], - cx, - ); - - check_imports( - &RUST, - indoc! {" - use std::collections::HashSet; - - fn main() { - let unqualified = HashSet::new(); - let qualified = std::collections::HashMap::new(); - } - - use std::any::TypeId; - "}, - &[ - &["std", "collections", "HashSet"], - &["std", "any", "TypeId"], - ], - cx, - ); - } - - #[gpui::test] - fn test_rust_wildcard(cx: &mut TestAppContext) { - check_imports(&RUST, "use prelude::*;", &[&["prelude", "WILDCARD"]], cx); - - check_imports( - &RUST, - "use zed::prelude::*;", - &[&["zed", "prelude", "WILDCARD"]], - cx, - ); - - check_imports(&RUST, "use prelude::{*};", &[&["prelude", "WILDCARD"]], cx); - - check_imports( - &RUST, - "use prelude::{File, *};", - &[&["prelude", "File"], &["prelude", "WILDCARD"]], - cx, - ); - - check_imports( - &RUST, - "use zed::{App, prelude::*};", - &[&["zed", "App"], &["zed", "prelude", "WILDCARD"]], - cx, - ); - } - - #[gpui::test] - fn test_rust_alias(cx: &mut TestAppContext) { - check_imports( - &RUST, - "use std::io::Result as IoResult;", - &[&["std", "io", "Result AS IoResult"]], - cx, - ); - } - - #[gpui::test] - fn test_rust_crate_and_super(cx: &mut TestAppContext) { - check_imports(&RUST, "use crate::a::b::c;", &[&["a", "b", "c"]], cx); - check_imports(&RUST, "use super::a::b::c;", &[&["a", "b", "c"]], cx); - // TODO: Consider stripping leading "::". Not done for now because for the text similarity matching usecase this - // is fine. - check_imports(&RUST, "use ::a::b::c;", &[&["::a", "b", "c"]], cx); - } - - #[gpui::test] - fn test_typescript_imports(cx: &mut TestAppContext) { - let parent_abs_path = PathBuf::from("/home/user/project"); - - check_imports_with_file_abs_path( - Some(&parent_abs_path), - &TYPESCRIPT, - r#"import "./maths.js";"#, - &[&["SOURCE /home/user/project/maths", "WILDCARD"]], - cx, - ); - - check_imports_with_file_abs_path( - Some(&parent_abs_path), - &TYPESCRIPT, - r#"import "../maths.js";"#, - &[&["SOURCE /home/user/maths", "WILDCARD"]], - cx, - ); - - check_imports_with_file_abs_path( - Some(&parent_abs_path), - &TYPESCRIPT, - r#"import RandomNumberGenerator, { pi as π } from "./maths.js";"#, - &[ - &["SOURCE /home/user/project/maths", "RandomNumberGenerator"], - &["SOURCE /home/user/project/maths", "pi AS π"], - ], - cx, - ); - - check_imports_with_file_abs_path( - Some(&parent_abs_path), - &TYPESCRIPT, - r#"import { pi, phi, absolute } from "./maths.js";"#, - &[ - &["SOURCE /home/user/project/maths", "pi"], - &["SOURCE /home/user/project/maths", "phi"], - &["SOURCE /home/user/project/maths", "absolute"], - ], - cx, - ); - - // index.js is removed by import_path_strip_regex - check_imports_with_file_abs_path( - Some(&parent_abs_path), - &TYPESCRIPT, - r#"import { pi, phi, absolute } from "./maths/index.js";"#, - &[ - &["SOURCE /home/user/project/maths", "pi"], - &["SOURCE /home/user/project/maths", "phi"], - &["SOURCE /home/user/project/maths", "absolute"], - ], - cx, - ); - - check_imports_with_file_abs_path( - Some(&parent_abs_path), - &TYPESCRIPT, - r#"import type { SomeThing } from "./some-module.js";"#, - &[&["SOURCE /home/user/project/some-module", "SomeThing"]], - cx, - ); - - check_imports_with_file_abs_path( - Some(&parent_abs_path), - &TYPESCRIPT, - r#"import { type SomeThing, OtherThing } from "./some-module.js";"#, - &[ - &["SOURCE /home/user/project/some-module", "SomeThing"], - &["SOURCE /home/user/project/some-module", "OtherThing"], - ], - cx, - ); - - // index.js is removed by import_path_strip_regex - check_imports_with_file_abs_path( - Some(&parent_abs_path), - &TYPESCRIPT, - r#"import { type SomeThing, OtherThing } from "./some-module/index.js";"#, - &[ - &["SOURCE /home/user/project/some-module", "SomeThing"], - &["SOURCE /home/user/project/some-module", "OtherThing"], - ], - cx, - ); - - // fuzzy paths - check_imports_with_file_abs_path( - Some(&parent_abs_path), - &TYPESCRIPT, - r#"import { type SomeThing, OtherThing } from "@my-app/some-module.js";"#, - &[ - &["SOURCE FUZZY @my-app/some-module", "SomeThing"], - &["SOURCE FUZZY @my-app/some-module", "OtherThing"], - ], - cx, - ); - } - - #[gpui::test] - fn test_typescript_named_module_imports(cx: &mut TestAppContext) { - let parent_abs_path = PathBuf::from("/home/user/project"); - - // TODO: These should provide the name that the module is bound to. - // For now instead these are treated as unqualified wildcard imports. - check_imports_with_file_abs_path( - Some(&parent_abs_path), - &TYPESCRIPT, - r#"import * as math from "./maths.js";"#, - // &[&["/home/user/project/maths.js", "WILDCARD AS math"]], - &[&["SOURCE /home/user/project/maths", "WILDCARD"]], - cx, - ); - check_imports_with_file_abs_path( - Some(&parent_abs_path), - &TYPESCRIPT, - r#"import math = require("./maths");"#, - // &[&["/home/user/project/maths", "WILDCARD AS math"]], - &[&["SOURCE /home/user/project/maths", "WILDCARD"]], - cx, - ); - } - - #[gpui::test] - fn test_python_imports(cx: &mut TestAppContext) { - check_imports(&PYTHON, "from math import pi", &[&["math", "pi"]], cx); - - check_imports( - &PYTHON, - "from math import pi, sin, cos", - &[&["math", "pi"], &["math", "sin"], &["math", "cos"]], - cx, - ); - - check_imports(&PYTHON, "from math import *", &[&["math", "WILDCARD"]], cx); - - check_imports( - &PYTHON, - "from math import foo.bar.baz", - &[&["math", "foo", "bar", "baz"]], - cx, - ); - - check_imports( - &PYTHON, - "from math import pi as PI", - &[&["math", "pi AS PI"]], - cx, - ); - - check_imports( - &PYTHON, - "from serializers.json import JsonSerializer", - &[&["serializers", "json", "JsonSerializer"]], - cx, - ); - - check_imports( - &PYTHON, - "from custom.serializers import json, xml, yaml", - &[ - &["custom", "serializers", "json"], - &["custom", "serializers", "xml"], - &["custom", "serializers", "yaml"], - ], - cx, - ); - } - - #[gpui::test] - fn test_python_named_module_imports(cx: &mut TestAppContext) { - // TODO: These should provide the name that the module is bound to. - // For now instead these are treated as unqualified wildcard imports. - // - // check_imports(&PYTHON, "import math", &[&["math", "WILDCARD as math"]], cx); - // check_imports(&PYTHON, "import math as maths", &[&["math", "WILDCARD AS maths"]], cx); - // - // Something like: - // - // (import_statement - // name: [ - // (dotted_name - // (identifier)* @namespace - // (identifier) @name.module .) - // (aliased_import - // name: (dotted_name - // ((identifier) ".")* @namespace - // (identifier) @name.module .) - // alias: (identifier) @alias) - // ]) @import - - check_imports(&PYTHON, "import math", &[&["math", "WILDCARD"]], cx); - - check_imports( - &PYTHON, - "import math as maths", - &[&["math", "WILDCARD"]], - cx, - ); - - check_imports(&PYTHON, "import a.b.c", &[&["a", "b", "c", "WILDCARD"]], cx); - - check_imports( - &PYTHON, - "import a.b.c as d", - &[&["a", "b", "c", "WILDCARD"]], - cx, - ); - } - - #[gpui::test] - fn test_python_package_relative_imports(cx: &mut TestAppContext) { - // TODO: These should provide info about the dir they are relative to, to provide more - // precise resolution. Instead, fuzzy matching is used as usual. - - check_imports(&PYTHON, "from . import math", &[&["math"]], cx); - - check_imports(&PYTHON, "from .a import math", &[&["a", "math"]], cx); - - check_imports( - &PYTHON, - "from ..a.b import math", - &[&["a", "b", "math"]], - cx, - ); - - check_imports( - &PYTHON, - "from ..a.b import *", - &[&["a", "b", "WILDCARD"]], - cx, - ); - } - - #[gpui::test] - fn test_c_imports(cx: &mut TestAppContext) { - let parent_abs_path = PathBuf::from("/home/user/project"); - - // TODO: Distinguish that these are not relative to current path - check_imports_with_file_abs_path( - Some(&parent_abs_path), - &C, - r#"#include "#, - &[&["SOURCE FUZZY math.h", "WILDCARD"]], - cx, - ); - - // TODO: These should be treated as relative, but don't start with ./ or ../ - check_imports_with_file_abs_path( - Some(&parent_abs_path), - &C, - r#"#include "math.h""#, - &[&["SOURCE FUZZY math.h", "WILDCARD"]], - cx, - ); - } - - #[gpui::test] - fn test_cpp_imports(cx: &mut TestAppContext) { - let parent_abs_path = PathBuf::from("/home/user/project"); - - // TODO: Distinguish that these are not relative to current path - check_imports_with_file_abs_path( - Some(&parent_abs_path), - &CPP, - r#"#include "#, - &[&["SOURCE FUZZY math.h", "WILDCARD"]], - cx, - ); - - // TODO: These should be treated as relative, but don't start with ./ or ../ - check_imports_with_file_abs_path( - Some(&parent_abs_path), - &CPP, - r#"#include "math.h""#, - &[&["SOURCE FUZZY math.h", "WILDCARD"]], - cx, - ); - } - - #[gpui::test] - fn test_go_imports(cx: &mut TestAppContext) { - check_imports( - &GO, - r#"import . "lib/math""#, - &[&["lib/math", "WILDCARD"]], - cx, - ); - - // not included, these are only for side-effects - check_imports(&GO, r#"import _ "lib/math""#, &[], cx); - } - - #[gpui::test] - fn test_go_named_module_imports(cx: &mut TestAppContext) { - // TODO: These should provide the name that the module is bound to. - // For now instead these are treated as unqualified wildcard imports. - - check_imports( - &GO, - r#"import "lib/math""#, - &[&["lib/math", "WILDCARD"]], - cx, - ); - check_imports( - &GO, - r#"import m "lib/math""#, - &[&["lib/math", "WILDCARD"]], - cx, - ); - } - - #[track_caller] - fn check_imports( - language: &Arc, - source: &str, - expected: &[&[&str]], - cx: &mut TestAppContext, - ) { - check_imports_with_file_abs_path(None, language, source, expected, cx); - } - - #[track_caller] - fn check_imports_with_file_abs_path( - parent_abs_path: Option<&Path>, - language: &Arc, - source: &str, - expected: &[&[&str]], - cx: &mut TestAppContext, - ) { - let buffer = cx.new(|cx| { - let mut buffer = Buffer::local(source, cx); - buffer.set_language(Some(language.clone()), cx); - buffer - }); - cx.run_until_parked(); - - let snapshot = buffer.read_with(cx, |buffer, _cx| buffer.snapshot()); - - let imports = Imports::gather(&snapshot, parent_abs_path); - let mut actual_symbols = imports - .identifier_to_imports - .iter() - .flat_map(|(identifier, imports)| { - imports - .iter() - .map(|import| import.to_identifier_parts(identifier.name.as_ref())) - }) - .chain( - imports - .wildcard_modules - .iter() - .map(|module| module.to_identifier_parts("WILDCARD")), - ) - .collect::>(); - let mut expected_symbols = expected - .iter() - .map(|expected| expected.iter().map(|s| s.to_string()).collect::>()) - .collect::>(); - actual_symbols.sort(); - expected_symbols.sort(); - if actual_symbols != expected_symbols { - let top_layer = snapshot.syntax_layers().next().unwrap(); - panic!( - "Expected imports: {:?}\n\ - Actual imports: {:?}\n\ - Tree:\n{}", - expected_symbols, - actual_symbols, - tree_to_string(&top_layer.node()), - ); - } - } - - fn tree_to_string(node: &tree_sitter::Node) -> String { - let mut cursor = node.walk(); - let mut result = String::new(); - let mut depth = 0; - 'outer: loop { - result.push_str(&" ".repeat(depth)); - if let Some(field_name) = cursor.field_name() { - result.push_str(field_name); - result.push_str(": "); - } - if cursor.node().is_named() { - result.push_str(cursor.node().kind()); - } else { - result.push('"'); - result.push_str(cursor.node().kind()); - result.push('"'); - } - result.push('\n'); - - if cursor.goto_first_child() { - depth += 1; - continue; - } - if cursor.goto_next_sibling() { - continue; - } - while cursor.goto_parent() { - depth -= 1; - if cursor.goto_next_sibling() { - continue 'outer; - } - } - break; - } - result - } - - static RUST: LazyLock> = LazyLock::new(|| { - Arc::new( - Language::new( - LanguageConfig { - name: "Rust".into(), - ignored_import_segments: HashSet::from_iter(["crate".into(), "super".into()]), - import_path_strip_regex: Some(Regex::new("/(lib|mod)\\.rs$").unwrap()), - ..Default::default() - }, - Some(tree_sitter_rust::LANGUAGE.into()), - ) - .with_imports_query(include_str!("../../languages/src/rust/imports.scm")) - .unwrap(), - ) - }); - - static TYPESCRIPT: LazyLock> = LazyLock::new(|| { - Arc::new( - Language::new( - LanguageConfig { - name: "TypeScript".into(), - import_path_strip_regex: Some(Regex::new("(?:/index)?\\.[jt]s$").unwrap()), - ..Default::default() - }, - Some(tree_sitter_typescript::LANGUAGE_TYPESCRIPT.into()), - ) - .with_imports_query(include_str!("../../languages/src/typescript/imports.scm")) - .unwrap(), - ) - }); - - static PYTHON: LazyLock> = LazyLock::new(|| { - Arc::new( - Language::new( - LanguageConfig { - name: "Python".into(), - import_path_strip_regex: Some(Regex::new("/__init__\\.py$").unwrap()), - ..Default::default() - }, - Some(tree_sitter_python::LANGUAGE.into()), - ) - .with_imports_query(include_str!("../../languages/src/python/imports.scm")) - .unwrap(), - ) - }); - - // TODO: Ideally should use actual language configurations - static C: LazyLock> = LazyLock::new(|| { - Arc::new( - Language::new( - LanguageConfig { - name: "C".into(), - import_path_strip_regex: Some(Regex::new("^<|>$").unwrap()), - ..Default::default() - }, - Some(tree_sitter_c::LANGUAGE.into()), - ) - .with_imports_query(include_str!("../../languages/src/c/imports.scm")) - .unwrap(), - ) - }); - - static CPP: LazyLock> = LazyLock::new(|| { - Arc::new( - Language::new( - LanguageConfig { - name: "C++".into(), - import_path_strip_regex: Some(Regex::new("^<|>$").unwrap()), - ..Default::default() - }, - Some(tree_sitter_cpp::LANGUAGE.into()), - ) - .with_imports_query(include_str!("../../languages/src/cpp/imports.scm")) - .unwrap(), - ) - }); - - static GO: LazyLock> = LazyLock::new(|| { - Arc::new( - Language::new( - LanguageConfig { - name: "Go".into(), - ..Default::default() - }, - Some(tree_sitter_go::LANGUAGE.into()), - ) - .with_imports_query(include_str!("../../languages/src/go/imports.scm")) - .unwrap(), - ) - }); - - impl Import { - fn to_identifier_parts(&self, identifier: &str) -> Vec { - match self { - Import::Direct { module } => module.to_identifier_parts(identifier), - Import::Alias { - module, - external_identifier: external_name, - } => { - module.to_identifier_parts(&format!("{} AS {}", external_name.name, identifier)) - } - } - } - } - - impl Module { - fn to_identifier_parts(&self, identifier: &str) -> Vec { - match self { - Self::Namespace(namespace) => namespace.to_identifier_parts(identifier), - Self::SourceExact(path) => { - vec![ - format!("SOURCE {}", path.display().to_string().replace("\\", "/")), - identifier.to_string(), - ] - } - Self::SourceFuzzy(path) => { - vec![ - format!( - "SOURCE FUZZY {}", - path.display().to_string().replace("\\", "/") - ), - identifier.to_string(), - ] - } - } - } - } - - impl Namespace { - fn to_identifier_parts(&self, identifier: &str) -> Vec { - self.0 - .iter() - .map(|chunk| chunk.to_string()) - .chain(std::iter::once(identifier.to_string())) - .collect::>() - } - } -} diff --git a/crates/edit_prediction_context/src/outline.rs b/crates/edit_prediction_context/src/outline.rs deleted file mode 100644 index ec02c869dfae4cb861206cb801c285462e734f36..0000000000000000000000000000000000000000 --- a/crates/edit_prediction_context/src/outline.rs +++ /dev/null @@ -1,126 +0,0 @@ -use language::{BufferSnapshot, SyntaxMapMatches}; -use std::{cmp::Reverse, ops::Range}; - -use crate::declaration::Identifier; - -// TODO: -// -// * how to handle multiple name captures? for now last one wins -// -// * annotation ranges -// -// * new "signature" capture for outline queries -// -// * Check parent behavior of "int x, y = 0" declarations in a test - -pub struct OutlineDeclaration { - pub parent_index: Option, - pub identifier: Identifier, - pub item_range: Range, - pub signature_range: Range, -} - -pub fn declarations_in_buffer(buffer: &BufferSnapshot) -> Vec { - declarations_overlapping_range(0..buffer.len(), buffer) -} - -pub fn declarations_overlapping_range( - range: Range, - buffer: &BufferSnapshot, -) -> Vec { - let mut declarations = OutlineIterator::new(range, buffer).collect::>(); - declarations.sort_unstable_by_key(|item| (item.item_range.start, Reverse(item.item_range.end))); - - let mut parent_stack: Vec<(usize, Range)> = Vec::new(); - for (index, declaration) in declarations.iter_mut().enumerate() { - while let Some((top_parent_index, top_parent_range)) = parent_stack.last() { - if declaration.item_range.start >= top_parent_range.end { - parent_stack.pop(); - } else { - declaration.parent_index = Some(*top_parent_index); - break; - } - } - parent_stack.push((index, declaration.item_range.clone())); - } - declarations -} - -/// Iterates outline items without being ordered w.r.t. nested items and without populating -/// `parent`. -pub struct OutlineIterator<'a> { - buffer: &'a BufferSnapshot, - matches: SyntaxMapMatches<'a>, -} - -impl<'a> OutlineIterator<'a> { - pub fn new(range: Range, buffer: &'a BufferSnapshot) -> Self { - let matches = buffer.syntax.matches(range, &buffer.text, |grammar| { - grammar.outline_config.as_ref().map(|c| &c.query) - }); - - Self { buffer, matches } - } -} - -impl<'a> Iterator for OutlineIterator<'a> { - type Item = OutlineDeclaration; - - fn next(&mut self) -> Option { - while let Some(mat) = self.matches.peek() { - let config = self.matches.grammars()[mat.grammar_index] - .outline_config - .as_ref() - .unwrap(); - - let mut name_range = None; - let mut item_range = None; - let mut signature_start = None; - let mut signature_end = None; - - let mut add_to_signature = |range: Range| { - if signature_start.is_none() { - signature_start = Some(range.start); - } - signature_end = Some(range.end); - }; - - for capture in mat.captures { - let range = capture.node.byte_range(); - if capture.index == config.name_capture_ix { - name_range = Some(range.clone()); - add_to_signature(range); - } else if Some(capture.index) == config.context_capture_ix - || Some(capture.index) == config.extra_context_capture_ix - { - add_to_signature(range); - } else if capture.index == config.item_capture_ix { - item_range = Some(range.clone()); - } - } - - let language_id = mat.language.id(); - self.matches.advance(); - - if let Some(name_range) = name_range - && let Some(item_range) = item_range - && let Some(signature_start) = signature_start - && let Some(signature_end) = signature_end - { - let name = self - .buffer - .text_for_range(name_range) - .collect::() - .into(); - - return Some(OutlineDeclaration { - identifier: Identifier { name, language_id }, - item_range: item_range, - signature_range: signature_start..signature_end, - parent_index: None, - }); - } - } - None - } -} diff --git a/crates/edit_prediction_context/src/reference.rs b/crates/edit_prediction_context/src/reference.rs deleted file mode 100644 index 699adf1d8036802a7a4b9e34ca8e8094e4f97458..0000000000000000000000000000000000000000 --- a/crates/edit_prediction_context/src/reference.rs +++ /dev/null @@ -1,173 +0,0 @@ -use collections::HashMap; -use language::BufferSnapshot; -use std::ops::Range; -use util::RangeExt; - -use crate::{ - declaration::Identifier, - excerpt::{EditPredictionExcerpt, EditPredictionExcerptText}, -}; - -#[derive(Debug, Clone)] -pub struct Reference { - pub identifier: Identifier, - pub range: Range, - pub region: ReferenceRegion, -} - -#[derive(Copy, Clone, Debug, Eq, PartialEq)] -pub enum ReferenceRegion { - Breadcrumb, - Nearby, -} - -pub fn references_in_excerpt( - excerpt: &EditPredictionExcerpt, - excerpt_text: &EditPredictionExcerptText, - snapshot: &BufferSnapshot, -) -> HashMap> { - let mut references = references_in_range( - excerpt.range.clone(), - excerpt_text.body.as_str(), - ReferenceRegion::Nearby, - snapshot, - ); - - for ((_, range), text) in excerpt - .parent_declarations - .iter() - .zip(excerpt_text.parent_signatures.iter()) - { - references.extend(references_in_range( - range.clone(), - text.as_str(), - ReferenceRegion::Breadcrumb, - snapshot, - )); - } - - let mut identifier_to_references: HashMap> = HashMap::default(); - for reference in references { - identifier_to_references - .entry(reference.identifier.clone()) - .or_insert_with(Vec::new) - .push(reference); - } - identifier_to_references -} - -/// Finds all nodes which have a "variable" match from the highlights query within the offset range. -pub fn references_in_range( - range: Range, - range_text: &str, - reference_region: ReferenceRegion, - buffer: &BufferSnapshot, -) -> Vec { - let mut matches = buffer - .syntax - .matches(range.clone(), &buffer.text, |grammar| { - grammar - .highlights_config - .as_ref() - .map(|config| &config.query) - }); - - let mut references = Vec::new(); - let mut last_added_range = None; - while let Some(mat) = matches.peek() { - let config = matches.grammars()[mat.grammar_index] - .highlights_config - .as_ref(); - - if let Some(config) = config { - for capture in mat.captures { - if config.identifier_capture_indices.contains(&capture.index) { - let node_range = capture.node.byte_range(); - - // sometimes multiple highlight queries match - this deduplicates them - if Some(node_range.clone()) == last_added_range { - continue; - } - - if !range.contains_inclusive(&node_range) { - continue; - } - - let identifier_text = - &range_text[node_range.start - range.start..node_range.end - range.start]; - - references.push(Reference { - identifier: Identifier { - name: identifier_text.into(), - language_id: mat.language.id(), - }, - range: node_range.clone(), - region: reference_region, - }); - last_added_range = Some(node_range); - } - } - } - - matches.advance(); - } - references -} - -#[cfg(test)] -mod test { - use gpui::{TestAppContext, prelude::*}; - use indoc::indoc; - use language::{BufferSnapshot, Language, LanguageConfig, LanguageMatcher, tree_sitter_rust}; - - use crate::reference::{ReferenceRegion, references_in_range}; - - #[gpui::test] - fn test_identifier_node_truncated(cx: &mut TestAppContext) { - let code = indoc! { r#" - fn main() { - add(1, 2); - } - - fn add(a: i32, b: i32) -> i32 { - a + b - } - "# }; - let buffer = create_buffer(code, cx); - - let range = 0..35; - let references = references_in_range( - range.clone(), - &code[range], - ReferenceRegion::Breadcrumb, - &buffer, - ); - assert_eq!(references.len(), 2); - assert_eq!(references[0].identifier.name.as_ref(), "main"); - assert_eq!(references[1].identifier.name.as_ref(), "add"); - } - - fn create_buffer(text: &str, cx: &mut TestAppContext) -> BufferSnapshot { - let buffer = - cx.new(|cx| language::Buffer::local(text, cx).with_language(rust_lang().into(), cx)); - buffer.read_with(cx, |buffer, _| buffer.snapshot()) - } - - fn rust_lang() -> Language { - Language::new( - LanguageConfig { - name: "Rust".into(), - matcher: LanguageMatcher { - path_suffixes: vec!["rs".to_string()], - ..Default::default() - }, - ..Default::default() - }, - Some(tree_sitter_rust::LANGUAGE.into()), - ) - .with_highlights_query(include_str!("../../languages/src/rust/highlights.scm")) - .unwrap() - .with_outline_query(include_str!("../../languages/src/rust/outline.scm")) - .unwrap() - } -} diff --git a/crates/edit_prediction_context/src/syntax_index.rs b/crates/edit_prediction_context/src/syntax_index.rs deleted file mode 100644 index f489a083341b66c7cca3cdad76a9c7ea16fdc959..0000000000000000000000000000000000000000 --- a/crates/edit_prediction_context/src/syntax_index.rs +++ /dev/null @@ -1,1069 +0,0 @@ -use anyhow::{Result, anyhow}; -use collections::{HashMap, HashSet}; -use futures::channel::mpsc; -use futures::lock::Mutex; -use futures::{FutureExt as _, StreamExt, future}; -use gpui::{App, AppContext as _, AsyncApp, Context, Entity, Task, WeakEntity}; -use itertools::Itertools; - -use language::{Buffer, BufferEvent}; -use postage::stream::Stream as _; -use project::buffer_store::{BufferStore, BufferStoreEvent}; -use project::worktree_store::{WorktreeStore, WorktreeStoreEvent}; -use project::{PathChange, Project, ProjectEntryId, ProjectPath}; -use slotmap::SlotMap; -use std::iter; -use std::ops::{DerefMut, Range}; -use std::sync::Arc; -use text::BufferId; -use util::{RangeExt as _, debug_panic, some_or_debug_panic}; - -use crate::CachedDeclarationPath; -use crate::declaration::{ - BufferDeclaration, Declaration, DeclarationId, FileDeclaration, Identifier, -}; -use crate::outline::declarations_in_buffer; - -// TODO -// -// * Also queue / debounce buffer changes. A challenge for this is that use of -// `buffer_declarations_containing_range` assumes that the index is always immediately up to date. -// -// * Add a per language configuration for skipping indexing. -// -// * Handle tsx / ts / js referencing each-other - -// Potential future improvements: -// -// * Prevent indexing of a large file from blocking the queue. -// -// * Send multiple selected excerpt ranges. Challenge is that excerpt ranges influence which -// references are present and their scores. -// -// * Include single-file worktrees / non visible worktrees? E.g. go to definition that resolves to a -// file in a build dependency. Should not be editable in that case - but how to distinguish the case -// where it should be editable? - -// Potential future optimizations: -// -// * Index files on multiple threads in Zed (currently only parallel for the CLI). Adding some kind -// of priority system to the background executor could help - it's single threaded for now to avoid -// interfering with other work. -// -// * Parse files directly instead of loading into a Rope. -// -// - This would allow the task handling dirty_files to be done entirely on the background executor. -// -// - Make SyntaxMap generic to handle embedded languages? Will also need to find line boundaries, -// but that can be done by scanning characters in the flat representation. -// -// * Use something similar to slotmap without key versions. -// -// * Concurrent slotmap - -pub struct SyntaxIndex { - state: Arc>, - project: WeakEntity, - initial_file_indexing_done_rx: postage::watch::Receiver, - _file_indexing_task: Option>, -} - -pub struct SyntaxIndexState { - declarations: SlotMap, - identifiers: HashMap>, - files: HashMap, - buffers: HashMap, - dirty_files: HashMap, - dirty_files_tx: mpsc::Sender<()>, -} - -#[derive(Debug, Default)] -struct FileState { - declarations: Vec, -} - -#[derive(Default)] -struct BufferState { - declarations: Vec, - task: Option>, -} - -impl SyntaxIndex { - pub fn new( - project: &Entity, - file_indexing_parallelism: usize, - cx: &mut Context, - ) -> Self { - assert!(file_indexing_parallelism > 0); - let (dirty_files_tx, mut dirty_files_rx) = mpsc::channel::<()>(1); - let (mut initial_file_indexing_done_tx, initial_file_indexing_done_rx) = - postage::watch::channel(); - - let initial_state = SyntaxIndexState { - declarations: SlotMap::default(), - identifiers: HashMap::default(), - files: HashMap::default(), - buffers: HashMap::default(), - dirty_files: HashMap::default(), - dirty_files_tx, - }; - let mut this = Self { - project: project.downgrade(), - state: Arc::new(Mutex::new(initial_state)), - initial_file_indexing_done_rx, - _file_indexing_task: None, - }; - - let worktree_store = project.read(cx).worktree_store(); - let initial_worktree_snapshots = worktree_store - .read(cx) - .worktrees() - .map(|w| w.read(cx).snapshot()) - .collect::>(); - this._file_indexing_task = Some(cx.spawn(async move |this, cx| { - let snapshots_file_count = initial_worktree_snapshots - .iter() - .map(|worktree| worktree.file_count()) - .sum::(); - if snapshots_file_count > 0 { - let chunk_size = snapshots_file_count.div_ceil(file_indexing_parallelism); - let chunk_count = snapshots_file_count.div_ceil(chunk_size); - let file_chunks = initial_worktree_snapshots - .iter() - .flat_map(|worktree| { - let worktree_id = worktree.id(); - worktree.files(false, 0).map(move |entry| { - ( - entry.id, - ProjectPath { - worktree_id, - path: entry.path.clone(), - }, - ) - }) - }) - .chunks(chunk_size); - - let mut tasks = Vec::with_capacity(chunk_count); - for chunk in file_chunks.into_iter() { - tasks.push(Self::update_dirty_files( - &this, - chunk.into_iter().collect(), - cx.clone(), - )); - } - futures::future::join_all(tasks).await; - log::info!("Finished initial file indexing"); - } - - *initial_file_indexing_done_tx.borrow_mut() = true; - - let Ok(state) = this.read_with(cx, |this, _cx| Arc::downgrade(&this.state)) else { - return; - }; - while dirty_files_rx.next().await.is_some() { - let Some(state) = state.upgrade() else { - return; - }; - let mut state = state.lock().await; - let was_underused = state.dirty_files.capacity() > 255 - && state.dirty_files.len() * 8 < state.dirty_files.capacity(); - let dirty_files = state.dirty_files.drain().collect::>(); - if was_underused { - state.dirty_files.shrink_to_fit(); - } - drop(state); - if dirty_files.is_empty() { - continue; - } - - let chunk_size = dirty_files.len().div_ceil(file_indexing_parallelism); - let chunk_count = dirty_files.len().div_ceil(chunk_size); - let mut tasks = Vec::with_capacity(chunk_count); - let chunks = dirty_files.into_iter().chunks(chunk_size); - for chunk in chunks.into_iter() { - tasks.push(Self::update_dirty_files( - &this, - chunk.into_iter().collect(), - cx.clone(), - )); - } - futures::future::join_all(tasks).await; - } - })); - - cx.subscribe(&worktree_store, Self::handle_worktree_store_event) - .detach(); - - let buffer_store = project.read(cx).buffer_store().clone(); - for buffer in buffer_store.read(cx).buffers().collect::>() { - this.register_buffer(&buffer, cx); - } - cx.subscribe(&buffer_store, Self::handle_buffer_store_event) - .detach(); - - this - } - - async fn update_dirty_files( - this: &WeakEntity, - dirty_files: Vec<(ProjectEntryId, ProjectPath)>, - mut cx: AsyncApp, - ) { - for (entry_id, project_path) in dirty_files { - let Ok(task) = this.update(&mut cx, |this, cx| { - this.update_file(entry_id, project_path, cx) - }) else { - return; - }; - task.await; - } - } - - pub fn wait_for_initial_file_indexing(&self, cx: &App) -> Task> { - if *self.initial_file_indexing_done_rx.borrow() { - Task::ready(Ok(())) - } else { - let mut rx = self.initial_file_indexing_done_rx.clone(); - cx.background_spawn(async move { - loop { - match rx.recv().await { - Some(true) => return Ok(()), - Some(false) => {} - None => { - return Err(anyhow!( - "SyntaxIndex dropped while waiting for initial file indexing" - )); - } - } - } - }) - } - } - - pub fn indexed_file_paths(&self, cx: &App) -> Task> { - let state = self.state.clone(); - let project = self.project.clone(); - - cx.spawn(async move |cx| { - let state = state.lock().await; - let Some(project) = project.upgrade() else { - return vec![]; - }; - project - .read_with(cx, |project, cx| { - state - .files - .keys() - .filter_map(|entry_id| project.path_for_entry(*entry_id, cx)) - .collect() - }) - .unwrap_or_default() - }) - } - - fn handle_worktree_store_event( - &mut self, - _worktree_store: Entity, - event: &WorktreeStoreEvent, - cx: &mut Context, - ) { - use WorktreeStoreEvent::*; - match event { - WorktreeUpdatedEntries(worktree_id, updated_entries_set) => { - let state = Arc::downgrade(&self.state); - let worktree_id = *worktree_id; - let updated_entries_set = updated_entries_set.clone(); - cx.background_spawn(async move { - let Some(state) = state.upgrade() else { return }; - let mut state = state.lock().await; - for (path, entry_id, path_change) in updated_entries_set.iter() { - if let PathChange::Removed = path_change { - state.files.remove(entry_id); - state.dirty_files.remove(entry_id); - } else { - let project_path = ProjectPath { - worktree_id, - path: path.clone(), - }; - state.dirty_files.insert(*entry_id, project_path); - } - } - match state.dirty_files_tx.try_send(()) { - Err(err) if err.is_disconnected() => { - log::error!("bug: syntax indexing queue is disconnected"); - } - _ => {} - } - }) - .detach(); - } - WorktreeDeletedEntry(_worktree_id, project_entry_id) => { - let project_entry_id = *project_entry_id; - self.with_state(cx, move |state| { - state.files.remove(&project_entry_id); - }) - } - _ => {} - } - } - - fn handle_buffer_store_event( - &mut self, - _buffer_store: Entity, - event: &BufferStoreEvent, - cx: &mut Context, - ) { - use BufferStoreEvent::*; - match event { - BufferAdded(buffer) => self.register_buffer(buffer, cx), - BufferOpened { .. } - | BufferChangedFilePath { .. } - | BufferDropped { .. } - | SharedBufferClosed { .. } => {} - } - } - - pub fn state(&self) -> &Arc> { - &self.state - } - - fn with_state(&self, cx: &mut App, f: impl FnOnce(&mut SyntaxIndexState) + Send + 'static) { - if let Some(mut state) = self.state.try_lock() { - f(&mut state); - return; - } - let state = Arc::downgrade(&self.state); - cx.background_spawn(async move { - let Some(state) = state.upgrade() else { - return; - }; - let mut state = state.lock().await; - f(&mut state) - }) - .detach(); - } - - fn register_buffer(&self, buffer: &Entity, cx: &mut Context) { - let buffer_id = buffer.read(cx).remote_id(); - cx.observe_release(buffer, move |this, _buffer, cx| { - this.with_state(cx, move |state| { - if let Some(buffer_state) = state.buffers.remove(&buffer_id) { - SyntaxIndexState::remove_buffer_declarations( - &buffer_state.declarations, - &mut state.declarations, - &mut state.identifiers, - ); - } - }) - }) - .detach(); - cx.subscribe(buffer, Self::handle_buffer_event).detach(); - - self.update_buffer(buffer.clone(), cx); - } - - fn handle_buffer_event( - &mut self, - buffer: Entity, - event: &BufferEvent, - cx: &mut Context, - ) { - match event { - BufferEvent::Edited | - // paths are cached and so should be updated - BufferEvent::FileHandleChanged => self.update_buffer(buffer, cx), - _ => {} - } - } - - fn update_buffer(&self, buffer_entity: Entity, cx: &mut Context) { - let buffer = buffer_entity.read(cx); - if buffer.language().is_none() { - return; - } - - let Some((project_entry_id, cached_path)) = project::File::from_dyn(buffer.file()) - .and_then(|f| { - let project_entry_id = f.project_entry_id()?; - let cached_path = CachedDeclarationPath::new( - f.worktree.read(cx).abs_path(), - &f.path, - buffer.language(), - ); - Some((project_entry_id, cached_path)) - }) - else { - return; - }; - let buffer_id = buffer.remote_id(); - - let mut parse_status = buffer.parse_status(); - let snapshot_task = cx.spawn({ - let weak_buffer = buffer_entity.downgrade(); - async move |_, cx| { - while *parse_status.borrow() != language::ParseStatus::Idle { - parse_status.changed().await?; - } - weak_buffer.read_with(cx, |buffer, _cx| buffer.snapshot()) - } - }); - - let state = Arc::downgrade(&self.state); - let task = cx.background_spawn(async move { - // TODO: How to handle errors? - let Ok(snapshot) = snapshot_task.await else { - return; - }; - let rope = snapshot.text.as_rope(); - - let declarations = declarations_in_buffer(&snapshot) - .into_iter() - .map(|item| { - ( - item.parent_index, - BufferDeclaration::from_outline(item, &rope), - ) - }) - .collect::>(); - - let Some(state) = state.upgrade() else { - return; - }; - let mut state = state.lock().await; - let state = state.deref_mut(); - - let buffer_state = state - .buffers - .entry(buffer_id) - .or_insert_with(Default::default); - - SyntaxIndexState::remove_buffer_declarations( - &buffer_state.declarations, - &mut state.declarations, - &mut state.identifiers, - ); - - let mut new_ids = Vec::with_capacity(declarations.len()); - state.declarations.reserve(declarations.len()); - for (parent_index, mut declaration) in declarations { - declaration.parent = - parent_index.and_then(|ix| some_or_debug_panic(new_ids.get(ix).copied())); - - let identifier = declaration.identifier.clone(); - let declaration_id = state.declarations.insert(Declaration::Buffer { - rope: rope.clone(), - buffer_id, - declaration, - project_entry_id, - cached_path: cached_path.clone(), - }); - new_ids.push(declaration_id); - - state - .identifiers - .entry(identifier) - .or_default() - .insert(declaration_id); - } - - buffer_state.declarations = new_ids; - }); - - self.with_state(cx, move |state| { - state - .buffers - .entry(buffer_id) - .or_insert_with(Default::default) - .task = Some(task) - }); - } - - fn update_file( - &mut self, - entry_id: ProjectEntryId, - project_path: ProjectPath, - cx: &mut Context, - ) -> Task<()> { - let Some(project) = self.project.upgrade() else { - return Task::ready(()); - }; - let project = project.read(cx); - - let language_registry = project.languages(); - let Some(available_language) = - language_registry.language_for_file_path(project_path.path.as_std_path()) - else { - return Task::ready(()); - }; - let language = if let Some(Ok(Ok(language))) = language_registry - .load_language(&available_language) - .now_or_never() - { - if language - .grammar() - .is_none_or(|grammar| grammar.outline_config.is_none()) - { - return Task::ready(()); - } - future::Either::Left(async { Ok(language) }) - } else { - let language_registry = language_registry.clone(); - future::Either::Right(async move { - anyhow::Ok( - language_registry - .load_language(&available_language) - .await??, - ) - }) - }; - - let Some(worktree) = project.worktree_for_id(project_path.worktree_id, cx) else { - return Task::ready(()); - }; - - let snapshot_task = worktree.update(cx, |worktree, cx| { - let load_task = worktree.load_file(&project_path.path, cx); - let worktree_abs_path = worktree.abs_path(); - cx.spawn(async move |_this, cx| { - let loaded_file = load_task.await?; - let language = language.await?; - - let buffer = cx.new(|cx| { - let mut buffer = Buffer::local(loaded_file.text, cx); - buffer.set_language(Some(language.clone()), cx); - buffer - })?; - - let mut parse_status = buffer.read_with(cx, |buffer, _| buffer.parse_status())?; - while *parse_status.borrow() != language::ParseStatus::Idle { - parse_status.changed().await?; - } - - let cached_path = CachedDeclarationPath::new( - worktree_abs_path, - &project_path.path, - Some(&language), - ); - - let snapshot = buffer.read_with(cx, |buffer, _cx| buffer.snapshot())?; - - anyhow::Ok((snapshot, cached_path)) - }) - }); - - let state = Arc::downgrade(&self.state); - cx.background_spawn(async move { - // TODO: How to handle errors? - let Ok((snapshot, cached_path)) = snapshot_task.await else { - return; - }; - let rope = snapshot.as_rope(); - let declarations = declarations_in_buffer(&snapshot) - .into_iter() - .map(|item| (item.parent_index, FileDeclaration::from_outline(item, rope))) - .collect::>(); - - let Some(state) = state.upgrade() else { - return; - }; - let mut state = state.lock().await; - let state = state.deref_mut(); - - let file_state = state.files.entry(entry_id).or_insert_with(Default::default); - for old_declaration_id in &file_state.declarations { - let Some(declaration) = state.declarations.remove(*old_declaration_id) else { - debug_panic!("declaration not found"); - continue; - }; - if let Some(identifier_declarations) = - state.identifiers.get_mut(declaration.identifier()) - { - identifier_declarations.remove(old_declaration_id); - } - } - - let mut new_ids = Vec::with_capacity(declarations.len()); - state.declarations.reserve(declarations.len()); - for (parent_index, mut declaration) in declarations { - declaration.parent = - parent_index.and_then(|ix| some_or_debug_panic(new_ids.get(ix).copied())); - - let identifier = declaration.identifier.clone(); - let declaration_id = state.declarations.insert(Declaration::File { - project_entry_id: entry_id, - declaration, - cached_path: cached_path.clone(), - }); - new_ids.push(declaration_id); - - state - .identifiers - .entry(identifier) - .or_default() - .insert(declaration_id); - } - file_state.declarations = new_ids; - }) - } -} - -impl SyntaxIndexState { - pub fn declaration(&self, id: DeclarationId) -> Option<&Declaration> { - self.declarations.get(id) - } - - /// Returns declarations for the identifier. If the limit is exceeded, returns an empty vector. - /// - /// TODO: Consider doing some pre-ranking and instead truncating when N is exceeded. - pub fn declarations_for_identifier( - &self, - identifier: &Identifier, - ) -> Vec<(DeclarationId, &Declaration)> { - // make sure to not have a large stack allocation - assert!(N < 32); - - let Some(declaration_ids) = self.identifiers.get(&identifier) else { - return vec![]; - }; - - let mut result = Vec::with_capacity(N); - let mut included_buffer_entry_ids = arrayvec::ArrayVec::<_, N>::new(); - let mut file_declarations = Vec::new(); - - for declaration_id in declaration_ids { - let declaration = self.declarations.get(*declaration_id); - let Some(declaration) = some_or_debug_panic(declaration) else { - continue; - }; - match declaration { - Declaration::Buffer { - project_entry_id, .. - } => { - included_buffer_entry_ids.push(*project_entry_id); - result.push((*declaration_id, declaration)); - if result.len() == N { - return Vec::new(); - } - } - Declaration::File { - project_entry_id, .. - } => { - if !included_buffer_entry_ids.contains(&project_entry_id) { - file_declarations.push((*declaration_id, declaration)); - } - } - } - } - - for (declaration_id, declaration) in file_declarations { - match declaration { - Declaration::File { - project_entry_id, .. - } => { - if !included_buffer_entry_ids.contains(&project_entry_id) { - result.push((declaration_id, declaration)); - - if result.len() == N { - return Vec::new(); - } - } - } - Declaration::Buffer { .. } => {} - } - } - - result - } - - pub fn buffer_declarations_containing_range( - &self, - buffer_id: BufferId, - range: Range, - ) -> impl Iterator { - let Some(buffer_state) = self.buffers.get(&buffer_id) else { - return itertools::Either::Left(iter::empty()); - }; - - let iter = buffer_state - .declarations - .iter() - .filter_map(move |declaration_id| { - let Some(declaration) = self - .declarations - .get(*declaration_id) - .and_then(|d| d.as_buffer()) - else { - log::error!("bug: missing buffer outline declaration"); - return None; - }; - if declaration.item_range.contains_inclusive(&range) { - return Some((*declaration_id, declaration)); - } - return None; - }); - itertools::Either::Right(iter) - } - - pub fn file_declaration_count(&self, declaration: &Declaration) -> usize { - match declaration { - Declaration::File { - project_entry_id, .. - } => self - .files - .get(project_entry_id) - .map(|file_state| file_state.declarations.len()) - .unwrap_or_default(), - Declaration::Buffer { buffer_id, .. } => self - .buffers - .get(buffer_id) - .map(|buffer_state| buffer_state.declarations.len()) - .unwrap_or_default(), - } - } - - fn remove_buffer_declarations( - old_declaration_ids: &[DeclarationId], - declarations: &mut SlotMap, - identifiers: &mut HashMap>, - ) { - for old_declaration_id in old_declaration_ids { - let Some(declaration) = declarations.remove(*old_declaration_id) else { - debug_panic!("declaration not found"); - continue; - }; - if let Some(identifier_declarations) = identifiers.get_mut(declaration.identifier()) { - identifier_declarations.remove(old_declaration_id); - } - } - } -} - -#[cfg(test)] -mod tests { - use super::*; - use std::sync::Arc; - - use gpui::TestAppContext; - use indoc::indoc; - use language::{Language, LanguageConfig, LanguageId, LanguageMatcher, tree_sitter_rust}; - use project::{FakeFs, Project}; - use serde_json::json; - use settings::SettingsStore; - use text::OffsetRangeExt as _; - use util::{path, rel_path::rel_path}; - - use crate::syntax_index::SyntaxIndex; - - #[gpui::test] - async fn test_unopen_indexed_files(cx: &mut TestAppContext) { - let (project, index, rust_lang_id) = init_test(cx).await; - let main = Identifier { - name: "main".into(), - language_id: rust_lang_id, - }; - - let index_state = index.read_with(cx, |index, _cx| index.state().clone()); - let index_state = index_state.lock().await; - cx.update(|cx| { - let decls = index_state.declarations_for_identifier::<8>(&main); - assert_eq!(decls.len(), 2); - - let decl = expect_file_decl("a.rs", &decls[0].1, &project, cx); - assert_eq!(decl.identifier, main); - assert_eq!(decl.item_range, 0..98); - - let decl = expect_file_decl("c.rs", &decls[1].1, &project, cx); - assert_eq!(decl.identifier, main.clone()); - assert_eq!(decl.item_range, 32..280); - }); - } - - #[gpui::test] - async fn test_parents_in_file(cx: &mut TestAppContext) { - let (project, index, rust_lang_id) = init_test(cx).await; - let test_process_data = Identifier { - name: "test_process_data".into(), - language_id: rust_lang_id, - }; - - let index_state = index.read_with(cx, |index, _cx| index.state().clone()); - let index_state = index_state.lock().await; - cx.update(|cx| { - let decls = index_state.declarations_for_identifier::<8>(&test_process_data); - assert_eq!(decls.len(), 1); - - let decl = expect_file_decl("c.rs", &decls[0].1, &project, cx); - assert_eq!(decl.identifier, test_process_data); - - let parent_id = decl.parent.unwrap(); - let parent = index_state.declaration(parent_id).unwrap(); - let parent_decl = expect_file_decl("c.rs", &parent, &project, cx); - assert_eq!( - parent_decl.identifier, - Identifier { - name: "tests".into(), - language_id: rust_lang_id - } - ); - assert_eq!(parent_decl.parent, None); - }); - } - - #[gpui::test] - async fn test_parents_in_buffer(cx: &mut TestAppContext) { - let (project, index, rust_lang_id) = init_test(cx).await; - let test_process_data = Identifier { - name: "test_process_data".into(), - language_id: rust_lang_id, - }; - - let buffer = project - .update(cx, |project, cx| { - let project_path = project.find_project_path("c.rs", cx).unwrap(); - project.open_buffer(project_path, cx) - }) - .await - .unwrap(); - - cx.run_until_parked(); - - let index_state = index.read_with(cx, |index, _cx| index.state().clone()); - let index_state = index_state.lock().await; - cx.update(|cx| { - let decls = index_state.declarations_for_identifier::<8>(&test_process_data); - assert_eq!(decls.len(), 1); - - let decl = expect_buffer_decl("c.rs", &decls[0].1, &project, cx); - assert_eq!(decl.identifier, test_process_data); - - let parent_id = decl.parent.unwrap(); - let parent = index_state.declaration(parent_id).unwrap(); - let parent_decl = expect_buffer_decl("c.rs", &parent, &project, cx); - assert_eq!( - parent_decl.identifier, - Identifier { - name: "tests".into(), - language_id: rust_lang_id - } - ); - assert_eq!(parent_decl.parent, None); - }); - - drop(buffer); - } - - #[gpui::test] - async fn test_declarations_limit(cx: &mut TestAppContext) { - let (_, index, rust_lang_id) = init_test(cx).await; - - let index_state = index.read_with(cx, |index, _cx| index.state().clone()); - let index_state = index_state.lock().await; - let decls = index_state.declarations_for_identifier::<1>(&Identifier { - name: "main".into(), - language_id: rust_lang_id, - }); - assert_eq!(decls.len(), 0); - } - - #[gpui::test] - async fn test_buffer_shadow(cx: &mut TestAppContext) { - let (project, index, rust_lang_id) = init_test(cx).await; - - let main = Identifier { - name: "main".into(), - language_id: rust_lang_id, - }; - - let buffer = project - .update(cx, |project, cx| { - let project_path = project.find_project_path("c.rs", cx).unwrap(); - project.open_buffer(project_path, cx) - }) - .await - .unwrap(); - - cx.run_until_parked(); - - let index_state_arc = index.read_with(cx, |index, _cx| index.state().clone()); - { - let index_state = index_state_arc.lock().await; - - cx.update(|cx| { - let decls = index_state.declarations_for_identifier::<8>(&main); - assert_eq!(decls.len(), 2); - let decl = expect_buffer_decl("c.rs", &decls[0].1, &project, cx); - assert_eq!(decl.identifier, main); - assert_eq!(decl.item_range.to_offset(&buffer.read(cx)), 32..280); - - expect_file_decl("a.rs", &decls[1].1, &project, cx); - }); - } - - // Drop the buffer and wait for release - cx.update(|_| { - drop(buffer); - }); - cx.run_until_parked(); - - let index_state = index_state_arc.lock().await; - - cx.update(|cx| { - let decls = index_state.declarations_for_identifier::<8>(&main); - assert_eq!(decls.len(), 2); - expect_file_decl("a.rs", &decls[0].1, &project, cx); - expect_file_decl("c.rs", &decls[1].1, &project, cx); - }); - } - - fn expect_buffer_decl<'a>( - path: &str, - declaration: &'a Declaration, - project: &Entity, - cx: &App, - ) -> &'a BufferDeclaration { - if let Declaration::Buffer { - declaration, - project_entry_id, - .. - } = declaration - { - let project_path = project - .read(cx) - .path_for_entry(*project_entry_id, cx) - .unwrap(); - assert_eq!(project_path.path.as_ref(), rel_path(path),); - declaration - } else { - panic!("Expected a buffer declaration, found {:?}", declaration); - } - } - - fn expect_file_decl<'a>( - path: &str, - declaration: &'a Declaration, - project: &Entity, - cx: &App, - ) -> &'a FileDeclaration { - if let Declaration::File { - declaration, - project_entry_id: file, - .. - } = declaration - { - assert_eq!( - project - .read(cx) - .path_for_entry(*file, cx) - .unwrap() - .path - .as_ref(), - rel_path(path), - ); - declaration - } else { - panic!("Expected a file declaration, found {:?}", declaration); - } - } - - async fn init_test( - cx: &mut TestAppContext, - ) -> (Entity, Entity, LanguageId) { - cx.update(|cx| { - let settings_store = SettingsStore::test(cx); - cx.set_global(settings_store); - }); - - let fs = FakeFs::new(cx.executor()); - fs.insert_tree( - path!("/root"), - json!({ - "a.rs": indoc! {r#" - fn main() { - let x = 1; - let y = 2; - let z = add(x, y); - println!("Result: {}", z); - } - - fn add(a: i32, b: i32) -> i32 { - a + b - } - "#}, - "b.rs": indoc! {" - pub struct Config { - pub name: String, - pub value: i32, - } - - impl Config { - pub fn new(name: String, value: i32) -> Self { - Config { name, value } - } - } - "}, - "c.rs": indoc! {r#" - use std::collections::HashMap; - - fn main() { - let args: Vec = std::env::args().collect(); - let data: Vec = args[1..] - .iter() - .filter_map(|s| s.parse().ok()) - .collect(); - let result = process_data(data); - println!("{:?}", result); - } - - fn process_data(data: Vec) -> HashMap { - let mut counts = HashMap::new(); - for value in data { - *counts.entry(value).or_insert(0) += 1; - } - counts - } - - #[cfg(test)] - mod tests { - use super::*; - - #[test] - fn test_process_data() { - let data = vec![1, 2, 2, 3]; - let result = process_data(data); - assert_eq!(result.get(&2), Some(&2)); - } - } - "#} - }), - ) - .await; - let project = Project::test(fs.clone(), [path!("/root").as_ref()], cx).await; - let language_registry = project.read_with(cx, |project, _| project.languages().clone()); - let lang = rust_lang(); - let lang_id = lang.id(); - language_registry.add(Arc::new(lang)); - - let file_indexing_parallelism = 2; - let index = cx.new(|cx| SyntaxIndex::new(&project, file_indexing_parallelism, cx)); - cx.run_until_parked(); - - (project, index, lang_id) - } - - fn rust_lang() -> Language { - Language::new( - LanguageConfig { - name: "Rust".into(), - matcher: LanguageMatcher { - path_suffixes: vec!["rs".to_string()], - ..Default::default() - }, - ..Default::default() - }, - Some(tree_sitter_rust::LANGUAGE.into()), - ) - .with_outline_query(include_str!("../../languages/src/rust/outline.scm")) - .unwrap() - } -} diff --git a/crates/edit_prediction_context/src/text_similarity.rs b/crates/edit_prediction_context/src/text_similarity.rs deleted file mode 100644 index 308a9570206084fc223c72f2e1c49109ea157714..0000000000000000000000000000000000000000 --- a/crates/edit_prediction_context/src/text_similarity.rs +++ /dev/null @@ -1,314 +0,0 @@ -use hashbrown::HashTable; -use regex::Regex; -use std::{ - borrow::Cow, - hash::{Hash, Hasher as _}, - path::Path, - sync::LazyLock, -}; -use util::rel_path::RelPath; - -use crate::reference::Reference; - -// TODO: Consider implementing sliding window similarity matching like -// https://github.com/sourcegraph/cody-public-snapshot/blob/8e20ac6c1460c08b0db581c0204658112a246eda/vscode/src/completions/context/retrievers/jaccard-similarity/bestJaccardMatch.ts -// -// That implementation could actually be more efficient - no need to track words in the window that -// are not in the query. - -// TODO: Consider a flat sorted Vec<(String, usize)> representation. Intersection can just walk the -// two in parallel. - -static IDENTIFIER_REGEX: LazyLock = LazyLock::new(|| Regex::new(r"\b\w+\b").unwrap()); - -/// Multiset of text occurrences for text similarity that only stores hashes and counts. -#[derive(Debug, Default)] -pub struct Occurrences { - table: HashTable, - total_count: usize, -} - -#[derive(Debug)] -struct OccurrenceEntry { - hash: u64, - count: usize, -} - -impl Occurrences { - pub fn within_string(text: &str) -> Self { - Self::from_identifiers(IDENTIFIER_REGEX.find_iter(text).map(|mat| mat.as_str())) - } - - #[allow(dead_code)] - pub fn within_references(references: &[Reference]) -> Self { - Self::from_identifiers( - references - .iter() - .map(|reference| reference.identifier.name.as_ref()), - ) - } - - pub fn from_identifiers(identifiers: impl IntoIterator>) -> Self { - let mut this = Self::default(); - // TODO: Score matches that match case higher? - // - // TODO: Also include unsplit identifier? - for identifier in identifiers { - for identifier_part in split_identifier(identifier.as_ref()) { - this.add_hash(fx_hash(&identifier_part.to_lowercase())); - } - } - this - } - - pub fn from_worktree_path(worktree_name: Option>, rel_path: &RelPath) -> Self { - if let Some(worktree_name) = worktree_name { - Self::from_identifiers( - std::iter::once(worktree_name) - .chain(iter_path_without_extension(rel_path.as_std_path())), - ) - } else { - Self::from_path(rel_path.as_std_path()) - } - } - - pub fn from_path(path: &Path) -> Self { - Self::from_identifiers(iter_path_without_extension(path)) - } - - fn add_hash(&mut self, hash: u64) { - self.table - .entry( - hash, - |entry: &OccurrenceEntry| entry.hash == hash, - |entry| entry.hash, - ) - .and_modify(|entry| entry.count += 1) - .or_insert(OccurrenceEntry { hash, count: 1 }); - self.total_count += 1; - } - - fn contains_hash(&self, hash: u64) -> bool { - self.get_count(hash) != 0 - } - - fn get_count(&self, hash: u64) -> usize { - self.table - .find(hash, |entry| entry.hash == hash) - .map(|entry| entry.count) - .unwrap_or(0) - } -} - -fn iter_path_without_extension(path: &Path) -> impl Iterator> { - let last_component: Option> = path.file_stem().map(|stem| stem.to_string_lossy()); - let mut path_components = path.components(); - path_components.next_back(); - path_components - .map(|component| component.as_os_str().to_string_lossy()) - .chain(last_component) -} - -pub fn fx_hash(data: &T) -> u64 { - let mut hasher = collections::FxHasher::default(); - data.hash(&mut hasher); - hasher.finish() -} - -// Splits camelcase / snakecase / kebabcase / pascalcase -// -// TODO: Make this more efficient / elegant. -fn split_identifier(identifier: &str) -> Vec<&str> { - let mut parts = Vec::new(); - let mut start = 0; - let chars: Vec = identifier.chars().collect(); - - if chars.is_empty() { - return parts; - } - - let mut i = 0; - while i < chars.len() { - let ch = chars[i]; - - // Handle explicit delimiters (underscore and hyphen) - if ch == '_' || ch == '-' { - if i > start { - parts.push(&identifier[start..i]); - } - start = i + 1; - i += 1; - continue; - } - - // Handle camelCase and PascalCase transitions - if i > 0 && i < chars.len() { - let prev_char = chars[i - 1]; - - // Transition from lowercase/digit to uppercase - if (prev_char.is_lowercase() || prev_char.is_ascii_digit()) && ch.is_uppercase() { - parts.push(&identifier[start..i]); - start = i; - } - // Handle sequences like "XMLParser" -> ["XML", "Parser"] - else if i + 1 < chars.len() - && ch.is_uppercase() - && chars[i + 1].is_lowercase() - && prev_char.is_uppercase() - { - parts.push(&identifier[start..i]); - start = i; - } - } - - i += 1; - } - - // Add the last part if there's any remaining - if start < identifier.len() { - parts.push(&identifier[start..]); - } - - // Filter out empty strings - parts.into_iter().filter(|s| !s.is_empty()).collect() -} - -pub fn jaccard_similarity<'a>(mut set_a: &'a Occurrences, mut set_b: &'a Occurrences) -> f32 { - if set_a.table.len() > set_b.table.len() { - std::mem::swap(&mut set_a, &mut set_b); - } - let intersection = set_a - .table - .iter() - .filter(|entry| set_b.contains_hash(entry.hash)) - .count(); - let union = set_a.table.len() + set_b.table.len() - intersection; - intersection as f32 / union as f32 -} - -// TODO -#[allow(dead_code)] -pub fn overlap_coefficient<'a>(mut set_a: &'a Occurrences, mut set_b: &'a Occurrences) -> f32 { - if set_a.table.len() > set_b.table.len() { - std::mem::swap(&mut set_a, &mut set_b); - } - let intersection = set_a - .table - .iter() - .filter(|entry| set_b.contains_hash(entry.hash)) - .count(); - intersection as f32 / set_a.table.len() as f32 -} - -// TODO -#[allow(dead_code)] -pub fn weighted_jaccard_similarity<'a>( - mut set_a: &'a Occurrences, - mut set_b: &'a Occurrences, -) -> f32 { - if set_a.table.len() > set_b.table.len() { - std::mem::swap(&mut set_a, &mut set_b); - } - - let mut numerator = 0; - let mut denominator_a = 0; - let mut used_count_b = 0; - for entry_a in set_a.table.iter() { - let count_a = entry_a.count; - let count_b = set_b.get_count(entry_a.hash); - numerator += count_a.min(count_b); - denominator_a += count_a.max(count_b); - used_count_b += count_b; - } - - let denominator = denominator_a + (set_b.total_count - used_count_b); - if denominator == 0 { - 0.0 - } else { - numerator as f32 / denominator as f32 - } -} - -pub fn weighted_overlap_coefficient<'a>( - mut set_a: &'a Occurrences, - mut set_b: &'a Occurrences, -) -> f32 { - if set_a.table.len() > set_b.table.len() { - std::mem::swap(&mut set_a, &mut set_b); - } - - let mut numerator = 0; - for entry_a in set_a.table.iter() { - let count_a = entry_a.count; - let count_b = set_b.get_count(entry_a.hash); - numerator += count_a.min(count_b); - } - - let denominator = set_a.total_count.min(set_b.total_count); - if denominator == 0 { - 0.0 - } else { - numerator as f32 / denominator as f32 - } -} - -#[cfg(test)] -mod test { - use super::*; - - #[test] - fn test_split_identifier() { - assert_eq!(split_identifier("snake_case"), vec!["snake", "case"]); - assert_eq!(split_identifier("kebab-case"), vec!["kebab", "case"]); - assert_eq!(split_identifier("PascalCase"), vec!["Pascal", "Case"]); - assert_eq!(split_identifier("camelCase"), vec!["camel", "Case"]); - assert_eq!(split_identifier("XMLParser"), vec!["XML", "Parser"]); - } - - #[test] - fn test_similarity_functions() { - // 10 identifier parts, 8 unique - // Repeats: 2 "outline", 2 "items" - let set_a = Occurrences::within_string( - "let mut outline_items = query_outline_items(&language, &tree, &source);", - ); - // 14 identifier parts, 11 unique - // Repeats: 2 "outline", 2 "language", 2 "tree" - let set_b = Occurrences::within_string( - "pub fn query_outline_items(language: &Language, tree: &Tree, source: &str) -> Vec {", - ); - - // 6 overlaps: "outline", "items", "query", "language", "tree", "source" - // 7 non-overlaps: "let", "mut", "pub", "fn", "vec", "item", "str" - assert_eq!(jaccard_similarity(&set_a, &set_b), 6.0 / (6.0 + 7.0)); - - // Numerator is one more than before due to both having 2 "outline". - // Denominator is the same except for 3 more due to the non-overlapping duplicates - assert_eq!( - weighted_jaccard_similarity(&set_a, &set_b), - 7.0 / (7.0 + 7.0 + 3.0) - ); - - // Numerator is the same as jaccard_similarity. Denominator is the size of the smaller set, 8. - assert_eq!(overlap_coefficient(&set_a, &set_b), 6.0 / 8.0); - - // Numerator is the same as weighted_jaccard_similarity. Denominator is the total weight of - // the smaller set, 10. - assert_eq!(weighted_overlap_coefficient(&set_a, &set_b), 7.0 / 10.0); - } - - #[test] - fn test_iter_path_without_extension() { - let mut iter = iter_path_without_extension(Path::new("")); - assert_eq!(iter.next(), None); - - let iter = iter_path_without_extension(Path::new("foo")); - assert_eq!(iter.collect::>(), ["foo"]); - - let iter = iter_path_without_extension(Path::new("foo/bar.txt")); - assert_eq!(iter.collect::>(), ["foo", "bar"]); - - let iter = iter_path_without_extension(Path::new("foo/bar/baz.txt")); - assert_eq!(iter.collect::>(), ["foo", "bar", "baz"]); - } -} diff --git a/crates/edit_prediction_context2/Cargo.toml b/crates/edit_prediction_context2/Cargo.toml deleted file mode 100644 index 597884b44821e24a930c8730225be4c6bf1c90f6..0000000000000000000000000000000000000000 --- a/crates/edit_prediction_context2/Cargo.toml +++ /dev/null @@ -1,42 +0,0 @@ -[package] -name = "edit_prediction_context2" -version = "0.1.0" -edition.workspace = true -publish.workspace = true -license = "GPL-3.0-or-later" - -[lints] -workspace = true - -[lib] -path = "src/edit_prediction_context2.rs" - -[dependencies] -parking_lot.workspace = true -anyhow.workspace = true -collections.workspace = true -futures.workspace = true -gpui.workspace = true -language.workspace = true -lsp.workspace = true -project.workspace = true -log.workspace = true -serde.workspace = true -smallvec.workspace = true -tree-sitter.workspace = true -util.workspace = true - -[dev-dependencies] -env_logger.workspace = true -indoc.workspace = true -futures.workspace = true -gpui = { workspace = true, features = ["test-support"] } -language = { workspace = true, features = ["test-support"] } -lsp = { workspace = true, features = ["test-support"] } -pretty_assertions.workspace = true -project = {workspace= true, features = ["test-support"]} -serde_json.workspace = true -settings = {workspace= true, features = ["test-support"]} -text = { workspace = true, features = ["test-support"] } -util = { workspace = true, features = ["test-support"] } -zlog.workspace = true diff --git a/crates/edit_prediction_context2/src/edit_prediction_context2.rs b/crates/edit_prediction_context2/src/edit_prediction_context2.rs deleted file mode 100644 index f8790478547ddb8b7b873015846f2af6c1bcbc2c..0000000000000000000000000000000000000000 --- a/crates/edit_prediction_context2/src/edit_prediction_context2.rs +++ /dev/null @@ -1,465 +0,0 @@ -use crate::assemble_excerpts::assemble_excerpts; -use anyhow::Result; -use collections::HashMap; -use futures::{FutureExt, StreamExt as _, channel::mpsc, future}; -use gpui::{App, AppContext, AsyncApp, Context, Entity, EventEmitter, Task, WeakEntity}; -use language::{Anchor, Buffer, BufferSnapshot, OffsetRangeExt as _, Point, Rope, ToOffset as _}; -use project::{LocationLink, Project, ProjectPath}; -use serde::{Serialize, Serializer}; -use smallvec::SmallVec; -use std::{ - collections::hash_map, - ops::Range, - sync::Arc, - time::{Duration, Instant}, -}; -use util::{RangeExt as _, ResultExt}; - -mod assemble_excerpts; -#[cfg(test)] -mod edit_prediction_context_tests; -#[cfg(test)] -mod fake_definition_lsp; - -pub struct RelatedExcerptStore { - project: WeakEntity, - related_files: Vec, - cache: HashMap>, - update_tx: mpsc::UnboundedSender<(Entity, Anchor)>, -} - -pub enum RelatedExcerptStoreEvent { - StartedRefresh, - FinishedRefresh { - cache_hit_count: usize, - cache_miss_count: usize, - mean_definition_latency: Duration, - max_definition_latency: Duration, - }, -} - -#[derive(Clone, Debug, PartialEq, Eq, Hash)] -struct Identifier { - pub name: String, - pub range: Range, -} - -enum DefinitionTask { - CacheHit(Arc), - CacheMiss(Task>>>), -} - -#[derive(Debug)] -struct CacheEntry { - definitions: SmallVec<[CachedDefinition; 1]>, -} - -#[derive(Clone, Debug)] -struct CachedDefinition { - path: ProjectPath, - buffer: Entity, - anchor_range: Range, -} - -#[derive(Clone, Debug, Serialize)] -pub struct RelatedFile { - #[serde(serialize_with = "serialize_project_path")] - pub path: ProjectPath, - #[serde(skip)] - pub buffer: WeakEntity, - pub excerpts: Vec, - pub max_row: u32, -} - -impl RelatedFile { - pub fn merge_excerpts(&mut self) { - self.excerpts.sort_unstable_by(|a, b| { - a.point_range - .start - .cmp(&b.point_range.start) - .then(b.point_range.end.cmp(&a.point_range.end)) - }); - - let mut index = 1; - while index < self.excerpts.len() { - if self.excerpts[index - 1] - .point_range - .end - .cmp(&self.excerpts[index].point_range.start) - .is_ge() - { - let removed = self.excerpts.remove(index); - if removed - .point_range - .end - .cmp(&self.excerpts[index - 1].point_range.end) - .is_gt() - { - self.excerpts[index - 1].point_range.end = removed.point_range.end; - self.excerpts[index - 1].anchor_range.end = removed.anchor_range.end; - } - } else { - index += 1; - } - } - } -} - -#[derive(Clone, Debug, Serialize)] -pub struct RelatedExcerpt { - #[serde(skip)] - pub anchor_range: Range, - #[serde(serialize_with = "serialize_point_range")] - pub point_range: Range, - #[serde(serialize_with = "serialize_rope")] - pub text: Rope, -} - -fn serialize_project_path( - project_path: &ProjectPath, - serializer: S, -) -> Result { - project_path.path.serialize(serializer) -} - -fn serialize_rope(rope: &Rope, serializer: S) -> Result { - rope.to_string().serialize(serializer) -} - -fn serialize_point_range( - range: &Range, - serializer: S, -) -> Result { - [ - [range.start.row, range.start.column], - [range.end.row, range.end.column], - ] - .serialize(serializer) -} - -const DEBOUNCE_DURATION: Duration = Duration::from_millis(100); - -impl EventEmitter for RelatedExcerptStore {} - -impl RelatedExcerptStore { - pub fn new(project: &Entity, cx: &mut Context) -> Self { - let (update_tx, mut update_rx) = mpsc::unbounded::<(Entity, Anchor)>(); - cx.spawn(async move |this, cx| { - let executor = cx.background_executor().clone(); - while let Some((mut buffer, mut position)) = update_rx.next().await { - let mut timer = executor.timer(DEBOUNCE_DURATION).fuse(); - loop { - futures::select_biased! { - next = update_rx.next() => { - if let Some((new_buffer, new_position)) = next { - buffer = new_buffer; - position = new_position; - timer = executor.timer(DEBOUNCE_DURATION).fuse(); - } else { - return anyhow::Ok(()); - } - } - _ = timer => break, - } - } - - Self::fetch_excerpts(this.clone(), buffer, position, cx).await?; - } - anyhow::Ok(()) - }) - .detach_and_log_err(cx); - - RelatedExcerptStore { - project: project.downgrade(), - update_tx, - related_files: Vec::new(), - cache: Default::default(), - } - } - - pub fn refresh(&mut self, buffer: Entity, position: Anchor, _: &mut Context) { - self.update_tx.unbounded_send((buffer, position)).ok(); - } - - pub fn related_files(&self) -> &[RelatedFile] { - &self.related_files - } - - async fn fetch_excerpts( - this: WeakEntity, - buffer: Entity, - position: Anchor, - cx: &mut AsyncApp, - ) -> Result<()> { - let (project, snapshot) = this.read_with(cx, |this, cx| { - (this.project.upgrade(), buffer.read(cx).snapshot()) - })?; - let Some(project) = project else { - return Ok(()); - }; - - let file = snapshot.file().cloned(); - if let Some(file) = &file { - log::debug!("retrieving_context buffer:{}", file.path().as_unix_str()); - } - - this.update(cx, |_, cx| { - cx.emit(RelatedExcerptStoreEvent::StartedRefresh); - })?; - - let identifiers = cx - .background_spawn(async move { identifiers_for_position(&snapshot, position) }) - .await; - - let async_cx = cx.clone(); - let start_time = Instant::now(); - let futures = this.update(cx, |this, cx| { - identifiers - .into_iter() - .filter_map(|identifier| { - let task = if let Some(entry) = this.cache.get(&identifier) { - DefinitionTask::CacheHit(entry.clone()) - } else { - DefinitionTask::CacheMiss( - this.project - .update(cx, |project, cx| { - project.definitions(&buffer, identifier.range.start, cx) - }) - .ok()?, - ) - }; - - let cx = async_cx.clone(); - let project = project.clone(); - Some(async move { - match task { - DefinitionTask::CacheHit(cache_entry) => { - Some((identifier, cache_entry, None)) - } - DefinitionTask::CacheMiss(task) => { - let locations = task.await.log_err()??; - let duration = start_time.elapsed(); - cx.update(|cx| { - ( - identifier, - Arc::new(CacheEntry { - definitions: locations - .into_iter() - .filter_map(|location| { - process_definition(location, &project, cx) - }) - .collect(), - }), - Some(duration), - ) - }) - .ok() - } - } - }) - }) - .collect::>() - })?; - - let mut cache_hit_count = 0; - let mut cache_miss_count = 0; - let mut mean_definition_latency = Duration::ZERO; - let mut max_definition_latency = Duration::ZERO; - let mut new_cache = HashMap::default(); - new_cache.reserve(futures.len()); - for (identifier, entry, duration) in future::join_all(futures).await.into_iter().flatten() { - new_cache.insert(identifier, entry); - if let Some(duration) = duration { - cache_miss_count += 1; - mean_definition_latency += duration; - max_definition_latency = max_definition_latency.max(duration); - } else { - cache_hit_count += 1; - } - } - mean_definition_latency /= cache_miss_count.max(1) as u32; - - let (new_cache, related_files) = rebuild_related_files(new_cache, cx).await?; - - if let Some(file) = &file { - log::debug!( - "finished retrieving context buffer:{}, latency:{:?}", - file.path().as_unix_str(), - start_time.elapsed() - ); - } - - this.update(cx, |this, cx| { - this.cache = new_cache; - this.related_files = related_files; - cx.emit(RelatedExcerptStoreEvent::FinishedRefresh { - cache_hit_count, - cache_miss_count, - mean_definition_latency, - max_definition_latency, - }); - })?; - - anyhow::Ok(()) - } -} - -async fn rebuild_related_files( - new_entries: HashMap>, - cx: &mut AsyncApp, -) -> Result<(HashMap>, Vec)> { - let mut snapshots = HashMap::default(); - for entry in new_entries.values() { - for definition in &entry.definitions { - if let hash_map::Entry::Vacant(e) = snapshots.entry(definition.buffer.entity_id()) { - definition - .buffer - .read_with(cx, |buffer, _| buffer.parsing_idle())? - .await; - e.insert( - definition - .buffer - .read_with(cx, |buffer, _| buffer.snapshot())?, - ); - } - } - } - - Ok(cx - .background_spawn(async move { - let mut files = Vec::::new(); - let mut ranges_by_buffer = HashMap::<_, Vec>>::default(); - let mut paths_by_buffer = HashMap::default(); - for entry in new_entries.values() { - for definition in &entry.definitions { - let Some(snapshot) = snapshots.get(&definition.buffer.entity_id()) else { - continue; - }; - paths_by_buffer.insert(definition.buffer.entity_id(), definition.path.clone()); - ranges_by_buffer - .entry(definition.buffer.clone()) - .or_default() - .push(definition.anchor_range.to_point(snapshot)); - } - } - - for (buffer, ranges) in ranges_by_buffer { - let Some(snapshot) = snapshots.get(&buffer.entity_id()) else { - continue; - }; - let Some(project_path) = paths_by_buffer.get(&buffer.entity_id()) else { - continue; - }; - let excerpts = assemble_excerpts(snapshot, ranges); - files.push(RelatedFile { - path: project_path.clone(), - buffer: buffer.downgrade(), - excerpts, - max_row: snapshot.max_point().row, - }); - } - - files.sort_by_key(|file| file.path.clone()); - (new_entries, files) - }) - .await) -} - -fn process_definition( - location: LocationLink, - project: &Entity, - cx: &mut App, -) -> Option { - let buffer = location.target.buffer.read(cx); - let anchor_range = location.target.range; - let file = buffer.file()?; - let worktree = project.read(cx).worktree_for_id(file.worktree_id(cx), cx)?; - if worktree.read(cx).is_single_file() { - return None; - } - Some(CachedDefinition { - path: ProjectPath { - worktree_id: file.worktree_id(cx), - path: file.path().clone(), - }, - buffer: location.target.buffer, - anchor_range, - }) -} - -/// Gets all of the identifiers that are present in the given line, and its containing -/// outline items. -fn identifiers_for_position(buffer: &BufferSnapshot, position: Anchor) -> Vec { - let offset = position.to_offset(buffer); - let point = buffer.offset_to_point(offset); - - let line_range = Point::new(point.row, 0)..Point::new(point.row + 1, 0).min(buffer.max_point()); - let mut ranges = vec![line_range.to_offset(&buffer)]; - - // Include the range of the outline item itself, but not its body. - let outline_items = buffer.outline_items_as_offsets_containing(offset..offset, false, None); - for item in outline_items { - if let Some(body_range) = item.body_range(&buffer) { - ranges.push(item.range.start..body_range.start.to_offset(&buffer)); - } else { - ranges.push(item.range.clone()); - } - } - - ranges.sort_by(|a, b| a.start.cmp(&b.start).then(b.end.cmp(&a.end))); - ranges.dedup_by(|a, b| { - if a.start <= b.end { - b.start = b.start.min(a.start); - b.end = b.end.max(a.end); - true - } else { - false - } - }); - - let mut identifiers = Vec::new(); - let outer_range = - ranges.first().map_or(0, |r| r.start)..ranges.last().map_or(buffer.len(), |r| r.end); - - let mut captures = buffer - .syntax - .captures(outer_range.clone(), &buffer.text, |grammar| { - grammar - .highlights_config - .as_ref() - .map(|config| &config.query) - }); - - for range in ranges { - captures.set_byte_range(range.start..outer_range.end); - - let mut last_range = None; - while let Some(capture) = captures.peek() { - let node_range = capture.node.byte_range(); - if node_range.start > range.end { - break; - } - let config = captures.grammars()[capture.grammar_index] - .highlights_config - .as_ref(); - - if let Some(config) = config - && config.identifier_capture_indices.contains(&capture.index) - && range.contains_inclusive(&node_range) - && Some(&node_range) != last_range.as_ref() - { - let name = buffer.text_for_range(node_range.clone()).collect(); - identifiers.push(Identifier { - range: buffer.anchor_after(node_range.start) - ..buffer.anchor_before(node_range.end), - name, - }); - last_range = Some(node_range); - } - - captures.advance(); - } - } - - identifiers -} diff --git a/crates/edit_prediction_types/Cargo.toml b/crates/edit_prediction_types/Cargo.toml new file mode 100644 index 0000000000000000000000000000000000000000..ebc09680e1dcf99dc21e1714eca6a9db337f4a90 --- /dev/null +++ b/crates/edit_prediction_types/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "edit_prediction_types" +version = "0.1.0" +edition.workspace = true +publish.workspace = true +license = "GPL-3.0-or-later" + +[lints] +workspace = true + +[lib] +path = "src/edit_prediction_types.rs" + +[dependencies] +client.workspace = true +gpui.workspace = true +language.workspace = true diff --git a/crates/edit_prediction_context2/LICENSE-GPL b/crates/edit_prediction_types/LICENSE-GPL similarity index 100% rename from crates/edit_prediction_context2/LICENSE-GPL rename to crates/edit_prediction_types/LICENSE-GPL diff --git a/crates/edit_prediction_types/src/edit_prediction_types.rs b/crates/edit_prediction_types/src/edit_prediction_types.rs new file mode 100644 index 0000000000000000000000000000000000000000..1f63b8626d15dfd3e2cba78aacb50505186da01c --- /dev/null +++ b/crates/edit_prediction_types/src/edit_prediction_types.rs @@ -0,0 +1,298 @@ +use std::{ops::Range, sync::Arc}; + +use client::EditPredictionUsage; +use gpui::{App, Context, Entity, SharedString}; +use language::{Anchor, Buffer, BufferSnapshot, OffsetRangeExt}; + +// TODO: Find a better home for `Direction`. +// +// This should live in an ancestor crate of `editor` and `edit_prediction`, +// but at time of writing there isn't an obvious spot. +#[derive(Copy, Clone, PartialEq, Eq)] +pub enum Direction { + Prev, + Next, +} + +#[derive(Clone)] +pub enum EditPrediction { + /// Edits within the buffer that requested the prediction + Local { + id: Option, + edits: Vec<(Range, Arc)>, + edit_preview: Option, + }, + /// Jump to a different file from the one that requested the prediction + Jump { + id: Option, + snapshot: language::BufferSnapshot, + target: language::Anchor, + }, +} + +pub enum DataCollectionState { + /// The provider doesn't support data collection. + Unsupported, + /// Data collection is enabled. + Enabled { is_project_open_source: bool }, + /// Data collection is disabled or unanswered. + Disabled { is_project_open_source: bool }, +} + +impl DataCollectionState { + pub fn is_supported(&self) -> bool { + !matches!(self, DataCollectionState::Unsupported) + } + + pub fn is_enabled(&self) -> bool { + matches!(self, DataCollectionState::Enabled { .. }) + } + + pub fn is_project_open_source(&self) -> bool { + match self { + Self::Enabled { + is_project_open_source, + } + | Self::Disabled { + is_project_open_source, + } => *is_project_open_source, + _ => false, + } + } +} + +pub trait EditPredictionDelegate: 'static + Sized { + fn name() -> &'static str; + fn display_name() -> &'static str; + fn show_predictions_in_menu() -> bool; + fn show_tab_accept_marker() -> bool { + false + } + fn supports_jump_to_edit() -> bool { + true + } + + fn data_collection_state(&self, _cx: &App) -> DataCollectionState { + DataCollectionState::Unsupported + } + + fn usage(&self, _cx: &App) -> Option { + None + } + + fn toggle_data_collection(&mut self, _cx: &mut App) {} + fn is_enabled( + &self, + buffer: &Entity, + cursor_position: language::Anchor, + cx: &App, + ) -> bool; + fn is_refreshing(&self, cx: &App) -> bool; + fn refresh( + &mut self, + buffer: Entity, + cursor_position: language::Anchor, + debounce: bool, + cx: &mut Context, + ); + fn cycle( + &mut self, + buffer: Entity, + cursor_position: language::Anchor, + direction: Direction, + cx: &mut Context, + ); + fn accept(&mut self, cx: &mut Context); + fn discard(&mut self, cx: &mut Context); + fn did_show(&mut self, _cx: &mut Context) {} + fn suggest( + &mut self, + buffer: &Entity, + cursor_position: language::Anchor, + cx: &mut Context, + ) -> Option; +} + +pub trait EditPredictionDelegateHandle { + fn name(&self) -> &'static str; + fn display_name(&self) -> &'static str; + fn is_enabled( + &self, + buffer: &Entity, + cursor_position: language::Anchor, + cx: &App, + ) -> bool; + fn show_predictions_in_menu(&self) -> bool; + fn show_tab_accept_marker(&self) -> bool; + fn supports_jump_to_edit(&self) -> bool; + fn data_collection_state(&self, cx: &App) -> DataCollectionState; + fn usage(&self, cx: &App) -> Option; + fn toggle_data_collection(&self, cx: &mut App); + fn is_refreshing(&self, cx: &App) -> bool; + fn refresh( + &self, + buffer: Entity, + cursor_position: language::Anchor, + debounce: bool, + cx: &mut App, + ); + fn cycle( + &self, + buffer: Entity, + cursor_position: language::Anchor, + direction: Direction, + cx: &mut App, + ); + fn did_show(&self, cx: &mut App); + fn accept(&self, cx: &mut App); + fn discard(&self, cx: &mut App); + fn suggest( + &self, + buffer: &Entity, + cursor_position: language::Anchor, + cx: &mut App, + ) -> Option; +} + +impl EditPredictionDelegateHandle for Entity +where + T: EditPredictionDelegate, +{ + fn name(&self) -> &'static str { + T::name() + } + + fn display_name(&self) -> &'static str { + T::display_name() + } + + fn show_predictions_in_menu(&self) -> bool { + T::show_predictions_in_menu() + } + + fn show_tab_accept_marker(&self) -> bool { + T::show_tab_accept_marker() + } + + fn supports_jump_to_edit(&self) -> bool { + T::supports_jump_to_edit() + } + + fn data_collection_state(&self, cx: &App) -> DataCollectionState { + self.read(cx).data_collection_state(cx) + } + + fn usage(&self, cx: &App) -> Option { + self.read(cx).usage(cx) + } + + fn toggle_data_collection(&self, cx: &mut App) { + self.update(cx, |this, cx| this.toggle_data_collection(cx)) + } + + fn is_enabled( + &self, + buffer: &Entity, + cursor_position: language::Anchor, + cx: &App, + ) -> bool { + self.read(cx).is_enabled(buffer, cursor_position, cx) + } + + fn is_refreshing(&self, cx: &App) -> bool { + self.read(cx).is_refreshing(cx) + } + + fn refresh( + &self, + buffer: Entity, + cursor_position: language::Anchor, + debounce: bool, + cx: &mut App, + ) { + self.update(cx, |this, cx| { + this.refresh(buffer, cursor_position, debounce, cx) + }) + } + + fn cycle( + &self, + buffer: Entity, + cursor_position: language::Anchor, + direction: Direction, + cx: &mut App, + ) { + self.update(cx, |this, cx| { + this.cycle(buffer, cursor_position, direction, cx) + }) + } + + fn accept(&self, cx: &mut App) { + self.update(cx, |this, cx| this.accept(cx)) + } + + fn discard(&self, cx: &mut App) { + self.update(cx, |this, cx| this.discard(cx)) + } + + fn did_show(&self, cx: &mut App) { + self.update(cx, |this, cx| this.did_show(cx)) + } + + fn suggest( + &self, + buffer: &Entity, + cursor_position: language::Anchor, + cx: &mut App, + ) -> Option { + self.update(cx, |this, cx| this.suggest(buffer, cursor_position, cx)) + } +} + +/// Returns edits updated based on user edits since the old snapshot. None is returned if any user +/// edit is not a prefix of a predicted insertion. +pub fn interpolate_edits( + old_snapshot: &BufferSnapshot, + new_snapshot: &BufferSnapshot, + current_edits: &[(Range, Arc)], +) -> Option, Arc)>> { + let mut edits = Vec::new(); + + let mut model_edits = current_edits.iter().peekable(); + for user_edit in new_snapshot.edits_since::(&old_snapshot.version) { + while let Some((model_old_range, _)) = model_edits.peek() { + let model_old_range = model_old_range.to_offset(old_snapshot); + if model_old_range.end < user_edit.old.start { + let (model_old_range, model_new_text) = model_edits.next().unwrap(); + edits.push((model_old_range.clone(), model_new_text.clone())); + } else { + break; + } + } + + if let Some((model_old_range, model_new_text)) = model_edits.peek() { + let model_old_offset_range = model_old_range.to_offset(old_snapshot); + if user_edit.old == model_old_offset_range { + let user_new_text = new_snapshot + .text_for_range(user_edit.new.clone()) + .collect::(); + + if let Some(model_suffix) = model_new_text.strip_prefix(&user_new_text) { + if !model_suffix.is_empty() { + let anchor = old_snapshot.anchor_after(user_edit.old.end); + edits.push((anchor..anchor, model_suffix.into())); + } + + model_edits.next(); + continue; + } + } + } + + return None; + } + + edits.extend(model_edits.cloned()); + + if edits.is_empty() { None } else { Some(edits) } +} diff --git a/crates/edit_prediction_button/Cargo.toml b/crates/edit_prediction_ui/Cargo.toml similarity index 77% rename from crates/edit_prediction_button/Cargo.toml rename to crates/edit_prediction_ui/Cargo.toml index d336cf66926d37ab7c0ebb1d5aa5a2172342350c..fb846f35d76ae2f6478ef675f246e4d06fe5f469 100644 --- a/crates/edit_prediction_button/Cargo.toml +++ b/crates/edit_prediction_ui/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "edit_prediction_button" +name = "edit_prediction_ui" version = "0.1.0" edition.workspace = true publish.workspace = true @@ -9,35 +9,43 @@ license = "GPL-3.0-or-later" workspace = true [lib] -path = "src/edit_prediction_button.rs" +path = "src/edit_prediction_ui.rs" doctest = false [dependencies] anyhow.workspace = true +buffer_diff.workspace = true client.workspace = true cloud_llm_client.workspace = true +cloud_zeta2_prompt.workspace = true codestral.workspace = true +command_palette_hooks.workspace = true copilot.workspace = true edit_prediction.workspace = true +edit_prediction_types.workspace = true editor.workspace = true feature_flags.workspace = true fs.workspace = true +futures.workspace = true gpui.workspace = true indoc.workspace = true language.workspace = true +markdown.workspace = true +menu.workspace = true +multi_buffer.workspace = true paths.workspace = true project.workspace = true regex.workspace = true settings.workspace = true supermaven.workspace = true telemetry.workspace = true +text.workspace = true +theme.workspace = true ui.workspace = true ui_input.workspace = true -menu.workspace = true util.workspace = true workspace.workspace = true zed_actions.workspace = true -zeta.workspace = true [dev-dependencies] copilot = { workspace = true, features = ["test-support"] } diff --git a/crates/zeta/LICENSE-GPL b/crates/edit_prediction_ui/LICENSE-GPL similarity index 100% rename from crates/zeta/LICENSE-GPL rename to crates/edit_prediction_ui/LICENSE-GPL diff --git a/crates/edit_prediction_button/src/edit_prediction_button.rs b/crates/edit_prediction_ui/src/edit_prediction_button.rs similarity index 97% rename from crates/edit_prediction_button/src/edit_prediction_button.rs rename to crates/edit_prediction_ui/src/edit_prediction_button.rs index 8b234497376aefdc972681c877a1122f3f9cee17..dd3ebab42029f5adb7570b71ae0cd662aff3328e 100644 --- a/crates/edit_prediction_button/src/edit_prediction_button.rs +++ b/crates/edit_prediction_ui/src/edit_prediction_button.rs @@ -1,16 +1,14 @@ -mod sweep_api_token_modal; - -pub use sweep_api_token_modal::SweepApiKeyModal; - use anyhow::Result; use client::{Client, UserStore, zed_urls}; use cloud_llm_client::UsageLimit; -use codestral::CodestralCompletionProvider; +use codestral::CodestralEditPredictionDelegate; use copilot::{Copilot, Status}; +use edit_prediction::{SweepFeatureFlag, Zeta2FeatureFlag}; +use edit_prediction_types::EditPredictionDelegateHandle; use editor::{ Editor, MultiBufferOffset, SelectionEffects, actions::ShowEditPrediction, scroll::Autoscroll, }; -use feature_flags::{FeatureFlagAppExt, PredictEditsRateCompletionsFeatureFlag}; +use feature_flags::FeatureFlagAppExt; use fs::Fs; use gpui::{ Action, Animation, AnimationExt, App, AsyncWindowContext, Corner, Entity, FocusHandle, @@ -44,7 +42,11 @@ use workspace::{ notifications::NotificationId, }; use zed_actions::OpenBrowser; -use zeta::{RateCompletions, SweepFeatureFlag, Zeta2FeatureFlag}; + +use crate::{ + RatePredictions, SweepApiKeyModal, + rate_prediction_modal::PredictEditsRatePredictionsFeatureFlag, +}; actions!( edit_prediction, @@ -67,7 +69,7 @@ pub struct EditPredictionButton { editor_focus_handle: Option, language: Option>, file: Option>, - edit_prediction_provider: Option>, + edit_prediction_provider: Option>, fs: Arc, user_store: Entity, popover_menu_handle: PopoverMenuHandle, @@ -244,7 +246,7 @@ impl Render for EditPredictionButton { EditPredictionProvider::Codestral => { let enabled = self.editor_enabled.unwrap_or(true); - let has_api_key = CodestralCompletionProvider::has_api_key(cx); + let has_api_key = CodestralEditPredictionDelegate::has_api_key(cx); let fs = self.fs.clone(); let this = cx.weak_entity(); @@ -317,16 +319,16 @@ impl Render for EditPredictionButton { ); let sweep_missing_token = is_sweep - && !zeta::Zeta::try_global(cx) - .map_or(false, |zeta| zeta.read(cx).has_sweep_api_token()); + && !edit_prediction::EditPredictionStore::try_global(cx) + .map_or(false, |ep_store| ep_store.read(cx).has_sweep_api_token()); - let zeta_icon = match (is_sweep, enabled) { + let ep_icon = match (is_sweep, enabled) { (true, _) => IconName::SweepAi, (false, true) => IconName::ZedPredict, (false, false) => IconName::ZedPredictDisabled, }; - if zeta::should_show_upsell_modal() { + if edit_prediction::should_show_upsell_modal() { let tooltip_meta = if self.user_store.read(cx).current_user().is_some() { "Choose a Plan" } else { @@ -334,7 +336,7 @@ impl Render for EditPredictionButton { }; return div().child( - IconButton::new("zed-predict-pending-button", zeta_icon) + IconButton::new("zed-predict-pending-button", ep_icon) .shape(IconButtonShape::Square) .indicator(Indicator::dot().color(Color::Muted)) .indicator_border_color(Some(cx.theme().colors().status_bar_background)) @@ -379,7 +381,7 @@ impl Render for EditPredictionButton { None }; - let icon_button = IconButton::new("zed-predict-pending-button", zeta_icon) + let icon_button = IconButton::new("zed-predict-pending-button", ep_icon) .shape(IconButtonShape::Square) .when_some(indicator_color, |this, color| { this.indicator(Indicator::dot().color(color)) @@ -419,13 +421,13 @@ impl Render for EditPredictionButton { let this = cx.weak_entity(); - let mut popover_menu = PopoverMenu::new("zeta") + let mut popover_menu = PopoverMenu::new("edit-prediction") .when(user.is_some(), |popover_menu| { let this = this.clone(); popover_menu.menu(move |window, cx| { this.update(cx, |this, cx| { - this.build_zeta_context_menu(provider, window, cx) + this.build_edit_prediction_context_menu(provider, window, cx) }) .ok() }) @@ -485,7 +487,7 @@ impl EditPredictionButton { cx.observe_global::(move |_, cx| cx.notify()) .detach(); - CodestralCompletionProvider::ensure_api_key_loaded(client.http_client(), cx); + CodestralEditPredictionDelegate::ensure_api_key_loaded(client.http_client(), cx); Self { editor_subscription: None, @@ -520,7 +522,7 @@ impl EditPredictionButton { } } - if CodestralCompletionProvider::has_api_key(cx) { + if CodestralEditPredictionDelegate::has_api_key(cx) { providers.push(EditPredictionProvider::Codestral); } @@ -599,8 +601,8 @@ impl EditPredictionButton { EditPredictionProvider::Experimental( EXPERIMENTAL_SWEEP_EDIT_PREDICTION_PROVIDER_NAME, ) => { - let has_api_token = zeta::Zeta::try_global(cx) - .map_or(false, |zeta| zeta.read(cx).has_sweep_api_token()); + let has_api_token = edit_prediction::EditPredictionStore::try_global(cx) + .map_or(false, |ep_store| ep_store.read(cx).has_sweep_api_token()); let should_open_modal = !has_api_token || is_current; @@ -947,8 +949,8 @@ impl EditPredictionButton { ) .context(editor_focus_handle) .when( - cx.has_flag::(), - |this| this.action("Rate Completions", RateCompletions.boxed_clone()), + cx.has_flag::(), + |this| this.action("Rate Predictions", RatePredictions.boxed_clone()), ); } @@ -1016,7 +1018,7 @@ impl EditPredictionButton { }) } - fn build_zeta_context_menu( + fn build_edit_prediction_context_menu( &self, provider: EditPredictionProvider, window: &mut Window, diff --git a/crates/zeta2_tools/src/zeta2_context_view.rs b/crates/edit_prediction_ui/src/edit_prediction_context_view.rs similarity index 85% rename from crates/zeta2_tools/src/zeta2_context_view.rs rename to crates/edit_prediction_ui/src/edit_prediction_context_view.rs index 882846929a62f90f349d40f8f6b6996f83613ec7..0e343fe3fcb8ed7bb6bf3e8481927344d63133ee 100644 --- a/crates/zeta2_tools/src/zeta2_context_view.rs +++ b/crates/edit_prediction_ui/src/edit_prediction_context_view.rs @@ -23,16 +23,16 @@ use ui::{ StyledTypography as _, h_flex, v_flex, }; -use workspace::Item; -use zeta::{ - Zeta, ZetaContextRetrievalFinishedDebugInfo, ZetaContextRetrievalStartedDebugInfo, - ZetaDebugInfo, +use edit_prediction::{ + ContextRetrievalFinishedDebugEvent, ContextRetrievalStartedDebugEvent, DebugEvent, + EditPredictionStore, }; +use workspace::Item; -pub struct Zeta2ContextView { +pub struct EditPredictionContextView { empty_focus_handle: FocusHandle, project: Entity, - zeta: Entity, + store: Entity, runs: VecDeque, current_ix: usize, _update_task: Task>, @@ -50,13 +50,13 @@ actions!( dev, [ /// Go to the previous context retrieval run - Zeta2ContextGoBack, + EditPredictionContextGoBack, /// Go to the next context retrieval run - Zeta2ContextGoForward + EditPredictionContextGoForward ] ); -impl Zeta2ContextView { +impl EditPredictionContextView { pub fn new( project: Entity, client: &Arc, @@ -64,13 +64,13 @@ impl Zeta2ContextView { window: &mut gpui::Window, cx: &mut Context, ) -> Self { - let zeta = Zeta::global(client, user_store, cx); + let store = EditPredictionStore::global(client, user_store, cx); - let mut debug_rx = zeta.update(cx, |zeta, _| zeta.debug_info()); + let mut debug_rx = store.update(cx, |store, _| store.debug_info()); let _update_task = cx.spawn_in(window, async move |this, cx| { while let Some(event) = debug_rx.next().await { this.update_in(cx, |this, window, cx| { - this.handle_zeta_event(event, window, cx) + this.handle_store_event(event, window, cx) })?; } Ok(()) @@ -81,35 +81,35 @@ impl Zeta2ContextView { project, runs: VecDeque::new(), current_ix: 0, - zeta, + store, _update_task, } } - fn handle_zeta_event( + fn handle_store_event( &mut self, - event: ZetaDebugInfo, + event: DebugEvent, window: &mut gpui::Window, cx: &mut Context, ) { match event { - ZetaDebugInfo::ContextRetrievalStarted(info) => { + DebugEvent::ContextRetrievalStarted(info) => { if info.project_entity_id == self.project.entity_id() { self.handle_context_retrieval_started(info, window, cx); } } - ZetaDebugInfo::ContextRetrievalFinished(info) => { + DebugEvent::ContextRetrievalFinished(info) => { if info.project_entity_id == self.project.entity_id() { self.handle_context_retrieval_finished(info, window, cx); } } - ZetaDebugInfo::EditPredictionRequested(_) => {} + DebugEvent::EditPredictionRequested(_) => {} } } fn handle_context_retrieval_started( &mut self, - info: ZetaContextRetrievalStartedDebugInfo, + info: ContextRetrievalStartedDebugEvent, window: &mut Window, cx: &mut Context, ) { @@ -141,7 +141,7 @@ impl Zeta2ContextView { fn handle_context_retrieval_finished( &mut self, - info: ZetaContextRetrievalFinishedDebugInfo, + info: ContextRetrievalFinishedDebugEvent, window: &mut Window, cx: &mut Context, ) { @@ -154,7 +154,7 @@ impl Zeta2ContextView { let project = self.project.clone(); let related_files = self - .zeta + .store .read(cx) .context_for_project(&self.project, cx) .to_vec(); @@ -220,7 +220,7 @@ impl Zeta2ContextView { fn handle_go_back( &mut self, - _: &Zeta2ContextGoBack, + _: &EditPredictionContextGoBack, window: &mut Window, cx: &mut Context, ) { @@ -231,7 +231,7 @@ impl Zeta2ContextView { fn handle_go_forward( &mut self, - _: &Zeta2ContextGoForward, + _: &EditPredictionContextGoForward, window: &mut Window, cx: &mut Context, ) { @@ -243,7 +243,10 @@ impl Zeta2ContextView { cx.notify(); } - fn render_informational_footer(&self, cx: &mut Context<'_, Zeta2ContextView>) -> ui::Div { + fn render_informational_footer( + &self, + cx: &mut Context<'_, EditPredictionContextView>, + ) -> ui::Div { let run = &self.runs[self.current_ix]; let new_run_started = self .runs @@ -279,10 +282,10 @@ impl Zeta2ContextView { .disabled(self.current_ix == 0 || self.runs.len() < 2) .tooltip(ui::Tooltip::for_action_title( "Go to previous run", - &Zeta2ContextGoBack, + &EditPredictionContextGoBack, )) .on_click(cx.listener(|this, _, window, cx| { - this.handle_go_back(&Zeta2ContextGoBack, window, cx); + this.handle_go_back(&EditPredictionContextGoBack, window, cx); })), ) .child( @@ -308,10 +311,14 @@ impl Zeta2ContextView { .disabled(self.current_ix + 1 == self.runs.len()) .tooltip(ui::Tooltip::for_action_title( "Go to next run", - &Zeta2ContextGoBack, + &EditPredictionContextGoBack, )) .on_click(cx.listener(|this, _, window, cx| { - this.handle_go_forward(&Zeta2ContextGoForward, window, cx); + this.handle_go_forward( + &EditPredictionContextGoForward, + window, + cx, + ); })), ), ), @@ -319,7 +326,7 @@ impl Zeta2ContextView { } } -impl Focusable for Zeta2ContextView { +impl Focusable for EditPredictionContextView { fn focus_handle(&self, cx: &App) -> FocusHandle { self.runs .get(self.current_ix) @@ -328,9 +335,9 @@ impl Focusable for Zeta2ContextView { } } -impl EventEmitter<()> for Zeta2ContextView {} +impl EventEmitter<()> for EditPredictionContextView {} -impl Item for Zeta2ContextView { +impl Item for EditPredictionContextView { type Event = (); fn tab_content_text(&self, _detail: usize, _cx: &App) -> SharedString { @@ -357,10 +364,10 @@ impl Item for Zeta2ContextView { } } -impl gpui::Render for Zeta2ContextView { +impl gpui::Render for EditPredictionContextView { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl ui::IntoElement { v_flex() - .key_context("Zeta2Context") + .key_context("EditPredictionContext") .on_action(cx.listener(Self::handle_go_back)) .on_action(cx.listener(Self::handle_go_forward)) .size_full() diff --git a/crates/edit_prediction_ui/src/edit_prediction_ui.rs b/crates/edit_prediction_ui/src/edit_prediction_ui.rs new file mode 100644 index 0000000000000000000000000000000000000000..51b491c6b3512968bca4ce2e7ed73a505bd73a00 --- /dev/null +++ b/crates/edit_prediction_ui/src/edit_prediction_ui.rs @@ -0,0 +1,128 @@ +mod edit_prediction_button; +mod edit_prediction_context_view; +mod rate_prediction_modal; +mod sweep_api_token_modal; + +use std::any::{Any as _, TypeId}; + +use command_palette_hooks::CommandPaletteFilter; +use edit_prediction::{ResetOnboarding, Zeta2FeatureFlag}; +use edit_prediction_context_view::EditPredictionContextView; +use feature_flags::FeatureFlagAppExt as _; +use gpui::actions; +use project::DisableAiSettings; +use rate_prediction_modal::RatePredictionsModal; +use settings::{Settings as _, SettingsStore}; +use ui::{App, prelude::*}; +use workspace::{SplitDirection, Workspace}; + +pub use edit_prediction_button::{EditPredictionButton, ToggleMenu}; +pub use sweep_api_token_modal::SweepApiKeyModal; + +use crate::rate_prediction_modal::PredictEditsRatePredictionsFeatureFlag; + +actions!( + dev, + [ + /// Opens the edit prediction context view. + OpenEditPredictionContextView, + ] +); + +actions!( + edit_prediction, + [ + /// Opens the rate completions modal. + RatePredictions, + ] +); + +pub fn init(cx: &mut App) { + feature_gate_predict_edits_actions(cx); + + cx.observe_new(move |workspace: &mut Workspace, _, _cx| { + workspace.register_action(|workspace, _: &RatePredictions, window, cx| { + if cx.has_flag::() { + RatePredictionsModal::toggle(workspace, window, cx); + } + }); + + workspace.register_action_renderer(|div, _, _, cx| { + let has_flag = cx.has_flag::(); + div.when(has_flag, |div| { + div.on_action(cx.listener( + move |workspace, _: &OpenEditPredictionContextView, window, cx| { + let project = workspace.project(); + workspace.split_item( + SplitDirection::Right, + Box::new(cx.new(|cx| { + EditPredictionContextView::new( + project.clone(), + workspace.client(), + workspace.user_store(), + window, + cx, + ) + })), + window, + cx, + ); + }, + )) + }) + }); + }) + .detach(); +} + +fn feature_gate_predict_edits_actions(cx: &mut App) { + let rate_completion_action_types = [TypeId::of::()]; + let reset_onboarding_action_types = [TypeId::of::()]; + let all_action_types = [ + TypeId::of::(), + TypeId::of::(), + zed_actions::OpenZedPredictOnboarding.type_id(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + ]; + + CommandPaletteFilter::update_global(cx, |filter, _cx| { + filter.hide_action_types(&rate_completion_action_types); + filter.hide_action_types(&reset_onboarding_action_types); + filter.hide_action_types(&[zed_actions::OpenZedPredictOnboarding.type_id()]); + }); + + cx.observe_global::(move |cx| { + let is_ai_disabled = DisableAiSettings::get_global(cx).disable_ai; + let has_feature_flag = cx.has_flag::(); + + CommandPaletteFilter::update_global(cx, |filter, _cx| { + if is_ai_disabled { + filter.hide_action_types(&all_action_types); + } else if has_feature_flag { + filter.show_action_types(&rate_completion_action_types); + } else { + filter.hide_action_types(&rate_completion_action_types); + } + }); + }) + .detach(); + + cx.observe_flag::(move |is_enabled, cx| { + if !DisableAiSettings::get_global(cx).disable_ai { + if is_enabled { + CommandPaletteFilter::update_global(cx, |filter, _cx| { + filter.show_action_types(&rate_completion_action_types); + }); + } else { + CommandPaletteFilter::update_global(cx, |filter, _cx| { + filter.hide_action_types(&rate_completion_action_types); + }); + } + } + }) + .detach(); +} diff --git a/crates/zeta/src/rate_prediction_modal.rs b/crates/edit_prediction_ui/src/rate_prediction_modal.rs similarity index 95% rename from crates/zeta/src/rate_prediction_modal.rs rename to crates/edit_prediction_ui/src/rate_prediction_modal.rs index 0cceb86608ed609122c81d406c71280894789e88..8e754b33dc18c5be60bc052c33aa08cdcb980acb 100644 --- a/crates/zeta/src/rate_prediction_modal.rs +++ b/crates/edit_prediction_ui/src/rate_prediction_modal.rs @@ -1,7 +1,8 @@ -use crate::{EditPrediction, EditPredictionRating, Zeta}; use buffer_diff::{BufferDiff, BufferDiffSnapshot}; use cloud_zeta2_prompt::write_codeblock; +use edit_prediction::{EditPrediction, EditPredictionRating, EditPredictionStore}; use editor::{Editor, ExcerptRange, MultiBuffer}; +use feature_flags::FeatureFlag; use gpui::{ App, BorderStyle, DismissEvent, EdgesRefinement, Entity, EventEmitter, FocusHandle, Focusable, Length, StyleRefinement, TextStyleRefinement, Window, actions, prelude::*, @@ -9,9 +10,7 @@ use gpui::{ use language::{LanguageRegistry, Point, language_settings}; use markdown::{Markdown, MarkdownStyle}; use settings::Settings as _; -use std::fmt::Write; -use std::sync::Arc; -use std::time::Duration; +use std::{fmt::Write, sync::Arc, time::Duration}; use theme::ThemeSettings; use ui::{KeyBinding, List, ListItem, ListItemSpacing, Tooltip, prelude::*}; use workspace::{ModalView, Workspace}; @@ -34,8 +33,14 @@ actions!( ] ); +pub struct PredictEditsRatePredictionsFeatureFlag; + +impl FeatureFlag for PredictEditsRatePredictionsFeatureFlag { + const NAME: &'static str = "predict-edits-rate-completions"; +} + pub struct RatePredictionsModal { - zeta: Entity, + ep_store: Entity, language_registry: Arc, active_prediction: Option, selected_index: usize, @@ -68,10 +73,10 @@ impl RatePredictionView { impl RatePredictionsModal { pub fn toggle(workspace: &mut Workspace, window: &mut Window, cx: &mut Context) { - if let Some(zeta) = Zeta::try_global(cx) { + if let Some(ep_store) = EditPredictionStore::try_global(cx) { let language_registry = workspace.app_state().languages.clone(); workspace.toggle_modal(window, cx, |window, cx| { - RatePredictionsModal::new(zeta, language_registry, window, cx) + RatePredictionsModal::new(ep_store, language_registry, window, cx) }); telemetry::event!("Rate Prediction Modal Open", source = "Edit Prediction"); @@ -79,15 +84,15 @@ impl RatePredictionsModal { } pub fn new( - zeta: Entity, + ep_store: Entity, language_registry: Arc, window: &mut Window, cx: &mut Context, ) -> Self { - let subscription = cx.observe(&zeta, |_, _, cx| cx.notify()); + let subscription = cx.observe(&ep_store, |_, _, cx| cx.notify()); Self { - zeta, + ep_store, language_registry, selected_index: 0, focus_handle: cx.focus_handle(), @@ -113,7 +118,7 @@ impl RatePredictionsModal { self.selected_index += 1; self.selected_index = usize::min( self.selected_index, - self.zeta.read(cx).shown_predictions().count(), + self.ep_store.read(cx).shown_predictions().count(), ); cx.notify(); } @@ -130,7 +135,7 @@ impl RatePredictionsModal { fn select_next_edit(&mut self, _: &NextEdit, _: &mut Window, cx: &mut Context) { let next_index = self - .zeta + .ep_store .read(cx) .shown_predictions() .skip(self.selected_index) @@ -146,11 +151,11 @@ impl RatePredictionsModal { } fn select_prev_edit(&mut self, _: &PreviousEdit, _: &mut Window, cx: &mut Context) { - let zeta = self.zeta.read(cx); - let completions_len = zeta.shown_completions_len(); + let ep_store = self.ep_store.read(cx); + let completions_len = ep_store.shown_completions_len(); let prev_index = self - .zeta + .ep_store .read(cx) .shown_predictions() .rev() @@ -173,7 +178,7 @@ impl RatePredictionsModal { } fn select_last(&mut self, _: &menu::SelectLast, _window: &mut Window, cx: &mut Context) { - self.selected_index = self.zeta.read(cx).shown_completions_len() - 1; + self.selected_index = self.ep_store.read(cx).shown_completions_len() - 1; cx.notify(); } @@ -183,9 +188,9 @@ impl RatePredictionsModal { window: &mut Window, cx: &mut Context, ) { - self.zeta.update(cx, |zeta, cx| { + self.ep_store.update(cx, |ep_store, cx| { if let Some(active) = &self.active_prediction { - zeta.rate_prediction( + ep_store.rate_prediction( &active.prediction, EditPredictionRating::Positive, active.feedback_editor.read(cx).text(cx), @@ -216,8 +221,8 @@ impl RatePredictionsModal { return; } - self.zeta.update(cx, |zeta, cx| { - zeta.rate_prediction( + self.ep_store.update(cx, |ep_store, cx| { + ep_store.rate_prediction( &active.prediction, EditPredictionRating::Negative, active.feedback_editor.read(cx).text(cx), @@ -254,7 +259,7 @@ impl RatePredictionsModal { cx: &mut Context, ) { let completion = self - .zeta + .ep_store .read(cx) .shown_predictions() .skip(self.selected_index) @@ -267,7 +272,7 @@ impl RatePredictionsModal { fn confirm(&mut self, _: &menu::Confirm, window: &mut Window, cx: &mut Context) { let completion = self - .zeta + .ep_store .read(cx) .shown_predictions() .skip(self.selected_index) @@ -288,7 +293,7 @@ impl RatePredictionsModal { // Avoid resetting completion rating if it's already selected. if let Some(prediction) = prediction { self.selected_index = self - .zeta + .ep_store .read(cx) .shown_predictions() .enumerate() @@ -376,7 +381,7 @@ impl RatePredictionsModal { &included_file.path, &included_file.excerpts, if included_file.path == prediction.inputs.cursor_path { - cursor_insertions + cursor_insertions.as_slice() } else { &[] }, @@ -564,7 +569,7 @@ impl RatePredictionsModal { let border_color = cx.theme().colors().border; let bg_color = cx.theme().colors().editor_background; - let rated = self.zeta.read(cx).is_prediction_rated(&completion_id); + let rated = self.ep_store.read(cx).is_prediction_rated(&completion_id); let feedback_empty = active_prediction .feedback_editor .read(cx) @@ -715,7 +720,7 @@ impl RatePredictionsModal { } fn render_shown_completions(&self, cx: &Context) -> impl Iterator { - self.zeta + self.ep_store .read(cx) .shown_predictions() .cloned() @@ -725,7 +730,7 @@ impl RatePredictionsModal { .active_prediction .as_ref() .is_some_and(|selected| selected.prediction.id == completion.id); - let rated = self.zeta.read(cx).is_prediction_rated(&completion.id); + let rated = self.ep_store.read(cx).is_prediction_rated(&completion.id); let (icon_name, icon_color, tooltip_text) = match (rated, completion.edits.is_empty()) { diff --git a/crates/edit_prediction_button/src/sweep_api_token_modal.rs b/crates/edit_prediction_ui/src/sweep_api_token_modal.rs similarity index 92% rename from crates/edit_prediction_button/src/sweep_api_token_modal.rs rename to crates/edit_prediction_ui/src/sweep_api_token_modal.rs index ab2102f25a2a7291644ca67ab3c89fd47da7ac0a..80366fc2ac691f165d44e1e6a29a633522146984 100644 --- a/crates/edit_prediction_button/src/sweep_api_token_modal.rs +++ b/crates/edit_prediction_ui/src/sweep_api_token_modal.rs @@ -1,10 +1,10 @@ +use edit_prediction::EditPredictionStore; use gpui::{ DismissEvent, Entity, EventEmitter, FocusHandle, Focusable, IntoElement, ParentElement, Render, }; use ui::{Button, ButtonStyle, Clickable, Headline, HeadlineSize, prelude::*}; use ui_input::InputField; use workspace::ModalView; -use zeta::Zeta; pub struct SweepApiKeyModal { api_key_input: Entity, @@ -29,9 +29,10 @@ impl SweepApiKeyModal { let api_key = self.api_key_input.read(cx).text(cx); let api_key = (!api_key.trim().is_empty()).then_some(api_key); - if let Some(zeta) = Zeta::try_global(cx) { - zeta.update(cx, |zeta, cx| { - zeta.sweep_ai + if let Some(ep_store) = EditPredictionStore::try_global(cx) { + ep_store.update(cx, |ep_store, cx| { + ep_store + .sweep_ai .set_api_token(api_key, cx) .detach_and_log_err(cx); }); diff --git a/crates/editor/Cargo.toml b/crates/editor/Cargo.toml index 736916ebbf74f20f11e8c03a0e584bd8ae92e07d..94c9fb10f50f8e0440b2e91cf0c16d1f701d9451 100644 --- a/crates/editor/Cargo.toml +++ b/crates/editor/Cargo.toml @@ -49,7 +49,7 @@ fs.workspace = true git.workspace = true gpui.workspace = true indoc.workspace = true -edit_prediction.workspace = true +edit_prediction_types.workspace = true itertools.workspace = true language.workspace = true linkify.workspace = true diff --git a/crates/editor/src/edit_prediction_tests.rs b/crates/editor/src/edit_prediction_tests.rs index a1839144a47a81f668ba2743cd5e362f6711d0e9..bfce1532ce78699e1fb524fd594df1ba83c864a5 100644 --- a/crates/editor/src/edit_prediction_tests.rs +++ b/crates/editor/src/edit_prediction_tests.rs @@ -1,4 +1,4 @@ -use edit_prediction::EditPredictionProvider; +use edit_prediction_types::EditPredictionDelegate; use gpui::{Entity, KeyBinding, Modifiers, prelude::*}; use indoc::indoc; use multi_buffer::{Anchor, MultiBufferSnapshot, ToPoint}; @@ -15,7 +15,7 @@ async fn test_edit_prediction_insert(cx: &mut gpui::TestAppContext) { init_test(cx, |_| {}); let mut cx = EditorTestContext::new(cx).await; - let provider = cx.new(|_| FakeEditPredictionProvider::default()); + let provider = cx.new(|_| FakeEditPredictionDelegate::default()); assign_editor_completion_provider(provider.clone(), &mut cx); cx.set_state("let absolute_zero_celsius = ˇ;"); @@ -37,7 +37,7 @@ async fn test_edit_prediction_modification(cx: &mut gpui::TestAppContext) { init_test(cx, |_| {}); let mut cx = EditorTestContext::new(cx).await; - let provider = cx.new(|_| FakeEditPredictionProvider::default()); + let provider = cx.new(|_| FakeEditPredictionDelegate::default()); assign_editor_completion_provider(provider.clone(), &mut cx); cx.set_state("let pi = ˇ\"foo\";"); @@ -59,7 +59,7 @@ async fn test_edit_prediction_jump_button(cx: &mut gpui::TestAppContext) { init_test(cx, |_| {}); let mut cx = EditorTestContext::new(cx).await; - let provider = cx.new(|_| FakeEditPredictionProvider::default()); + let provider = cx.new(|_| FakeEditPredictionDelegate::default()); assign_editor_completion_provider(provider.clone(), &mut cx); // Cursor is 2+ lines above the proposed edit @@ -128,7 +128,7 @@ async fn test_edit_prediction_invalidation_range(cx: &mut gpui::TestAppContext) init_test(cx, |_| {}); let mut cx = EditorTestContext::new(cx).await; - let provider = cx.new(|_| FakeEditPredictionProvider::default()); + let provider = cx.new(|_| FakeEditPredictionDelegate::default()); assign_editor_completion_provider(provider.clone(), &mut cx); // Cursor is 3+ lines above the proposed edit @@ -233,7 +233,7 @@ async fn test_edit_prediction_jump_disabled_for_non_zed_providers(cx: &mut gpui: init_test(cx, |_| {}); let mut cx = EditorTestContext::new(cx).await; - let provider = cx.new(|_| FakeNonZedEditPredictionProvider::default()); + let provider = cx.new(|_| FakeNonZedEditPredictionDelegate::default()); assign_editor_completion_provider_non_zed(provider.clone(), &mut cx); // Cursor is 2+ lines above the proposed edit @@ -281,7 +281,7 @@ async fn test_edit_prediction_preview_cleanup_on_toggle_off(cx: &mut gpui::TestA cx.update(|cx| cx.bind_keys([KeyBinding::new("ctrl-shift-a", AcceptEditPrediction, None)])); let mut cx = EditorTestContext::new(cx).await; - let provider = cx.new(|_| FakeEditPredictionProvider::default()); + let provider = cx.new(|_| FakeEditPredictionDelegate::default()); assign_editor_completion_provider(provider.clone(), &mut cx); cx.set_state("let x = ˇ;"); @@ -371,7 +371,7 @@ fn accept_completion(cx: &mut EditorTestContext) { } fn propose_edits( - provider: &Entity, + provider: &Entity, edits: Vec<(Range, &str)>, cx: &mut EditorTestContext, ) { @@ -383,7 +383,7 @@ fn propose_edits( cx.update(|_, cx| { provider.update(cx, |provider, _| { - provider.set_edit_prediction(Some(edit_prediction::EditPrediction::Local { + provider.set_edit_prediction(Some(edit_prediction_types::EditPrediction::Local { id: None, edits: edits.collect(), edit_preview: None, @@ -393,7 +393,7 @@ fn propose_edits( } fn assign_editor_completion_provider( - provider: Entity, + provider: Entity, cx: &mut EditorTestContext, ) { cx.update_editor(|editor, window, cx| { @@ -402,7 +402,7 @@ fn assign_editor_completion_provider( } fn propose_edits_non_zed( - provider: &Entity, + provider: &Entity, edits: Vec<(Range, &str)>, cx: &mut EditorTestContext, ) { @@ -414,7 +414,7 @@ fn propose_edits_non_zed( cx.update(|_, cx| { provider.update(cx, |provider, _| { - provider.set_edit_prediction(Some(edit_prediction::EditPrediction::Local { + provider.set_edit_prediction(Some(edit_prediction_types::EditPrediction::Local { id: None, edits: edits.collect(), edit_preview: None, @@ -424,7 +424,7 @@ fn propose_edits_non_zed( } fn assign_editor_completion_provider_non_zed( - provider: Entity, + provider: Entity, cx: &mut EditorTestContext, ) { cx.update_editor(|editor, window, cx| { @@ -433,17 +433,20 @@ fn assign_editor_completion_provider_non_zed( } #[derive(Default, Clone)] -pub struct FakeEditPredictionProvider { - pub completion: Option, +pub struct FakeEditPredictionDelegate { + pub completion: Option, } -impl FakeEditPredictionProvider { - pub fn set_edit_prediction(&mut self, completion: Option) { +impl FakeEditPredictionDelegate { + pub fn set_edit_prediction( + &mut self, + completion: Option, + ) { self.completion = completion; } } -impl EditPredictionProvider for FakeEditPredictionProvider { +impl EditPredictionDelegate for FakeEditPredictionDelegate { fn name() -> &'static str { "fake-completion-provider" } @@ -452,7 +455,7 @@ impl EditPredictionProvider for FakeEditPredictionProvider { "Fake Completion Provider" } - fn show_completions_in_menu() -> bool { + fn show_predictions_in_menu() -> bool { true } @@ -486,7 +489,7 @@ impl EditPredictionProvider for FakeEditPredictionProvider { &mut self, _buffer: gpui::Entity, _cursor_position: language::Anchor, - _direction: edit_prediction::Direction, + _direction: edit_prediction_types::Direction, _cx: &mut gpui::Context, ) { } @@ -500,23 +503,26 @@ impl EditPredictionProvider for FakeEditPredictionProvider { _buffer: &gpui::Entity, _cursor_position: language::Anchor, _cx: &mut gpui::Context, - ) -> Option { + ) -> Option { self.completion.clone() } } #[derive(Default, Clone)] -pub struct FakeNonZedEditPredictionProvider { - pub completion: Option, +pub struct FakeNonZedEditPredictionDelegate { + pub completion: Option, } -impl FakeNonZedEditPredictionProvider { - pub fn set_edit_prediction(&mut self, completion: Option) { +impl FakeNonZedEditPredictionDelegate { + pub fn set_edit_prediction( + &mut self, + completion: Option, + ) { self.completion = completion; } } -impl EditPredictionProvider for FakeNonZedEditPredictionProvider { +impl EditPredictionDelegate for FakeNonZedEditPredictionDelegate { fn name() -> &'static str { "fake-non-zed-provider" } @@ -525,7 +531,7 @@ impl EditPredictionProvider for FakeNonZedEditPredictionProvider { "Fake Non-Zed Provider" } - fn show_completions_in_menu() -> bool { + fn show_predictions_in_menu() -> bool { false } @@ -559,7 +565,7 @@ impl EditPredictionProvider for FakeNonZedEditPredictionProvider { &mut self, _buffer: gpui::Entity, _cursor_position: language::Anchor, - _direction: edit_prediction::Direction, + _direction: edit_prediction_types::Direction, _cx: &mut gpui::Context, ) { } @@ -573,7 +579,7 @@ impl EditPredictionProvider for FakeNonZedEditPredictionProvider { _buffer: &gpui::Entity, _cursor_position: language::Anchor, _cx: &mut gpui::Context, - ) -> Option { + ) -> Option { self.completion.clone() } } diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 306d7a272b0b8c33e66803ccdbbd74194fde403a..6651cce374001865d21dfdb182659f2a8c008305 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -51,7 +51,7 @@ pub mod test; pub(crate) use actions::*; pub use display_map::{ChunkRenderer, ChunkRendererContext, DisplayPoint, FoldPlaceholder}; -pub use edit_prediction::Direction; +pub use edit_prediction_types::Direction; pub use editor_settings::{ CurrentLineHighlight, DocumentColorsRenderMode, EditorSettings, HideMouseMode, ScrollBeyondLastLine, ScrollbarAxes, SearchSettings, ShowMinimap, @@ -92,7 +92,7 @@ use collections::{BTreeMap, HashMap, HashSet, VecDeque}; use convert_case::{Case, Casing}; use dap::TelemetrySpawnLocation; use display_map::*; -use edit_prediction::{EditPredictionProvider, EditPredictionProviderHandle}; +use edit_prediction_types::{EditPredictionDelegate, EditPredictionDelegateHandle}; use editor_settings::{GoToDefinitionFallback, Minimap as MinimapSettings}; use element::{AcceptEditPredictionBinding, LineWithInvisibles, PositionMap, layout_line}; use futures::{ @@ -1120,7 +1120,7 @@ pub struct Editor { pending_mouse_down: Option>>>, gutter_hovered: bool, hovered_link_state: Option, - edit_prediction_provider: Option, + edit_prediction_provider: Option, code_action_providers: Vec>, active_edit_prediction: Option, /// Used to prevent flickering as the user types while the menu is open @@ -1562,8 +1562,8 @@ pub struct RenameState { struct InvalidationStack(Vec); -struct RegisteredEditPredictionProvider { - provider: Arc, +struct RegisteredEditPredictionDelegate { + provider: Arc, _subscription: Subscription, } @@ -2988,9 +2988,9 @@ impl Editor { window: &mut Window, cx: &mut Context, ) where - T: EditPredictionProvider, + T: EditPredictionDelegate, { - self.edit_prediction_provider = provider.map(|provider| RegisteredEditPredictionProvider { + self.edit_prediction_provider = provider.map(|provider| RegisteredEditPredictionDelegate { _subscription: cx.observe_in(&provider, window, |this, _, window, cx| { if this.focus_handle.is_focused(window) { this.update_visible_edit_prediction(window, cx); @@ -7394,7 +7394,7 @@ impl Editor { && self .edit_prediction_provider .as_ref() - .is_some_and(|provider| provider.provider.show_completions_in_menu()); + .is_some_and(|provider| provider.provider.show_predictions_in_menu()); let preview_requires_modifier = all_language_settings(file, cx).edit_predictions_mode() == EditPredictionsMode::Subtle; @@ -8095,12 +8095,12 @@ impl Editor { let edit_prediction = provider.suggest(&buffer, cursor_buffer_position, cx)?; let (completion_id, edits, edit_preview) = match edit_prediction { - edit_prediction::EditPrediction::Local { + edit_prediction_types::EditPrediction::Local { id, edits, edit_preview, } => (id, edits, edit_preview), - edit_prediction::EditPrediction::Jump { + edit_prediction_types::EditPrediction::Jump { id, snapshot, target, @@ -8241,7 +8241,7 @@ impl Editor { Some(()) } - pub fn edit_prediction_provider(&self) -> Option> { + pub fn edit_prediction_provider(&self) -> Option> { Some(self.edit_prediction_provider.as_ref()?.provider.clone()) } @@ -9563,7 +9563,7 @@ impl Editor { editor_bg_color.blend(accent_color.opacity(0.6)) } fn get_prediction_provider_icon_name( - provider: &Option, + provider: &Option, ) -> IconName { match provider { Some(provider) => match provider.provider.name() { diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rs index 7ab3dcc2345dd8a140b7c4762dc5afadb9cef484..683972254ce0ffb719679d431f0a72485cee97f2 100644 --- a/crates/editor/src/editor_tests.rs +++ b/crates/editor/src/editor_tests.rs @@ -2,7 +2,7 @@ use super::*; use crate::{ JoinLines, code_context_menus::CodeContextMenu, - edit_prediction_tests::FakeEditPredictionProvider, + edit_prediction_tests::FakeEditPredictionDelegate, element::StickyHeader, linked_editing_ranges::LinkedEditingRanges, scroll::scroll_amount::ScrollAmount, @@ -8636,7 +8636,7 @@ async fn test_undo_edit_prediction_scrolls_to_edit_pos(cx: &mut TestAppContext) let mut cx = EditorTestContext::new(cx).await; - let provider = cx.new(|_| FakeEditPredictionProvider::default()); + let provider = cx.new(|_| FakeEditPredictionDelegate::default()); cx.update_editor(|editor, window, cx| { editor.set_edit_prediction_provider(Some(provider.clone()), window, cx); }); @@ -8659,7 +8659,7 @@ async fn test_undo_edit_prediction_scrolls_to_edit_pos(cx: &mut TestAppContext) cx.update(|_, cx| { provider.update(cx, |provider, _| { - provider.set_edit_prediction(Some(edit_prediction::EditPrediction::Local { + provider.set_edit_prediction(Some(edit_prediction_types::EditPrediction::Local { id: None, edits: vec![(edit_position..edit_position, "X".into())], edit_preview: None, diff --git a/crates/feature_flags/src/flags.rs b/crates/feature_flags/src/flags.rs index 47b6f1230ac747c2633327d1be923d33388cf179..26615aea0f7566ec6dbbd66a128c1a395cc1b9bc 100644 --- a/crates/feature_flags/src/flags.rs +++ b/crates/feature_flags/src/flags.rs @@ -1,11 +1,5 @@ use crate::FeatureFlag; -pub struct PredictEditsRateCompletionsFeatureFlag; - -impl FeatureFlag for PredictEditsRateCompletionsFeatureFlag { - const NAME: &'static str = "predict-edits-rate-completions"; -} - pub struct NotebookFeatureFlag; impl FeatureFlag for NotebookFeatureFlag { diff --git a/crates/supermaven/Cargo.toml b/crates/supermaven/Cargo.toml index 5b86367f35d508579ac6ba999fc8c9236e7fd66a..c2d0c48a9e7733402eae32886c0863326882c134 100644 --- a/crates/supermaven/Cargo.toml +++ b/crates/supermaven/Cargo.toml @@ -16,7 +16,7 @@ doctest = false anyhow.workspace = true client.workspace = true collections.workspace = true -edit_prediction.workspace = true +edit_prediction_types.workspace = true futures.workspace = true gpui.workspace = true language.workspace = true diff --git a/crates/supermaven/src/supermaven.rs b/crates/supermaven/src/supermaven.rs index 7a9963dbc424185c52be6879a0a9e722db7106b2..527f4ec37da17c784d3323ebc87a23eb914905ea 100644 --- a/crates/supermaven/src/supermaven.rs +++ b/crates/supermaven/src/supermaven.rs @@ -1,7 +1,7 @@ mod messages; -mod supermaven_completion_provider; +mod supermaven_edit_prediction_delegate; -pub use supermaven_completion_provider::*; +pub use supermaven_edit_prediction_delegate::*; use anyhow::{Context as _, Result}; #[allow(unused_imports)] diff --git a/crates/supermaven/src/supermaven_completion_provider.rs b/crates/supermaven/src/supermaven_edit_prediction_delegate.rs similarity index 95% rename from crates/supermaven/src/supermaven_completion_provider.rs rename to crates/supermaven/src/supermaven_edit_prediction_delegate.rs index 9d5e256aca1b66644145cb688851d0ec5c1b81b9..578bc894f223fd458f510694194aebe633d7a6db 100644 --- a/crates/supermaven/src/supermaven_completion_provider.rs +++ b/crates/supermaven/src/supermaven_edit_prediction_delegate.rs @@ -1,6 +1,6 @@ use crate::{Supermaven, SupermavenCompletionStateId}; use anyhow::Result; -use edit_prediction::{Direction, EditPrediction, EditPredictionProvider}; +use edit_prediction_types::{Direction, EditPrediction, EditPredictionDelegate}; use futures::StreamExt as _; use gpui::{App, Context, Entity, EntityId, Task}; use language::{Anchor, Buffer, BufferSnapshot}; @@ -15,7 +15,7 @@ use unicode_segmentation::UnicodeSegmentation; pub const DEBOUNCE_TIMEOUT: Duration = Duration::from_millis(75); -pub struct SupermavenCompletionProvider { +pub struct SupermavenEditPredictionDelegate { supermaven: Entity, buffer_id: Option, completion_id: Option, @@ -25,7 +25,7 @@ pub struct SupermavenCompletionProvider { completion_position: Option, } -impl SupermavenCompletionProvider { +impl SupermavenEditPredictionDelegate { pub fn new(supermaven: Entity) -> Self { Self { supermaven, @@ -104,7 +104,7 @@ fn completion_from_diff( } } -impl EditPredictionProvider for SupermavenCompletionProvider { +impl EditPredictionDelegate for SupermavenEditPredictionDelegate { fn name() -> &'static str { "supermaven" } @@ -113,7 +113,7 @@ impl EditPredictionProvider for SupermavenCompletionProvider { "Supermaven" } - fn show_completions_in_menu() -> bool { + fn show_predictions_in_menu() -> bool { true } @@ -269,8 +269,8 @@ impl EditPredictionProvider for SupermavenCompletionProvider { } fn reset_completion_cache( - provider: &mut SupermavenCompletionProvider, - _cx: &mut Context, + provider: &mut SupermavenEditPredictionDelegate, + _cx: &mut Context, ) { provider.pending_refresh = None; provider.completion_id = None; diff --git a/crates/zed/Cargo.toml b/crates/zed/Cargo.toml index 3358cc5d32bea308083ae1f6ee06268cf22d670a..6ee7d0a4ea75ff5e13a4db6f5fe73c2a5ba80193 100644 --- a/crates/zed/Cargo.toml +++ b/crates/zed/Cargo.toml @@ -50,7 +50,6 @@ debugger_tools.workspace = true debugger_ui.workspace = true diagnostics.workspace = true editor.workspace = true -zeta2_tools.workspace = true env_logger.workspace = true extension.workspace = true extension_host.workspace = true @@ -74,7 +73,8 @@ gpui = { workspace = true, features = [ gpui_tokio.workspace = true rayon.workspace = true -edit_prediction_button.workspace = true +edit_prediction.workspace = true +edit_prediction_ui.workspace = true http_client.workspace = true image_viewer.workspace = true inspector_ui.workspace = true @@ -160,7 +160,6 @@ web_search_providers.workspace = true workspace.workspace = true zed_actions.workspace = true zed_env_vars.workspace = true -zeta.workspace = true zlog.workspace = true zlog_settings.workspace = true chrono.workspace = true diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rs index f92c819dd22c69d95533d16249345e6128e9ded0..10f599e876032bf297d3eaf173093a308d666cc9 100644 --- a/crates/zed/src/main.rs +++ b/crates/zed/src/main.rs @@ -581,7 +581,7 @@ pub fn main() { language_model::init(app_state.client.clone(), cx); language_models::init(app_state.user_store.clone(), app_state.client.clone(), cx); acp_tools::init(cx); - zeta2_tools::init(cx); + edit_prediction_ui::init(cx); web_search::init(cx); web_search_providers::init(app_state.client.clone(), cx); snippet_provider::init(cx); @@ -640,7 +640,7 @@ pub fn main() { settings_ui::init(cx); keymap_editor::init(cx); extensions_ui::init(cx); - zeta::init(cx); + edit_prediction::init(cx); inspector_ui::init(app_state.clone(), cx); json_schema_store::init(cx); miniprofiler_ui::init(*STARTUP_TIME.get().unwrap(), cx); diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs index 49a43eae47fe36c9cd93f3ce6371cf39c5f5e514..164d6b8383fe940e3a92d5461edbff878300474a 100644 --- a/crates/zed/src/zed.rs +++ b/crates/zed/src/zed.rs @@ -401,8 +401,8 @@ pub fn initialize_workspace( unstable_version_notification(cx); let edit_prediction_menu_handle = PopoverMenuHandle::default(); - let edit_prediction_button = cx.new(|cx| { - edit_prediction_button::EditPredictionButton::new( + let edit_prediction_ui = cx.new(|cx| { + edit_prediction_ui::EditPredictionButton::new( app_state.fs.clone(), app_state.user_store.clone(), edit_prediction_menu_handle.clone(), @@ -411,7 +411,7 @@ pub fn initialize_workspace( ) }); workspace.register_action({ - move |_, _: &edit_prediction_button::ToggleMenu, window, cx| { + move |_, _: &edit_prediction_ui::ToggleMenu, window, cx| { edit_prediction_menu_handle.toggle(window, cx); } }); @@ -450,7 +450,7 @@ pub fn initialize_workspace( status_bar.add_left_item(lsp_button, window, cx); status_bar.add_left_item(diagnostic_summary, window, cx); status_bar.add_left_item(activity_indicator, window, cx); - status_bar.add_right_item(edit_prediction_button, window, cx); + status_bar.add_right_item(edit_prediction_ui, window, cx); status_bar.add_right_item(active_buffer_language, window, cx); status_bar.add_right_item(active_toolchain_language, window, cx); status_bar.add_right_item(line_ending_indicator, window, cx); diff --git a/crates/zed/src/zed/edit_prediction_registry.rs b/crates/zed/src/zed/edit_prediction_registry.rs index f413fd94cb1a48adb213120364ed2f59c4cf58e0..2d5746b87ab20de5d0aca47a4d5da60b9ec33d2a 100644 --- a/crates/zed/src/zed/edit_prediction_registry.rs +++ b/crates/zed/src/zed/edit_prediction_registry.rs @@ -1,7 +1,8 @@ use client::{Client, UserStore}; -use codestral::CodestralCompletionProvider; +use codestral::CodestralEditPredictionDelegate; use collections::HashMap; -use copilot::{Copilot, CopilotCompletionProvider}; +use copilot::{Copilot, CopilotEditPredictionDelegate}; +use edit_prediction::{SweepFeatureFlag, ZedEditPredictionDelegate, Zeta2FeatureFlag}; use editor::Editor; use feature_flags::FeatureFlagAppExt; use gpui::{AnyWindowHandle, App, AppContext as _, Context, Entity, WeakEntity}; @@ -12,9 +13,8 @@ use settings::{ EXPERIMENTAL_ZETA2_EDIT_PREDICTION_PROVIDER_NAME, SettingsStore, }; use std::{cell::RefCell, rc::Rc, sync::Arc}; -use supermaven::{Supermaven, SupermavenCompletionProvider}; +use supermaven::{Supermaven, SupermavenEditPredictionDelegate}; use ui::Window; -use zeta::{SweepFeatureFlag, Zeta2FeatureFlag, ZetaEditPredictionProvider}; pub fn init(client: Arc, user_store: Entity, cx: &mut App) { let editors: Rc, AnyWindowHandle>>> = Rc::default(); @@ -59,7 +59,7 @@ pub fn init(client: Arc, user_store: Entity, cx: &mut App) { }) .detach(); - cx.on_action(clear_zeta_edit_history); + cx.on_action(clear_edit_prediction_store_edit_history); let mut provider = all_language_settings(None, cx).edit_predictions.provider; cx.subscribe(&user_store, { @@ -100,9 +100,9 @@ pub fn init(client: Arc, user_store: Entity, cx: &mut App) { .detach(); } -fn clear_zeta_edit_history(_: &zeta::ClearHistory, cx: &mut App) { - if let Some(zeta) = zeta::Zeta::try_global(cx) { - zeta.update(cx, |zeta, _| zeta.clear_history()); +fn clear_edit_prediction_store_edit_history(_: &edit_prediction::ClearHistory, cx: &mut App) { + if let Some(ep_store) = edit_prediction::EditPredictionStore::try_global(cx) { + ep_store.update(cx, |ep_store, _| ep_store.clear_history()); } } @@ -176,7 +176,7 @@ fn assign_edit_prediction_provider( match provider { EditPredictionProvider::None => { - editor.set_edit_prediction_provider::(None, window, cx); + editor.set_edit_prediction_provider::(None, window, cx); } EditPredictionProvider::Copilot => { if let Some(copilot) = Copilot::global(cx) { @@ -187,55 +187,61 @@ fn assign_edit_prediction_provider( copilot.register_buffer(&buffer, cx); }); } - let provider = cx.new(|_| CopilotCompletionProvider::new(copilot)); + let provider = cx.new(|_| CopilotEditPredictionDelegate::new(copilot)); editor.set_edit_prediction_provider(Some(provider), window, cx); } } EditPredictionProvider::Supermaven => { if let Some(supermaven) = Supermaven::global(cx) { - let provider = cx.new(|_| SupermavenCompletionProvider::new(supermaven)); + let provider = cx.new(|_| SupermavenEditPredictionDelegate::new(supermaven)); editor.set_edit_prediction_provider(Some(provider), window, cx); } } EditPredictionProvider::Codestral => { let http_client = client.http_client(); - let provider = cx.new(|_| CodestralCompletionProvider::new(http_client)); + let provider = cx.new(|_| CodestralEditPredictionDelegate::new(http_client)); editor.set_edit_prediction_provider(Some(provider), window, cx); } value @ (EditPredictionProvider::Experimental(_) | EditPredictionProvider::Zed) => { - let zeta = zeta::Zeta::global(client, &user_store, cx); + let ep_store = edit_prediction::EditPredictionStore::global(client, &user_store, cx); if let Some(project) = editor.project() && let Some(buffer) = &singleton_buffer && buffer.read(cx).file().is_some() { - let has_model = zeta.update(cx, |zeta, cx| { + let has_model = ep_store.update(cx, |ep_store, cx| { let model = if let EditPredictionProvider::Experimental(name) = value { if name == EXPERIMENTAL_SWEEP_EDIT_PREDICTION_PROVIDER_NAME && cx.has_flag::() { - zeta::ZetaEditPredictionModel::Sweep + edit_prediction::EditPredictionModel::Sweep } else if name == EXPERIMENTAL_ZETA2_EDIT_PREDICTION_PROVIDER_NAME && cx.has_flag::() { - zeta::ZetaEditPredictionModel::Zeta2 + edit_prediction::EditPredictionModel::Zeta2 } else { return false; } } else if user_store.read(cx).current_user().is_some() { - zeta::ZetaEditPredictionModel::Zeta1 + edit_prediction::EditPredictionModel::Zeta1 } else { return false; }; - zeta.set_edit_prediction_model(model); - zeta.register_buffer(buffer, project, cx); + ep_store.set_edit_prediction_model(model); + ep_store.register_buffer(buffer, project, cx); true }); if has_model { let provider = cx.new(|cx| { - ZetaEditPredictionProvider::new(project.clone(), &client, &user_store, cx) + ZedEditPredictionDelegate::new( + project.clone(), + singleton_buffer, + &client, + &user_store, + cx, + ) }); editor.set_edit_prediction_provider(Some(provider), window, cx); } diff --git a/crates/zeta/Cargo.toml b/crates/zeta/Cargo.toml deleted file mode 100644 index b90934e67c2a689e1f7bb9704ff28a408de3049a..0000000000000000000000000000000000000000 --- a/crates/zeta/Cargo.toml +++ /dev/null @@ -1,85 +0,0 @@ -[package] -name = "zeta" -version = "0.1.0" -edition.workspace = true -publish.workspace = true -license = "GPL-3.0-or-later" - -[lints] -workspace = true - -[lib] -path = "src/zeta.rs" - -[features] -eval-support = [] - -[dependencies] -ai_onboarding.workspace = true -anyhow.workspace = true -arrayvec.workspace = true -brotli.workspace = true -buffer_diff.workspace = true -client.workspace = true -cloud_llm_client.workspace = true -cloud_zeta2_prompt.workspace = true -collections.workspace = true -command_palette_hooks.workspace = true -copilot.workspace = true -credentials_provider.workspace = true -db.workspace = true -edit_prediction.workspace = true -edit_prediction_context.workspace = true -edit_prediction_context2.workspace = true -editor.workspace = true -feature_flags.workspace = true -fs.workspace = true -futures.workspace = true -gpui.workspace = true -indoc.workspace = true -itertools.workspace = true -language.workspace = true -language_model.workspace = true -log.workspace = true -lsp.workspace = true -markdown.workspace = true -menu.workspace = true -open_ai.workspace = true -postage.workspace = true -pretty_assertions.workspace = true -project.workspace = true -rand.workspace = true -regex.workspace = true -release_channel.workspace = true -semver.workspace = true -serde.workspace = true -serde_json.workspace = true -settings.workspace = true -smol.workspace = true -strsim.workspace = true -strum.workspace = true -telemetry.workspace = true -telemetry_events.workspace = true -theme.workspace = true -thiserror.workspace = true -ui.workspace = true -util.workspace = true -uuid.workspace = true -workspace.workspace = true -worktree.workspace = true -zed_actions.workspace = true - -[dev-dependencies] -clock = { workspace = true, features = ["test-support"] } -cloud_api_types.workspace = true -cloud_llm_client = { workspace = true, features = ["test-support"] } -ctor.workspace = true -gpui = { workspace = true, features = ["test-support"] } -indoc.workspace = true -language = { workspace = true, features = ["test-support"] } -language_model = { workspace = true, features = ["test-support"] } -lsp.workspace = true -parking_lot.workspace = true -project = { workspace = true, features = ["test-support"] } -settings = { workspace = true, features = ["test-support"] } -zlog.workspace = true diff --git a/crates/zeta/src/retrieval_search.rs b/crates/zeta/src/retrieval_search.rs deleted file mode 100644 index f429f167744422c3641b5a68ca662af48c8e1614..0000000000000000000000000000000000000000 --- a/crates/zeta/src/retrieval_search.rs +++ /dev/null @@ -1,490 +0,0 @@ -use anyhow::Result; -use cloud_zeta2_prompt::retrieval_prompt::SearchToolQuery; -use collections::HashMap; -use edit_prediction_context2::{RelatedExcerpt, RelatedFile}; -use futures::{ - StreamExt, - channel::mpsc::{self, UnboundedSender}, -}; -use gpui::{AppContext, AsyncApp, Entity}; -use language::{Anchor, Buffer, BufferSnapshot, OffsetRangeExt, Point, ToOffset, ToPoint}; -use project::{ - Project, ProjectPath, WorktreeSettings, - search::{SearchQuery, SearchResult}, -}; -use smol::channel; -use std::ops::Range; -use util::{ - ResultExt as _, - paths::{PathMatcher, PathStyle}, -}; -use workspace::item::Settings as _; - -#[cfg(feature = "eval-support")] -type CachedSearchResults = std::collections::BTreeMap>>; - -pub async fn run_retrieval_searches( - queries: Vec, - project: Entity, - #[cfg(feature = "eval-support")] eval_cache: Option>, - cx: &mut AsyncApp, -) -> Result> { - #[cfg(feature = "eval-support")] - let cache = if let Some(eval_cache) = eval_cache { - use crate::EvalCacheEntryKind; - use anyhow::Context; - use collections::FxHasher; - use std::hash::{Hash, Hasher}; - - let mut hasher = FxHasher::default(); - project.read_with(cx, |project, cx| { - let mut worktrees = project.worktrees(cx); - let Some(worktree) = worktrees.next() else { - panic!("Expected a single worktree in eval project. Found none."); - }; - assert!( - worktrees.next().is_none(), - "Expected a single worktree in eval project. Found more than one." - ); - worktree.read(cx).abs_path().hash(&mut hasher); - })?; - - queries.hash(&mut hasher); - let key = (EvalCacheEntryKind::Search, hasher.finish()); - - if let Some(cached_results) = eval_cache.read(key) { - let file_results = serde_json::from_str::(&cached_results) - .context("Failed to deserialize cached search results")?; - let mut results = Vec::new(); - - for (path, ranges) in file_results { - let project_path = project.update(cx, |project, cx| { - project.find_project_path(path, cx).unwrap() - })?; - let buffer = project - .update(cx, |project, cx| { - project.open_buffer(project_path.clone(), cx) - })? - .await?; - let snapshot = buffer.read_with(cx, |buffer, _| buffer.snapshot())?; - let mut ranges: Vec<_> = ranges - .into_iter() - .map( - |Range { - start: (start_row, start_col), - end: (end_row, end_col), - }| { - snapshot.anchor_before(Point::new(start_row, start_col)) - ..snapshot.anchor_after(Point::new(end_row, end_col)) - }, - ) - .collect(); - merge_anchor_ranges(&mut ranges, &snapshot); - results.push(RelatedFile { - path: project_path, - buffer: buffer.downgrade(), - excerpts: ranges - .into_iter() - .map(|range| RelatedExcerpt { - point_range: range.to_point(&snapshot), - text: snapshot.as_rope().slice(range.to_offset(&snapshot)), - anchor_range: range, - }) - .collect(), - max_row: snapshot.max_point().row, - }); - } - - return Ok(results); - } - - Some((eval_cache, serde_json::to_string_pretty(&queries)?, key)) - } else { - None - }; - - let (exclude_matcher, path_style) = project.update(cx, |project, cx| { - let global_settings = WorktreeSettings::get_global(cx); - let exclude_patterns = global_settings - .file_scan_exclusions - .sources() - .chain(global_settings.private_files.sources()); - let path_style = project.path_style(cx); - anyhow::Ok((PathMatcher::new(exclude_patterns, path_style)?, path_style)) - })??; - - let (results_tx, mut results_rx) = mpsc::unbounded(); - - for query in queries { - let exclude_matcher = exclude_matcher.clone(); - let results_tx = results_tx.clone(); - let project = project.clone(); - cx.spawn(async move |cx| { - run_query( - query, - results_tx.clone(), - path_style, - exclude_matcher, - &project, - cx, - ) - .await - .log_err(); - }) - .detach() - } - drop(results_tx); - - #[cfg(feature = "eval-support")] - let cache = cache.clone(); - cx.background_spawn(async move { - let mut results: Vec = Vec::default(); - let mut snapshots = HashMap::default(); - - let mut total_bytes = 0; - 'outer: while let Some((project_path, buffer, snapshot, excerpts)) = results_rx.next().await - { - let existing = results - .iter_mut() - .find(|related_file| related_file.buffer.entity_id() == buffer.entity_id()); - let existing = match existing { - Some(existing) => existing, - None => { - results.push(RelatedFile { - path: project_path, - buffer: buffer.downgrade(), - excerpts: Vec::new(), - max_row: snapshot.max_point().row, - }); - results.last_mut().unwrap() - } - }; - // let existing = results.entry(buffer).or_default(); - existing.excerpts.reserve(excerpts.len()); - - for (range, size) in excerpts { - // Blunt trimming of the results until we have a proper algorithmic filtering step - if (total_bytes + size) > MAX_RESULTS_LEN { - log::trace!("Combined results reached limit of {MAX_RESULTS_LEN}B"); - break 'outer; - } - total_bytes += size; - existing.excerpts.push(RelatedExcerpt { - point_range: range.to_point(&snapshot), - text: snapshot.as_rope().slice(range.to_offset(&snapshot)), - anchor_range: range, - }); - } - snapshots.insert(buffer.entity_id(), snapshot); - } - - #[cfg(feature = "eval-support")] - if let Some((cache, queries, key)) = cache { - let cached_results: CachedSearchResults = results - .iter() - .map(|related_file| { - let mut ranges = related_file - .excerpts - .iter() - .map( - |RelatedExcerpt { - point_range: Range { start, end }, - .. - }| { - (start.row, start.column)..(end.row, end.column) - }, - ) - .collect::>(); - ranges.sort_unstable_by_key(|range| (range.start, range.end)); - (related_file.path.path.as_std_path().to_path_buf(), ranges) - }) - .collect(); - cache.write( - key, - &queries, - &serde_json::to_string_pretty(&cached_results)?, - ); - } - - for related_file in results.iter_mut() { - related_file.merge_excerpts(); - } - - Ok(results) - }) - .await -} - -#[cfg(feature = "eval-support")] -pub(crate) fn merge_anchor_ranges(ranges: &mut Vec>, snapshot: &BufferSnapshot) { - ranges.sort_unstable_by(|a, b| { - a.start - .cmp(&b.start, snapshot) - .then(b.end.cmp(&a.end, snapshot)) - }); - - let mut index = 1; - while index < ranges.len() { - if ranges[index - 1] - .end - .cmp(&ranges[index].start, snapshot) - .is_ge() - { - let removed = ranges.remove(index); - if removed.end.cmp(&ranges[index - 1].end, snapshot).is_gt() { - ranges[index - 1].end = removed.end; - } - } else { - index += 1; - } - } -} - -const MAX_EXCERPT_LEN: usize = 768; -const MAX_RESULTS_LEN: usize = MAX_EXCERPT_LEN * 5; - -struct SearchJob { - buffer: Entity, - snapshot: BufferSnapshot, - project_path: ProjectPath, - ranges: Vec>, - query_ix: usize, - jobs_tx: channel::Sender, -} - -async fn run_query( - input_query: SearchToolQuery, - results_tx: UnboundedSender<( - ProjectPath, - Entity, - BufferSnapshot, - Vec<(Range, usize)>, - )>, - path_style: PathStyle, - exclude_matcher: PathMatcher, - project: &Entity, - cx: &mut AsyncApp, -) -> Result<()> { - let include_matcher = PathMatcher::new(vec![input_query.glob], path_style)?; - - let make_search = |regex: &str| -> Result { - SearchQuery::regex( - regex, - false, - true, - false, - true, - include_matcher.clone(), - exclude_matcher.clone(), - true, - None, - ) - }; - - if let Some(outer_syntax_regex) = input_query.syntax_node.first() { - let outer_syntax_query = make_search(outer_syntax_regex)?; - let nested_syntax_queries = input_query - .syntax_node - .into_iter() - .skip(1) - .map(|query| make_search(&query)) - .collect::>>()?; - let content_query = input_query - .content - .map(|regex| make_search(®ex)) - .transpose()?; - - let (jobs_tx, jobs_rx) = channel::unbounded(); - - let outer_search_results_rx = - project.update(cx, |project, cx| project.search(outer_syntax_query, cx))?; - - let outer_search_task = cx.spawn(async move |cx| { - futures::pin_mut!(outer_search_results_rx); - while let Some(SearchResult::Buffer { buffer, ranges }) = - outer_search_results_rx.next().await - { - buffer - .read_with(cx, |buffer, _| buffer.parsing_idle())? - .await; - let snapshot = buffer.read_with(cx, |buffer, _cx| buffer.snapshot())?; - let Some(file) = snapshot.file() else { - continue; - }; - - let project_path = cx.update(|cx| ProjectPath { - worktree_id: file.worktree_id(cx), - path: file.path().clone(), - })?; - let expanded_ranges: Vec<_> = ranges - .into_iter() - .filter_map(|range| expand_to_parent_range(&range, &snapshot)) - .collect(); - jobs_tx - .send(SearchJob { - project_path, - buffer, - snapshot, - ranges: expanded_ranges, - query_ix: 0, - jobs_tx: jobs_tx.clone(), - }) - .await?; - } - anyhow::Ok(()) - }); - - let n_workers = cx.background_executor().num_cpus(); - let search_job_task = cx.background_executor().scoped(|scope| { - for _ in 0..n_workers { - scope.spawn(async { - while let Ok(job) = jobs_rx.recv().await { - process_nested_search_job( - &results_tx, - &nested_syntax_queries, - &content_query, - job, - ) - .await; - } - }); - } - }); - - search_job_task.await; - outer_search_task.await?; - } else if let Some(content_regex) = &input_query.content { - let search_query = make_search(&content_regex)?; - - let results_rx = project.update(cx, |project, cx| project.search(search_query, cx))?; - futures::pin_mut!(results_rx); - - while let Some(SearchResult::Buffer { buffer, ranges }) = results_rx.next().await { - let snapshot = buffer.read_with(cx, |buffer, _cx| buffer.snapshot())?; - let Some(file) = snapshot.file() else { - continue; - }; - let project_path = cx.update(|cx| ProjectPath { - worktree_id: file.worktree_id(cx), - path: file.path().clone(), - })?; - - let ranges = ranges - .into_iter() - .map(|range| { - let range = range.to_offset(&snapshot); - let range = expand_to_entire_lines(range, &snapshot); - let size = range.len(); - let range = - snapshot.anchor_before(range.start)..snapshot.anchor_after(range.end); - (range, size) - }) - .collect(); - - let send_result = - results_tx.unbounded_send((project_path, buffer.clone(), snapshot.clone(), ranges)); - - if let Err(err) = send_result - && !err.is_disconnected() - { - log::error!("{err}"); - } - } - } else { - log::warn!("Context gathering model produced a glob-only search"); - } - - anyhow::Ok(()) -} - -async fn process_nested_search_job( - results_tx: &UnboundedSender<( - ProjectPath, - Entity, - BufferSnapshot, - Vec<(Range, usize)>, - )>, - queries: &Vec, - content_query: &Option, - job: SearchJob, -) { - if let Some(search_query) = queries.get(job.query_ix) { - let mut subranges = Vec::new(); - for range in job.ranges { - let start = range.start; - let search_results = search_query.search(&job.snapshot, Some(range)).await; - for subrange in search_results { - let subrange = start + subrange.start..start + subrange.end; - subranges.extend(expand_to_parent_range(&subrange, &job.snapshot)); - } - } - job.jobs_tx - .send(SearchJob { - project_path: job.project_path, - buffer: job.buffer, - snapshot: job.snapshot, - ranges: subranges, - query_ix: job.query_ix + 1, - jobs_tx: job.jobs_tx.clone(), - }) - .await - .ok(); - } else { - let ranges = if let Some(content_query) = content_query { - let mut subranges = Vec::new(); - for range in job.ranges { - let start = range.start; - let search_results = content_query.search(&job.snapshot, Some(range)).await; - for subrange in search_results { - let subrange = start + subrange.start..start + subrange.end; - subranges.push(subrange); - } - } - subranges - } else { - job.ranges - }; - - let matches = ranges - .into_iter() - .map(|range| { - let snapshot = &job.snapshot; - let range = expand_to_entire_lines(range, snapshot); - let size = range.len(); - let range = snapshot.anchor_before(range.start)..snapshot.anchor_after(range.end); - (range, size) - }) - .collect(); - - let send_result = - results_tx.unbounded_send((job.project_path, job.buffer, job.snapshot, matches)); - - if let Err(err) = send_result - && !err.is_disconnected() - { - log::error!("{err}"); - } - } -} - -fn expand_to_entire_lines(range: Range, snapshot: &BufferSnapshot) -> Range { - let mut point_range = range.to_point(snapshot); - point_range.start.column = 0; - if point_range.end.column > 0 { - point_range.end = snapshot.max_point().min(point_range.end + Point::new(1, 0)); - } - point_range.to_offset(snapshot) -} - -fn expand_to_parent_range( - range: &Range, - snapshot: &BufferSnapshot, -) -> Option> { - let mut line_range = range.to_point(&snapshot); - line_range.start.column = snapshot.indent_size_for_line(line_range.start.row).len; - line_range.end.column = snapshot.line_len(line_range.end.row); - // TODO skip result if matched line isn't the first node line? - - let node = snapshot.syntax_ancestor(line_range)?; - Some(node.byte_range()) -} diff --git a/crates/zeta/src/zeta.rs b/crates/zeta/src/zeta.rs deleted file mode 100644 index 576067b9844cd668c69411d7a4098975db4a5d26..0000000000000000000000000000000000000000 --- a/crates/zeta/src/zeta.rs +++ /dev/null @@ -1,3890 +0,0 @@ -use anyhow::{Context as _, Result, anyhow, bail}; -use arrayvec::ArrayVec; -use client::{Client, EditPredictionUsage, UserStore}; -use cloud_llm_client::predict_edits_v3::{self, Event, PromptFormat}; -use cloud_llm_client::{ - AcceptEditPredictionBody, EXPIRED_LLM_TOKEN_HEADER_NAME, EditPredictionRejectReason, - EditPredictionRejection, MAX_EDIT_PREDICTION_REJECTIONS_PER_REQUEST, - MINIMUM_REQUIRED_VERSION_HEADER_NAME, PredictEditsRequestTrigger, RejectEditPredictionsBodyRef, - ZED_VERSION_HEADER_NAME, -}; -use cloud_zeta2_prompt::retrieval_prompt::{SearchToolInput, SearchToolQuery}; -use cloud_zeta2_prompt::{CURSOR_MARKER, DEFAULT_MAX_PROMPT_BYTES}; -use collections::{HashMap, HashSet}; -use command_palette_hooks::CommandPaletteFilter; -use db::kvp::{Dismissable, KEY_VALUE_STORE}; -use edit_prediction_context::{ - EditPredictionContextOptions, EditPredictionExcerpt, EditPredictionExcerptOptions, - EditPredictionScoreOptions, Line, SyntaxIndex, -}; -use edit_prediction_context2::{ - RelatedExcerpt, RelatedExcerptStore, RelatedExcerptStoreEvent, RelatedFile, -}; -use feature_flags::{FeatureFlag, FeatureFlagAppExt as _, PredictEditsRateCompletionsFeatureFlag}; -use futures::{ - AsyncReadExt as _, FutureExt as _, StreamExt as _, - channel::{ - mpsc::{self, UnboundedReceiver}, - oneshot, - }, - select_biased, -}; -use gpui::BackgroundExecutor; -use gpui::{ - App, AsyncApp, Entity, EntityId, Global, SharedString, Subscription, Task, WeakEntity, actions, - http_client::{self, AsyncBody, Method}, - prelude::*, -}; -use language::language_settings::all_language_settings; -use language::{ - Anchor, Buffer, DiagnosticSet, File, LanguageServerId, Point, ToOffset as _, ToPoint, -}; -use language::{BufferSnapshot, OffsetRangeExt}; -use language_model::{LlmApiToken, RefreshLlmTokenListener}; -use open_ai::FunctionDefinition; -use project::{DisableAiSettings, Project, ProjectItem as _, ProjectPath, WorktreeId}; -use release_channel::AppVersion; -use semver::Version; -use serde::de::DeserializeOwned; -use settings::{EditPredictionProvider, Settings, SettingsStore, update_settings_file}; -use std::any::{Any as _, TypeId}; -use std::collections::{VecDeque, hash_map}; -use telemetry_events::EditPredictionRating; -use workspace::Workspace; - -use std::ops::Range; -use std::path::Path; -use std::rc::Rc; -use std::str::FromStr as _; -use std::sync::{Arc, LazyLock}; -use std::time::{Duration, Instant}; -use std::{env, mem}; -use thiserror::Error; -use util::{LogErrorFuture, RangeExt as _, ResultExt as _, TryFutureExt}; -use workspace::notifications::{ErrorMessagePrompt, NotificationId, show_app_notification}; - -mod license_detection; -mod onboarding_modal; -mod prediction; -mod provider; -mod rate_prediction_modal; -pub mod retrieval_search; -pub mod sweep_ai; -pub mod udiff; -mod xml_edits; -pub mod zeta1; - -#[cfg(test)] -mod zeta_tests; - -use crate::license_detection::LicenseDetectionWatcher; -use crate::onboarding_modal::ZedPredictModal; -pub use crate::prediction::EditPrediction; -pub use crate::prediction::EditPredictionId; -pub use crate::prediction::EditPredictionInputs; -use crate::prediction::EditPredictionResult; -use crate::rate_prediction_modal::{ - NextEdit, PreviousEdit, RatePredictionsModal, ThumbsDownActivePrediction, - ThumbsUpActivePrediction, -}; -pub use crate::sweep_ai::SweepAi; -use crate::zeta1::request_prediction_with_zeta1; -pub use provider::ZetaEditPredictionProvider; - -actions!( - edit_prediction, - [ - /// Resets the edit prediction onboarding state. - ResetOnboarding, - /// Opens the rate completions modal. - RateCompletions, - /// Clears the edit prediction history. - ClearHistory, - ] -); - -/// Maximum number of events to track. -const EVENT_COUNT_MAX: usize = 6; -const CHANGE_GROUPING_LINE_SPAN: u32 = 8; -const ZED_PREDICT_DATA_COLLECTION_CHOICE: &str = "zed_predict_data_collection_choice"; -const REJECT_REQUEST_DEBOUNCE: Duration = Duration::from_secs(15); - -pub struct SweepFeatureFlag; - -impl FeatureFlag for SweepFeatureFlag { - const NAME: &str = "sweep-ai"; -} -pub const DEFAULT_EXCERPT_OPTIONS: EditPredictionExcerptOptions = EditPredictionExcerptOptions { - max_bytes: 512, - min_bytes: 128, - target_before_cursor_over_total_bytes: 0.5, -}; - -pub const DEFAULT_CONTEXT_OPTIONS: ContextMode = ContextMode::Lsp(DEFAULT_EXCERPT_OPTIONS); - -pub const DEFAULT_AGENTIC_CONTEXT_OPTIONS: AgenticContextOptions = AgenticContextOptions { - excerpt: DEFAULT_EXCERPT_OPTIONS, -}; - -pub const DEFAULT_SYNTAX_CONTEXT_OPTIONS: EditPredictionContextOptions = - EditPredictionContextOptions { - use_imports: true, - max_retrieved_declarations: 0, - excerpt: DEFAULT_EXCERPT_OPTIONS, - score: EditPredictionScoreOptions { - omit_excerpt_overlaps: true, - }, - }; - -pub const DEFAULT_OPTIONS: ZetaOptions = ZetaOptions { - context: DEFAULT_CONTEXT_OPTIONS, - max_prompt_bytes: DEFAULT_MAX_PROMPT_BYTES, - max_diagnostic_bytes: 2048, - prompt_format: PromptFormat::DEFAULT, - file_indexing_parallelism: 1, - buffer_change_grouping_interval: Duration::from_secs(1), -}; - -static USE_OLLAMA: LazyLock = - LazyLock::new(|| env::var("ZED_ZETA2_OLLAMA").is_ok_and(|var| !var.is_empty())); -static CONTEXT_RETRIEVAL_MODEL_ID: LazyLock = LazyLock::new(|| { - env::var("ZED_ZETA2_CONTEXT_MODEL").unwrap_or(if *USE_OLLAMA { - "qwen3-coder:30b".to_string() - } else { - "yqvev8r3".to_string() - }) -}); -static EDIT_PREDICTIONS_MODEL_ID: LazyLock = LazyLock::new(|| { - match env::var("ZED_ZETA2_MODEL").as_deref() { - Ok("zeta2-exp") => "4w5n28vw", // Fine-tuned model @ Baseten - Ok(model) => model, - Err(_) if *USE_OLLAMA => "qwen3-coder:30b", - Err(_) => "yqvev8r3", // Vanilla qwen3-coder @ Baseten - } - .to_string() -}); -static PREDICT_EDITS_URL: LazyLock> = LazyLock::new(|| { - env::var("ZED_PREDICT_EDITS_URL").ok().or_else(|| { - if *USE_OLLAMA { - Some("http://localhost:11434/v1/chat/completions".into()) - } else { - None - } - }) -}); - -pub struct Zeta2FeatureFlag; - -impl FeatureFlag for Zeta2FeatureFlag { - const NAME: &'static str = "zeta2"; - - fn enabled_for_staff() -> bool { - true - } -} - -#[derive(Clone)] -struct ZetaGlobal(Entity); - -impl Global for ZetaGlobal {} - -pub struct Zeta { - client: Arc, - user_store: Entity, - llm_token: LlmApiToken, - _llm_token_subscription: Subscription, - projects: HashMap, - use_context: bool, - options: ZetaOptions, - update_required: bool, - debug_tx: Option>, - #[cfg(feature = "eval-support")] - eval_cache: Option>, - edit_prediction_model: ZetaEditPredictionModel, - pub sweep_ai: SweepAi, - data_collection_choice: DataCollectionChoice, - reject_predictions_tx: mpsc::UnboundedSender, - shown_predictions: VecDeque, - rated_predictions: HashSet, -} - -#[derive(Copy, Clone, Default, PartialEq, Eq)] -pub enum ZetaEditPredictionModel { - #[default] - Zeta1, - Zeta2, - Sweep, -} - -#[derive(Debug, Clone, PartialEq)] -pub struct ZetaOptions { - pub context: ContextMode, - pub max_prompt_bytes: usize, - pub max_diagnostic_bytes: usize, - pub prompt_format: predict_edits_v3::PromptFormat, - pub file_indexing_parallelism: usize, - pub buffer_change_grouping_interval: Duration, -} - -#[derive(Debug, Clone, PartialEq)] -pub enum ContextMode { - Agentic(AgenticContextOptions), - Syntax(EditPredictionContextOptions), - Lsp(EditPredictionExcerptOptions), -} - -#[derive(Debug, Clone, PartialEq)] -pub struct AgenticContextOptions { - pub excerpt: EditPredictionExcerptOptions, -} - -impl ContextMode { - pub fn excerpt(&self) -> &EditPredictionExcerptOptions { - match self { - ContextMode::Agentic(options) => &options.excerpt, - ContextMode::Syntax(options) => &options.excerpt, - ContextMode::Lsp(options) => &options, - } - } -} - -#[derive(Debug)] -pub enum ZetaDebugInfo { - ContextRetrievalStarted(ZetaContextRetrievalStartedDebugInfo), - ContextRetrievalFinished(ZetaContextRetrievalFinishedDebugInfo), - EditPredictionRequested(ZetaEditPredictionDebugInfo), -} - -#[derive(Debug)] -pub struct ZetaContextRetrievalStartedDebugInfo { - pub project_entity_id: EntityId, - pub timestamp: Instant, - pub search_prompt: String, -} - -#[derive(Debug)] -pub struct ZetaContextRetrievalFinishedDebugInfo { - pub project_entity_id: EntityId, - pub timestamp: Instant, - pub metadata: Vec<(&'static str, SharedString)>, -} - -#[derive(Debug)] -pub struct ZetaEditPredictionDebugInfo { - pub inputs: EditPredictionInputs, - pub retrieval_time: Duration, - pub buffer: WeakEntity, - pub position: language::Anchor, - pub local_prompt: Result, - pub response_rx: oneshot::Receiver<(Result, Duration)>, -} - -pub type RequestDebugInfo = predict_edits_v3::DebugInfo; - -struct ZetaProject { - events: VecDeque>, - last_event: Option, - recent_paths: VecDeque, - registered_buffers: HashMap, - current_prediction: Option, - next_pending_prediction_id: usize, - pending_predictions: ArrayVec, - context_updates_tx: smol::channel::Sender<()>, - context_updates_rx: smol::channel::Receiver<()>, - last_prediction_refresh: Option<(EntityId, Instant)>, - cancelled_predictions: HashSet, - context: ZetaProjectContext, - license_detection_watchers: HashMap>, - _subscription: gpui::Subscription, -} - -enum ZetaProjectContext { - Syntax(Entity), - Lsp(Entity), - Agentic { - refresh_context_task: Option>>>, - refresh_context_debounce_task: Option>>, - refresh_context_timestamp: Option, - context: Vec, - }, -} - -impl ZetaProject { - pub fn events(&self, cx: &App) -> Vec> { - self.events - .iter() - .cloned() - .chain( - self.last_event - .as_ref() - .and_then(|event| event.finalize(&self.license_detection_watchers, cx)), - ) - .collect() - } - - fn cancel_pending_prediction( - &mut self, - pending_prediction: PendingPrediction, - cx: &mut Context, - ) { - self.cancelled_predictions.insert(pending_prediction.id); - - cx.spawn(async move |this, cx| { - let Some(prediction_id) = pending_prediction.task.await else { - return; - }; - - this.update(cx, |this, _cx| { - this.reject_prediction(prediction_id, EditPredictionRejectReason::Canceled, false); - }) - .ok(); - }) - .detach() - } -} - -#[derive(Debug, Clone)] -struct CurrentEditPrediction { - pub requested_by: PredictionRequestedBy, - pub prediction: EditPrediction, - pub was_shown: bool, -} - -impl CurrentEditPrediction { - fn should_replace_prediction(&self, old_prediction: &Self, cx: &App) -> bool { - let Some(new_edits) = self - .prediction - .interpolate(&self.prediction.buffer.read(cx)) - else { - return false; - }; - - if self.prediction.buffer != old_prediction.prediction.buffer { - return true; - } - - let Some(old_edits) = old_prediction - .prediction - .interpolate(&old_prediction.prediction.buffer.read(cx)) - else { - return true; - }; - - let requested_by_buffer_id = self.requested_by.buffer_id(); - - // This reduces the occurrence of UI thrash from replacing edits - // - // TODO: This is fairly arbitrary - should have a more general heuristic that handles multiple edits. - if requested_by_buffer_id == Some(self.prediction.buffer.entity_id()) - && requested_by_buffer_id == Some(old_prediction.prediction.buffer.entity_id()) - && old_edits.len() == 1 - && new_edits.len() == 1 - { - let (old_range, old_text) = &old_edits[0]; - let (new_range, new_text) = &new_edits[0]; - new_range == old_range && new_text.starts_with(old_text.as_ref()) - } else { - true - } - } -} - -#[derive(Debug, Clone)] -enum PredictionRequestedBy { - DiagnosticsUpdate, - Buffer(EntityId), -} - -impl PredictionRequestedBy { - pub fn buffer_id(&self) -> Option { - match self { - PredictionRequestedBy::DiagnosticsUpdate => None, - PredictionRequestedBy::Buffer(buffer_id) => Some(*buffer_id), - } - } -} - -#[derive(Debug)] -struct PendingPrediction { - id: usize, - task: Task>, -} - -/// A prediction from the perspective of a buffer. -#[derive(Debug)] -enum BufferEditPrediction<'a> { - Local { prediction: &'a EditPrediction }, - Jump { prediction: &'a EditPrediction }, -} - -#[cfg(test)] -impl std::ops::Deref for BufferEditPrediction<'_> { - type Target = EditPrediction; - - fn deref(&self) -> &Self::Target { - match self { - BufferEditPrediction::Local { prediction } => prediction, - BufferEditPrediction::Jump { prediction } => prediction, - } - } -} - -struct RegisteredBuffer { - snapshot: BufferSnapshot, - _subscriptions: [gpui::Subscription; 2], -} - -struct LastEvent { - old_snapshot: BufferSnapshot, - new_snapshot: BufferSnapshot, - end_edit_anchor: Option, -} - -impl LastEvent { - pub fn finalize( - &self, - license_detection_watchers: &HashMap>, - cx: &App, - ) -> Option> { - let path = buffer_path_with_id_fallback(&self.new_snapshot, cx); - let old_path = buffer_path_with_id_fallback(&self.old_snapshot, cx); - - let file = self.new_snapshot.file(); - let old_file = self.old_snapshot.file(); - - let in_open_source_repo = [file, old_file].iter().all(|file| { - file.is_some_and(|file| { - license_detection_watchers - .get(&file.worktree_id(cx)) - .is_some_and(|watcher| watcher.is_project_open_source()) - }) - }); - - let diff = language::unified_diff(&self.old_snapshot.text(), &self.new_snapshot.text()); - - if path == old_path && diff.is_empty() { - None - } else { - Some(Arc::new(predict_edits_v3::Event::BufferChange { - old_path, - path, - diff, - in_open_source_repo, - // TODO: Actually detect if this edit was predicted or not - predicted: false, - })) - } - } -} - -fn buffer_path_with_id_fallback(snapshot: &BufferSnapshot, cx: &App) -> Arc { - if let Some(file) = snapshot.file() { - file.full_path(cx).into() - } else { - Path::new(&format!("untitled-{}", snapshot.remote_id())).into() - } -} - -impl Zeta { - pub fn try_global(cx: &App) -> Option> { - cx.try_global::().map(|global| global.0.clone()) - } - - pub fn global( - client: &Arc, - user_store: &Entity, - cx: &mut App, - ) -> Entity { - cx.try_global::() - .map(|global| global.0.clone()) - .unwrap_or_else(|| { - let zeta = cx.new(|cx| Self::new(client.clone(), user_store.clone(), cx)); - cx.set_global(ZetaGlobal(zeta.clone())); - zeta - }) - } - - pub fn new(client: Arc, user_store: Entity, cx: &mut Context) -> Self { - let refresh_llm_token_listener = RefreshLlmTokenListener::global(cx); - let data_collection_choice = Self::load_data_collection_choice(); - - let llm_token = LlmApiToken::default(); - - let (reject_tx, reject_rx) = mpsc::unbounded(); - cx.background_spawn({ - let client = client.clone(); - let llm_token = llm_token.clone(); - let app_version = AppVersion::global(cx); - let background_executor = cx.background_executor().clone(); - async move { - Self::handle_rejected_predictions( - reject_rx, - client, - llm_token, - app_version, - background_executor, - ) - .await - } - }) - .detach(); - - let mut this = Self { - projects: HashMap::default(), - client, - user_store, - options: DEFAULT_OPTIONS, - use_context: false, - llm_token, - _llm_token_subscription: cx.subscribe( - &refresh_llm_token_listener, - |this, _listener, _event, cx| { - let client = this.client.clone(); - let llm_token = this.llm_token.clone(); - cx.spawn(async move |_this, _cx| { - llm_token.refresh(&client).await?; - anyhow::Ok(()) - }) - .detach_and_log_err(cx); - }, - ), - update_required: false, - debug_tx: None, - #[cfg(feature = "eval-support")] - eval_cache: None, - edit_prediction_model: ZetaEditPredictionModel::Zeta2, - sweep_ai: SweepAi::new(cx), - data_collection_choice, - reject_predictions_tx: reject_tx, - rated_predictions: Default::default(), - shown_predictions: Default::default(), - }; - - this.enable_or_disable_context_retrieval(cx); - let weak_this = cx.weak_entity(); - cx.on_flags_ready(move |_, cx| { - weak_this - .update(cx, |this, cx| this.enable_or_disable_context_retrieval(cx)) - .ok(); - }) - .detach(); - cx.observe_global::(|this, cx| { - this.enable_or_disable_context_retrieval(cx); - }) - .detach(); - - this - } - - pub fn set_edit_prediction_model(&mut self, model: ZetaEditPredictionModel) { - self.edit_prediction_model = model; - } - - pub fn has_sweep_api_token(&self) -> bool { - self.sweep_ai - .api_token - .clone() - .now_or_never() - .flatten() - .is_some() - } - - #[cfg(feature = "eval-support")] - pub fn with_eval_cache(&mut self, cache: Arc) { - self.eval_cache = Some(cache); - } - - pub fn debug_info(&mut self) -> mpsc::UnboundedReceiver { - let (debug_watch_tx, debug_watch_rx) = mpsc::unbounded(); - self.debug_tx = Some(debug_watch_tx); - debug_watch_rx - } - - pub fn options(&self) -> &ZetaOptions { - &self.options - } - - pub fn set_options(&mut self, options: ZetaOptions) { - self.options = options; - } - - pub fn set_use_context(&mut self, use_context: bool) { - self.use_context = use_context; - } - - pub fn clear_history(&mut self) { - for zeta_project in self.projects.values_mut() { - zeta_project.events.clear(); - } - } - - pub fn context_for_project<'a>( - &'a self, - project: &Entity, - cx: &'a App, - ) -> &'a [RelatedFile] { - self.projects - .get(&project.entity_id()) - .and_then(|project| match &project.context { - ZetaProjectContext::Syntax(_) => None, - ZetaProjectContext::Lsp(store) => Some(store.read(cx).related_files()), - ZetaProjectContext::Agentic { context, .. } => Some(context.as_slice()), - }) - .unwrap_or(&[]) - } - - pub fn usage(&self, cx: &App) -> Option { - if self.edit_prediction_model == ZetaEditPredictionModel::Zeta2 { - self.user_store.read(cx).edit_prediction_usage() - } else { - None - } - } - - pub fn register_project(&mut self, project: &Entity, cx: &mut Context) { - self.get_or_init_zeta_project(project, cx); - } - - pub fn register_buffer( - &mut self, - buffer: &Entity, - project: &Entity, - cx: &mut Context, - ) { - let zeta_project = self.get_or_init_zeta_project(project, cx); - Self::register_buffer_impl(zeta_project, buffer, project, cx); - } - - fn get_or_init_zeta_project( - &mut self, - project: &Entity, - cx: &mut Context, - ) -> &mut ZetaProject { - let entity_id = project.entity_id(); - let (context_updates_tx, context_updates_rx) = smol::channel::unbounded(); - self.projects - .entry(entity_id) - .or_insert_with(|| ZetaProject { - context: match &self.options.context { - ContextMode::Agentic(_) => ZetaProjectContext::Agentic { - refresh_context_task: None, - refresh_context_debounce_task: None, - refresh_context_timestamp: None, - context: Vec::new(), - }, - ContextMode::Syntax(_) => ZetaProjectContext::Syntax(cx.new(|cx| { - SyntaxIndex::new(project, self.options.file_indexing_parallelism, cx) - })), - ContextMode::Lsp(_) => { - let related_excerpt_store = - cx.new(|cx| RelatedExcerptStore::new(project, cx)); - cx.subscribe( - &related_excerpt_store, - move |this, _, event, _| match event { - RelatedExcerptStoreEvent::StartedRefresh => { - if let Some(debug_tx) = this.debug_tx.clone() { - debug_tx - .unbounded_send(ZetaDebugInfo::ContextRetrievalStarted( - ZetaContextRetrievalStartedDebugInfo { - project_entity_id: entity_id, - timestamp: Instant::now(), - search_prompt: String::new(), - }, - )) - .ok(); - } - } - RelatedExcerptStoreEvent::FinishedRefresh { - cache_hit_count, - cache_miss_count, - mean_definition_latency, - max_definition_latency, - } => { - if let Some(debug_tx) = this.debug_tx.clone() { - debug_tx - .unbounded_send( - ZetaDebugInfo::ContextRetrievalFinished( - ZetaContextRetrievalFinishedDebugInfo { - project_entity_id: entity_id, - timestamp: Instant::now(), - metadata: vec![ - ( - "Cache Hits", - format!( - "{}/{}", - cache_hit_count, - cache_hit_count - + cache_miss_count - ) - .into(), - ), - ( - "Max LSP Time", - format!( - "{} ms", - max_definition_latency - .as_millis() - ) - .into(), - ), - ( - "Mean LSP Time", - format!( - "{} ms", - mean_definition_latency - .as_millis() - ) - .into(), - ), - ], - }, - ), - ) - .ok(); - } - if let Some(project_state) = this.projects.get(&entity_id) { - project_state.context_updates_tx.send_blocking(()).ok(); - } - } - }, - ) - .detach(); - ZetaProjectContext::Lsp(related_excerpt_store) - } - }, - events: VecDeque::new(), - last_event: None, - recent_paths: VecDeque::new(), - context_updates_rx, - context_updates_tx, - registered_buffers: HashMap::default(), - current_prediction: None, - cancelled_predictions: HashSet::default(), - pending_predictions: ArrayVec::new(), - next_pending_prediction_id: 0, - last_prediction_refresh: None, - license_detection_watchers: HashMap::default(), - _subscription: cx.subscribe(&project, Self::handle_project_event), - }) - } - - pub fn project_context_updates( - &self, - project: &Entity, - ) -> Option> { - let project_state = self.projects.get(&project.entity_id())?; - Some(project_state.context_updates_rx.clone()) - } - - fn handle_project_event( - &mut self, - project: Entity, - event: &project::Event, - cx: &mut Context, - ) { - // TODO [zeta2] init with recent paths - match event { - project::Event::ActiveEntryChanged(Some(active_entry_id)) => { - let Some(zeta_project) = self.projects.get_mut(&project.entity_id()) else { - return; - }; - let path = project.read(cx).path_for_entry(*active_entry_id, cx); - if let Some(path) = path { - if let Some(ix) = zeta_project - .recent_paths - .iter() - .position(|probe| probe == &path) - { - zeta_project.recent_paths.remove(ix); - } - zeta_project.recent_paths.push_front(path); - } - } - project::Event::DiagnosticsUpdated { .. } => { - if cx.has_flag::() { - self.refresh_prediction_from_diagnostics(project, cx); - } - } - _ => (), - } - } - - fn register_buffer_impl<'a>( - zeta_project: &'a mut ZetaProject, - buffer: &Entity, - project: &Entity, - cx: &mut Context, - ) -> &'a mut RegisteredBuffer { - let buffer_id = buffer.entity_id(); - - if let Some(file) = buffer.read(cx).file() { - let worktree_id = file.worktree_id(cx); - if let Some(worktree) = project.read(cx).worktree_for_id(worktree_id, cx) { - zeta_project - .license_detection_watchers - .entry(worktree_id) - .or_insert_with(|| { - let project_entity_id = project.entity_id(); - cx.observe_release(&worktree, move |this, _worktree, _cx| { - let Some(zeta_project) = this.projects.get_mut(&project_entity_id) - else { - return; - }; - zeta_project.license_detection_watchers.remove(&worktree_id); - }) - .detach(); - Rc::new(LicenseDetectionWatcher::new(&worktree, cx)) - }); - } - } - - match zeta_project.registered_buffers.entry(buffer_id) { - hash_map::Entry::Occupied(entry) => entry.into_mut(), - hash_map::Entry::Vacant(entry) => { - let snapshot = buffer.read(cx).snapshot(); - let project_entity_id = project.entity_id(); - entry.insert(RegisteredBuffer { - snapshot, - _subscriptions: [ - cx.subscribe(buffer, { - let project = project.downgrade(); - move |this, buffer, event, cx| { - if let language::BufferEvent::Edited = event - && let Some(project) = project.upgrade() - { - this.report_changes_for_buffer(&buffer, &project, cx); - } - } - }), - cx.observe_release(buffer, move |this, _buffer, _cx| { - let Some(zeta_project) = this.projects.get_mut(&project_entity_id) - else { - return; - }; - zeta_project.registered_buffers.remove(&buffer_id); - }), - ], - }) - } - } - } - - fn report_changes_for_buffer( - &mut self, - buffer: &Entity, - project: &Entity, - cx: &mut Context, - ) { - let project_state = self.get_or_init_zeta_project(project, cx); - let registered_buffer = Self::register_buffer_impl(project_state, buffer, project, cx); - - let new_snapshot = buffer.read(cx).snapshot(); - if new_snapshot.version == registered_buffer.snapshot.version { - return; - } - - let old_snapshot = mem::replace(&mut registered_buffer.snapshot, new_snapshot.clone()); - let end_edit_anchor = new_snapshot - .anchored_edits_since::(&old_snapshot.version) - .last() - .map(|(_, range)| range.end); - let events = &mut project_state.events; - - if let Some(LastEvent { - new_snapshot: last_new_snapshot, - end_edit_anchor: last_end_edit_anchor, - .. - }) = project_state.last_event.as_mut() - { - let is_next_snapshot_of_same_buffer = old_snapshot.remote_id() - == last_new_snapshot.remote_id() - && old_snapshot.version == last_new_snapshot.version; - - let should_coalesce = is_next_snapshot_of_same_buffer - && end_edit_anchor - .as_ref() - .zip(last_end_edit_anchor.as_ref()) - .is_some_and(|(a, b)| { - let a = a.to_point(&new_snapshot); - let b = b.to_point(&new_snapshot); - a.row.abs_diff(b.row) <= CHANGE_GROUPING_LINE_SPAN - }); - - if should_coalesce { - *last_end_edit_anchor = end_edit_anchor; - *last_new_snapshot = new_snapshot; - return; - } - } - - if events.len() + 1 >= EVENT_COUNT_MAX { - events.pop_front(); - } - - if let Some(event) = project_state.last_event.take() { - events.extend(event.finalize(&project_state.license_detection_watchers, cx)); - } - - project_state.last_event = Some(LastEvent { - old_snapshot, - new_snapshot, - end_edit_anchor, - }); - } - - fn current_prediction_for_buffer( - &self, - buffer: &Entity, - project: &Entity, - cx: &App, - ) -> Option> { - let project_state = self.projects.get(&project.entity_id())?; - - let CurrentEditPrediction { - requested_by, - prediction, - .. - } = project_state.current_prediction.as_ref()?; - - if prediction.targets_buffer(buffer.read(cx)) { - Some(BufferEditPrediction::Local { prediction }) - } else { - let show_jump = match requested_by { - PredictionRequestedBy::Buffer(requested_by_buffer_id) => { - requested_by_buffer_id == &buffer.entity_id() - } - PredictionRequestedBy::DiagnosticsUpdate => true, - }; - - if show_jump { - Some(BufferEditPrediction::Jump { prediction }) - } else { - None - } - } - } - - fn accept_current_prediction(&mut self, project: &Entity, cx: &mut Context) { - match self.edit_prediction_model { - ZetaEditPredictionModel::Zeta1 | ZetaEditPredictionModel::Zeta2 => {} - ZetaEditPredictionModel::Sweep => return, - } - - let Some(project_state) = self.projects.get_mut(&project.entity_id()) else { - return; - }; - - let Some(prediction) = project_state.current_prediction.take() else { - return; - }; - let request_id = prediction.prediction.id.to_string(); - for pending_prediction in mem::take(&mut project_state.pending_predictions) { - project_state.cancel_pending_prediction(pending_prediction, cx); - } - - let client = self.client.clone(); - let llm_token = self.llm_token.clone(); - let app_version = AppVersion::global(cx); - cx.spawn(async move |this, cx| { - let url = if let Ok(predict_edits_url) = env::var("ZED_ACCEPT_PREDICTION_URL") { - http_client::Url::parse(&predict_edits_url)? - } else { - client - .http_client() - .build_zed_llm_url("/predict_edits/accept", &[])? - }; - - let response = cx - .background_spawn(Self::send_api_request::<()>( - move |builder| { - let req = builder.uri(url.as_ref()).body( - serde_json::to_string(&AcceptEditPredictionBody { - request_id: request_id.clone(), - })? - .into(), - ); - Ok(req?) - }, - client, - llm_token, - app_version, - )) - .await; - - Self::handle_api_response(&this, response, cx)?; - anyhow::Ok(()) - }) - .detach_and_log_err(cx); - } - - async fn handle_rejected_predictions( - rx: UnboundedReceiver, - client: Arc, - llm_token: LlmApiToken, - app_version: Version, - background_executor: BackgroundExecutor, - ) { - let mut rx = std::pin::pin!(rx.peekable()); - let mut batched = Vec::new(); - - while let Some(rejection) = rx.next().await { - batched.push(rejection); - - if batched.len() < MAX_EDIT_PREDICTION_REJECTIONS_PER_REQUEST / 2 { - select_biased! { - next = rx.as_mut().peek().fuse() => { - if next.is_some() { - continue; - } - } - () = background_executor.timer(REJECT_REQUEST_DEBOUNCE).fuse() => {}, - } - } - - let url = client - .http_client() - .build_zed_llm_url("/predict_edits/reject", &[]) - .unwrap(); - - let flush_count = batched - .len() - // in case items have accumulated after failure - .min(MAX_EDIT_PREDICTION_REJECTIONS_PER_REQUEST); - let start = batched.len() - flush_count; - - let body = RejectEditPredictionsBodyRef { - rejections: &batched[start..], - }; - - let result = Self::send_api_request::<()>( - |builder| { - let req = builder - .uri(url.as_ref()) - .body(serde_json::to_string(&body)?.into()); - anyhow::Ok(req?) - }, - client.clone(), - llm_token.clone(), - app_version.clone(), - ) - .await; - - if result.log_err().is_some() { - batched.drain(start..); - } - } - } - - fn reject_current_prediction( - &mut self, - reason: EditPredictionRejectReason, - project: &Entity, - ) { - if let Some(project_state) = self.projects.get_mut(&project.entity_id()) { - project_state.pending_predictions.clear(); - if let Some(prediction) = project_state.current_prediction.take() { - self.reject_prediction(prediction.prediction.id, reason, prediction.was_shown); - } - }; - } - - fn did_show_current_prediction(&mut self, project: &Entity, _cx: &mut Context) { - if let Some(project_state) = self.projects.get_mut(&project.entity_id()) { - if let Some(current_prediction) = project_state.current_prediction.as_mut() { - if !current_prediction.was_shown { - current_prediction.was_shown = true; - self.shown_predictions - .push_front(current_prediction.prediction.clone()); - if self.shown_predictions.len() > 50 { - let completion = self.shown_predictions.pop_back().unwrap(); - self.rated_predictions.remove(&completion.id); - } - } - } - } - } - - fn reject_prediction( - &mut self, - prediction_id: EditPredictionId, - reason: EditPredictionRejectReason, - was_shown: bool, - ) { - match self.edit_prediction_model { - ZetaEditPredictionModel::Zeta1 | ZetaEditPredictionModel::Zeta2 => {} - ZetaEditPredictionModel::Sweep => return, - } - - self.reject_predictions_tx - .unbounded_send(EditPredictionRejection { - request_id: prediction_id.to_string(), - reason, - was_shown, - }) - .log_err(); - } - - fn is_refreshing(&self, project: &Entity) -> bool { - self.projects - .get(&project.entity_id()) - .is_some_and(|project_state| !project_state.pending_predictions.is_empty()) - } - - pub fn refresh_prediction_from_buffer( - &mut self, - project: Entity, - buffer: Entity, - position: language::Anchor, - cx: &mut Context, - ) { - self.queue_prediction_refresh(project.clone(), buffer.entity_id(), cx, move |this, cx| { - let Some(request_task) = this - .update(cx, |this, cx| { - this.request_prediction( - &project, - &buffer, - position, - PredictEditsRequestTrigger::Other, - cx, - ) - }) - .log_err() - else { - return Task::ready(anyhow::Ok(None)); - }; - - cx.spawn(async move |_cx| { - request_task.await.map(|prediction_result| { - prediction_result.map(|prediction_result| { - ( - prediction_result, - PredictionRequestedBy::Buffer(buffer.entity_id()), - ) - }) - }) - }) - }) - } - - pub fn refresh_prediction_from_diagnostics( - &mut self, - project: Entity, - cx: &mut Context, - ) { - let Some(zeta_project) = self.projects.get_mut(&project.entity_id()) else { - return; - }; - - // Prefer predictions from buffer - if zeta_project.current_prediction.is_some() { - return; - }; - - self.queue_prediction_refresh(project.clone(), project.entity_id(), cx, move |this, cx| { - let Some(open_buffer_task) = project - .update(cx, |project, cx| { - project - .active_entry() - .and_then(|entry| project.path_for_entry(entry, cx)) - .map(|path| project.open_buffer(path, cx)) - }) - .log_err() - .flatten() - else { - return Task::ready(anyhow::Ok(None)); - }; - - cx.spawn(async move |cx| { - let active_buffer = open_buffer_task.await?; - let snapshot = active_buffer.read_with(cx, |buffer, _cx| buffer.snapshot())?; - - let Some((jump_buffer, jump_position)) = Self::next_diagnostic_location( - active_buffer, - &snapshot, - Default::default(), - Default::default(), - &project, - cx, - ) - .await? - else { - return anyhow::Ok(None); - }; - - let Some(prediction_result) = this - .update(cx, |this, cx| { - this.request_prediction( - &project, - &jump_buffer, - jump_position, - PredictEditsRequestTrigger::Diagnostics, - cx, - ) - })? - .await? - else { - return anyhow::Ok(None); - }; - - this.update(cx, |this, cx| { - Some(( - if this - .get_or_init_zeta_project(&project, cx) - .current_prediction - .is_none() - { - prediction_result - } else { - EditPredictionResult { - id: prediction_result.id, - prediction: Err(EditPredictionRejectReason::CurrentPreferred), - } - }, - PredictionRequestedBy::DiagnosticsUpdate, - )) - }) - }) - }); - } - - #[cfg(not(test))] - pub const THROTTLE_TIMEOUT: Duration = Duration::from_millis(300); - #[cfg(test)] - pub const THROTTLE_TIMEOUT: Duration = Duration::ZERO; - - fn queue_prediction_refresh( - &mut self, - project: Entity, - throttle_entity: EntityId, - cx: &mut Context, - do_refresh: impl FnOnce( - WeakEntity, - &mut AsyncApp, - ) - -> Task>> - + 'static, - ) { - let zeta_project = self.get_or_init_zeta_project(&project, cx); - let pending_prediction_id = zeta_project.next_pending_prediction_id; - zeta_project.next_pending_prediction_id += 1; - let last_request = zeta_project.last_prediction_refresh; - - let task = cx.spawn(async move |this, cx| { - if let Some((last_entity, last_timestamp)) = last_request - && throttle_entity == last_entity - && let Some(timeout) = - (last_timestamp + Self::THROTTLE_TIMEOUT).checked_duration_since(Instant::now()) - { - cx.background_executor().timer(timeout).await; - } - - // If this task was cancelled before the throttle timeout expired, - // do not perform a request. - let mut is_cancelled = true; - this.update(cx, |this, cx| { - let project_state = this.get_or_init_zeta_project(&project, cx); - if !project_state - .cancelled_predictions - .remove(&pending_prediction_id) - { - project_state.last_prediction_refresh = Some((throttle_entity, Instant::now())); - is_cancelled = false; - } - }) - .ok(); - if is_cancelled { - return None; - } - - let new_prediction_result = do_refresh(this.clone(), cx).await.log_err().flatten(); - let new_prediction_id = new_prediction_result - .as_ref() - .map(|(prediction, _)| prediction.id.clone()); - - // When a prediction completes, remove it from the pending list, and cancel - // any pending predictions that were enqueued before it. - this.update(cx, |this, cx| { - let zeta_project = this.get_or_init_zeta_project(&project, cx); - - let is_cancelled = zeta_project - .cancelled_predictions - .remove(&pending_prediction_id); - - let new_current_prediction = if !is_cancelled - && let Some((prediction_result, requested_by)) = new_prediction_result - { - match prediction_result.prediction { - Ok(prediction) => { - let new_prediction = CurrentEditPrediction { - requested_by, - prediction, - was_shown: false, - }; - - if let Some(current_prediction) = - zeta_project.current_prediction.as_ref() - { - if new_prediction.should_replace_prediction(¤t_prediction, cx) - { - this.reject_current_prediction( - EditPredictionRejectReason::Replaced, - &project, - ); - - Some(new_prediction) - } else { - this.reject_prediction( - new_prediction.prediction.id, - EditPredictionRejectReason::CurrentPreferred, - false, - ); - None - } - } else { - Some(new_prediction) - } - } - Err(reject_reason) => { - this.reject_prediction(prediction_result.id, reject_reason, false); - None - } - } - } else { - None - }; - - let zeta_project = this.get_or_init_zeta_project(&project, cx); - - if let Some(new_prediction) = new_current_prediction { - zeta_project.current_prediction = Some(new_prediction); - } - - let mut pending_predictions = mem::take(&mut zeta_project.pending_predictions); - for (ix, pending_prediction) in pending_predictions.iter().enumerate() { - if pending_prediction.id == pending_prediction_id { - pending_predictions.remove(ix); - for pending_prediction in pending_predictions.drain(0..ix) { - zeta_project.cancel_pending_prediction(pending_prediction, cx) - } - break; - } - } - this.get_or_init_zeta_project(&project, cx) - .pending_predictions = pending_predictions; - cx.notify(); - }) - .ok(); - - new_prediction_id - }); - - if zeta_project.pending_predictions.len() <= 1 { - zeta_project.pending_predictions.push(PendingPrediction { - id: pending_prediction_id, - task, - }); - } else if zeta_project.pending_predictions.len() == 2 { - let pending_prediction = zeta_project.pending_predictions.pop().unwrap(); - zeta_project.pending_predictions.push(PendingPrediction { - id: pending_prediction_id, - task, - }); - zeta_project.cancel_pending_prediction(pending_prediction, cx); - } - } - - pub fn request_prediction( - &mut self, - project: &Entity, - active_buffer: &Entity, - position: language::Anchor, - trigger: PredictEditsRequestTrigger, - cx: &mut Context, - ) -> Task>> { - self.request_prediction_internal( - project.clone(), - active_buffer.clone(), - position, - trigger, - cx.has_flag::(), - cx, - ) - } - - fn request_prediction_internal( - &mut self, - project: Entity, - active_buffer: Entity, - position: language::Anchor, - trigger: PredictEditsRequestTrigger, - allow_jump: bool, - cx: &mut Context, - ) -> Task>> { - const DIAGNOSTIC_LINES_RANGE: u32 = 20; - - self.get_or_init_zeta_project(&project, cx); - let zeta_project = self.projects.get(&project.entity_id()).unwrap(); - let events = zeta_project.events(cx); - let has_events = !events.is_empty(); - - let snapshot = active_buffer.read(cx).snapshot(); - let cursor_point = position.to_point(&snapshot); - let diagnostic_search_start = cursor_point.row.saturating_sub(DIAGNOSTIC_LINES_RANGE); - let diagnostic_search_end = cursor_point.row + DIAGNOSTIC_LINES_RANGE; - let diagnostic_search_range = - Point::new(diagnostic_search_start, 0)..Point::new(diagnostic_search_end, 0); - - let task = match self.edit_prediction_model { - ZetaEditPredictionModel::Zeta1 => request_prediction_with_zeta1( - self, - &project, - &active_buffer, - snapshot.clone(), - position, - events, - trigger, - cx, - ), - ZetaEditPredictionModel::Zeta2 => self.request_prediction_with_zeta2( - &project, - &active_buffer, - snapshot.clone(), - position, - events, - trigger, - cx, - ), - ZetaEditPredictionModel::Sweep => self.sweep_ai.request_prediction_with_sweep( - &project, - &active_buffer, - snapshot.clone(), - position, - events, - &zeta_project.recent_paths, - if self.use_context { - self.context_for_project(&project, cx).to_vec() - } else { - Vec::new() - }, - diagnostic_search_range.clone(), - cx, - ), - }; - - cx.spawn(async move |this, cx| { - let prediction = task.await?; - - if prediction.is_none() && allow_jump { - let cursor_point = position.to_point(&snapshot); - if has_events - && let Some((jump_buffer, jump_position)) = Self::next_diagnostic_location( - active_buffer.clone(), - &snapshot, - diagnostic_search_range, - cursor_point, - &project, - cx, - ) - .await? - { - return this - .update(cx, |this, cx| { - this.request_prediction_internal( - project, - jump_buffer, - jump_position, - trigger, - false, - cx, - ) - })? - .await; - } - - return anyhow::Ok(None); - } - - Ok(prediction) - }) - } - - async fn next_diagnostic_location( - active_buffer: Entity, - active_buffer_snapshot: &BufferSnapshot, - active_buffer_diagnostic_search_range: Range, - active_buffer_cursor_point: Point, - project: &Entity, - cx: &mut AsyncApp, - ) -> Result, language::Anchor)>> { - // find the closest diagnostic to the cursor that wasn't close enough to be included in the last request - let mut jump_location = active_buffer_snapshot - .diagnostic_groups(None) - .into_iter() - .filter_map(|(_, group)| { - let range = &group.entries[group.primary_ix] - .range - .to_point(&active_buffer_snapshot); - if range.overlaps(&active_buffer_diagnostic_search_range) { - None - } else { - Some(range.start) - } - }) - .min_by_key(|probe| probe.row.abs_diff(active_buffer_cursor_point.row)) - .map(|position| { - ( - active_buffer.clone(), - active_buffer_snapshot.anchor_before(position), - ) - }); - - if jump_location.is_none() { - let active_buffer_path = active_buffer.read_with(cx, |buffer, cx| { - let file = buffer.file()?; - - Some(ProjectPath { - worktree_id: file.worktree_id(cx), - path: file.path().clone(), - }) - })?; - - let buffer_task = project.update(cx, |project, cx| { - let (path, _, _) = project - .diagnostic_summaries(false, cx) - .filter(|(path, _, _)| Some(path) != active_buffer_path.as_ref()) - .max_by_key(|(path, _, _)| { - // find the buffer with errors that shares most parent directories - path.path - .components() - .zip( - active_buffer_path - .as_ref() - .map(|p| p.path.components()) - .unwrap_or_default(), - ) - .take_while(|(a, b)| a == b) - .count() - })?; - - Some(project.open_buffer(path, cx)) - })?; - - if let Some(buffer_task) = buffer_task { - let closest_buffer = buffer_task.await?; - - jump_location = closest_buffer - .read_with(cx, |buffer, _cx| { - buffer - .buffer_diagnostics(None) - .into_iter() - .min_by_key(|entry| entry.diagnostic.severity) - .map(|entry| entry.range.start) - })? - .map(|position| (closest_buffer, position)); - } - } - - anyhow::Ok(jump_location) - } - - fn request_prediction_with_zeta2( - &mut self, - project: &Entity, - active_buffer: &Entity, - active_snapshot: BufferSnapshot, - position: language::Anchor, - events: Vec>, - trigger: PredictEditsRequestTrigger, - cx: &mut Context, - ) -> Task>> { - let options = self.options.clone(); - let buffer_snapshotted_at = Instant::now(); - - let Some((excerpt_path, active_project_path)) = active_snapshot - .file() - .map(|file| -> Arc { file.full_path(cx).into() }) - .zip(active_buffer.read(cx).project_path(cx)) - else { - return Task::ready(Err(anyhow!("No file path for excerpt"))); - }; - - let client = self.client.clone(); - let llm_token = self.llm_token.clone(); - let app_version = AppVersion::global(cx); - let debug_tx = self.debug_tx.clone(); - - let diagnostics = active_snapshot.diagnostic_sets().clone(); - - let file = active_buffer.read(cx).file(); - - let active_file_full_path = file.as_ref().map(|f| f.full_path(cx)); - - // TODO data collection - let can_collect_data = file - .as_ref() - .map_or(false, |file| self.can_collect_file(project, file, cx)); - - let mut included_files = self.context_for_project(project, cx).to_vec(); - - #[cfg(feature = "eval-support")] - let eval_cache = self.eval_cache.clone(); - - let request_task = cx.background_spawn({ - let active_buffer = active_buffer.clone(); - async move { - let cursor_offset = position.to_offset(&active_snapshot); - let cursor_point = cursor_offset.to_point(&active_snapshot); - - let before_retrieval = Instant::now(); - - let (diagnostic_groups, diagnostic_groups_truncated) = - Self::gather_nearby_diagnostics( - cursor_offset, - &diagnostics, - &active_snapshot, - options.max_diagnostic_bytes, - ); - - let excerpt_options = options.context.excerpt(); - - let Some(excerpt) = EditPredictionExcerpt::select_from_buffer( - cursor_point, - &active_snapshot, - &excerpt_options, - None, - ) else { - return Ok((None, None)); - }; - - let excerpt_anchor_range = active_snapshot.anchor_after(excerpt.range.start) - ..active_snapshot.anchor_before(excerpt.range.end); - let related_excerpt = RelatedExcerpt { - anchor_range: excerpt_anchor_range.clone(), - point_range: Point::new(excerpt.line_range.start.0, 0) - ..Point::new(excerpt.line_range.end.0, 0), - text: active_snapshot.as_rope().slice(excerpt.range), - }; - - if let Some(buffer_ix) = included_files - .iter() - .position(|file| file.buffer.entity_id() == active_buffer.entity_id()) - { - let file = &mut included_files[buffer_ix]; - file.excerpts.push(related_excerpt); - file.merge_excerpts(); - let last_ix = included_files.len() - 1; - included_files.swap(buffer_ix, last_ix); - } else { - let active_file = RelatedFile { - path: active_project_path, - buffer: active_buffer.downgrade(), - excerpts: vec![related_excerpt], - max_row: active_snapshot.max_point().row, - }; - included_files.push(active_file); - } - - let included_files = included_files - .iter() - .map(|related_file| predict_edits_v3::IncludedFile { - path: Arc::from(related_file.path.path.as_std_path()), - max_row: Line(related_file.max_row), - excerpts: related_file - .excerpts - .iter() - .map(|excerpt| predict_edits_v3::Excerpt { - start_line: Line(excerpt.point_range.start.row), - text: excerpt.text.to_string().into(), - }) - .collect(), - }) - .collect::>(); - - let cloud_request = predict_edits_v3::PredictEditsRequest { - excerpt_path, - excerpt: String::new(), - excerpt_line_range: Line(0)..Line(0), - excerpt_range: 0..0, - cursor_point: predict_edits_v3::Point { - line: predict_edits_v3::Line(cursor_point.row), - column: cursor_point.column, - }, - included_files, - referenced_declarations: vec![], - events, - can_collect_data, - diagnostic_groups, - diagnostic_groups_truncated, - debug_info: debug_tx.is_some(), - prompt_max_bytes: Some(options.max_prompt_bytes), - prompt_format: options.prompt_format, - // TODO [zeta2] - signatures: vec![], - excerpt_parent: None, - git_info: None, - trigger, - }; - - let prompt_result = cloud_zeta2_prompt::build_prompt(&cloud_request); - - let inputs = EditPredictionInputs { - included_files: cloud_request.included_files, - events: cloud_request.events, - cursor_point: cloud_request.cursor_point, - cursor_path: cloud_request.excerpt_path, - }; - - let retrieval_time = Instant::now() - before_retrieval; - - let debug_response_tx = if let Some(debug_tx) = &debug_tx { - let (response_tx, response_rx) = oneshot::channel(); - - debug_tx - .unbounded_send(ZetaDebugInfo::EditPredictionRequested( - ZetaEditPredictionDebugInfo { - inputs: inputs.clone(), - retrieval_time, - buffer: active_buffer.downgrade(), - local_prompt: match prompt_result.as_ref() { - Ok((prompt, _)) => Ok(prompt.clone()), - Err(err) => Err(err.to_string()), - }, - position, - response_rx, - }, - )) - .ok(); - Some(response_tx) - } else { - None - }; - - if cfg!(debug_assertions) && env::var("ZED_ZETA2_SKIP_REQUEST").is_ok() { - if let Some(debug_response_tx) = debug_response_tx { - debug_response_tx - .send((Err("Request skipped".to_string()), Duration::ZERO)) - .ok(); - } - anyhow::bail!("Skipping request because ZED_ZETA2_SKIP_REQUEST is set") - } - - let (prompt, _) = prompt_result?; - let generation_params = - cloud_zeta2_prompt::generation_params(cloud_request.prompt_format); - let request = open_ai::Request { - model: EDIT_PREDICTIONS_MODEL_ID.clone(), - messages: vec![open_ai::RequestMessage::User { - content: open_ai::MessageContent::Plain(prompt), - }], - stream: false, - max_completion_tokens: None, - stop: generation_params.stop.unwrap_or_default(), - temperature: generation_params.temperature.unwrap_or(0.7), - tool_choice: None, - parallel_tool_calls: None, - tools: vec![], - prompt_cache_key: None, - reasoning_effort: None, - }; - - log::trace!("Sending edit prediction request"); - - let before_request = Instant::now(); - let response = Self::send_raw_llm_request( - request, - client, - llm_token, - app_version, - #[cfg(feature = "eval-support")] - eval_cache, - #[cfg(feature = "eval-support")] - EvalCacheEntryKind::Prediction, - ) - .await; - let received_response_at = Instant::now(); - let request_time = received_response_at - before_request; - - log::trace!("Got edit prediction response"); - - if let Some(debug_response_tx) = debug_response_tx { - debug_response_tx - .send(( - response - .as_ref() - .map_err(|err| err.to_string()) - .map(|response| response.0.clone()), - request_time, - )) - .ok(); - } - - let (res, usage) = response?; - let request_id = EditPredictionId(res.id.clone().into()); - let Some(mut output_text) = text_from_response(res) else { - return Ok((Some((request_id, None)), usage)); - }; - - if output_text.contains(CURSOR_MARKER) { - log::trace!("Stripping out {CURSOR_MARKER} from response"); - output_text = output_text.replace(CURSOR_MARKER, ""); - } - - let get_buffer_from_context = |path: &Path| { - if Some(path) == active_file_full_path.as_deref() { - Some(( - &active_snapshot, - std::slice::from_ref(&excerpt_anchor_range), - )) - } else { - None - } - }; - - let (_, edits) = match options.prompt_format { - PromptFormat::NumLinesUniDiff => { - // TODO: Implement parsing of multi-file diffs - crate::udiff::parse_diff(&output_text, get_buffer_from_context).await? - } - PromptFormat::Minimal - | PromptFormat::MinimalQwen - | PromptFormat::SeedCoder1120 => { - if output_text.contains("--- a/\n+++ b/\nNo edits") { - let edits = vec![]; - (&active_snapshot, edits) - } else { - crate::udiff::parse_diff(&output_text, get_buffer_from_context).await? - } - } - PromptFormat::OldTextNewText => { - crate::xml_edits::parse_xml_edits(&output_text, get_buffer_from_context) - .await? - } - _ => { - bail!("unsupported prompt format {}", options.prompt_format) - } - }; - - anyhow::Ok(( - Some(( - request_id, - Some(( - inputs, - active_buffer, - active_snapshot.clone(), - edits, - received_response_at, - )), - )), - usage, - )) - } - }); - - cx.spawn({ - async move |this, cx| { - let Some((id, prediction)) = - Self::handle_api_response(&this, request_task.await, cx)? - else { - return Ok(None); - }; - - let Some(( - inputs, - edited_buffer, - edited_buffer_snapshot, - edits, - received_response_at, - )) = prediction - else { - return Ok(Some(EditPredictionResult { - id, - prediction: Err(EditPredictionRejectReason::Empty), - })); - }; - - // TODO telemetry: duration, etc - Ok(Some( - EditPredictionResult::new( - id, - &edited_buffer, - &edited_buffer_snapshot, - edits.into(), - buffer_snapshotted_at, - received_response_at, - inputs, - cx, - ) - .await, - )) - } - }) - } - - async fn send_raw_llm_request( - request: open_ai::Request, - client: Arc, - llm_token: LlmApiToken, - app_version: Version, - #[cfg(feature = "eval-support")] eval_cache: Option>, - #[cfg(feature = "eval-support")] eval_cache_kind: EvalCacheEntryKind, - ) -> Result<(open_ai::Response, Option)> { - let url = if let Some(predict_edits_url) = PREDICT_EDITS_URL.as_ref() { - http_client::Url::parse(&predict_edits_url)? - } else { - client - .http_client() - .build_zed_llm_url("/predict_edits/raw", &[])? - }; - - #[cfg(feature = "eval-support")] - let cache_key = if let Some(cache) = eval_cache { - use collections::FxHasher; - use std::hash::{Hash, Hasher}; - - let mut hasher = FxHasher::default(); - url.hash(&mut hasher); - let request_str = serde_json::to_string_pretty(&request)?; - request_str.hash(&mut hasher); - let hash = hasher.finish(); - - let key = (eval_cache_kind, hash); - if let Some(response_str) = cache.read(key) { - return Ok((serde_json::from_str(&response_str)?, None)); - } - - Some((cache, request_str, key)) - } else { - None - }; - - let (response, usage) = Self::send_api_request( - |builder| { - let req = builder - .uri(url.as_ref()) - .body(serde_json::to_string(&request)?.into()); - Ok(req?) - }, - client, - llm_token, - app_version, - ) - .await?; - - #[cfg(feature = "eval-support")] - if let Some((cache, request, key)) = cache_key { - cache.write(key, &request, &serde_json::to_string_pretty(&response)?); - } - - Ok((response, usage)) - } - - fn handle_api_response( - this: &WeakEntity, - response: Result<(T, Option)>, - cx: &mut gpui::AsyncApp, - ) -> Result { - match response { - Ok((data, usage)) => { - if let Some(usage) = usage { - this.update(cx, |this, cx| { - this.user_store.update(cx, |user_store, cx| { - user_store.update_edit_prediction_usage(usage, cx); - }); - }) - .ok(); - } - Ok(data) - } - Err(err) => { - if err.is::() { - cx.update(|cx| { - this.update(cx, |this, _cx| { - this.update_required = true; - }) - .ok(); - - let error_message: SharedString = err.to_string().into(); - show_app_notification( - NotificationId::unique::(), - cx, - move |cx| { - cx.new(|cx| { - ErrorMessagePrompt::new(error_message.clone(), cx) - .with_link_button("Update Zed", "https://zed.dev/releases") - }) - }, - ); - }) - .ok(); - } - Err(err) - } - } - } - - async fn send_api_request( - build: impl Fn(http_client::http::request::Builder) -> Result>, - client: Arc, - llm_token: LlmApiToken, - app_version: Version, - ) -> Result<(Res, Option)> - where - Res: DeserializeOwned, - { - let http_client = client.http_client(); - let mut token = llm_token.acquire(&client).await?; - let mut did_retry = false; - - loop { - let request_builder = http_client::Request::builder().method(Method::POST); - - let request = build( - request_builder - .header("Content-Type", "application/json") - .header("Authorization", format!("Bearer {}", token)) - .header(ZED_VERSION_HEADER_NAME, app_version.to_string()), - )?; - - let mut response = http_client.send(request).await?; - - if let Some(minimum_required_version) = response - .headers() - .get(MINIMUM_REQUIRED_VERSION_HEADER_NAME) - .and_then(|version| Version::from_str(version.to_str().ok()?).ok()) - { - anyhow::ensure!( - app_version >= minimum_required_version, - ZedUpdateRequiredError { - minimum_version: minimum_required_version - } - ); - } - - if response.status().is_success() { - let usage = EditPredictionUsage::from_headers(response.headers()).ok(); - - let mut body = Vec::new(); - response.body_mut().read_to_end(&mut body).await?; - return Ok((serde_json::from_slice(&body)?, usage)); - } else if !did_retry - && response - .headers() - .get(EXPIRED_LLM_TOKEN_HEADER_NAME) - .is_some() - { - did_retry = true; - token = llm_token.refresh(&client).await?; - } else { - let mut body = String::new(); - response.body_mut().read_to_string(&mut body).await?; - anyhow::bail!( - "Request failed with status: {:?}\nBody: {}", - response.status(), - body - ); - } - } - } - - pub const CONTEXT_RETRIEVAL_IDLE_DURATION: Duration = Duration::from_secs(10); - pub const CONTEXT_RETRIEVAL_DEBOUNCE_DURATION: Duration = Duration::from_secs(3); - - pub fn refresh_context_if_needed( - &mut self, - project: &Entity, - buffer: &Entity, - cursor_position: language::Anchor, - cx: &mut Context, - ) { - if !self.use_context { - return; - } - let Some(zeta_project) = self.projects.get_mut(&project.entity_id()) else { - return; - }; - - match &mut zeta_project.context { - ZetaProjectContext::Syntax(_entity) => {} - ZetaProjectContext::Lsp(related_excerpt_store) => { - related_excerpt_store.update(cx, |store, cx| { - store.refresh(buffer.clone(), cursor_position, cx); - }); - } - ZetaProjectContext::Agentic { - refresh_context_debounce_task, - refresh_context_timestamp, - .. - } => { - let now = Instant::now(); - let was_idle = refresh_context_timestamp.map_or(true, |timestamp| { - now - timestamp > Self::CONTEXT_RETRIEVAL_IDLE_DURATION - }); - *refresh_context_timestamp = Some(now); - *refresh_context_debounce_task = Some(cx.spawn({ - let buffer = buffer.clone(); - let project = project.clone(); - async move |this, cx| { - if was_idle { - log::debug!("refetching edit prediction context after idle"); - } else { - cx.background_executor() - .timer(Self::CONTEXT_RETRIEVAL_DEBOUNCE_DURATION) - .await; - log::debug!("refetching edit prediction context after pause"); - } - this.update(cx, |this, cx| { - let task = this.refresh_context_with_agentic_retrieval( - project.clone(), - buffer, - cursor_position, - cx, - ); - - if let Some(zeta_project) = this.projects.get_mut(&project.entity_id()) - { - if let ZetaProjectContext::Agentic { - refresh_context_task, - .. - } = &mut zeta_project.context - { - *refresh_context_task = Some(task.log_err()); - } - }; - }) - .ok() - } - })); - } - } - } - - // Refresh the related excerpts asynchronously. Ensure the task runs to completion, - // and avoid spawning more than one concurrent task. - pub fn refresh_context_with_agentic_retrieval( - &mut self, - project: Entity, - buffer: Entity, - cursor_position: language::Anchor, - cx: &mut Context, - ) -> Task> { - let Some(zeta_project) = self.projects.get(&project.entity_id()) else { - return Task::ready(anyhow::Ok(())); - }; - - let ContextMode::Agentic(options) = &self.options().context else { - return Task::ready(anyhow::Ok(())); - }; - - let snapshot = buffer.read(cx).snapshot(); - let cursor_point = cursor_position.to_point(&snapshot); - let Some(cursor_excerpt) = EditPredictionExcerpt::select_from_buffer( - cursor_point, - &snapshot, - &options.excerpt, - None, - ) else { - return Task::ready(Ok(())); - }; - - let app_version = AppVersion::global(cx); - let client = self.client.clone(); - let llm_token = self.llm_token.clone(); - let debug_tx = self.debug_tx.clone(); - let current_file_path: Arc = snapshot - .file() - .map(|f| f.full_path(cx).into()) - .unwrap_or_else(|| Path::new("untitled").into()); - - let prompt = match cloud_zeta2_prompt::retrieval_prompt::build_prompt( - predict_edits_v3::PlanContextRetrievalRequest { - excerpt: cursor_excerpt.text(&snapshot).body, - excerpt_path: current_file_path, - excerpt_line_range: cursor_excerpt.line_range, - cursor_file_max_row: Line(snapshot.max_point().row), - events: zeta_project.events(cx), - }, - ) { - Ok(prompt) => prompt, - Err(err) => { - return Task::ready(Err(err)); - } - }; - - let retrieval_started_at = Instant::now(); - - if let Some(debug_tx) = &debug_tx { - debug_tx - .unbounded_send(ZetaDebugInfo::ContextRetrievalStarted( - ZetaContextRetrievalStartedDebugInfo { - project_entity_id: project.entity_id(), - timestamp: retrieval_started_at, - search_prompt: prompt.clone(), - }, - )) - .ok(); - } - - pub static TOOL_SCHEMA: LazyLock<(serde_json::Value, String)> = LazyLock::new(|| { - let schema = language_model::tool_schema::root_schema_for::( - language_model::LanguageModelToolSchemaFormat::JsonSchemaSubset, - ); - - let description = schema - .get("description") - .and_then(|description| description.as_str()) - .unwrap() - .to_string(); - - (schema.into(), description) - }); - - let (tool_schema, tool_description) = TOOL_SCHEMA.clone(); - - let request = open_ai::Request { - model: CONTEXT_RETRIEVAL_MODEL_ID.clone(), - messages: vec![open_ai::RequestMessage::User { - content: open_ai::MessageContent::Plain(prompt), - }], - stream: false, - max_completion_tokens: None, - stop: Default::default(), - temperature: 0.7, - tool_choice: None, - parallel_tool_calls: None, - tools: vec![open_ai::ToolDefinition::Function { - function: FunctionDefinition { - name: cloud_zeta2_prompt::retrieval_prompt::TOOL_NAME.to_string(), - description: Some(tool_description), - parameters: Some(tool_schema), - }, - }], - prompt_cache_key: None, - reasoning_effort: None, - }; - - #[cfg(feature = "eval-support")] - let eval_cache = self.eval_cache.clone(); - - cx.spawn(async move |this, cx| { - log::trace!("Sending search planning request"); - let response = Self::send_raw_llm_request( - request, - client, - llm_token, - app_version, - #[cfg(feature = "eval-support")] - eval_cache.clone(), - #[cfg(feature = "eval-support")] - EvalCacheEntryKind::Context, - ) - .await; - let mut response = Self::handle_api_response(&this, response, cx)?; - log::trace!("Got search planning response"); - - let choice = response - .choices - .pop() - .context("No choices in retrieval response")?; - let open_ai::RequestMessage::Assistant { - content: _, - tool_calls, - } = choice.message - else { - anyhow::bail!("Retrieval response didn't include an assistant message"); - }; - - let mut queries: Vec = Vec::new(); - for tool_call in tool_calls { - let open_ai::ToolCallContent::Function { function } = tool_call.content; - if function.name != cloud_zeta2_prompt::retrieval_prompt::TOOL_NAME { - log::warn!( - "Context retrieval response tried to call an unknown tool: {}", - function.name - ); - - continue; - } - - let input: SearchToolInput = serde_json::from_str(&function.arguments) - .with_context(|| format!("invalid search json {}", &function.arguments))?; - queries.extend(input.queries); - } - - log::trace!("Running retrieval search: {queries:#?}"); - let query_generation_finished_at = Instant::now(); - - let related_excerpts_result = retrieval_search::run_retrieval_searches( - queries, - project.clone(), - #[cfg(feature = "eval-support")] - eval_cache, - cx, - ) - .await; - - log::trace!("Search queries executed"); - let query_execution_finished_at = Instant::now(); - - this.update(cx, |this, _cx| { - let Some(zeta_project) = this.projects.get_mut(&project.entity_id()) else { - return Ok(()); - }; - if let ZetaProjectContext::Agentic { - refresh_context_task, - context, - .. - } = &mut zeta_project.context - { - refresh_context_task.take(); - if let Some(debug_tx) = &this.debug_tx { - debug_tx - .unbounded_send(ZetaDebugInfo::ContextRetrievalFinished( - ZetaContextRetrievalFinishedDebugInfo { - project_entity_id: project.entity_id(), - timestamp: Instant::now(), - metadata: vec![ - ( - "query_generation", - format!( - "{:?}", - query_generation_finished_at - retrieval_started_at - ) - .into(), - ), - ( - "search_execution", - format!( - "{:?}", - query_execution_finished_at - - query_generation_finished_at - ) - .into(), - ), - ], - }, - )) - .ok(); - } - match related_excerpts_result { - Ok(excerpts) => { - *context = excerpts; - Ok(()) - } - Err(error) => Err(error), - } - } else { - Ok(()) - } - })? - }) - } - - fn gather_nearby_diagnostics( - cursor_offset: usize, - diagnostic_sets: &[(LanguageServerId, DiagnosticSet)], - snapshot: &BufferSnapshot, - max_diagnostics_bytes: usize, - ) -> (Vec, bool) { - // TODO: Could make this more efficient - let mut diagnostic_groups = Vec::new(); - for (language_server_id, diagnostics) in diagnostic_sets { - let mut groups = Vec::new(); - diagnostics.groups(*language_server_id, &mut groups, &snapshot); - diagnostic_groups.extend( - groups - .into_iter() - .map(|(_, group)| group.resolve::(&snapshot)), - ); - } - - // sort by proximity to cursor - diagnostic_groups.sort_by_key(|group| { - let range = &group.entries[group.primary_ix].range; - if range.start >= cursor_offset { - range.start - cursor_offset - } else if cursor_offset >= range.end { - cursor_offset - range.end - } else { - (cursor_offset - range.start).min(range.end - cursor_offset) - } - }); - - let mut results = Vec::new(); - let mut diagnostic_groups_truncated = false; - let mut diagnostics_byte_count = 0; - for group in diagnostic_groups { - let raw_value = serde_json::value::to_raw_value(&group).unwrap(); - diagnostics_byte_count += raw_value.get().len(); - if diagnostics_byte_count > max_diagnostics_bytes { - diagnostic_groups_truncated = true; - break; - } - results.push(predict_edits_v3::DiagnosticGroup(raw_value)); - } - - (results, diagnostic_groups_truncated) - } - - pub fn wait_for_initial_indexing( - &mut self, - project: &Entity, - cx: &mut Context, - ) -> Task> { - let zeta_project = self.get_or_init_zeta_project(project, cx); - if let ZetaProjectContext::Syntax(syntax_index) = &zeta_project.context { - syntax_index.read(cx).wait_for_initial_file_indexing(cx) - } else { - Task::ready(Ok(())) - } - } - - fn is_file_open_source( - &self, - project: &Entity, - file: &Arc, - cx: &App, - ) -> bool { - if !file.is_local() || file.is_private() { - return false; - } - let Some(zeta_project) = self.projects.get(&project.entity_id()) else { - return false; - }; - zeta_project - .license_detection_watchers - .get(&file.worktree_id(cx)) - .as_ref() - .is_some_and(|watcher| watcher.is_project_open_source()) - } - - fn can_collect_file(&self, project: &Entity, file: &Arc, cx: &App) -> bool { - self.data_collection_choice.is_enabled() && self.is_file_open_source(project, file, cx) - } - - fn can_collect_events(&self, events: &[Arc]) -> bool { - if !self.data_collection_choice.is_enabled() { - return false; - } - events.iter().all(|event| { - matches!( - event.as_ref(), - Event::BufferChange { - in_open_source_repo: true, - .. - } - ) - }) - } - - fn load_data_collection_choice() -> DataCollectionChoice { - let choice = KEY_VALUE_STORE - .read_kvp(ZED_PREDICT_DATA_COLLECTION_CHOICE) - .log_err() - .flatten(); - - match choice.as_deref() { - Some("true") => DataCollectionChoice::Enabled, - Some("false") => DataCollectionChoice::Disabled, - Some(_) => { - log::error!("unknown value in '{ZED_PREDICT_DATA_COLLECTION_CHOICE}'"); - DataCollectionChoice::NotAnswered - } - None => DataCollectionChoice::NotAnswered, - } - } - - pub fn shown_predictions(&self) -> impl DoubleEndedIterator { - self.shown_predictions.iter() - } - - pub fn shown_completions_len(&self) -> usize { - self.shown_predictions.len() - } - - pub fn is_prediction_rated(&self, id: &EditPredictionId) -> bool { - self.rated_predictions.contains(id) - } - - pub fn rate_prediction( - &mut self, - prediction: &EditPrediction, - rating: EditPredictionRating, - feedback: String, - cx: &mut Context, - ) { - self.rated_predictions.insert(prediction.id.clone()); - telemetry::event!( - "Edit Prediction Rated", - rating, - inputs = prediction.inputs, - output = prediction.edit_preview.as_unified_diff(&prediction.edits), - feedback - ); - self.client.telemetry().flush_events().detach(); - cx.notify(); - } - - fn enable_or_disable_context_retrieval(&mut self, cx: &mut Context<'_, Zeta>) { - self.use_context = cx.has_flag::() - && all_language_settings(None, cx).edit_predictions.use_context; - } -} - -pub fn text_from_response(mut res: open_ai::Response) -> Option { - let choice = res.choices.pop()?; - let output_text = match choice.message { - open_ai::RequestMessage::Assistant { - content: Some(open_ai::MessageContent::Plain(content)), - .. - } => content, - open_ai::RequestMessage::Assistant { - content: Some(open_ai::MessageContent::Multipart(mut content)), - .. - } => { - if content.is_empty() { - log::error!("No output from Baseten completion response"); - return None; - } - - match content.remove(0) { - open_ai::MessagePart::Text { text } => text, - open_ai::MessagePart::Image { .. } => { - log::error!("Expected text, got an image"); - return None; - } - } - } - _ => { - log::error!("Invalid response message: {:?}", choice.message); - return None; - } - }; - Some(output_text) -} - -#[derive(Error, Debug)] -#[error( - "You must update to Zed version {minimum_version} or higher to continue using edit predictions." -)] -pub struct ZedUpdateRequiredError { - minimum_version: Version, -} - -#[cfg(feature = "eval-support")] -pub type EvalCacheKey = (EvalCacheEntryKind, u64); - -#[cfg(feature = "eval-support")] -#[derive(Debug, Clone, Copy, PartialEq)] -pub enum EvalCacheEntryKind { - Context, - Search, - Prediction, -} - -#[cfg(feature = "eval-support")] -impl std::fmt::Display for EvalCacheEntryKind { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - EvalCacheEntryKind::Search => write!(f, "search"), - EvalCacheEntryKind::Context => write!(f, "context"), - EvalCacheEntryKind::Prediction => write!(f, "prediction"), - } - } -} - -#[cfg(feature = "eval-support")] -pub trait EvalCache: Send + Sync { - fn read(&self, key: EvalCacheKey) -> Option; - fn write(&self, key: EvalCacheKey, input: &str, value: &str); -} - -#[derive(Debug, Clone, Copy)] -pub enum DataCollectionChoice { - NotAnswered, - Enabled, - Disabled, -} - -impl DataCollectionChoice { - pub fn is_enabled(self) -> bool { - match self { - Self::Enabled => true, - Self::NotAnswered | Self::Disabled => false, - } - } - - pub fn is_answered(self) -> bool { - match self { - Self::Enabled | Self::Disabled => true, - Self::NotAnswered => false, - } - } - - #[must_use] - pub fn toggle(&self) -> DataCollectionChoice { - match self { - Self::Enabled => Self::Disabled, - Self::Disabled => Self::Enabled, - Self::NotAnswered => Self::Enabled, - } - } -} - -impl From for DataCollectionChoice { - fn from(value: bool) -> Self { - match value { - true => DataCollectionChoice::Enabled, - false => DataCollectionChoice::Disabled, - } - } -} - -struct ZedPredictUpsell; - -impl Dismissable for ZedPredictUpsell { - const KEY: &'static str = "dismissed-edit-predict-upsell"; - - fn dismissed() -> bool { - // To make this backwards compatible with older versions of Zed, we - // check if the user has seen the previous Edit Prediction Onboarding - // before, by checking the data collection choice which was written to - // the database once the user clicked on "Accept and Enable" - if KEY_VALUE_STORE - .read_kvp(ZED_PREDICT_DATA_COLLECTION_CHOICE) - .log_err() - .is_some_and(|s| s.is_some()) - { - return true; - } - - KEY_VALUE_STORE - .read_kvp(Self::KEY) - .log_err() - .is_some_and(|s| s.is_some()) - } -} - -pub fn should_show_upsell_modal() -> bool { - !ZedPredictUpsell::dismissed() -} - -pub fn init(cx: &mut App) { - feature_gate_predict_edits_actions(cx); - - cx.observe_new(move |workspace: &mut Workspace, _, _cx| { - workspace.register_action(|workspace, _: &RateCompletions, window, cx| { - if cx.has_flag::() { - RatePredictionsModal::toggle(workspace, window, cx); - } - }); - - workspace.register_action( - move |workspace, _: &zed_actions::OpenZedPredictOnboarding, window, cx| { - ZedPredictModal::toggle( - workspace, - workspace.user_store().clone(), - workspace.client().clone(), - window, - cx, - ) - }, - ); - - workspace.register_action(|workspace, _: &ResetOnboarding, _window, cx| { - update_settings_file(workspace.app_state().fs.clone(), cx, move |settings, _| { - settings - .project - .all_languages - .features - .get_or_insert_default() - .edit_prediction_provider = Some(EditPredictionProvider::None) - }); - }); - }) - .detach(); -} - -fn feature_gate_predict_edits_actions(cx: &mut App) { - let rate_completion_action_types = [TypeId::of::()]; - let reset_onboarding_action_types = [TypeId::of::()]; - let zeta_all_action_types = [ - TypeId::of::(), - TypeId::of::(), - zed_actions::OpenZedPredictOnboarding.type_id(), - TypeId::of::(), - TypeId::of::(), - TypeId::of::(), - TypeId::of::(), - TypeId::of::(), - ]; - - CommandPaletteFilter::update_global(cx, |filter, _cx| { - filter.hide_action_types(&rate_completion_action_types); - filter.hide_action_types(&reset_onboarding_action_types); - filter.hide_action_types(&[zed_actions::OpenZedPredictOnboarding.type_id()]); - }); - - cx.observe_global::(move |cx| { - let is_ai_disabled = DisableAiSettings::get_global(cx).disable_ai; - let has_feature_flag = cx.has_flag::(); - - CommandPaletteFilter::update_global(cx, |filter, _cx| { - if is_ai_disabled { - filter.hide_action_types(&zeta_all_action_types); - } else if has_feature_flag { - filter.show_action_types(&rate_completion_action_types); - } else { - filter.hide_action_types(&rate_completion_action_types); - } - }); - }) - .detach(); - - cx.observe_flag::(move |is_enabled, cx| { - if !DisableAiSettings::get_global(cx).disable_ai { - if is_enabled { - CommandPaletteFilter::update_global(cx, |filter, _cx| { - filter.show_action_types(&rate_completion_action_types); - }); - } else { - CommandPaletteFilter::update_global(cx, |filter, _cx| { - filter.hide_action_types(&rate_completion_action_types); - }); - } - } - }) - .detach(); -} - -#[cfg(test)] -mod tests { - use std::{path::Path, sync::Arc, time::Duration}; - - use client::UserStore; - use clock::FakeSystemClock; - use cloud_llm_client::{ - EditPredictionRejectReason, EditPredictionRejection, RejectEditPredictionsBody, - }; - use futures::{ - AsyncReadExt, StreamExt, - channel::{mpsc, oneshot}, - }; - use gpui::{ - Entity, TestAppContext, - http_client::{FakeHttpClient, Response}, - prelude::*, - }; - use indoc::indoc; - use language::OffsetRangeExt as _; - use lsp::LanguageServerId; - use open_ai::Usage; - use pretty_assertions::{assert_eq, assert_matches}; - use project::{FakeFs, Project}; - use serde_json::json; - use settings::SettingsStore; - use util::path; - use uuid::Uuid; - - use crate::{BufferEditPrediction, EditPredictionId, REJECT_REQUEST_DEBOUNCE, Zeta}; - - #[gpui::test] - async fn test_current_state(cx: &mut TestAppContext) { - let (zeta, mut requests) = init_test(cx); - let fs = FakeFs::new(cx.executor()); - fs.insert_tree( - "/root", - json!({ - "1.txt": "Hello!\nHow\nBye\n", - "2.txt": "Hola!\nComo\nAdios\n" - }), - ) - .await; - let project = Project::test(fs, vec![path!("/root").as_ref()], cx).await; - - zeta.update(cx, |zeta, cx| { - zeta.register_project(&project, cx); - }); - - let buffer1 = project - .update(cx, |project, cx| { - let path = project.find_project_path(path!("/root/1.txt"), cx).unwrap(); - project.set_active_path(Some(path.clone()), cx); - project.open_buffer(path, cx) - }) - .await - .unwrap(); - let snapshot1 = buffer1.read_with(cx, |buffer, _cx| buffer.snapshot()); - let position = snapshot1.anchor_before(language::Point::new(1, 3)); - - // Prediction for current file - - zeta.update(cx, |zeta, cx| { - zeta.refresh_prediction_from_buffer(project.clone(), buffer1.clone(), position, cx) - }); - let (_request, respond_tx) = requests.predict.next().await.unwrap(); - - respond_tx - .send(model_response(indoc! {r" - --- a/root/1.txt - +++ b/root/1.txt - @@ ... @@ - Hello! - -How - +How are you? - Bye - "})) - .unwrap(); - - cx.run_until_parked(); - - zeta.read_with(cx, |zeta, cx| { - let prediction = zeta - .current_prediction_for_buffer(&buffer1, &project, cx) - .unwrap(); - assert_matches!(prediction, BufferEditPrediction::Local { .. }); - }); - - zeta.update(cx, |zeta, _cx| { - zeta.reject_current_prediction(EditPredictionRejectReason::Discarded, &project); - }); - - // Prediction for diagnostic in another file - - let diagnostic = lsp::Diagnostic { - range: lsp::Range::new(lsp::Position::new(1, 1), lsp::Position::new(1, 5)), - severity: Some(lsp::DiagnosticSeverity::ERROR), - message: "Sentence is incomplete".to_string(), - ..Default::default() - }; - - project.update(cx, |project, cx| { - project.lsp_store().update(cx, |lsp_store, cx| { - lsp_store - .update_diagnostics( - LanguageServerId(0), - lsp::PublishDiagnosticsParams { - uri: lsp::Uri::from_file_path(path!("/root/2.txt")).unwrap(), - diagnostics: vec![diagnostic], - version: None, - }, - None, - language::DiagnosticSourceKind::Pushed, - &[], - cx, - ) - .unwrap(); - }); - }); - - let (_request, respond_tx) = requests.predict.next().await.unwrap(); - respond_tx - .send(model_response(indoc! {r#" - --- a/root/2.txt - +++ b/root/2.txt - Hola! - -Como - +Como estas? - Adios - "#})) - .unwrap(); - cx.run_until_parked(); - - zeta.read_with(cx, |zeta, cx| { - let prediction = zeta - .current_prediction_for_buffer(&buffer1, &project, cx) - .unwrap(); - assert_matches!( - prediction, - BufferEditPrediction::Jump { prediction } if prediction.snapshot.file().unwrap().full_path(cx) == Path::new(path!("root/2.txt")) - ); - }); - - let buffer2 = project - .update(cx, |project, cx| { - let path = project.find_project_path(path!("root/2.txt"), cx).unwrap(); - project.open_buffer(path, cx) - }) - .await - .unwrap(); - - zeta.read_with(cx, |zeta, cx| { - let prediction = zeta - .current_prediction_for_buffer(&buffer2, &project, cx) - .unwrap(); - assert_matches!(prediction, BufferEditPrediction::Local { .. }); - }); - } - - #[gpui::test] - async fn test_simple_request(cx: &mut TestAppContext) { - let (zeta, mut requests) = init_test(cx); - let fs = FakeFs::new(cx.executor()); - fs.insert_tree( - "/root", - json!({ - "foo.md": "Hello!\nHow\nBye\n" - }), - ) - .await; - let project = Project::test(fs, vec![path!("/root").as_ref()], cx).await; - - let buffer = project - .update(cx, |project, cx| { - let path = project.find_project_path(path!("root/foo.md"), cx).unwrap(); - project.open_buffer(path, cx) - }) - .await - .unwrap(); - let snapshot = buffer.read_with(cx, |buffer, _cx| buffer.snapshot()); - let position = snapshot.anchor_before(language::Point::new(1, 3)); - - let prediction_task = zeta.update(cx, |zeta, cx| { - zeta.request_prediction(&project, &buffer, position, Default::default(), cx) - }); - - let (_, respond_tx) = requests.predict.next().await.unwrap(); - - // TODO Put back when we have a structured request again - // assert_eq!( - // request.excerpt_path.as_ref(), - // Path::new(path!("root/foo.md")) - // ); - // assert_eq!( - // request.cursor_point, - // Point { - // line: Line(1), - // column: 3 - // } - // ); - - respond_tx - .send(model_response(indoc! { r" - --- a/root/foo.md - +++ b/root/foo.md - @@ ... @@ - Hello! - -How - +How are you? - Bye - "})) - .unwrap(); - - let prediction = prediction_task.await.unwrap().unwrap().prediction.unwrap(); - - assert_eq!(prediction.edits.len(), 1); - assert_eq!( - prediction.edits[0].0.to_point(&snapshot).start, - language::Point::new(1, 3) - ); - assert_eq!(prediction.edits[0].1.as_ref(), " are you?"); - } - - #[gpui::test] - async fn test_request_events(cx: &mut TestAppContext) { - let (zeta, mut requests) = init_test(cx); - let fs = FakeFs::new(cx.executor()); - fs.insert_tree( - "/root", - json!({ - "foo.md": "Hello!\n\nBye\n" - }), - ) - .await; - let project = Project::test(fs, vec![path!("/root").as_ref()], cx).await; - - let buffer = project - .update(cx, |project, cx| { - let path = project.find_project_path(path!("root/foo.md"), cx).unwrap(); - project.open_buffer(path, cx) - }) - .await - .unwrap(); - - zeta.update(cx, |zeta, cx| { - zeta.register_buffer(&buffer, &project, cx); - }); - - buffer.update(cx, |buffer, cx| { - buffer.edit(vec![(7..7, "How")], None, cx); - }); - - let snapshot = buffer.read_with(cx, |buffer, _cx| buffer.snapshot()); - let position = snapshot.anchor_before(language::Point::new(1, 3)); - - let prediction_task = zeta.update(cx, |zeta, cx| { - zeta.request_prediction(&project, &buffer, position, Default::default(), cx) - }); - - let (request, respond_tx) = requests.predict.next().await.unwrap(); - - let prompt = prompt_from_request(&request); - assert!( - prompt.contains(indoc! {" - --- a/root/foo.md - +++ b/root/foo.md - @@ -1,3 +1,3 @@ - Hello! - - - +How - Bye - "}), - "{prompt}" - ); - - respond_tx - .send(model_response(indoc! {r#" - --- a/root/foo.md - +++ b/root/foo.md - @@ ... @@ - Hello! - -How - +How are you? - Bye - "#})) - .unwrap(); - - let prediction = prediction_task.await.unwrap().unwrap().prediction.unwrap(); - - assert_eq!(prediction.edits.len(), 1); - assert_eq!( - prediction.edits[0].0.to_point(&snapshot).start, - language::Point::new(1, 3) - ); - assert_eq!(prediction.edits[0].1.as_ref(), " are you?"); - } - - #[gpui::test] - async fn test_empty_prediction(cx: &mut TestAppContext) { - let (zeta, mut requests) = init_test(cx); - let fs = FakeFs::new(cx.executor()); - fs.insert_tree( - "/root", - json!({ - "foo.md": "Hello!\nHow\nBye\n" - }), - ) - .await; - let project = Project::test(fs, vec![path!("/root").as_ref()], cx).await; - - let buffer = project - .update(cx, |project, cx| { - let path = project.find_project_path(path!("root/foo.md"), cx).unwrap(); - project.open_buffer(path, cx) - }) - .await - .unwrap(); - let snapshot = buffer.read_with(cx, |buffer, _cx| buffer.snapshot()); - let position = snapshot.anchor_before(language::Point::new(1, 3)); - - zeta.update(cx, |zeta, cx| { - zeta.refresh_prediction_from_buffer(project.clone(), buffer.clone(), position, cx); - }); - - const NO_OP_DIFF: &str = indoc! { r" - --- a/root/foo.md - +++ b/root/foo.md - @@ ... @@ - Hello! - -How - +How - Bye - "}; - - let (_, respond_tx) = requests.predict.next().await.unwrap(); - let response = model_response(NO_OP_DIFF); - let id = response.id.clone(); - respond_tx.send(response).unwrap(); - - cx.run_until_parked(); - - zeta.read_with(cx, |zeta, cx| { - assert!( - zeta.current_prediction_for_buffer(&buffer, &project, cx) - .is_none() - ); - }); - - // prediction is reported as rejected - let (reject_request, _) = requests.reject.next().await.unwrap(); - - assert_eq!( - &reject_request.rejections, - &[EditPredictionRejection { - request_id: id, - reason: EditPredictionRejectReason::Empty, - was_shown: false - }] - ); - } - - #[gpui::test] - async fn test_interpolated_empty(cx: &mut TestAppContext) { - let (zeta, mut requests) = init_test(cx); - let fs = FakeFs::new(cx.executor()); - fs.insert_tree( - "/root", - json!({ - "foo.md": "Hello!\nHow\nBye\n" - }), - ) - .await; - let project = Project::test(fs, vec![path!("/root").as_ref()], cx).await; - - let buffer = project - .update(cx, |project, cx| { - let path = project.find_project_path(path!("root/foo.md"), cx).unwrap(); - project.open_buffer(path, cx) - }) - .await - .unwrap(); - let snapshot = buffer.read_with(cx, |buffer, _cx| buffer.snapshot()); - let position = snapshot.anchor_before(language::Point::new(1, 3)); - - zeta.update(cx, |zeta, cx| { - zeta.refresh_prediction_from_buffer(project.clone(), buffer.clone(), position, cx); - }); - - let (_, respond_tx) = requests.predict.next().await.unwrap(); - - buffer.update(cx, |buffer, cx| { - buffer.set_text("Hello!\nHow are you?\nBye", cx); - }); - - let response = model_response(SIMPLE_DIFF); - let id = response.id.clone(); - respond_tx.send(response).unwrap(); - - cx.run_until_parked(); - - zeta.read_with(cx, |zeta, cx| { - assert!( - zeta.current_prediction_for_buffer(&buffer, &project, cx) - .is_none() - ); - }); - - // prediction is reported as rejected - let (reject_request, _) = requests.reject.next().await.unwrap(); - - assert_eq!( - &reject_request.rejections, - &[EditPredictionRejection { - request_id: id, - reason: EditPredictionRejectReason::InterpolatedEmpty, - was_shown: false - }] - ); - } - - const SIMPLE_DIFF: &str = indoc! { r" - --- a/root/foo.md - +++ b/root/foo.md - @@ ... @@ - Hello! - -How - +How are you? - Bye - "}; - - #[gpui::test] - async fn test_replace_current(cx: &mut TestAppContext) { - let (zeta, mut requests) = init_test(cx); - let fs = FakeFs::new(cx.executor()); - fs.insert_tree( - "/root", - json!({ - "foo.md": "Hello!\nHow\nBye\n" - }), - ) - .await; - let project = Project::test(fs, vec![path!("/root").as_ref()], cx).await; - - let buffer = project - .update(cx, |project, cx| { - let path = project.find_project_path(path!("root/foo.md"), cx).unwrap(); - project.open_buffer(path, cx) - }) - .await - .unwrap(); - let snapshot = buffer.read_with(cx, |buffer, _cx| buffer.snapshot()); - let position = snapshot.anchor_before(language::Point::new(1, 3)); - - zeta.update(cx, |zeta, cx| { - zeta.refresh_prediction_from_buffer(project.clone(), buffer.clone(), position, cx); - }); - - let (_, respond_tx) = requests.predict.next().await.unwrap(); - let first_response = model_response(SIMPLE_DIFF); - let first_id = first_response.id.clone(); - respond_tx.send(first_response).unwrap(); - - cx.run_until_parked(); - - zeta.read_with(cx, |zeta, cx| { - assert_eq!( - zeta.current_prediction_for_buffer(&buffer, &project, cx) - .unwrap() - .id - .0, - first_id - ); - }); - - // a second request is triggered - zeta.update(cx, |zeta, cx| { - zeta.refresh_prediction_from_buffer(project.clone(), buffer.clone(), position, cx); - }); - - let (_, respond_tx) = requests.predict.next().await.unwrap(); - let second_response = model_response(SIMPLE_DIFF); - let second_id = second_response.id.clone(); - respond_tx.send(second_response).unwrap(); - - cx.run_until_parked(); - - zeta.read_with(cx, |zeta, cx| { - // second replaces first - assert_eq!( - zeta.current_prediction_for_buffer(&buffer, &project, cx) - .unwrap() - .id - .0, - second_id - ); - }); - - // first is reported as replaced - let (reject_request, _) = requests.reject.next().await.unwrap(); - - assert_eq!( - &reject_request.rejections, - &[EditPredictionRejection { - request_id: first_id, - reason: EditPredictionRejectReason::Replaced, - was_shown: false - }] - ); - } - - #[gpui::test] - async fn test_current_preferred(cx: &mut TestAppContext) { - let (zeta, mut requests) = init_test(cx); - let fs = FakeFs::new(cx.executor()); - fs.insert_tree( - "/root", - json!({ - "foo.md": "Hello!\nHow\nBye\n" - }), - ) - .await; - let project = Project::test(fs, vec![path!("/root").as_ref()], cx).await; - - let buffer = project - .update(cx, |project, cx| { - let path = project.find_project_path(path!("root/foo.md"), cx).unwrap(); - project.open_buffer(path, cx) - }) - .await - .unwrap(); - let snapshot = buffer.read_with(cx, |buffer, _cx| buffer.snapshot()); - let position = snapshot.anchor_before(language::Point::new(1, 3)); - - zeta.update(cx, |zeta, cx| { - zeta.refresh_prediction_from_buffer(project.clone(), buffer.clone(), position, cx); - }); - - let (_, respond_tx) = requests.predict.next().await.unwrap(); - let first_response = model_response(SIMPLE_DIFF); - let first_id = first_response.id.clone(); - respond_tx.send(first_response).unwrap(); - - cx.run_until_parked(); - - zeta.read_with(cx, |zeta, cx| { - assert_eq!( - zeta.current_prediction_for_buffer(&buffer, &project, cx) - .unwrap() - .id - .0, - first_id - ); - }); - - // a second request is triggered - zeta.update(cx, |zeta, cx| { - zeta.refresh_prediction_from_buffer(project.clone(), buffer.clone(), position, cx); - }); - - let (_, respond_tx) = requests.predict.next().await.unwrap(); - // worse than current prediction - let second_response = model_response(indoc! { r" - --- a/root/foo.md - +++ b/root/foo.md - @@ ... @@ - Hello! - -How - +How are - Bye - "}); - let second_id = second_response.id.clone(); - respond_tx.send(second_response).unwrap(); - - cx.run_until_parked(); - - zeta.read_with(cx, |zeta, cx| { - // first is preferred over second - assert_eq!( - zeta.current_prediction_for_buffer(&buffer, &project, cx) - .unwrap() - .id - .0, - first_id - ); - }); - - // second is reported as rejected - let (reject_request, _) = requests.reject.next().await.unwrap(); - - assert_eq!( - &reject_request.rejections, - &[EditPredictionRejection { - request_id: second_id, - reason: EditPredictionRejectReason::CurrentPreferred, - was_shown: false - }] - ); - } - - #[gpui::test] - async fn test_cancel_earlier_pending_requests(cx: &mut TestAppContext) { - let (zeta, mut requests) = init_test(cx); - let fs = FakeFs::new(cx.executor()); - fs.insert_tree( - "/root", - json!({ - "foo.md": "Hello!\nHow\nBye\n" - }), - ) - .await; - let project = Project::test(fs, vec![path!("/root").as_ref()], cx).await; - - let buffer = project - .update(cx, |project, cx| { - let path = project.find_project_path(path!("root/foo.md"), cx).unwrap(); - project.open_buffer(path, cx) - }) - .await - .unwrap(); - let snapshot = buffer.read_with(cx, |buffer, _cx| buffer.snapshot()); - let position = snapshot.anchor_before(language::Point::new(1, 3)); - - // start two refresh tasks - zeta.update(cx, |zeta, cx| { - zeta.refresh_prediction_from_buffer(project.clone(), buffer.clone(), position, cx); - }); - - let (_, respond_first) = requests.predict.next().await.unwrap(); - - zeta.update(cx, |zeta, cx| { - zeta.refresh_prediction_from_buffer(project.clone(), buffer.clone(), position, cx); - }); - - let (_, respond_second) = requests.predict.next().await.unwrap(); - - // wait for throttle - cx.run_until_parked(); - - // second responds first - let second_response = model_response(SIMPLE_DIFF); - let second_id = second_response.id.clone(); - respond_second.send(second_response).unwrap(); - - cx.run_until_parked(); - - zeta.read_with(cx, |zeta, cx| { - // current prediction is second - assert_eq!( - zeta.current_prediction_for_buffer(&buffer, &project, cx) - .unwrap() - .id - .0, - second_id - ); - }); - - let first_response = model_response(SIMPLE_DIFF); - let first_id = first_response.id.clone(); - respond_first.send(first_response).unwrap(); - - cx.run_until_parked(); - - zeta.read_with(cx, |zeta, cx| { - // current prediction is still second, since first was cancelled - assert_eq!( - zeta.current_prediction_for_buffer(&buffer, &project, cx) - .unwrap() - .id - .0, - second_id - ); - }); - - // first is reported as rejected - let (reject_request, _) = requests.reject.next().await.unwrap(); - - cx.run_until_parked(); - - assert_eq!( - &reject_request.rejections, - &[EditPredictionRejection { - request_id: first_id, - reason: EditPredictionRejectReason::Canceled, - was_shown: false - }] - ); - } - - #[gpui::test] - async fn test_cancel_second_on_third_request(cx: &mut TestAppContext) { - let (zeta, mut requests) = init_test(cx); - let fs = FakeFs::new(cx.executor()); - fs.insert_tree( - "/root", - json!({ - "foo.md": "Hello!\nHow\nBye\n" - }), - ) - .await; - let project = Project::test(fs, vec![path!("/root").as_ref()], cx).await; - - let buffer = project - .update(cx, |project, cx| { - let path = project.find_project_path(path!("root/foo.md"), cx).unwrap(); - project.open_buffer(path, cx) - }) - .await - .unwrap(); - let snapshot = buffer.read_with(cx, |buffer, _cx| buffer.snapshot()); - let position = snapshot.anchor_before(language::Point::new(1, 3)); - - // start two refresh tasks - zeta.update(cx, |zeta, cx| { - zeta.refresh_prediction_from_buffer(project.clone(), buffer.clone(), position, cx); - }); - - let (_, respond_first) = requests.predict.next().await.unwrap(); - - zeta.update(cx, |zeta, cx| { - zeta.refresh_prediction_from_buffer(project.clone(), buffer.clone(), position, cx); - }); - - let (_, respond_second) = requests.predict.next().await.unwrap(); - - // wait for throttle, so requests are sent - cx.run_until_parked(); - - zeta.update(cx, |zeta, cx| { - // start a third request - zeta.refresh_prediction_from_buffer(project.clone(), buffer.clone(), position, cx); - - // 2 are pending, so 2nd is cancelled - assert_eq!( - zeta.get_or_init_zeta_project(&project, cx) - .cancelled_predictions - .iter() - .copied() - .collect::>(), - [1] - ); - }); - - // wait for throttle - cx.run_until_parked(); - - let (_, respond_third) = requests.predict.next().await.unwrap(); - - let first_response = model_response(SIMPLE_DIFF); - let first_id = first_response.id.clone(); - respond_first.send(first_response).unwrap(); - - cx.run_until_parked(); - - zeta.read_with(cx, |zeta, cx| { - // current prediction is first - assert_eq!( - zeta.current_prediction_for_buffer(&buffer, &project, cx) - .unwrap() - .id - .0, - first_id - ); - }); - - let cancelled_response = model_response(SIMPLE_DIFF); - let cancelled_id = cancelled_response.id.clone(); - respond_second.send(cancelled_response).unwrap(); - - cx.run_until_parked(); - - zeta.read_with(cx, |zeta, cx| { - // current prediction is still first, since second was cancelled - assert_eq!( - zeta.current_prediction_for_buffer(&buffer, &project, cx) - .unwrap() - .id - .0, - first_id - ); - }); - - let third_response = model_response(SIMPLE_DIFF); - let third_response_id = third_response.id.clone(); - respond_third.send(third_response).unwrap(); - - cx.run_until_parked(); - - zeta.read_with(cx, |zeta, cx| { - // third completes and replaces first - assert_eq!( - zeta.current_prediction_for_buffer(&buffer, &project, cx) - .unwrap() - .id - .0, - third_response_id - ); - }); - - // second is reported as rejected - let (reject_request, _) = requests.reject.next().await.unwrap(); - - cx.run_until_parked(); - - assert_eq!( - &reject_request.rejections, - &[ - EditPredictionRejection { - request_id: cancelled_id, - reason: EditPredictionRejectReason::Canceled, - was_shown: false - }, - EditPredictionRejection { - request_id: first_id, - reason: EditPredictionRejectReason::Replaced, - was_shown: false - } - ] - ); - } - - #[gpui::test] - async fn test_rejections_flushing(cx: &mut TestAppContext) { - let (zeta, mut requests) = init_test(cx); - - zeta.update(cx, |zeta, _cx| { - zeta.reject_prediction( - EditPredictionId("test-1".into()), - EditPredictionRejectReason::Discarded, - false, - ); - zeta.reject_prediction( - EditPredictionId("test-2".into()), - EditPredictionRejectReason::Canceled, - true, - ); - }); - - cx.executor().advance_clock(REJECT_REQUEST_DEBOUNCE); - cx.run_until_parked(); - - let (reject_request, respond_tx) = requests.reject.next().await.unwrap(); - respond_tx.send(()).unwrap(); - - // batched - assert_eq!(reject_request.rejections.len(), 2); - assert_eq!( - reject_request.rejections[0], - EditPredictionRejection { - request_id: "test-1".to_string(), - reason: EditPredictionRejectReason::Discarded, - was_shown: false - } - ); - assert_eq!( - reject_request.rejections[1], - EditPredictionRejection { - request_id: "test-2".to_string(), - reason: EditPredictionRejectReason::Canceled, - was_shown: true - } - ); - - // Reaching batch size limit sends without debounce - zeta.update(cx, |zeta, _cx| { - for i in 0..70 { - zeta.reject_prediction( - EditPredictionId(format!("batch-{}", i).into()), - EditPredictionRejectReason::Discarded, - false, - ); - } - }); - - // First MAX/2 items are sent immediately - cx.run_until_parked(); - let (reject_request, respond_tx) = requests.reject.next().await.unwrap(); - respond_tx.send(()).unwrap(); - - assert_eq!(reject_request.rejections.len(), 50); - assert_eq!(reject_request.rejections[0].request_id, "batch-0"); - assert_eq!(reject_request.rejections[49].request_id, "batch-49"); - - // Remaining items are debounced with the next batch - cx.executor().advance_clock(Duration::from_secs(15)); - cx.run_until_parked(); - - let (reject_request, respond_tx) = requests.reject.next().await.unwrap(); - respond_tx.send(()).unwrap(); - - assert_eq!(reject_request.rejections.len(), 20); - assert_eq!(reject_request.rejections[0].request_id, "batch-50"); - assert_eq!(reject_request.rejections[19].request_id, "batch-69"); - - // Request failure - zeta.update(cx, |zeta, _cx| { - zeta.reject_prediction( - EditPredictionId("retry-1".into()), - EditPredictionRejectReason::Discarded, - false, - ); - }); - - cx.executor().advance_clock(REJECT_REQUEST_DEBOUNCE); - cx.run_until_parked(); - - let (reject_request, _respond_tx) = requests.reject.next().await.unwrap(); - assert_eq!(reject_request.rejections.len(), 1); - assert_eq!(reject_request.rejections[0].request_id, "retry-1"); - // Simulate failure - drop(_respond_tx); - - // Add another rejection - zeta.update(cx, |zeta, _cx| { - zeta.reject_prediction( - EditPredictionId("retry-2".into()), - EditPredictionRejectReason::Discarded, - false, - ); - }); - - cx.executor().advance_clock(REJECT_REQUEST_DEBOUNCE); - cx.run_until_parked(); - - // Retry should include both the failed item and the new one - let (reject_request, respond_tx) = requests.reject.next().await.unwrap(); - respond_tx.send(()).unwrap(); - - assert_eq!(reject_request.rejections.len(), 2); - assert_eq!(reject_request.rejections[0].request_id, "retry-1"); - assert_eq!(reject_request.rejections[1].request_id, "retry-2"); - } - - // Skipped until we start including diagnostics in prompt - // #[gpui::test] - // async fn test_request_diagnostics(cx: &mut TestAppContext) { - // let (zeta, mut req_rx) = init_test(cx); - // let fs = FakeFs::new(cx.executor()); - // fs.insert_tree( - // "/root", - // json!({ - // "foo.md": "Hello!\nBye" - // }), - // ) - // .await; - // let project = Project::test(fs, vec![path!("/root").as_ref()], cx).await; - - // let path_to_buffer_uri = lsp::Uri::from_file_path(path!("/root/foo.md")).unwrap(); - // let diagnostic = lsp::Diagnostic { - // range: lsp::Range::new(lsp::Position::new(1, 1), lsp::Position::new(1, 5)), - // severity: Some(lsp::DiagnosticSeverity::ERROR), - // message: "\"Hello\" deprecated. Use \"Hi\" instead".to_string(), - // ..Default::default() - // }; - - // project.update(cx, |project, cx| { - // project.lsp_store().update(cx, |lsp_store, cx| { - // // Create some diagnostics - // lsp_store - // .update_diagnostics( - // LanguageServerId(0), - // lsp::PublishDiagnosticsParams { - // uri: path_to_buffer_uri.clone(), - // diagnostics: vec![diagnostic], - // version: None, - // }, - // None, - // language::DiagnosticSourceKind::Pushed, - // &[], - // cx, - // ) - // .unwrap(); - // }); - // }); - - // let buffer = project - // .update(cx, |project, cx| { - // let path = project.find_project_path(path!("root/foo.md"), cx).unwrap(); - // project.open_buffer(path, cx) - // }) - // .await - // .unwrap(); - - // let snapshot = buffer.read_with(cx, |buffer, _cx| buffer.snapshot()); - // let position = snapshot.anchor_before(language::Point::new(0, 0)); - - // let _prediction_task = zeta.update(cx, |zeta, cx| { - // zeta.request_prediction(&project, &buffer, position, cx) - // }); - - // let (request, _respond_tx) = req_rx.next().await.unwrap(); - - // assert_eq!(request.diagnostic_groups.len(), 1); - // let value = serde_json::from_str::(request.diagnostic_groups[0].0.get()) - // .unwrap(); - // // We probably don't need all of this. TODO define a specific diagnostic type in predict_edits_v3 - // assert_eq!( - // value, - // json!({ - // "entries": [{ - // "range": { - // "start": 8, - // "end": 10 - // }, - // "diagnostic": { - // "source": null, - // "code": null, - // "code_description": null, - // "severity": 1, - // "message": "\"Hello\" deprecated. Use \"Hi\" instead", - // "markdown": null, - // "group_id": 0, - // "is_primary": true, - // "is_disk_based": false, - // "is_unnecessary": false, - // "source_kind": "Pushed", - // "data": null, - // "underline": true - // } - // }], - // "primary_ix": 0 - // }) - // ); - // } - - fn model_response(text: &str) -> open_ai::Response { - open_ai::Response { - id: Uuid::new_v4().to_string(), - object: "response".into(), - created: 0, - model: "model".into(), - choices: vec![open_ai::Choice { - index: 0, - message: open_ai::RequestMessage::Assistant { - content: Some(open_ai::MessageContent::Plain(text.to_string())), - tool_calls: vec![], - }, - finish_reason: None, - }], - usage: Usage { - prompt_tokens: 0, - completion_tokens: 0, - total_tokens: 0, - }, - } - } - - fn prompt_from_request(request: &open_ai::Request) -> &str { - assert_eq!(request.messages.len(), 1); - let open_ai::RequestMessage::User { - content: open_ai::MessageContent::Plain(content), - .. - } = &request.messages[0] - else { - panic!( - "Request does not have single user message of type Plain. {:#?}", - request - ); - }; - content - } - - struct RequestChannels { - predict: mpsc::UnboundedReceiver<(open_ai::Request, oneshot::Sender)>, - reject: mpsc::UnboundedReceiver<(RejectEditPredictionsBody, oneshot::Sender<()>)>, - } - - fn init_test(cx: &mut TestAppContext) -> (Entity, RequestChannels) { - cx.update(move |cx| { - let settings_store = SettingsStore::test(cx); - cx.set_global(settings_store); - zlog::init_test(); - - let (predict_req_tx, predict_req_rx) = mpsc::unbounded(); - let (reject_req_tx, reject_req_rx) = mpsc::unbounded(); - - let http_client = FakeHttpClient::create({ - move |req| { - let uri = req.uri().path().to_string(); - let mut body = req.into_body(); - let predict_req_tx = predict_req_tx.clone(); - let reject_req_tx = reject_req_tx.clone(); - async move { - let resp = match uri.as_str() { - "/client/llm_tokens" => serde_json::to_string(&json!({ - "token": "test" - })) - .unwrap(), - "/predict_edits/raw" => { - let mut buf = Vec::new(); - body.read_to_end(&mut buf).await.ok(); - let req = serde_json::from_slice(&buf).unwrap(); - let (res_tx, res_rx) = oneshot::channel(); - predict_req_tx.unbounded_send((req, res_tx)).unwrap(); - serde_json::to_string(&res_rx.await?).unwrap() - } - "/predict_edits/reject" => { - let mut buf = Vec::new(); - body.read_to_end(&mut buf).await.ok(); - let req = serde_json::from_slice(&buf).unwrap(); - - let (res_tx, res_rx) = oneshot::channel(); - reject_req_tx.unbounded_send((req, res_tx)).unwrap(); - serde_json::to_string(&res_rx.await?).unwrap() - } - _ => { - panic!("Unexpected path: {}", uri) - } - }; - - Ok(Response::builder().body(resp.into()).unwrap()) - } - } - }); - - let client = client::Client::new(Arc::new(FakeSystemClock::new()), http_client, cx); - client.cloud_client().set_credentials(1, "test".into()); - - language_model::init(client.clone(), cx); - - let user_store = cx.new(|cx| UserStore::new(client.clone(), cx)); - let zeta = Zeta::global(&client, &user_store, cx); - - ( - zeta, - RequestChannels { - predict: predict_req_rx, - reject: reject_req_rx, - }, - ) - }) - } -} diff --git a/crates/zeta/src/zeta_tests.rs b/crates/zeta/src/zeta_tests.rs deleted file mode 100644 index 3549cda36d575a989f5bc4bd5bb8bea6810d3180..0000000000000000000000000000000000000000 --- a/crates/zeta/src/zeta_tests.rs +++ /dev/null @@ -1,671 +0,0 @@ -use client::test::FakeServer; -use clock::{FakeSystemClock, ReplicaId}; -use cloud_api_types::{CreateLlmTokenResponse, LlmToken}; -use cloud_llm_client::{PredictEditsBody, PredictEditsResponse}; -use gpui::TestAppContext; -use http_client::FakeHttpClient; -use indoc::indoc; -use language::Point; -use parking_lot::Mutex; -use serde_json::json; -use settings::SettingsStore; -use util::{path, rel_path::rel_path}; - -use crate::zeta1::MAX_EVENT_TOKENS; - -use super::*; - -const BSD_0_TXT: &str = include_str!("../license_examples/0bsd.txt"); - -#[gpui::test] -async fn test_edit_prediction_basic_interpolation(cx: &mut TestAppContext) { - let buffer = cx.new(|cx| Buffer::local("Lorem ipsum dolor", cx)); - let edits: Arc<[(Range, Arc)]> = cx.update(|cx| { - to_completion_edits([(2..5, "REM".into()), (9..11, "".into())], &buffer, cx).into() - }); - - let edit_preview = cx - .read(|cx| buffer.read(cx).preview_edits(edits.clone(), cx)) - .await; - - let completion = EditPrediction { - edits, - edit_preview, - buffer: buffer.clone(), - snapshot: cx.read(|cx| buffer.read(cx).snapshot()), - id: EditPredictionId("the-id".into()), - inputs: EditPredictionInputs { - events: Default::default(), - included_files: Default::default(), - cursor_point: cloud_llm_client::predict_edits_v3::Point { - line: Line(0), - column: 0, - }, - cursor_path: Path::new("").into(), - }, - buffer_snapshotted_at: Instant::now(), - response_received_at: Instant::now(), - }; - - cx.update(|cx| { - assert_eq!( - from_completion_edits( - &completion.interpolate(&buffer.read(cx).snapshot()).unwrap(), - &buffer, - cx - ), - vec![(2..5, "REM".into()), (9..11, "".into())] - ); - - buffer.update(cx, |buffer, cx| buffer.edit([(2..5, "")], None, cx)); - assert_eq!( - from_completion_edits( - &completion.interpolate(&buffer.read(cx).snapshot()).unwrap(), - &buffer, - cx - ), - vec![(2..2, "REM".into()), (6..8, "".into())] - ); - - buffer.update(cx, |buffer, cx| buffer.undo(cx)); - assert_eq!( - from_completion_edits( - &completion.interpolate(&buffer.read(cx).snapshot()).unwrap(), - &buffer, - cx - ), - vec![(2..5, "REM".into()), (9..11, "".into())] - ); - - buffer.update(cx, |buffer, cx| buffer.edit([(2..5, "R")], None, cx)); - assert_eq!( - from_completion_edits( - &completion.interpolate(&buffer.read(cx).snapshot()).unwrap(), - &buffer, - cx - ), - vec![(3..3, "EM".into()), (7..9, "".into())] - ); - - buffer.update(cx, |buffer, cx| buffer.edit([(3..3, "E")], None, cx)); - assert_eq!( - from_completion_edits( - &completion.interpolate(&buffer.read(cx).snapshot()).unwrap(), - &buffer, - cx - ), - vec![(4..4, "M".into()), (8..10, "".into())] - ); - - buffer.update(cx, |buffer, cx| buffer.edit([(4..4, "M")], None, cx)); - assert_eq!( - from_completion_edits( - &completion.interpolate(&buffer.read(cx).snapshot()).unwrap(), - &buffer, - cx - ), - vec![(9..11, "".into())] - ); - - buffer.update(cx, |buffer, cx| buffer.edit([(4..5, "")], None, cx)); - assert_eq!( - from_completion_edits( - &completion.interpolate(&buffer.read(cx).snapshot()).unwrap(), - &buffer, - cx - ), - vec![(4..4, "M".into()), (8..10, "".into())] - ); - - buffer.update(cx, |buffer, cx| buffer.edit([(8..10, "")], None, cx)); - assert_eq!( - from_completion_edits( - &completion.interpolate(&buffer.read(cx).snapshot()).unwrap(), - &buffer, - cx - ), - vec![(4..4, "M".into())] - ); - - buffer.update(cx, |buffer, cx| buffer.edit([(4..6, "")], None, cx)); - assert_eq!(completion.interpolate(&buffer.read(cx).snapshot()), None); - }) -} - -#[gpui::test] -async fn test_clean_up_diff(cx: &mut TestAppContext) { - init_test(cx); - - assert_eq!( - apply_edit_prediction( - indoc! {" - fn main() { - let word_1 = \"lorem\"; - let range = word.len()..word.len(); - } - "}, - indoc! {" - <|editable_region_start|> - fn main() { - let word_1 = \"lorem\"; - let range = word_1.len()..word_1.len(); - } - - <|editable_region_end|> - "}, - cx, - ) - .await, - indoc! {" - fn main() { - let word_1 = \"lorem\"; - let range = word_1.len()..word_1.len(); - } - "}, - ); - - assert_eq!( - apply_edit_prediction( - indoc! {" - fn main() { - let story = \"the quick\" - } - "}, - indoc! {" - <|editable_region_start|> - fn main() { - let story = \"the quick brown fox jumps over the lazy dog\"; - } - - <|editable_region_end|> - "}, - cx, - ) - .await, - indoc! {" - fn main() { - let story = \"the quick brown fox jumps over the lazy dog\"; - } - "}, - ); -} - -#[gpui::test] -async fn test_edit_prediction_end_of_buffer(cx: &mut TestAppContext) { - init_test(cx); - - let buffer_content = "lorem\n"; - let completion_response = indoc! {" - ```animals.js - <|start_of_file|> - <|editable_region_start|> - lorem - ipsum - <|editable_region_end|> - ```"}; - - assert_eq!( - apply_edit_prediction(buffer_content, completion_response, cx).await, - "lorem\nipsum" - ); -} - -#[gpui::test] -async fn test_can_collect_data(cx: &mut TestAppContext) { - init_test(cx); - - let fs = project::FakeFs::new(cx.executor()); - fs.insert_tree(path!("/project"), json!({ "LICENSE": BSD_0_TXT })) - .await; - - let project = Project::test(fs.clone(), [path!("/project").as_ref()], cx).await; - let buffer = project - .update(cx, |project, cx| { - project.open_local_buffer(path!("/project/src/main.rs"), cx) - }) - .await - .unwrap(); - - let (zeta, captured_request, _) = make_test_zeta(&project, cx).await; - zeta.update(cx, |zeta, _cx| { - zeta.data_collection_choice = DataCollectionChoice::Enabled - }); - - run_edit_prediction(&buffer, &project, &zeta, cx).await; - assert_eq!( - captured_request.lock().clone().unwrap().can_collect_data, - true - ); - - zeta.update(cx, |zeta, _cx| { - zeta.data_collection_choice = DataCollectionChoice::Disabled - }); - - run_edit_prediction(&buffer, &project, &zeta, cx).await; - assert_eq!( - captured_request.lock().clone().unwrap().can_collect_data, - false - ); -} - -#[gpui::test] -async fn test_no_data_collection_for_remote_file(cx: &mut TestAppContext) { - init_test(cx); - - let fs = project::FakeFs::new(cx.executor()); - let project = Project::test(fs.clone(), [], cx).await; - - let buffer = cx.new(|_cx| { - Buffer::remote( - language::BufferId::new(1).unwrap(), - ReplicaId::new(1), - language::Capability::ReadWrite, - "fn main() {\n println!(\"Hello\");\n}", - ) - }); - - let (zeta, captured_request, _) = make_test_zeta(&project, cx).await; - zeta.update(cx, |zeta, _cx| { - zeta.data_collection_choice = DataCollectionChoice::Enabled - }); - - run_edit_prediction(&buffer, &project, &zeta, cx).await; - assert_eq!( - captured_request.lock().clone().unwrap().can_collect_data, - false - ); -} - -#[gpui::test] -async fn test_no_data_collection_for_private_file(cx: &mut TestAppContext) { - init_test(cx); - - let fs = project::FakeFs::new(cx.executor()); - fs.insert_tree( - path!("/project"), - json!({ - "LICENSE": BSD_0_TXT, - ".env": "SECRET_KEY=secret" - }), - ) - .await; - - let project = Project::test(fs.clone(), [path!("/project").as_ref()], cx).await; - let buffer = project - .update(cx, |project, cx| { - project.open_local_buffer("/project/.env", cx) - }) - .await - .unwrap(); - - let (zeta, captured_request, _) = make_test_zeta(&project, cx).await; - zeta.update(cx, |zeta, _cx| { - zeta.data_collection_choice = DataCollectionChoice::Enabled - }); - - run_edit_prediction(&buffer, &project, &zeta, cx).await; - assert_eq!( - captured_request.lock().clone().unwrap().can_collect_data, - false - ); -} - -#[gpui::test] -async fn test_no_data_collection_for_untitled_buffer(cx: &mut TestAppContext) { - init_test(cx); - - let fs = project::FakeFs::new(cx.executor()); - let project = Project::test(fs.clone(), [], cx).await; - let buffer = cx.new(|cx| Buffer::local("", cx)); - - let (zeta, captured_request, _) = make_test_zeta(&project, cx).await; - zeta.update(cx, |zeta, _cx| { - zeta.data_collection_choice = DataCollectionChoice::Enabled - }); - - run_edit_prediction(&buffer, &project, &zeta, cx).await; - assert_eq!( - captured_request.lock().clone().unwrap().can_collect_data, - false - ); -} - -#[gpui::test] -async fn test_no_data_collection_when_closed_source(cx: &mut TestAppContext) { - init_test(cx); - - let fs = project::FakeFs::new(cx.executor()); - fs.insert_tree(path!("/project"), json!({ "main.rs": "fn main() {}" })) - .await; - - let project = Project::test(fs.clone(), [path!("/project").as_ref()], cx).await; - let buffer = project - .update(cx, |project, cx| { - project.open_local_buffer("/project/main.rs", cx) - }) - .await - .unwrap(); - - let (zeta, captured_request, _) = make_test_zeta(&project, cx).await; - zeta.update(cx, |zeta, _cx| { - zeta.data_collection_choice = DataCollectionChoice::Enabled - }); - - run_edit_prediction(&buffer, &project, &zeta, cx).await; - assert_eq!( - captured_request.lock().clone().unwrap().can_collect_data, - false - ); -} - -#[gpui::test] -async fn test_data_collection_status_changes_on_move(cx: &mut TestAppContext) { - init_test(cx); - - let fs = project::FakeFs::new(cx.executor()); - fs.insert_tree( - path!("/open_source_worktree"), - json!({ "LICENSE": BSD_0_TXT, "main.rs": "" }), - ) - .await; - fs.insert_tree(path!("/closed_source_worktree"), json!({ "main.rs": "" })) - .await; - - let project = Project::test( - fs.clone(), - [ - path!("/open_source_worktree").as_ref(), - path!("/closed_source_worktree").as_ref(), - ], - cx, - ) - .await; - let buffer = project - .update(cx, |project, cx| { - project.open_local_buffer(path!("/open_source_worktree/main.rs"), cx) - }) - .await - .unwrap(); - - let (zeta, captured_request, _) = make_test_zeta(&project, cx).await; - zeta.update(cx, |zeta, _cx| { - zeta.data_collection_choice = DataCollectionChoice::Enabled - }); - - run_edit_prediction(&buffer, &project, &zeta, cx).await; - assert_eq!( - captured_request.lock().clone().unwrap().can_collect_data, - true - ); - - let closed_source_file = project - .update(cx, |project, cx| { - let worktree2 = project - .worktree_for_root_name("closed_source_worktree", cx) - .unwrap(); - worktree2.update(cx, |worktree2, cx| { - worktree2.load_file(rel_path("main.rs"), cx) - }) - }) - .await - .unwrap() - .file; - - buffer.update(cx, |buffer, cx| { - buffer.file_updated(closed_source_file, cx); - }); - - run_edit_prediction(&buffer, &project, &zeta, cx).await; - assert_eq!( - captured_request.lock().clone().unwrap().can_collect_data, - false - ); -} - -#[gpui::test] -async fn test_no_data_collection_for_events_in_uncollectable_buffers(cx: &mut TestAppContext) { - init_test(cx); - - let fs = project::FakeFs::new(cx.executor()); - fs.insert_tree( - path!("/worktree1"), - json!({ "LICENSE": BSD_0_TXT, "main.rs": "", "other.rs": "" }), - ) - .await; - fs.insert_tree(path!("/worktree2"), json!({ "private.rs": "" })) - .await; - - let project = Project::test( - fs.clone(), - [path!("/worktree1").as_ref(), path!("/worktree2").as_ref()], - cx, - ) - .await; - let buffer = project - .update(cx, |project, cx| { - project.open_local_buffer(path!("/worktree1/main.rs"), cx) - }) - .await - .unwrap(); - let private_buffer = project - .update(cx, |project, cx| { - project.open_local_buffer(path!("/worktree2/file.rs"), cx) - }) - .await - .unwrap(); - - let (zeta, captured_request, _) = make_test_zeta(&project, cx).await; - zeta.update(cx, |zeta, _cx| { - zeta.data_collection_choice = DataCollectionChoice::Enabled - }); - - run_edit_prediction(&buffer, &project, &zeta, cx).await; - assert_eq!( - captured_request.lock().clone().unwrap().can_collect_data, - true - ); - - // this has a side effect of registering the buffer to watch for edits - run_edit_prediction(&private_buffer, &project, &zeta, cx).await; - assert_eq!( - captured_request.lock().clone().unwrap().can_collect_data, - false - ); - - private_buffer.update(cx, |private_buffer, cx| { - private_buffer.edit([(0..0, "An edit for the history!")], None, cx); - }); - - run_edit_prediction(&buffer, &project, &zeta, cx).await; - assert_eq!( - captured_request.lock().clone().unwrap().can_collect_data, - false - ); - - // make an edit that uses too many bytes, causing private_buffer edit to not be able to be - // included - buffer.update(cx, |buffer, cx| { - buffer.edit( - [( - 0..0, - " ".repeat(MAX_EVENT_TOKENS * zeta1::BYTES_PER_TOKEN_GUESS), - )], - None, - cx, - ); - }); - - run_edit_prediction(&buffer, &project, &zeta, cx).await; - assert_eq!( - captured_request.lock().clone().unwrap().can_collect_data, - true - ); -} - -fn init_test(cx: &mut TestAppContext) { - cx.update(|cx| { - let settings_store = SettingsStore::test(cx); - cx.set_global(settings_store); - }); -} - -async fn apply_edit_prediction( - buffer_content: &str, - completion_response: &str, - cx: &mut TestAppContext, -) -> String { - let fs = project::FakeFs::new(cx.executor()); - let project = Project::test(fs.clone(), [path!("/project").as_ref()], cx).await; - let buffer = cx.new(|cx| Buffer::local(buffer_content, cx)); - let (zeta, _, response) = make_test_zeta(&project, cx).await; - *response.lock() = completion_response.to_string(); - let edit_prediction = run_edit_prediction(&buffer, &project, &zeta, cx).await; - buffer.update(cx, |buffer, cx| { - buffer.edit(edit_prediction.edits.iter().cloned(), None, cx) - }); - buffer.read_with(cx, |buffer, _| buffer.text()) -} - -async fn run_edit_prediction( - buffer: &Entity, - project: &Entity, - zeta: &Entity, - cx: &mut TestAppContext, -) -> EditPrediction { - let cursor = buffer.read_with(cx, |buffer, _| buffer.anchor_before(Point::new(1, 0))); - zeta.update(cx, |zeta, cx| zeta.register_buffer(buffer, &project, cx)); - cx.background_executor.run_until_parked(); - let prediction_task = zeta.update(cx, |zeta, cx| { - zeta.request_prediction(&project, buffer, cursor, Default::default(), cx) - }); - prediction_task.await.unwrap().unwrap().prediction.unwrap() -} - -async fn make_test_zeta( - project: &Entity, - cx: &mut TestAppContext, -) -> ( - Entity, - Arc>>, - Arc>, -) { - let default_response = indoc! {" - ```main.rs - <|start_of_file|> - <|editable_region_start|> - hello world - <|editable_region_end|> - ```" - }; - let captured_request: Arc>> = Arc::new(Mutex::new(None)); - let completion_response: Arc> = - Arc::new(Mutex::new(default_response.to_string())); - let http_client = FakeHttpClient::create({ - let captured_request = captured_request.clone(); - let completion_response = completion_response.clone(); - let mut next_request_id = 0; - move |req| { - let captured_request = captured_request.clone(); - let completion_response = completion_response.clone(); - async move { - match (req.method(), req.uri().path()) { - (&Method::POST, "/client/llm_tokens") => Ok(http_client::Response::builder() - .status(200) - .body( - serde_json::to_string(&CreateLlmTokenResponse { - token: LlmToken("the-llm-token".to_string()), - }) - .unwrap() - .into(), - ) - .unwrap()), - (&Method::POST, "/predict_edits/v2") => { - let mut request_body = String::new(); - req.into_body().read_to_string(&mut request_body).await?; - *captured_request.lock() = - Some(serde_json::from_str(&request_body).unwrap()); - next_request_id += 1; - Ok(http_client::Response::builder() - .status(200) - .body( - serde_json::to_string(&PredictEditsResponse { - request_id: format!("request-{next_request_id}"), - output_excerpt: completion_response.lock().clone(), - }) - .unwrap() - .into(), - ) - .unwrap()) - } - _ => Ok(http_client::Response::builder() - .status(404) - .body("Not Found".into()) - .unwrap()), - } - } - } - }); - - let client = cx.update(|cx| Client::new(Arc::new(FakeSystemClock::new()), http_client, cx)); - cx.update(|cx| { - RefreshLlmTokenListener::register(client.clone(), cx); - }); - let _server = FakeServer::for_client(42, &client, cx).await; - - let zeta = cx.new(|cx| { - let mut zeta = Zeta::new(client, project.read(cx).user_store(), cx); - zeta.set_edit_prediction_model(ZetaEditPredictionModel::Zeta1); - - let worktrees = project.read(cx).worktrees(cx).collect::>(); - for worktree in worktrees { - let worktree_id = worktree.read(cx).id(); - zeta.get_or_init_zeta_project(project, cx) - .license_detection_watchers - .entry(worktree_id) - .or_insert_with(|| Rc::new(LicenseDetectionWatcher::new(&worktree, cx))); - } - - zeta - }); - - (zeta, captured_request, completion_response) -} - -fn to_completion_edits( - iterator: impl IntoIterator, Arc)>, - buffer: &Entity, - cx: &App, -) -> Vec<(Range, Arc)> { - let buffer = buffer.read(cx); - iterator - .into_iter() - .map(|(range, text)| { - ( - buffer.anchor_after(range.start)..buffer.anchor_before(range.end), - text, - ) - }) - .collect() -} - -fn from_completion_edits( - editor_edits: &[(Range, Arc)], - buffer: &Entity, - cx: &App, -) -> Vec<(Range, Arc)> { - let buffer = buffer.read(cx); - editor_edits - .iter() - .map(|(range, text)| { - ( - range.start.to_offset(buffer)..range.end.to_offset(buffer), - text.clone(), - ) - }) - .collect() -} - -#[ctor::ctor] -fn init_logger() { - zlog::init_test(); -} diff --git a/crates/zeta2_tools/Cargo.toml b/crates/zeta2_tools/Cargo.toml deleted file mode 100644 index 8e20224736c658d4d80d678b29d4231ec7e4b2f5..0000000000000000000000000000000000000000 --- a/crates/zeta2_tools/Cargo.toml +++ /dev/null @@ -1,48 +0,0 @@ -[package] -name = "zeta2_tools" -version = "0.1.0" -edition.workspace = true -publish.workspace = true -license = "GPL-3.0-or-later" - -[lints] -workspace = true - -[lib] -path = "src/zeta2_tools.rs" - -[dependencies] -anyhow.workspace = true -client.workspace = true -cloud_llm_client.workspace = true -collections.workspace = true -edit_prediction_context.workspace = true -editor.workspace = true -feature_flags.workspace = true -futures.workspace = true -gpui.workspace = true -language.workspace = true -multi_buffer.workspace = true -project.workspace = true -serde.workspace = true -serde_json.workspace = true -telemetry.workspace = true -text.workspace = true -ui.workspace = true -ui_input.workspace = true -util.workspace = true -workspace.workspace = true -zeta.workspace = true - -[dev-dependencies] -clap.workspace = true -gpui = { workspace = true, features = ["test-support"] } -indoc.workspace = true -language = { workspace = true, features = ["test-support"] } -pretty_assertions.workspace = true -project = { workspace = true, features = ["test-support"] } -serde_json.workspace = true -settings = { workspace = true, features = ["test-support"] } -text = { workspace = true, features = ["test-support"] } -util = { workspace = true, features = ["test-support"] } -zlog.workspace = true diff --git a/crates/zeta2_tools/LICENSE-GPL b/crates/zeta2_tools/LICENSE-GPL deleted file mode 120000 index 89e542f750cd3860a0598eff0dc34b56d7336dc4..0000000000000000000000000000000000000000 --- a/crates/zeta2_tools/LICENSE-GPL +++ /dev/null @@ -1 +0,0 @@ -../../LICENSE-GPL \ No newline at end of file diff --git a/crates/zeta2_tools/src/zeta2_tools.rs b/crates/zeta2_tools/src/zeta2_tools.rs deleted file mode 100644 index 26d68b075153557ab50ed0a231c5d45f0bb9646c..0000000000000000000000000000000000000000 --- a/crates/zeta2_tools/src/zeta2_tools.rs +++ /dev/null @@ -1,1035 +0,0 @@ -mod zeta2_context_view; - -use std::{str::FromStr, sync::Arc, time::Duration}; - -use client::{Client, UserStore}; -use cloud_llm_client::predict_edits_v3::PromptFormat; -use collections::HashMap; -use editor::{Editor, EditorEvent, EditorMode, MultiBuffer}; -use feature_flags::FeatureFlagAppExt as _; -use futures::{FutureExt, StreamExt as _, channel::oneshot, future::Shared}; -use gpui::{ - Empty, Entity, EventEmitter, FocusHandle, Focusable, Subscription, Task, WeakEntity, actions, - prelude::*, -}; -use language::Buffer; -use project::{Project, telemetry_snapshot::TelemetrySnapshot}; -use ui::{ButtonLike, ContextMenu, ContextMenuEntry, DropdownMenu, KeyBinding, prelude::*}; -use ui_input::InputField; -use util::ResultExt; -use workspace::{Item, SplitDirection, Workspace}; -use zeta::{ - AgenticContextOptions, ContextMode, DEFAULT_SYNTAX_CONTEXT_OPTIONS, EditPredictionInputs, Zeta, - Zeta2FeatureFlag, ZetaDebugInfo, ZetaEditPredictionDebugInfo, ZetaOptions, -}; - -use edit_prediction_context::{EditPredictionContextOptions, EditPredictionExcerptOptions}; -use zeta2_context_view::Zeta2ContextView; - -actions!( - dev, - [ - /// Opens the edit prediction context view. - OpenZeta2ContextView, - /// Opens the edit prediction inspector. - OpenZeta2Inspector, - /// Rate prediction as positive. - Zeta2RatePredictionPositive, - /// Rate prediction as negative. - Zeta2RatePredictionNegative, - ] -); - -pub fn init(cx: &mut App) { - cx.observe_new(move |workspace: &mut Workspace, _, _cx| { - workspace.register_action_renderer(|div, _, _, cx| { - let has_flag = cx.has_flag::(); - div.when(has_flag, |div| { - div.on_action( - cx.listener(move |workspace, _: &OpenZeta2Inspector, window, cx| { - let project = workspace.project(); - workspace.split_item( - SplitDirection::Right, - Box::new(cx.new(|cx| { - Zeta2Inspector::new( - &project, - workspace.client(), - workspace.user_store(), - window, - cx, - ) - })), - window, - cx, - ) - }), - ) - .on_action(cx.listener( - move |workspace, _: &OpenZeta2ContextView, window, cx| { - let project = workspace.project(); - workspace.split_item( - SplitDirection::Right, - Box::new(cx.new(|cx| { - Zeta2ContextView::new( - project.clone(), - workspace.client(), - workspace.user_store(), - window, - cx, - ) - })), - window, - cx, - ); - }, - )) - }) - }); - }) - .detach(); -} - -// TODO show included diagnostics, and events - -pub struct Zeta2Inspector { - focus_handle: FocusHandle, - project: Entity, - last_prediction: Option, - max_excerpt_bytes_input: Entity, - min_excerpt_bytes_input: Entity, - cursor_context_ratio_input: Entity, - max_prompt_bytes_input: Entity, - context_mode: ContextModeState, - zeta: Entity, - _active_editor_subscription: Option, - _update_state_task: Task<()>, - _receive_task: Task<()>, -} - -pub enum ContextModeState { - Llm, - Lsp, - Syntax { - max_retrieved_declarations: Entity, - }, -} - -struct LastPrediction { - prompt_editor: Entity, - retrieval_time: Duration, - request_time: Option, - buffer: WeakEntity, - position: language::Anchor, - state: LastPredictionState, - inputs: EditPredictionInputs, - project_snapshot: Shared>>, - _task: Option>, -} - -#[derive(Clone, Copy, PartialEq)] -enum Feedback { - Positive, - Negative, -} - -enum LastPredictionState { - Requested, - Success { - model_response_editor: Entity, - feedback_editor: Entity, - feedback: Option, - request_id: String, - }, - Failed { - message: String, - }, -} - -impl Zeta2Inspector { - pub fn new( - project: &Entity, - client: &Arc, - user_store: &Entity, - window: &mut Window, - cx: &mut Context, - ) -> Self { - let zeta = Zeta::global(client, user_store, cx); - let mut request_rx = zeta.update(cx, |zeta, _cx| zeta.debug_info()); - - let receive_task = cx.spawn_in(window, async move |this, cx| { - while let Some(prediction) = request_rx.next().await { - this.update_in(cx, |this, window, cx| { - this.update_last_prediction(prediction, window, cx) - }) - .ok(); - } - }); - - let mut this = Self { - focus_handle: cx.focus_handle(), - project: project.clone(), - last_prediction: None, - max_excerpt_bytes_input: Self::number_input("Max Excerpt Bytes", window, cx), - min_excerpt_bytes_input: Self::number_input("Min Excerpt Bytes", window, cx), - cursor_context_ratio_input: Self::number_input("Cursor Context Ratio", window, cx), - max_prompt_bytes_input: Self::number_input("Max Prompt Bytes", window, cx), - context_mode: ContextModeState::Llm, - zeta: zeta.clone(), - _active_editor_subscription: None, - _update_state_task: Task::ready(()), - _receive_task: receive_task, - }; - this.set_options_state(&zeta.read(cx).options().clone(), window, cx); - this - } - - fn set_options_state( - &mut self, - options: &ZetaOptions, - window: &mut Window, - cx: &mut Context, - ) { - let excerpt_options = options.context.excerpt(); - self.max_excerpt_bytes_input.update(cx, |input, cx| { - input.set_text(excerpt_options.max_bytes.to_string(), window, cx); - }); - self.min_excerpt_bytes_input.update(cx, |input, cx| { - input.set_text(excerpt_options.min_bytes.to_string(), window, cx); - }); - self.cursor_context_ratio_input.update(cx, |input, cx| { - input.set_text( - format!( - "{:.2}", - excerpt_options.target_before_cursor_over_total_bytes - ), - window, - cx, - ); - }); - self.max_prompt_bytes_input.update(cx, |input, cx| { - input.set_text(options.max_prompt_bytes.to_string(), window, cx); - }); - - match &options.context { - ContextMode::Agentic(_) => { - self.context_mode = ContextModeState::Llm; - } - ContextMode::Syntax(_) => { - self.context_mode = ContextModeState::Syntax { - max_retrieved_declarations: Self::number_input( - "Max Retrieved Definitions", - window, - cx, - ), - }; - } - ContextMode::Lsp(_) => { - self.context_mode = ContextModeState::Lsp; - } - } - cx.notify(); - } - - fn set_zeta_options(&mut self, options: ZetaOptions, cx: &mut Context) { - self.zeta.update(cx, |this, _cx| this.set_options(options)); - - if let Some(prediction) = self.last_prediction.as_mut() { - if let Some(buffer) = prediction.buffer.upgrade() { - let position = prediction.position; - let project = self.project.clone(); - self.zeta.update(cx, |zeta, cx| { - zeta.refresh_prediction_from_buffer(project, buffer, position, cx) - }); - prediction.state = LastPredictionState::Requested; - } else { - self.last_prediction.take(); - } - } - - cx.notify(); - } - - fn number_input( - label: &'static str, - window: &mut Window, - cx: &mut Context, - ) -> Entity { - let input = cx.new(|cx| { - InputField::new(window, cx, "") - .label(label) - .label_min_width(px(64.)) - }); - - cx.subscribe_in( - &input.read(cx).editor().clone(), - window, - |this, _, event, _window, cx| { - let EditorEvent::BufferEdited = event else { - return; - }; - - fn number_input_value( - input: &Entity, - cx: &App, - ) -> T { - input - .read(cx) - .editor() - .read(cx) - .text(cx) - .parse::() - .unwrap_or_default() - } - - let zeta_options = this.zeta.read(cx).options().clone(); - - let excerpt_options = EditPredictionExcerptOptions { - max_bytes: number_input_value(&this.max_excerpt_bytes_input, cx), - min_bytes: number_input_value(&this.min_excerpt_bytes_input, cx), - target_before_cursor_over_total_bytes: number_input_value( - &this.cursor_context_ratio_input, - cx, - ), - }; - - let context = match zeta_options.context { - ContextMode::Agentic(_context_options) => { - ContextMode::Agentic(AgenticContextOptions { - excerpt: excerpt_options, - }) - } - ContextMode::Syntax(context_options) => { - let max_retrieved_declarations = match &this.context_mode { - ContextModeState::Llm => { - zeta::DEFAULT_SYNTAX_CONTEXT_OPTIONS.max_retrieved_declarations - } - ContextModeState::Syntax { - max_retrieved_declarations, - } => number_input_value(max_retrieved_declarations, cx), - ContextModeState::Lsp => { - zeta::DEFAULT_SYNTAX_CONTEXT_OPTIONS.max_retrieved_declarations - } - }; - - ContextMode::Syntax(EditPredictionContextOptions { - excerpt: excerpt_options, - max_retrieved_declarations, - ..context_options - }) - } - ContextMode::Lsp(excerpt_options) => ContextMode::Lsp(excerpt_options), - }; - - this.set_zeta_options( - ZetaOptions { - context, - max_prompt_bytes: number_input_value(&this.max_prompt_bytes_input, cx), - max_diagnostic_bytes: zeta_options.max_diagnostic_bytes, - prompt_format: zeta_options.prompt_format, - file_indexing_parallelism: zeta_options.file_indexing_parallelism, - buffer_change_grouping_interval: zeta_options - .buffer_change_grouping_interval, - }, - cx, - ); - }, - ) - .detach(); - input - } - - fn update_last_prediction( - &mut self, - prediction: zeta::ZetaDebugInfo, - window: &mut Window, - cx: &mut Context, - ) { - self._update_state_task = cx.spawn_in(window, { - let language_registry = self.project.read(cx).languages().clone(); - async move |this, cx| { - let mut languages = HashMap::default(); - let ZetaDebugInfo::EditPredictionRequested(prediction) = prediction else { - return; - }; - for ext in prediction - .inputs - .included_files - .iter() - .filter_map(|file| file.path.extension()) - { - if !languages.contains_key(ext) { - // Most snippets are gonna be the same language, - // so we think it's fine to do this sequentially for now - languages.insert( - ext.to_owned(), - language_registry - .language_for_name_or_extension(&ext.to_string_lossy()) - .await - .ok(), - ); - } - } - - let markdown_language = language_registry - .language_for_name("Markdown") - .await - .log_err(); - - let json_language = language_registry.language_for_name("Json").await.log_err(); - - this.update_in(cx, |this, window, cx| { - let ZetaEditPredictionDebugInfo { - response_rx, - position, - buffer, - retrieval_time, - local_prompt, - .. - } = prediction; - - let task = cx.spawn_in(window, { - let markdown_language = markdown_language.clone(); - let json_language = json_language.clone(); - async move |this, cx| { - let response = response_rx.await; - - this.update_in(cx, |this, window, cx| { - if let Some(prediction) = this.last_prediction.as_mut() { - prediction.state = match response { - Ok((Ok(response), request_time)) => { - prediction.request_time = Some(request_time); - - let feedback_editor = cx.new(|cx| { - let buffer = cx.new(|cx| { - let mut buffer = Buffer::local("", cx); - buffer.set_language( - markdown_language.clone(), - cx, - ); - buffer - }); - let buffer = - cx.new(|cx| MultiBuffer::singleton(buffer, cx)); - let mut editor = Editor::new( - EditorMode::AutoHeight { - min_lines: 3, - max_lines: None, - }, - buffer, - None, - window, - cx, - ); - editor.set_placeholder_text( - "Write feedback here", - window, - cx, - ); - editor.set_show_line_numbers(false, cx); - editor.set_show_gutter(false, cx); - editor.set_show_scrollbars(false, cx); - editor - }); - - cx.subscribe_in( - &feedback_editor, - window, - |this, editor, ev, window, cx| match ev { - EditorEvent::BufferEdited => { - if let Some(last_prediction) = - this.last_prediction.as_mut() - && let LastPredictionState::Success { - feedback: feedback_state, - .. - } = &mut last_prediction.state - { - if feedback_state.take().is_some() { - editor.update(cx, |editor, cx| { - editor.set_placeholder_text( - "Write feedback here", - window, - cx, - ); - }); - cx.notify(); - } - } - } - _ => {} - }, - ) - .detach(); - - LastPredictionState::Success { - model_response_editor: cx.new(|cx| { - let buffer = cx.new(|cx| { - let mut buffer = Buffer::local( - serde_json::to_string_pretty(&response) - .unwrap_or_default(), - cx, - ); - buffer.set_language(json_language, cx); - buffer - }); - let buffer = cx.new(|cx| { - MultiBuffer::singleton(buffer, cx) - }); - let mut editor = Editor::new( - EditorMode::full(), - buffer, - None, - window, - cx, - ); - editor.set_read_only(true); - editor.set_show_line_numbers(false, cx); - editor.set_show_gutter(false, cx); - editor.set_show_scrollbars(false, cx); - editor - }), - feedback_editor, - feedback: None, - request_id: response.id.clone(), - } - } - Ok((Err(err), request_time)) => { - prediction.request_time = Some(request_time); - LastPredictionState::Failed { message: err } - } - Err(oneshot::Canceled) => LastPredictionState::Failed { - message: "Canceled".to_string(), - }, - }; - } - }) - .ok(); - } - }); - - let project_snapshot_task = TelemetrySnapshot::new(&this.project, cx); - - this.last_prediction = Some(LastPrediction { - prompt_editor: cx.new(|cx| { - let buffer = cx.new(|cx| { - let mut buffer = - Buffer::local(local_prompt.unwrap_or_else(|err| err), cx); - buffer.set_language(markdown_language.clone(), cx); - buffer - }); - let buffer = cx.new(|cx| MultiBuffer::singleton(buffer, cx)); - let mut editor = - Editor::new(EditorMode::full(), buffer, None, window, cx); - editor.set_read_only(true); - editor.set_show_line_numbers(false, cx); - editor.set_show_gutter(false, cx); - editor.set_show_scrollbars(false, cx); - editor - }), - retrieval_time, - request_time: None, - buffer, - position, - state: LastPredictionState::Requested, - project_snapshot: cx - .foreground_executor() - .spawn(async move { Arc::new(project_snapshot_task.await) }) - .shared(), - inputs: prediction.inputs, - _task: Some(task), - }); - cx.notify(); - }) - .ok(); - } - }); - } - - fn handle_rate_positive( - &mut self, - _action: &Zeta2RatePredictionPositive, - window: &mut Window, - cx: &mut Context, - ) { - self.handle_rate(Feedback::Positive, window, cx); - } - - fn handle_rate_negative( - &mut self, - _action: &Zeta2RatePredictionNegative, - window: &mut Window, - cx: &mut Context, - ) { - self.handle_rate(Feedback::Negative, window, cx); - } - - fn handle_rate(&mut self, kind: Feedback, window: &mut Window, cx: &mut Context) { - let Some(last_prediction) = self.last_prediction.as_mut() else { - return; - }; - - let project_snapshot_task = last_prediction.project_snapshot.clone(); - - cx.spawn_in(window, async move |this, cx| { - let project_snapshot = project_snapshot_task.await; - this.update_in(cx, |this, window, cx| { - let Some(last_prediction) = this.last_prediction.as_mut() else { - return; - }; - - let LastPredictionState::Success { - feedback: feedback_state, - feedback_editor, - model_response_editor, - request_id, - .. - } = &mut last_prediction.state - else { - return; - }; - - *feedback_state = Some(kind); - let text = feedback_editor.update(cx, |feedback_editor, cx| { - feedback_editor.set_placeholder_text( - "Submitted. Edit or submit again to change.", - window, - cx, - ); - feedback_editor.text(cx) - }); - cx.notify(); - - cx.defer_in(window, { - let model_response_editor = model_response_editor.downgrade(); - move |_, window, cx| { - if let Some(model_response_editor) = model_response_editor.upgrade() { - model_response_editor.focus_handle(cx).focus(window); - } - } - }); - - let kind = match kind { - Feedback::Positive => "positive", - Feedback::Negative => "negative", - }; - - telemetry::event!( - "Zeta2 Prediction Rated", - id = request_id, - kind = kind, - text = text, - request = last_prediction.inputs, - project_snapshot = project_snapshot, - ); - }) - .log_err(); - }) - .detach(); - } - - fn render_options(&self, window: &mut Window, cx: &mut Context) -> Div { - v_flex() - .gap_2() - .child( - h_flex() - .child(Headline::new("Options").size(HeadlineSize::Small)) - .justify_between() - .child( - ui::Button::new("reset-options", "Reset") - .disabled(self.zeta.read(cx).options() == &zeta::DEFAULT_OPTIONS) - .style(ButtonStyle::Outlined) - .size(ButtonSize::Large) - .on_click(cx.listener(|this, _, window, cx| { - this.set_options_state(&zeta::DEFAULT_OPTIONS, window, cx); - })), - ), - ) - .child( - v_flex() - .gap_2() - .child( - h_flex() - .gap_2() - .items_end() - .child(self.max_excerpt_bytes_input.clone()) - .child(self.min_excerpt_bytes_input.clone()) - .child(self.cursor_context_ratio_input.clone()) - .child(self.render_context_mode_dropdown(window, cx)), - ) - .child( - h_flex() - .gap_2() - .items_end() - .children(match &self.context_mode { - ContextModeState::Llm => None, - ContextModeState::Syntax { - max_retrieved_declarations, - } => Some(max_retrieved_declarations.clone()), - ContextModeState::Lsp => None, - }) - .child(self.max_prompt_bytes_input.clone()) - .child(self.render_prompt_format_dropdown(window, cx)), - ), - ) - } - - fn render_context_mode_dropdown(&self, window: &mut Window, cx: &mut Context) -> Div { - let this = cx.weak_entity(); - - v_flex() - .gap_1p5() - .child( - Label::new("Context Mode") - .size(LabelSize::Small) - .color(Color::Muted), - ) - .child( - DropdownMenu::new( - "ep-ctx-mode", - match &self.context_mode { - ContextModeState::Llm => "LLM-based", - ContextModeState::Syntax { .. } => "Syntax", - ContextModeState::Lsp => "LSP-based", - }, - ContextMenu::build(window, cx, move |menu, _window, _cx| { - menu.item( - ContextMenuEntry::new("LLM-based") - .toggleable( - IconPosition::End, - matches!(self.context_mode, ContextModeState::Llm), - ) - .handler({ - let this = this.clone(); - move |window, cx| { - this.update(cx, |this, cx| { - let current_options = - this.zeta.read(cx).options().clone(); - match current_options.context.clone() { - ContextMode::Agentic(_) => {} - ContextMode::Lsp(_) => {} - ContextMode::Syntax(context_options) => { - let options = ZetaOptions { - context: ContextMode::Agentic( - AgenticContextOptions { - excerpt: context_options.excerpt, - }, - ), - ..current_options - }; - this.set_options_state(&options, window, cx); - this.set_zeta_options(options, cx); - } - } - }) - .ok(); - } - }), - ) - .item( - ContextMenuEntry::new("Syntax") - .toggleable( - IconPosition::End, - matches!(self.context_mode, ContextModeState::Syntax { .. }), - ) - .handler({ - move |window, cx| { - this.update(cx, |this, cx| { - let current_options = - this.zeta.read(cx).options().clone(); - match current_options.context.clone() { - ContextMode::Agentic(context_options) => { - let options = ZetaOptions { - context: ContextMode::Syntax( - EditPredictionContextOptions { - excerpt: context_options.excerpt, - ..DEFAULT_SYNTAX_CONTEXT_OPTIONS - }, - ), - ..current_options - }; - this.set_options_state(&options, window, cx); - this.set_zeta_options(options, cx); - } - ContextMode::Syntax(_) => {} - ContextMode::Lsp(_) => {} - } - }) - .ok(); - } - }), - ) - }), - ) - .style(ui::DropdownStyle::Outlined), - ) - } - - fn render_prompt_format_dropdown(&self, window: &mut Window, cx: &mut Context) -> Div { - let active_format = self.zeta.read(cx).options().prompt_format; - let this = cx.weak_entity(); - - v_flex() - .gap_1p5() - .child( - Label::new("Prompt Format") - .size(LabelSize::Small) - .color(Color::Muted), - ) - .child( - DropdownMenu::new( - "ep-prompt-format", - active_format.to_string(), - ContextMenu::build(window, cx, move |mut menu, _window, _cx| { - for prompt_format in PromptFormat::iter() { - menu = menu.item( - ContextMenuEntry::new(prompt_format.to_string()) - .toggleable(IconPosition::End, active_format == prompt_format) - .handler({ - let this = this.clone(); - move |_window, cx| { - this.update(cx, |this, cx| { - let current_options = - this.zeta.read(cx).options().clone(); - let options = ZetaOptions { - prompt_format, - ..current_options - }; - this.set_zeta_options(options, cx); - }) - .ok(); - } - }), - ) - } - menu - }), - ) - .style(ui::DropdownStyle::Outlined), - ) - } - - fn render_stats(&self) -> Option
{ - let Some(prediction) = self.last_prediction.as_ref() else { - return None; - }; - - Some( - v_flex() - .p_4() - .gap_2() - .min_w(px(160.)) - .child(Headline::new("Stats").size(HeadlineSize::Small)) - .child(Self::render_duration( - "Context retrieval", - Some(prediction.retrieval_time), - )) - .child(Self::render_duration("Request", prediction.request_time)), - ) - } - - fn render_duration(name: &'static str, time: Option) -> Div { - h_flex() - .gap_1() - .child(Label::new(name).color(Color::Muted).size(LabelSize::Small)) - .child(match time { - Some(time) => Label::new(if time.as_micros() >= 1000 { - format!("{} ms", time.as_millis()) - } else { - format!("{} µs", time.as_micros()) - }) - .size(LabelSize::Small), - None => Label::new("...").size(LabelSize::Small), - }) - } - - fn render_content(&self, _: &mut Window, cx: &mut Context) -> AnyElement { - if !cx.has_flag::() { - return Self::render_message("`zeta2` feature flag is not enabled"); - } - - match self.last_prediction.as_ref() { - None => Self::render_message("No prediction"), - Some(prediction) => self.render_last_prediction(prediction, cx).into_any(), - } - } - - fn render_message(message: impl Into) -> AnyElement { - v_flex() - .size_full() - .justify_center() - .items_center() - .child(Label::new(message).size(LabelSize::Large)) - .into_any() - } - - fn render_last_prediction(&self, prediction: &LastPrediction, cx: &mut Context) -> Div { - h_flex() - .items_start() - .w_full() - .flex_1() - .border_t_1() - .border_color(cx.theme().colors().border) - .bg(cx.theme().colors().editor_background) - .child( - v_flex() - .flex_1() - .gap_2() - .p_4() - .h_full() - .child( - h_flex() - .justify_between() - .child(ui::Headline::new("Prompt").size(ui::HeadlineSize::XSmall)) - .child(match prediction.state { - LastPredictionState::Requested - | LastPredictionState::Failed { .. } => ui::Chip::new("Local") - .bg_color(cx.theme().status().warning_background) - .label_color(Color::Success), - LastPredictionState::Success { .. } => ui::Chip::new("Cloud") - .bg_color(cx.theme().status().success_background) - .label_color(Color::Success), - }), - ) - .child(prediction.prompt_editor.clone()), - ) - .child(ui::vertical_divider()) - .child( - v_flex() - .flex_1() - .gap_2() - .h_full() - .child( - v_flex() - .flex_1() - .gap_2() - .p_4() - .child( - ui::Headline::new("Model Response").size(ui::HeadlineSize::XSmall), - ) - .child(match &prediction.state { - LastPredictionState::Success { - model_response_editor, - .. - } => model_response_editor.clone().into_any_element(), - LastPredictionState::Requested => v_flex() - .gap_2() - .child(Label::new("Loading...").buffer_font(cx)) - .into_any_element(), - LastPredictionState::Failed { message } => v_flex() - .gap_2() - .max_w_96() - .child(Label::new(message.clone()).buffer_font(cx)) - .into_any_element(), - }), - ) - .child(ui::divider()) - .child( - if let LastPredictionState::Success { - feedback_editor, - feedback: feedback_state, - .. - } = &prediction.state - { - v_flex() - .key_context("Zeta2Feedback") - .on_action(cx.listener(Self::handle_rate_positive)) - .on_action(cx.listener(Self::handle_rate_negative)) - .gap_2() - .p_2() - .child(feedback_editor.clone()) - .child( - h_flex() - .justify_end() - .w_full() - .child( - ButtonLike::new("rate-positive") - .when( - *feedback_state == Some(Feedback::Positive), - |this| this.style(ButtonStyle::Filled), - ) - .child( - KeyBinding::for_action( - &Zeta2RatePredictionPositive, - cx, - ) - .size(TextSize::Small.rems(cx)), - ) - .child(ui::Icon::new(ui::IconName::ThumbsUp)) - .on_click(cx.listener(|this, _, window, cx| { - this.handle_rate_positive( - &Zeta2RatePredictionPositive, - window, - cx, - ); - })), - ) - .child( - ButtonLike::new("rate-negative") - .when( - *feedback_state == Some(Feedback::Negative), - |this| this.style(ButtonStyle::Filled), - ) - .child( - KeyBinding::for_action( - &Zeta2RatePredictionNegative, - cx, - ) - .size(TextSize::Small.rems(cx)), - ) - .child(ui::Icon::new(ui::IconName::ThumbsDown)) - .on_click(cx.listener(|this, _, window, cx| { - this.handle_rate_negative( - &Zeta2RatePredictionNegative, - window, - cx, - ); - })), - ), - ) - .into_any() - } else { - Empty.into_any_element() - }, - ), - ) - } -} - -impl Focusable for Zeta2Inspector { - fn focus_handle(&self, _cx: &App) -> FocusHandle { - self.focus_handle.clone() - } -} - -impl Item for Zeta2Inspector { - type Event = (); - - fn tab_content_text(&self, _detail: usize, _cx: &App) -> SharedString { - "Zeta2 Inspector".into() - } -} - -impl EventEmitter<()> for Zeta2Inspector {} - -impl Render for Zeta2Inspector { - fn render(&mut self, window: &mut Window, cx: &mut Context) -> impl IntoElement { - v_flex() - .size_full() - .bg(cx.theme().colors().editor_background) - .child( - h_flex() - .w_full() - .child( - v_flex() - .flex_1() - .p_4() - .h_full() - .justify_between() - .child(self.render_options(window, cx)) - .gap_4(), - ) - .child(ui::vertical_divider()) - .children(self.render_stats()), - ) - .child(self.render_content(window, cx)) - } -} diff --git a/crates/zeta_cli/LICENSE-GPL b/crates/zeta_cli/LICENSE-GPL deleted file mode 120000 index 89e542f750cd3860a0598eff0dc34b56d7336dc4..0000000000000000000000000000000000000000 --- a/crates/zeta_cli/LICENSE-GPL +++ /dev/null @@ -1 +0,0 @@ -../../LICENSE-GPL \ No newline at end of file diff --git a/crates/zeta_cli/src/syntax_retrieval_stats.rs b/crates/zeta_cli/src/syntax_retrieval_stats.rs deleted file mode 100644 index 4c7506ff78952da79acfeae751959bfe8182b9d4..0000000000000000000000000000000000000000 --- a/crates/zeta_cli/src/syntax_retrieval_stats.rs +++ /dev/null @@ -1,1260 +0,0 @@ -use ::util::rel_path::RelPath; -use ::util::{RangeExt, ResultExt as _}; -use anyhow::{Context as _, Result}; -use cloud_llm_client::predict_edits_v3::DeclarationScoreComponents; -use edit_prediction_context::{ - Declaration, DeclarationStyle, EditPredictionContext, EditPredictionContextOptions, Identifier, - Imports, Reference, ReferenceRegion, SyntaxIndex, SyntaxIndexState, references_in_range, -}; -use futures::StreamExt as _; -use futures::channel::mpsc; -use gpui::Entity; -use gpui::{AppContext, AsyncApp}; -use language::OffsetRangeExt; -use language::{BufferSnapshot, Point}; -use ordered_float::OrderedFloat; -use polars::prelude::*; -use project::{Project, ProjectEntryId, ProjectPath, Worktree}; -use serde::{Deserialize, Serialize}; -use std::fs; -use std::{ - cmp::Reverse, - collections::{HashMap, HashSet}, - fs::File, - hash::{Hash, Hasher}, - io::{BufRead, BufReader, BufWriter, Write as _}, - ops::Range, - path::{Path, PathBuf}, - sync::{ - Arc, - atomic::{self, AtomicUsize}, - }, - time::Duration, -}; -use util::paths::PathStyle; -use zeta::ContextMode; - -use crate::headless::ZetaCliAppState; -use crate::source_location::SourceLocation; -use crate::util::{open_buffer, open_buffer_with_language_server}; - -pub async fn retrieval_stats( - worktree: PathBuf, - app_state: Arc, - only_extension: Option, - file_limit: Option, - skip_files: Option, - options: zeta::ZetaOptions, - cx: &mut AsyncApp, -) -> Result { - let ContextMode::Syntax(context_options) = options.context.clone() else { - anyhow::bail!("retrieval stats only works in ContextMode::Syntax"); - }; - - let options = Arc::new(options); - let worktree_path = worktree.canonicalize()?; - - let project = cx.update(|cx| { - Project::local( - app_state.client.clone(), - app_state.node_runtime.clone(), - app_state.user_store.clone(), - app_state.languages.clone(), - app_state.fs.clone(), - None, - cx, - ) - })?; - - let worktree = project - .update(cx, |project, cx| { - project.create_worktree(&worktree_path, true, cx) - })? - .await?; - - // wait for worktree scan so that wait_for_initial_file_indexing waits for the whole worktree. - worktree - .read_with(cx, |worktree, _cx| { - worktree.as_local().unwrap().scan_complete() - })? - .await; - - let index = cx.new(|cx| SyntaxIndex::new(&project, options.file_indexing_parallelism, cx))?; - index - .read_with(cx, |index, cx| index.wait_for_initial_file_indexing(cx))? - .await?; - let indexed_files = index - .read_with(cx, |index, cx| index.indexed_file_paths(cx))? - .await; - let mut filtered_files = indexed_files - .into_iter() - .filter(|project_path| { - let file_extension = project_path.path.extension(); - if let Some(only_extension) = only_extension.as_ref() { - file_extension.is_some_and(|extension| extension == only_extension) - } else { - file_extension - .is_some_and(|extension| !["md", "json", "sh", "diff"].contains(&extension)) - } - }) - .collect::>(); - filtered_files.sort_by(|a, b| a.path.cmp(&b.path)); - - let index_state = index.read_with(cx, |index, _cx| index.state().clone())?; - cx.update(|_| { - drop(index); - })?; - let index_state = Arc::new( - Arc::into_inner(index_state) - .context("Index state had more than 1 reference")? - .into_inner(), - ); - - struct FileSnapshot { - project_entry_id: ProjectEntryId, - snapshot: BufferSnapshot, - hash: u64, - parent_abs_path: Arc, - } - - let files: Vec = futures::future::try_join_all({ - filtered_files - .iter() - .map(|file| { - let buffer_task = - open_buffer(project.clone(), worktree.clone(), file.path.clone(), cx); - cx.spawn(async move |cx| { - let buffer = buffer_task.await?; - let (project_entry_id, parent_abs_path, snapshot) = - buffer.read_with(cx, |buffer, cx| { - let file = project::File::from_dyn(buffer.file()).unwrap(); - let project_entry_id = file.project_entry_id().unwrap(); - let mut parent_abs_path = file.worktree.read(cx).absolutize(&file.path); - if !parent_abs_path.pop() { - panic!("Invalid worktree path"); - } - - (project_entry_id, parent_abs_path, buffer.snapshot()) - })?; - - anyhow::Ok( - cx.background_spawn(async move { - let mut hasher = collections::FxHasher::default(); - snapshot.text().hash(&mut hasher); - FileSnapshot { - project_entry_id, - snapshot, - hash: hasher.finish(), - parent_abs_path: parent_abs_path.into(), - } - }) - .await, - ) - }) - }) - .collect::>() - }) - .await?; - - let mut file_snapshots = HashMap::default(); - let mut hasher = collections::FxHasher::default(); - for FileSnapshot { - project_entry_id, - snapshot, - hash, - .. - } in &files - { - file_snapshots.insert(*project_entry_id, snapshot.clone()); - hash.hash(&mut hasher); - } - let files_hash = hasher.finish(); - let file_snapshots = Arc::new(file_snapshots); - let target_cli_dir = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../target/zeta_cli"); - fs::create_dir_all(&target_cli_dir).unwrap(); - let target_cli_dir = target_cli_dir.canonicalize().unwrap(); - - let lsp_cache_dir = target_cli_dir.join("cache"); - fs::create_dir_all(&lsp_cache_dir).unwrap(); - - let lsp_definitions_path = lsp_cache_dir.join(format!( - "{}-{:x}.jsonl", - worktree_path.file_stem().unwrap_or_default().display(), - files_hash - )); - - let mut lsp_definitions = HashMap::default(); - let mut lsp_files = 0; - - if fs::exists(&lsp_definitions_path)? { - log::info!( - "Using cached LSP definitions from {}", - lsp_definitions_path.display() - ); - - let file = File::options() - .read(true) - .write(true) - .open(&lsp_definitions_path)?; - let lines = BufReader::new(&file).lines(); - let mut valid_len: usize = 0; - - for (line, expected_file) in lines.zip(files.iter()) { - let line = line?; - let FileLspDefinitions { path, references } = match serde_json::from_str(&line) { - Ok(ok) => ok, - Err(_) => { - log::error!("Found invalid cache line. Truncating to #{lsp_files}.",); - file.set_len(valid_len as u64)?; - break; - } - }; - let expected_path = expected_file.snapshot.file().unwrap().path().as_unix_str(); - if expected_path != path.as_ref() { - log::error!( - "Expected file #{} to be {expected_path}, but found {path}. Truncating to #{lsp_files}.", - lsp_files + 1 - ); - file.set_len(valid_len as u64)?; - break; - } - for (point, ranges) in references { - let Ok(path) = RelPath::new(Path::new(path.as_ref()), PathStyle::Posix) else { - log::warn!("Invalid path: {}", path); - continue; - }; - lsp_definitions.insert( - SourceLocation { - path: path.into_arc(), - point: point.into(), - }, - ranges, - ); - } - lsp_files += 1; - valid_len += line.len() + 1 - } - } - - if lsp_files < files.len() { - if lsp_files == 0 { - log::warn!( - "No LSP definitions found, populating {}", - lsp_definitions_path.display() - ); - } else { - log::warn!("{} files missing from LSP cache", files.len() - lsp_files); - } - - gather_lsp_definitions( - &lsp_definitions_path, - lsp_files, - &filtered_files, - &worktree, - &project, - &mut lsp_definitions, - cx, - ) - .await?; - } - let files_len = files.len().min(file_limit.unwrap_or(usize::MAX)); - let done_count = Arc::new(AtomicUsize::new(0)); - - let (output_tx, output_rx) = mpsc::unbounded::(); - - let tasks = files - .into_iter() - .skip(skip_files.unwrap_or(0)) - .take(file_limit.unwrap_or(usize::MAX)) - .map(|project_file| { - let index_state = index_state.clone(); - let lsp_definitions = lsp_definitions.clone(); - let output_tx = output_tx.clone(); - let done_count = done_count.clone(); - let file_snapshots = file_snapshots.clone(); - let context_options = context_options.clone(); - cx.background_spawn(async move { - let snapshot = project_file.snapshot; - - let full_range = 0..snapshot.len(); - let references = references_in_range( - full_range, - &snapshot.text(), - ReferenceRegion::Nearby, - &snapshot, - ); - - let imports = if context_options.use_imports { - Imports::gather(&snapshot, Some(&project_file.parent_abs_path)) - } else { - Imports::default() - }; - - let path = snapshot.file().unwrap().path(); - - for reference in references { - let query_point = snapshot.offset_to_point(reference.range.start); - let source_location = SourceLocation { - path: path.clone(), - point: query_point, - }; - let lsp_definitions = lsp_definitions - .get(&source_location) - .cloned() - .unwrap_or_else(|| { - log::warn!( - "No definitions found for source location: {:?}", - source_location - ); - Vec::new() - }); - - let retrieve_result = retrieve_definitions( - &reference, - &imports, - query_point, - &snapshot, - &index_state, - &file_snapshots, - &context_options, - ) - .await?; - - let result = ReferenceRetrievalResult { - cursor_path: path.clone(), - identifier: reference.identifier, - cursor_point: query_point, - lsp_definitions, - retrieved_definitions: retrieve_result.definitions, - excerpt_range: retrieve_result.excerpt_range, - }; - - output_tx.unbounded_send(result).ok(); - } - - println!( - "{:02}/{:02} done", - done_count.fetch_add(1, atomic::Ordering::Relaxed) + 1, - files_len, - ); - - anyhow::Ok(()) - }) - }) - .collect::>(); - - drop(output_tx); - - let df_task = cx.background_spawn(build_dataframe(output_rx)); - - futures::future::try_join_all(tasks).await?; - let mut df = df_task.await?; - - let run_id = format!( - "{}-{}", - worktree_path.file_stem().unwrap_or_default().display(), - chrono::Local::now().format("%Y%m%d_%H%M%S") - ); - let run_dir = target_cli_dir.join(run_id); - fs::create_dir(&run_dir).unwrap(); - - let parquet_path = run_dir.join("stats.parquet"); - let mut parquet_file = fs::File::create(&parquet_path)?; - - ParquetWriter::new(&mut parquet_file) - .finish(&mut df) - .unwrap(); - - let stats = SummaryStats::from_dataframe(df)?; - - let stats_path = run_dir.join("stats.txt"); - fs::write(&stats_path, format!("{}", stats))?; - - println!("{}", stats); - println!("\nWrote:"); - println!("- {}", relativize_path(&parquet_path).display()); - println!("- {}", relativize_path(&stats_path).display()); - println!("- {}", relativize_path(&lsp_definitions_path).display()); - - Ok("".to_string()) -} - -async fn build_dataframe( - mut output_rx: mpsc::UnboundedReceiver, -) -> Result { - use soa_rs::{Soa, Soars}; - - #[derive(Default, Soars)] - struct Row { - ref_id: u32, - cursor_path: String, - cursor_row: u32, - cursor_column: u32, - cursor_identifier: String, - gold_in_excerpt: bool, - gold_path: String, - gold_row: u32, - gold_column: u32, - gold_is_external: bool, - candidate_count: u32, - candidate_path: Option, - candidate_row: Option, - candidate_column: Option, - candidate_is_gold: Option, - candidate_rank: Option, - candidate_is_same_file: Option, - candidate_is_referenced_nearby: Option, - candidate_is_referenced_in_breadcrumb: Option, - candidate_reference_count: Option, - candidate_same_file_declaration_count: Option, - candidate_declaration_count: Option, - candidate_reference_line_distance: Option, - candidate_declaration_line_distance: Option, - candidate_excerpt_vs_item_jaccard: Option, - candidate_excerpt_vs_signature_jaccard: Option, - candidate_adjacent_vs_item_jaccard: Option, - candidate_adjacent_vs_signature_jaccard: Option, - candidate_excerpt_vs_item_weighted_overlap: Option, - candidate_excerpt_vs_signature_weighted_overlap: Option, - candidate_adjacent_vs_item_weighted_overlap: Option, - candidate_adjacent_vs_signature_weighted_overlap: Option, - candidate_path_import_match_count: Option, - candidate_wildcard_path_import_match_count: Option, - candidate_import_similarity: Option, - candidate_max_import_similarity: Option, - candidate_normalized_import_similarity: Option, - candidate_wildcard_import_similarity: Option, - candidate_normalized_wildcard_import_similarity: Option, - candidate_included_by_others: Option, - candidate_includes_others: Option, - } - let mut rows = Soa::::new(); - let mut next_ref_id = 0; - - while let Some(result) = output_rx.next().await { - let mut gold_is_external = false; - let mut gold_in_excerpt = false; - let cursor_path = result.cursor_path.as_unix_str(); - let cursor_row = result.cursor_point.row + 1; - let cursor_column = result.cursor_point.column + 1; - let cursor_identifier = result.identifier.name.to_string(); - let ref_id = next_ref_id; - next_ref_id += 1; - - for lsp_definition in result.lsp_definitions { - let SourceRange { - path: gold_path, - point_range: gold_point_range, - offset_range: gold_offset_range, - } = lsp_definition; - let lsp_point_range = - SerializablePoint::into_language_point_range(gold_point_range.clone()); - - gold_is_external = gold_is_external - || gold_path.is_absolute() - || gold_path - .components() - .any(|component| component.as_os_str() == "node_modules"); - - gold_in_excerpt = gold_in_excerpt - || result.excerpt_range.as_ref().is_some_and(|excerpt_range| { - excerpt_range.contains_inclusive(&gold_offset_range) - }); - - let gold_row = gold_point_range.start.row; - let gold_column = gold_point_range.start.column; - let candidate_count = result.retrieved_definitions.len() as u32; - - for (candidate_rank, retrieved_definition) in - result.retrieved_definitions.iter().enumerate() - { - let candidate_is_gold = gold_path.as_path() - == retrieved_definition.path.as_std_path() - && retrieved_definition - .range - .contains_inclusive(&lsp_point_range); - - let candidate_row = retrieved_definition.range.start.row + 1; - let candidate_column = retrieved_definition.range.start.column + 1; - - let DeclarationScoreComponents { - is_same_file, - is_referenced_nearby, - is_referenced_in_breadcrumb, - reference_count, - same_file_declaration_count, - declaration_count, - reference_line_distance, - declaration_line_distance, - excerpt_vs_item_jaccard, - excerpt_vs_signature_jaccard, - adjacent_vs_item_jaccard, - adjacent_vs_signature_jaccard, - excerpt_vs_item_weighted_overlap, - excerpt_vs_signature_weighted_overlap, - adjacent_vs_item_weighted_overlap, - adjacent_vs_signature_weighted_overlap, - path_import_match_count, - wildcard_path_import_match_count, - import_similarity, - max_import_similarity, - normalized_import_similarity, - wildcard_import_similarity, - normalized_wildcard_import_similarity, - included_by_others, - includes_others, - } = retrieved_definition.components; - - rows.push(Row { - ref_id, - cursor_path: cursor_path.to_string(), - cursor_row, - cursor_column, - cursor_identifier: cursor_identifier.clone(), - gold_in_excerpt, - gold_path: gold_path.to_string_lossy().to_string(), - gold_row, - gold_column, - gold_is_external, - candidate_count, - candidate_path: Some(retrieved_definition.path.as_unix_str().to_string()), - candidate_row: Some(candidate_row), - candidate_column: Some(candidate_column), - candidate_is_gold: Some(candidate_is_gold), - candidate_rank: Some(candidate_rank as u32), - candidate_is_same_file: Some(is_same_file), - candidate_is_referenced_nearby: Some(is_referenced_nearby), - candidate_is_referenced_in_breadcrumb: Some(is_referenced_in_breadcrumb), - candidate_reference_count: Some(reference_count as u32), - candidate_same_file_declaration_count: Some(same_file_declaration_count as u32), - candidate_declaration_count: Some(declaration_count as u32), - candidate_reference_line_distance: Some(reference_line_distance), - candidate_declaration_line_distance: Some(declaration_line_distance), - candidate_excerpt_vs_item_jaccard: Some(excerpt_vs_item_jaccard), - candidate_excerpt_vs_signature_jaccard: Some(excerpt_vs_signature_jaccard), - candidate_adjacent_vs_item_jaccard: Some(adjacent_vs_item_jaccard), - candidate_adjacent_vs_signature_jaccard: Some(adjacent_vs_signature_jaccard), - candidate_excerpt_vs_item_weighted_overlap: Some( - excerpt_vs_item_weighted_overlap, - ), - candidate_excerpt_vs_signature_weighted_overlap: Some( - excerpt_vs_signature_weighted_overlap, - ), - candidate_adjacent_vs_item_weighted_overlap: Some( - adjacent_vs_item_weighted_overlap, - ), - candidate_adjacent_vs_signature_weighted_overlap: Some( - adjacent_vs_signature_weighted_overlap, - ), - candidate_path_import_match_count: Some(path_import_match_count as u32), - candidate_wildcard_path_import_match_count: Some( - wildcard_path_import_match_count as u32, - ), - candidate_import_similarity: Some(import_similarity), - candidate_max_import_similarity: Some(max_import_similarity), - candidate_normalized_import_similarity: Some(normalized_import_similarity), - candidate_wildcard_import_similarity: Some(wildcard_import_similarity), - candidate_normalized_wildcard_import_similarity: Some( - normalized_wildcard_import_similarity, - ), - candidate_included_by_others: Some(included_by_others as u32), - candidate_includes_others: Some(includes_others as u32), - }); - } - - if result.retrieved_definitions.is_empty() { - rows.push(Row { - ref_id, - cursor_path: cursor_path.to_string(), - cursor_row, - cursor_column, - cursor_identifier: cursor_identifier.clone(), - gold_in_excerpt, - gold_path: gold_path.to_string_lossy().to_string(), - gold_row, - gold_column, - gold_is_external, - candidate_count, - ..Default::default() - }); - } - } - } - let slices = rows.slices(); - - let RowSlices { - ref_id, - cursor_path, - cursor_row, - cursor_column, - cursor_identifier, - gold_in_excerpt, - gold_path, - gold_row, - gold_column, - gold_is_external, - candidate_path, - candidate_row, - candidate_column, - candidate_is_gold, - candidate_rank, - candidate_count, - candidate_is_same_file, - candidate_is_referenced_nearby, - candidate_is_referenced_in_breadcrumb, - candidate_reference_count, - candidate_same_file_declaration_count, - candidate_declaration_count, - candidate_reference_line_distance, - candidate_declaration_line_distance, - candidate_excerpt_vs_item_jaccard, - candidate_excerpt_vs_signature_jaccard, - candidate_adjacent_vs_item_jaccard, - candidate_adjacent_vs_signature_jaccard, - candidate_excerpt_vs_item_weighted_overlap, - candidate_excerpt_vs_signature_weighted_overlap, - candidate_adjacent_vs_item_weighted_overlap, - candidate_adjacent_vs_signature_weighted_overlap, - candidate_path_import_match_count, - candidate_wildcard_path_import_match_count, - candidate_import_similarity, - candidate_max_import_similarity, - candidate_normalized_import_similarity, - candidate_wildcard_import_similarity, - candidate_normalized_wildcard_import_similarity, - candidate_included_by_others, - candidate_includes_others, - } = slices; - - let df = DataFrame::new(vec![ - Series::new(PlSmallStr::from_str("ref_id"), ref_id).into(), - Series::new(PlSmallStr::from_str("cursor_path"), cursor_path).into(), - Series::new(PlSmallStr::from_str("cursor_row"), cursor_row).into(), - Series::new(PlSmallStr::from_str("cursor_column"), cursor_column).into(), - Series::new(PlSmallStr::from_str("cursor_identifier"), cursor_identifier).into(), - Series::new(PlSmallStr::from_str("gold_in_excerpt"), gold_in_excerpt).into(), - Series::new(PlSmallStr::from_str("gold_path"), gold_path).into(), - Series::new(PlSmallStr::from_str("gold_row"), gold_row).into(), - Series::new(PlSmallStr::from_str("gold_column"), gold_column).into(), - Series::new(PlSmallStr::from_str("gold_is_external"), gold_is_external).into(), - Series::new(PlSmallStr::from_str("candidate_count"), candidate_count).into(), - Series::new(PlSmallStr::from_str("candidate_path"), candidate_path).into(), - Series::new(PlSmallStr::from_str("candidate_row"), candidate_row).into(), - Series::new(PlSmallStr::from_str("candidate_column"), candidate_column).into(), - Series::new(PlSmallStr::from_str("candidate_is_gold"), candidate_is_gold).into(), - Series::new(PlSmallStr::from_str("candidate_rank"), candidate_rank).into(), - Series::new( - PlSmallStr::from_str("candidate_is_same_file"), - candidate_is_same_file, - ) - .into(), - Series::new( - PlSmallStr::from_str("candidate_is_referenced_nearby"), - candidate_is_referenced_nearby, - ) - .into(), - Series::new( - PlSmallStr::from_str("candidate_is_referenced_in_breadcrumb"), - candidate_is_referenced_in_breadcrumb, - ) - .into(), - Series::new( - PlSmallStr::from_str("candidate_reference_count"), - candidate_reference_count, - ) - .into(), - Series::new( - PlSmallStr::from_str("candidate_same_file_declaration_count"), - candidate_same_file_declaration_count, - ) - .into(), - Series::new( - PlSmallStr::from_str("candidate_declaration_count"), - candidate_declaration_count, - ) - .into(), - Series::new( - PlSmallStr::from_str("candidate_reference_line_distance"), - candidate_reference_line_distance, - ) - .into(), - Series::new( - PlSmallStr::from_str("candidate_declaration_line_distance"), - candidate_declaration_line_distance, - ) - .into(), - Series::new( - PlSmallStr::from_str("candidate_excerpt_vs_item_jaccard"), - candidate_excerpt_vs_item_jaccard, - ) - .into(), - Series::new( - PlSmallStr::from_str("candidate_excerpt_vs_signature_jaccard"), - candidate_excerpt_vs_signature_jaccard, - ) - .into(), - Series::new( - PlSmallStr::from_str("candidate_adjacent_vs_item_jaccard"), - candidate_adjacent_vs_item_jaccard, - ) - .into(), - Series::new( - PlSmallStr::from_str("candidate_adjacent_vs_signature_jaccard"), - candidate_adjacent_vs_signature_jaccard, - ) - .into(), - Series::new( - PlSmallStr::from_str("candidate_excerpt_vs_item_weighted_overlap"), - candidate_excerpt_vs_item_weighted_overlap, - ) - .into(), - Series::new( - PlSmallStr::from_str("candidate_excerpt_vs_signature_weighted_overlap"), - candidate_excerpt_vs_signature_weighted_overlap, - ) - .into(), - Series::new( - PlSmallStr::from_str("candidate_adjacent_vs_item_weighted_overlap"), - candidate_adjacent_vs_item_weighted_overlap, - ) - .into(), - Series::new( - PlSmallStr::from_str("candidate_adjacent_vs_signature_weighted_overlap"), - candidate_adjacent_vs_signature_weighted_overlap, - ) - .into(), - Series::new( - PlSmallStr::from_str("candidate_path_import_match_count"), - candidate_path_import_match_count, - ) - .into(), - Series::new( - PlSmallStr::from_str("candidate_wildcard_path_import_match_count"), - candidate_wildcard_path_import_match_count, - ) - .into(), - Series::new( - PlSmallStr::from_str("candidate_import_similarity"), - candidate_import_similarity, - ) - .into(), - Series::new( - PlSmallStr::from_str("candidate_max_import_similarity"), - candidate_max_import_similarity, - ) - .into(), - Series::new( - PlSmallStr::from_str("candidate_normalized_import_similarity"), - candidate_normalized_import_similarity, - ) - .into(), - Series::new( - PlSmallStr::from_str("candidate_wildcard_import_similarity"), - candidate_wildcard_import_similarity, - ) - .into(), - Series::new( - PlSmallStr::from_str("candidate_normalized_wildcard_import_similarity"), - candidate_normalized_wildcard_import_similarity, - ) - .into(), - Series::new( - PlSmallStr::from_str("candidate_included_by_others"), - candidate_included_by_others, - ) - .into(), - Series::new( - PlSmallStr::from_str("candidate_includes_others"), - candidate_includes_others, - ) - .into(), - ])?; - - Ok(df) -} - -fn relativize_path(path: &Path) -> &Path { - path.strip_prefix(std::env::current_dir().unwrap()) - .unwrap_or(path) -} - -struct SummaryStats { - references_count: u32, - retrieved_count: u32, - top_match_count: u32, - non_top_match_count: u32, - ranking_involved_top_match_count: u32, - missing_none_retrieved: u32, - missing_wrong_retrieval: u32, - missing_external: u32, - in_excerpt_count: u32, -} - -impl SummaryStats { - fn from_dataframe(df: DataFrame) -> Result { - // TODO: use lazy more - let unique_refs = - df.unique::<(), ()>(Some(&["ref_id".into()]), UniqueKeepStrategy::Any, None)?; - let references_count = unique_refs.height() as u32; - - let gold_mask = df.column("candidate_is_gold")?.bool()?; - let gold_df = df.filter(&gold_mask)?; - let retrieved_count = gold_df.height() as u32; - - let top_match_mask = gold_df.column("candidate_rank")?.u32()?.equal(0); - let top_match_df = gold_df.filter(&top_match_mask)?; - let top_match_count = top_match_df.height() as u32; - - let ranking_involved_top_match_count = top_match_df - .column("candidate_count")? - .u32()? - .gt(1) - .sum() - .unwrap_or_default(); - - let non_top_match_count = (!top_match_mask).sum().unwrap_or(0); - - let not_retrieved_df = df - .lazy() - .group_by(&[col("ref_id"), col("candidate_count")]) - .agg(&[ - col("candidate_is_gold") - .fill_null(false) - .sum() - .alias("gold_count"), - col("gold_in_excerpt").sum().alias("gold_in_excerpt_count"), - col("gold_is_external") - .sum() - .alias("gold_is_external_count"), - ]) - .filter(col("gold_count").eq(lit(0))) - .collect()?; - - let in_excerpt_mask = not_retrieved_df - .column("gold_in_excerpt_count")? - .u32()? - .gt(0); - let in_excerpt_count = in_excerpt_mask.sum().unwrap_or(0); - - let missing_df = not_retrieved_df.filter(&!in_excerpt_mask)?; - - let missing_none_retrieved_mask = missing_df.column("candidate_count")?.u32()?.equal(0); - let missing_none_retrieved = missing_none_retrieved_mask.sum().unwrap_or(0); - let external_mask = missing_df.column("gold_is_external_count")?.u32()?.gt(0); - let missing_external = (missing_none_retrieved_mask & external_mask) - .sum() - .unwrap_or(0); - - let missing_wrong_retrieval = missing_df - .column("candidate_count")? - .u32()? - .gt(0) - .sum() - .unwrap_or(0); - - Ok(SummaryStats { - references_count, - retrieved_count, - top_match_count, - non_top_match_count, - ranking_involved_top_match_count, - missing_none_retrieved, - missing_wrong_retrieval, - missing_external, - in_excerpt_count, - }) - } - - fn count_and_percentage(part: u32, total: u32) -> String { - format!("{} ({:.2}%)", part, (part as f64 / total as f64) * 100.0) - } -} - -impl std::fmt::Display for SummaryStats { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - let included = self.in_excerpt_count + self.retrieved_count; - let missing = self.references_count - included; - writeln!(f)?; - writeln!(f, "╮ references: {}", self.references_count)?; - writeln!( - f, - "├─╮ included: {}", - Self::count_and_percentage(included, self.references_count), - )?; - writeln!( - f, - "│ ├─╮ retrieved: {}", - Self::count_and_percentage(self.retrieved_count, self.references_count) - )?; - writeln!( - f, - "│ │ ├─╮ top match : {}", - Self::count_and_percentage(self.top_match_count, self.retrieved_count) - )?; - writeln!( - f, - "│ │ │ ╰─╴ involving ranking: {}", - Self::count_and_percentage(self.ranking_involved_top_match_count, self.top_match_count) - )?; - writeln!( - f, - "│ │ ╰─╴ non-top match: {}", - Self::count_and_percentage(self.non_top_match_count, self.retrieved_count) - )?; - writeln!( - f, - "│ ╰─╴ in excerpt: {}", - Self::count_and_percentage(self.in_excerpt_count, included) - )?; - writeln!( - f, - "╰─╮ missing: {}", - Self::count_and_percentage(missing, self.references_count) - )?; - writeln!( - f, - " ├─╮ none retrieved: {}", - Self::count_and_percentage(self.missing_none_retrieved, missing) - )?; - writeln!( - f, - " │ ╰─╴ external (expected): {}", - Self::count_and_percentage(self.missing_external, missing) - )?; - writeln!( - f, - " ╰─╴ wrong retrieval: {}", - Self::count_and_percentage(self.missing_wrong_retrieval, missing) - )?; - Ok(()) - } -} - -#[derive(Debug)] -struct ReferenceRetrievalResult { - cursor_path: Arc, - cursor_point: Point, - identifier: Identifier, - excerpt_range: Option>, - lsp_definitions: Vec, - retrieved_definitions: Vec, -} - -#[derive(Debug)] -struct RetrievedDefinition { - path: Arc, - range: Range, - score: f32, - #[allow(dead_code)] - retrieval_score: f32, - #[allow(dead_code)] - components: DeclarationScoreComponents, -} - -struct RetrieveResult { - definitions: Vec, - excerpt_range: Option>, -} - -async fn retrieve_definitions( - reference: &Reference, - imports: &Imports, - query_point: Point, - snapshot: &BufferSnapshot, - index: &Arc, - file_snapshots: &Arc>, - context_options: &EditPredictionContextOptions, -) -> Result { - let mut single_reference_map = HashMap::default(); - single_reference_map.insert(reference.identifier.clone(), vec![reference.clone()]); - let edit_prediction_context = EditPredictionContext::gather_context_with_references_fn( - query_point, - snapshot, - imports, - &context_options, - Some(&index), - |_, _, _| single_reference_map, - ); - - let Some(edit_prediction_context) = edit_prediction_context else { - return Ok(RetrieveResult { - definitions: Vec::new(), - excerpt_range: None, - }); - }; - - let mut retrieved_definitions = Vec::new(); - for scored_declaration in edit_prediction_context.declarations { - match &scored_declaration.declaration { - Declaration::File { - project_entry_id, - declaration, - .. - } => { - let Some(snapshot) = file_snapshots.get(&project_entry_id) else { - log::error!("bug: file project entry not found"); - continue; - }; - let path = snapshot.file().unwrap().path().clone(); - retrieved_definitions.push(RetrievedDefinition { - path, - range: snapshot.offset_to_point(declaration.item_range.start) - ..snapshot.offset_to_point(declaration.item_range.end), - score: scored_declaration.score(DeclarationStyle::Declaration), - retrieval_score: scored_declaration.retrieval_score(), - components: scored_declaration.components, - }); - } - Declaration::Buffer { - project_entry_id, - rope, - declaration, - .. - } => { - let Some(snapshot) = file_snapshots.get(&project_entry_id) else { - // This case happens when dependency buffers have been opened by - // go-to-definition, resulting in single-file worktrees. - continue; - }; - let path = snapshot.file().unwrap().path().clone(); - retrieved_definitions.push(RetrievedDefinition { - path, - range: rope.offset_to_point(declaration.item_range.start) - ..rope.offset_to_point(declaration.item_range.end), - score: scored_declaration.score(DeclarationStyle::Declaration), - retrieval_score: scored_declaration.retrieval_score(), - components: scored_declaration.components, - }); - } - } - } - retrieved_definitions.sort_by_key(|definition| Reverse(OrderedFloat(definition.score))); - - Ok(RetrieveResult { - definitions: retrieved_definitions, - excerpt_range: Some(edit_prediction_context.excerpt.range), - }) -} - -async fn gather_lsp_definitions( - lsp_definitions_path: &Path, - start_index: usize, - files: &[ProjectPath], - worktree: &Entity, - project: &Entity, - definitions: &mut HashMap>, - cx: &mut AsyncApp, -) -> Result<()> { - let worktree_id = worktree.read_with(cx, |worktree, _cx| worktree.id())?; - - let lsp_store = project.read_with(cx, |project, _cx| project.lsp_store())?; - cx.subscribe(&lsp_store, { - move |_, event, _| { - if let project::LspStoreEvent::LanguageServerUpdate { - message: - client::proto::update_language_server::Variant::WorkProgress( - client::proto::LspWorkProgress { - message: Some(message), - .. - }, - ), - .. - } = event - { - println!("⟲ {message}") - } - } - })? - .detach(); - - let (cache_line_tx, mut cache_line_rx) = mpsc::unbounded::(); - - let cache_file = File::options() - .append(true) - .create(true) - .open(lsp_definitions_path) - .unwrap(); - - let cache_task = cx.background_spawn(async move { - let mut writer = BufWriter::new(cache_file); - while let Some(line) = cache_line_rx.next().await { - serde_json::to_writer(&mut writer, &line).unwrap(); - writer.write_all(&[b'\n']).unwrap(); - } - writer.flush().unwrap(); - }); - - let mut error_count = 0; - let mut lsp_open_handles = Vec::new(); - let mut ready_languages = HashSet::default(); - for (file_index, project_path) in files[start_index..].iter().enumerate() { - println!( - "Processing file {} of {}: {}", - start_index + file_index + 1, - files.len(), - project_path.path.display(PathStyle::Posix) - ); - - let Some((lsp_open_handle, language_server_id, buffer)) = open_buffer_with_language_server( - project.clone(), - worktree.clone(), - project_path.path.clone(), - &mut ready_languages, - cx, - ) - .await - .log_err() else { - continue; - }; - lsp_open_handles.push(lsp_open_handle); - - let snapshot = buffer.read_with(cx, |buffer, _cx| buffer.snapshot())?; - let full_range = 0..snapshot.len(); - let references = references_in_range( - full_range, - &snapshot.text(), - ReferenceRegion::Nearby, - &snapshot, - ); - - loop { - let is_ready = lsp_store - .read_with(cx, |lsp_store, _cx| { - lsp_store - .language_server_statuses - .get(&language_server_id) - .is_some_and(|status| status.pending_work.is_empty()) - }) - .unwrap(); - if is_ready { - break; - } - cx.background_executor() - .timer(Duration::from_millis(10)) - .await; - } - - let mut cache_line_references = Vec::with_capacity(references.len()); - - for reference in references { - // TODO: Rename declaration to definition in edit_prediction_context? - let lsp_result = project - .update(cx, |project, cx| { - project.definitions(&buffer, reference.range.start, cx) - })? - .await; - - match lsp_result { - Ok(lsp_definitions) => { - let mut targets = Vec::new(); - for target in lsp_definitions.unwrap_or_default() { - let buffer = target.target.buffer; - let anchor_range = target.target.range; - buffer.read_with(cx, |buffer, cx| { - let Some(file) = project::File::from_dyn(buffer.file()) else { - return; - }; - let file_worktree = file.worktree.read(cx); - let file_worktree_id = file_worktree.id(); - // Relative paths for worktree files, absolute for all others - let path = if worktree_id != file_worktree_id { - file.worktree.read(cx).absolutize(&file.path) - } else { - file.path.as_std_path().to_path_buf() - }; - let offset_range = anchor_range.to_offset(&buffer); - let point_range = SerializablePoint::from_language_point_range( - offset_range.to_point(&buffer), - ); - targets.push(SourceRange { - path, - offset_range, - point_range, - }); - })?; - } - - let point = snapshot.offset_to_point(reference.range.start); - - cache_line_references.push((point.into(), targets.clone())); - definitions.insert( - SourceLocation { - path: project_path.path.clone(), - point, - }, - targets, - ); - } - Err(err) => { - log::error!("Language server error: {err}"); - error_count += 1; - } - } - } - - cache_line_tx - .unbounded_send(FileLspDefinitions { - path: project_path.path.as_unix_str().into(), - references: cache_line_references, - }) - .log_err(); - } - - drop(cache_line_tx); - - if error_count > 0 { - log::error!("Encountered {} language server errors", error_count); - } - - cache_task.await; - - Ok(()) -} - -#[derive(Serialize, Deserialize)] -struct FileLspDefinitions { - path: Arc, - references: Vec<(SerializablePoint, Vec)>, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -struct SourceRange { - path: PathBuf, - point_range: Range, - offset_range: Range, -} - -/// Serializes to 1-based row and column indices. -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct SerializablePoint { - pub row: u32, - pub column: u32, -} - -impl SerializablePoint { - pub fn into_language_point_range(range: Range) -> Range { - range.start.into()..range.end.into() - } - - pub fn from_language_point_range(range: Range) -> Range { - range.start.into()..range.end.into() - } -} - -impl From for SerializablePoint { - fn from(point: Point) -> Self { - SerializablePoint { - row: point.row + 1, - column: point.column + 1, - } - } -} - -impl From for Point { - fn from(serializable: SerializablePoint) -> Self { - Point { - row: serializable.row.saturating_sub(1), - column: serializable.column.saturating_sub(1), - } - } -} From d6241b17d35c4eae1d23dfbde16cae0eb8187ac2 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 4 Dec 2025 22:51:26 -0800 Subject: [PATCH 070/621] Fix infinite loop in assemble_excerpts (#44195) Also, expand the number of identifiers fetched. Release Notes: - N/A --- crates/edit_prediction/src/edit_prediction.rs | 8 +- .../src/assemble_excerpts.rs | 165 +---------------- .../src/edit_prediction_context.rs | 33 +++- .../src/edit_prediction_context_tests.rs | 174 +++++++++++++++++- 4 files changed, 204 insertions(+), 176 deletions(-) diff --git a/crates/edit_prediction/src/edit_prediction.rs b/crates/edit_prediction/src/edit_prediction.rs index ddb29d0796a6c6b24ee3914533b29b967d224ac8..ea8f0af7e16dedd30a86284af5386829053d7fab 100644 --- a/crates/edit_prediction/src/edit_prediction.rs +++ b/crates/edit_prediction/src/edit_prediction.rs @@ -480,16 +480,16 @@ impl EditPredictionStore { shown_predictions: Default::default(), }; - this.enable_or_disable_context_retrieval(cx); + this.configure_context_retrieval(cx); let weak_this = cx.weak_entity(); cx.on_flags_ready(move |_, cx| { weak_this - .update(cx, |this, cx| this.enable_or_disable_context_retrieval(cx)) + .update(cx, |this, cx| this.configure_context_retrieval(cx)) .ok(); }) .detach(); cx.observe_global::(|this, cx| { - this.enable_or_disable_context_retrieval(cx); + this.configure_context_retrieval(cx); }) .detach(); @@ -1770,7 +1770,7 @@ impl EditPredictionStore { cx.notify(); } - fn enable_or_disable_context_retrieval(&mut self, cx: &mut Context<'_, EditPredictionStore>) { + fn configure_context_retrieval(&mut self, cx: &mut Context<'_, EditPredictionStore>) { self.use_context = cx.has_flag::() && all_language_settings(None, cx).edit_predictions.use_context; } diff --git a/crates/edit_prediction_context/src/assemble_excerpts.rs b/crates/edit_prediction_context/src/assemble_excerpts.rs index b3b8d4f8bc480053a1e9ab9d498d5350039ed609..15f4c03d653429af671c22d6b5abc652d282a38e 100644 --- a/crates/edit_prediction_context/src/assemble_excerpts.rs +++ b/crates/edit_prediction_context/src/assemble_excerpts.rs @@ -61,8 +61,8 @@ pub fn assemble_excerpts( buffer, &mut outline_ranges, ); - child_outline_ix += 1; } + child_outline_ix += 1; } } } @@ -159,166 +159,3 @@ pub fn merge_ranges(ranges: &mut Vec>) { } } } - -#[cfg(test)] -mod tests { - use super::*; - use gpui::{TestAppContext, prelude::*}; - use indoc::indoc; - use language::{Buffer, Language, LanguageConfig, LanguageMatcher, OffsetRangeExt}; - use pretty_assertions::assert_eq; - use std::{fmt::Write as _, sync::Arc}; - use util::test::marked_text_ranges; - - #[gpui::test] - fn test_rust(cx: &mut TestAppContext) { - let table = [ - ( - indoc! {r#" - struct User { - first_name: String, - «last_name»: String, - age: u32, - email: String, - create_at: Instant, - } - - impl User { - pub fn first_name(&self) -> String { - self.first_name.clone() - } - - pub fn full_name(&self) -> String { - « format!("{} {}", self.first_name, self.last_name) - » } - } - "#}, - indoc! {r#" - struct User { - first_name: String, - last_name: String, - … - } - - impl User { - … - pub fn full_name(&self) -> String { - format!("{} {}", self.first_name, self.last_name) - } - } - "#}, - ), - ( - indoc! {r#" - struct «User» { - first_name: String, - last_name: String, - age: u32, - } - - impl User { - // methods - } - "# - }, - indoc! {r#" - struct User { - first_name: String, - last_name: String, - age: u32, - } - … - "#}, - ), - ( - indoc! {r#" - trait «FooProvider» { - const NAME: &'static str; - - fn provide_foo(&self, id: usize) -> Foo; - - fn provide_foo_batched(&self, ids: &[usize]) -> Vec { - ids.iter() - .map(|id| self.provide_foo(*id)) - .collect() - } - - fn sync(&self); - } - "# - }, - indoc! {r#" - trait FooProvider { - const NAME: &'static str; - - fn provide_foo(&self, id: usize) -> Foo; - - fn provide_foo_batched(&self, ids: &[usize]) -> Vec { - … - } - - fn sync(&self); - } - "#}, - ), - ]; - - for (input, expected_output) in table { - let (input, ranges) = marked_text_ranges(&input, false); - let buffer = - cx.new(|cx| Buffer::local(input, cx).with_language(Arc::new(rust_lang()), cx)); - buffer.read_with(cx, |buffer, _cx| { - let ranges: Vec> = ranges - .into_iter() - .map(|range| range.to_point(&buffer)) - .collect(); - - let excerpts = assemble_excerpts(&buffer.snapshot(), ranges); - - let output = format_excerpts(buffer, &excerpts); - assert_eq!(output, expected_output); - }); - } - } - - fn format_excerpts(buffer: &Buffer, excerpts: &[RelatedExcerpt]) -> String { - let mut output = String::new(); - let file_line_count = buffer.max_point().row; - let mut current_row = 0; - for excerpt in excerpts { - if excerpt.text.is_empty() { - continue; - } - if current_row < excerpt.point_range.start.row { - writeln!(&mut output, "…").unwrap(); - } - current_row = excerpt.point_range.start.row; - - for line in excerpt.text.to_string().lines() { - output.push_str(line); - output.push('\n'); - current_row += 1; - } - } - if current_row < file_line_count { - writeln!(&mut output, "…").unwrap(); - } - output - } - - fn rust_lang() -> Language { - Language::new( - LanguageConfig { - name: "Rust".into(), - matcher: LanguageMatcher { - path_suffixes: vec!["rs".to_string()], - ..Default::default() - }, - ..Default::default() - }, - Some(language::tree_sitter_rust::LANGUAGE.into()), - ) - .with_outline_query(include_str!("../../languages/src/rust/outline.scm")) - .unwrap() - } -} diff --git a/crates/edit_prediction_context/src/edit_prediction_context.rs b/crates/edit_prediction_context/src/edit_prediction_context.rs index e316c5a052acd241e7d33356bd0d5dfa5fd075bd..475050fabb8b17ad76c34234094cf798e36a76ab 100644 --- a/crates/edit_prediction_context/src/edit_prediction_context.rs +++ b/crates/edit_prediction_context/src/edit_prediction_context.rs @@ -25,11 +25,14 @@ mod fake_definition_lsp; pub use cloud_llm_client::predict_edits_v3::Line; pub use excerpt::{EditPredictionExcerpt, EditPredictionExcerptOptions, EditPredictionExcerptText}; +const IDENTIFIER_LINE_COUNT: u32 = 3; + pub struct RelatedExcerptStore { project: WeakEntity, related_files: Vec, cache: HashMap>, update_tx: mpsc::UnboundedSender<(Entity, Anchor)>, + identifier_line_count: u32, } pub enum RelatedExcerptStoreEvent { @@ -178,9 +181,14 @@ impl RelatedExcerptStore { update_tx, related_files: Vec::new(), cache: Default::default(), + identifier_line_count: IDENTIFIER_LINE_COUNT, } } + pub fn set_identifier_line_count(&mut self, count: u32) { + self.identifier_line_count = count; + } + pub fn refresh(&mut self, buffer: Entity, position: Anchor, _: &mut Context) { self.update_tx.unbounded_send((buffer, position)).ok(); } @@ -195,8 +203,12 @@ impl RelatedExcerptStore { position: Anchor, cx: &mut AsyncApp, ) -> Result<()> { - let (project, snapshot) = this.read_with(cx, |this, cx| { - (this.project.upgrade(), buffer.read(cx).snapshot()) + let (project, snapshot, identifier_line_count) = this.read_with(cx, |this, cx| { + ( + this.project.upgrade(), + buffer.read(cx).snapshot(), + this.identifier_line_count, + ) })?; let Some(project) = project else { return Ok(()); @@ -212,7 +224,9 @@ impl RelatedExcerptStore { })?; let identifiers = cx - .background_spawn(async move { identifiers_for_position(&snapshot, position) }) + .background_spawn(async move { + identifiers_for_position(&snapshot, position, identifier_line_count) + }) .await; let async_cx = cx.clone(); @@ -393,14 +407,21 @@ fn process_definition( /// Gets all of the identifiers that are present in the given line, and its containing /// outline items. -fn identifiers_for_position(buffer: &BufferSnapshot, position: Anchor) -> Vec { +fn identifiers_for_position( + buffer: &BufferSnapshot, + position: Anchor, + identifier_line_count: u32, +) -> Vec { let offset = position.to_offset(buffer); let point = buffer.offset_to_point(offset); - let line_range = Point::new(point.row, 0)..Point::new(point.row + 1, 0).min(buffer.max_point()); + // Search for identifiers on lines adjacent to the cursor. + let start = Point::new(point.row.saturating_sub(identifier_line_count), 0); + let end = Point::new(point.row + identifier_line_count + 1, 0).min(buffer.max_point()); + let line_range = start..end; let mut ranges = vec![line_range.to_offset(&buffer)]; - // Include the range of the outline item itself, but not its body. + // Search for identifiers mentioned in headers/signatures of containing outline items. let outline_items = buffer.outline_items_as_offsets_containing(offset..offset, false, None); for item in outline_items { if let Some(body_range) = item.body_range(&buffer) { diff --git a/crates/edit_prediction_context/src/edit_prediction_context_tests.rs b/crates/edit_prediction_context/src/edit_prediction_context_tests.rs index 05d1becc2167837a5f9741d77e7bc96c2f5b8d34..f62df37e551db19145e9ea631b6ab6a16fefda78 100644 --- a/crates/edit_prediction_context/src/edit_prediction_context_tests.rs +++ b/crates/edit_prediction_context/src/edit_prediction_context_tests.rs @@ -7,8 +7,8 @@ use lsp::FakeLanguageServer; use project::{FakeFs, LocationLink, Project}; use serde_json::json; use settings::SettingsStore; -use std::sync::Arc; -use util::path; +use std::{fmt::Write as _, sync::Arc}; +use util::{path, test::marked_text_ranges}; #[gpui::test] async fn test_edit_prediction_context(cx: &mut TestAppContext) { @@ -37,6 +37,7 @@ async fn test_edit_prediction_context(cx: &mut TestAppContext) { buffer.anchor_before(offset) }; + store.set_identifier_line_count(0); store.refresh(buffer.clone(), position, cx); }); @@ -85,6 +86,150 @@ async fn test_edit_prediction_context(cx: &mut TestAppContext) { }); } +#[gpui::test] +fn test_assemble_excerpts(cx: &mut TestAppContext) { + let table = [ + ( + indoc! {r#" + struct User { + first_name: String, + «last_name»: String, + age: u32, + email: String, + create_at: Instant, + } + + impl User { + pub fn first_name(&self) -> String { + self.first_name.clone() + } + + pub fn full_name(&self) -> String { + « format!("{} {}", self.first_name, self.last_name) + » } + } + "#}, + indoc! {r#" + struct User { + first_name: String, + last_name: String, + … + } + + impl User { + … + pub fn full_name(&self) -> String { + format!("{} {}", self.first_name, self.last_name) + } + } + "#}, + ), + ( + indoc! {r#" + struct «User» { + first_name: String, + last_name: String, + age: u32, + } + + impl User { + // methods + } + "#}, + indoc! {r#" + struct User { + first_name: String, + last_name: String, + age: u32, + } + … + "#}, + ), + ( + indoc! {r#" + trait «FooProvider» { + const NAME: &'static str; + + fn provide_foo(&self, id: usize) -> Foo; + + fn provide_foo_batched(&self, ids: &[usize]) -> Vec { + ids.iter() + .map(|id| self.provide_foo(*id)) + .collect() + } + + fn sync(&self); + } + "# + }, + indoc! {r#" + trait FooProvider { + const NAME: &'static str; + + fn provide_foo(&self, id: usize) -> Foo; + + fn provide_foo_batched(&self, ids: &[usize]) -> Vec { + … + } + + fn sync(&self); + } + "#}, + ), + ( + indoc! {r#" + trait «Something» { + fn method1(&self, id: usize) -> Foo; + + fn method2(&self, ids: &[usize]) -> Vec { + struct Helper1 { + field1: usize, + } + + struct Helper2 { + field2: usize, + } + + struct Helper3 { + filed2: usize, + } + } + + fn sync(&self); + } + "# + }, + indoc! {r#" + trait Something { + fn method1(&self, id: usize) -> Foo; + + fn method2(&self, ids: &[usize]) -> Vec { + … + } + + fn sync(&self); + } + "#}, + ), + ]; + + for (input, expected_output) in table { + let (input, ranges) = marked_text_ranges(&input, false); + let buffer = cx.new(|cx| Buffer::local(input, cx).with_language(rust_lang(), cx)); + buffer.read_with(cx, |buffer, _cx| { + let ranges: Vec> = ranges + .into_iter() + .map(|range| range.to_point(&buffer)) + .collect(); + + let excerpts = assemble_excerpts(&buffer.snapshot(), ranges); + + let output = format_excerpts(buffer, &excerpts); + assert_eq!(output, expected_output); + }); + } +} + #[gpui::test] async fn test_fake_definition_lsp(cx: &mut TestAppContext) { init_test(cx); @@ -339,6 +484,31 @@ fn assert_definitions(definitions: &[LocationLink], first_lines: &[&str], cx: &m assert_eq!(actual_first_lines, first_lines); } +fn format_excerpts(buffer: &Buffer, excerpts: &[RelatedExcerpt]) -> String { + let mut output = String::new(); + let file_line_count = buffer.max_point().row; + let mut current_row = 0; + for excerpt in excerpts { + if excerpt.text.is_empty() { + continue; + } + if current_row < excerpt.point_range.start.row { + writeln!(&mut output, "…").unwrap(); + } + current_row = excerpt.point_range.start.row; + + for line in excerpt.text.to_string().lines() { + output.push_str(line); + output.push('\n'); + current_row += 1; + } + } + if current_row < file_line_count { + writeln!(&mut output, "…").unwrap(); + } + output +} + pub(crate) fn rust_lang() -> Arc { Arc::new( Language::new( From 35da6d000aa047484bd5d489ecee6455c39cda57 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Fri, 5 Dec 2025 12:08:04 +0100 Subject: [PATCH 071/621] debugger: Fix evaluate selection running two evaluations & failing for Python and go (#44205) Evaluate selection now acts as if the text was typed verbatim into the console. Closes ##33526 Release Notes: - debugger: Fixed "evaluate selection" not behaving as if the highlighted text was not typed verbatim into the console. --- crates/debugger_ui/src/debugger_ui.rs | 13 +++++++++++-- crates/debugger_ui/src/new_process_modal.rs | 2 +- crates/project/src/debugger/session.rs | 2 ++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/crates/debugger_ui/src/debugger_ui.rs b/crates/debugger_ui/src/debugger_ui.rs index a9abb50bb68851334285b05064176e0347474014..bd5a7cda4a21a3d3fd0ac132d6ba2e7aace68722 100644 --- a/crates/debugger_ui/src/debugger_ui.rs +++ b/crates/debugger_ui/src/debugger_ui.rs @@ -387,7 +387,7 @@ pub fn init(cx: &mut App) { window.on_action( TypeId::of::(), move |_, _, window, cx| { - maybe!({ + let status = maybe!({ let text = editor .update(cx, |editor, cx| { let range = editor @@ -411,7 +411,13 @@ pub fn init(cx: &mut App) { state.session().update(cx, |session, cx| { session - .evaluate(text, None, stack_id, None, cx) + .evaluate( + text, + Some(dap::EvaluateArgumentsContext::Repl), + stack_id, + None, + cx, + ) .detach(); }); }); @@ -419,6 +425,9 @@ pub fn init(cx: &mut App) { Some(()) }); + if status.is_some() { + cx.stop_propagation(); + } }, ); }) diff --git a/crates/debugger_ui/src/new_process_modal.rs b/crates/debugger_ui/src/new_process_modal.rs index 40187cef9cc55cb4192a3cea773f42dca15a2571..ca13e3eed5fd770e8b80f0cd5b8610ff1e9e2f51 100644 --- a/crates/debugger_ui/src/new_process_modal.rs +++ b/crates/debugger_ui/src/new_process_modal.rs @@ -1023,7 +1023,7 @@ impl DebugDelegate { Some(TaskSourceKind::Lsp { language_name, .. }) => { Some(format!("LSP: {language_name}")) } - Some(TaskSourceKind::Language { name }) => Some(format!("Lang: {name}")), + Some(TaskSourceKind::Language { name }) => Some(format!("Language: {name}")), _ => context.clone().and_then(|ctx| { ctx.task_context .task_variables diff --git a/crates/project/src/debugger/session.rs b/crates/project/src/debugger/session.rs index b5fbfd80d6152faf9d04715138859dc565e8cba8..47fe98827cbc163682ef6f002eff4008967d4ced 100644 --- a/crates/project/src/debugger/session.rs +++ b/crates/project/src/debugger/session.rs @@ -2656,6 +2656,8 @@ impl Session { this.update(cx, |this, cx| { this.memory.clear(cx.background_executor()); this.invalidate_command_type::(); + this.invalidate_command_type::(); + cx.emit(SessionEvent::Variables); match response { Ok(response) => { let event = dap::OutputEvent { From a5ab5c7d5dae496123624ed655ecd6ecd456b05a Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Fri, 5 Dec 2025 13:35:05 +0100 Subject: [PATCH 072/621] gpui: Document the leak detector (#44208) Release Notes: - N/A *or* Added/Fixed/Improved ... --- crates/gpui/src/app/entity_map.rs | 112 ++++++++++++++++++++++++++++-- 1 file changed, 107 insertions(+), 5 deletions(-) diff --git a/crates/gpui/src/app/entity_map.rs b/crates/gpui/src/app/entity_map.rs index 81dbfdbf5733eed92a77fc2dc18fb971bd9bd4a7..8c1bdfa1cee509dcbc061200cb651ce5d3bf4fcd 100644 --- a/crates/gpui/src/app/entity_map.rs +++ b/crates/gpui/src/app/entity_map.rs @@ -584,7 +584,33 @@ impl AnyWeakEntity { }) } - /// Assert that entity referenced by this weak handle has been released. + /// Asserts that the entity referenced by this weak handle has been fully released. + /// + /// # Example + /// + /// ```ignore + /// let entity = cx.new(|_| MyEntity::new()); + /// let weak = entity.downgrade(); + /// drop(entity); + /// + /// // Verify the entity was released + /// weak.assert_released(); + /// ``` + /// + /// # Debugging Leaks + /// + /// If this method panics due to leaked handles, set the `LEAK_BACKTRACE` environment + /// variable to see where the leaked handles were allocated: + /// + /// ```bash + /// LEAK_BACKTRACE=1 cargo test my_test + /// ``` + /// + /// # Panics + /// + /// - Panics if any strong handles to the entity are still alive. + /// - Panics if the entity was recently dropped but cleanup hasn't completed yet + /// (resources are retained until the end of the effect cycle). #[cfg(any(test, feature = "leak-detection"))] pub fn assert_released(&self) { self.entity_ref_counts @@ -814,16 +840,70 @@ impl PartialOrd for WeakEntity { } } +/// Controls whether backtraces are captured when entity handles are created. +/// +/// Set the `LEAK_BACKTRACE` environment variable to any non-empty value to enable +/// backtrace capture. This helps identify where leaked handles were allocated. #[cfg(any(test, feature = "leak-detection"))] static LEAK_BACKTRACE: std::sync::LazyLock = std::sync::LazyLock::new(|| std::env::var("LEAK_BACKTRACE").is_ok_and(|b| !b.is_empty())); +/// Unique identifier for a specific entity handle instance. +/// +/// This is distinct from `EntityId` - while multiple handles can point to the same +/// entity (same `EntityId`), each handle has its own unique `HandleId`. #[cfg(any(test, feature = "leak-detection"))] #[derive(Clone, Copy, Debug, Default, Hash, PartialEq, Eq)] pub(crate) struct HandleId { - id: u64, // id of the handle itself, not the pointed at object + id: u64, } +/// Tracks entity handle allocations to detect leaks. +/// +/// The leak detector is enabled in tests and when the `leak-detection` feature is active. +/// It tracks every `Entity` and `AnyEntity` handle that is created and released, +/// allowing you to verify that all handles to an entity have been properly dropped. +/// +/// # How do leaks happen? +/// +/// Entities are reference-counted structures that can own other entities +/// allowing to form cycles. If such a strong-reference counted cycle is +/// created, all participating strong entities in this cycle will effectively +/// leak as they cannot be released anymore. +/// +/// # Usage +/// +/// You can use `WeakEntity::assert_released` or `AnyWeakEntity::assert_released` +/// to verify that an entity has been fully released: +/// +/// ```ignore +/// let entity = cx.new(|_| MyEntity::new()); +/// let weak = entity.downgrade(); +/// drop(entity); +/// +/// // This will panic if any handles to the entity are still alive +/// weak.assert_released(); +/// ``` +/// +/// # Debugging Leaks +/// +/// When a leak is detected, the detector will panic with information about the leaked +/// handles. To see where the leaked handles were allocated, set the `LEAK_BACKTRACE` +/// environment variable: +/// +/// ```bash +/// LEAK_BACKTRACE=1 cargo test my_test +/// ``` +/// +/// This will capture and display backtraces for each leaked handle, helping you +/// identify where handles were created but not released. +/// +/// # How It Works +/// +/// - When an entity handle is created (via `Entity::new`, `Entity::clone`, or +/// `WeakEntity::upgrade`), `handle_created` is called to register the handle. +/// - When a handle is dropped, `handle_released` removes it from tracking. +/// - `assert_released` verifies that no handles remain for a given entity. #[cfg(any(test, feature = "leak-detection"))] pub(crate) struct LeakDetector { next_handle_id: u64, @@ -832,6 +912,11 @@ pub(crate) struct LeakDetector { #[cfg(any(test, feature = "leak-detection"))] impl LeakDetector { + /// Records that a new handle has been created for the given entity. + /// + /// Returns a unique `HandleId` that must be passed to `handle_released` when + /// the handle is dropped. If `LEAK_BACKTRACE` is set, captures a backtrace + /// at the allocation site. #[track_caller] pub fn handle_created(&mut self, entity_id: EntityId) -> HandleId { let id = util::post_inc(&mut self.next_handle_id); @@ -844,23 +929,40 @@ impl LeakDetector { handle_id } + /// Records that a handle has been released (dropped). + /// + /// This removes the handle from tracking. The `handle_id` should be the same + /// one returned by `handle_created` when the handle was allocated. pub fn handle_released(&mut self, entity_id: EntityId, handle_id: HandleId) { let handles = self.entity_handles.entry(entity_id).or_default(); handles.remove(&handle_id); } + /// Asserts that all handles to the given entity have been released. + /// + /// # Panics + /// + /// Panics if any handles to the entity are still alive. The panic message + /// includes backtraces for each leaked handle if `LEAK_BACKTRACE` is set, + /// otherwise it suggests setting the environment variable to get more info. pub fn assert_released(&mut self, entity_id: EntityId) { + use std::fmt::Write as _; let handles = self.entity_handles.entry(entity_id).or_default(); if !handles.is_empty() { + let mut out = String::new(); for backtrace in handles.values_mut() { if let Some(mut backtrace) = backtrace.take() { backtrace.resolve(); - eprintln!("Leaked handle: {:#?}", backtrace); + writeln!(out, "Leaked handle:\n{:?}", backtrace).unwrap(); } else { - eprintln!("Leaked handle: export LEAK_BACKTRACE to find allocation site"); + writeln!( + out, + "Leaked handle: (export LEAK_BACKTRACE to find allocation site)" + ) + .unwrap(); } } - panic!(); + panic!("{out}"); } } } From 126d708fa1dc493e2d0fafb477bd814d40df0238 Mon Sep 17 00:00:00 2001 From: Anthony Eid <56899983+Anthony-Eid@users.noreply.github.com> Date: Fri, 5 Dec 2025 07:59:13 -0500 Subject: [PATCH 073/621] git: Fix branch picker creating new branches with refs/head/ prefixed on the branch name (#44206) The bug was introduced in this recent PR: https://github.com/zed-industries/zed/pull/42819. Since it's still in nightly, there is no need for release notes. I also polished the feature a bit by: - Ensuring branch names are always a single line so the branch picker's uniform list uses the correct element height. - Adding tooltip text for the filter remotes button. - Fixing the create branch from default icon showing up for non-new branch entries. Release Notes: - N/A --- assets/keymaps/default-linux.json | 3 +- assets/keymaps/default-macos.json | 3 +- assets/keymaps/default-windows.json | 3 +- crates/fs/src/fake_git_repo.rs | 17 ++++-- crates/git_ui/src/branch_picker.rs | 89 +++++++++++++++++------------ 5 files changed, 69 insertions(+), 46 deletions(-) diff --git a/assets/keymaps/default-linux.json b/assets/keymaps/default-linux.json index 0b001f31790c7f8211a6b44d227c15a6ff605ca4..41415bf2047e1faadd86dd5be159f526d6c57678 100644 --- a/assets/keymaps/default-linux.json +++ b/assets/keymaps/default-linux.json @@ -1332,7 +1332,8 @@ "context": "GitBranchSelector || (GitBranchSelector > Picker > Editor)", "use_key_equivalents": true, "bindings": { - "ctrl-shift-backspace": "branch_picker::DeleteBranch" + "ctrl-shift-backspace": "branch_picker::DeleteBranch", + "ctrl-shift-i": "branch_picker::FilterRemotes" } } ] diff --git a/assets/keymaps/default-macos.json b/assets/keymaps/default-macos.json index e4595242d570628e2e70c43b66d14a0f9820512b..fa8edbe5c23b008eb2c267850e440a851c54087d 100644 --- a/assets/keymaps/default-macos.json +++ b/assets/keymaps/default-macos.json @@ -1437,7 +1437,8 @@ "context": "GitBranchSelector || (GitBranchSelector > Picker > Editor)", "use_key_equivalents": true, "bindings": { - "cmd-shift-backspace": "branch_picker::DeleteBranch" + "cmd-shift-backspace": "branch_picker::DeleteBranch", + "cmd-shift-i": "branch_picker::FilterRemotes" } } ] diff --git a/assets/keymaps/default-windows.json b/assets/keymaps/default-windows.json index b625e7c7018c0f4c8277fcf3f739a8f06361c4df..45f37fbd41af3fcc3108f0ffe150a80ff25332e1 100644 --- a/assets/keymaps/default-windows.json +++ b/assets/keymaps/default-windows.json @@ -1351,7 +1351,8 @@ "context": "GitBranchSelector || (GitBranchSelector > Picker > Editor)", "use_key_equivalents": true, "bindings": { - "ctrl-shift-backspace": "branch_picker::DeleteBranch" + "ctrl-shift-backspace": "branch_picker::DeleteBranch", + "ctrl-shift-i": "branch_picker::FilterRemotes" } } ] diff --git a/crates/fs/src/fake_git_repo.rs b/crates/fs/src/fake_git_repo.rs index 3bc411ff2d9b917fd409c29cca03d2191ee80978..6ca8b5a58f9f8f75023aa73e7a80e8547eb156f3 100644 --- a/crates/fs/src/fake_git_repo.rs +++ b/crates/fs/src/fake_git_repo.rs @@ -381,11 +381,18 @@ impl GitRepository for FakeGitRepository { Ok(state .branches .iter() - .map(|branch_name| Branch { - is_head: Some(branch_name) == current_branch.as_ref(), - ref_name: branch_name.into(), - most_recent_commit: None, - upstream: None, + .map(|branch_name| { + let ref_name = if branch_name.starts_with("refs/") { + branch_name.into() + } else { + format!("refs/heads/{branch_name}").into() + }; + Branch { + is_head: Some(branch_name) == current_branch.as_ref(), + ref_name, + most_recent_commit: None, + upstream: None, + } }) .collect()) }) diff --git a/crates/git_ui/src/branch_picker.rs b/crates/git_ui/src/branch_picker.rs index 42e043cada2813126af3489c9769aca9c675999f..33b852c1de9b1bd1a8abcc36dff964d14cbe1807 100644 --- a/crates/git_ui/src/branch_picker.rs +++ b/crates/git_ui/src/branch_picker.rs @@ -770,7 +770,7 @@ impl PickerDelegate for BranchListDelegate { } else { None }; - self.create_branch(from_branch, format!("refs/heads/{name}").into(), window, cx); + self.create_branch(from_branch, name.into(), window, cx); } } @@ -812,28 +812,21 @@ impl PickerDelegate for BranchListDelegate { }) .unwrap_or_else(|| (None, None, None)); - let icon = if let Some(default_branch) = self.default_branch.clone() { - let icon = match &entry { - Entry::Branch { .. } => Some(( - IconName::GitBranchAlt, - format!("Create branch based off default: {default_branch}"), - )), - Entry::NewUrl { url } => { - Some((IconName::Screen, format!("Create remote based off {url}"))) - } - Entry::NewBranch { .. } => None, - }; + let icon = if let Some(default_branch) = self.default_branch.clone() + && matches!(entry, Entry::NewBranch { .. }) + { + let tooltip_text = format!("Create branch based off default: {default_branch}"); - icon.map(|(icon, tooltip_text)| { - IconButton::new("branch-from-default", icon) + Some( + IconButton::new("branch-from-default", IconName::GitBranchAlt) .on_click(cx.listener(move |this, _, window, cx| { this.delegate.set_selected_index(ix, window, cx); this.delegate.confirm(true, window, cx); })) .tooltip(move |_window, cx| { Tooltip::for_action(tooltip_text.clone(), &menu::SecondaryConfirm, cx) - }) - }) + }), + ) } else { None }; @@ -875,7 +868,9 @@ impl PickerDelegate for BranchListDelegate { .max_w_48() .child(h_flex().mr_1().child(icon_element)) .child( - HighlightedLabel::new(branch.name().to_string(), positions.clone()).truncate(), + HighlightedLabel::new(branch.name().to_string(), positions.clone()) + .single_line() + .truncate(), ) .into_any_element(), }; @@ -962,18 +957,13 @@ impl PickerDelegate for BranchListDelegate { _window: &mut Window, cx: &mut Context>, ) -> Option { - if matches!( - self.state, - PickerState::CreateRemote(_) | PickerState::NewRemote | PickerState::NewBranch - ) { - return None; - } - let label = if self.display_remotes { - "Remote" - } else { - "Local" - }; - Some( + matches!(self.state, PickerState::List).then(|| { + let label = if self.display_remotes { + "Remote" + } else { + "Local" + }; + h_flex() .w_full() .p_1p5() @@ -981,8 +971,8 @@ impl PickerDelegate for BranchListDelegate { .border_t_1() .border_color(cx.theme().colors().border_variant) .child(Label::new(label).size(LabelSize::Small).color(Color::Muted)) - .into_any(), - ) + .into_any() + }) } fn render_footer(&self, _: &mut Window, cx: &mut Context>) -> Option { @@ -1010,7 +1000,8 @@ impl PickerDelegate for BranchListDelegate { .border_t_1() .border_color(cx.theme().colors().border_variant) .justify_between() - .child( + .child({ + let focus_handle = focus_handle.clone(); Button::new("filter-remotes", "Filter remotes") .key_binding( KeyBinding::for_action_in( @@ -1028,8 +1019,26 @@ impl PickerDelegate for BranchListDelegate { }) .disabled(self.loading) .style(ButtonStyle::Subtle) - .toggle_state(self.display_remotes), - ) + .toggle_state(self.display_remotes) + .tooltip({ + let state = self.display_remotes; + + move |_window, cx| { + let tooltip_text = if state { + "Show local branches" + } else { + "Show remote branches" + }; + + Tooltip::for_action_in( + tooltip_text, + &branch_picker::FilterRemotes, + &focus_handle, + cx, + ) + } + }) + }) .child( Button::new("delete-branch", "Delete") .key_binding( @@ -1527,10 +1536,14 @@ mod tests { .unwrap() .unwrap(); - assert!( - branches - .into_iter() - .any(|branch| branch.name() == "new-feature-branch") + let new_branch = branches + .into_iter() + .find(|branch| branch.name() == "new-feature-branch") + .expect("new-feature-branch should exist"); + assert_eq!( + new_branch.ref_name.as_ref(), + "refs/heads/new-feature-branch", + "branch ref_name should not have duplicate refs/heads/ prefix" ); } From 822fc7ef167e7a26358afe7f13d0b05b4df468eb Mon Sep 17 00:00:00 2001 From: Agus Zubiaga Date: Fri, 5 Dec 2025 10:04:01 -0300 Subject: [PATCH 074/621] remote: Use last line of `uname` and shell output (#44165) We have seen cases (see https://github.com/zed-industries/zed/issues/43694) where the user's shell initialization script includes text that ends up in the output of the commands we use to detect the platform and shell of the remote. This solution isn't perfect, but it should address the issue in most situations since both commands should only output one line. Release Notes: - remote: Improve resiliency when initialization scripts output text --- crates/remote/src/transport/ssh.rs | 150 +++++++++++++++++++++-------- 1 file changed, 109 insertions(+), 41 deletions(-) diff --git a/crates/remote/src/transport/ssh.rs b/crates/remote/src/transport/ssh.rs index 20cd0c5ff4b427d3a37882603ce2962db9e4e1e0..56f29be092b5ed6ab4993664eb256056837047f5 100644 --- a/crates/remote/src/transport/ssh.rs +++ b/crates/remote/src/transport/ssh.rs @@ -1055,57 +1055,74 @@ impl SshSocket { } async fn platform(&self, shell: ShellKind) -> Result { - let uname = self.run_command(shell, "uname", &["-sm"], false).await?; - let Some((os, arch)) = uname.split_once(" ") else { - anyhow::bail!("unknown uname: {uname:?}") - }; - - let os = match os.trim() { - "Darwin" => "macos", - "Linux" => "linux", - _ => anyhow::bail!( - "Prebuilt remote servers are not yet available for {os:?}. See https://zed.dev/docs/remote-development" - ), - }; - // exclude armv5,6,7 as they are 32-bit. - let arch = if arch.starts_with("armv8") - || arch.starts_with("armv9") - || arch.starts_with("arm64") - || arch.starts_with("aarch64") - { - "aarch64" - } else if arch.starts_with("x86") { - "x86_64" - } else { - anyhow::bail!( - "Prebuilt remote servers are not yet available for {arch:?}. See https://zed.dev/docs/remote-development" - ) - }; - - Ok(RemotePlatform { os, arch }) + let output = self.run_command(shell, "uname", &["-sm"], false).await?; + parse_platform(&output) } async fn shell(&self) -> String { - let default_shell = "sh"; match self .run_command(ShellKind::Posix, "sh", &["-c", "echo $SHELL"], false) .await { - Ok(shell) => match shell.trim() { - "" => { - log::error!("$SHELL is not set, falling back to {default_shell}"); - default_shell.to_owned() - } - shell => shell.to_owned(), - }, + Ok(output) => parse_shell(&output), Err(e) => { log::error!("Failed to get shell: {e}"); - default_shell.to_owned() + DEFAULT_SHELL.to_owned() } } } } +const DEFAULT_SHELL: &str = "sh"; + +/// Parses the output of `uname -sm` to determine the remote platform. +/// Takes the last line to skip possible shell initialization output. +fn parse_platform(output: &str) -> Result { + let output = output.trim(); + let uname = output.rsplit_once('\n').map_or(output, |(_, last)| last); + let Some((os, arch)) = uname.split_once(" ") else { + anyhow::bail!("unknown uname: {uname:?}") + }; + + let os = match os { + "Darwin" => "macos", + "Linux" => "linux", + _ => anyhow::bail!( + "Prebuilt remote servers are not yet available for {os:?}. See https://zed.dev/docs/remote-development" + ), + }; + + // exclude armv5,6,7 as they are 32-bit. + let arch = if arch.starts_with("armv8") + || arch.starts_with("armv9") + || arch.starts_with("arm64") + || arch.starts_with("aarch64") + { + "aarch64" + } else if arch.starts_with("x86") { + "x86_64" + } else { + anyhow::bail!( + "Prebuilt remote servers are not yet available for {arch:?}. See https://zed.dev/docs/remote-development" + ) + }; + + Ok(RemotePlatform { os, arch }) +} + +/// Parses the output of `echo $SHELL` to determine the remote shell. +/// Takes the last line to skip possible shell initialization output. +fn parse_shell(output: &str) -> String { + let output = output.trim(); + let shell = output.rsplit_once('\n').map_or(output, |(_, last)| last); + if shell.is_empty() { + log::error!("$SHELL is not set, falling back to {DEFAULT_SHELL}"); + DEFAULT_SHELL.to_owned() + } else { + shell.to_owned() + } +} + fn parse_port_number(port_str: &str) -> Result { port_str .parse() @@ -1502,12 +1519,63 @@ mod tests { "-p".to_string(), "2222".to_string(), "-o".to_string(), - "StrictHostKeyChecking=no".to_string() + "StrictHostKeyChecking=no".to_string(), ] ); - assert!( - scp_args.iter().all(|arg| !arg.starts_with("-L")), - "scp args should not contain port forward flags: {scp_args:?}" + } + + #[test] + fn test_parse_platform() { + let result = parse_platform("Linux x86_64\n").unwrap(); + assert_eq!(result.os, "linux"); + assert_eq!(result.arch, "x86_64"); + + let result = parse_platform("Darwin arm64\n").unwrap(); + assert_eq!(result.os, "macos"); + assert_eq!(result.arch, "aarch64"); + + let result = parse_platform("Linux x86_64").unwrap(); + assert_eq!(result.os, "linux"); + assert_eq!(result.arch, "x86_64"); + + let result = parse_platform("some shell init output\nLinux aarch64\n").unwrap(); + assert_eq!(result.os, "linux"); + assert_eq!(result.arch, "aarch64"); + + let result = parse_platform("some shell init output\nLinux aarch64").unwrap(); + assert_eq!(result.os, "linux"); + assert_eq!(result.arch, "aarch64"); + + assert_eq!(parse_platform("Linux armv8l\n").unwrap().arch, "aarch64"); + assert_eq!(parse_platform("Linux aarch64\n").unwrap().arch, "aarch64"); + assert_eq!(parse_platform("Linux x86_64\n").unwrap().arch, "x86_64"); + + let result = parse_platform( + r#"Linux x86_64 - What you're referring to as Linux, is in fact, GNU/Linux...\n"#, + ) + .unwrap(); + assert_eq!(result.os, "linux"); + assert_eq!(result.arch, "x86_64"); + + assert!(parse_platform("Windows x86_64\n").is_err()); + assert!(parse_platform("Linux armv7l\n").is_err()); + } + + #[test] + fn test_parse_shell() { + assert_eq!(parse_shell("/bin/bash\n"), "/bin/bash"); + assert_eq!(parse_shell("/bin/zsh\n"), "/bin/zsh"); + + assert_eq!(parse_shell("/bin/bash"), "/bin/bash"); + assert_eq!( + parse_shell("some shell init output\n/bin/bash\n"), + "/bin/bash" + ); + assert_eq!( + parse_shell("some shell init output\n/bin/bash"), + "/bin/bash" ); + assert_eq!(parse_shell(""), "sh"); + assert_eq!(parse_shell("\n"), "sh"); } } From c7ef3025e42c1e16f16011ee7330856be9438e67 Mon Sep 17 00:00:00 2001 From: Agus Zubiaga Date: Fri, 5 Dec 2025 12:16:46 -0300 Subject: [PATCH 075/621] remoting: Server download connect timeout (#44216) Sometimes machines are configured to drop outbound packets (rather than reject connections). In these cases, curl/wget just hang causing our download step to never complete. This PR adds a timeout of 10s for the connection (not the whole download), so that in situations like this we can fallback to our client-side download eventually. Related to but doesn't fully fix: https://github.com/zed-industries/zed/issues/43694 and https://github.com/zed-industries/zed/issues/43718 Release Notes: - remote: Add 10s connect timeout for server download --- crates/remote/src/transport/ssh.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/crates/remote/src/transport/ssh.rs b/crates/remote/src/transport/ssh.rs index 56f29be092b5ed6ab4993664eb256056837047f5..bdc9cda08a9634258a4e18532556c1cde2bf8f32 100644 --- a/crates/remote/src/transport/ssh.rs +++ b/crates/remote/src/transport/ssh.rs @@ -668,6 +668,8 @@ impl SshRemoteConnection { delegate.set_status(Some("Downloading remote development server on host"), cx); + const CONNECT_TIMEOUT_SECS: &str = "10"; + match self .socket .run_command( @@ -676,6 +678,8 @@ impl SshRemoteConnection { &[ "-f", "-L", + "--connect-timeout", + CONNECT_TIMEOUT_SECS, url, "-o", &tmp_path_gz.display(self.path_style()), @@ -701,7 +705,15 @@ impl SshRemoteConnection { .run_command( self.ssh_shell_kind, "wget", - &[url, "-O", &tmp_path_gz.display(self.path_style())], + &[ + "--connect-timeout", + CONNECT_TIMEOUT_SECS, + "--tries", + "1", + url, + "-O", + &tmp_path_gz.display(self.path_style()), + ], true, ) .await From 1d0aef6b2229acc81de7708c315472fb0e7c627c Mon Sep 17 00:00:00 2001 From: Dino Date: Fri, 5 Dec 2025 15:24:07 +0000 Subject: [PATCH 076/621] Ensure font features are applied to styled text (#44219) - Replace `gpui::styled::Styled.font_family()` calls with `gpui::styled::Styled.font()` when laying out inline diagnostics and inline blame, to ensure that the font's features are also used, and not just the font feature. - Update both `editor::hover_popover::hover_markdown_style` and `editor::hover_popover::diagnostics_markdown_style` to ensure that both the UI and Buffer font features are used in both markdown and diagnostics popover. Closes #44209 Release Notes: - Fixed font feature application for inline git blame, inline diagnostics, markdown popovers and diagnostics popovers --- crates/editor/src/element.rs | 2 +- crates/editor/src/hover_popover.rs | 8 ++++++++ crates/git_ui/src/blame_ui.rs | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index fb9dc31a94441c81bccedfea66e2881acaf7ed82..edb3778ff94809ef880ffa167f2ff410a3199a37 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -2340,7 +2340,7 @@ impl EditorElement { .opacity(0.05)) .text_color(severity_to_color(&diagnostic_to_render.severity).color(cx)) .text_sm() - .font_family(style.text.font().family) + .font(style.text.font()) .child(diagnostic_to_render.message.clone()) .into_any(); diff --git a/crates/editor/src/hover_popover.rs b/crates/editor/src/hover_popover.rs index caabe6e6f5ab6ae80b3ead9d72fdcbec59937ff6..9ef54139d39ece6e9414d8fee3c7a75c9a89036d 100644 --- a/crates/editor/src/hover_popover.rs +++ b/crates/editor/src/hover_popover.rs @@ -607,13 +607,16 @@ async fn parse_blocks( pub fn hover_markdown_style(window: &Window, cx: &App) -> MarkdownStyle { let settings = ThemeSettings::get_global(cx); let ui_font_family = settings.ui_font.family.clone(); + let ui_font_features = settings.ui_font.features.clone(); let ui_font_fallbacks = settings.ui_font.fallbacks.clone(); let buffer_font_family = settings.buffer_font.family.clone(); + let buffer_font_features = settings.buffer_font.features.clone(); let buffer_font_fallbacks = settings.buffer_font.fallbacks.clone(); let mut base_text_style = window.text_style(); base_text_style.refine(&TextStyleRefinement { font_family: Some(ui_font_family), + font_features: Some(ui_font_features), font_fallbacks: ui_font_fallbacks, color: Some(cx.theme().colors().editor_foreground), ..Default::default() @@ -624,6 +627,7 @@ pub fn hover_markdown_style(window: &Window, cx: &App) -> MarkdownStyle { inline_code: TextStyleRefinement { background_color: Some(cx.theme().colors().background), font_family: Some(buffer_font_family), + font_features: Some(buffer_font_features), font_fallbacks: buffer_font_fallbacks, ..Default::default() }, @@ -657,12 +661,15 @@ pub fn diagnostics_markdown_style(window: &Window, cx: &App) -> MarkdownStyle { let settings = ThemeSettings::get_global(cx); let ui_font_family = settings.ui_font.family.clone(); let ui_font_fallbacks = settings.ui_font.fallbacks.clone(); + let ui_font_features = settings.ui_font.features.clone(); let buffer_font_family = settings.buffer_font.family.clone(); + let buffer_font_features = settings.buffer_font.features.clone(); let buffer_font_fallbacks = settings.buffer_font.fallbacks.clone(); let mut base_text_style = window.text_style(); base_text_style.refine(&TextStyleRefinement { font_family: Some(ui_font_family), + font_features: Some(ui_font_features), font_fallbacks: ui_font_fallbacks, color: Some(cx.theme().colors().editor_foreground), ..Default::default() @@ -673,6 +680,7 @@ pub fn diagnostics_markdown_style(window: &Window, cx: &App) -> MarkdownStyle { inline_code: TextStyleRefinement { background_color: Some(cx.theme().colors().editor_background.opacity(0.5)), font_family: Some(buffer_font_family), + font_features: Some(buffer_font_features), font_fallbacks: buffer_font_fallbacks, ..Default::default() }, diff --git a/crates/git_ui/src/blame_ui.rs b/crates/git_ui/src/blame_ui.rs index 47703e09824a49c633798c7967652d7f48f821be..c904c4b3b7cba499f6a81399a1ff87d2108f3012 100644 --- a/crates/git_ui/src/blame_ui.rs +++ b/crates/git_ui/src/blame_ui.rs @@ -148,7 +148,7 @@ impl BlameRenderer for GitBlameRenderer { h_flex() .id("inline-blame") .w_full() - .font_family(style.font().family) + .font(style.font()) .text_color(cx.theme().status().hint) .line_height(style.line_height) .child(Icon::new(IconName::FileGit).color(Color::Hint)) From b776178b52aa46e3aaed2720f019295def7eae45 Mon Sep 17 00:00:00 2001 From: Ben Brandt Date: Fri, 5 Dec 2025 16:50:32 +0100 Subject: [PATCH 077/621] agent_ui: Fix mention and slash command menu not appearing with show_completions_on_input set to false (#44222) Addresses a regression introduced by https://github.com/zed-industries/zed/pull/44021 that caused @mentions and slash commands to stop working if you set `show_completions_on_input: false` in your settings. In this case, we should always show these menus, otherwise the features won't work at all. Release Notes: - N/A --- crates/agent_ui/src/acp/message_editor.rs | 1 + crates/editor/src/editor.rs | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/crates/agent_ui/src/acp/message_editor.rs b/crates/agent_ui/src/acp/message_editor.rs index ae634e45dc17cc471d9ac621faf5b98c0a754c2b..827990599912fe832d40605fb1dceb58eab4ff2f 100644 --- a/crates/agent_ui/src/acp/message_editor.rs +++ b/crates/agent_ui/src/acp/message_editor.rs @@ -124,6 +124,7 @@ impl MessageEditor { let mut editor = Editor::new(mode, buffer, None, window, cx); editor.set_placeholder_text(placeholder, window, cx); editor.set_show_indent_guides(false, cx); + editor.set_show_completions_on_input(Some(true)); editor.set_soft_wrap(); editor.set_use_modal_editing(true); editor.set_context_menu_options(ContextMenuOptions { diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 6651cce374001865d21dfdb182659f2a8c008305..a4a8a5e02baad4e3306278ed11709d3527e868ce 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -1128,6 +1128,7 @@ pub struct Editor { edit_prediction_settings: EditPredictionSettings, edit_predictions_hidden_for_vim_mode: bool, show_edit_predictions_override: Option, + show_completions_on_input_override: Option, menu_edit_predictions_policy: MenuEditPredictionsPolicy, edit_prediction_preview: EditPredictionPreview, edit_prediction_indent_conflict: bool, @@ -2275,6 +2276,7 @@ impl Editor { editor_actions: Rc::default(), edit_predictions_hidden_for_vim_mode: false, show_edit_predictions_override: None, + show_completions_on_input_override: None, menu_edit_predictions_policy: MenuEditPredictionsPolicy::ByProvider, edit_prediction_settings: EditPredictionSettings::Disabled, edit_prediction_indent_conflict: false, @@ -3157,6 +3159,10 @@ impl Editor { } } + pub fn set_show_completions_on_input(&mut self, show_completions_on_input: Option) { + self.show_completions_on_input_override = show_completions_on_input; + } + pub fn set_show_edit_predictions( &mut self, show_edit_predictions: Option, @@ -5533,7 +5539,10 @@ impl Editor { let language_settings = language_settings(language.clone(), buffer_snapshot.file(), cx); let completion_settings = language_settings.completions.clone(); - if !menu_is_open && trigger.is_some() && !language_settings.show_completions_on_input { + let show_completions_on_input = self + .show_completions_on_input_override + .unwrap_or(language_settings.show_completions_on_input); + if !menu_is_open && trigger.is_some() && !show_completions_on_input { return; } From 07fe8e9bb1484b2771d8a9d80f7fc370cee9c4ac Mon Sep 17 00:00:00 2001 From: Agus Zubiaga Date: Fri, 5 Dec 2025 13:47:29 -0300 Subject: [PATCH 078/621] remoting: Proxy configuration docs (#44225) Adds an explicit section about how to configure proxies when remoting. Release Notes: - N/A --- docs/src/remote-development.md | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/docs/src/remote-development.md b/docs/src/remote-development.md index f046fa44334554230d19f885e6e38ab0274f2b44..c25d160a17549f6338f25741afd68391cf88d769 100644 --- a/docs/src/remote-development.md +++ b/docs/src/remote-development.md @@ -174,14 +174,38 @@ When opening a remote project there are three relevant settings locations: Both the local Zed and the server Zed read the project settings, but they are not aware of the other's main `settings.json`. -Depending on the kind of setting you want to make, which settings file you should use: +Which settings file you should use depends on the kind of setting you want to make: - Project settings should be used for things that affect the project: indentation settings, which formatter / language server to use, etc. -- Server settings should be used for things that affect the server: paths to language servers, etc. +- Server settings should be used for things that affect the server: paths to language servers, proxy settings, etc. - Local settings should be used for things that affect the UI: font size, etc. In addition any extensions you have installed locally will be propagated to the remote server. This means that language servers, etc. will run correctly. +## Proxy Configuration + +The remote server will not use your local machine's proxy configuration because they may be under different network policies. If your remote server requires a proxy to access the internet, you must configure it on the remote server itself. + +In most cases, your remote server will already have proxy environment variables configured. Zed will automatically use them when downloading language servers, communicating with LLM models, etc. + +If needed, you can set these environment variables in the server's shell configuration (e.g., `~/.bashrc`): + +```bash +export http_proxy="http://proxy.example.com:8080" +export https_proxy="http://proxy.example.com:8080" +export no_proxy="localhost,127.0.0.1" +``` + +Alternatively, you can configure the proxy in the remote machine's `~/.config/zed/settings.json` (Linux) or `~/.zed/settings.json` (macOS): + +```json +{ + "proxy": "http://proxy.example.com:8080" +} +``` + +See the [proxy documentation](./configuring-zed.md#network-proxy) for supported proxy types and additional configuration options. + ## Initializing the remote server Once you provide the SSH options, Zed shells out to `ssh` on your local machine to create a ControlMaster connection with the options you provide. From b558be7ec60b265837e34d6f9b6f0ef176c20082 Mon Sep 17 00:00:00 2001 From: David Kleingeld Date: Fri, 5 Dec 2025 18:23:06 +0100 Subject: [PATCH 079/621] adds tracing for instrumenting non-async functions (#44147) Tracing code is not included in normal release builds Documents how to use them in our performance docs Only the maps and cursors are instrumented atm # Compile times: current main: fresh release build (cargo clean then build --release) 377.34 secs current main: fresh debug build (cargo clean then build ) 89.31 secs tracing tracy: fresh release build (cargo clean then build --release) 374.84 secs tracing tracy: fresh debug build (cargo clean then build ) 88.95 secs tracing tracy: fresh release build with timings (cargo clean then build --release --features tracing) 375.77 secs tracing tracy: fresh debug build with timings (cargo clean then build --features tracing) 90.03 secs Release Notes: - N/A --------- Co-authored-by: localcc --- Cargo.lock | 103 ++- Cargo.toml | 6 + crates/collab/Cargo.toml | 2 +- crates/editor/Cargo.toml | 3 + crates/editor/src/display_map/block_map.rs | 42 + crates/editor/src/display_map/crease_map.rs | 17 + .../src/display_map/custom_highlights.rs | 3 + crates/editor/src/display_map/fold_map.rs | 35 + crates/editor/src/display_map/inlay_map.rs | 28 + crates/editor/src/display_map/invisibles.rs | 1 + crates/editor/src/display_map/tab_map.rs | 27 + crates/editor/src/display_map/wrap_map.rs | 38 + crates/git_ui/Cargo.toml | 7 +- crates/git_ui/src/project_diff.rs | 2 + crates/multi_buffer/Cargo.toml | 5 + crates/multi_buffer/src/multi_buffer.rs | 5 + crates/multi_buffer/src/path_key.rs | 872 +++++++++--------- crates/project/Cargo.toml | 5 + crates/project/src/git_store/branch_diff.rs | 3 + crates/rope/Cargo.toml | 5 + crates/rope/src/rope.rs | 2 + crates/sum_tree/Cargo.toml | 5 + crates/sum_tree/src/cursor.rs | 5 + crates/sum_tree/src/sum_tree.rs | 3 + crates/zed/Cargo.toml | 4 +- crates/zed/src/main.rs | 3 +- crates/ztracing/Cargo.toml | 17 + crates/ztracing/LICENSE-AGPL | 1 + crates/ztracing/LICENSE-APACHE | 1 + crates/ztracing/LICENSE-GPL | 1 + crates/ztracing/build.rs | 9 + crates/ztracing/src/lib.rs | 16 + crates/ztracing_macro/Cargo.toml | 11 + crates/ztracing_macro/LICENSE-AGPL | 1 + crates/ztracing_macro/LICENSE-APACHE | 1 + crates/ztracing_macro/LICENSE-GPL | 1 + crates/ztracing_macro/src/lib.rs | 7 + docs/src/performance.md | 52 +- 38 files changed, 898 insertions(+), 451 deletions(-) create mode 100644 crates/ztracing/Cargo.toml create mode 120000 crates/ztracing/LICENSE-AGPL create mode 120000 crates/ztracing/LICENSE-APACHE create mode 120000 crates/ztracing/LICENSE-GPL create mode 100644 crates/ztracing/build.rs create mode 100644 crates/ztracing/src/lib.rs create mode 100644 crates/ztracing_macro/Cargo.toml create mode 120000 crates/ztracing_macro/LICENSE-AGPL create mode 120000 crates/ztracing_macro/LICENSE-APACHE create mode 120000 crates/ztracing_macro/LICENSE-GPL create mode 100644 crates/ztracing_macro/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 885fbe77fd17a90e4cc948d4c40166d41a26cd35..a8f0096a7a1219ee30b287c61efd9f77f4b9d223 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5344,6 +5344,7 @@ dependencies = [ "text", "theme", "time", + "tracing", "tree-sitter-bash", "tree-sitter-c", "tree-sitter-html", @@ -5363,6 +5364,7 @@ dependencies = [ "workspace", "zed_actions", "zlog", + "ztracing", ] [[package]] @@ -6824,6 +6826,20 @@ dependencies = [ "seq-macro", ] +[[package]] +name = "generator" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "605183a538e3e2a9c1038635cc5c2d194e2ee8fd0d1b66b8349fad7dbacce5a2" +dependencies = [ + "cc", + "cfg-if", + "libc", + "log", + "rustversion", + "windows 0.61.3", +] + [[package]] name = "generic-array" version = "0.14.7" @@ -7042,6 +7058,7 @@ dependencies = [ "theme", "time", "time_format", + "tracing", "ui", "unindent", "util", @@ -7051,6 +7068,7 @@ dependencies = [ "zed_actions", "zeroize", "zlog", + "ztracing", ] [[package]] @@ -9373,6 +9391,19 @@ dependencies = [ "value-bag", ] +[[package]] +name = "loom" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "419e0dc8046cb947daa77eb95ae174acfbddb7673b4151f56d1eed8e93fbfaca" +dependencies = [ + "cfg-if", + "generator", + "scoped-tls", + "tracing", + "tracing-subscriber", +] + [[package]] name = "loop9" version = "0.1.5" @@ -10043,9 +10074,11 @@ dependencies = [ "sum_tree", "text", "theme", + "tracing", "tree-sitter", "util", "zlog", + "ztracing", ] [[package]] @@ -12400,6 +12433,7 @@ dependencies = [ "terminal", "text", "toml 0.8.23", + "tracing", "unindent", "url", "util", @@ -12409,6 +12443,7 @@ dependencies = [ "worktree", "zeroize", "zlog", + "ztracing", ] [[package]] @@ -13677,9 +13712,11 @@ dependencies = [ "rand 0.9.2", "rayon", "sum_tree", + "tracing", "unicode-segmentation", "util", "zlog", + "ztracing", ] [[package]] @@ -15615,7 +15652,9 @@ dependencies = [ "log", "rand 0.9.2", "rayon", + "tracing", "zlog", + "ztracing", ] [[package]] @@ -17100,9 +17139,9 @@ checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" [[package]] name = "tracing" -version = "0.1.41" +version = "0.1.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" +checksum = "2d15d90a0b5c19378952d479dc858407149d7bb45a14de0142f6c534b16fc647" dependencies = [ "log", "pin-project-lite", @@ -17112,9 +17151,9 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.30" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81383ab64e72a7a8b8e13130c49e3dab29def6d0c7d76a03087b3cf71c5c6903" +checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" dependencies = [ "proc-macro2", "quote", @@ -17123,9 +17162,9 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.34" +version = "0.1.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9d12581f227e93f094d3af2ae690a574abb8a2b9b7a96e7cfe9647b2b617678" +checksum = "7a04e24fab5c89c6a36eb8558c9656f30d81de51dfa4d3b45f26b21d61fa0a6c" dependencies = [ "once_cell", "valuable", @@ -17154,9 +17193,9 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.3.20" +version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2054a14f5307d601f88daf0553e1cbf472acc4f2c51afab632431cdcd72124d5" +checksum = "2f30143827ddab0d256fd843b7a66d164e9f271cfa0dde49142c5ca0ca291f1e" dependencies = [ "matchers", "nu-ansi-term", @@ -17173,6 +17212,38 @@ dependencies = [ "tracing-serde", ] +[[package]] +name = "tracing-tracy" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eaa1852afa96e0fe9e44caa53dc0bd2d9d05e0f2611ce09f97f8677af56e4ba" +dependencies = [ + "tracing-core", + "tracing-subscriber", + "tracy-client", +] + +[[package]] +name = "tracy-client" +version = "0.18.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91d722a05fe49b31fef971c4732a7d4aa6a18283d9ba46abddab35f484872947" +dependencies = [ + "loom", + "once_cell", + "tracy-client-sys", +] + +[[package]] +name = "tracy-client-sys" +version = "0.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fb391ac70462b3097a755618fbf9c8f95ecc1eb379a414f7b46f202ed10db1f" +dependencies = [ + "cc", + "windows-targets 0.52.6", +] + [[package]] name = "trait-variant" version = "0.1.2" @@ -20515,6 +20586,7 @@ dependencies = [ "time", "title_bar", "toolchain_selector", + "tracing", "tree-sitter-md", "tree-sitter-rust", "ui", @@ -20537,6 +20609,7 @@ dependencies = [ "zed_env_vars", "zlog", "zlog_settings", + "ztracing", ] [[package]] @@ -20931,6 +21004,20 @@ dependencies = [ "pkg-config", ] +[[package]] +name = "ztracing" +version = "0.1.0" +dependencies = [ + "tracing", + "tracing-subscriber", + "tracing-tracy", + "ztracing_macro", +] + +[[package]] +name = "ztracing_macro" +version = "0.1.0" + [[package]] name = "zune-core" version = "0.4.12" diff --git a/Cargo.toml b/Cargo.toml index 83bc42e353f6462148abe15327373a3d57a029e8..858da1dc460cda2fecbaf2ed94d437bfd25d9644 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -204,6 +204,8 @@ members = [ "crates/edit_prediction_cli", "crates/zlog", "crates/zlog_settings", + "crates/ztracing", + "crates/ztracing_macro", # # Extensions @@ -434,6 +436,8 @@ zed_env_vars = { path = "crates/zed_env_vars" } edit_prediction = { path = "crates/edit_prediction" } zlog = { path = "crates/zlog" } zlog_settings = { path = "crates/zlog_settings" } +ztracing = { path = "crates/ztracing" } +ztracing_macro = { path = "crates/ztracing_macro" } # # External crates @@ -694,6 +698,8 @@ tree-sitter-ruby = "0.23" tree-sitter-rust = "0.24" tree-sitter-typescript = { git = "https://github.com/zed-industries/tree-sitter-typescript", rev = "e2c53597d6a5d9cf7bbe8dccde576fe1e46c5899" } # https://github.com/tree-sitter/tree-sitter-typescript/pull/347 tree-sitter-yaml = { git = "https://github.com/zed-industries/tree-sitter-yaml", rev = "baff0b51c64ef6a1fb1f8390f3ad6015b83ec13a" } +tracing = "0.1.40" +tracing-tracy = "0.11.4" unicase = "2.6" unicode-script = "0.5.7" unicode-segmentation = "1.10" diff --git a/crates/collab/Cargo.toml b/crates/collab/Cargo.toml index b8a4c035499d45adc494c9f8175a772d15aa96df..79fc21fe33423d7eb887744b4ad84094a022862e 100644 --- a/crates/collab/Cargo.toml +++ b/crates/collab/Cargo.toml @@ -65,7 +65,7 @@ tokio = { workspace = true, features = ["full"] } toml.workspace = true tower = "0.4" tower-http = { workspace = true, features = ["trace"] } -tracing = "0.1.40" +tracing.workspace = true tracing-subscriber = { version = "0.3.18", features = ["env-filter", "json", "registry", "tracing-log"] } # workaround for https://github.com/tokio-rs/tracing/issues/2927 util.workspace = true uuid.workspace = true diff --git a/crates/editor/Cargo.toml b/crates/editor/Cargo.toml index 94c9fb10f50f8e0440b2e91cf0c16d1f701d9451..f3ed28ab05c6839a478ebbf6c81ca5e66fc372e3 100644 --- a/crates/editor/Cargo.toml +++ b/crates/editor/Cargo.toml @@ -84,6 +84,8 @@ tree-sitter-html = { workspace = true, optional = true } tree-sitter-rust = { workspace = true, optional = true } tree-sitter-typescript = { workspace = true, optional = true } tree-sitter-python = { workspace = true, optional = true } +ztracing.workspace = true +tracing.workspace = true unicode-segmentation.workspace = true unicode-script.workspace = true unindent = { workspace = true, optional = true } @@ -94,6 +96,7 @@ uuid.workspace = true vim_mode_setting.workspace = true workspace.workspace = true zed_actions.workspace = true +zlog.workspace = true [dev-dependencies] criterion.workspace = true diff --git a/crates/editor/src/display_map/block_map.rs b/crates/editor/src/display_map/block_map.rs index a6744041971101dafa4957523fb7a16250f38996..79d06dbf8b6e27cffffd47d6637c83eadcb00424 100644 --- a/crates/editor/src/display_map/block_map.rs +++ b/crates/editor/src/display_map/block_map.rs @@ -164,6 +164,7 @@ impl BlockPlacement { } impl BlockPlacement { + #[ztracing::instrument(skip_all)] fn cmp(&self, other: &Self, buffer: &MultiBufferSnapshot) -> Ordering { self.start() .cmp(other.start(), buffer) @@ -171,6 +172,7 @@ impl BlockPlacement { .then_with(|| self.tie_break().cmp(&other.tie_break())) } + #[ztracing::instrument(skip_all)] fn to_wrap_row(&self, wrap_snapshot: &WrapSnapshot) -> Option> { let buffer_snapshot = wrap_snapshot.buffer_snapshot(); match self { @@ -474,6 +476,7 @@ pub struct BlockRows<'a> { } impl BlockMap { + #[ztracing::instrument(skip_all)] pub fn new( wrap_snapshot: WrapSnapshot, buffer_header_height: u32, @@ -503,6 +506,7 @@ impl BlockMap { map } + #[ztracing::instrument(skip_all)] pub fn read(&self, wrap_snapshot: WrapSnapshot, edits: WrapPatch) -> BlockMapReader<'_> { self.sync(&wrap_snapshot, edits); *self.wrap_snapshot.borrow_mut() = wrap_snapshot.clone(); @@ -518,13 +522,17 @@ impl BlockMap { } } + #[ztracing::instrument(skip_all)] pub fn write(&mut self, wrap_snapshot: WrapSnapshot, edits: WrapPatch) -> BlockMapWriter<'_> { self.sync(&wrap_snapshot, edits); *self.wrap_snapshot.borrow_mut() = wrap_snapshot; BlockMapWriter(self) } + #[ztracing::instrument(skip_all, fields(edits))] fn sync(&self, wrap_snapshot: &WrapSnapshot, mut edits: WrapPatch) { + let _timer = zlog::time!("BlockMap::sync").warn_if_gt(std::time::Duration::from_millis(50)); + let buffer = wrap_snapshot.buffer_snapshot(); // Handle changing the last excerpt if it is empty. @@ -784,6 +792,7 @@ impl BlockMap { *transforms = new_transforms; } + #[ztracing::instrument(skip_all)] pub fn replace_blocks(&mut self, mut renderers: HashMap) { for block in &mut self.custom_blocks { if let Some(render) = renderers.remove(&block.id) { @@ -793,6 +802,7 @@ impl BlockMap { } /// Guarantees that `wrap_row_for` is called with points in increasing order. + #[ztracing::instrument(skip_all)] fn header_and_footer_blocks<'a, R, T>( &'a self, buffer: &'a multi_buffer::MultiBufferSnapshot, @@ -880,6 +890,7 @@ impl BlockMap { }) } + #[ztracing::instrument(skip_all)] fn sort_blocks(blocks: &mut Vec<(BlockPlacement, Block)>) { blocks.sort_unstable_by(|(placement_a, block_a), (placement_b, block_b)| { placement_a @@ -1016,6 +1027,7 @@ impl DerefMut for BlockMapReader<'_> { } impl BlockMapReader<'_> { + #[ztracing::instrument(skip_all)] pub fn row_for_block(&self, block_id: CustomBlockId) -> Option { let block = self.blocks.iter().find(|block| block.id == block_id)?; let buffer_row = block @@ -1054,6 +1066,7 @@ impl BlockMapReader<'_> { } impl BlockMapWriter<'_> { + #[ztracing::instrument(skip_all)] pub fn insert( &mut self, blocks: impl IntoIterator>, @@ -1120,6 +1133,7 @@ impl BlockMapWriter<'_> { ids } + #[ztracing::instrument(skip_all)] pub fn resize(&mut self, mut heights: HashMap) { let wrap_snapshot = &*self.0.wrap_snapshot.borrow(); let buffer = wrap_snapshot.buffer_snapshot(); @@ -1172,6 +1186,7 @@ impl BlockMapWriter<'_> { self.0.sync(wrap_snapshot, edits); } + #[ztracing::instrument(skip_all)] pub fn remove(&mut self, block_ids: HashSet) { let wrap_snapshot = &*self.0.wrap_snapshot.borrow(); let buffer = wrap_snapshot.buffer_snapshot(); @@ -1217,6 +1232,7 @@ impl BlockMapWriter<'_> { self.0.sync(wrap_snapshot, edits); } + #[ztracing::instrument(skip_all)] pub fn remove_intersecting_replace_blocks( &mut self, ranges: impl IntoIterator>, @@ -1239,6 +1255,7 @@ impl BlockMapWriter<'_> { self.0.buffers_with_disabled_headers.insert(buffer_id); } + #[ztracing::instrument(skip_all)] pub fn fold_buffers( &mut self, buffer_ids: impl IntoIterator, @@ -1248,6 +1265,7 @@ impl BlockMapWriter<'_> { self.fold_or_unfold_buffers(true, buffer_ids, multi_buffer, cx); } + #[ztracing::instrument(skip_all)] pub fn unfold_buffers( &mut self, buffer_ids: impl IntoIterator, @@ -1257,6 +1275,7 @@ impl BlockMapWriter<'_> { self.fold_or_unfold_buffers(false, buffer_ids, multi_buffer, cx); } + #[ztracing::instrument(skip_all)] fn fold_or_unfold_buffers( &mut self, fold: bool, @@ -1292,6 +1311,7 @@ impl BlockMapWriter<'_> { self.0.sync(&wrap_snapshot, edits); } + #[ztracing::instrument(skip_all)] fn blocks_intersecting_buffer_range( &self, range: Range, @@ -1326,6 +1346,7 @@ impl BlockMapWriter<'_> { impl BlockSnapshot { #[cfg(test)] + #[ztracing::instrument(skip_all)] pub fn text(&self) -> String { self.chunks( BlockRow(0)..self.transforms.summary().output_rows, @@ -1337,6 +1358,7 @@ impl BlockSnapshot { .collect() } + #[ztracing::instrument(skip_all)] pub(crate) fn chunks<'a>( &'a self, rows: Range, @@ -1378,6 +1400,7 @@ impl BlockSnapshot { } } + #[ztracing::instrument(skip_all)] pub(super) fn row_infos(&self, start_row: BlockRow) -> BlockRows<'_> { let mut cursor = self.transforms.cursor::>(()); cursor.seek(&start_row, Bias::Right); @@ -1399,6 +1422,7 @@ impl BlockSnapshot { } } + #[ztracing::instrument(skip_all)] pub fn blocks_in_range( &self, rows: Range, @@ -1432,6 +1456,7 @@ impl BlockSnapshot { }) } + #[ztracing::instrument(skip_all)] pub(crate) fn sticky_header_excerpt(&self, position: f64) -> Option> { let top_row = position as u32; let mut cursor = self.transforms.cursor::(()); @@ -1455,6 +1480,7 @@ impl BlockSnapshot { None } + #[ztracing::instrument(skip_all)] pub fn block_for_id(&self, block_id: BlockId) -> Option { let buffer = self.wrap_snapshot.buffer_snapshot(); let wrap_point = match block_id { @@ -1491,6 +1517,7 @@ impl BlockSnapshot { None } + #[ztracing::instrument(skip_all)] pub fn max_point(&self) -> BlockPoint { let row = self .transforms @@ -1500,10 +1527,12 @@ impl BlockSnapshot { BlockPoint::new(row, self.line_len(row)) } + #[ztracing::instrument(skip_all)] pub fn longest_row(&self) -> BlockRow { self.transforms.summary().longest_row } + #[ztracing::instrument(skip_all)] pub fn longest_row_in_range(&self, range: Range) -> BlockRow { let mut cursor = self.transforms.cursor::>(()); cursor.seek(&range.start, Bias::Right); @@ -1555,6 +1584,7 @@ impl BlockSnapshot { longest_row } + #[ztracing::instrument(skip_all)] pub(super) fn line_len(&self, row: BlockRow) -> u32 { let (start, _, item) = self.transforms @@ -1574,11 +1604,13 @@ impl BlockSnapshot { } } + #[ztracing::instrument(skip_all)] pub(super) fn is_block_line(&self, row: BlockRow) -> bool { let (_, _, item) = self.transforms.find::((), &row, Bias::Right); item.is_some_and(|t| t.block.is_some()) } + #[ztracing::instrument(skip_all)] pub(super) fn is_folded_buffer_header(&self, row: BlockRow) -> bool { let (_, _, item) = self.transforms.find::((), &row, Bias::Right); let Some(transform) = item else { @@ -1587,6 +1619,7 @@ impl BlockSnapshot { matches!(transform.block, Some(Block::FoldedBuffer { .. })) } + #[ztracing::instrument(skip_all)] pub(super) fn is_line_replaced(&self, row: MultiBufferRow) -> bool { let wrap_point = self .wrap_snapshot @@ -1602,6 +1635,7 @@ impl BlockSnapshot { }) } + #[ztracing::instrument(skip_all)] pub fn clip_point(&self, point: BlockPoint, bias: Bias) -> BlockPoint { let mut cursor = self.transforms.cursor::>(()); cursor.seek(&BlockRow(point.row), Bias::Right); @@ -1663,6 +1697,7 @@ impl BlockSnapshot { } } + #[ztracing::instrument(skip_all)] pub fn to_block_point(&self, wrap_point: WrapPoint) -> BlockPoint { let (start, _, item) = self.transforms.find::, _>( (), @@ -1684,6 +1719,7 @@ impl BlockSnapshot { } } + #[ztracing::instrument(skip_all)] pub fn to_wrap_point(&self, block_point: BlockPoint, bias: Bias) -> WrapPoint { let (start, end, item) = self.transforms.find::, _>( (), @@ -1719,6 +1755,7 @@ impl BlockSnapshot { impl BlockChunks<'_> { /// Go to the next transform + #[ztracing::instrument(skip_all)] fn advance(&mut self) { self.input_chunk = Chunk::default(); self.transforms.next(); @@ -1759,6 +1796,7 @@ pub struct StickyHeaderExcerpt<'a> { impl<'a> Iterator for BlockChunks<'a> { type Item = Chunk<'a>; + #[ztracing::instrument(skip_all)] fn next(&mut self) -> Option { if self.output_row >= self.max_output_row { return None; @@ -1858,6 +1896,7 @@ impl<'a> Iterator for BlockChunks<'a> { impl Iterator for BlockRows<'_> { type Item = RowInfo; + #[ztracing::instrument(skip_all)] fn next(&mut self) -> Option { if self.started { self.output_row.0 += 1; @@ -1960,14 +1999,17 @@ impl DerefMut for BlockContext<'_, '_> { } impl CustomBlock { + #[ztracing::instrument(skip_all)] pub fn render(&self, cx: &mut BlockContext) -> AnyElement { self.render.lock()(cx) } + #[ztracing::instrument(skip_all)] pub fn start(&self) -> Anchor { *self.placement.start() } + #[ztracing::instrument(skip_all)] pub fn end(&self) -> Anchor { *self.placement.end() } diff --git a/crates/editor/src/display_map/crease_map.rs b/crates/editor/src/display_map/crease_map.rs index a68c27886733d34a60ef0ce2ef4006b92b679db9..8f4a3781f4f335f1a3e61ec5a19818661a7c6ea5 100644 --- a/crates/editor/src/display_map/crease_map.rs +++ b/crates/editor/src/display_map/crease_map.rs @@ -19,6 +19,7 @@ pub struct CreaseMap { } impl CreaseMap { + #[ztracing::instrument(skip_all)] pub fn new(snapshot: &MultiBufferSnapshot) -> Self { CreaseMap { snapshot: CreaseSnapshot::new(snapshot), @@ -40,11 +41,13 @@ impl CreaseSnapshot { } } + #[ztracing::instrument(skip_all)] pub fn creases(&self) -> impl Iterator)> { self.creases.iter().map(|item| (item.id, &item.crease)) } /// Returns the first Crease starting on the specified buffer row. + #[ztracing::instrument(skip_all)] pub fn query_row<'a>( &'a self, row: MultiBufferRow, @@ -69,6 +72,7 @@ impl CreaseSnapshot { None } + #[ztracing::instrument(skip_all)] pub fn creases_in_range<'a>( &'a self, range: Range, @@ -95,6 +99,7 @@ impl CreaseSnapshot { }) } + #[ztracing::instrument(skip_all)] pub fn crease_items_with_offsets( &self, snapshot: &MultiBufferSnapshot, @@ -156,6 +161,7 @@ pub struct CreaseMetadata { } impl Crease { + #[ztracing::instrument(skip_all)] pub fn simple(range: Range, placeholder: FoldPlaceholder) -> Self { Crease::Inline { range, @@ -166,6 +172,7 @@ impl Crease { } } + #[ztracing::instrument(skip_all)] pub fn block(range: Range, height: u32, style: BlockStyle, render: RenderBlock) -> Self { Self::Block { range, @@ -177,6 +184,7 @@ impl Crease { } } + #[ztracing::instrument(skip_all)] pub fn inline( range: Range, placeholder: FoldPlaceholder, @@ -216,6 +224,7 @@ impl Crease { } } + #[ztracing::instrument(skip_all)] pub fn with_metadata(self, metadata: CreaseMetadata) -> Self { match self { Crease::Inline { @@ -235,6 +244,7 @@ impl Crease { } } + #[ztracing::instrument(skip_all)] pub fn range(&self) -> &Range { match self { Crease::Inline { range, .. } => range, @@ -242,6 +252,7 @@ impl Crease { } } + #[ztracing::instrument(skip_all)] pub fn metadata(&self) -> Option<&CreaseMetadata> { match self { Self::Inline { metadata, .. } => metadata.as_ref(), @@ -287,6 +298,7 @@ impl CreaseMap { self.snapshot.clone() } + #[ztracing::instrument(skip_all)] pub fn insert( &mut self, creases: impl IntoIterator>, @@ -312,6 +324,7 @@ impl CreaseMap { new_ids } + #[ztracing::instrument(skip_all)] pub fn remove( &mut self, ids: impl IntoIterator, @@ -379,6 +392,7 @@ impl sum_tree::Summary for ItemSummary { impl sum_tree::Item for CreaseItem { type Summary = ItemSummary; + #[ztracing::instrument(skip_all)] fn summary(&self, _cx: &MultiBufferSnapshot) -> Self::Summary { ItemSummary { range: self.crease.range().clone(), @@ -388,12 +402,14 @@ impl sum_tree::Item for CreaseItem { /// Implements `SeekTarget` for `Range` to enable seeking within a `SumTree` of `CreaseItem`s. impl SeekTarget<'_, ItemSummary, ItemSummary> for Range { + #[ztracing::instrument(skip_all)] fn cmp(&self, cursor_location: &ItemSummary, snapshot: &MultiBufferSnapshot) -> Ordering { AnchorRangeExt::cmp(self, &cursor_location.range, snapshot) } } impl SeekTarget<'_, ItemSummary, ItemSummary> for Anchor { + #[ztracing::instrument(skip_all)] fn cmp(&self, other: &ItemSummary, snapshot: &MultiBufferSnapshot) -> Ordering { self.cmp(&other.range.start, snapshot) } @@ -461,6 +477,7 @@ mod test { } #[gpui::test] + #[ztracing::instrument(skip_all)] fn test_creases_in_range(cx: &mut App) { let text = "line1\nline2\nline3\nline4\nline5\nline6\nline7"; let buffer = MultiBuffer::build_simple(text, cx); diff --git a/crates/editor/src/display_map/custom_highlights.rs b/crates/editor/src/display_map/custom_highlights.rs index a40d1adc82f4bc79308eaec901586232e9e2e5c2..c9202280bf957fac4d729bab558f686c0f62e774 100644 --- a/crates/editor/src/display_map/custom_highlights.rs +++ b/crates/editor/src/display_map/custom_highlights.rs @@ -30,6 +30,7 @@ struct HighlightEndpoint { } impl<'a> CustomHighlightsChunks<'a> { + #[ztracing::instrument(skip_all)] pub fn new( range: Range, language_aware: bool, @@ -51,6 +52,7 @@ impl<'a> CustomHighlightsChunks<'a> { } } + #[ztracing::instrument(skip_all)] pub fn seek(&mut self, new_range: Range) { self.highlight_endpoints = create_highlight_endpoints(&new_range, self.text_highlights, self.multibuffer_snapshot); @@ -108,6 +110,7 @@ fn create_highlight_endpoints( impl<'a> Iterator for CustomHighlightsChunks<'a> { type Item = Chunk<'a>; + #[ztracing::instrument(skip_all)] fn next(&mut self) -> Option { let mut next_highlight_endpoint = MultiBufferOffset(usize::MAX); while let Some(endpoint) = self.highlight_endpoints.peek().copied() { diff --git a/crates/editor/src/display_map/fold_map.rs b/crates/editor/src/display_map/fold_map.rs index 2d37dea38a93cc609a3a92064a6e35cdc76eb3da..bb0d6885acc2afd95e97fe9121acd2d0580554f3 100644 --- a/crates/editor/src/display_map/fold_map.rs +++ b/crates/editor/src/display_map/fold_map.rs @@ -99,6 +99,7 @@ impl FoldPoint { &mut self.0.column } + #[ztracing::instrument(skip_all)] pub fn to_inlay_point(self, snapshot: &FoldSnapshot) -> InlayPoint { let (start, _, _) = snapshot .transforms @@ -107,6 +108,7 @@ impl FoldPoint { InlayPoint(start.1.0 + overshoot) } + #[ztracing::instrument(skip_all)] pub fn to_offset(self, snapshot: &FoldSnapshot) -> FoldOffset { let (start, _, item) = snapshot .transforms @@ -138,6 +140,7 @@ impl<'a> sum_tree::Dimension<'a, TransformSummary> for FoldPoint { pub(crate) struct FoldMapWriter<'a>(&'a mut FoldMap); impl FoldMapWriter<'_> { + #[ztracing::instrument(skip_all)] pub(crate) fn fold( &mut self, ranges: impl IntoIterator, FoldPlaceholder)>, @@ -202,6 +205,7 @@ impl FoldMapWriter<'_> { } /// Removes any folds with the given ranges. + #[ztracing::instrument(skip_all)] pub(crate) fn remove_folds( &mut self, ranges: impl IntoIterator>, @@ -215,6 +219,7 @@ impl FoldMapWriter<'_> { } /// Removes any folds whose ranges intersect the given ranges. + #[ztracing::instrument(skip_all)] pub(crate) fn unfold_intersecting( &mut self, ranges: impl IntoIterator>, @@ -225,6 +230,7 @@ impl FoldMapWriter<'_> { /// Removes any folds that intersect the given ranges and for which the given predicate /// returns true. + #[ztracing::instrument(skip_all)] fn remove_folds_with( &mut self, ranges: impl IntoIterator>, @@ -277,6 +283,7 @@ impl FoldMapWriter<'_> { (self.0.snapshot.clone(), edits) } + #[ztracing::instrument(skip_all)] pub(crate) fn update_fold_widths( &mut self, new_widths: impl IntoIterator, @@ -326,6 +333,7 @@ pub struct FoldMap { } impl FoldMap { + #[ztracing::instrument(skip_all)] pub fn new(inlay_snapshot: InlaySnapshot) -> (Self, FoldSnapshot) { let this = Self { snapshot: FoldSnapshot { @@ -350,6 +358,7 @@ impl FoldMap { (this, snapshot) } + #[ztracing::instrument(skip_all)] pub fn read( &mut self, inlay_snapshot: InlaySnapshot, @@ -360,6 +369,7 @@ impl FoldMap { (self.snapshot.clone(), edits) } + #[ztracing::instrument(skip_all)] pub(crate) fn write( &mut self, inlay_snapshot: InlaySnapshot, @@ -369,6 +379,7 @@ impl FoldMap { (FoldMapWriter(self), snapshot, edits) } + #[ztracing::instrument(skip_all)] fn check_invariants(&self) { if cfg!(test) { assert_eq!( @@ -398,6 +409,7 @@ impl FoldMap { } } + #[ztracing::instrument(skip_all)] fn sync( &mut self, inlay_snapshot: InlaySnapshot, @@ -645,6 +657,7 @@ impl FoldSnapshot { &self.inlay_snapshot.buffer } + #[ztracing::instrument(skip_all)] fn fold_width(&self, fold_id: &FoldId) -> Option { self.fold_metadata_by_id.get(fold_id)?.width } @@ -665,6 +678,7 @@ impl FoldSnapshot { self.folds.items(&self.inlay_snapshot.buffer).len() } + #[ztracing::instrument(skip_all)] pub fn text_summary_for_range(&self, range: Range) -> MBTextSummary { let mut summary = MBTextSummary::default(); @@ -718,6 +732,7 @@ impl FoldSnapshot { summary } + #[ztracing::instrument(skip_all)] pub fn to_fold_point(&self, point: InlayPoint, bias: Bias) -> FoldPoint { let (start, end, item) = self .transforms @@ -734,6 +749,7 @@ impl FoldSnapshot { } } + #[ztracing::instrument(skip_all)] pub fn fold_point_cursor(&self) -> FoldPointCursor<'_> { let cursor = self .transforms @@ -741,10 +757,12 @@ impl FoldSnapshot { FoldPointCursor { cursor } } + #[ztracing::instrument(skip_all)] pub fn len(&self) -> FoldOffset { FoldOffset(self.transforms.summary().output.len) } + #[ztracing::instrument(skip_all)] pub fn line_len(&self, row: u32) -> u32 { let line_start = FoldPoint::new(row, 0).to_offset(self).0; let line_end = if row >= self.max_point().row() { @@ -755,6 +773,7 @@ impl FoldSnapshot { (line_end - line_start) as u32 } + #[ztracing::instrument(skip_all)] pub fn row_infos(&self, start_row: u32) -> FoldRows<'_> { if start_row > self.transforms.summary().output.lines.row { panic!("invalid display row {}", start_row); @@ -777,6 +796,7 @@ impl FoldSnapshot { } } + #[ztracing::instrument(skip_all)] pub fn max_point(&self) -> FoldPoint { FoldPoint(self.transforms.summary().output.lines) } @@ -786,6 +806,7 @@ impl FoldSnapshot { self.transforms.summary().output.longest_row } + #[ztracing::instrument(skip_all)] pub fn folds_in_range(&self, range: Range) -> impl Iterator where T: ToOffset, @@ -800,6 +821,7 @@ impl FoldSnapshot { }) } + #[ztracing::instrument(skip_all)] pub fn intersects_fold(&self, offset: T) -> bool where T: ToOffset, @@ -812,6 +834,7 @@ impl FoldSnapshot { item.is_some_and(|t| t.placeholder.is_some()) } + #[ztracing::instrument(skip_all)] pub fn is_line_folded(&self, buffer_row: MultiBufferRow) -> bool { let mut inlay_point = self .inlay_snapshot @@ -840,6 +863,7 @@ impl FoldSnapshot { } } + #[ztracing::instrument(skip_all)] pub(crate) fn chunks<'a>( &'a self, range: Range, @@ -884,6 +908,7 @@ impl FoldSnapshot { } } + #[ztracing::instrument(skip_all)] pub fn chars_at(&self, start: FoldPoint) -> impl '_ + Iterator { self.chunks( start.to_offset(self)..self.len(), @@ -893,6 +918,7 @@ impl FoldSnapshot { .flat_map(|chunk| chunk.text.chars()) } + #[ztracing::instrument(skip_all)] pub fn chunks_at(&self, start: FoldPoint) -> FoldChunks<'_> { self.chunks( start.to_offset(self)..self.len(), @@ -902,6 +928,7 @@ impl FoldSnapshot { } #[cfg(test)] + #[ztracing::instrument(skip_all)] pub fn clip_offset(&self, offset: FoldOffset, bias: Bias) -> FoldOffset { if offset > self.len() { self.len() @@ -910,6 +937,7 @@ impl FoldSnapshot { } } + #[ztracing::instrument(skip_all)] pub fn clip_point(&self, point: FoldPoint, bias: Bias) -> FoldPoint { let (start, end, item) = self .transforms @@ -939,6 +967,7 @@ pub struct FoldPointCursor<'transforms> { } impl FoldPointCursor<'_> { + #[ztracing::instrument(skip_all)] pub fn map(&mut self, point: InlayPoint, bias: Bias) -> FoldPoint { let cursor = &mut self.cursor; if cursor.did_seek() { @@ -1267,6 +1296,7 @@ pub struct FoldRows<'a> { } impl FoldRows<'_> { + #[ztracing::instrument(skip_all)] pub(crate) fn seek(&mut self, row: u32) { let fold_point = FoldPoint::new(row, 0); self.cursor.seek(&fold_point, Bias::Left); @@ -1280,6 +1310,7 @@ impl FoldRows<'_> { impl Iterator for FoldRows<'_> { type Item = RowInfo; + #[ztracing::instrument(skip_all)] fn next(&mut self) -> Option { let mut traversed_fold = false; while self.fold_point > self.cursor.end().0 { @@ -1391,6 +1422,7 @@ pub struct FoldChunks<'a> { } impl FoldChunks<'_> { + #[ztracing::instrument(skip_all)] pub(crate) fn seek(&mut self, range: Range) { self.transform_cursor.seek(&range.start, Bias::Right); @@ -1425,6 +1457,7 @@ impl FoldChunks<'_> { impl<'a> Iterator for FoldChunks<'a> { type Item = Chunk<'a>; + #[ztracing::instrument(skip_all)] fn next(&mut self) -> Option { if self.output_offset >= self.max_output_offset { return None; @@ -1524,6 +1557,7 @@ impl<'a> Iterator for FoldChunks<'a> { pub struct FoldOffset(pub MultiBufferOffset); impl FoldOffset { + #[ztracing::instrument(skip_all)] pub fn to_point(self, snapshot: &FoldSnapshot) -> FoldPoint { let (start, _, item) = snapshot .transforms @@ -1539,6 +1573,7 @@ impl FoldOffset { } #[cfg(test)] + #[ztracing::instrument(skip_all)] pub fn to_inlay_offset(self, snapshot: &FoldSnapshot) -> InlayOffset { let (start, _, _) = snapshot .transforms diff --git a/crates/editor/src/display_map/inlay_map.rs b/crates/editor/src/display_map/inlay_map.rs index 73174c3018e1f76a16acbff3f4bad1c7af84da33..d85f761a82e2f466b6868c4ce28bcb3a4e6b061d 100644 --- a/crates/editor/src/display_map/inlay_map.rs +++ b/crates/editor/src/display_map/inlay_map.rs @@ -52,6 +52,7 @@ enum Transform { impl sum_tree::Item for Transform { type Summary = TransformSummary; + #[ztracing::instrument(skip_all)] fn summary(&self, _: ()) -> Self::Summary { match self { Transform::Isomorphic(summary) => TransformSummary { @@ -228,6 +229,7 @@ pub struct InlayChunk<'a> { } impl InlayChunks<'_> { + #[ztracing::instrument(skip_all)] pub fn seek(&mut self, new_range: Range) { self.transforms.seek(&new_range.start, Bias::Right); @@ -248,6 +250,7 @@ impl InlayChunks<'_> { impl<'a> Iterator for InlayChunks<'a> { type Item = InlayChunk<'a>; + #[ztracing::instrument(skip_all)] fn next(&mut self) -> Option { if self.output_offset == self.max_output_offset { return None; @@ -441,6 +444,7 @@ impl<'a> Iterator for InlayChunks<'a> { } impl InlayBufferRows<'_> { + #[ztracing::instrument(skip_all)] pub fn seek(&mut self, row: u32) { let inlay_point = InlayPoint::new(row, 0); self.transforms.seek(&inlay_point, Bias::Left); @@ -465,6 +469,7 @@ impl InlayBufferRows<'_> { impl Iterator for InlayBufferRows<'_> { type Item = RowInfo; + #[ztracing::instrument(skip_all)] fn next(&mut self) -> Option { let buffer_row = if self.inlay_row == 0 { self.buffer_rows.next().unwrap() @@ -494,6 +499,7 @@ impl InlayPoint { } impl InlayMap { + #[ztracing::instrument(skip_all)] pub fn new(buffer: MultiBufferSnapshot) -> (Self, InlaySnapshot) { let version = 0; let snapshot = InlaySnapshot { @@ -511,6 +517,7 @@ impl InlayMap { ) } + #[ztracing::instrument(skip_all)] pub fn sync( &mut self, buffer_snapshot: MultiBufferSnapshot, @@ -643,6 +650,7 @@ impl InlayMap { } } + #[ztracing::instrument(skip_all)] pub fn splice( &mut self, to_remove: &[InlayId], @@ -693,11 +701,13 @@ impl InlayMap { (snapshot, edits) } + #[ztracing::instrument(skip_all)] pub fn current_inlays(&self) -> impl Iterator { self.inlays.iter() } #[cfg(test)] + #[ztracing::instrument(skip_all)] pub(crate) fn randomly_mutate( &mut self, next_inlay_id: &mut usize, @@ -766,6 +776,7 @@ impl InlayMap { } impl InlaySnapshot { + #[ztracing::instrument(skip_all)] pub fn to_point(&self, offset: InlayOffset) -> InlayPoint { let (start, _, item) = self.transforms.find:: InlayOffset { InlayOffset(self.transforms.summary().output.len) } + #[ztracing::instrument(skip_all)] pub fn max_point(&self) -> InlayPoint { InlayPoint(self.transforms.summary().output.lines) } + #[ztracing::instrument(skip_all, fields(point))] pub fn to_offset(&self, point: InlayPoint) -> InlayOffset { let (start, _, item) = self .transforms @@ -817,6 +831,7 @@ impl InlaySnapshot { None => self.len(), } } + #[ztracing::instrument(skip_all)] pub fn to_buffer_point(&self, point: InlayPoint) -> Point { let (start, _, item) = self.transforms @@ -830,6 +845,7 @@ impl InlaySnapshot { None => self.buffer.max_point(), } } + #[ztracing::instrument(skip_all)] pub fn to_buffer_offset(&self, offset: InlayOffset) -> MultiBufferOffset { let (start, _, item) = self .transforms @@ -844,6 +860,7 @@ impl InlaySnapshot { } } + #[ztracing::instrument(skip_all)] pub fn to_inlay_offset(&self, offset: MultiBufferOffset) -> InlayOffset { let mut cursor = self .transforms @@ -880,10 +897,12 @@ impl InlaySnapshot { } } + #[ztracing::instrument(skip_all)] pub fn to_inlay_point(&self, point: Point) -> InlayPoint { self.inlay_point_cursor().map(point) } + #[ztracing::instrument(skip_all)] pub fn inlay_point_cursor(&self) -> InlayPointCursor<'_> { let cursor = self.transforms.cursor::>(()); InlayPointCursor { @@ -892,6 +911,7 @@ impl InlaySnapshot { } } + #[ztracing::instrument(skip_all)] pub fn clip_point(&self, mut point: InlayPoint, mut bias: Bias) -> InlayPoint { let mut cursor = self.transforms.cursor::>(()); cursor.seek(&point, Bias::Left); @@ -983,10 +1003,12 @@ impl InlaySnapshot { } } + #[ztracing::instrument(skip_all)] pub fn text_summary(&self) -> MBTextSummary { self.transforms.summary().output } + #[ztracing::instrument(skip_all)] pub fn text_summary_for_range(&self, range: Range) -> MBTextSummary { let mut summary = MBTextSummary::default(); @@ -1044,6 +1066,7 @@ impl InlaySnapshot { summary } + #[ztracing::instrument(skip_all)] pub fn row_infos(&self, row: u32) -> InlayBufferRows<'_> { let mut cursor = self.transforms.cursor::>(()); let inlay_point = InlayPoint::new(row, 0); @@ -1071,6 +1094,7 @@ impl InlaySnapshot { } } + #[ztracing::instrument(skip_all)] pub fn line_len(&self, row: u32) -> u32 { let line_start = self.to_offset(InlayPoint::new(row, 0)).0; let line_end = if row >= self.max_point().row() { @@ -1081,6 +1105,7 @@ impl InlaySnapshot { (line_end - line_start) as u32 } + #[ztracing::instrument(skip_all)] pub(crate) fn chunks<'a>( &'a self, range: Range, @@ -1115,12 +1140,14 @@ impl InlaySnapshot { } #[cfg(test)] + #[ztracing::instrument(skip_all)] pub fn text(&self) -> String { self.chunks(Default::default()..self.len(), false, Highlights::default()) .map(|chunk| chunk.chunk.text) .collect() } + #[ztracing::instrument(skip_all)] fn check_invariants(&self) { #[cfg(any(debug_assertions, feature = "test-support"))] { @@ -1147,6 +1174,7 @@ pub struct InlayPointCursor<'transforms> { } impl InlayPointCursor<'_> { + #[ztracing::instrument(skip_all)] pub fn map(&mut self, point: Point) -> InlayPoint { let cursor = &mut self.cursor; if cursor.did_seek() { diff --git a/crates/editor/src/display_map/invisibles.rs b/crates/editor/src/display_map/invisibles.rs index 5622a659b7acf850d24f6a476b23b53d214d855d..90bd54ab2807bbef703ac29e4ac4eaf49bcf71fd 100644 --- a/crates/editor/src/display_map/invisibles.rs +++ b/crates/editor/src/display_map/invisibles.rs @@ -30,6 +30,7 @@ // ref: https://gist.github.com/ConradIrwin/f759e1fc29267143c4c7895aa495dca5?h=1 // ref: https://unicode.org/Public/emoji/13.0/emoji-test.txt // https://github.com/bits/UTF-8-Unicode-Test-Documents/blob/master/UTF-8_sequence_separated/utf8_sequence_0-0x10ffff_assigned_including-unprintable-asis.txt +#[ztracing::instrument(skip_all)] pub fn is_invisible(c: char) -> bool { if c <= '\u{1f}' { c != '\t' && c != '\n' && c != '\r' diff --git a/crates/editor/src/display_map/tab_map.rs b/crates/editor/src/display_map/tab_map.rs index 347d7732151e172812de1e0252ca8d65f4cdbb8b..4e768a477159820ea380aa48a123d103c0c2f6a2 100644 --- a/crates/editor/src/display_map/tab_map.rs +++ b/crates/editor/src/display_map/tab_map.rs @@ -20,6 +20,7 @@ const MAX_TABS: NonZeroU32 = NonZeroU32::new(SPACES.len() as u32).unwrap(); pub struct TabMap(TabSnapshot); impl TabMap { + #[ztracing::instrument(skip_all)] pub fn new(fold_snapshot: FoldSnapshot, tab_size: NonZeroU32) -> (Self, TabSnapshot) { let snapshot = TabSnapshot { fold_snapshot, @@ -36,6 +37,7 @@ impl TabMap { self.0.clone() } + #[ztracing::instrument(skip_all)] pub fn sync( &mut self, fold_snapshot: FoldSnapshot, @@ -176,10 +178,12 @@ impl std::ops::Deref for TabSnapshot { } impl TabSnapshot { + #[ztracing::instrument(skip_all)] pub fn buffer_snapshot(&self) -> &MultiBufferSnapshot { &self.fold_snapshot.inlay_snapshot.buffer } + #[ztracing::instrument(skip_all)] pub fn line_len(&self, row: u32) -> u32 { let max_point = self.max_point(); if row < max_point.row() { @@ -191,10 +195,12 @@ impl TabSnapshot { } } + #[ztracing::instrument(skip_all)] pub fn text_summary(&self) -> TextSummary { self.text_summary_for_range(TabPoint::zero()..self.max_point()) } + #[ztracing::instrument(skip_all, fields(rows))] pub fn text_summary_for_range(&self, range: Range) -> TextSummary { let input_start = self.tab_point_to_fold_point(range.start, Bias::Left).0; let input_end = self.tab_point_to_fold_point(range.end, Bias::Right).0; @@ -234,6 +240,7 @@ impl TabSnapshot { } } + #[ztracing::instrument(skip_all)] pub(crate) fn chunks<'a>( &'a self, range: Range, @@ -276,11 +283,13 @@ impl TabSnapshot { } } + #[ztracing::instrument(skip_all)] pub fn rows(&self, row: u32) -> fold_map::FoldRows<'_> { self.fold_snapshot.row_infos(row) } #[cfg(test)] + #[ztracing::instrument(skip_all)] pub fn text(&self) -> String { self.chunks( TabPoint::zero()..self.max_point(), @@ -291,10 +300,12 @@ impl TabSnapshot { .collect() } + #[ztracing::instrument(skip_all)] pub fn max_point(&self) -> TabPoint { self.fold_point_to_tab_point(self.fold_snapshot.max_point()) } + #[ztracing::instrument(skip_all)] pub fn clip_point(&self, point: TabPoint, bias: Bias) -> TabPoint { self.fold_point_to_tab_point( self.fold_snapshot @@ -302,6 +313,7 @@ impl TabSnapshot { ) } + #[ztracing::instrument(skip_all)] pub fn fold_point_to_tab_point(&self, input: FoldPoint) -> TabPoint { let chunks = self.fold_snapshot.chunks_at(FoldPoint::new(input.row(), 0)); let tab_cursor = TabStopCursor::new(chunks); @@ -309,10 +321,12 @@ impl TabSnapshot { TabPoint::new(input.row(), expanded) } + #[ztracing::instrument(skip_all)] pub fn tab_point_cursor(&self) -> TabPointCursor<'_> { TabPointCursor { this: self } } + #[ztracing::instrument(skip_all)] pub fn tab_point_to_fold_point(&self, output: TabPoint, bias: Bias) -> (FoldPoint, u32, u32) { let chunks = self .fold_snapshot @@ -330,12 +344,14 @@ impl TabSnapshot { ) } + #[ztracing::instrument(skip_all)] pub fn point_to_tab_point(&self, point: Point, bias: Bias) -> TabPoint { let inlay_point = self.fold_snapshot.inlay_snapshot.to_inlay_point(point); let fold_point = self.fold_snapshot.to_fold_point(inlay_point, bias); self.fold_point_to_tab_point(fold_point) } + #[ztracing::instrument(skip_all)] pub fn tab_point_to_point(&self, point: TabPoint, bias: Bias) -> Point { let fold_point = self.tab_point_to_fold_point(point, bias).0; let inlay_point = fold_point.to_inlay_point(&self.fold_snapshot); @@ -344,6 +360,7 @@ impl TabSnapshot { .to_buffer_point(inlay_point) } + #[ztracing::instrument(skip_all)] fn expand_tabs<'a, I>(&self, mut cursor: TabStopCursor<'a, I>, column: u32) -> u32 where I: Iterator>, @@ -377,6 +394,7 @@ impl TabSnapshot { expanded_bytes + column.saturating_sub(collapsed_bytes) } + #[ztracing::instrument(skip_all)] fn collapse_tabs<'a, I>( &self, mut cursor: TabStopCursor<'a, I>, @@ -442,6 +460,7 @@ pub struct TabPointCursor<'this> { } impl TabPointCursor<'_> { + #[ztracing::instrument(skip_all)] pub fn map(&mut self, point: FoldPoint) -> TabPoint { self.this.fold_point_to_tab_point(point) } @@ -486,6 +505,7 @@ pub struct TextSummary { } impl<'a> From<&'a str> for TextSummary { + #[ztracing::instrument(skip_all)] fn from(text: &'a str) -> Self { let sum = text::TextSummary::from(text); @@ -500,6 +520,7 @@ impl<'a> From<&'a str> for TextSummary { } impl<'a> std::ops::AddAssign<&'a Self> for TextSummary { + #[ztracing::instrument(skip_all)] fn add_assign(&mut self, other: &'a Self) { let joined_chars = self.last_line_chars + other.first_line_chars; if joined_chars > self.longest_row_chars { @@ -541,6 +562,7 @@ pub struct TabChunks<'a> { } impl TabChunks<'_> { + #[ztracing::instrument(skip_all)] pub(crate) fn seek(&mut self, range: Range) { let (input_start, expanded_char_column, to_next_stop) = self .snapshot @@ -576,6 +598,7 @@ impl TabChunks<'_> { impl<'a> Iterator for TabChunks<'a> { type Item = Chunk<'a>; + #[ztracing::instrument(skip_all)] fn next(&mut self) -> Option { if self.chunk.text.is_empty() { if let Some(chunk) = self.fold_chunks.next() { @@ -1452,6 +1475,7 @@ impl<'a, I> TabStopCursor<'a, I> where I: Iterator>, { + #[ztracing::instrument(skip_all)] fn new(chunks: impl IntoIterator, IntoIter = I>) -> Self { Self { chunks: chunks.into_iter(), @@ -1461,6 +1485,7 @@ where } } + #[ztracing::instrument(skip_all)] fn bytes_until_next_char(&self) -> Option { self.current_chunk.as_ref().and_then(|(chunk, idx)| { let mut idx = *idx; @@ -1482,6 +1507,7 @@ where }) } + #[ztracing::instrument(skip_all)] fn is_char_boundary(&self) -> bool { self.current_chunk .as_ref() @@ -1489,6 +1515,7 @@ where } /// distance: length to move forward while searching for the next tab stop + #[ztracing::instrument(skip_all)] fn seek(&mut self, distance: u32) -> Option { if distance == 0 { return None; diff --git a/crates/editor/src/display_map/wrap_map.rs b/crates/editor/src/display_map/wrap_map.rs index 20ef9391888e6a824b87fe5de2607500049904ff..51d5324c838dc7cb7f4df04b0e58577108aab6c8 100644 --- a/crates/editor/src/display_map/wrap_map.rs +++ b/crates/editor/src/display_map/wrap_map.rs @@ -86,6 +86,7 @@ pub struct WrapRows<'a> { } impl WrapRows<'_> { + #[ztracing::instrument(skip_all)] pub(crate) fn seek(&mut self, start_row: WrapRow) { self.transforms .seek(&WrapPoint::new(start_row, 0), Bias::Left); @@ -101,6 +102,7 @@ impl WrapRows<'_> { } impl WrapMap { + #[ztracing::instrument(skip_all)] pub fn new( tab_snapshot: TabSnapshot, font: Font, @@ -131,6 +133,7 @@ impl WrapMap { self.background_task.is_some() } + #[ztracing::instrument(skip_all)] pub fn sync( &mut self, tab_snapshot: TabSnapshot, @@ -150,6 +153,7 @@ impl WrapMap { (self.snapshot.clone(), mem::take(&mut self.edits_since_sync)) } + #[ztracing::instrument(skip_all)] pub fn set_font_with_size( &mut self, font: Font, @@ -167,6 +171,7 @@ impl WrapMap { } } + #[ztracing::instrument(skip_all)] pub fn set_wrap_width(&mut self, wrap_width: Option, cx: &mut Context) -> bool { if wrap_width == self.wrap_width { return false; @@ -177,6 +182,7 @@ impl WrapMap { true } + #[ztracing::instrument(skip_all)] fn rewrap(&mut self, cx: &mut Context) { self.background_task.take(); self.interpolated_edits.clear(); @@ -248,6 +254,7 @@ impl WrapMap { } } + #[ztracing::instrument(skip_all)] fn flush_edits(&mut self, cx: &mut Context) { if !self.snapshot.interpolated { let mut to_remove_len = 0; @@ -330,6 +337,7 @@ impl WrapMap { } impl WrapSnapshot { + #[ztracing::instrument(skip_all)] fn new(tab_snapshot: TabSnapshot) -> Self { let mut transforms = SumTree::default(); let extent = tab_snapshot.text_summary(); @@ -343,10 +351,12 @@ impl WrapSnapshot { } } + #[ztracing::instrument(skip_all)] pub fn buffer_snapshot(&self) -> &MultiBufferSnapshot { self.tab_snapshot.buffer_snapshot() } + #[ztracing::instrument(skip_all)] fn interpolate(&mut self, new_tab_snapshot: TabSnapshot, tab_edits: &[TabEdit]) -> WrapPatch { let mut new_transforms; if tab_edits.is_empty() { @@ -411,6 +421,7 @@ impl WrapSnapshot { old_snapshot.compute_edits(tab_edits, self) } + #[ztracing::instrument(skip_all)] async fn update( &mut self, new_tab_snapshot: TabSnapshot, @@ -570,6 +581,7 @@ impl WrapSnapshot { old_snapshot.compute_edits(tab_edits, self) } + #[ztracing::instrument(skip_all)] fn compute_edits(&self, tab_edits: &[TabEdit], new_snapshot: &WrapSnapshot) -> WrapPatch { let mut wrap_edits = Vec::with_capacity(tab_edits.len()); let mut old_cursor = self.transforms.cursor::(()); @@ -606,6 +618,7 @@ impl WrapSnapshot { Patch::new(wrap_edits) } + #[ztracing::instrument(skip_all)] pub(crate) fn chunks<'a>( &'a self, rows: Range, @@ -640,10 +653,12 @@ impl WrapSnapshot { } } + #[ztracing::instrument(skip_all)] pub fn max_point(&self) -> WrapPoint { WrapPoint(self.transforms.summary().output.lines) } + #[ztracing::instrument(skip_all)] pub fn line_len(&self, row: WrapRow) -> u32 { let (start, _, item) = self.transforms.find::, _>( (), @@ -664,6 +679,7 @@ impl WrapSnapshot { } } + #[ztracing::instrument(skip_all, fields(rows))] pub fn text_summary_for_range(&self, rows: Range) -> TextSummary { let mut summary = TextSummary::default(); @@ -725,6 +741,7 @@ impl WrapSnapshot { summary } + #[ztracing::instrument(skip_all)] pub fn soft_wrap_indent(&self, row: WrapRow) -> Option { let (.., item) = self.transforms.find::( (), @@ -740,10 +757,12 @@ impl WrapSnapshot { }) } + #[ztracing::instrument(skip_all)] pub fn longest_row(&self) -> u32 { self.transforms.summary().output.longest_row } + #[ztracing::instrument(skip_all)] pub fn row_infos(&self, start_row: WrapRow) -> WrapRows<'_> { let mut transforms = self .transforms @@ -766,6 +785,7 @@ impl WrapSnapshot { } } + #[ztracing::instrument(skip_all)] pub fn to_tab_point(&self, point: WrapPoint) -> TabPoint { let (start, _, item) = self.transforms @@ -777,15 +797,18 @@ impl WrapSnapshot { TabPoint(tab_point) } + #[ztracing::instrument(skip_all)] pub fn to_point(&self, point: WrapPoint, bias: Bias) -> Point { self.tab_snapshot .tab_point_to_point(self.to_tab_point(point), bias) } + #[ztracing::instrument(skip_all)] pub fn make_wrap_point(&self, point: Point, bias: Bias) -> WrapPoint { self.tab_point_to_wrap_point(self.tab_snapshot.point_to_tab_point(point, bias)) } + #[ztracing::instrument(skip_all)] pub fn tab_point_to_wrap_point(&self, point: TabPoint) -> WrapPoint { let (start, ..) = self.transforms @@ -793,6 +816,7 @@ impl WrapSnapshot { WrapPoint(start.1.0 + (point.0 - start.0.0)) } + #[ztracing::instrument(skip_all)] pub fn wrap_point_cursor(&self) -> WrapPointCursor<'_> { WrapPointCursor { cursor: self @@ -801,6 +825,7 @@ impl WrapSnapshot { } } + #[ztracing::instrument(skip_all)] pub fn clip_point(&self, mut point: WrapPoint, bias: Bias) -> WrapPoint { if bias == Bias::Left { let (start, _, item) = self @@ -815,6 +840,7 @@ impl WrapSnapshot { self.tab_point_to_wrap_point(self.tab_snapshot.clip_point(self.to_tab_point(point), bias)) } + #[ztracing::instrument(skip_all, fields(point, ret))] pub fn prev_row_boundary(&self, mut point: WrapPoint) -> WrapRow { if self.transforms.is_empty() { return WrapRow(0); @@ -841,6 +867,7 @@ impl WrapSnapshot { unreachable!() } + #[ztracing::instrument(skip_all)] pub fn next_row_boundary(&self, mut point: WrapPoint) -> Option { point.0 += Point::new(1, 0); @@ -860,11 +887,13 @@ impl WrapSnapshot { } #[cfg(test)] + #[ztracing::instrument(skip_all)] pub fn text(&self) -> String { self.text_chunks(WrapRow(0)).collect() } #[cfg(test)] + #[ztracing::instrument(skip_all)] pub fn text_chunks(&self, wrap_row: WrapRow) -> impl Iterator { self.chunks( wrap_row..self.max_point().row() + WrapRow(1), @@ -874,6 +903,7 @@ impl WrapSnapshot { .map(|h| h.text) } + #[ztracing::instrument(skip_all)] fn check_invariants(&self) { #[cfg(test)] { @@ -927,6 +957,7 @@ pub struct WrapPointCursor<'transforms> { } impl WrapPointCursor<'_> { + #[ztracing::instrument(skip_all)] pub fn map(&mut self, point: TabPoint) -> WrapPoint { let cursor = &mut self.cursor; if cursor.did_seek() { @@ -939,6 +970,7 @@ impl WrapPointCursor<'_> { } impl WrapChunks<'_> { + #[ztracing::instrument(skip_all)] pub(crate) fn seek(&mut self, rows: Range) { let output_start = WrapPoint::new(rows.start, 0); let output_end = WrapPoint::new(rows.end, 0); @@ -961,6 +993,7 @@ impl WrapChunks<'_> { impl<'a> Iterator for WrapChunks<'a> { type Item = Chunk<'a>; + #[ztracing::instrument(skip_all)] fn next(&mut self) -> Option { if self.output_position.row() >= self.max_output_row { return None; @@ -1033,6 +1066,7 @@ impl<'a> Iterator for WrapChunks<'a> { impl Iterator for WrapRows<'_> { type Item = RowInfo; + #[ztracing::instrument(skip_all)] fn next(&mut self) -> Option { if self.output_row > self.max_output_row { return None; @@ -1069,6 +1103,7 @@ impl Iterator for WrapRows<'_> { } impl Transform { + #[ztracing::instrument(skip_all)] fn isomorphic(summary: TextSummary) -> Self { #[cfg(test)] assert!(!summary.lines.is_zero()); @@ -1082,6 +1117,7 @@ impl Transform { } } + #[ztracing::instrument(skip_all)] fn wrap(indent: u32) -> Self { static WRAP_TEXT: LazyLock = LazyLock::new(|| { let mut wrap_text = String::new(); @@ -1134,6 +1170,7 @@ trait SumTreeExt { } impl SumTreeExt for SumTree { + #[ztracing::instrument(skip_all)] fn push_or_extend(&mut self, transform: Transform) { let mut transform = Some(transform); self.update_last( @@ -1197,6 +1234,7 @@ impl<'a> sum_tree::Dimension<'a, TransformSummary> for TabPoint { } impl sum_tree::SeekTarget<'_, TransformSummary, TransformSummary> for TabPoint { + #[ztracing::instrument(skip_all)] fn cmp(&self, cursor_location: &TransformSummary, _: ()) -> std::cmp::Ordering { Ord::cmp(&self.0, &cursor_location.input.lines) } diff --git a/crates/git_ui/Cargo.toml b/crates/git_ui/Cargo.toml index 5e96cd3529b48bb401ee14e1a704b9bec485e356..beaf192b0ef538fb524ff4986710255040b89f27 100644 --- a/crates/git_ui/Cargo.toml +++ b/crates/git_ui/Cargo.toml @@ -13,7 +13,6 @@ name = "git_ui" path = "src/git_ui.rs" [features] -default = [] test-support = ["multi_buffer/test-support"] [dependencies] @@ -62,7 +61,8 @@ watch.workspace = true workspace.workspace = true zed_actions.workspace = true zeroize.workspace = true - +ztracing.workspace = true +tracing.workspace = true [target.'cfg(windows)'.dependencies] windows.workspace = true @@ -78,3 +78,6 @@ settings = { workspace = true, features = ["test-support"] } unindent.workspace = true workspace = { workspace = true, features = ["test-support"] } zlog.workspace = true + +[package.metadata.cargo-machete] +ignored = ["tracing"] diff --git a/crates/git_ui/src/project_diff.rs b/crates/git_ui/src/project_diff.rs index 0a8667ba6c753f9b7925948f212388f0668c1c92..f211483c5efeb14fd230def9235d82a1a79f49b4 100644 --- a/crates/git_ui/src/project_diff.rs +++ b/crates/git_ui/src/project_diff.rs @@ -46,6 +46,7 @@ use workspace::{ notifications::NotifyTaskExt, searchable::SearchableItemHandle, }; +use ztracing::instrument; actions!( git, @@ -469,6 +470,7 @@ impl ProjectDiff { } } + #[instrument(skip_all)] fn register_buffer( &mut self, path_key: PathKey, diff --git a/crates/multi_buffer/Cargo.toml b/crates/multi_buffer/Cargo.toml index 93747140c1960b70b9a9ddffe2a609e8a32a7dc7..524c916682f4d17b4e4b598a9af158e259b40ffc 100644 --- a/crates/multi_buffer/Cargo.toml +++ b/crates/multi_buffer/Cargo.toml @@ -42,6 +42,8 @@ sum_tree.workspace = true text.workspace = true theme.workspace = true tree-sitter.workspace = true +ztracing.workspace = true +tracing.workspace = true util.workspace = true [dev-dependencies] @@ -56,3 +58,6 @@ settings = { workspace = true, features = ["test-support"] } text = { workspace = true, features = ["test-support"] } util = { workspace = true, features = ["test-support"] } zlog.workspace = true + +[package.metadata.cargo-machete] +ignored = ["tracing"] diff --git a/crates/multi_buffer/src/multi_buffer.rs b/crates/multi_buffer/src/multi_buffer.rs index af36aaadf02b53224c4ef0bcf0a17d3643ab8f0f..24cb55d2f5e7311cc492ec70ab320eb12e78f8ee 100644 --- a/crates/multi_buffer/src/multi_buffer.rs +++ b/crates/multi_buffer/src/multi_buffer.rs @@ -57,6 +57,7 @@ use text::{ }; use theme::SyntaxTheme; use util::post_inc; +use ztracing::instrument; pub use self::path_key::PathKey; @@ -1671,6 +1672,7 @@ impl MultiBuffer { self.insert_excerpts_after(ExcerptId::max(), buffer, ranges, cx) } + #[instrument(skip_all)] fn merge_excerpt_ranges<'a>( expanded_ranges: impl IntoIterator> + 'a, ) -> (Vec>, Vec) { @@ -4483,6 +4485,7 @@ impl MultiBufferSnapshot { self.convert_dimension(point, text::BufferSnapshot::point_utf16_to_point) } + #[instrument(skip_all)] pub fn point_to_offset(&self, point: Point) -> MultiBufferOffset { self.convert_dimension(point, text::BufferSnapshot::point_to_offset) } @@ -4536,6 +4539,7 @@ impl MultiBufferSnapshot { } } + #[instrument(skip_all)] fn convert_dimension( &self, key: MBR1, @@ -6684,6 +6688,7 @@ where MBD: MultiBufferDimension + Ord + Sub + ops::AddAssign<::Output>, BD: TextDimension + AddAssign<::Output>, { + #[instrument(skip_all)] fn seek(&mut self, position: &MBD) { let position = OutputDimension(*position); self.cached_region.take(); diff --git a/crates/multi_buffer/src/path_key.rs b/crates/multi_buffer/src/path_key.rs index 1685e7a27329b1beea5f0d2c9563acfab07d8d8b..82bb902c230180d98c54225e8b57bf85beeedc2d 100644 --- a/crates/multi_buffer/src/path_key.rs +++ b/crates/multi_buffer/src/path_key.rs @@ -1,435 +1,437 @@ -use std::{mem, ops::Range, sync::Arc}; - -use collections::HashSet; -use gpui::{App, AppContext, Context, Entity}; -use itertools::Itertools; -use language::{Buffer, BufferSnapshot}; -use rope::Point; -use text::{Bias, BufferId, OffsetRangeExt, locator::Locator}; -use util::{post_inc, rel_path::RelPath}; - -use crate::{ - Anchor, ExcerptId, ExcerptRange, ExpandExcerptDirection, MultiBuffer, build_excerpt_ranges, -}; - -#[derive(PartialEq, Eq, Ord, PartialOrd, Clone, Hash, Debug)] -pub struct PathKey { - // Used by the derived PartialOrd & Ord - pub sort_prefix: Option, - pub path: Arc, -} - -impl PathKey { - pub fn with_sort_prefix(sort_prefix: u64, path: Arc) -> Self { - Self { - sort_prefix: Some(sort_prefix), - path, - } - } - - pub fn for_buffer(buffer: &Entity, cx: &App) -> Self { - if let Some(file) = buffer.read(cx).file() { - Self::with_sort_prefix(file.worktree_id(cx).to_proto(), file.path().clone()) - } else { - Self { - sort_prefix: None, - path: RelPath::unix(&buffer.entity_id().to_string()) - .unwrap() - .into_arc(), - } - } - } -} - -impl MultiBuffer { - pub fn paths(&self) -> impl Iterator + '_ { - self.excerpts_by_path.keys().cloned() - } - - pub fn remove_excerpts_for_path(&mut self, path: PathKey, cx: &mut Context) { - if let Some(to_remove) = self.excerpts_by_path.remove(&path) { - self.remove_excerpts(to_remove, cx) - } - if let Some(follower) = &self.follower { - follower.update(cx, |follower, cx| { - follower.remove_excerpts_for_path(path, cx); - }); - } - } - - pub fn location_for_path(&self, path: &PathKey, cx: &App) -> Option { - let excerpt_id = self.excerpts_by_path.get(path)?.first()?; - let snapshot = self.read(cx); - let excerpt = snapshot.excerpt(*excerpt_id)?; - Some(Anchor::in_buffer(excerpt.id, excerpt.range.context.start)) - } - - pub fn excerpt_paths(&self) -> impl Iterator { - self.excerpts_by_path.keys() - } - - /// Sets excerpts, returns `true` if at least one new excerpt was added. - pub fn set_excerpts_for_path( - &mut self, - path: PathKey, - buffer: Entity, - ranges: impl IntoIterator>, - context_line_count: u32, - cx: &mut Context, - ) -> (Vec>, bool) { - let buffer_snapshot = buffer.read(cx).snapshot(); - let excerpt_ranges = build_excerpt_ranges(ranges, context_line_count, &buffer_snapshot); - - let (new, counts) = Self::merge_excerpt_ranges(&excerpt_ranges); - self.set_merged_excerpt_ranges_for_path( - path, - buffer, - excerpt_ranges, - &buffer_snapshot, - new, - counts, - cx, - ) - } - - pub fn set_excerpt_ranges_for_path( - &mut self, - path: PathKey, - buffer: Entity, - buffer_snapshot: &BufferSnapshot, - excerpt_ranges: Vec>, - cx: &mut Context, - ) -> (Vec>, bool) { - let (new, counts) = Self::merge_excerpt_ranges(&excerpt_ranges); - self.set_merged_excerpt_ranges_for_path( - path, - buffer, - excerpt_ranges, - buffer_snapshot, - new, - counts, - cx, - ) - } - - pub fn set_anchored_excerpts_for_path( - &self, - path_key: PathKey, - buffer: Entity, - ranges: Vec>, - context_line_count: u32, - cx: &Context, - ) -> impl Future>> + use<> { - let buffer_snapshot = buffer.read(cx).snapshot(); - let multi_buffer = cx.weak_entity(); - let mut app = cx.to_async(); - async move { - let snapshot = buffer_snapshot.clone(); - let (excerpt_ranges, new, counts) = app - .background_spawn(async move { - let ranges = ranges.into_iter().map(|range| range.to_point(&snapshot)); - let excerpt_ranges = - build_excerpt_ranges(ranges, context_line_count, &snapshot); - let (new, counts) = Self::merge_excerpt_ranges(&excerpt_ranges); - (excerpt_ranges, new, counts) - }) - .await; - - multi_buffer - .update(&mut app, move |multi_buffer, cx| { - let (ranges, _) = multi_buffer.set_merged_excerpt_ranges_for_path( - path_key, - buffer, - excerpt_ranges, - &buffer_snapshot, - new, - counts, - cx, - ); - ranges - }) - .ok() - .unwrap_or_default() - } - } - - pub fn remove_excerpts_for_buffer(&mut self, buffer: BufferId, cx: &mut Context) { - self.remove_excerpts( - self.excerpts_for_buffer(buffer, cx) - .into_iter() - .map(|(excerpt, _)| excerpt), - cx, - ); - } - - pub(super) fn expand_excerpts_with_paths( - &mut self, - ids: impl IntoIterator, - line_count: u32, - direction: ExpandExcerptDirection, - cx: &mut Context, - ) { - let grouped = ids - .into_iter() - .chunk_by(|id| self.paths_by_excerpt.get(id).cloned()) - .into_iter() - .filter_map(|(k, v)| Some((k?, v.into_iter().collect::>()))) - .collect::>(); - let snapshot = self.snapshot(cx); - - for (path, ids) in grouped.into_iter() { - let Some(excerpt_ids) = self.excerpts_by_path.get(&path) else { - continue; - }; - - let ids_to_expand = HashSet::from_iter(ids); - let mut excerpt_id_ = None; - let expanded_ranges = excerpt_ids.iter().filter_map(|excerpt_id| { - let excerpt = snapshot.excerpt(*excerpt_id)?; - let excerpt_id = excerpt.id; - if excerpt_id_.is_none() { - excerpt_id_ = Some(excerpt_id); - } - - let mut context = excerpt.range.context.to_point(&excerpt.buffer); - if ids_to_expand.contains(&excerpt_id) { - match direction { - ExpandExcerptDirection::Up => { - context.start.row = context.start.row.saturating_sub(line_count); - context.start.column = 0; - } - ExpandExcerptDirection::Down => { - context.end.row = - (context.end.row + line_count).min(excerpt.buffer.max_point().row); - context.end.column = excerpt.buffer.line_len(context.end.row); - } - ExpandExcerptDirection::UpAndDown => { - context.start.row = context.start.row.saturating_sub(line_count); - context.start.column = 0; - context.end.row = - (context.end.row + line_count).min(excerpt.buffer.max_point().row); - context.end.column = excerpt.buffer.line_len(context.end.row); - } - } - } - - Some(ExcerptRange { - context, - primary: excerpt.range.primary.to_point(&excerpt.buffer), - }) - }); - let mut merged_ranges: Vec> = Vec::new(); - for range in expanded_ranges { - if let Some(last_range) = merged_ranges.last_mut() - && last_range.context.end >= range.context.start - { - last_range.context.end = range.context.end; - continue; - } - merged_ranges.push(range) - } - let Some(excerpt_id) = excerpt_id_ else { - continue; - }; - let Some(buffer_id) = &snapshot.buffer_id_for_excerpt(excerpt_id) else { - continue; - }; - - let Some(buffer) = self.buffers.get(buffer_id).map(|b| b.buffer.clone()) else { - continue; - }; - - let buffer_snapshot = buffer.read(cx).snapshot(); - self.update_path_excerpts(path.clone(), buffer, &buffer_snapshot, merged_ranges, cx); - } - } - - /// Sets excerpts, returns `true` if at least one new excerpt was added. - fn set_merged_excerpt_ranges_for_path( - &mut self, - path: PathKey, - buffer: Entity, - ranges: Vec>, - buffer_snapshot: &BufferSnapshot, - new: Vec>, - counts: Vec, - cx: &mut Context, - ) -> (Vec>, bool) { - let (excerpt_ids, added_a_new_excerpt) = - self.update_path_excerpts(path, buffer, buffer_snapshot, new, cx); - - let mut result = Vec::new(); - let mut ranges = ranges.into_iter(); - for (excerpt_id, range_count) in excerpt_ids.into_iter().zip(counts.into_iter()) { - for range in ranges.by_ref().take(range_count) { - let range = Anchor::range_in_buffer( - excerpt_id, - buffer_snapshot.anchor_before(&range.primary.start) - ..buffer_snapshot.anchor_after(&range.primary.end), - ); - result.push(range) - } - } - (result, added_a_new_excerpt) - } - - fn update_path_excerpts( - &mut self, - path: PathKey, - buffer: Entity, - buffer_snapshot: &BufferSnapshot, - new: Vec>, - cx: &mut Context, - ) -> (Vec, bool) { - let mut insert_after = self - .excerpts_by_path - .range(..path.clone()) - .next_back() - .and_then(|(_, value)| value.last().copied()) - .unwrap_or(ExcerptId::min()); - - let existing = self - .excerpts_by_path - .get(&path) - .cloned() - .unwrap_or_default(); - let mut new_iter = new.into_iter().peekable(); - let mut existing_iter = existing.into_iter().peekable(); - - let mut excerpt_ids = Vec::new(); - let mut to_remove = Vec::new(); - let mut to_insert: Vec<(ExcerptId, ExcerptRange)> = Vec::new(); - let mut added_a_new_excerpt = false; - let snapshot = self.snapshot(cx); - - let mut next_excerpt_id = - // is this right? What if we remove the last excerpt, then we might reallocate with a wrong mapping? - if let Some(last_entry) = self.snapshot.borrow().excerpt_ids.last() { - last_entry.id.0 + 1 - } else { - 1 - }; - - let mut next_excerpt_id = move || ExcerptId(post_inc(&mut next_excerpt_id)); - - let mut excerpts_cursor = snapshot.excerpts.cursor::>(()); - excerpts_cursor.next(); - - loop { - let existing = if let Some(&existing_id) = existing_iter.peek() { - let locator = snapshot.excerpt_locator_for_id(existing_id); - excerpts_cursor.seek_forward(&Some(locator), Bias::Left); - if let Some(excerpt) = excerpts_cursor.item() { - if excerpt.buffer_id != buffer_snapshot.remote_id() { - to_remove.push(existing_id); - existing_iter.next(); - continue; - } - Some((existing_id, excerpt.range.context.to_point(buffer_snapshot))) - } else { - None - } - } else { - None - }; - - let new = new_iter.peek(); - if let Some((last_id, last)) = to_insert.last_mut() { - if let Some(new) = new - && last.context.end >= new.context.start - { - last.context.end = last.context.end.max(new.context.end); - excerpt_ids.push(*last_id); - new_iter.next(); - continue; - } - if let Some((existing_id, existing_range)) = &existing - && last.context.end >= existing_range.start - { - last.context.end = last.context.end.max(existing_range.end); - to_remove.push(*existing_id); - self.snapshot - .get_mut() - .replaced_excerpts - .insert(*existing_id, *last_id); - existing_iter.next(); - continue; - } - } - - match (new, existing) { - (None, None) => break, - (None, Some((existing_id, _))) => { - existing_iter.next(); - to_remove.push(existing_id); - continue; - } - (Some(_), None) => { - added_a_new_excerpt = true; - let new_id = next_excerpt_id(); - excerpt_ids.push(new_id); - to_insert.push((new_id, new_iter.next().unwrap())); - continue; - } - (Some(new), Some((_, existing_range))) => { - if existing_range.end < new.context.start { - let existing_id = existing_iter.next().unwrap(); - to_remove.push(existing_id); - continue; - } else if existing_range.start > new.context.end { - let new_id = next_excerpt_id(); - excerpt_ids.push(new_id); - to_insert.push((new_id, new_iter.next().unwrap())); - continue; - } - - if existing_range.start == new.context.start - && existing_range.end == new.context.end - { - self.insert_excerpts_with_ids_after( - insert_after, - buffer.clone(), - mem::take(&mut to_insert), - cx, - ); - insert_after = existing_iter.next().unwrap(); - excerpt_ids.push(insert_after); - new_iter.next(); - } else { - let existing_id = existing_iter.next().unwrap(); - let new_id = next_excerpt_id(); - self.snapshot - .get_mut() - .replaced_excerpts - .insert(existing_id, new_id); - to_remove.push(existing_id); - let mut range = new_iter.next().unwrap(); - range.context.start = range.context.start.min(existing_range.start); - range.context.end = range.context.end.max(existing_range.end); - excerpt_ids.push(new_id); - to_insert.push((new_id, range)); - } - } - }; - } - - self.insert_excerpts_with_ids_after(insert_after, buffer, to_insert, cx); - // todo(lw): There is a logic bug somewhere that causes the to_remove vector to be not ordered correctly - to_remove.sort_by_cached_key(|&id| snapshot.excerpt_locator_for_id(id)); - self.remove_excerpts(to_remove, cx); - - if excerpt_ids.is_empty() { - self.excerpts_by_path.remove(&path); - } else { - for excerpt_id in &excerpt_ids { - self.paths_by_excerpt.insert(*excerpt_id, path.clone()); - } - let snapshot = &*self.snapshot.get_mut(); - let mut excerpt_ids: Vec<_> = excerpt_ids.iter().dedup().cloned().collect(); - excerpt_ids.sort_by_cached_key(|&id| snapshot.excerpt_locator_for_id(id)); - self.excerpts_by_path.insert(path, excerpt_ids); - } - - (excerpt_ids, added_a_new_excerpt) - } -} +use std::{mem, ops::Range, sync::Arc}; + +use collections::HashSet; +use gpui::{App, AppContext, Context, Entity}; +use itertools::Itertools; +use language::{Buffer, BufferSnapshot}; +use rope::Point; +use text::{Bias, BufferId, OffsetRangeExt, locator::Locator}; +use util::{post_inc, rel_path::RelPath}; +use ztracing::instrument; + +use crate::{ + Anchor, ExcerptId, ExcerptRange, ExpandExcerptDirection, MultiBuffer, build_excerpt_ranges, +}; + +#[derive(PartialEq, Eq, Ord, PartialOrd, Clone, Hash, Debug)] +pub struct PathKey { + // Used by the derived PartialOrd & Ord + pub sort_prefix: Option, + pub path: Arc, +} + +impl PathKey { + pub fn with_sort_prefix(sort_prefix: u64, path: Arc) -> Self { + Self { + sort_prefix: Some(sort_prefix), + path, + } + } + + pub fn for_buffer(buffer: &Entity, cx: &App) -> Self { + if let Some(file) = buffer.read(cx).file() { + Self::with_sort_prefix(file.worktree_id(cx).to_proto(), file.path().clone()) + } else { + Self { + sort_prefix: None, + path: RelPath::unix(&buffer.entity_id().to_string()) + .unwrap() + .into_arc(), + } + } + } +} + +impl MultiBuffer { + pub fn paths(&self) -> impl Iterator + '_ { + self.excerpts_by_path.keys().cloned() + } + + pub fn remove_excerpts_for_path(&mut self, path: PathKey, cx: &mut Context) { + if let Some(to_remove) = self.excerpts_by_path.remove(&path) { + self.remove_excerpts(to_remove, cx) + } + if let Some(follower) = &self.follower { + follower.update(cx, |follower, cx| { + follower.remove_excerpts_for_path(path, cx); + }); + } + } + + pub fn location_for_path(&self, path: &PathKey, cx: &App) -> Option { + let excerpt_id = self.excerpts_by_path.get(path)?.first()?; + let snapshot = self.read(cx); + let excerpt = snapshot.excerpt(*excerpt_id)?; + Some(Anchor::in_buffer(excerpt.id, excerpt.range.context.start)) + } + + pub fn excerpt_paths(&self) -> impl Iterator { + self.excerpts_by_path.keys() + } + + /// Sets excerpts, returns `true` if at least one new excerpt was added. + #[instrument(skip_all)] + pub fn set_excerpts_for_path( + &mut self, + path: PathKey, + buffer: Entity, + ranges: impl IntoIterator>, + context_line_count: u32, + cx: &mut Context, + ) -> (Vec>, bool) { + let buffer_snapshot = buffer.read(cx).snapshot(); + let excerpt_ranges = build_excerpt_ranges(ranges, context_line_count, &buffer_snapshot); + + let (new, counts) = Self::merge_excerpt_ranges(&excerpt_ranges); + self.set_merged_excerpt_ranges_for_path( + path, + buffer, + excerpt_ranges, + &buffer_snapshot, + new, + counts, + cx, + ) + } + + pub fn set_excerpt_ranges_for_path( + &mut self, + path: PathKey, + buffer: Entity, + buffer_snapshot: &BufferSnapshot, + excerpt_ranges: Vec>, + cx: &mut Context, + ) -> (Vec>, bool) { + let (new, counts) = Self::merge_excerpt_ranges(&excerpt_ranges); + self.set_merged_excerpt_ranges_for_path( + path, + buffer, + excerpt_ranges, + buffer_snapshot, + new, + counts, + cx, + ) + } + + pub fn set_anchored_excerpts_for_path( + &self, + path_key: PathKey, + buffer: Entity, + ranges: Vec>, + context_line_count: u32, + cx: &Context, + ) -> impl Future>> + use<> { + let buffer_snapshot = buffer.read(cx).snapshot(); + let multi_buffer = cx.weak_entity(); + let mut app = cx.to_async(); + async move { + let snapshot = buffer_snapshot.clone(); + let (excerpt_ranges, new, counts) = app + .background_spawn(async move { + let ranges = ranges.into_iter().map(|range| range.to_point(&snapshot)); + let excerpt_ranges = + build_excerpt_ranges(ranges, context_line_count, &snapshot); + let (new, counts) = Self::merge_excerpt_ranges(&excerpt_ranges); + (excerpt_ranges, new, counts) + }) + .await; + + multi_buffer + .update(&mut app, move |multi_buffer, cx| { + let (ranges, _) = multi_buffer.set_merged_excerpt_ranges_for_path( + path_key, + buffer, + excerpt_ranges, + &buffer_snapshot, + new, + counts, + cx, + ); + ranges + }) + .ok() + .unwrap_or_default() + } + } + + pub fn remove_excerpts_for_buffer(&mut self, buffer: BufferId, cx: &mut Context) { + self.remove_excerpts( + self.excerpts_for_buffer(buffer, cx) + .into_iter() + .map(|(excerpt, _)| excerpt), + cx, + ); + } + + pub(super) fn expand_excerpts_with_paths( + &mut self, + ids: impl IntoIterator, + line_count: u32, + direction: ExpandExcerptDirection, + cx: &mut Context, + ) { + let grouped = ids + .into_iter() + .chunk_by(|id| self.paths_by_excerpt.get(id).cloned()) + .into_iter() + .filter_map(|(k, v)| Some((k?, v.into_iter().collect::>()))) + .collect::>(); + let snapshot = self.snapshot(cx); + + for (path, ids) in grouped.into_iter() { + let Some(excerpt_ids) = self.excerpts_by_path.get(&path) else { + continue; + }; + + let ids_to_expand = HashSet::from_iter(ids); + let mut excerpt_id_ = None; + let expanded_ranges = excerpt_ids.iter().filter_map(|excerpt_id| { + let excerpt = snapshot.excerpt(*excerpt_id)?; + let excerpt_id = excerpt.id; + if excerpt_id_.is_none() { + excerpt_id_ = Some(excerpt_id); + } + + let mut context = excerpt.range.context.to_point(&excerpt.buffer); + if ids_to_expand.contains(&excerpt_id) { + match direction { + ExpandExcerptDirection::Up => { + context.start.row = context.start.row.saturating_sub(line_count); + context.start.column = 0; + } + ExpandExcerptDirection::Down => { + context.end.row = + (context.end.row + line_count).min(excerpt.buffer.max_point().row); + context.end.column = excerpt.buffer.line_len(context.end.row); + } + ExpandExcerptDirection::UpAndDown => { + context.start.row = context.start.row.saturating_sub(line_count); + context.start.column = 0; + context.end.row = + (context.end.row + line_count).min(excerpt.buffer.max_point().row); + context.end.column = excerpt.buffer.line_len(context.end.row); + } + } + } + + Some(ExcerptRange { + context, + primary: excerpt.range.primary.to_point(&excerpt.buffer), + }) + }); + let mut merged_ranges: Vec> = Vec::new(); + for range in expanded_ranges { + if let Some(last_range) = merged_ranges.last_mut() + && last_range.context.end >= range.context.start + { + last_range.context.end = range.context.end; + continue; + } + merged_ranges.push(range) + } + let Some(excerpt_id) = excerpt_id_ else { + continue; + }; + let Some(buffer_id) = &snapshot.buffer_id_for_excerpt(excerpt_id) else { + continue; + }; + + let Some(buffer) = self.buffers.get(buffer_id).map(|b| b.buffer.clone()) else { + continue; + }; + + let buffer_snapshot = buffer.read(cx).snapshot(); + self.update_path_excerpts(path.clone(), buffer, &buffer_snapshot, merged_ranges, cx); + } + } + + /// Sets excerpts, returns `true` if at least one new excerpt was added. + fn set_merged_excerpt_ranges_for_path( + &mut self, + path: PathKey, + buffer: Entity, + ranges: Vec>, + buffer_snapshot: &BufferSnapshot, + new: Vec>, + counts: Vec, + cx: &mut Context, + ) -> (Vec>, bool) { + let (excerpt_ids, added_a_new_excerpt) = + self.update_path_excerpts(path, buffer, buffer_snapshot, new, cx); + + let mut result = Vec::new(); + let mut ranges = ranges.into_iter(); + for (excerpt_id, range_count) in excerpt_ids.into_iter().zip(counts.into_iter()) { + for range in ranges.by_ref().take(range_count) { + let range = Anchor::range_in_buffer( + excerpt_id, + buffer_snapshot.anchor_before(&range.primary.start) + ..buffer_snapshot.anchor_after(&range.primary.end), + ); + result.push(range) + } + } + (result, added_a_new_excerpt) + } + + fn update_path_excerpts( + &mut self, + path: PathKey, + buffer: Entity, + buffer_snapshot: &BufferSnapshot, + new: Vec>, + cx: &mut Context, + ) -> (Vec, bool) { + let mut insert_after = self + .excerpts_by_path + .range(..path.clone()) + .next_back() + .and_then(|(_, value)| value.last().copied()) + .unwrap_or(ExcerptId::min()); + + let existing = self + .excerpts_by_path + .get(&path) + .cloned() + .unwrap_or_default(); + let mut new_iter = new.into_iter().peekable(); + let mut existing_iter = existing.into_iter().peekable(); + + let mut excerpt_ids = Vec::new(); + let mut to_remove = Vec::new(); + let mut to_insert: Vec<(ExcerptId, ExcerptRange)> = Vec::new(); + let mut added_a_new_excerpt = false; + let snapshot = self.snapshot(cx); + + let mut next_excerpt_id = + // is this right? What if we remove the last excerpt, then we might reallocate with a wrong mapping? + if let Some(last_entry) = self.snapshot.borrow().excerpt_ids.last() { + last_entry.id.0 + 1 + } else { + 1 + }; + + let mut next_excerpt_id = move || ExcerptId(post_inc(&mut next_excerpt_id)); + + let mut excerpts_cursor = snapshot.excerpts.cursor::>(()); + excerpts_cursor.next(); + + loop { + let existing = if let Some(&existing_id) = existing_iter.peek() { + let locator = snapshot.excerpt_locator_for_id(existing_id); + excerpts_cursor.seek_forward(&Some(locator), Bias::Left); + if let Some(excerpt) = excerpts_cursor.item() { + if excerpt.buffer_id != buffer_snapshot.remote_id() { + to_remove.push(existing_id); + existing_iter.next(); + continue; + } + Some((existing_id, excerpt.range.context.to_point(buffer_snapshot))) + } else { + None + } + } else { + None + }; + + let new = new_iter.peek(); + if let Some((last_id, last)) = to_insert.last_mut() { + if let Some(new) = new + && last.context.end >= new.context.start + { + last.context.end = last.context.end.max(new.context.end); + excerpt_ids.push(*last_id); + new_iter.next(); + continue; + } + if let Some((existing_id, existing_range)) = &existing + && last.context.end >= existing_range.start + { + last.context.end = last.context.end.max(existing_range.end); + to_remove.push(*existing_id); + self.snapshot + .get_mut() + .replaced_excerpts + .insert(*existing_id, *last_id); + existing_iter.next(); + continue; + } + } + + match (new, existing) { + (None, None) => break, + (None, Some((existing_id, _))) => { + existing_iter.next(); + to_remove.push(existing_id); + continue; + } + (Some(_), None) => { + added_a_new_excerpt = true; + let new_id = next_excerpt_id(); + excerpt_ids.push(new_id); + to_insert.push((new_id, new_iter.next().unwrap())); + continue; + } + (Some(new), Some((_, existing_range))) => { + if existing_range.end < new.context.start { + let existing_id = existing_iter.next().unwrap(); + to_remove.push(existing_id); + continue; + } else if existing_range.start > new.context.end { + let new_id = next_excerpt_id(); + excerpt_ids.push(new_id); + to_insert.push((new_id, new_iter.next().unwrap())); + continue; + } + + if existing_range.start == new.context.start + && existing_range.end == new.context.end + { + self.insert_excerpts_with_ids_after( + insert_after, + buffer.clone(), + mem::take(&mut to_insert), + cx, + ); + insert_after = existing_iter.next().unwrap(); + excerpt_ids.push(insert_after); + new_iter.next(); + } else { + let existing_id = existing_iter.next().unwrap(); + let new_id = next_excerpt_id(); + self.snapshot + .get_mut() + .replaced_excerpts + .insert(existing_id, new_id); + to_remove.push(existing_id); + let mut range = new_iter.next().unwrap(); + range.context.start = range.context.start.min(existing_range.start); + range.context.end = range.context.end.max(existing_range.end); + excerpt_ids.push(new_id); + to_insert.push((new_id, range)); + } + } + }; + } + + self.insert_excerpts_with_ids_after(insert_after, buffer, to_insert, cx); + // todo(lw): There is a logic bug somewhere that causes the to_remove vector to be not ordered correctly + to_remove.sort_by_cached_key(|&id| snapshot.excerpt_locator_for_id(id)); + self.remove_excerpts(to_remove, cx); + + if excerpt_ids.is_empty() { + self.excerpts_by_path.remove(&path); + } else { + for excerpt_id in &excerpt_ids { + self.paths_by_excerpt.insert(*excerpt_id, path.clone()); + } + let snapshot = &*self.snapshot.get_mut(); + let mut excerpt_ids: Vec<_> = excerpt_ids.iter().dedup().cloned().collect(); + excerpt_ids.sort_by_cached_key(|&id| snapshot.excerpt_locator_for_id(id)); + self.excerpts_by_path.insert(path, excerpt_ids); + } + + (excerpt_ids, added_a_new_excerpt) + } +} diff --git a/crates/project/Cargo.toml b/crates/project/Cargo.toml index a33efb9896959cc12fd828986c881f73e84e0ec7..9e2789fc109b8217f0f1033cc6d4832105c0ad48 100644 --- a/crates/project/Cargo.toml +++ b/crates/project/Cargo.toml @@ -91,6 +91,8 @@ which.workspace = true worktree.workspace = true zeroize.workspace = true zlog.workspace = true +ztracing.workspace = true +tracing.workspace = true [dev-dependencies] client = { workspace = true, features = ["test-support"] } @@ -113,3 +115,6 @@ snippet_provider = { workspace = true, features = ["test-support"] } unindent.workspace = true util = { workspace = true, features = ["test-support"] } worktree = { workspace = true, features = ["test-support"] } + +[package.metadata.cargo-machete] +ignored = ["tracing"] diff --git a/crates/project/src/git_store/branch_diff.rs b/crates/project/src/git_store/branch_diff.rs index 5065eafe4e185e65ce144f6d797ac8ccd616d5fa..dd0026961ec7ad77b674e2e9506b3133f07ce3f2 100644 --- a/crates/project/src/git_store/branch_diff.rs +++ b/crates/project/src/git_store/branch_diff.rs @@ -14,6 +14,7 @@ use gpui::{ use language::Buffer; use text::BufferId; use util::ResultExt; +use ztracing::instrument; use crate::{ Project, @@ -254,6 +255,7 @@ impl BranchDiff { self.repo.as_ref() } + #[instrument(skip_all)] pub fn load_buffers(&mut self, cx: &mut Context) -> Vec { let mut output = Vec::default(); let Some(repo) = self.repo.clone() else { @@ -318,6 +320,7 @@ impl BranchDiff { output } + #[instrument(skip_all)] fn load_buffer( branch_diff: Option, project_path: crate::ProjectPath, diff --git a/crates/rope/Cargo.toml b/crates/rope/Cargo.toml index 4107c2e012debc13b0cc44003250f4da63e5039f..9f0fc2be8a021a4cd43679beefb18a3567452dde 100644 --- a/crates/rope/Cargo.toml +++ b/crates/rope/Cargo.toml @@ -18,6 +18,8 @@ rayon.workspace = true sum_tree.workspace = true unicode-segmentation.workspace = true util.workspace = true +ztracing.workspace = true +tracing.workspace = true [dev-dependencies] ctor.workspace = true @@ -30,3 +32,6 @@ zlog.workspace = true [[bench]] name = "rope_benchmark" harness = false + +[package.metadata.cargo-machete] +ignored = ["tracing"] diff --git a/crates/rope/src/rope.rs b/crates/rope/src/rope.rs index 2d3c811e179fbd47cada7c2bebb89b03acd3eeb0..50f9ba044d90072aa9c6fc2fc4abfd6d0e6b98cb 100644 --- a/crates/rope/src/rope.rs +++ b/crates/rope/src/rope.rs @@ -12,6 +12,7 @@ use std::{ str, }; use sum_tree::{Bias, Dimension, Dimensions, SumTree}; +use ztracing::instrument; pub use chunk::{Chunk, ChunkSlice}; pub use offset_utf16::OffsetUtf16; @@ -428,6 +429,7 @@ impl Rope { }) } + #[instrument(skip_all)] pub fn point_to_offset(&self, point: Point) -> usize { if point >= self.summary().lines { return self.summary().len; diff --git a/crates/sum_tree/Cargo.toml b/crates/sum_tree/Cargo.toml index 81916c842225085ceec4721dbd8d212608f6bcb9..3e06ede162dad37f94017207ccbd6ee5c38f26a5 100644 --- a/crates/sum_tree/Cargo.toml +++ b/crates/sum_tree/Cargo.toml @@ -17,8 +17,13 @@ doctest = false arrayvec = "0.7.1" rayon.workspace = true log.workspace = true +ztracing.workspace = true +tracing.workspace = true [dev-dependencies] ctor.workspace = true rand.workspace = true zlog.workspace = true + +[package.metadata.cargo-machete] +ignored = ["tracing"] diff --git a/crates/sum_tree/src/cursor.rs b/crates/sum_tree/src/cursor.rs index 0ca89d16db9f8b4dae6e8283c673f781dbdd27dc..589ae96a2aa3293490aa91674dd3e0cac127e3cc 100644 --- a/crates/sum_tree/src/cursor.rs +++ b/crates/sum_tree/src/cursor.rs @@ -1,6 +1,7 @@ use super::*; use arrayvec::ArrayVec; use std::{cmp::Ordering, mem, sync::Arc}; +use ztracing::instrument; #[derive(Clone)] struct StackEntry<'a, T: Item, D> { @@ -211,6 +212,7 @@ where } #[track_caller] + #[instrument(skip_all)] pub fn prev(&mut self) { self.search_backward(|_| true) } @@ -394,6 +396,7 @@ where { /// Returns whether we found the item you were seeking for. #[track_caller] + #[instrument(skip_all)] pub fn seek(&mut self, pos: &Target, bias: Bias) -> bool where Target: SeekTarget<'a, T::Summary, D>, @@ -408,6 +411,7 @@ where /// /// If we did not seek before, use seek instead in that case. #[track_caller] + #[instrument(skip_all)] pub fn seek_forward(&mut self, pos: &Target, bias: Bias) -> bool where Target: SeekTarget<'a, T::Summary, D>, @@ -449,6 +453,7 @@ where /// Returns whether we found the item you were seeking for. #[track_caller] + #[instrument(skip_all)] fn seek_internal( &mut self, target: &dyn SeekTarget<'a, T::Summary, D>, diff --git a/crates/sum_tree/src/sum_tree.rs b/crates/sum_tree/src/sum_tree.rs index da700201f558a0b29ed4dc45bd3d3d3e7474a297..bfc4587969ec67bbda2fb90d34550c7d464317c9 100644 --- a/crates/sum_tree/src/sum_tree.rs +++ b/crates/sum_tree/src/sum_tree.rs @@ -8,6 +8,7 @@ use std::marker::PhantomData; use std::mem; use std::{cmp::Ordering, fmt, iter::FromIterator, sync::Arc}; pub use tree_map::{MapSeekTarget, TreeMap, TreeSet}; +use ztracing::instrument; #[cfg(test)] pub const TREE_BASE: usize = 2; @@ -379,6 +380,7 @@ impl SumTree { /// A more efficient version of `Cursor::new()` + `Cursor::seek()` + `Cursor::item()`. /// /// Only returns the item that exactly has the target match. + #[instrument(skip_all)] pub fn find_exact<'a, 'slf, D, Target>( &'slf self, cx: ::Context<'a>, @@ -404,6 +406,7 @@ impl SumTree { } /// A more efficient version of `Cursor::new()` + `Cursor::seek()` + `Cursor::item()` + #[instrument(skip_all)] pub fn find<'a, 'slf, D, Target>( &'slf self, cx: ::Context<'a>, diff --git a/crates/zed/Cargo.toml b/crates/zed/Cargo.toml index 6ee7d0a4ea75ff5e13a4db6f5fe73c2a5ba80193..e304ad7f5cd94c05daab2755cb9e7bed21fe0f8d 100644 --- a/crates/zed/Cargo.toml +++ b/crates/zed/Cargo.toml @@ -144,6 +144,8 @@ theme_extension.workspace = true theme_selector.workspace = true time.workspace = true title_bar.workspace = true +ztracing.workspace = true +tracing.workspace = true toolchain_selector.workspace = true ui.workspace = true ui_input.workspace = true @@ -223,4 +225,4 @@ osx_info_plist_exts = ["resources/info/*"] osx_url_schemes = ["zed"] [package.metadata.cargo-machete] -ignored = ["profiling", "zstd"] +ignored = ["profiling", "zstd", "tracing"] diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rs index 10f599e876032bf297d3eaf173093a308d666cc9..7751e6cb0118e3590488600ca2601645d6657fb7 100644 --- a/crates/zed/src/main.rs +++ b/crates/zed/src/main.rs @@ -162,10 +162,11 @@ fn fail_to_open_window(e: anyhow::Error, _cx: &mut App) { .detach(); } } - pub static STARTUP_TIME: OnceLock = OnceLock::new(); pub fn main() { + ztracing::init(); + STARTUP_TIME.get_or_init(|| Instant::now()); #[cfg(unix)] diff --git a/crates/ztracing/Cargo.toml b/crates/ztracing/Cargo.toml new file mode 100644 index 0000000000000000000000000000000000000000..fbc9dc032d2d485f74a15e5fe3b073a7017911fd --- /dev/null +++ b/crates/ztracing/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "ztracing" +version = "0.1.0" +edition.workspace = true +publish.workspace = true +license = "GPL-3.0-or-later" + +[lints] +workspace = true + +[dependencies] +tracing.workspace = true + +tracing-subscriber = "0.3.22" +tracing-tracy = { workspace = true, features = ["enable", "ondemand"] } + +ztracing_macro.workspace = true diff --git a/crates/ztracing/LICENSE-AGPL b/crates/ztracing/LICENSE-AGPL new file mode 120000 index 0000000000000000000000000000000000000000..5f5cf25dc458e75f4050c7378c186fca9b68fd19 --- /dev/null +++ b/crates/ztracing/LICENSE-AGPL @@ -0,0 +1 @@ +../../LICENSE-AGPL \ No newline at end of file diff --git a/crates/ztracing/LICENSE-APACHE b/crates/ztracing/LICENSE-APACHE new file mode 120000 index 0000000000000000000000000000000000000000..1cd601d0a3affae83854be02a0afdec3b7a9ec4d --- /dev/null +++ b/crates/ztracing/LICENSE-APACHE @@ -0,0 +1 @@ +../../LICENSE-APACHE \ No newline at end of file diff --git a/crates/ztracing/LICENSE-GPL b/crates/ztracing/LICENSE-GPL new file mode 120000 index 0000000000000000000000000000000000000000..89e542f750cd3860a0598eff0dc34b56d7336dc4 --- /dev/null +++ b/crates/ztracing/LICENSE-GPL @@ -0,0 +1 @@ +../../LICENSE-GPL \ No newline at end of file diff --git a/crates/ztracing/build.rs b/crates/ztracing/build.rs new file mode 100644 index 0000000000000000000000000000000000000000..dc0d0ad704d49c4c0ab639d769024330e10d2481 --- /dev/null +++ b/crates/ztracing/build.rs @@ -0,0 +1,9 @@ +use std::env; + +fn main() { + if env::var_os("ZTRACING").is_some() { + println!(r"cargo::rustc-cfg=ztracing"); + } + println!("cargo::rerun-if-changed=build.rs"); + println!("cargo::rerun-if-env-changed=ZTRACING"); +} diff --git a/crates/ztracing/src/lib.rs b/crates/ztracing/src/lib.rs new file mode 100644 index 0000000000000000000000000000000000000000..1ab687a2f4550e9b08432764dd7f80aedf5791c0 --- /dev/null +++ b/crates/ztracing/src/lib.rs @@ -0,0 +1,16 @@ +#[cfg(ztracing)] +pub use tracing::instrument; +#[cfg(not(ztracing))] +pub use ztracing_macro::instrument; + +#[cfg(ztracing)] +pub fn init() { + use tracing_subscriber::prelude::*; + tracing::subscriber::set_global_default( + tracing_subscriber::registry().with(tracing_tracy::TracyLayer::default()), + ) + .expect("setup tracy layer"); +} + +#[cfg(not(ztracing))] +pub fn init() {} diff --git a/crates/ztracing_macro/Cargo.toml b/crates/ztracing_macro/Cargo.toml new file mode 100644 index 0000000000000000000000000000000000000000..dbd7adce5fccd054c3dc87acaf1283e9e7c36889 --- /dev/null +++ b/crates/ztracing_macro/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "ztracing_macro" +version = "0.1.0" +edition.workspace = true +publish.workspace = true +license = "GPL-3.0-or-later" + +[lib] +proc-macro = true + +[dependencies] diff --git a/crates/ztracing_macro/LICENSE-AGPL b/crates/ztracing_macro/LICENSE-AGPL new file mode 120000 index 0000000000000000000000000000000000000000..5f5cf25dc458e75f4050c7378c186fca9b68fd19 --- /dev/null +++ b/crates/ztracing_macro/LICENSE-AGPL @@ -0,0 +1 @@ +../../LICENSE-AGPL \ No newline at end of file diff --git a/crates/ztracing_macro/LICENSE-APACHE b/crates/ztracing_macro/LICENSE-APACHE new file mode 120000 index 0000000000000000000000000000000000000000..1cd601d0a3affae83854be02a0afdec3b7a9ec4d --- /dev/null +++ b/crates/ztracing_macro/LICENSE-APACHE @@ -0,0 +1 @@ +../../LICENSE-APACHE \ No newline at end of file diff --git a/crates/ztracing_macro/LICENSE-GPL b/crates/ztracing_macro/LICENSE-GPL new file mode 120000 index 0000000000000000000000000000000000000000..89e542f750cd3860a0598eff0dc34b56d7336dc4 --- /dev/null +++ b/crates/ztracing_macro/LICENSE-GPL @@ -0,0 +1 @@ +../../LICENSE-GPL \ No newline at end of file diff --git a/crates/ztracing_macro/src/lib.rs b/crates/ztracing_macro/src/lib.rs new file mode 100644 index 0000000000000000000000000000000000000000..d9b073ed130bdc829e4d5d943b6d4b6a6d802888 --- /dev/null +++ b/crates/ztracing_macro/src/lib.rs @@ -0,0 +1,7 @@ +#[proc_macro_attribute] +pub fn instrument( + _attr: proc_macro::TokenStream, + item: proc_macro::TokenStream, +) -> proc_macro::TokenStream { + item +} diff --git a/docs/src/performance.md b/docs/src/performance.md index a04d7c5c342d4f0dfa506451d4b890bfdfd1013c..4adc38f5eea27de26f1d5818b6787fb78ae1d1ad 100644 --- a/docs/src/performance.md +++ b/docs/src/performance.md @@ -1,6 +1,6 @@ How to use our internal tools to profile and keep Zed fast. -# Flamechart/CPU profiling +# Rough quick CPU profiling (Flamechart) See what the CPU spends the most time on. Strongly recommend you use [samply](https://github.com/mstange/samply). It opens an interactive profile in @@ -12,6 +12,46 @@ The profile.json does not contain any symbols. Firefox profiler can add the loca image +# In depth CPU profiling (Tracing) + +See how long each annotated function call took and its arguments (if +configured). + +Annotate any function you need appear in the profile with instrument. For more +details see +[tracing-instrument](https://docs.rs/tracing/latest/tracing/attr.instrument.html): + +```rust +#[instrument(skip_all)] +fn should_appear_in_profile(kitty: Cat) { + sleep(QUITE_LONG) +} +``` + +Then either compile Zed with `ZTRACING=1 cargo r --release`. The release build is optional but highly recommended as like every program Zeds performance characteristics change dramatically with optimizations. You do not want to chase slowdowns that do not exist in release. + +## One time Setup/Building the profiler: + +Download the profiler: +[linux x86_64](https://zed-tracy-import-miniprofiler.nyc3.digitaloceanspaces.com/tracy-profiler-linux-x86_64) +[macos aarch64](https://zed-tracy-import-miniprofiler.nyc3.digitaloceanspaces.com/tracy-profiler-0.13.0-macos-aarch64) + +### Alternative: Building it yourself + +- Clone the repo at git@github.com:wolfpld/tracy.git +- `cd profiler && mkdir build && cd build` +- Run cmake to generate build files: `cmake -G Ninja -DCMAKE_BUILD_TYPE=Release ..` +- Build the profiler: `ninja` +- [Optional] move the profiler somewhere nice like ~/.local/bin on linux + +## Usage + +Open the profiler (tracy-profiler), you should see zed in the list of `Discovered clients` click it. +image + +To find functions that take a long time follow this image: +image + # Task/Async profiling Get a profile of the zed foreground executor and background executors. Check if @@ -23,11 +63,17 @@ look at the results live. ## Setup/Building the importer: +Download the importer +[linux x86_64](https://zed-tracy-import-miniprofiler.nyc3.digitaloceanspaces.com/tracy-import-miniprofiler-linux-x86_64) +[mac aarch64](https://zed-tracy-import-miniprofiler.nyc3.digitaloceanspaces.com/tracy-import-miniprofiler-macos-aarch64) + +### Alternative: Building it yourself + - Clone the repo at git@github.com:zed-industries/tracy.git on v0.12.2 branch -- `cd profiler && mkdir build && cd build` +- `cd import && mkdir build && cd build` - Run cmake to generate build files: `cmake -G Ninja -DCMAKE_BUILD_TYPE=Release ..` - Build the importer: `ninja` -- Run the impoter on the trace file: `./tracy-import-miniprofiler /path/to/trace.miniprof /path/to/output.tracy` +- Run the importer on the trace file: `./tracy-import-miniprofiler /path/to/trace.miniprof /path/to/output.tracy` - Open the trace in tracy: - If you're on windows download the v0.12.2 version from the releases on the upstream repo - If you're on other platforms open it on the website: https://tracy.nereid.pl/ (the version might mismatch so your luck might vary, we need to host our own ideally..) From d76dd86272361eebd96cf9495e4d9899e287ddad Mon Sep 17 00:00:00 2001 From: Dino Date: Fri, 5 Dec 2025 18:18:51 +0000 Subject: [PATCH 080/621] tab_switcher: Add documentation for tab switcher (#44189) Release Notes: - Added documentation for Tab Switcher --- assets/keymaps/default-linux.json | 2 +- assets/keymaps/default-macos.json | 2 +- assets/keymaps/default-windows.json | 2 +- docs/src/SUMMARY.md | 1 + docs/src/tab-switcher.md | 46 +++++++++++++++++++++++++++++ 5 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 docs/src/tab-switcher.md diff --git a/assets/keymaps/default-linux.json b/assets/keymaps/default-linux.json index 41415bf2047e1faadd86dd5be159f526d6c57678..54a4f331c0b0c59eca79065fe42c1a8ecbf646b7 100644 --- a/assets/keymaps/default-linux.json +++ b/assets/keymaps/default-linux.json @@ -616,8 +616,8 @@ "ctrl-alt-super-p": "settings_profile_selector::Toggle", "ctrl-t": "project_symbols::Toggle", "ctrl-p": "file_finder::Toggle", - "ctrl-tab": "tab_switcher::Toggle", "ctrl-shift-tab": ["tab_switcher::Toggle", { "select_last": true }], + "ctrl-tab": "tab_switcher::Toggle", "ctrl-e": "file_finder::Toggle", "f1": "command_palette::Toggle", "ctrl-shift-p": "command_palette::Toggle", diff --git a/assets/keymaps/default-macos.json b/assets/keymaps/default-macos.json index fa8edbe5c23b008eb2c267850e440a851c54087d..060151c647e42370f5aa0be5d2fa186774c2574d 100644 --- a/assets/keymaps/default-macos.json +++ b/assets/keymaps/default-macos.json @@ -684,8 +684,8 @@ "ctrl-alt-cmd-p": "settings_profile_selector::Toggle", "cmd-t": "project_symbols::Toggle", "cmd-p": "file_finder::Toggle", - "ctrl-tab": "tab_switcher::Toggle", "ctrl-shift-tab": ["tab_switcher::Toggle", { "select_last": true }], + "ctrl-tab": "tab_switcher::Toggle", "cmd-shift-p": "command_palette::Toggle", "cmd-shift-m": "diagnostics::Deploy", "cmd-shift-e": "project_panel::ToggleFocus", diff --git a/assets/keymaps/default-windows.json b/assets/keymaps/default-windows.json index 45f37fbd41af3fcc3108f0ffe150a80ff25332e1..32b52365e08e50266ad5feb7630a7b03f860c8e8 100644 --- a/assets/keymaps/default-windows.json +++ b/assets/keymaps/default-windows.json @@ -608,8 +608,8 @@ "ctrl-alt-super-p": "settings_profile_selector::Toggle", "ctrl-t": "project_symbols::Toggle", "ctrl-p": "file_finder::Toggle", - "ctrl-tab": "tab_switcher::Toggle", "ctrl-shift-tab": ["tab_switcher::Toggle", { "select_last": true }], + "ctrl-tab": "tab_switcher::Toggle", "ctrl-e": "file_finder::Toggle", "f1": "command_palette::Toggle", "ctrl-shift-p": "command_palette::Toggle", diff --git a/docs/src/SUMMARY.md b/docs/src/SUMMARY.md index 0d0cd35f43610d206749dea7a87af553620633f0..9d1f6f61d446b67256c00bf6322aed73af922c5e 100644 --- a/docs/src/SUMMARY.md +++ b/docs/src/SUMMARY.md @@ -41,6 +41,7 @@ - [Debugger](./debugger.md) - [Diagnostics](./diagnostics.md) - [Tasks](./tasks.md) +- [Tab Switcher](./tab-switcher.md) - [Remote Development](./remote-development.md) - [Environment Variables](./environment.md) - [REPL](./repl.md) diff --git a/docs/src/tab-switcher.md b/docs/src/tab-switcher.md new file mode 100644 index 0000000000000000000000000000000000000000..5cc72be449c94c38fbe4814893595289cb499b5a --- /dev/null +++ b/docs/src/tab-switcher.md @@ -0,0 +1,46 @@ +# Tab Switcher + +The Tab Switcher provides a quick way to navigate between open tabs in Zed. It +displays a list of your open tabs sorted by recent usage, making it easy to jump +back to whatever you were just working on. + +![Tab Switcher with multiple panes](https://zed.dev/img/features/tab-switcher.png) + +## Quick Switching + +When the Tab Switcher is opened using {#kb tab_switcher::Toggle}, instead of +running the {#action tab_switcher::Toggle} from the command palette, it'll stay +active as long as the ctrl key is held down. + +While holding down ctrl, each subsequent tab press cycles to the next item (shift to cycle backwards) and, when ctrl is released, the selected item is confirmed and +the switcher is closed. + +## Opening the Tab Switcher + +The Tab Switcher can also be opened with either {#action tab_switcher::Toggle} +or {#action tab_switcher::ToggleAll}. Using {#kb tab_switcher::Toggle} will show +only the tabs for the current pane, while {#kb tab_switcher::ToggleAll} shows +all tabs for all panes. + +While the Tab Switcher is open, you can: + +- Press {#kb menu::SelectNext} to move to the next tab in the list +- Press {#kb menu::SelectPrevious} to move to the previous tab +- Press enter to confirm the selected tab and close the switcher +- Press escape to close the switcher and return to the original tab from which + the switcher was opened +- Press {#kb tab_switcher::CloseSelectedItem} to close the currently selected tab + +As you navigate through the list, Zed will update the pane's active item to +match the selected tab. + +## Action Reference + +| Action | Description | +| ----------------------------------------- | ------------------------------------------------- | +| {#action tab_switcher::Toggle} | Open the Tab Switcher for the current pane | +| {#action tab_switcher::ToggleAll} | Open the Tab Switcher showing tabs from all panes | +| {#action tab_switcher::CloseSelectedItem} | Close the selected tab in the Tab Switcher | From 37b0cdf94ba931db41039a42a78993eb3e7b0bd0 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Fri, 5 Dec 2025 19:20:29 +0100 Subject: [PATCH 081/621] multi_buffer: Remap excerpt ids to latest excerpt in excerpt fetching (#44229) Closes #ISSUE Release Notes: - N/A *or* Added/Fixed/Improved ... Co-authored by: Cole Miller --- crates/editor/src/selections_collection.rs | 16 ++++++++++++---- crates/multi_buffer/src/multi_buffer.rs | 5 +++-- crates/multi_buffer/src/path_key.rs | 2 +- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/crates/editor/src/selections_collection.rs b/crates/editor/src/selections_collection.rs index f8ff9da763403b0946e99a4e39c934ff43ad6634..6c6c88faf5e32195e049228fe573d19e13ae111a 100644 --- a/crates/editor/src/selections_collection.rs +++ b/crates/editor/src/selections_collection.rs @@ -419,22 +419,30 @@ impl SelectionsCollection { mutable_collection.disjoint.iter().for_each(|selection| { assert!( snapshot.can_resolve(&selection.start), - "disjoint selection start is not resolvable for the given snapshot:\n{selection:?}", + "disjoint selection start is not resolvable for the given snapshot:\n{selection:?}, {excerpt:?}", + excerpt = snapshot.buffer_for_excerpt(selection.start.excerpt_id).map(|snapshot| snapshot.remote_id()), ); assert!( snapshot.can_resolve(&selection.end), - "disjoint selection end is not resolvable for the given snapshot: {selection:?}", + "disjoint selection end is not resolvable for the given snapshot: {selection:?}, {excerpt:?}", + excerpt = snapshot.buffer_for_excerpt(selection.end.excerpt_id).map(|snapshot| snapshot.remote_id()), ); }); if let Some(pending) = &mutable_collection.pending { let selection = &pending.selection; assert!( snapshot.can_resolve(&selection.start), - "pending selection start is not resolvable for the given snapshot: {pending:?}", + "pending selection start is not resolvable for the given snapshot: {pending:?}, {excerpt:?}", + excerpt = snapshot + .buffer_for_excerpt(selection.start.excerpt_id) + .map(|snapshot| snapshot.remote_id()), ); assert!( snapshot.can_resolve(&selection.end), - "pending selection end is not resolvable for the given snapshot: {pending:?}", + "pending selection end is not resolvable for the given snapshot: {pending:?}, {excerpt:?}", + excerpt = snapshot + .buffer_for_excerpt(selection.end.excerpt_id) + .map(|snapshot| snapshot.remote_id()), ); } } diff --git a/crates/multi_buffer/src/multi_buffer.rs b/crates/multi_buffer/src/multi_buffer.rs index 24cb55d2f5e7311cc492ec70ab320eb12e78f8ee..bd163557c4f6239353e7cd5ad08a6120e20e4a3d 100644 --- a/crates/multi_buffer/src/multi_buffer.rs +++ b/crates/multi_buffer/src/multi_buffer.rs @@ -6457,12 +6457,13 @@ impl MultiBufferSnapshot { } /// Returns the excerpt for the given id. The returned excerpt is guaranteed - /// to have the same excerpt id as the one passed in, with the exception of - /// `ExcerptId::max()`. + /// to have the latest excerpt id for the one passed in and will also remap + /// `ExcerptId::max()` to the corresponding excertp ID. /// /// Callers of this function should generally use the resulting excerpt's `id` field /// afterwards. fn excerpt(&self, excerpt_id: ExcerptId) -> Option<&Excerpt> { + let excerpt_id = self.latest_excerpt_id(excerpt_id); let mut cursor = self.excerpts.cursor::>(()); let locator = self.excerpt_locator_for_id(excerpt_id); cursor.seek(&Some(locator), Bias::Left); diff --git a/crates/multi_buffer/src/path_key.rs b/crates/multi_buffer/src/path_key.rs index 82bb902c230180d98c54225e8b57bf85beeedc2d..119194d088c946941b13ffab3f6f2b3ea126cd09 100644 --- a/crates/multi_buffer/src/path_key.rs +++ b/crates/multi_buffer/src/path_key.rs @@ -305,7 +305,7 @@ impl MultiBuffer { let snapshot = self.snapshot(cx); let mut next_excerpt_id = - // is this right? What if we remove the last excerpt, then we might reallocate with a wrong mapping? + // todo(lw): is this right? What if we remove the last excerpt, then we might reallocate with a wrong mapping? if let Some(last_entry) = self.snapshot.borrow().excerpt_ids.last() { last_entry.id.0 + 1 } else { From 3bb6c2546a1d104c9198096339e9317080f6ee87 Mon Sep 17 00:00:00 2001 From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Date: Fri, 5 Dec 2025 15:46:28 -0300 Subject: [PATCH 082/621] git_ui: Fix history view label truncation (#44218) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There's still a weird problem happening where the labels (and the label on the tab, too, for what is worth) flicker as the file history view gets smaller. I suspect that problem is related to something else—potentially the truncation algorithm or focus management—so I'm not solving it here. Screenshot 2025-12-05 at 11  24@2x Release Notes: - N/A --- crates/git_ui/src/file_history_view.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/crates/git_ui/src/file_history_view.rs b/crates/git_ui/src/file_history_view.rs index e34806aacae48122caf3a12246b04862898f2bed..5b3588d29678ec406749ec45be3de154fd71c5f8 100644 --- a/crates/git_ui/src/file_history_view.rs +++ b/crates/git_ui/src/file_history_view.rs @@ -267,15 +267,19 @@ impl FileHistoryView { .child(self.render_commit_avatar(&entry.sha, window, cx)) .child( h_flex() + .min_w_0() .w_full() .justify_between() .child( h_flex() + .min_w_0() + .w_full() .gap_1() .child( Label::new(entry.author_name.clone()) .size(LabelSize::Small) - .color(Color::Default), + .color(Color::Default) + .truncate(), ) .child( Label::new(&entry.subject) @@ -285,9 +289,11 @@ impl FileHistoryView { ), ) .child( - Label::new(relative_timestamp) - .size(LabelSize::Small) - .color(Color::Muted), + h_flex().flex_none().child( + Label::new(relative_timestamp) + .size(LabelSize::Small) + .color(Color::Muted), + ), ), ), ) From f9cea5af29a988be7932e48d5a0f1b5e15c51d0d Mon Sep 17 00:00:00 2001 From: Bennet Bo Fenner Date: Fri, 5 Dec 2025 19:53:53 +0100 Subject: [PATCH 083/621] Fix project not getting dropped after closing window (#44237) --- crates/agent_ui/src/acp/entry_view_state.rs | 12 ++-- crates/agent_ui/src/acp/message_editor.rs | 44 ++++++------- crates/agent_ui/src/acp/thread_view.rs | 4 +- .../assistant_text_thread/src/text_thread.rs | 16 ++--- .../src/text_thread_store.rs | 65 +++++++++++++------ 5 files changed, 80 insertions(+), 61 deletions(-) diff --git a/crates/agent_ui/src/acp/entry_view_state.rs b/crates/agent_ui/src/acp/entry_view_state.rs index 53f24947658be8def877eb6b3a7d4e29b541d0c0..feae74a86bc241c5d2e01f0941eafc60210f1bf6 100644 --- a/crates/agent_ui/src/acp/entry_view_state.rs +++ b/crates/agent_ui/src/acp/entry_view_state.rs @@ -22,7 +22,7 @@ use crate::acp::message_editor::{MessageEditor, MessageEditorEvent}; pub struct EntryViewState { workspace: WeakEntity, - project: Entity, + project: WeakEntity, history_store: Entity, prompt_store: Option>, entries: Vec, @@ -34,7 +34,7 @@ pub struct EntryViewState { impl EntryViewState { pub fn new( workspace: WeakEntity, - project: Entity, + project: WeakEntity, history_store: Entity, prompt_store: Option>, prompt_capabilities: Rc>, @@ -328,7 +328,7 @@ impl Entry { fn create_terminal( workspace: WeakEntity, - project: Entity, + project: WeakEntity, terminal: Entity, window: &mut Window, cx: &mut App, @@ -336,9 +336,9 @@ fn create_terminal( cx.new(|cx| { let mut view = TerminalView::new( terminal.read(cx).inner().clone(), - workspace.clone(), + workspace, None, - project.downgrade(), + project, window, cx, ); @@ -458,7 +458,7 @@ mod tests { let view_state = cx.new(|_cx| { EntryViewState::new( workspace.downgrade(), - project.clone(), + project.downgrade(), history_store, None, Default::default(), diff --git a/crates/agent_ui/src/acp/message_editor.rs b/crates/agent_ui/src/acp/message_editor.rs index 827990599912fe832d40605fb1dceb58eab4ff2f..875dc495cea710d1df950b47b328042bbda4a287 100644 --- a/crates/agent_ui/src/acp/message_editor.rs +++ b/crates/agent_ui/src/acp/message_editor.rs @@ -39,7 +39,6 @@ use zed_actions::agent::Chat; pub struct MessageEditor { mention_set: Entity, editor: Entity, - project: Entity, workspace: WeakEntity, prompt_capabilities: Rc>, available_commands: Rc>>, @@ -98,7 +97,7 @@ impl PromptCompletionProviderDelegate for Entity { impl MessageEditor { pub fn new( workspace: WeakEntity, - project: Entity, + project: WeakEntity, history_store: Entity, prompt_store: Option>, prompt_capabilities: Rc>, @@ -135,13 +134,8 @@ impl MessageEditor { editor.register_addon(MessageEditorAddon::new()); editor }); - let mention_set = cx.new(|_cx| { - MentionSet::new( - project.downgrade(), - history_store.clone(), - prompt_store.clone(), - ) - }); + let mention_set = + cx.new(|_cx| MentionSet::new(project, history_store.clone(), prompt_store.clone())); let completion_provider = Rc::new(PromptCompletionProvider::new( cx.entity(), editor.downgrade(), @@ -199,7 +193,6 @@ impl MessageEditor { Self { editor, - project, mention_set, workspace, prompt_capabilities, @@ -572,17 +565,18 @@ impl MessageEditor { let Some(workspace) = self.workspace.upgrade() else { return; }; - let path_style = self.project.read(cx).path_style(cx); + let project = workspace.read(cx).project().clone(); + let path_style = project.read(cx).path_style(cx); let buffer = self.editor.read(cx).buffer().clone(); let Some(buffer) = buffer.read(cx).as_singleton() else { return; }; let mut tasks = Vec::new(); for path in paths { - let Some(entry) = self.project.read(cx).entry_for_path(&path, cx) else { + let Some(entry) = project.read(cx).entry_for_path(&path, cx) else { continue; }; - let Some(worktree) = self.project.read(cx).worktree_for_id(path.worktree_id, cx) else { + let Some(worktree) = project.read(cx).worktree_for_id(path.worktree_id, cx) else { continue; }; let abs_path = worktree.read(cx).absolutize(&path.path); @@ -690,9 +684,13 @@ impl MessageEditor { window: &mut Window, cx: &mut Context, ) { + let Some(workspace) = self.workspace.upgrade() else { + return; + }; + self.clear(window, cx); - let path_style = self.project.read(cx).path_style(cx); + let path_style = workspace.read(cx).project().read(cx).path_style(cx); let mut text = String::new(); let mut mentions = Vec::new(); @@ -935,7 +933,7 @@ mod tests { cx.new(|cx| { MessageEditor::new( workspace.downgrade(), - project.clone(), + project.downgrade(), history_store.clone(), None, Default::default(), @@ -1046,7 +1044,7 @@ mod tests { cx.new(|cx| { MessageEditor::new( workspace_handle.clone(), - project.clone(), + project.downgrade(), history_store.clone(), None, prompt_capabilities.clone(), @@ -1207,7 +1205,7 @@ mod tests { let message_editor = cx.new(|cx| { MessageEditor::new( workspace_handle, - project.clone(), + project.downgrade(), history_store.clone(), None, prompt_capabilities.clone(), @@ -1429,7 +1427,7 @@ mod tests { let message_editor = cx.new(|cx| { MessageEditor::new( workspace_handle, - project.clone(), + project.downgrade(), history_store.clone(), None, prompt_capabilities.clone(), @@ -1920,7 +1918,7 @@ mod tests { cx.new(|cx| { let editor = MessageEditor::new( workspace.downgrade(), - project.clone(), + project.downgrade(), history_store.clone(), None, Default::default(), @@ -2025,7 +2023,7 @@ mod tests { cx.new(|cx| { let mut editor = MessageEditor::new( workspace.downgrade(), - project.clone(), + project.downgrade(), history_store.clone(), None, Default::default(), @@ -2094,7 +2092,7 @@ mod tests { cx.new(|cx| { MessageEditor::new( workspace.downgrade(), - project.clone(), + project.downgrade(), history_store.clone(), None, Default::default(), @@ -2157,7 +2155,7 @@ mod tests { let message_editor = cx.new(|cx| { MessageEditor::new( workspace_handle, - project.clone(), + project.downgrade(), history_store.clone(), None, Default::default(), @@ -2315,7 +2313,7 @@ mod tests { let message_editor = cx.new(|cx| { MessageEditor::new( workspace_handle, - project.clone(), + project.downgrade(), history_store.clone(), None, Default::default(), diff --git a/crates/agent_ui/src/acp/thread_view.rs b/crates/agent_ui/src/acp/thread_view.rs index aedb96bb82f07723f934d0ec73aa1fd545461f00..c917a48ad5bac67e7dcdef94dbace97b26843404 100644 --- a/crates/agent_ui/src/acp/thread_view.rs +++ b/crates/agent_ui/src/acp/thread_view.rs @@ -344,7 +344,7 @@ impl AcpThreadView { let message_editor = cx.new(|cx| { let mut editor = MessageEditor::new( workspace.clone(), - project.clone(), + project.downgrade(), history_store.clone(), prompt_store.clone(), prompt_capabilities.clone(), @@ -369,7 +369,7 @@ impl AcpThreadView { let entry_view_state = cx.new(|_| { EntryViewState::new( workspace.clone(), - project.clone(), + project.downgrade(), history_store.clone(), prompt_store.clone(), prompt_capabilities.clone(), diff --git a/crates/assistant_text_thread/src/text_thread.rs b/crates/assistant_text_thread/src/text_thread.rs index 7f24c8f665f8d34aed199562dce1131797f13c9d..b808d9fb0019ccad25366d9ae60cc1f765126c74 100644 --- a/crates/assistant_text_thread/src/text_thread.rs +++ b/crates/assistant_text_thread/src/text_thread.rs @@ -14,7 +14,7 @@ use fs::{Fs, RenameOptions}; use futures::{FutureExt, StreamExt, future::Shared}; use gpui::{ App, AppContext as _, Context, Entity, EventEmitter, RenderImage, SharedString, Subscription, - Task, + Task, WeakEntity, }; use itertools::Itertools as _; use language::{AnchorRangeExt, Bias, Buffer, LanguageRegistry, OffsetRangeExt, Point, ToOffset}; @@ -688,7 +688,7 @@ pub struct TextThread { _subscriptions: Vec, telemetry: Option>, language_registry: Arc, - project: Option>, + project: Option>, prompt_builder: Arc, completion_mode: agent_settings::CompletionMode, } @@ -708,7 +708,7 @@ impl EventEmitter for TextThread {} impl TextThread { pub fn local( language_registry: Arc, - project: Option>, + project: Option>, telemetry: Option>, prompt_builder: Arc, slash_commands: Arc, @@ -742,7 +742,7 @@ impl TextThread { language_registry: Arc, prompt_builder: Arc, slash_commands: Arc, - project: Option>, + project: Option>, telemetry: Option>, cx: &mut Context, ) -> Self { @@ -873,7 +873,7 @@ impl TextThread { language_registry: Arc, prompt_builder: Arc, slash_commands: Arc, - project: Option>, + project: Option>, telemetry: Option>, cx: &mut Context, ) -> Self { @@ -1167,10 +1167,6 @@ impl TextThread { self.language_registry.clone() } - pub fn project(&self) -> Option> { - self.project.clone() - } - pub fn prompt_builder(&self) -> Arc { self.prompt_builder.clone() } @@ -2967,7 +2963,7 @@ impl TextThread { } fn update_model_request_usage(&self, amount: u32, limit: UsageLimit, cx: &mut App) { - let Some(project) = &self.project else { + let Some(project) = self.project.as_ref().and_then(|project| project.upgrade()) else { return; }; project.read(cx).user_store().update(cx, |user_store, cx| { diff --git a/crates/assistant_text_thread/src/text_thread_store.rs b/crates/assistant_text_thread/src/text_thread_store.rs index 19c317baf0fa728c77faebc388b5e36008aa39b3..71fabed503e8c04a8865bed72c28ae5b30e75574 100644 --- a/crates/assistant_text_thread/src/text_thread_store.rs +++ b/crates/assistant_text_thread/src/text_thread_store.rs @@ -51,7 +51,7 @@ pub struct TextThreadStore { telemetry: Arc, _watch_updates: Task>, client: Arc, - project: Entity, + project: WeakEntity, project_is_shared: bool, client_subscription: Option, _project_subscriptions: Vec, @@ -119,10 +119,10 @@ impl TextThreadStore { ], project_is_shared: false, client: project.read(cx).client(), - project: project.clone(), + project: project.downgrade(), prompt_builder, }; - this.handle_project_shared(project.clone(), cx); + this.handle_project_shared(cx); this.synchronize_contexts(cx); this.register_context_server_handlers(cx); this.reload(cx).detach_and_log_err(cx); @@ -146,7 +146,7 @@ impl TextThreadStore { telemetry: project.read(cx).client().telemetry().clone(), _watch_updates: Task::ready(None), client: project.read(cx).client(), - project, + project: project.downgrade(), project_is_shared: false, client_subscription: None, _project_subscriptions: Default::default(), @@ -180,8 +180,10 @@ impl TextThreadStore { ) -> Result { let context_id = TextThreadId::from_proto(envelope.payload.context_id); let operations = this.update(&mut cx, |this, cx| { + let project = this.project.upgrade().context("project not found")?; + anyhow::ensure!( - !this.project.read(cx).is_via_collab(), + !project.read(cx).is_via_collab(), "only the host contexts can be opened" ); @@ -211,8 +213,9 @@ impl TextThreadStore { mut cx: AsyncApp, ) -> Result { let (context_id, operations) = this.update(&mut cx, |this, cx| { + let project = this.project.upgrade().context("project not found")?; anyhow::ensure!( - !this.project.read(cx).is_via_collab(), + !project.read(cx).is_via_collab(), "can only create contexts as the host" ); @@ -255,8 +258,9 @@ impl TextThreadStore { mut cx: AsyncApp, ) -> Result { this.update(&mut cx, |this, cx| { + let project = this.project.upgrade().context("project not found")?; anyhow::ensure!( - !this.project.read(cx).is_via_collab(), + !project.read(cx).is_via_collab(), "only the host can synchronize contexts" ); @@ -293,8 +297,12 @@ impl TextThreadStore { })? } - fn handle_project_shared(&mut self, _: Entity, cx: &mut Context) { - let is_shared = self.project.read(cx).is_shared(); + fn handle_project_shared(&mut self, cx: &mut Context) { + let Some(project) = self.project.upgrade() else { + return; + }; + + let is_shared = project.read(cx).is_shared(); let was_shared = mem::replace(&mut self.project_is_shared, is_shared); if is_shared == was_shared { return; @@ -309,7 +317,7 @@ impl TextThreadStore { false } }); - let remote_id = self.project.read(cx).remote_id().unwrap(); + let remote_id = project.read(cx).remote_id().unwrap(); self.client_subscription = self .client .subscribe_to_entity(remote_id) @@ -323,13 +331,13 @@ impl TextThreadStore { fn handle_project_event( &mut self, - project: Entity, + _project: Entity, event: &project::Event, cx: &mut Context, ) { match event { project::Event::RemoteIdChanged(_) => { - self.handle_project_shared(project, cx); + self.handle_project_shared(cx); } project::Event::Reshared => { self.advertise_contexts(cx); @@ -382,7 +390,10 @@ impl TextThreadStore { } pub fn create_remote(&mut self, cx: &mut Context) -> Task>> { - let project = self.project.read(cx); + let Some(project) = self.project.upgrade() else { + return Task::ready(Err(anyhow::anyhow!("project was dropped"))); + }; + let project = project.read(cx); let Some(project_id) = project.remote_id() else { return Task::ready(Err(anyhow::anyhow!("project was not remote"))); }; @@ -541,7 +552,10 @@ impl TextThreadStore { text_thread_id: TextThreadId, cx: &mut Context, ) -> Task>> { - let project = self.project.read(cx); + let Some(project) = self.project.upgrade() else { + return Task::ready(Err(anyhow::anyhow!("project was dropped"))); + }; + let project = project.read(cx); let Some(project_id) = project.remote_id() else { return Task::ready(Err(anyhow::anyhow!("project was not remote"))); }; @@ -618,7 +632,10 @@ impl TextThreadStore { event: &TextThreadEvent, cx: &mut Context, ) { - let Some(project_id) = self.project.read(cx).remote_id() else { + let Some(project) = self.project.upgrade() else { + return; + }; + let Some(project_id) = project.read(cx).remote_id() else { return; }; @@ -652,12 +669,14 @@ impl TextThreadStore { } fn advertise_contexts(&self, cx: &App) { - let Some(project_id) = self.project.read(cx).remote_id() else { + let Some(project) = self.project.upgrade() else { + return; + }; + let Some(project_id) = project.read(cx).remote_id() else { return; }; - // For now, only the host can advertise their open contexts. - if self.project.read(cx).is_via_collab() { + if project.read(cx).is_via_collab() { return; } @@ -689,7 +708,10 @@ impl TextThreadStore { } fn synchronize_contexts(&mut self, cx: &mut Context) { - let Some(project_id) = self.project.read(cx).remote_id() else { + let Some(project) = self.project.upgrade() else { + return; + }; + let Some(project_id) = project.read(cx).remote_id() else { return; }; @@ -828,7 +850,10 @@ impl TextThreadStore { } fn register_context_server_handlers(&self, cx: &mut Context) { - let context_server_store = self.project.read(cx).context_server_store(); + let Some(project) = self.project.upgrade() else { + return; + }; + let context_server_store = project.read(cx).context_server_store(); cx.subscribe(&context_server_store, Self::handle_context_server_event) .detach(); From bd6ca841ad48b9fedf868761618ef6f9cccd9f83 Mon Sep 17 00:00:00 2001 From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Date: Fri, 5 Dec 2025 17:17:50 -0300 Subject: [PATCH 084/621] git_ui: Improve the branch picker UI (#44217) Follow up to https://github.com/zed-industries/zed/pull/42819 and https://github.com/zed-industries/zed/pull/44206. - Make this picker feel more consistent with other similar pickers (namely, the project picker) - Move actions to the footer and toggle them conditionally - Only show the "Create" and "Create New From: {default}" when we're selecting the "Create" list item _or_ when that item is the only visible. This means I'm changing here the state transition to only change to `NewBranch/NewRemote` if we only have those items available. - Reuse more UI code and use components when available (e.g., `ListHeader`) - Remove secondary actions from the list item Next step (in another PR), will be refine the same picker in the smaller, panel version. https://github.com/user-attachments/assets/fe72ac06-c1df-4829-a8a4-df8a9222672f Release Notes: - N/A --- crates/git_ui/src/branch_picker.rs | 476 ++++++++++++++++------------- 1 file changed, 260 insertions(+), 216 deletions(-) diff --git a/crates/git_ui/src/branch_picker.rs b/crates/git_ui/src/branch_picker.rs index 33b852c1de9b1bd1a8abcc36dff964d14cbe1807..06405651206befad38c938c9fec35a98dab1ef2c 100644 --- a/crates/git_ui/src/branch_picker.rs +++ b/crates/git_ui/src/branch_picker.rs @@ -17,8 +17,8 @@ use settings::Settings; use std::sync::Arc; use time::OffsetDateTime; use ui::{ - CommonAnimationExt, Divider, HighlightedLabel, KeyBinding, ListItem, ListItemSpacing, Tooltip, - prelude::*, + CommonAnimationExt, Divider, HighlightedLabel, KeyBinding, ListHeader, ListItem, + ListItemSpacing, Tooltip, prelude::*, }; use util::ResultExt; use workspace::notifications::DetachAndPromptErr; @@ -440,13 +440,6 @@ impl BranchListDelegate { cx.emit(DismissEvent); } - fn loader(&self) -> AnyElement { - Icon::new(IconName::LoadCircle) - .size(IconSize::Small) - .with_rotate_animation(3) - .into_any_element() - } - fn delete_at(&self, idx: usize, window: &mut Window, cx: &mut Context>) { let Some(entry) = self.matches.get(idx).cloned() else { return; @@ -683,10 +676,16 @@ impl PickerDelegate for BranchListDelegate { } else { Entry::NewBranch { name: query } }; - picker.delegate.state = if is_url { - PickerState::NewRemote + // Only transition to NewBranch/NewRemote states when we only show their list item + // Otherwise, stay in List state so footer buttons remain visible + picker.delegate.state = if matches.is_empty() { + if is_url { + PickerState::NewRemote + } else { + PickerState::NewBranch + } } else { - PickerState::NewBranch + PickerState::List }; matches.push(entry); } else { @@ -812,67 +811,35 @@ impl PickerDelegate for BranchListDelegate { }) .unwrap_or_else(|| (None, None, None)); - let icon = if let Some(default_branch) = self.default_branch.clone() - && matches!(entry, Entry::NewBranch { .. }) - { - let tooltip_text = format!("Create branch based off default: {default_branch}"); - - Some( - IconButton::new("branch-from-default", IconName::GitBranchAlt) - .on_click(cx.listener(move |this, _, window, cx| { - this.delegate.set_selected_index(ix, window, cx); - this.delegate.confirm(true, window, cx); - })) - .tooltip(move |_window, cx| { - Tooltip::for_action(tooltip_text.clone(), &menu::SecondaryConfirm, cx) - }), - ) - } else { - None - }; + let entry_icon = match entry { + Entry::NewUrl { .. } | Entry::NewBranch { .. } => { + Icon::new(IconName::Plus).color(Color::Muted) + } - let icon_element = if self.display_remotes { - Icon::new(IconName::Screen) - } else { - Icon::new(IconName::GitBranchAlt) + Entry::Branch { .. } => { + if self.display_remotes { + Icon::new(IconName::Screen).color(Color::Muted) + } else { + Icon::new(IconName::GitBranchAlt).color(Color::Muted) + } + } }; - let entry_name = match entry { - Entry::NewUrl { .. } => h_flex() - .gap_1() - .child( - Icon::new(IconName::Plus) - .size(IconSize::Small) - .color(Color::Muted), - ) - .child( - Label::new("Create remote repository".to_string()) - .single_line() - .truncate(), - ) + let entry_title = match entry { + Entry::NewUrl { .. } => Label::new("Create Remote Repository") + .single_line() + .truncate() .into_any_element(), - Entry::NewBranch { name } => h_flex() - .gap_1() - .child( - Icon::new(IconName::Plus) - .size(IconSize::Small) - .color(Color::Muted), - ) - .child( - Label::new(format!("Create branch \"{name}\"…")) - .single_line() - .truncate(), - ) - .into_any_element(), - Entry::Branch { branch, positions } => h_flex() - .max_w_48() - .child(h_flex().mr_1().child(icon_element)) - .child( - HighlightedLabel::new(branch.name().to_string(), positions.clone()) - .single_line() - .truncate(), - ) + Entry::NewBranch { name } => Label::new(format!("Create Branch: \"{name}\"…")) + .single_line() + .truncate() .into_any_element(), + Entry::Branch { branch, positions } => { + HighlightedLabel::new(branch.name().to_string(), positions.clone()) + .single_line() + .truncate() + .into_any_element() + } }; Some( @@ -880,82 +847,96 @@ impl PickerDelegate for BranchListDelegate { .inset(true) .spacing(ListItemSpacing::Sparse) .toggle_state(selected) - .tooltip({ - match entry { - Entry::Branch { branch, .. } => Tooltip::text(branch.name().to_string()), - Entry::NewUrl { .. } => { - Tooltip::text("Create remote repository".to_string()) - } - Entry::NewBranch { name } => { - Tooltip::text(format!("Create branch \"{name}\"")) - } - } - }) .child( - v_flex() + h_flex() .w_full() - .overflow_hidden() + .gap_3() + .flex_grow() + .child(entry_icon) .child( - h_flex() - .gap_6() - .justify_between() - .overflow_x_hidden() - .child(entry_name) - .when_some(commit_time, |label, commit_time| { - label.child( - Label::new(commit_time) - .size(LabelSize::Small) - .color(Color::Muted) - .into_element(), - ) - }), - ) - .when(self.style == BranchListStyle::Modal, |el| { - el.child(div().max_w_96().child({ - let message = match entry { - Entry::NewUrl { url } => format!("based off {url}"), - Entry::NewBranch { .. } => { - if let Some(current_branch) = - self.repo.as_ref().and_then(|repo| { - repo.read(cx).branch.as_ref().map(|b| b.name()) - }) - { - format!("based off {}", current_branch) - } else { - "based off the current branch".to_string() - } - } - Entry::Branch { .. } => { - let show_author_name = ProjectSettings::get_global(cx) - .git - .branch_picker - .show_author_name; - - subject.map_or("no commits found".into(), |subject| { - if show_author_name && author_name.is_some() { - format!("{} • {}", author_name.unwrap(), subject) - } else { - subject.to_string() - } + v_flex() + .id("info_container") + .w_full() + .child(entry_title) + .child( + h_flex() + .w_full() + .justify_between() + .gap_1p5() + .when(self.style == BranchListStyle::Modal, |el| { + el.child(div().max_w_96().child({ + let message = match entry { + Entry::NewUrl { url } => { + format!("Based off {url}") + } + Entry::NewBranch { .. } => { + if let Some(current_branch) = + self.repo.as_ref().and_then(|repo| { + repo.read(cx) + .branch + .as_ref() + .map(|b| b.name()) + }) + { + format!("Based off {}", current_branch) + } else { + "Based off the current branch" + .to_string() + } + } + Entry::Branch { .. } => { + let show_author_name = + ProjectSettings::get_global(cx) + .git + .branch_picker + .show_author_name; + + subject.map_or( + "No commits found".into(), + |subject| { + if show_author_name + && author_name.is_some() + { + format!( + "{} • {}", + author_name.unwrap(), + subject + ) + } else { + subject.to_string() + } + }, + ) + } + }; + + Label::new(message) + .size(LabelSize::Small) + .color(Color::Muted) + .truncate() + })) }) - } - }; - - Label::new(message) - .size(LabelSize::Small) - .truncate() - .color(Color::Muted) - })) - }), - ) - .end_slot::(icon), + .when_some(commit_time, |label, commit_time| { + label.child( + Label::new(commit_time) + .size(LabelSize::Small) + .color(Color::Muted), + ) + }), + ) + .when_some( + entry.as_branch().map(|b| b.name().to_string()), + |this, branch_name| this.tooltip(Tooltip::text(branch_name)), + ), + ), + ), ) } fn render_header( &self, _window: &mut Window, - cx: &mut Context>, + _cx: &mut Context>, ) -> Option { matches!(self.state, PickerState::List).then(|| { let label = if self.display_remotes { @@ -964,83 +945,54 @@ impl PickerDelegate for BranchListDelegate { "Local" }; - h_flex() - .w_full() - .p_1p5() - .gap_1() - .border_t_1() - .border_color(cx.theme().colors().border_variant) - .child(Label::new(label).size(LabelSize::Small).color(Color::Muted)) - .into_any() + ListHeader::new(label).inset(true).into_any_element() }) } fn render_footer(&self, _: &mut Window, cx: &mut Context>) -> Option { let focus_handle = self.focus_handle.clone(); + let loading_icon = Icon::new(IconName::LoadCircle) + .size(IconSize::Small) + .with_rotate_animation(3); + + let footer_container = || { + h_flex() + .w_full() + .p_1p5() + .border_t_1() + .border_color(cx.theme().colors().border_variant) + }; - if self.loading { - return Some( - h_flex() - .w_full() - .p_1p5() - .gap_1() - .justify_end() - .border_t_1() - .border_color(cx.theme().colors().border_variant) - .child(self.loader()) - .into_any(), - ); - } match self.state { - PickerState::List => Some( - h_flex() - .w_full() - .p_1p5() - .gap_0p5() - .border_t_1() - .border_color(cx.theme().colors().border_variant) - .justify_between() - .child({ - let focus_handle = focus_handle.clone(); - Button::new("filter-remotes", "Filter remotes") + PickerState::List => { + let selected_entry = self.matches.get(self.selected_index); + + let branch_from_default_button = self + .default_branch + .as_ref() + .filter(|_| matches!(selected_entry, Some(Entry::NewBranch { .. }))) + .map(|default_branch| { + let button_label = format!("Create New From: {default_branch}"); + + Button::new("branch-from-default", button_label) .key_binding( KeyBinding::for_action_in( - &branch_picker::FilterRemotes, + &menu::SecondaryConfirm, &focus_handle, cx, ) .map(|kb| kb.size(rems_from_px(12.))), ) - .on_click(|_click, window, cx| { - window.dispatch_action( - branch_picker::FilterRemotes.boxed_clone(), - cx, - ); - }) - .disabled(self.loading) - .style(ButtonStyle::Subtle) - .toggle_state(self.display_remotes) - .tooltip({ - let state = self.display_remotes; - - move |_window, cx| { - let tooltip_text = if state { - "Show local branches" - } else { - "Show remote branches" - }; - - Tooltip::for_action_in( - tooltip_text, - &branch_picker::FilterRemotes, - &focus_handle, - cx, - ) - } - }) - }) + .on_click(cx.listener(|this, _, window, cx| { + this.delegate.confirm(true, window, cx); + })) + }); + + let delete_and_select_btns = h_flex() + .gap_0p5() .child( Button::new("delete-branch", "Delete") + .disabled(self.loading) .key_binding( KeyBinding::for_action_in( &branch_picker::DeleteBranch, @@ -1049,43 +1001,134 @@ impl PickerDelegate for BranchListDelegate { ) .map(|kb| kb.size(rems_from_px(12.))), ) - .disabled(self.loading) .on_click(|_, window, cx| { window .dispatch_action(branch_picker::DeleteBranch.boxed_clone(), cx); }), ) - .when(self.loading, |this| this.child(self.loader())) - .into_any(), - ), + .child( + Button::new("select_branch", "Select") + .key_binding( + KeyBinding::for_action_in(&menu::Confirm, &focus_handle, cx) + .map(|kb| kb.size(rems_from_px(12.))), + ) + .on_click(cx.listener(|this, _, window, cx| { + this.delegate.confirm(false, window, cx); + })), + ); + + Some( + footer_container() + .map(|this| { + if branch_from_default_button.is_some() { + this.justify_end().when_some( + branch_from_default_button, + |this, button| { + this.child(button).child( + Button::new("create", "Create") + .key_binding( + KeyBinding::for_action_in( + &menu::Confirm, + &focus_handle, + cx, + ) + .map(|kb| kb.size(rems_from_px(12.))), + ) + .on_click(cx.listener(|this, _, window, cx| { + this.delegate.confirm(false, window, cx); + })), + ) + }, + ) + } else if self.loading { + this.justify_between() + .child(loading_icon) + .child(delete_and_select_btns) + } else { + this.justify_between() + .child({ + let focus_handle = focus_handle.clone(); + Button::new("filter-remotes", "Filter Remotes") + .disabled(self.loading) + .toggle_state(self.display_remotes) + .key_binding( + KeyBinding::for_action_in( + &branch_picker::FilterRemotes, + &focus_handle, + cx, + ) + .map(|kb| kb.size(rems_from_px(12.))), + ) + .on_click(|_click, window, cx| { + window.dispatch_action( + branch_picker::FilterRemotes.boxed_clone(), + cx, + ); + }) + }) + .child(delete_and_select_btns) + } + }) + .into_any_element(), + ) + } + PickerState::NewBranch => { + let branch_from_default_button = + self.default_branch.as_ref().map(|default_branch| { + let button_label = format!("Create New From: {default_branch}"); + + Button::new("branch-from-default", button_label) + .key_binding( + KeyBinding::for_action_in( + &menu::SecondaryConfirm, + &focus_handle, + cx, + ) + .map(|kb| kb.size(rems_from_px(12.))), + ) + .on_click(cx.listener(|this, _, window, cx| { + this.delegate.confirm(true, window, cx); + })) + }); + + Some( + footer_container() + .gap_0p5() + .justify_end() + .when_some(branch_from_default_button, |this, button| { + this.child(button) + }) + .child( + Button::new("branch-from-default", "Create") + .key_binding( + KeyBinding::for_action_in(&menu::Confirm, &focus_handle, cx) + .map(|kb| kb.size(rems_from_px(12.))), + ) + .on_click(cx.listener(|this, _, window, cx| { + this.delegate.confirm(false, window, cx); + })), + ) + .into_any_element(), + ) + } PickerState::CreateRemote(_) => Some( - h_flex() - .w_full() - .p_1p5() - .gap_1() - .border_t_1() - .border_color(cx.theme().colors().border_variant) + footer_container() + .justify_end() .child( Label::new("Choose a name for this remote repository") .size(LabelSize::Small) .color(Color::Muted), ) .child( - h_flex().w_full().justify_end().child( - Label::new("Save") - .size(LabelSize::Small) - .color(Color::Muted), - ), + Label::new("Save") + .size(LabelSize::Small) + .color(Color::Muted), ) - .into_any(), + .into_any_element(), ), - PickerState::NewRemote | PickerState::NewBranch => None, + PickerState::NewRemote => None, } } - - fn no_matches_text(&self, _window: &mut Window, _cx: &mut App) -> Option { - None - } } #[cfg(test)] @@ -1515,6 +1558,7 @@ mod tests { let last_match = picker.delegate.matches.last().unwrap(); assert!(last_match.is_new_branch()); assert_eq!(last_match.name(), "new-feature-branch"); + // State is NewBranch because no existing branches fuzzy-match the query assert!(matches!(picker.delegate.state, PickerState::NewBranch)); picker.delegate.confirm(false, window, cx); }) From a350438a21c80e1199ceae78f4e9f7e6f7403330 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Fri, 5 Dec 2025 22:26:42 +0200 Subject: [PATCH 085/621] Specify a schema to use when dealing with JSONC files (#44250) Follow-up of https://github.com/zed-industries/zed/pull/43854 Closes https://github.com/zed-industries/zed/issues/40970 Seems that json language server does not distinguish between JSONC and JSON files in runtime, but there is a static schema, which accepts globs in its `fileMatch` fields. Use all glob overrides and file suffixes for JSONC inside those match fields, and provide a grammar for such matches, which accepts trailing commas. Release Notes: - Improved JSONC trailing comma handling --- .../src/json_schema_store.rs | 54 +++++++++++++++++-- crates/language/src/language_registry.rs | 4 +- crates/language/src/language_settings.rs | 9 ++-- crates/languages/src/json.rs | 11 ++-- crates/languages/src/lib.rs | 2 +- 5 files changed, 65 insertions(+), 15 deletions(-) diff --git a/crates/json_schema_store/src/json_schema_store.rs b/crates/json_schema_store/src/json_schema_store.rs index b44efb8b1b135850ab78460a428b5088e5fa0928..18041545ccd404eef0035b9b50ff8244d212fa0b 100644 --- a/crates/json_schema_store/src/json_schema_store.rs +++ b/crates/json_schema_store/src/json_schema_store.rs @@ -3,8 +3,9 @@ use std::{str::FromStr, sync::Arc}; use anyhow::{Context as _, Result}; use gpui::{App, AsyncApp, BorrowAppContext as _, Entity, WeakEntity}; -use language::LanguageRegistry; +use language::{LanguageRegistry, language_settings::all_language_settings}; use project::LspStore; +use util::schemars::{AllowTrailingCommas, DefaultDenyUnknownFields}; // Origin: https://github.com/SchemaStore/schemastore const TSCONFIG_SCHEMA: &str = include_str!("schemas/tsconfig.json"); @@ -159,14 +160,35 @@ pub fn resolve_schema_request_inner( } } "snippets" => snippet_provider::format::VsSnippetsFile::generate_json_schema(), + "jsonc" => jsonc_schema(), _ => { - anyhow::bail!("Unrecognized builtin JSON schema: {}", schema_name); + anyhow::bail!("Unrecognized builtin JSON schema: {schema_name}"); } }; Ok(schema) } -pub fn all_schema_file_associations(cx: &mut App) -> serde_json::Value { +const JSONC_LANGUAGE_NAME: &str = "JSONC"; + +pub fn all_schema_file_associations( + languages: &Arc, + cx: &mut App, +) -> serde_json::Value { + let extension_globs = languages + .available_language_for_name(JSONC_LANGUAGE_NAME) + .map(|language| language.matcher().path_suffixes.clone()) + .into_iter() + .flatten() + // Path suffixes can be entire file names or just their extensions. + .flat_map(|path_suffix| [format!("*.{path_suffix}"), path_suffix]); + let override_globs = all_language_settings(None, cx) + .file_types + .get(JSONC_LANGUAGE_NAME) + .into_iter() + .flat_map(|(_, glob_strings)| glob_strings) + .cloned(); + let jsonc_globs = extension_globs.chain(override_globs).collect::>(); + let mut file_associations = serde_json::json!([ { "fileMatch": [ @@ -211,6 +233,10 @@ pub fn all_schema_file_associations(cx: &mut App) -> serde_json::Value { "fileMatch": ["package.json"], "url": "zed://schemas/package_json" }, + { + "fileMatch": &jsonc_globs, + "url": "zed://schemas/jsonc" + }, ]); #[cfg(debug_assertions)] @@ -233,7 +259,7 @@ pub fn all_schema_file_associations(cx: &mut App) -> serde_json::Value { let file_name = normalized_action_name_to_file_name(normalized_name.clone()); serde_json::json!({ "fileMatch": [file_name], - "url": format!("zed://schemas/action/{}", normalized_name) + "url": format!("zed://schemas/action/{normalized_name}") }) }), ); @@ -249,6 +275,26 @@ fn package_json_schema() -> serde_json::Value { serde_json::Value::from_str(PACKAGE_JSON_SCHEMA).unwrap() } +fn jsonc_schema() -> serde_json::Value { + let generator = schemars::generate::SchemaSettings::draft2019_09() + .with_transform(DefaultDenyUnknownFields) + .with_transform(AllowTrailingCommas) + .into_generator(); + let meta_schema = generator + .settings() + .meta_schema + .as_ref() + .expect("meta_schema should be present in schemars settings") + .to_string(); + let defs = generator.definitions(); + let schema = schemars::json_schema!({ + "$schema": meta_schema, + "allowTrailingCommas": true, + "$defs": defs, + }); + serde_json::to_value(schema).unwrap() +} + fn generate_inspector_style_schema() -> serde_json::Value { let schema = schemars::generate::SchemaSettings::draft2019_09() .with_transform(util::schemars::DefaultDenyUnknownFields) diff --git a/crates/language/src/language_registry.rs b/crates/language/src/language_registry.rs index a0b04efd1b1366a101812d8656965637c13769a5..af2b66316d133370a3c27f59da645cfff8d8aa66 100644 --- a/crates/language/src/language_registry.rs +++ b/crates/language/src/language_registry.rs @@ -745,7 +745,7 @@ impl LanguageRegistry { self: &Arc, path: &Path, content: Option<&Rope>, - user_file_types: Option<&FxHashMap, GlobSet>>, + user_file_types: Option<&FxHashMap, (GlobSet, Vec)>>, ) -> Option { let filename = path.file_name().and_then(|filename| filename.to_str()); // `Path.extension()` returns None for files with a leading '.' @@ -788,7 +788,7 @@ impl LanguageRegistry { let path_matches_custom_suffix = || { user_file_types .and_then(|types| types.get(language_name.as_ref())) - .map_or(None, |custom_suffixes| { + .map_or(None, |(custom_suffixes, _)| { path_suffixes .iter() .find(|(_, candidate)| custom_suffixes.is_match_candidate(candidate)) diff --git a/crates/language/src/language_settings.rs b/crates/language/src/language_settings.rs index 068f8e1aa39ca3422fda8eb5706c00de6f2f62ce..fccaa545b79c1f24589889df8fcd163fbc5b6c7d 100644 --- a/crates/language/src/language_settings.rs +++ b/crates/language/src/language_settings.rs @@ -51,7 +51,7 @@ pub struct AllLanguageSettings { pub edit_predictions: EditPredictionSettings, pub defaults: LanguageSettings, languages: HashMap, - pub(crate) file_types: FxHashMap, GlobSet>, + pub file_types: FxHashMap, (GlobSet, Vec)>, } #[derive(Debug, Clone, PartialEq)] @@ -656,7 +656,7 @@ impl settings::Settings for AllLanguageSettings { let enabled_in_text_threads = edit_predictions.enabled_in_text_threads.unwrap(); - let mut file_types: FxHashMap, GlobSet> = FxHashMap::default(); + let mut file_types: FxHashMap, (GlobSet, Vec)> = FxHashMap::default(); for (language, patterns) in all_languages.file_types.iter().flatten() { let mut builder = GlobSetBuilder::new(); @@ -665,7 +665,10 @@ impl settings::Settings for AllLanguageSettings { builder.add(Glob::new(pattern).unwrap()); } - file_types.insert(language.clone(), builder.build().unwrap()); + file_types.insert( + language.clone(), + (builder.build().unwrap(), patterns.0.clone()), + ); } Self { diff --git a/crates/languages/src/json.rs b/crates/languages/src/json.rs index f695512c1a9ed55289a79bbbd632114a24b82d8d..00bb265967f83ee9a95c034cc0bbcbf63e952647 100644 --- a/crates/languages/src/json.rs +++ b/crates/languages/src/json.rs @@ -7,8 +7,8 @@ use futures::StreamExt; use gpui::{App, AsyncApp, Task}; use http_client::github::{GitHubLspBinaryVersion, latest_github_release}; use language::{ - ContextProvider, LanguageName, LocalFile as _, LspAdapter, LspAdapterDelegate, LspInstaller, - Toolchain, + ContextProvider, LanguageName, LanguageRegistry, LocalFile as _, LspAdapter, + LspAdapterDelegate, LspInstaller, Toolchain, }; use lsp::{LanguageServerBinary, LanguageServerName, Uri}; use node_runtime::{NodeRuntime, VersionStrategy}; @@ -129,14 +129,15 @@ fn server_binary_arguments(server_path: &Path) -> Vec { } pub struct JsonLspAdapter { + languages: Arc, node: NodeRuntime, } impl JsonLspAdapter { const PACKAGE_NAME: &str = "vscode-langservers-extracted"; - pub fn new(node: NodeRuntime) -> Self { - Self { node } + pub fn new(languages: Arc, node: NodeRuntime) -> Self { + Self { languages, node } } } @@ -255,7 +256,7 @@ impl LspAdapter for JsonLspAdapter { cx: &mut AsyncApp, ) -> Result { let mut config = cx.update(|cx| { - let schemas = json_schema_store::all_schema_file_associations(cx); + let schemas = json_schema_store::all_schema_file_associations(&self.languages, cx); // This can be viewed via `dev: open language server logs` -> `json-language-server` -> // `Server Info` diff --git a/crates/languages/src/lib.rs b/crates/languages/src/lib.rs index 9df14fb162e2ed722f5ed7527e179f3aec9b0af6..8ce234a864085a324adeb93a1005a0ed60b1c2b1 100644 --- a/crates/languages/src/lib.rs +++ b/crates/languages/src/lib.rs @@ -89,7 +89,7 @@ pub fn init(languages: Arc, fs: Arc, node: NodeRuntime let go_context_provider = Arc::new(go::GoContextProvider); let go_lsp_adapter = Arc::new(go::GoLspAdapter); let json_context_provider = Arc::new(JsonTaskProvider); - let json_lsp_adapter = Arc::new(json::JsonLspAdapter::new(node.clone())); + let json_lsp_adapter = Arc::new(json::JsonLspAdapter::new(languages.clone(), node.clone())); let node_version_lsp_adapter = Arc::new(json::NodeVersionAdapter); let py_lsp_adapter = Arc::new(python::PyLspAdapter::new()); let ty_lsp_adapter = Arc::new(python::TyLspAdapter::new(fs.clone())); From 5cd30e51067c9f4aa57f7e68b9f3aef957916a18 Mon Sep 17 00:00:00 2001 From: Michael Benfield Date: Fri, 5 Dec 2025 13:28:29 -0800 Subject: [PATCH 086/621] inline assistant: Use tools and remove insertion mode (#44248) Co-authored by: Mikayla Maki Co-authored-by: Danilo Leal Release Notes: - N/A --- assets/prompts/content_prompt_v2.hbs | 44 ++++ crates/agent/src/tools.rs | 4 + crates/agent_ui/src/agent_model_selector.rs | 2 +- crates/agent_ui/src/buffer_codegen.rs | 265 ++++++++++++++++++-- crates/agent_ui/src/inline_assistant.rs | 111 ++++++-- crates/agent_ui/src/inline_prompt_editor.rs | 131 ++++++++-- crates/feature_flags/src/flags.rs | 6 + crates/language_model/src/language_model.rs | 34 +++ crates/prompt_store/src/prompts.rs | 92 +++++++ 9 files changed, 630 insertions(+), 59 deletions(-) create mode 100644 assets/prompts/content_prompt_v2.hbs diff --git a/assets/prompts/content_prompt_v2.hbs b/assets/prompts/content_prompt_v2.hbs new file mode 100644 index 0000000000000000000000000000000000000000..e1b6ddc6f023e9e97c9bb851473ac02e989c8feb --- /dev/null +++ b/assets/prompts/content_prompt_v2.hbs @@ -0,0 +1,44 @@ +{{#if language_name}} +Here's a file of {{language_name}} that the user is going to ask you to make an edit to. +{{else}} +Here's a file of text that the user is going to ask you to make an edit to. +{{/if}} + +The section you'll need to rewrite is marked with tags. + + +{{{document_content}}} + + +{{#if is_truncated}} +The context around the relevant section has been truncated (possibly in the middle of a line) for brevity. +{{/if}} + +{{#if rewrite_section}} +And here's the section to rewrite based on that prompt again for reference: + + +{{{rewrite_section}}} + + +{{#if diagnostic_errors}} +Below are the diagnostic errors visible to the user. If the user requests problems to be fixed, use this information, but do not try to fix these errors if the user hasn't asked you to. + +{{#each diagnostic_errors}} + + {{line_number}} + {{error_message}} + {{code_content}} + +{{/each}} +{{/if}} + +{{/if}} + +Only make changes that are necessary to fulfill the prompt, leave everything else as-is. All surrounding {{content_type}} will be preserved. + +Start at the indentation level in the original file in the rewritten {{content_type}}. + +You must use one of the provided tools to make the rewrite or to provide an explanation as to why the user's request cannot be fulfilled. It is an error if +you simply send back unstructured text. If you need to make a statement or ask a question you must use one of the tools to do so. +It is an error if you try to make a change that cannot be made simply by editing the rewrite_section. diff --git a/crates/agent/src/tools.rs b/crates/agent/src/tools.rs index 1d3c0d557716ec3a52f910971547df4ee764cab0..62a52998a705e11d1c9e69cbade7f427cc9cfc32 100644 --- a/crates/agent/src/tools.rs +++ b/crates/agent/src/tools.rs @@ -4,6 +4,7 @@ mod create_directory_tool; mod delete_path_tool; mod diagnostics_tool; mod edit_file_tool; + mod fetch_tool; mod find_path_tool; mod grep_tool; @@ -12,6 +13,7 @@ mod move_path_tool; mod now_tool; mod open_tool; mod read_file_tool; + mod terminal_tool; mod thinking_tool; mod web_search_tool; @@ -25,6 +27,7 @@ pub use create_directory_tool::*; pub use delete_path_tool::*; pub use diagnostics_tool::*; pub use edit_file_tool::*; + pub use fetch_tool::*; pub use find_path_tool::*; pub use grep_tool::*; @@ -33,6 +36,7 @@ pub use move_path_tool::*; pub use now_tool::*; pub use open_tool::*; pub use read_file_tool::*; + pub use terminal_tool::*; pub use thinking_tool::*; pub use web_search_tool::*; diff --git a/crates/agent_ui/src/agent_model_selector.rs b/crates/agent_ui/src/agent_model_selector.rs index 43982cdda7bd887b8fd9970e836090a0e549ae11..3840e40cf4d22db9d52e74ef0489c06ca8a15f26 100644 --- a/crates/agent_ui/src/agent_model_selector.rs +++ b/crates/agent_ui/src/agent_model_selector.rs @@ -98,7 +98,7 @@ impl Render for AgentModelSelector { .child( Icon::new(IconName::ChevronDown) .color(color) - .size(IconSize::XSmall), + .size(IconSize::Small), ), move |_window, cx| { Tooltip::for_action_in("Change Model", &ToggleModelSelector, &focus_handle, cx) diff --git a/crates/agent_ui/src/buffer_codegen.rs b/crates/agent_ui/src/buffer_codegen.rs index 972ead664464876e57d7830b18db3f2b0c49629c..0d014f50294f90aa2bda1f51025c937cc0e2ae56 100644 --- a/crates/agent_ui/src/buffer_codegen.rs +++ b/crates/agent_ui/src/buffer_codegen.rs @@ -5,22 +5,26 @@ use client::telemetry::Telemetry; use cloud_llm_client::CompletionIntent; use collections::HashSet; use editor::{Anchor, AnchorRangeExt, MultiBuffer, MultiBufferSnapshot, ToOffset as _, ToPoint}; +use feature_flags::{FeatureFlagAppExt as _, InlineAssistantV2FeatureFlag}; use futures::{ SinkExt, Stream, StreamExt, TryStreamExt as _, channel::mpsc, future::{LocalBoxFuture, Shared}, join, }; -use gpui::{App, AppContext as _, Context, Entity, EventEmitter, Subscription, Task}; +use gpui::{App, AppContext as _, AsyncApp, Context, Entity, EventEmitter, Subscription, Task}; use language::{Buffer, IndentKind, Point, TransactionId, line_diff}; use language_model::{ - LanguageModel, LanguageModelRegistry, LanguageModelRequest, LanguageModelRequestMessage, - LanguageModelTextStream, Role, report_assistant_event, + LanguageModel, LanguageModelCompletionError, LanguageModelRegistry, LanguageModelRequest, + LanguageModelRequestMessage, LanguageModelRequestTool, LanguageModelTextStream, Role, + report_assistant_event, }; use multi_buffer::MultiBufferRow; use parking_lot::Mutex; use prompt_store::PromptBuilder; use rope::Rope; +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; use smol::future::FutureExt; use std::{ cmp, @@ -34,6 +38,29 @@ use std::{ }; use streaming_diff::{CharOperation, LineDiff, LineOperation, StreamingDiff}; use telemetry_events::{AssistantEventData, AssistantKind, AssistantPhase}; +use ui::SharedString; + +/// Use this tool to provide a message to the user when you're unable to complete a task. +#[derive(Debug, Serialize, Deserialize, JsonSchema)] +pub struct FailureMessageInput { + /// A brief message to the user explaining why you're unable to fulfill the request or to ask a question about the request. + /// + /// The message may use markdown formatting if you wish. + pub message: String, +} + +/// Replaces text in tags with your replacement_text. +#[derive(Debug, Serialize, Deserialize, JsonSchema)] +pub struct RewriteSectionInput { + /// A brief description of the edit you have made. + /// + /// The description may use markdown formatting if you wish. + /// This is optional - if the edit is simple or obvious, you should leave it empty. + pub description: String, + + /// The text to replace the section with. + pub replacement_text: String, +} pub struct BufferCodegen { alternatives: Vec>, @@ -238,6 +265,7 @@ pub struct CodegenAlternative { elapsed_time: Option, completion: Option, pub message_id: Option, + pub model_explanation: Option, } impl EventEmitter for CodegenAlternative {} @@ -288,14 +316,15 @@ impl CodegenAlternative { generation: Task::ready(()), diff: Diff::default(), telemetry, - _subscription: cx.subscribe(&buffer, Self::handle_buffer_event), builder, - active, + active: active, edits: Vec::new(), line_operations: Vec::new(), range, elapsed_time: None, completion: None, + model_explanation: None, + _subscription: cx.subscribe(&buffer, Self::handle_buffer_event), } } @@ -358,18 +387,124 @@ impl CodegenAlternative { let api_key = model.api_key(cx); let telemetry_id = model.telemetry_id(); let provider_id = model.provider_id(); - let stream: LocalBoxFuture> = - if user_prompt.trim().to_lowercase() == "delete" { - async { Ok(LanguageModelTextStream::default()) }.boxed_local() + + if cx.has_flag::() { + let request = self.build_request(&model, user_prompt, context_task, cx)?; + let tool_use = + cx.spawn(async move |_, cx| model.stream_completion_tool(request.await, cx).await); + self.handle_tool_use(telemetry_id, provider_id.to_string(), api_key, tool_use, cx); + } else { + let stream: LocalBoxFuture> = + if user_prompt.trim().to_lowercase() == "delete" { + async { Ok(LanguageModelTextStream::default()) }.boxed_local() + } else { + let request = self.build_request(&model, user_prompt, context_task, cx)?; + cx.spawn(async move |_, cx| { + Ok(model.stream_completion_text(request.await, cx).await?) + }) + .boxed_local() + }; + self.handle_stream(telemetry_id, provider_id.to_string(), api_key, stream, cx); + } + + Ok(()) + } + + fn build_request_v2( + &self, + model: &Arc, + user_prompt: String, + context_task: Shared>>, + cx: &mut App, + ) -> Result> { + let buffer = self.buffer.read(cx).snapshot(cx); + let language = buffer.language_at(self.range.start); + let language_name = if let Some(language) = language.as_ref() { + if Arc::ptr_eq(language, &language::PLAIN_TEXT) { + None } else { - let request = self.build_request(&model, user_prompt, context_task, cx)?; - cx.spawn(async move |_, cx| { - Ok(model.stream_completion_text(request.await, cx).await?) - }) - .boxed_local() + Some(language.name()) + } + } else { + None + }; + + let language_name = language_name.as_ref(); + let start = buffer.point_to_buffer_offset(self.range.start); + let end = buffer.point_to_buffer_offset(self.range.end); + let (buffer, range) = if let Some((start, end)) = start.zip(end) { + let (start_buffer, start_buffer_offset) = start; + let (end_buffer, end_buffer_offset) = end; + if start_buffer.remote_id() == end_buffer.remote_id() { + (start_buffer.clone(), start_buffer_offset..end_buffer_offset) + } else { + anyhow::bail!("invalid transformation range"); + } + } else { + anyhow::bail!("invalid transformation range"); + }; + + let system_prompt = self + .builder + .generate_inline_transformation_prompt_v2( + language_name, + buffer, + range.start.0..range.end.0, + ) + .context("generating content prompt")?; + + let temperature = AgentSettings::temperature_for_model(model, cx); + + let tool_input_format = model.tool_input_format(); + + Ok(cx.spawn(async move |_cx| { + let mut messages = vec![LanguageModelRequestMessage { + role: Role::System, + content: vec![system_prompt.into()], + cache: false, + reasoning_details: None, + }]; + + let mut user_message = LanguageModelRequestMessage { + role: Role::User, + content: Vec::new(), + cache: false, + reasoning_details: None, }; - self.handle_stream(telemetry_id, provider_id.to_string(), api_key, stream, cx); - Ok(()) + + if let Some(context) = context_task.await { + context.add_to_request_message(&mut user_message); + } + + user_message.content.push(user_prompt.into()); + messages.push(user_message); + + let tools = vec![ + LanguageModelRequestTool { + name: "rewrite_section".to_string(), + description: "Replaces text in tags with your replacement_text.".to_string(), + input_schema: language_model::tool_schema::root_schema_for::(tool_input_format).to_value(), + }, + LanguageModelRequestTool { + name: "failure_message".to_string(), + description: "Use this tool to provide a message to the user when you're unable to complete a task.".to_string(), + input_schema: language_model::tool_schema::root_schema_for::(tool_input_format).to_value(), + }, + ]; + + LanguageModelRequest { + thread_id: None, + prompt_id: None, + intent: Some(CompletionIntent::InlineAssist), + mode: None, + tools, + tool_choice: None, + stop: Vec::new(), + temperature, + messages, + thinking_allowed: false, + } + })) } fn build_request( @@ -379,6 +514,10 @@ impl CodegenAlternative { context_task: Shared>>, cx: &mut App, ) -> Result> { + if cx.has_flag::() { + return self.build_request_v2(model, user_prompt, context_task, cx); + } + let buffer = self.buffer.read(cx).snapshot(cx); let language = buffer.language_at(self.range.start); let language_name = if let Some(language) = language.as_ref() { @@ -510,6 +649,7 @@ impl CodegenAlternative { self.generation = cx.spawn(async move |codegen, cx| { let stream = stream.await; + let token_usage = stream .as_ref() .ok() @@ -899,6 +1039,101 @@ impl CodegenAlternative { .ok(); }) } + + fn handle_tool_use( + &mut self, + _telemetry_id: String, + _provider_id: String, + _api_key: Option, + tool_use: impl 'static + + Future< + Output = Result, + >, + cx: &mut Context, + ) { + self.diff = Diff::default(); + self.status = CodegenStatus::Pending; + + self.generation = cx.spawn(async move |codegen, cx| { + let finish_with_status = |status: CodegenStatus, cx: &mut AsyncApp| { + let _ = codegen.update(cx, |this, cx| { + this.status = status; + cx.emit(CodegenEvent::Finished); + cx.notify(); + }); + }; + + let tool_use = tool_use.await; + + match tool_use { + Ok(tool_use) if tool_use.name.as_ref() == "rewrite_section" => { + // Parse the input JSON into RewriteSectionInput + match serde_json::from_value::(tool_use.input) { + Ok(input) => { + // Store the description if non-empty + let description = if !input.description.trim().is_empty() { + Some(input.description.clone()) + } else { + None + }; + + // Apply the replacement text to the buffer and compute diff + let batch_diff_task = codegen + .update(cx, |this, cx| { + this.model_explanation = description.map(Into::into); + let range = this.range.clone(); + this.apply_edits( + std::iter::once((range, input.replacement_text)), + cx, + ); + this.reapply_batch_diff(cx) + }) + .ok(); + + // Wait for the diff computation to complete + if let Some(diff_task) = batch_diff_task { + diff_task.await; + } + + finish_with_status(CodegenStatus::Done, cx); + return; + } + Err(e) => { + finish_with_status(CodegenStatus::Error(e.into()), cx); + return; + } + } + } + Ok(tool_use) if tool_use.name.as_ref() == "failure_message" => { + // Handle failure message tool use + match serde_json::from_value::(tool_use.input) { + Ok(input) => { + let _ = codegen.update(cx, |this, _cx| { + // Store the failure message as the tool description + this.model_explanation = Some(input.message.into()); + }); + finish_with_status(CodegenStatus::Done, cx); + return; + } + Err(e) => { + finish_with_status(CodegenStatus::Error(e.into()), cx); + return; + } + } + } + Ok(_tool_use) => { + // Unexpected tool. + finish_with_status(CodegenStatus::Done, cx); + return; + } + Err(e) => { + finish_with_status(CodegenStatus::Error(e.into()), cx); + return; + } + } + }); + cx.notify(); + } } #[derive(Copy, Clone, Debug)] diff --git a/crates/agent_ui/src/inline_assistant.rs b/crates/agent_ui/src/inline_assistant.rs index cbc5891036fdf03ee04cca6b77820748faed2d0a..48da85d38554da8227d76d3cbe290e29ef4fc531 100644 --- a/crates/agent_ui/src/inline_assistant.rs +++ b/crates/agent_ui/src/inline_assistant.rs @@ -387,17 +387,9 @@ impl InlineAssistant { let mut selections = Vec::>::new(); let mut newest_selection = None; for mut selection in initial_selections { - if selection.end > selection.start { - selection.start.column = 0; - // If the selection ends at the start of the line, we don't want to include it. - if selection.end.column == 0 { - selection.end.row -= 1; - } - selection.end.column = snapshot - .buffer_snapshot() - .line_len(MultiBufferRow(selection.end.row)); - } else if let Some(fold) = - snapshot.crease_for_buffer_row(MultiBufferRow(selection.end.row)) + if selection.end == selection.start + && let Some(fold) = + snapshot.crease_for_buffer_row(MultiBufferRow(selection.end.row)) { selection.start = fold.range().start; selection.end = fold.range().end; @@ -424,6 +416,15 @@ impl InlineAssistant { } } } + } else { + selection.start.column = 0; + // If the selection ends at the start of the line, we don't want to include it. + if selection.end.column == 0 && selection.start.row != selection.end.row { + selection.end.row -= 1; + } + selection.end.column = snapshot + .buffer_snapshot() + .line_len(MultiBufferRow(selection.end.row)); } if let Some(prev_selection) = selections.last_mut() @@ -544,14 +545,15 @@ impl InlineAssistant { } } - let [prompt_block_id, end_block_id] = - self.insert_assist_blocks(editor, &range, &prompt_editor, cx); + let [prompt_block_id, tool_description_block_id, end_block_id] = + self.insert_assist_blocks(&editor, &range, &prompt_editor, cx); assists.push(( assist_id, range.clone(), prompt_editor, prompt_block_id, + tool_description_block_id, end_block_id, )); } @@ -570,7 +572,15 @@ impl InlineAssistant { }; let mut assist_group = InlineAssistGroup::new(); - for (assist_id, range, prompt_editor, prompt_block_id, end_block_id) in assists { + for ( + assist_id, + range, + prompt_editor, + prompt_block_id, + tool_description_block_id, + end_block_id, + ) in assists + { let codegen = prompt_editor.read(cx).codegen().clone(); self.assists.insert( @@ -581,6 +591,7 @@ impl InlineAssistant { editor, &prompt_editor, prompt_block_id, + tool_description_block_id, end_block_id, range, codegen, @@ -689,7 +700,7 @@ impl InlineAssistant { range: &Range, prompt_editor: &Entity>, cx: &mut App, - ) -> [CustomBlockId; 2] { + ) -> [CustomBlockId; 3] { let prompt_editor_height = prompt_editor.update(cx, |prompt_editor, cx| { prompt_editor .editor @@ -703,6 +714,14 @@ impl InlineAssistant { render: build_assist_editor_renderer(prompt_editor), priority: 0, }, + // Placeholder for tool description - will be updated dynamically + BlockProperties { + style: BlockStyle::Flex, + placement: BlockPlacement::Below(range.end), + height: Some(0), + render: Arc::new(|_cx| div().into_any_element()), + priority: 0, + }, BlockProperties { style: BlockStyle::Sticky, placement: BlockPlacement::Below(range.end), @@ -721,7 +740,7 @@ impl InlineAssistant { editor.update(cx, |editor, cx| { let block_ids = editor.insert_blocks(assist_blocks, None, cx); - [block_ids[0], block_ids[1]] + [block_ids[0], block_ids[1], block_ids[2]] }) } @@ -1113,6 +1132,9 @@ impl InlineAssistant { let mut to_remove = decorations.removed_line_block_ids; to_remove.insert(decorations.prompt_block_id); to_remove.insert(decorations.end_block_id); + if let Some(tool_description_block_id) = decorations.model_explanation { + to_remove.insert(tool_description_block_id); + } editor.remove_blocks(to_remove, None, cx); }); @@ -1433,8 +1455,60 @@ impl InlineAssistant { let old_snapshot = codegen.snapshot(cx); let old_buffer = codegen.old_buffer(cx); let deleted_row_ranges = codegen.diff(cx).deleted_row_ranges.clone(); + // let model_explanation = codegen.model_explanation(cx); editor.update(cx, |editor, cx| { + // Update tool description block + // if let Some(description) = model_explanation { + // if let Some(block_id) = decorations.model_explanation { + // editor.remove_blocks(HashSet::from_iter([block_id]), None, cx); + // let new_block_id = editor.insert_blocks( + // [BlockProperties { + // style: BlockStyle::Flex, + // placement: BlockPlacement::Below(assist.range.end), + // height: Some(1), + // render: Arc::new({ + // let description = description.clone(); + // move |cx| { + // div() + // .w_full() + // .py_1() + // .px_2() + // .bg(cx.theme().colors().editor_background) + // .border_y_1() + // .border_color(cx.theme().status().info_border) + // .child( + // Label::new(description.clone()) + // .color(Color::Muted) + // .size(LabelSize::Small), + // ) + // .into_any_element() + // } + // }), + // priority: 0, + // }], + // None, + // cx, + // ); + // decorations.model_explanation = new_block_id.into_iter().next(); + // } + // } else if let Some(block_id) = decorations.model_explanation { + // // Hide the block if there's no description + // editor.remove_blocks(HashSet::from_iter([block_id]), None, cx); + // let new_block_id = editor.insert_blocks( + // [BlockProperties { + // style: BlockStyle::Flex, + // placement: BlockPlacement::Below(assist.range.end), + // height: Some(0), + // render: Arc::new(|_cx| div().into_any_element()), + // priority: 0, + // }], + // None, + // cx, + // ); + // decorations.model_explanation = new_block_id.into_iter().next(); + // } + let old_blocks = mem::take(&mut decorations.removed_line_block_ids); editor.remove_blocks(old_blocks, None, cx); @@ -1686,6 +1760,7 @@ impl InlineAssist { editor: &Entity, prompt_editor: &Entity>, prompt_block_id: CustomBlockId, + tool_description_block_id: CustomBlockId, end_block_id: CustomBlockId, range: Range, codegen: Entity, @@ -1700,7 +1775,8 @@ impl InlineAssist { decorations: Some(InlineAssistDecorations { prompt_block_id, prompt_editor: prompt_editor.clone(), - removed_line_block_ids: HashSet::default(), + removed_line_block_ids: Default::default(), + model_explanation: Some(tool_description_block_id), end_block_id, }), range, @@ -1804,6 +1880,7 @@ struct InlineAssistDecorations { prompt_block_id: CustomBlockId, prompt_editor: Entity>, removed_line_block_ids: HashSet, + model_explanation: Option, end_block_id: CustomBlockId, } diff --git a/crates/agent_ui/src/inline_prompt_editor.rs b/crates/agent_ui/src/inline_prompt_editor.rs index b9e8d9ada230ba497ffcd4e577d3312dd440e604..0083648651645c456acfa19332d61b9f550ed4ed 100644 --- a/crates/agent_ui/src/inline_prompt_editor.rs +++ b/crates/agent_ui/src/inline_prompt_editor.rs @@ -11,9 +11,10 @@ use editor::{ use fs::Fs; use gpui::{ AnyElement, App, Context, CursorStyle, Entity, EventEmitter, FocusHandle, Focusable, - Subscription, TextStyle, WeakEntity, Window, + Subscription, TextStyle, TextStyleRefinement, WeakEntity, Window, }; use language_model::{LanguageModel, LanguageModelRegistry}; +use markdown::{HeadingLevelStyles, Markdown, MarkdownElement, MarkdownStyle}; use parking_lot::Mutex; use project::Project; use prompt_store::PromptStore; @@ -65,7 +66,7 @@ impl Render for PromptEditor { const RIGHT_PADDING: Pixels = px(9.); - let (left_gutter_width, right_padding) = match &self.mode { + let (left_gutter_width, right_padding, explanation) = match &self.mode { PromptEditorMode::Buffer { id: _, codegen, @@ -83,11 +84,17 @@ impl Render for PromptEditor { let left_gutter_width = gutter.full_width() + (gutter.margin / 2.0); let right_padding = editor_margins.right + RIGHT_PADDING; - (left_gutter_width, right_padding) + let explanation = codegen + .active_alternative() + .read(cx) + .model_explanation + .clone(); + + (left_gutter_width, right_padding, explanation) } PromptEditorMode::Terminal { .. } => { // Give the equivalent of the same left-padding that we're using on the right - (Pixels::from(40.0), Pixels::from(24.)) + (Pixels::from(40.0), Pixels::from(24.), None) } }; @@ -111,18 +118,30 @@ impl Render for PromptEditor { this.trigger_completion_menu(window, cx); })); + let markdown = window.use_state(cx, |_, cx| Markdown::new("".into(), None, None, cx)); + + if let Some(explanation) = &explanation { + markdown.update(cx, |markdown, cx| { + markdown.reset(explanation.clone(), cx); + }); + } + + let explanation_label = self + .render_markdown(markdown, markdown_style(window, cx)) + .into_any_element(); + v_flex() .key_context("PromptEditor") .capture_action(cx.listener(Self::paste)) - .bg(cx.theme().colors().editor_background) .block_mouse_except_scroll() - .gap_0p5() - .border_y_1() - .border_color(cx.theme().status().info_border) .size_full() .pt_0p5() .pb(bottom_padding) .pr(right_padding) + .bg(cx.theme().colors().editor_background) + .gap_0p5() + .border_y_1() + .border_color(cx.theme().colors().border) .child( h_flex() .items_start() @@ -139,12 +158,12 @@ impl Render for PromptEditor { .capture_action(cx.listener(Self::cycle_next)) .child( WithRemSize::new(ui_font_size) + .h_full() + .w(left_gutter_width) .flex() .flex_row() .flex_shrink_0() .items_center() - .h_full() - .w(left_gutter_width) .justify_center() .gap_2() .child(self.render_close_button(cx)) @@ -177,26 +196,82 @@ impl Render for PromptEditor { .flex_row() .items_center() .gap_1() + .child(add_context_button) + .child(self.model_selector.clone()) .children(buttons), ), ), ) - .child( - WithRemSize::new(ui_font_size) - .flex() - .flex_row() - .items_center() - .child(h_flex().flex_shrink_0().w(left_gutter_width)) - .child( - h_flex() - .w_full() - .pl_1() - .items_start() - .justify_between() - .child(add_context_button) - .child(self.model_selector.clone()), - ), - ) + .when_some(explanation, |this, _| { + this.child( + h_flex() + .size_full() + .child(div().w(left_gutter_width + px(6.))) + .child( + div() + .size_full() + .min_w_0() + .pb_px() + .pl_1() + .flex_1() + .border_t_1() + .border_color(cx.theme().colors().border_variant) + .child(explanation_label), + ), + ) + }) + } +} + +fn markdown_style(window: &Window, cx: &App) -> MarkdownStyle { + let theme_settings = ThemeSettings::get_global(cx); + let colors = cx.theme().colors(); + let mut text_style = window.text_style(); + + text_style.refine(&TextStyleRefinement { + font_family: Some(theme_settings.ui_font.family.clone()), + color: Some(colors.text), + ..Default::default() + }); + + MarkdownStyle { + base_text_style: text_style.clone(), + syntax: cx.theme().syntax().clone(), + selection_background_color: colors.element_selection_background, + heading_level_styles: Some(HeadingLevelStyles { + h1: Some(TextStyleRefinement { + font_size: Some(rems(1.15).into()), + ..Default::default() + }), + h2: Some(TextStyleRefinement { + font_size: Some(rems(1.1).into()), + ..Default::default() + }), + h3: Some(TextStyleRefinement { + font_size: Some(rems(1.05).into()), + ..Default::default() + }), + h4: Some(TextStyleRefinement { + font_size: Some(rems(1.).into()), + ..Default::default() + }), + h5: Some(TextStyleRefinement { + font_size: Some(rems(0.95).into()), + ..Default::default() + }), + h6: Some(TextStyleRefinement { + font_size: Some(rems(0.875).into()), + ..Default::default() + }), + }), + inline_code: TextStyleRefinement { + font_family: Some(theme_settings.buffer_font.family.clone()), + font_fallbacks: theme_settings.buffer_font.fallbacks.clone(), + font_features: Some(theme_settings.buffer_font.features.clone()), + background_color: Some(colors.editor_foreground.opacity(0.08)), + ..Default::default() + }, + ..Default::default() } } @@ -759,6 +834,10 @@ impl PromptEditor { }) .into_any_element() } + + fn render_markdown(&self, markdown: Entity, style: MarkdownStyle) -> MarkdownElement { + MarkdownElement::new(markdown, style) + } } pub enum PromptEditorMode { diff --git a/crates/feature_flags/src/flags.rs b/crates/feature_flags/src/flags.rs index 26615aea0f7566ec6dbbd66a128c1a395cc1b9bc..fe11a7b5eaa162a90ae8ba3f691ca804ab64db2d 100644 --- a/crates/feature_flags/src/flags.rs +++ b/crates/feature_flags/src/flags.rs @@ -11,3 +11,9 @@ pub struct PanicFeatureFlag; impl FeatureFlag for PanicFeatureFlag { const NAME: &'static str = "panic"; } + +pub struct InlineAssistantV2FeatureFlag; + +impl FeatureFlag for InlineAssistantV2FeatureFlag { + const NAME: &'static str = "inline-assistant-v2"; +} diff --git a/crates/language_model/src/language_model.rs b/crates/language_model/src/language_model.rs index c9b6391136da1a2b2e9a2ae470229179615a865a..cb03b84cbf34d3003e53befa518ecd91626a13e9 100644 --- a/crates/language_model/src/language_model.rs +++ b/crates/language_model/src/language_model.rs @@ -707,6 +707,40 @@ pub trait LanguageModel: Send + Sync { .boxed() } + fn stream_completion_tool( + &self, + request: LanguageModelRequest, + cx: &AsyncApp, + ) -> BoxFuture<'static, Result> { + let future = self.stream_completion(request, cx); + + async move { + let events = future.await?; + let mut events = events.fuse(); + + // Iterate through events until we find a complete ToolUse + while let Some(event) = events.next().await { + match event { + Ok(LanguageModelCompletionEvent::ToolUse(tool_use)) + if tool_use.is_input_complete => + { + return Ok(tool_use); + } + Err(err) => { + return Err(err); + } + _ => {} + } + } + + // Stream ended without a complete tool use + Err(LanguageModelCompletionError::Other(anyhow::anyhow!( + "Stream ended without receiving a complete tool use" + ))) + } + .boxed() + } + fn cache_configuration(&self) -> Option { None } diff --git a/crates/prompt_store/src/prompts.rs b/crates/prompt_store/src/prompts.rs index 3d47fbce7014e8e791ca8961447c8df1adf45abf..d6a172218a8eb3d4538363e6202a7e721d2b7bc1 100644 --- a/crates/prompt_store/src/prompts.rs +++ b/crates/prompt_store/src/prompts.rs @@ -94,6 +94,16 @@ pub struct ContentPromptContext { pub diagnostic_errors: Vec, } +#[derive(Serialize)] +pub struct ContentPromptContextV2 { + pub content_type: String, + pub language_name: Option, + pub is_truncated: bool, + pub document_content: String, + pub rewrite_section: Option, + pub diagnostic_errors: Vec, +} + #[derive(Serialize)] pub struct TerminalAssistantPromptContext { pub os: String, @@ -276,6 +286,88 @@ impl PromptBuilder { Ok(()) } + pub fn generate_inline_transformation_prompt_v2( + &self, + language_name: Option<&LanguageName>, + buffer: BufferSnapshot, + range: Range, + ) -> Result { + let content_type = match language_name.as_ref().map(|l| l.as_ref()) { + None | Some("Markdown" | "Plain Text") => "text", + Some(_) => "code", + }; + + const MAX_CTX: usize = 50000; + let is_insert = range.is_empty(); + let mut is_truncated = false; + + let before_range = 0..range.start; + let truncated_before = if before_range.len() > MAX_CTX { + is_truncated = true; + let start = buffer.clip_offset(range.start - MAX_CTX, text::Bias::Right); + start..range.start + } else { + before_range + }; + + let after_range = range.end..buffer.len(); + let truncated_after = if after_range.len() > MAX_CTX { + is_truncated = true; + let end = buffer.clip_offset(range.end + MAX_CTX, text::Bias::Left); + range.end..end + } else { + after_range + }; + + let mut document_content = String::new(); + for chunk in buffer.text_for_range(truncated_before) { + document_content.push_str(chunk); + } + if is_insert { + document_content.push_str(""); + } else { + document_content.push_str("\n"); + for chunk in buffer.text_for_range(range.clone()) { + document_content.push_str(chunk); + } + document_content.push_str("\n"); + } + for chunk in buffer.text_for_range(truncated_after) { + document_content.push_str(chunk); + } + + let rewrite_section = if !is_insert { + let mut section = String::new(); + for chunk in buffer.text_for_range(range.clone()) { + section.push_str(chunk); + } + Some(section) + } else { + None + }; + let diagnostics = buffer.diagnostics_in_range::<_, Point>(range, false); + let diagnostic_errors: Vec = diagnostics + .map(|entry| { + let start = entry.range.start; + ContentPromptDiagnosticContext { + line_number: (start.row + 1) as usize, + error_message: entry.diagnostic.message.clone(), + code_content: buffer.text_for_range(entry.range).collect(), + } + }) + .collect(); + + let context = ContentPromptContextV2 { + content_type: content_type.to_string(), + language_name: language_name.map(|s| s.to_string()), + is_truncated, + document_content, + rewrite_section, + diagnostic_errors, + }; + self.handlebars.lock().render("content_prompt_v2", &context) + } + pub fn generate_inline_transformation_prompt( &self, user_prompt: String, From f4b8b0f4716d842580e9a4d9a6526c8c3f0553b0 Mon Sep 17 00:00:00 2001 From: Mayank Verma Date: Sat, 6 Dec 2025 03:54:59 +0530 Subject: [PATCH 087/621] settings: Fix inconsistent terminal font weight step size (#44243) Closes #44242 Release Notes: - Fixed inconsistent terminal font weight step size in settings --- crates/settings/src/settings_content/terminal.rs | 5 ++--- crates/terminal/src/terminal_settings.rs | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/crates/settings/src/settings_content/terminal.rs b/crates/settings/src/settings_content/terminal.rs index cd01eb14fa5ce19b077c39b67f8bd90ac93ad35f..1a30eecaa12e1e4a2a9799b2ec752bae2998a257 100644 --- a/crates/settings/src/settings_content/terminal.rs +++ b/crates/settings/src/settings_content/terminal.rs @@ -1,7 +1,7 @@ use std::path::PathBuf; use collections::HashMap; -use gpui::{AbsoluteLength, FontFeatures, SharedString, px}; +use gpui::{AbsoluteLength, FontFeatures, FontWeight, SharedString, px}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use settings_macros::{MergeFrom, with_fallible_options}; @@ -96,8 +96,7 @@ pub struct TerminalSettingsContent { pub line_height: Option, pub font_features: Option, /// Sets the terminal's font weight in CSS weight units 0-900. - #[serde(serialize_with = "crate::serialize_optional_f32_with_two_decimal_places")] - pub font_weight: Option, + pub font_weight: Option, /// Default cursor shape for the terminal. /// Can be "bar", "block", "underline", or "hollow". /// diff --git a/crates/terminal/src/terminal_settings.rs b/crates/terminal/src/terminal_settings.rs index 3b3070c6f680452b43d398786fa2a705a06d3404..3d70d85f35239778bee61113ebc51eea7d87adcb 100644 --- a/crates/terminal/src/terminal_settings.rs +++ b/crates/terminal/src/terminal_settings.rs @@ -95,7 +95,7 @@ impl settings::Settings for TerminalSettings { ) }), font_features: user_content.font_features, - font_weight: user_content.font_weight.map(FontWeight), + font_weight: user_content.font_weight, line_height: user_content.line_height.unwrap(), env: project_content.env.unwrap(), cursor_shape: user_content.cursor_shape.unwrap().into(), From e5f87735d3611b45c778e27b99cc4c6880962901 Mon Sep 17 00:00:00 2001 From: "Oleksii (Alexey) Orlenko" Date: Fri, 5 Dec 2025 23:27:21 +0100 Subject: [PATCH 088/621] markdown_preview: Remove unnecessary vec allocation (#44238) Instead of allocating a one-element vec on the heap, we can just use an array here (since `Editor::edit` accepts anything that implements `IntoIterator`). I haven't checked if there are more instances that can be simplified, just accidentally stumbled upon this when working on something else in the markdown preview crate. Release Notes: - N/A --- crates/markdown_preview/src/markdown_preview_view.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/markdown_preview/src/markdown_preview_view.rs b/crates/markdown_preview/src/markdown_preview_view.rs index 4126a31379fa74a750a7d111ac71dc180a3bb0ff..df8201dc7a3dad18c279582d668304ce9e1cf77b 100644 --- a/crates/markdown_preview/src/markdown_preview_view.rs +++ b/crates/markdown_preview/src/markdown_preview_view.rs @@ -524,7 +524,7 @@ impl Render for MarkdownPreviewView { if e.checked() { "[x]" } else { "[ ]" }; editor.edit( - vec![( + [( MultiBufferOffset( e.source_range().start, ) From 4cef8eb47bb157916f10cedd18b0c1a85cd21977 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Fri, 5 Dec 2025 16:55:05 -0700 Subject: [PATCH 089/621] Fix persistence for single-file worktrees (#44257) We were just deleting them before Co-Authored-By: Matthew Chisolm Closes #ISSUE Release Notes: - Fixed restoring window location for single-file worktrees Co-authored-by: Matthew Chisolm --- crates/workspace/src/persistence.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/workspace/src/persistence.rs b/crates/workspace/src/persistence.rs index 824a9be90b6dc33094f854a3a9672db692e2b592..103e51d548648c18b5b2d724362228948a70930b 100644 --- a/crates/workspace/src/persistence.rs +++ b/crates/workspace/src/persistence.rs @@ -1359,11 +1359,11 @@ impl WorkspaceDb { // If a local workspace points to WSL, this check will cause us to wait for the // WSL VM and file server to boot up. This can block for many seconds. // Supported scenarios use remote workspaces. - if !has_wsl_path - && paths.paths().iter().all(|path| path.exists()) - && paths.paths().iter().any(|path| path.is_dir()) - { - result.push((id, SerializedWorkspaceLocation::Local, paths)); + if !has_wsl_path && paths.paths().iter().all(|path| path.exists()) { + // Only show directories in recent projects + if paths.paths().iter().any(|path| path.is_dir()) { + result.push((id, SerializedWorkspaceLocation::Local, paths)); + } } else { delete_tasks.push(self.delete_workspace_by_id(id)); } From 98608842175f02f503581737f9eb69eea01b56df Mon Sep 17 00:00:00 2001 From: Serophots <47299955+Serophots@users.noreply.github.com> Date: Sat, 6 Dec 2025 01:08:43 +0000 Subject: [PATCH 090/621] gpui: Make length helpers into const functions (#44259) Make gpui's `rems()`, `phi()`, `auto()` length related helpers into const functions. I can't see why these functions aren't already const except that it must've been overlooked when they were written? In my project I had need for rems() to be const, and I thought I'd do phi() and auto() whilst I was in the neighbourhood Release Notes: - N/A --- crates/gpui/src/geometry.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/gpui/src/geometry.rs b/crates/gpui/src/geometry.rs index 859ecb3d0e6c7b5c33f5765ce4c6295cef7fd566..4daec6d15367f3e12bab3cba658ccb3f261e9f46 100644 --- a/crates/gpui/src/geometry.rs +++ b/crates/gpui/src/geometry.rs @@ -3567,7 +3567,7 @@ pub const fn relative(fraction: f32) -> DefiniteLength { } /// Returns the Golden Ratio, i.e. `~(1.0 + sqrt(5.0)) / 2.0`. -pub fn phi() -> DefiniteLength { +pub const fn phi() -> DefiniteLength { relative(1.618_034) } @@ -3580,7 +3580,7 @@ pub fn phi() -> DefiniteLength { /// # Returns /// /// A `Rems` representing the specified number of rems. -pub fn rems(rems: f32) -> Rems { +pub const fn rems(rems: f32) -> Rems { Rems(rems) } @@ -3608,7 +3608,7 @@ pub const fn px(pixels: f32) -> Pixels { /// # Returns /// /// A `Length` variant set to `Auto`. -pub fn auto() -> Length { +pub const fn auto() -> Length { Length::Auto } From 363fbbf0d43d4f39a03be685a6283025243cc36f Mon Sep 17 00:00:00 2001 From: Cole Miller Date: Fri, 5 Dec 2025 21:05:34 -0500 Subject: [PATCH 091/621] git: Fix excerpt ranges in the commit view (#44261) Release Notes: - N/A --- crates/git_ui/src/commit_view.rs | 39 ++++++++++++-------------------- 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/crates/git_ui/src/commit_view.rs b/crates/git_ui/src/commit_view.rs index 7d191c1ae461ac36007dcbadc0b2e10f7dc53599..c637ea674f7e58954c186e1557df251d0d22d36b 100644 --- a/crates/git_ui/src/commit_view.rs +++ b/crates/git_ui/src/commit_view.rs @@ -1,7 +1,9 @@ use anyhow::{Context as _, Result}; use buffer_diff::{BufferDiff, BufferDiffSnapshot}; use editor::display_map::{BlockPlacement, BlockProperties, BlockStyle}; -use editor::{Editor, EditorEvent, ExcerptId, ExcerptRange, MultiBuffer}; +use editor::{ + Editor, EditorEvent, ExcerptId, ExcerptRange, MultiBuffer, multibuffer_context_lines, +}; use git::repository::{CommitDetails, CommitDiff, RepoPath}; use git::{GitHostingProviderRegistry, GitRemote, parse_git_remote_url}; use gpui::{ @@ -10,8 +12,8 @@ use gpui::{ PromptLevel, Render, Styled, Task, WeakEntity, Window, actions, }; use language::{ - Anchor, Buffer, Capability, DiskState, File, LanguageRegistry, LineEnding, ReplicaId, Rope, - TextBuffer, + Anchor, Buffer, Capability, DiskState, File, LanguageRegistry, LineEnding, OffsetRangeExt as _, + ReplicaId, Rope, TextBuffer, }; use multi_buffer::PathKey; use project::{Project, WorktreeId, git_store::Repository}; @@ -202,33 +204,22 @@ impl CommitView { this.multibuffer.update(cx, |multibuffer, cx| { let snapshot = buffer.read(cx).snapshot(); let path = snapshot.file().unwrap().path().clone(); - - let hunks: Vec<_> = buffer_diff.read(cx).hunks(&snapshot, cx).collect(); - - let excerpt_ranges = if hunks.is_empty() { - vec![language::Point::zero()..snapshot.max_point()] - } else { - hunks - .into_iter() - .map(|hunk| { - let start = hunk.range.start.max(language::Point::new( - hunk.range.start.row.saturating_sub(3), - 0, - )); - let end_row = - (hunk.range.end.row + 3).min(snapshot.max_point().row); - let end = - language::Point::new(end_row, snapshot.line_len(end_row)); - start..end - }) - .collect() + let excerpt_ranges = { + let mut hunks = buffer_diff.read(cx).hunks(&snapshot, cx).peekable(); + if hunks.peek().is_none() { + vec![language::Point::zero()..snapshot.max_point()] + } else { + hunks + .map(|hunk| hunk.buffer_range.to_point(&snapshot)) + .collect::>() + } }; let _is_newly_added = multibuffer.set_excerpts_for_path( PathKey::with_sort_prefix(FILE_NAMESPACE_SORT_PREFIX, path), buffer, excerpt_ranges, - 0, + multibuffer_context_lines(cx), cx, ); multibuffer.add_diff(buffer_diff, cx); From 66c7bdf037c51659e5848e72bf27a77980e14df4 Mon Sep 17 00:00:00 2001 From: Cole Miller Date: Fri, 5 Dec 2025 21:20:14 -0500 Subject: [PATCH 092/621] git: For conflicted files, set project diff excerpts using conflicts only (#44263) It's just distracting having excerpts for all the successfully merged hunks. Release Notes: - git: The project diff now focuses on merge conflicts for files that have them. --- crates/git_ui/src/project_diff.rs | 89 +++++++++---------------------- 1 file changed, 24 insertions(+), 65 deletions(-) diff --git a/crates/git_ui/src/project_diff.rs b/crates/git_ui/src/project_diff.rs index f211483c5efeb14fd230def9235d82a1a79f49b4..e560bba0d36ad9901fffa9b5aad4dbd88e3108b6 100644 --- a/crates/git_ui/src/project_diff.rs +++ b/crates/git_ui/src/project_diff.rs @@ -34,7 +34,6 @@ use project::{ use settings::{Settings, SettingsStore}; use smol::future::yield_now; use std::any::{Any, TypeId}; -use std::ops::Range; use std::sync::Arc; use theme::ActiveTheme; use ui::{KeyBinding, Tooltip, prelude::*, vertical_divider}; @@ -500,23 +499,30 @@ impl ProjectDiff { let snapshot = buffer.read(cx).snapshot(); let diff_read = diff.read(cx); - let diff_hunk_ranges = diff_read - .hunks_intersecting_range( - Anchor::min_max_range_for_buffer(diff_read.buffer_id), - &snapshot, - cx, - ) - .map(|diff_hunk| diff_hunk.buffer_range); - let conflicts = conflict_addon - .conflict_set(snapshot.remote_id()) - .map(|conflict_set| conflict_set.read(cx).snapshot().conflicts) - .unwrap_or_default(); - let conflicts = conflicts.iter().map(|conflict| conflict.range.clone()); - - let excerpt_ranges = - merge_anchor_ranges(diff_hunk_ranges.into_iter(), conflicts, &snapshot) - .map(|range| range.to_point(&snapshot)) - .collect::>(); + + let excerpt_ranges = { + let diff_hunk_ranges = diff_read + .hunks_intersecting_range( + Anchor::min_max_range_for_buffer(diff_read.buffer_id), + &snapshot, + cx, + ) + .map(|diff_hunk| diff_hunk.buffer_range.to_point(&snapshot)); + let conflicts = conflict_addon + .conflict_set(snapshot.remote_id()) + .map(|conflict_set| conflict_set.read(cx).snapshot().conflicts) + .unwrap_or_default(); + let mut conflicts = conflicts + .iter() + .map(|conflict| conflict.range.to_point(&snapshot)) + .peekable(); + + if conflicts.peek().is_some() { + conflicts.collect::>() + } else { + diff_hunk_ranges.collect() + } + }; let (was_empty, is_excerpt_newly_added) = self.multibuffer.update(cx, |multibuffer, cx| { let was_empty = multibuffer.is_empty(); @@ -1544,53 +1550,6 @@ mod preview { } } -fn merge_anchor_ranges<'a>( - left: impl 'a + Iterator>, - right: impl 'a + Iterator>, - snapshot: &'a language::BufferSnapshot, -) -> impl 'a + Iterator> { - let mut left = left.fuse().peekable(); - let mut right = right.fuse().peekable(); - - std::iter::from_fn(move || { - let Some(left_range) = left.peek() else { - return right.next(); - }; - let Some(right_range) = right.peek() else { - return left.next(); - }; - - let mut next_range = if left_range.start.cmp(&right_range.start, snapshot).is_lt() { - left.next().unwrap() - } else { - right.next().unwrap() - }; - - // Extend the basic range while there's overlap with a range from either stream. - loop { - if let Some(left_range) = left - .peek() - .filter(|range| range.start.cmp(&next_range.end, snapshot).is_le()) - .cloned() - { - left.next(); - next_range.end = left_range.end; - } else if let Some(right_range) = right - .peek() - .filter(|range| range.start.cmp(&next_range.end, snapshot).is_le()) - .cloned() - { - right.next(); - next_range.end = right_range.end; - } else { - break; - } - } - - Some(next_range) - }) -} - struct BranchDiffAddon { branch_diff: Entity, } From 51b7d06a27780d007f8391ac7d05313611a27163 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Sat, 6 Dec 2025 08:35:18 +0100 Subject: [PATCH 093/621] Fix a typo: to -> two (#44272) Release Notes: - N/A --- docs/src/development/debuggers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/development/debuggers.md b/docs/src/development/debuggers.md index a5713f6c8aae1123e48ab6ab9f85f2147dfc7819..11f49390d41b89cfb1f527e1adabfd8b1b6d401a 100644 --- a/docs/src/development/debuggers.md +++ b/docs/src/development/debuggers.md @@ -5,7 +5,7 @@ ## Using Zed's built-in debugger -While the Zed project is open you can open the `New Process Modal` and select the `Debug` tab. There you can see to debug configurations to debug Zed with, one for GDB and one for LLDB. Select the configuration you want and Zed will build and launch the binary. +While the Zed project is open you can open the `New Process Modal` and select the `Debug` tab. There you can see two debug configurations to debug Zed with, one for GDB and one for LLDB. Select the configuration you want and Zed will build and launch the binary. Please note, GDB isn't supported on arm Macbooks From f08fd732a7ecbfe191563e2498a61a7ae75d5b05 Mon Sep 17 00:00:00 2001 From: Agus Zubiaga Date: Sat, 6 Dec 2025 07:08:44 -0300 Subject: [PATCH 094/621] Add experimental mercury edit prediction provider (#44256) Release Notes: - N/A --------- Co-authored-by: Ben Kunkle Co-authored-by: Max Brunsfeld --- assets/icons/inception.svg | 11 + crates/edit_prediction/src/cursor_excerpt.rs | 78 ++++ crates/edit_prediction/src/edit_prediction.rs | 37 +- .../src/edit_prediction_tests.rs | 2 +- crates/edit_prediction/src/mercury.rs | 340 ++++++++++++++++++ .../edit_prediction/src/open_ai_response.rs | 31 ++ crates/edit_prediction/src/zeta1.rs | 178 ++++++++- .../src/zeta1/input_excerpt.rs | 231 ------------ crates/edit_prediction/src/zeta2.rs | 35 +- crates/edit_prediction_cli/src/predict.rs | 5 +- .../src/edit_prediction_button.rs | 112 +++++- .../src/edit_prediction_ui.rs | 4 +- ...s => external_provider_api_token_modal.rs} | 33 +- crates/icons/src/icons.rs | 15 +- .../language_models/src/provider/open_ai.rs | 2 +- crates/open_ai/src/open_ai.rs | 3 +- .../settings/src/settings_content/language.rs | 8 + .../zed/src/zed/edit_prediction_registry.rs | 5 + 18 files changed, 808 insertions(+), 322 deletions(-) create mode 100644 assets/icons/inception.svg create mode 100644 crates/edit_prediction/src/cursor_excerpt.rs create mode 100644 crates/edit_prediction/src/mercury.rs create mode 100644 crates/edit_prediction/src/open_ai_response.rs delete mode 100644 crates/edit_prediction/src/zeta1/input_excerpt.rs rename crates/edit_prediction_ui/src/{sweep_api_token_modal.rs => external_provider_api_token_modal.rs} (72%) diff --git a/assets/icons/inception.svg b/assets/icons/inception.svg new file mode 100644 index 0000000000000000000000000000000000000000..77a96c0b390ab9f2fe89143c2a89ba916000fabc --- /dev/null +++ b/assets/icons/inception.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/crates/edit_prediction/src/cursor_excerpt.rs b/crates/edit_prediction/src/cursor_excerpt.rs new file mode 100644 index 0000000000000000000000000000000000000000..1f2f1d32ebcb2eaa151433bd49d275e0e2a3b817 --- /dev/null +++ b/crates/edit_prediction/src/cursor_excerpt.rs @@ -0,0 +1,78 @@ +use language::{BufferSnapshot, Point}; +use std::ops::Range; + +pub fn editable_and_context_ranges_for_cursor_position( + position: Point, + snapshot: &BufferSnapshot, + editable_region_token_limit: usize, + context_token_limit: usize, +) -> (Range, Range) { + let mut scope_range = position..position; + let mut remaining_edit_tokens = editable_region_token_limit; + + while let Some(parent) = snapshot.syntax_ancestor(scope_range.clone()) { + let parent_tokens = guess_token_count(parent.byte_range().len()); + let parent_point_range = Point::new( + parent.start_position().row as u32, + parent.start_position().column as u32, + ) + ..Point::new( + parent.end_position().row as u32, + parent.end_position().column as u32, + ); + if parent_point_range == scope_range { + break; + } else if parent_tokens <= editable_region_token_limit { + scope_range = parent_point_range; + remaining_edit_tokens = editable_region_token_limit - parent_tokens; + } else { + break; + } + } + + let editable_range = expand_range(snapshot, scope_range, remaining_edit_tokens); + let context_range = expand_range(snapshot, editable_range.clone(), context_token_limit); + (editable_range, context_range) +} + +fn expand_range( + snapshot: &BufferSnapshot, + range: Range, + mut remaining_tokens: usize, +) -> Range { + let mut expanded_range = range; + expanded_range.start.column = 0; + expanded_range.end.column = snapshot.line_len(expanded_range.end.row); + loop { + let mut expanded = false; + + if remaining_tokens > 0 && expanded_range.start.row > 0 { + expanded_range.start.row -= 1; + let line_tokens = + guess_token_count(snapshot.line_len(expanded_range.start.row) as usize); + remaining_tokens = remaining_tokens.saturating_sub(line_tokens); + expanded = true; + } + + if remaining_tokens > 0 && expanded_range.end.row < snapshot.max_point().row { + expanded_range.end.row += 1; + expanded_range.end.column = snapshot.line_len(expanded_range.end.row); + let line_tokens = guess_token_count(expanded_range.end.column as usize); + remaining_tokens = remaining_tokens.saturating_sub(line_tokens); + expanded = true; + } + + if !expanded { + break; + } + } + expanded_range +} + +/// Typical number of string bytes per token for the purposes of limiting model input. This is +/// intentionally low to err on the side of underestimating limits. +pub(crate) const BYTES_PER_TOKEN_GUESS: usize = 3; + +pub fn guess_token_count(bytes: usize) -> usize { + bytes / BYTES_PER_TOKEN_GUESS +} diff --git a/crates/edit_prediction/src/edit_prediction.rs b/crates/edit_prediction/src/edit_prediction.rs index ea8f0af7e16dedd30a86284af5386829053d7fab..141fff3063b83d7e0003fddd6b4eba2d213d5fd5 100644 --- a/crates/edit_prediction/src/edit_prediction.rs +++ b/crates/edit_prediction/src/edit_prediction.rs @@ -51,8 +51,11 @@ use thiserror::Error; use util::{RangeExt as _, ResultExt as _}; use workspace::notifications::{ErrorMessagePrompt, NotificationId, show_app_notification}; +mod cursor_excerpt; mod license_detection; +pub mod mercury; mod onboarding_modal; +pub mod open_ai_response; mod prediction; pub mod sweep_ai; pub mod udiff; @@ -65,6 +68,7 @@ pub mod zeta2; mod edit_prediction_tests; use crate::license_detection::LicenseDetectionWatcher; +use crate::mercury::Mercury; use crate::onboarding_modal::ZedPredictModal; pub use crate::prediction::EditPrediction; pub use crate::prediction::EditPredictionId; @@ -96,6 +100,12 @@ impl FeatureFlag for SweepFeatureFlag { const NAME: &str = "sweep-ai"; } +pub struct MercuryFeatureFlag; + +impl FeatureFlag for MercuryFeatureFlag { + const NAME: &str = "mercury"; +} + pub const DEFAULT_OPTIONS: ZetaOptions = ZetaOptions { context: EditPredictionExcerptOptions { max_bytes: 512, @@ -157,6 +167,7 @@ pub struct EditPredictionStore { eval_cache: Option>, edit_prediction_model: EditPredictionModel, pub sweep_ai: SweepAi, + pub mercury: Mercury, data_collection_choice: DataCollectionChoice, reject_predictions_tx: mpsc::UnboundedSender, shown_predictions: VecDeque, @@ -169,6 +180,7 @@ pub enum EditPredictionModel { Zeta1, Zeta2, Sweep, + Mercury, } #[derive(Debug, Clone, PartialEq)] @@ -474,6 +486,7 @@ impl EditPredictionStore { eval_cache: None, edit_prediction_model: EditPredictionModel::Zeta2, sweep_ai: SweepAi::new(cx), + mercury: Mercury::new(cx), data_collection_choice, reject_predictions_tx: reject_tx, rated_predictions: Default::default(), @@ -509,6 +522,15 @@ impl EditPredictionStore { .is_some() } + pub fn has_mercury_api_token(&self) -> bool { + self.mercury + .api_token + .clone() + .now_or_never() + .flatten() + .is_some() + } + #[cfg(feature = "eval-support")] pub fn with_eval_cache(&mut self, cache: Arc) { self.eval_cache = Some(cache); @@ -868,7 +890,7 @@ impl EditPredictionStore { fn accept_current_prediction(&mut self, project: &Entity, cx: &mut Context) { match self.edit_prediction_model { EditPredictionModel::Zeta1 | EditPredictionModel::Zeta2 => {} - EditPredictionModel::Sweep => return, + EditPredictionModel::Sweep | EditPredictionModel::Mercury => return, } let Some(project_state) = self.projects.get_mut(&project.entity_id()) else { @@ -1013,7 +1035,7 @@ impl EditPredictionStore { ) { match self.edit_prediction_model { EditPredictionModel::Zeta1 | EditPredictionModel::Zeta2 => {} - EditPredictionModel::Sweep => return, + EditPredictionModel::Sweep | EditPredictionModel::Mercury => return, } self.reject_predictions_tx @@ -1373,6 +1395,17 @@ impl EditPredictionStore { diagnostic_search_range.clone(), cx, ), + EditPredictionModel::Mercury => self.mercury.request_prediction( + &project, + &active_buffer, + snapshot.clone(), + position, + events, + &project_state.recent_paths, + related_files, + diagnostic_search_range.clone(), + cx, + ), }; cx.spawn(async move |this, cx| { diff --git a/crates/edit_prediction/src/edit_prediction_tests.rs b/crates/edit_prediction/src/edit_prediction_tests.rs index 8d5bad9ed8990769fd512ecfe523cf8d79aebca6..0b7e289bb32b5a10c32a4bd34f118d7cb6c7d43c 100644 --- a/crates/edit_prediction/src/edit_prediction_tests.rs +++ b/crates/edit_prediction/src/edit_prediction_tests.rs @@ -1620,7 +1620,7 @@ async fn test_no_data_collection_for_events_in_uncollectable_buffers(cx: &mut Te buffer.edit( [( 0..0, - " ".repeat(MAX_EVENT_TOKENS * zeta1::BYTES_PER_TOKEN_GUESS), + " ".repeat(MAX_EVENT_TOKENS * cursor_excerpt::BYTES_PER_TOKEN_GUESS), )], None, cx, diff --git a/crates/edit_prediction/src/mercury.rs b/crates/edit_prediction/src/mercury.rs new file mode 100644 index 0000000000000000000000000000000000000000..40c0fdfac021f937df5172fd423d3b6bfc5f8146 --- /dev/null +++ b/crates/edit_prediction/src/mercury.rs @@ -0,0 +1,340 @@ +use anyhow::{Context as _, Result}; +use cloud_llm_client::predict_edits_v3::Event; +use credentials_provider::CredentialsProvider; +use edit_prediction_context::RelatedFile; +use futures::{AsyncReadExt as _, FutureExt, future::Shared}; +use gpui::{ + App, AppContext as _, Entity, Task, + http_client::{self, AsyncBody, Method}, +}; +use language::{Buffer, BufferSnapshot, OffsetRangeExt as _, Point, ToPoint as _}; +use project::{Project, ProjectPath}; +use std::{ + collections::VecDeque, fmt::Write as _, mem, ops::Range, path::Path, sync::Arc, time::Instant, +}; + +use crate::{ + EditPredictionId, EditPredictionInputs, open_ai_response::text_from_response, + prediction::EditPredictionResult, +}; + +const MERCURY_API_URL: &str = "https://api.inceptionlabs.ai/v1/edit/completions"; +const MAX_CONTEXT_TOKENS: usize = 150; +const MAX_REWRITE_TOKENS: usize = 350; + +pub struct Mercury { + pub api_token: Shared>>, +} + +impl Mercury { + pub fn new(cx: &App) -> Self { + Mercury { + api_token: load_api_token(cx).shared(), + } + } + + pub fn set_api_token(&mut self, api_token: Option, cx: &mut App) -> Task> { + self.api_token = Task::ready(api_token.clone()).shared(); + store_api_token_in_keychain(api_token, cx) + } + + pub fn request_prediction( + &self, + _project: &Entity, + active_buffer: &Entity, + snapshot: BufferSnapshot, + position: language::Anchor, + events: Vec>, + _recent_paths: &VecDeque, + related_files: Vec, + _diagnostic_search_range: Range, + cx: &mut App, + ) -> Task>> { + let Some(api_token) = self.api_token.clone().now_or_never().flatten() else { + return Task::ready(Ok(None)); + }; + let full_path: Arc = snapshot + .file() + .map(|file| file.full_path(cx)) + .unwrap_or_else(|| "untitled".into()) + .into(); + + let http_client = cx.http_client(); + let cursor_point = position.to_point(&snapshot); + let buffer_snapshotted_at = Instant::now(); + + let result = cx.background_spawn(async move { + let (editable_range, context_range) = + crate::cursor_excerpt::editable_and_context_ranges_for_cursor_position( + cursor_point, + &snapshot, + MAX_CONTEXT_TOKENS, + MAX_REWRITE_TOKENS, + ); + + let offset_range = editable_range.to_offset(&snapshot); + let prompt = build_prompt( + &events, + &related_files, + &snapshot, + full_path.as_ref(), + cursor_point, + editable_range, + context_range.clone(), + ); + + let inputs = EditPredictionInputs { + events: events, + included_files: vec![cloud_llm_client::predict_edits_v3::RelatedFile { + path: full_path.clone(), + max_row: cloud_llm_client::predict_edits_v3::Line(snapshot.max_point().row), + excerpts: vec![cloud_llm_client::predict_edits_v3::Excerpt { + start_line: cloud_llm_client::predict_edits_v3::Line( + context_range.start.row, + ), + text: snapshot + .text_for_range(context_range.clone()) + .collect::() + .into(), + }], + }], + cursor_point: cloud_llm_client::predict_edits_v3::Point { + column: cursor_point.column, + line: cloud_llm_client::predict_edits_v3::Line(cursor_point.row), + }, + cursor_path: full_path.clone(), + }; + + let request_body = open_ai::Request { + model: "mercury-coder".into(), + messages: vec![open_ai::RequestMessage::User { + content: open_ai::MessageContent::Plain(prompt), + }], + stream: false, + max_completion_tokens: None, + stop: vec![], + temperature: None, + tool_choice: None, + parallel_tool_calls: None, + tools: vec![], + prompt_cache_key: None, + reasoning_effort: None, + }; + + let buf = serde_json::to_vec(&request_body)?; + let body: AsyncBody = buf.into(); + + let request = http_client::Request::builder() + .uri(MERCURY_API_URL) + .header("Content-Type", "application/json") + .header("Authorization", format!("Bearer {}", api_token)) + .header("Connection", "keep-alive") + .method(Method::POST) + .body(body) + .context("Failed to create request")?; + + let mut response = http_client + .send(request) + .await + .context("Failed to send request")?; + + let mut body: Vec = Vec::new(); + response + .body_mut() + .read_to_end(&mut body) + .await + .context("Failed to read response body")?; + + let response_received_at = Instant::now(); + if !response.status().is_success() { + anyhow::bail!( + "Request failed with status: {:?}\nBody: {}", + response.status(), + String::from_utf8_lossy(&body), + ); + }; + + let mut response: open_ai::Response = + serde_json::from_slice(&body).context("Failed to parse response")?; + + let id = mem::take(&mut response.id); + let response_str = text_from_response(response).unwrap_or_default(); + + let response_str = response_str.strip_prefix("```\n").unwrap_or(&response_str); + let response_str = response_str.strip_suffix("\n```").unwrap_or(&response_str); + + let mut edits = Vec::new(); + const NO_PREDICTION_OUTPUT: &str = "None"; + + if response_str != NO_PREDICTION_OUTPUT { + let old_text = snapshot + .text_for_range(offset_range.clone()) + .collect::(); + edits.extend( + language::text_diff(&old_text, &response_str) + .into_iter() + .map(|(range, text)| { + ( + snapshot.anchor_after(offset_range.start + range.start) + ..snapshot.anchor_before(offset_range.start + range.end), + text, + ) + }), + ); + } + + anyhow::Ok((id, edits, snapshot, response_received_at, inputs)) + }); + + let buffer = active_buffer.clone(); + + cx.spawn(async move |cx| { + let (id, edits, old_snapshot, response_received_at, inputs) = + result.await.context("Mercury edit prediction failed")?; + anyhow::Ok(Some( + EditPredictionResult::new( + EditPredictionId(id.into()), + &buffer, + &old_snapshot, + edits.into(), + buffer_snapshotted_at, + response_received_at, + inputs, + cx, + ) + .await, + )) + }) + } +} + +fn build_prompt( + events: &[Arc], + related_files: &[RelatedFile], + cursor_buffer: &BufferSnapshot, + cursor_buffer_path: &Path, + cursor_point: Point, + editable_range: Range, + context_range: Range, +) -> String { + const RECENTLY_VIEWED_SNIPPETS_START: &str = "<|recently_viewed_code_snippets|>\n"; + const RECENTLY_VIEWED_SNIPPETS_END: &str = "<|/recently_viewed_code_snippets|>\n"; + const RECENTLY_VIEWED_SNIPPET_START: &str = "<|recently_viewed_code_snippet|>\n"; + const RECENTLY_VIEWED_SNIPPET_END: &str = "<|/recently_viewed_code_snippet|>\n"; + const CURRENT_FILE_CONTENT_START: &str = "<|current_file_content|>\n"; + const CURRENT_FILE_CONTENT_END: &str = "<|/current_file_content|>\n"; + const CODE_TO_EDIT_START: &str = "<|code_to_edit|>\n"; + const CODE_TO_EDIT_END: &str = "<|/code_to_edit|>\n"; + const EDIT_DIFF_HISTORY_START: &str = "<|edit_diff_history|>\n"; + const EDIT_DIFF_HISTORY_END: &str = "<|/edit_diff_history|>\n"; + const CURSOR_TAG: &str = "<|cursor|>"; + const CODE_SNIPPET_FILE_PATH_PREFIX: &str = "code_snippet_file_path: "; + const CURRENT_FILE_PATH_PREFIX: &str = "current_file_path: "; + + let mut prompt = String::new(); + + push_delimited( + &mut prompt, + RECENTLY_VIEWED_SNIPPETS_START..RECENTLY_VIEWED_SNIPPETS_END, + |prompt| { + for related_file in related_files { + for related_excerpt in &related_file.excerpts { + push_delimited( + prompt, + RECENTLY_VIEWED_SNIPPET_START..RECENTLY_VIEWED_SNIPPET_END, + |prompt| { + prompt.push_str(CODE_SNIPPET_FILE_PATH_PREFIX); + prompt.push_str(related_file.path.path.as_unix_str()); + prompt.push('\n'); + prompt.push_str(&related_excerpt.text.to_string()); + }, + ); + } + } + }, + ); + + push_delimited( + &mut prompt, + CURRENT_FILE_CONTENT_START..CURRENT_FILE_CONTENT_END, + |prompt| { + prompt.push_str(CURRENT_FILE_PATH_PREFIX); + prompt.push_str(cursor_buffer_path.as_os_str().to_string_lossy().as_ref()); + prompt.push('\n'); + + let prefix_range = context_range.start..editable_range.start; + let suffix_range = editable_range.end..context_range.end; + + prompt.extend(cursor_buffer.text_for_range(prefix_range)); + push_delimited(prompt, CODE_TO_EDIT_START..CODE_TO_EDIT_END, |prompt| { + let range_before_cursor = editable_range.start..cursor_point; + let range_after_cursor = cursor_point..editable_range.end; + prompt.extend(cursor_buffer.text_for_range(range_before_cursor)); + prompt.push_str(CURSOR_TAG); + prompt.extend(cursor_buffer.text_for_range(range_after_cursor)); + }); + prompt.extend(cursor_buffer.text_for_range(suffix_range)); + }, + ); + + push_delimited( + &mut prompt, + EDIT_DIFF_HISTORY_START..EDIT_DIFF_HISTORY_END, + |prompt| { + for event in events { + writeln!(prompt, "{event}").unwrap(); + } + }, + ); + + prompt +} + +fn push_delimited(prompt: &mut String, delimiters: Range<&str>, cb: impl FnOnce(&mut String)) { + prompt.push_str(delimiters.start); + cb(prompt); + prompt.push_str(delimiters.end); +} + +pub const MERCURY_CREDENTIALS_URL: &str = "https://api.inceptionlabs.ai/v1/edit/completions"; +pub const MERCURY_CREDENTIALS_USERNAME: &str = "mercury-api-token"; + +pub fn load_api_token(cx: &App) -> Task> { + if let Some(api_token) = std::env::var("MERCURY_AI_TOKEN") + .ok() + .filter(|value| !value.is_empty()) + { + return Task::ready(Some(api_token)); + } + let credentials_provider = ::global(cx); + cx.spawn(async move |cx| { + let (_, credentials) = credentials_provider + .read_credentials(MERCURY_CREDENTIALS_URL, &cx) + .await + .ok()??; + String::from_utf8(credentials).ok() + }) +} + +fn store_api_token_in_keychain(api_token: Option, cx: &App) -> Task> { + let credentials_provider = ::global(cx); + + cx.spawn(async move |cx| { + if let Some(api_token) = api_token { + credentials_provider + .write_credentials( + MERCURY_CREDENTIALS_URL, + MERCURY_CREDENTIALS_USERNAME, + api_token.as_bytes(), + cx, + ) + .await + .context("Failed to save Mercury API token to system keychain") + } else { + credentials_provider + .delete_credentials(MERCURY_CREDENTIALS_URL, cx) + .await + .context("Failed to delete Mercury API token from system keychain") + } + }) +} diff --git a/crates/edit_prediction/src/open_ai_response.rs b/crates/edit_prediction/src/open_ai_response.rs new file mode 100644 index 0000000000000000000000000000000000000000..c7e3350936dd89c89849130ba279ad2914dd2bd8 --- /dev/null +++ b/crates/edit_prediction/src/open_ai_response.rs @@ -0,0 +1,31 @@ +pub fn text_from_response(mut res: open_ai::Response) -> Option { + let choice = res.choices.pop()?; + let output_text = match choice.message { + open_ai::RequestMessage::Assistant { + content: Some(open_ai::MessageContent::Plain(content)), + .. + } => content, + open_ai::RequestMessage::Assistant { + content: Some(open_ai::MessageContent::Multipart(mut content)), + .. + } => { + if content.is_empty() { + log::error!("No output from Baseten completion response"); + return None; + } + + match content.remove(0) { + open_ai::MessagePart::Text { text } => text, + open_ai::MessagePart::Image { .. } => { + log::error!("Expected text, got an image"); + return None; + } + } + } + _ => { + log::error!("Invalid response message: {:?}", choice.message); + return None; + } + }; + Some(output_text) +} diff --git a/crates/edit_prediction/src/zeta1.rs b/crates/edit_prediction/src/zeta1.rs index 06248603464563db12fa55a90c9c0bccf153c5f4..20f70421810c6d1678f844d1ec4c968b1ca96678 100644 --- a/crates/edit_prediction/src/zeta1.rs +++ b/crates/edit_prediction/src/zeta1.rs @@ -1,9 +1,8 @@ -mod input_excerpt; - use std::{fmt::Write, ops::Range, path::Path, sync::Arc, time::Instant}; use crate::{ EditPredictionId, EditPredictionStore, ZedUpdateRequiredError, + cursor_excerpt::{editable_and_context_ranges_for_cursor_position, guess_token_count}, prediction::{EditPredictionInputs, EditPredictionResult}, }; use anyhow::{Context as _, Result}; @@ -12,7 +11,6 @@ use cloud_llm_client::{ predict_edits_v3::Event, }; use gpui::{App, AppContext as _, AsyncApp, Context, Entity, SharedString, Task}; -use input_excerpt::excerpt_for_cursor_position; use language::{ Anchor, Buffer, BufferSnapshot, OffsetRangeExt as _, Point, ToPoint as _, text_diff, }; @@ -495,10 +493,174 @@ pub fn format_event(event: &Event) -> String { } } -/// Typical number of string bytes per token for the purposes of limiting model input. This is -/// intentionally low to err on the side of underestimating limits. -pub(crate) const BYTES_PER_TOKEN_GUESS: usize = 3; +#[derive(Debug)] +pub struct InputExcerpt { + pub context_range: Range, + pub editable_range: Range, + pub prompt: String, +} + +pub fn excerpt_for_cursor_position( + position: Point, + path: &str, + snapshot: &BufferSnapshot, + editable_region_token_limit: usize, + context_token_limit: usize, +) -> InputExcerpt { + let (editable_range, context_range) = editable_and_context_ranges_for_cursor_position( + position, + snapshot, + editable_region_token_limit, + context_token_limit, + ); + + let mut prompt = String::new(); + + writeln!(&mut prompt, "```{path}").unwrap(); + if context_range.start == Point::zero() { + writeln!(&mut prompt, "{START_OF_FILE_MARKER}").unwrap(); + } + + for chunk in snapshot.chunks(context_range.start..editable_range.start, false) { + prompt.push_str(chunk.text); + } + + push_editable_range(position, snapshot, editable_range.clone(), &mut prompt); + + for chunk in snapshot.chunks(editable_range.end..context_range.end, false) { + prompt.push_str(chunk.text); + } + write!(prompt, "\n```").unwrap(); + + InputExcerpt { + context_range, + editable_range, + prompt, + } +} + +fn push_editable_range( + cursor_position: Point, + snapshot: &BufferSnapshot, + editable_range: Range, + prompt: &mut String, +) { + writeln!(prompt, "{EDITABLE_REGION_START_MARKER}").unwrap(); + for chunk in snapshot.chunks(editable_range.start..cursor_position, false) { + prompt.push_str(chunk.text); + } + prompt.push_str(CURSOR_MARKER); + for chunk in snapshot.chunks(cursor_position..editable_range.end, false) { + prompt.push_str(chunk.text); + } + write!(prompt, "\n{EDITABLE_REGION_END_MARKER}").unwrap(); +} + +#[cfg(test)] +mod tests { + use super::*; + use gpui::{App, AppContext}; + use indoc::indoc; + use language::{Buffer, Language, LanguageConfig, LanguageMatcher, tree_sitter_rust}; + use std::sync::Arc; + + #[gpui::test] + fn test_excerpt_for_cursor_position(cx: &mut App) { + let text = indoc! {r#" + fn foo() { + let x = 42; + println!("Hello, world!"); + } + + fn bar() { + let x = 42; + let mut sum = 0; + for i in 0..x { + sum += i; + } + println!("Sum: {}", sum); + return sum; + } + + fn generate_random_numbers() -> Vec { + let mut rng = rand::thread_rng(); + let mut numbers = Vec::new(); + for _ in 0..5 { + numbers.push(rng.random_range(1..101)); + } + numbers + } + "#}; + let buffer = cx.new(|cx| Buffer::local(text, cx).with_language(Arc::new(rust_lang()), cx)); + let snapshot = buffer.read(cx).snapshot(); + + // Ensure we try to fit the largest possible syntax scope, resorting to line-based expansion + // when a larger scope doesn't fit the editable region. + let excerpt = excerpt_for_cursor_position(Point::new(12, 5), "main.rs", &snapshot, 50, 32); + assert_eq!( + excerpt.prompt, + indoc! {r#" + ```main.rs + let x = 42; + println!("Hello, world!"); + <|editable_region_start|> + } + + fn bar() { + let x = 42; + let mut sum = 0; + for i in 0..x { + sum += i; + } + println!("Sum: {}", sum); + r<|user_cursor_is_here|>eturn sum; + } -fn guess_token_count(bytes: usize) -> usize { - bytes / BYTES_PER_TOKEN_GUESS + fn generate_random_numbers() -> Vec { + <|editable_region_end|> + let mut rng = rand::thread_rng(); + let mut numbers = Vec::new(); + ```"#} + ); + + // The `bar` function won't fit within the editable region, so we resort to line-based expansion. + let excerpt = excerpt_for_cursor_position(Point::new(12, 5), "main.rs", &snapshot, 40, 32); + assert_eq!( + excerpt.prompt, + indoc! {r#" + ```main.rs + fn bar() { + let x = 42; + let mut sum = 0; + <|editable_region_start|> + for i in 0..x { + sum += i; + } + println!("Sum: {}", sum); + r<|user_cursor_is_here|>eturn sum; + } + + fn generate_random_numbers() -> Vec { + let mut rng = rand::thread_rng(); + <|editable_region_end|> + let mut numbers = Vec::new(); + for _ in 0..5 { + numbers.push(rng.random_range(1..101)); + ```"#} + ); + } + + fn rust_lang() -> Language { + Language::new( + LanguageConfig { + name: "Rust".into(), + matcher: LanguageMatcher { + path_suffixes: vec!["rs".to_string()], + ..Default::default() + }, + ..Default::default() + }, + Some(tree_sitter_rust::LANGUAGE.into()), + ) + } } diff --git a/crates/edit_prediction/src/zeta1/input_excerpt.rs b/crates/edit_prediction/src/zeta1/input_excerpt.rs deleted file mode 100644 index 853d74da463c19de4f1d3915cb703a53b6c43c61..0000000000000000000000000000000000000000 --- a/crates/edit_prediction/src/zeta1/input_excerpt.rs +++ /dev/null @@ -1,231 +0,0 @@ -use super::{ - CURSOR_MARKER, EDITABLE_REGION_END_MARKER, EDITABLE_REGION_START_MARKER, START_OF_FILE_MARKER, - guess_token_count, -}; -use language::{BufferSnapshot, Point}; -use std::{fmt::Write, ops::Range}; - -#[derive(Debug)] -pub struct InputExcerpt { - pub context_range: Range, - pub editable_range: Range, - pub prompt: String, -} - -pub fn excerpt_for_cursor_position( - position: Point, - path: &str, - snapshot: &BufferSnapshot, - editable_region_token_limit: usize, - context_token_limit: usize, -) -> InputExcerpt { - let mut scope_range = position..position; - let mut remaining_edit_tokens = editable_region_token_limit; - - while let Some(parent) = snapshot.syntax_ancestor(scope_range.clone()) { - let parent_tokens = guess_token_count(parent.byte_range().len()); - let parent_point_range = Point::new( - parent.start_position().row as u32, - parent.start_position().column as u32, - ) - ..Point::new( - parent.end_position().row as u32, - parent.end_position().column as u32, - ); - if parent_point_range == scope_range { - break; - } else if parent_tokens <= editable_region_token_limit { - scope_range = parent_point_range; - remaining_edit_tokens = editable_region_token_limit - parent_tokens; - } else { - break; - } - } - - let editable_range = expand_range(snapshot, scope_range, remaining_edit_tokens); - let context_range = expand_range(snapshot, editable_range.clone(), context_token_limit); - - let mut prompt = String::new(); - - writeln!(&mut prompt, "```{path}").unwrap(); - if context_range.start == Point::zero() { - writeln!(&mut prompt, "{START_OF_FILE_MARKER}").unwrap(); - } - - for chunk in snapshot.chunks(context_range.start..editable_range.start, false) { - prompt.push_str(chunk.text); - } - - push_editable_range(position, snapshot, editable_range.clone(), &mut prompt); - - for chunk in snapshot.chunks(editable_range.end..context_range.end, false) { - prompt.push_str(chunk.text); - } - write!(prompt, "\n```").unwrap(); - - InputExcerpt { - context_range, - editable_range, - prompt, - } -} - -fn push_editable_range( - cursor_position: Point, - snapshot: &BufferSnapshot, - editable_range: Range, - prompt: &mut String, -) { - writeln!(prompt, "{EDITABLE_REGION_START_MARKER}").unwrap(); - for chunk in snapshot.chunks(editable_range.start..cursor_position, false) { - prompt.push_str(chunk.text); - } - prompt.push_str(CURSOR_MARKER); - for chunk in snapshot.chunks(cursor_position..editable_range.end, false) { - prompt.push_str(chunk.text); - } - write!(prompt, "\n{EDITABLE_REGION_END_MARKER}").unwrap(); -} - -fn expand_range( - snapshot: &BufferSnapshot, - range: Range, - mut remaining_tokens: usize, -) -> Range { - let mut expanded_range = range; - expanded_range.start.column = 0; - expanded_range.end.column = snapshot.line_len(expanded_range.end.row); - loop { - let mut expanded = false; - - if remaining_tokens > 0 && expanded_range.start.row > 0 { - expanded_range.start.row -= 1; - let line_tokens = - guess_token_count(snapshot.line_len(expanded_range.start.row) as usize); - remaining_tokens = remaining_tokens.saturating_sub(line_tokens); - expanded = true; - } - - if remaining_tokens > 0 && expanded_range.end.row < snapshot.max_point().row { - expanded_range.end.row += 1; - expanded_range.end.column = snapshot.line_len(expanded_range.end.row); - let line_tokens = guess_token_count(expanded_range.end.column as usize); - remaining_tokens = remaining_tokens.saturating_sub(line_tokens); - expanded = true; - } - - if !expanded { - break; - } - } - expanded_range -} - -#[cfg(test)] -mod tests { - use super::*; - use gpui::{App, AppContext}; - use indoc::indoc; - use language::{Buffer, Language, LanguageConfig, LanguageMatcher, tree_sitter_rust}; - use std::sync::Arc; - - #[gpui::test] - fn test_excerpt_for_cursor_position(cx: &mut App) { - let text = indoc! {r#" - fn foo() { - let x = 42; - println!("Hello, world!"); - } - - fn bar() { - let x = 42; - let mut sum = 0; - for i in 0..x { - sum += i; - } - println!("Sum: {}", sum); - return sum; - } - - fn generate_random_numbers() -> Vec { - let mut rng = rand::thread_rng(); - let mut numbers = Vec::new(); - for _ in 0..5 { - numbers.push(rng.random_range(1..101)); - } - numbers - } - "#}; - let buffer = cx.new(|cx| Buffer::local(text, cx).with_language(Arc::new(rust_lang()), cx)); - let snapshot = buffer.read(cx).snapshot(); - - // Ensure we try to fit the largest possible syntax scope, resorting to line-based expansion - // when a larger scope doesn't fit the editable region. - let excerpt = excerpt_for_cursor_position(Point::new(12, 5), "main.rs", &snapshot, 50, 32); - assert_eq!( - excerpt.prompt, - indoc! {r#" - ```main.rs - let x = 42; - println!("Hello, world!"); - <|editable_region_start|> - } - - fn bar() { - let x = 42; - let mut sum = 0; - for i in 0..x { - sum += i; - } - println!("Sum: {}", sum); - r<|user_cursor_is_here|>eturn sum; - } - - fn generate_random_numbers() -> Vec { - <|editable_region_end|> - let mut rng = rand::thread_rng(); - let mut numbers = Vec::new(); - ```"#} - ); - - // The `bar` function won't fit within the editable region, so we resort to line-based expansion. - let excerpt = excerpt_for_cursor_position(Point::new(12, 5), "main.rs", &snapshot, 40, 32); - assert_eq!( - excerpt.prompt, - indoc! {r#" - ```main.rs - fn bar() { - let x = 42; - let mut sum = 0; - <|editable_region_start|> - for i in 0..x { - sum += i; - } - println!("Sum: {}", sum); - r<|user_cursor_is_here|>eturn sum; - } - - fn generate_random_numbers() -> Vec { - let mut rng = rand::thread_rng(); - <|editable_region_end|> - let mut numbers = Vec::new(); - for _ in 0..5 { - numbers.push(rng.random_range(1..101)); - ```"#} - ); - } - - fn rust_lang() -> Language { - Language::new( - LanguageConfig { - name: "Rust".into(), - matcher: LanguageMatcher { - path_suffixes: vec!["rs".to_string()], - ..Default::default() - }, - ..Default::default() - }, - Some(tree_sitter_rust::LANGUAGE.into()), - ) - } -} diff --git a/crates/edit_prediction/src/zeta2.rs b/crates/edit_prediction/src/zeta2.rs index 4808f38fc529b1c34212dd0198d15fb03a0baddf..e542bc7e86e6e381766bbedac6a15f431e0693f1 100644 --- a/crates/edit_prediction/src/zeta2.rs +++ b/crates/edit_prediction/src/zeta2.rs @@ -1,5 +1,6 @@ #[cfg(feature = "eval-support")] use crate::EvalCacheEntryKind; +use crate::open_ai_response::text_from_response; use crate::prediction::EditPredictionResult; use crate::{ DebugEvent, EDIT_PREDICTIONS_MODEL_ID, EditPredictionId, EditPredictionInputs, @@ -199,7 +200,7 @@ pub fn request_prediction_with_zeta2( stream: false, max_completion_tokens: None, stop: generation_params.stop.unwrap_or_default(), - temperature: generation_params.temperature.unwrap_or(0.7), + temperature: generation_params.temperature.or(Some(0.7)), tool_choice: None, parallel_tool_calls: None, tools: vec![], @@ -324,35 +325,3 @@ pub fn request_prediction_with_zeta2( )) }) } - -pub fn text_from_response(mut res: open_ai::Response) -> Option { - let choice = res.choices.pop()?; - let output_text = match choice.message { - open_ai::RequestMessage::Assistant { - content: Some(open_ai::MessageContent::Plain(content)), - .. - } => content, - open_ai::RequestMessage::Assistant { - content: Some(open_ai::MessageContent::Multipart(mut content)), - .. - } => { - if content.is_empty() { - log::error!("No output from Baseten completion response"); - return None; - } - - match content.remove(0) { - open_ai::MessagePart::Text { text } => text, - open_ai::MessagePart::Image { .. } => { - log::error!("Expected text, got an image"); - return None; - } - } - } - _ => { - log::error!("Invalid response message: {:?}", choice.message); - return None; - } - }; - Some(output_text) -} diff --git a/crates/edit_prediction_cli/src/predict.rs b/crates/edit_prediction_cli/src/predict.rs index db1fed70d82a1a19713dfe54dfd6cea2bfa03d5d..74e939b887ce15790993ec15f5973c7f5fd01866 100644 --- a/crates/edit_prediction_cli/src/predict.rs +++ b/crates/edit_prediction_cli/src/predict.rs @@ -198,8 +198,9 @@ pub async fn perform_predict( let response = request.response_rx.await?.0.map_err(|err| anyhow!(err))?; - let response = edit_prediction::zeta2::text_from_response(response) - .unwrap_or_default(); + let response = + edit_prediction::open_ai_response::text_from_response(response) + .unwrap_or_default(); let prediction_finished_at = Instant::now(); fs::write(example_run_dir.join("prediction_response.md"), &response)?; diff --git a/crates/edit_prediction_ui/src/edit_prediction_button.rs b/crates/edit_prediction_ui/src/edit_prediction_button.rs index dd3ebab42029f5adb7570b71ae0cd662aff3328e..04c7614689c5fdc076ab0aa9c4b4fe7d68e2f582 100644 --- a/crates/edit_prediction_ui/src/edit_prediction_button.rs +++ b/crates/edit_prediction_ui/src/edit_prediction_button.rs @@ -3,7 +3,7 @@ use client::{Client, UserStore, zed_urls}; use cloud_llm_client::UsageLimit; use codestral::CodestralEditPredictionDelegate; use copilot::{Copilot, Status}; -use edit_prediction::{SweepFeatureFlag, Zeta2FeatureFlag}; +use edit_prediction::{MercuryFeatureFlag, SweepFeatureFlag, Zeta2FeatureFlag}; use edit_prediction_types::EditPredictionDelegateHandle; use editor::{ Editor, MultiBufferOffset, SelectionEffects, actions::ShowEditPrediction, scroll::Autoscroll, @@ -23,6 +23,7 @@ use language::{ use project::DisableAiSettings; use regex::Regex; use settings::{ + EXPERIMENTAL_MERCURY_EDIT_PREDICTION_PROVIDER_NAME, EXPERIMENTAL_SWEEP_EDIT_PREDICTION_PROVIDER_NAME, EXPERIMENTAL_ZETA2_EDIT_PREDICTION_PROVIDER_NAME, Settings, SettingsStore, update_settings_file, @@ -44,7 +45,7 @@ use workspace::{ use zed_actions::OpenBrowser; use crate::{ - RatePredictions, SweepApiKeyModal, + ExternalProviderApiKeyModal, RatePredictions, rate_prediction_modal::PredictEditsRatePredictionsFeatureFlag, }; @@ -311,21 +312,31 @@ impl Render for EditPredictionButton { provider @ (EditPredictionProvider::Experimental(_) | EditPredictionProvider::Zed) => { let enabled = self.editor_enabled.unwrap_or(true); - let is_sweep = matches!( - provider, - EditPredictionProvider::Experimental( - EXPERIMENTAL_SWEEP_EDIT_PREDICTION_PROVIDER_NAME - ) - ); - - let sweep_missing_token = is_sweep - && !edit_prediction::EditPredictionStore::try_global(cx) - .map_or(false, |ep_store| ep_store.read(cx).has_sweep_api_token()); + let ep_icon; + let mut missing_token = false; - let ep_icon = match (is_sweep, enabled) { - (true, _) => IconName::SweepAi, - (false, true) => IconName::ZedPredict, - (false, false) => IconName::ZedPredictDisabled, + match provider { + EditPredictionProvider::Experimental( + EXPERIMENTAL_SWEEP_EDIT_PREDICTION_PROVIDER_NAME, + ) => { + ep_icon = IconName::SweepAi; + missing_token = edit_prediction::EditPredictionStore::try_global(cx) + .is_some_and(|ep_store| !ep_store.read(cx).has_sweep_api_token()); + } + EditPredictionProvider::Experimental( + EXPERIMENTAL_MERCURY_EDIT_PREDICTION_PROVIDER_NAME, + ) => { + ep_icon = IconName::Inception; + missing_token = edit_prediction::EditPredictionStore::try_global(cx) + .is_some_and(|ep_store| !ep_store.read(cx).has_mercury_api_token()); + } + _ => { + ep_icon = if enabled { + IconName::ZedPredict + } else { + IconName::ZedPredictDisabled + }; + } }; if edit_prediction::should_show_upsell_modal() { @@ -369,7 +380,7 @@ impl Render for EditPredictionButton { let show_editor_predictions = self.editor_show_predictions; let user = self.user_store.read(cx).current_user(); - let indicator_color = if sweep_missing_token { + let indicator_color = if missing_token { Some(Color::Error) } else if enabled && (!show_editor_predictions || over_limit) { Some(if over_limit { @@ -532,6 +543,12 @@ impl EditPredictionButton { )); } + if cx.has_flag::() { + providers.push(EditPredictionProvider::Experimental( + EXPERIMENTAL_MERCURY_EDIT_PREDICTION_PROVIDER_NAME, + )); + } + if cx.has_flag::() { providers.push(EditPredictionProvider::Experimental( EXPERIMENTAL_ZETA2_EDIT_PREDICTION_PROVIDER_NAME, @@ -628,7 +645,66 @@ impl EditPredictionButton { if let Some(workspace) = window.root::().flatten() { workspace.update(cx, |workspace, cx| { workspace.toggle_modal(window, cx, |window, cx| { - SweepApiKeyModal::new(window, cx) + ExternalProviderApiKeyModal::new( + window, + cx, + |api_key, store, cx| { + store + .sweep_ai + .set_api_token(api_key, cx) + .detach_and_log_err(cx); + }, + ) + }); + }); + }; + } else { + set_completion_provider(fs.clone(), cx, provider); + } + }); + + menu.item(entry) + } + EditPredictionProvider::Experimental( + EXPERIMENTAL_MERCURY_EDIT_PREDICTION_PROVIDER_NAME, + ) => { + let has_api_token = edit_prediction::EditPredictionStore::try_global(cx) + .map_or(false, |ep_store| ep_store.read(cx).has_mercury_api_token()); + + let should_open_modal = !has_api_token || is_current; + + let entry = if has_api_token { + ContextMenuEntry::new("Mercury") + .toggleable(IconPosition::Start, is_current) + } else { + ContextMenuEntry::new("Mercury") + .icon(IconName::XCircle) + .icon_color(Color::Error) + .documentation_aside( + DocumentationSide::Left, + DocumentationEdge::Bottom, + |_| { + Label::new("Click to configure your Mercury API token") + .into_any_element() + }, + ) + }; + + let entry = entry.handler(move |window, cx| { + if should_open_modal { + if let Some(workspace) = window.root::().flatten() { + workspace.update(cx, |workspace, cx| { + workspace.toggle_modal(window, cx, |window, cx| { + ExternalProviderApiKeyModal::new( + window, + cx, + |api_key, store, cx| { + store + .mercury + .set_api_token(api_key, cx) + .detach_and_log_err(cx); + }, + ) }); }); }; diff --git a/crates/edit_prediction_ui/src/edit_prediction_ui.rs b/crates/edit_prediction_ui/src/edit_prediction_ui.rs index 51b491c6b3512968bca4ce2e7ed73a505bd73a00..c177b5233c33feb4f5ff82f60bf3fb6981cf3ee8 100644 --- a/crates/edit_prediction_ui/src/edit_prediction_ui.rs +++ b/crates/edit_prediction_ui/src/edit_prediction_ui.rs @@ -1,7 +1,7 @@ mod edit_prediction_button; mod edit_prediction_context_view; +mod external_provider_api_token_modal; mod rate_prediction_modal; -mod sweep_api_token_modal; use std::any::{Any as _, TypeId}; @@ -17,7 +17,7 @@ use ui::{App, prelude::*}; use workspace::{SplitDirection, Workspace}; pub use edit_prediction_button::{EditPredictionButton, ToggleMenu}; -pub use sweep_api_token_modal::SweepApiKeyModal; +pub use external_provider_api_token_modal::ExternalProviderApiKeyModal; use crate::rate_prediction_modal::PredictEditsRatePredictionsFeatureFlag; diff --git a/crates/edit_prediction_ui/src/sweep_api_token_modal.rs b/crates/edit_prediction_ui/src/external_provider_api_token_modal.rs similarity index 72% rename from crates/edit_prediction_ui/src/sweep_api_token_modal.rs rename to crates/edit_prediction_ui/src/external_provider_api_token_modal.rs index 80366fc2ac691f165d44e1e6a29a633522146984..bc312836e9fdd30237156ac532a055d1e23a2589 100644 --- a/crates/edit_prediction_ui/src/sweep_api_token_modal.rs +++ b/crates/edit_prediction_ui/src/external_provider_api_token_modal.rs @@ -6,18 +6,24 @@ use ui::{Button, ButtonStyle, Clickable, Headline, HeadlineSize, prelude::*}; use ui_input::InputField; use workspace::ModalView; -pub struct SweepApiKeyModal { +pub struct ExternalProviderApiKeyModal { api_key_input: Entity, focus_handle: FocusHandle, + on_confirm: Box, &mut EditPredictionStore, &mut App)>, } -impl SweepApiKeyModal { - pub fn new(window: &mut Window, cx: &mut Context) -> Self { - let api_key_input = cx.new(|cx| InputField::new(window, cx, "Enter your Sweep API token")); +impl ExternalProviderApiKeyModal { + pub fn new( + window: &mut Window, + cx: &mut Context, + on_confirm: impl Fn(Option, &mut EditPredictionStore, &mut App) + 'static, + ) -> Self { + let api_key_input = cx.new(|cx| InputField::new(window, cx, "Enter your API key")); Self { api_key_input, focus_handle: cx.focus_handle(), + on_confirm: Box::new(on_confirm), } } @@ -30,39 +36,34 @@ impl SweepApiKeyModal { let api_key = (!api_key.trim().is_empty()).then_some(api_key); if let Some(ep_store) = EditPredictionStore::try_global(cx) { - ep_store.update(cx, |ep_store, cx| { - ep_store - .sweep_ai - .set_api_token(api_key, cx) - .detach_and_log_err(cx); - }); + ep_store.update(cx, |ep_store, cx| (self.on_confirm)(api_key, ep_store, cx)) } cx.emit(DismissEvent); } } -impl EventEmitter for SweepApiKeyModal {} +impl EventEmitter for ExternalProviderApiKeyModal {} -impl ModalView for SweepApiKeyModal {} +impl ModalView for ExternalProviderApiKeyModal {} -impl Focusable for SweepApiKeyModal { +impl Focusable for ExternalProviderApiKeyModal { fn focus_handle(&self, _cx: &App) -> FocusHandle { self.focus_handle.clone() } } -impl Render for SweepApiKeyModal { +impl Render for ExternalProviderApiKeyModal { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { v_flex() - .key_context("SweepApiKeyModal") + .key_context("ExternalApiKeyModal") .on_action(cx.listener(Self::cancel)) .on_action(cx.listener(Self::confirm)) .elevation_2(cx) .w(px(400.)) .p_4() .gap_3() - .child(Headline::new("Sweep API Token").size(HeadlineSize::Small)) + .child(Headline::new("API Token").size(HeadlineSize::Small)) .child(self.api_key_input.clone()) .child( h_flex() diff --git a/crates/icons/src/icons.rs b/crates/icons/src/icons.rs index d28e2c1030c3c2378aa7997f4799c503cee97105..d79660356f04fd42425d9e549764a4c202d29d43 100644 --- a/crates/icons/src/icons.rs +++ b/crates/icons/src/icons.rs @@ -34,8 +34,8 @@ pub enum IconName { ArrowRightLeft, ArrowUp, ArrowUpRight, - Attach, AtSign, + Attach, AudioOff, AudioOn, Backspace, @@ -45,8 +45,8 @@ pub enum IconName { BellRing, Binary, Blocks, - BoltOutlined, BoltFilled, + BoltOutlined, Book, BookCopy, CaseSensitive, @@ -80,9 +80,9 @@ pub enum IconName { Debug, DebugBreakpoint, DebugContinue, + DebugDetach, DebugDisabledBreakpoint, DebugDisabledLogBreakpoint, - DebugDetach, DebugIgnoreBreakpoints, DebugLogBreakpoint, DebugPause, @@ -140,6 +140,7 @@ pub enum IconName { Hash, HistoryRerun, Image, + Inception, Indicator, Info, Json, @@ -147,6 +148,7 @@ pub enum IconName { Library, LineHeight, Link, + Linux, ListCollapse, ListFilter, ListTodo, @@ -172,8 +174,8 @@ pub enum IconName { PencilUnavailable, Person, Pin, - PlayOutlined, PlayFilled, + PlayOutlined, Plus, Power, Public, @@ -259,15 +261,14 @@ pub enum IconName { ZedAssistant, ZedBurnMode, ZedBurnModeOn, - ZedSrcCustom, - ZedSrcExtension, ZedPredict, ZedPredictDisabled, ZedPredictDown, ZedPredictError, ZedPredictUp, + ZedSrcCustom, + ZedSrcExtension, ZedXCopilot, - Linux, } impl IconName { diff --git a/crates/language_models/src/provider/open_ai.rs b/crates/language_models/src/provider/open_ai.rs index 46cea34e3e01cb0f8ad0f859827881f3ec74cad7..32ee95ce9bd423bf7f66efc1bc7440455380ab5c 100644 --- a/crates/language_models/src/provider/open_ai.rs +++ b/crates/language_models/src/provider/open_ai.rs @@ -438,7 +438,7 @@ pub fn into_open_ai( messages, stream, stop: request.stop, - temperature: request.temperature.unwrap_or(1.0), + temperature: request.temperature.or(Some(1.0)), max_completion_tokens: max_output_tokens, parallel_tool_calls: if supports_parallel_tool_calls && !request.tools.is_empty() { // Disable parallel tool calls, as the Agent currently expects a maximum of one per turn. diff --git a/crates/open_ai/src/open_ai.rs b/crates/open_ai/src/open_ai.rs index 6fdb393c9a13c7ff6a6981f949b4d0c865b9bff8..8ed70c9dd514cb59f5c7a160169031cbc28428e6 100644 --- a/crates/open_ai/src/open_ai.rs +++ b/crates/open_ai/src/open_ai.rs @@ -266,7 +266,8 @@ pub struct Request { pub max_completion_tokens: Option, #[serde(default, skip_serializing_if = "Vec::is_empty")] pub stop: Vec, - pub temperature: f32, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub temperature: Option, #[serde(default, skip_serializing_if = "Option::is_none")] pub tool_choice: Option, /// Whether to enable parallel function calling during tool use. diff --git a/crates/settings/src/settings_content/language.rs b/crates/settings/src/settings_content/language.rs index b466b4e0dd88bf41e0f77f67a38842305c11906f..25ff60e9f46cf797b815227222a3d27a6353c396 100644 --- a/crates/settings/src/settings_content/language.rs +++ b/crates/settings/src/settings_content/language.rs @@ -81,6 +81,7 @@ pub enum EditPredictionProvider { pub const EXPERIMENTAL_SWEEP_EDIT_PREDICTION_PROVIDER_NAME: &str = "sweep"; pub const EXPERIMENTAL_ZETA2_EDIT_PREDICTION_PROVIDER_NAME: &str = "zeta2"; +pub const EXPERIMENTAL_MERCURY_EDIT_PREDICTION_PROVIDER_NAME: &str = "mercury"; impl<'de> Deserialize<'de> for EditPredictionProvider { fn deserialize(deserializer: D) -> Result @@ -111,6 +112,13 @@ impl<'de> Deserialize<'de> for EditPredictionProvider { EXPERIMENTAL_SWEEP_EDIT_PREDICTION_PROVIDER_NAME, ) } + Content::Experimental(name) + if name == EXPERIMENTAL_MERCURY_EDIT_PREDICTION_PROVIDER_NAME => + { + EditPredictionProvider::Experimental( + EXPERIMENTAL_MERCURY_EDIT_PREDICTION_PROVIDER_NAME, + ) + } Content::Experimental(name) if name == EXPERIMENTAL_ZETA2_EDIT_PREDICTION_PROVIDER_NAME => { diff --git a/crates/zed/src/zed/edit_prediction_registry.rs b/crates/zed/src/zed/edit_prediction_registry.rs index 2d5746b87ab20de5d0aca47a4d5da60b9ec33d2a..77a1f71596f9cf1d2f4e32137580d0e3648359f5 100644 --- a/crates/zed/src/zed/edit_prediction_registry.rs +++ b/crates/zed/src/zed/edit_prediction_registry.rs @@ -9,6 +9,7 @@ use gpui::{AnyWindowHandle, App, AppContext as _, Context, Entity, WeakEntity}; use language::language_settings::{EditPredictionProvider, all_language_settings}; use language_models::MistralLanguageModelProvider; use settings::{ + EXPERIMENTAL_MERCURY_EDIT_PREDICTION_PROVIDER_NAME, EXPERIMENTAL_SWEEP_EDIT_PREDICTION_PROVIDER_NAME, EXPERIMENTAL_ZETA2_EDIT_PREDICTION_PROVIDER_NAME, SettingsStore, }; @@ -219,6 +220,10 @@ fn assign_edit_prediction_provider( && cx.has_flag::() { edit_prediction::EditPredictionModel::Zeta2 + } else if name == EXPERIMENTAL_MERCURY_EDIT_PREDICTION_PROVIDER_NAME + && cx.has_flag::() + { + edit_prediction::EditPredictionModel::Mercury } else { return false; } From e1d8c1a6a1af1821a6ab4cbdb87199c38ce1434f Mon Sep 17 00:00:00 2001 From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Date: Sat, 6 Dec 2025 09:06:43 -0300 Subject: [PATCH 095/621] Improve visual alignment on the inline assistant (#44265) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Just making all of the elements in the inline assistant more vertically centered. Screenshot 2025-12-06 at 12  02@2x Release Notes: - N/A --- crates/agent_ui/src/inline_prompt_editor.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/crates/agent_ui/src/inline_prompt_editor.rs b/crates/agent_ui/src/inline_prompt_editor.rs index 0083648651645c456acfa19332d61b9f550ed4ed..b9852ea727c7974e3564fadc652f132076c01f09 100644 --- a/crates/agent_ui/src/inline_prompt_editor.rs +++ b/crates/agent_ui/src/inline_prompt_editor.rs @@ -10,8 +10,8 @@ use editor::{ }; use fs::Fs; use gpui::{ - AnyElement, App, Context, CursorStyle, Entity, EventEmitter, FocusHandle, Focusable, - Subscription, TextStyle, TextStyleRefinement, WeakEntity, Window, + AnyElement, App, Context, Entity, EventEmitter, FocusHandle, Focusable, Subscription, + TextStyle, TextStyleRefinement, WeakEntity, Window, }; use language_model::{LanguageModel, LanguageModelRegistry}; use markdown::{HeadingLevelStyles, Markdown, MarkdownElement, MarkdownStyle}; @@ -100,7 +100,7 @@ impl Render for PromptEditor { let bottom_padding = match &self.mode { PromptEditorMode::Buffer { .. } => rems_from_px(2.0), - PromptEditorMode::Terminal { .. } => rems_from_px(8.0), + PromptEditorMode::Terminal { .. } => rems_from_px(4.0), }; buttons.extend(self.render_buttons(window, cx)); @@ -138,14 +138,13 @@ impl Render for PromptEditor { .pt_0p5() .pb(bottom_padding) .pr(right_padding) - .bg(cx.theme().colors().editor_background) .gap_0p5() + .justify_center() .border_y_1() .border_color(cx.theme().colors().border) + .bg(cx.theme().colors().editor_background) .child( h_flex() - .items_start() - .cursor(CursorStyle::Arrow) .on_action(cx.listener(|this, _: &ToggleModelSelector, window, cx| { this.model_selector .update(cx, |model_selector, cx| model_selector.toggle(window, cx)); @@ -165,7 +164,7 @@ impl Render for PromptEditor { .flex_shrink_0() .items_center() .justify_center() - .gap_2() + .gap_1() .child(self.render_close_button(cx)) .map(|el| { let CodegenStatus::Error(error) = self.codegen_status(cx) else { @@ -206,13 +205,14 @@ impl Render for PromptEditor { this.child( h_flex() .size_full() + .justify_center() .child(div().w(left_gutter_width + px(6.))) .child( div() .size_full() .min_w_0() - .pb_px() - .pl_1() + .pt(rems_from_px(3.)) + .pl_0p5() .flex_1() .border_t_1() .border_color(cx.theme().colors().border_variant) From 0565992d7a0bb53ad9b620196ad23ae0ed02ebab Mon Sep 17 00:00:00 2001 From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Date: Sat, 6 Dec 2025 09:06:51 -0300 Subject: [PATCH 096/621] project picker: Improve tooltip on secondary actions (#44264) This PR adds the keybinding for the "open in project window" button on the project picker as well as makes the tooltip for the content bit on the active list item only show up for the content container. https://github.com/user-attachments/assets/42944cf7-e4e7-4bf8-8695-48df8b3a35eb Release Notes: - N/A --- crates/recent_projects/src/recent_projects.rs | 45 ++++++++++++++----- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/crates/recent_projects/src/recent_projects.rs b/crates/recent_projects/src/recent_projects.rs index 280bf17a385db09c10c2844ac7126b3aac7adafb..8c081205444fbc13fb1d94c297946261fcab7fb3 100644 --- a/crates/recent_projects/src/recent_projects.rs +++ b/crates/recent_projects/src/recent_projects.rs @@ -132,7 +132,8 @@ pub fn init(cx: &mut App) { let create_new_window = open_recent.create_new_window; with_active_or_new_workspace(cx, move |workspace, window, cx| { let Some(recent_projects) = workspace.active_modal::(cx) else { - RecentProjects::open(workspace, create_new_window, window, cx); + let focus_handle = workspace.focus_handle(cx); + RecentProjects::open(workspace, create_new_window, window, focus_handle, cx); return; }; @@ -246,11 +247,12 @@ impl RecentProjects { workspace: &mut Workspace, create_new_window: bool, window: &mut Window, + focus_handle: FocusHandle, cx: &mut Context, ) { let weak = cx.entity().downgrade(); workspace.toggle_modal(window, cx, |window, cx| { - let delegate = RecentProjectsDelegate::new(weak, create_new_window, true); + let delegate = RecentProjectsDelegate::new(weak, create_new_window, true, focus_handle); Self::new(delegate, 34., window, cx) }) @@ -289,10 +291,16 @@ pub struct RecentProjectsDelegate { // Flag to reset index when there is a new query vs not reset index when user delete an item reset_selected_match_index: bool, has_any_non_local_projects: bool, + focus_handle: FocusHandle, } impl RecentProjectsDelegate { - fn new(workspace: WeakEntity, create_new_window: bool, render_paths: bool) -> Self { + fn new( + workspace: WeakEntity, + create_new_window: bool, + render_paths: bool, + focus_handle: FocusHandle, + ) -> Self { Self { workspace, workspaces: Vec::new(), @@ -302,6 +310,7 @@ impl RecentProjectsDelegate { render_paths, reset_selected_match_index: true, has_any_non_local_projects: false, + focus_handle, } } @@ -544,12 +553,23 @@ impl PickerDelegate for RecentProjectsDelegate { paths, }; + let focus_handle = self.focus_handle.clone(); + let secondary_actions = h_flex() .gap_px() .child( IconButton::new("open_new_window", IconName::ArrowUpRight) .icon_size(IconSize::XSmall) - .tooltip(Tooltip::text("Open Project in New Window")) + .tooltip({ + move |_, cx| { + Tooltip::for_action_in( + "Open Project in New Window", + &menu::SecondaryConfirm, + &focus_handle, + cx, + ) + } + }) .on_click(cx.listener(move |this, _event, window, cx| { cx.stop_propagation(); window.prevent_default(); @@ -577,8 +597,9 @@ impl PickerDelegate for RecentProjectsDelegate { .spacing(ListItemSpacing::Sparse) .child( h_flex() - .flex_grow() + .id("projecy_info_container") .gap_3() + .flex_grow() .when(self.has_any_non_local_projects, |this| { this.child(match location { SerializedWorkspaceLocation::Local => Icon::new(IconName::Screen) @@ -600,6 +621,13 @@ impl PickerDelegate for RecentProjectsDelegate { highlighted.paths.clear(); } highlighted.render(window, cx) + }) + .tooltip(move |_, cx| { + let tooltip_highlighted_location = highlighted_match.clone(); + cx.new(|_| MatchTooltip { + highlighted_location: tooltip_highlighted_location, + }) + .into() }), ) .map(|el| { @@ -608,13 +636,6 @@ impl PickerDelegate for RecentProjectsDelegate { } else { el.end_hover_slot(secondary_actions) } - }) - .tooltip(move |_, cx| { - let tooltip_highlighted_location = highlighted_match.clone(); - cx.new(|_| MatchTooltip { - highlighted_location: tooltip_highlighted_location, - }) - .into() }), ) } From d72746773faf458452ee393cf3ec01a164f98b37 Mon Sep 17 00:00:00 2001 From: David Kleingeld Date: Sat, 6 Dec 2025 13:08:01 +0100 Subject: [PATCH 097/621] Put tracy dependency behind feature tracy (#44277) It broke CI, now it no longer does :tada: Proper fix followes after the weekend. Release Notes: - N/A --- Cargo.toml | 1 - crates/zed/Cargo.toml | 3 +++ crates/ztracing/Cargo.toml | 5 ++++- docs/src/performance.md | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 858da1dc460cda2fecbaf2ed94d437bfd25d9644..be78357b2515b12acad808f436cf7359877b5418 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -699,7 +699,6 @@ tree-sitter-rust = "0.24" tree-sitter-typescript = { git = "https://github.com/zed-industries/tree-sitter-typescript", rev = "e2c53597d6a5d9cf7bbe8dccde576fe1e46c5899" } # https://github.com/tree-sitter/tree-sitter-typescript/pull/347 tree-sitter-yaml = { git = "https://github.com/zed-industries/tree-sitter-yaml", rev = "baff0b51c64ef6a1fb1f8390f3ad6015b83ec13a" } tracing = "0.1.40" -tracing-tracy = "0.11.4" unicase = "2.6" unicode-script = "0.5.7" unicode-segmentation = "1.10" diff --git a/crates/zed/Cargo.toml b/crates/zed/Cargo.toml index e304ad7f5cd94c05daab2755cb9e7bed21fe0f8d..a9a8ba87c645e99a68409865a95737e3222c87b3 100644 --- a/crates/zed/Cargo.toml +++ b/crates/zed/Cargo.toml @@ -10,6 +10,9 @@ authors = ["Zed Team "] [lints] workspace = true +[features] +tracy = ["ztracing/tracy"] + [[bin]] name = "zed" path = "src/zed-main.rs" diff --git a/crates/ztracing/Cargo.toml b/crates/ztracing/Cargo.toml index fbc9dc032d2d485f74a15e5fe3b073a7017911fd..c68ac15423cf3a26a8dc855769ba44b9ac29696a 100644 --- a/crates/ztracing/Cargo.toml +++ b/crates/ztracing/Cargo.toml @@ -8,10 +8,13 @@ license = "GPL-3.0-or-later" [lints] workspace = true +[features] +tracy = ["tracing-tracy"] + [dependencies] tracing.workspace = true tracing-subscriber = "0.3.22" -tracing-tracy = { workspace = true, features = ["enable", "ondemand"] } +tracing-tracy = { version = "0.11.4", optional = true, features = ["enable", "ondemand"] } ztracing_macro.workspace = true diff --git a/docs/src/performance.md b/docs/src/performance.md index 4adc38f5eea27de26f1d5818b6787fb78ae1d1ad..544e39e94babbf9c335a847af8819ad5b00494d1 100644 --- a/docs/src/performance.md +++ b/docs/src/performance.md @@ -28,7 +28,7 @@ fn should_appear_in_profile(kitty: Cat) { } ``` -Then either compile Zed with `ZTRACING=1 cargo r --release`. The release build is optional but highly recommended as like every program Zeds performance characteristics change dramatically with optimizations. You do not want to chase slowdowns that do not exist in release. +Then either compile Zed with `ZTRACING=1 cargo r --features tracy --release`. The release build is optional but highly recommended as like every program Zeds performance characteristics change dramatically with optimizations. You do not want to chase slowdowns that do not exist in release. ## One time Setup/Building the profiler: From a0848daab44c05f69e6adfcfa0682b84a0bd06d7 Mon Sep 17 00:00:00 2001 From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Date: Sat, 6 Dec 2025 09:43:37 -0300 Subject: [PATCH 098/621] agent ui: Fix clicks on the notification sometimes not being triggered (#44280) Closes https://github.com/zed-industries/zed/issues/43292 We were seeing clicks on the "View Panel" and "Dismiss" buttons sometimes not being triggered. I believe this was happening because the overall parent also had an on_click, which due to this being a popup window, was causing conflicts with the buttons' on click handlers. This should hopefully fix that issue. Release Notes: - agent: Fixed an issue where clicking on the agent notification buttons would sometimes not trigger their actions. --- crates/agent_ui/src/ui/agent_notification.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/crates/agent_ui/src/ui/agent_notification.rs b/crates/agent_ui/src/ui/agent_notification.rs index af2a022f147b79a0a299c17dd26c7e9a8b62aeb9..34ca0bb32a82aa23d1b954554ce2dfec436bfe1c 100644 --- a/crates/agent_ui/src/ui/agent_notification.rs +++ b/crates/agent_ui/src/ui/agent_notification.rs @@ -106,9 +106,6 @@ impl Render for AgentNotification { .font(ui_font) .border_color(cx.theme().colors().border) .rounded_xl() - .on_click(cx.listener(|_, _, _, cx| { - cx.emit(AgentNotificationEvent::Accepted); - })) .child( h_flex() .items_start() From 9e33243015d39ac54060c074d275aca3de77f2d9 Mon Sep 17 00:00:00 2001 From: John Tur Date: Sat, 6 Dec 2025 11:31:05 -0500 Subject: [PATCH 099/621] Fix unregistration logic for pull diagnostics (#44294) Even if `workspace_diagnostics_refresh_tasks` is empty, registrations which didn't advertise support for workspace diagnostics may still exist. Release Notes: - N/A --- crates/project/src/lsp_store.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/crates/project/src/lsp_store.rs b/crates/project/src/lsp_store.rs index 59b7a6932d4733a78959e9e4f481a63589811a52..1ae6d1295f37df31aac03e2019cb5510c836fb1c 100644 --- a/crates/project/src/lsp_store.rs +++ b/crates/project/src/lsp_store.rs @@ -12647,30 +12647,29 @@ impl LspStore { .language_servers .get_mut(&server_id) .context("Could not obtain Language Servers state")?; - local + let registrations = local .language_server_dynamic_registrations .get_mut(&server_id) .with_context(|| { format!("Expected dynamic registration to exist for server {server_id}") - })?.diagnostics + })?; + registrations.diagnostics .remove(&Some(unreg.id.clone())) .with_context(|| format!( "Attempted to unregister non-existent diagnostic registration with ID {}", unreg.id) )?; + let removed_last_diagnostic_provider = registrations.diagnostics.is_empty(); - let mut has_any_diagnostic_providers_still = true; if let LanguageServerState::Running { workspace_diagnostics_refresh_tasks, .. } = state { workspace_diagnostics_refresh_tasks.remove(&Some(unreg.id.clone())); - has_any_diagnostic_providers_still = - !workspace_diagnostics_refresh_tasks.is_empty(); } - if !has_any_diagnostic_providers_still { + if removed_last_diagnostic_provider { server.update_capabilities(|capabilities| { debug_assert!(capabilities.diagnostic_provider.is_some()); capabilities.diagnostic_provider = None; From b2e35b5f999b1640251d155d13a0b3914e7c96a1 Mon Sep 17 00:00:00 2001 From: Ben Kunkle Date: Sat, 6 Dec 2025 09:56:49 -0800 Subject: [PATCH 100/621] zlog: Fix dynamic mod path filtering (#44296) Closes #ISSUE Release Notes: - Linux: cleaned up noisy logs from `zbus` --- crates/zlog/src/filter.rs | 30 +++++++++++++++++++----------- crates/zlog/src/sink.rs | 6 +++--- crates/zlog/src/zlog.rs | 20 ++++++++++++++------ 3 files changed, 36 insertions(+), 20 deletions(-) diff --git a/crates/zlog/src/filter.rs b/crates/zlog/src/filter.rs index e2ca04be60f4fe7eba7cdb2fc9eb983092d2331a..0be6f4ead5bf64aa47f7a60391bf377c9998cfb4 100644 --- a/crates/zlog/src/filter.rs +++ b/crates/zlog/src/filter.rs @@ -5,12 +5,12 @@ use std::sync::{ atomic::{AtomicU8, Ordering}, }; -use crate::{SCOPE_DEPTH_MAX, SCOPE_STRING_SEP_STR, Scope, ScopeAlloc, env_config, private}; +use crate::{SCOPE_DEPTH_MAX, SCOPE_STRING_SEP_STR, ScopeAlloc, ScopeRef, env_config, private}; use log; static ENV_FILTER: OnceLock = OnceLock::new(); -static SCOPE_MAP: RwLock> = RwLock::new(None); +static SCOPE_MAP: RwLock = RwLock::new(ScopeMap::empty()); pub const LEVEL_ENABLED_MAX_DEFAULT: log::LevelFilter = log::LevelFilter::Info; /// The maximum log level of verbosity that is enabled by default. @@ -59,7 +59,11 @@ pub fn is_possibly_enabled_level(level: log::Level) -> bool { level as u8 <= LEVEL_ENABLED_MAX_CONFIG.load(Ordering::Acquire) } -pub fn is_scope_enabled(scope: &Scope, module_path: Option<&str>, level: log::Level) -> bool { +pub fn is_scope_enabled( + scope: &ScopeRef<'_>, + module_path: Option<&str>, + level: log::Level, +) -> bool { // TODO: is_always_allowed_level that checks against LEVEL_ENABLED_MIN_CONFIG if !is_possibly_enabled_level(level) { // [FAST PATH] @@ -74,16 +78,11 @@ pub fn is_scope_enabled(scope: &Scope, module_path: Option<&str>, level: log::Le err.into_inner() }); - let Some(map) = global_scope_map.as_ref() else { - // on failure, return false because it's not <= LEVEL_ENABLED_MAX_STATIC - return is_enabled_by_default; - }; - - if map.is_empty() { + if global_scope_map.is_empty() { // if no scopes are enabled, return false because it's not <= LEVEL_ENABLED_MAX_STATIC return is_enabled_by_default; } - let enabled_status = map.is_enabled(scope, module_path, level); + let enabled_status = global_scope_map.is_enabled(scope, module_path, level); match enabled_status { EnabledStatus::NotConfigured => is_enabled_by_default, EnabledStatus::Enabled => true, @@ -107,7 +106,7 @@ pub fn refresh_from_settings(settings: &HashMap) { SCOPE_MAP.clear_poison(); err.into_inner() }); - global_map.replace(map_new); + *global_map = map_new; } log::trace!("Log configuration updated"); } @@ -395,12 +394,21 @@ impl ScopeMap { } EnabledStatus::NotConfigured } + + const fn empty() -> ScopeMap { + ScopeMap { + entries: vec![], + modules: vec![], + root_count: 0, + } + } } #[cfg(test)] mod tests { use log::LevelFilter; + use crate::Scope; use crate::private::scope_new; use super::*; diff --git a/crates/zlog/src/sink.rs b/crates/zlog/src/sink.rs index 303e3139bc7cdb95ae01c7e87fff8f9bc6d100c2..07e87be1b071f2538e716bb8fd2b692527363fc4 100644 --- a/crates/zlog/src/sink.rs +++ b/crates/zlog/src/sink.rs @@ -8,7 +8,7 @@ use std::{ }, }; -use crate::{SCOPE_STRING_SEP_CHAR, Scope}; +use crate::{SCOPE_STRING_SEP_CHAR, ScopeRef}; // ANSI color escape codes for log levels const ANSI_RESET: &str = "\x1b[0m"; @@ -35,7 +35,7 @@ static SINK_FILE_SIZE_BYTES: AtomicU64 = AtomicU64::new(0); const SINK_FILE_SIZE_BYTES_MAX: u64 = 1024 * 1024; // 1 MB pub struct Record<'a> { - pub scope: Scope, + pub scope: ScopeRef<'a>, pub level: log::Level, pub message: &'a std::fmt::Arguments<'a>, pub module_path: Option<&'a str>, @@ -208,7 +208,7 @@ pub fn flush() { } struct SourceFmt<'a> { - scope: Scope, + scope: ScopeRef<'a>, module_path: Option<&'a str>, line: Option, ansi: bool, diff --git a/crates/zlog/src/zlog.rs b/crates/zlog/src/zlog.rs index bcd13216252e0b45f6dc553160e17c7216a87f27..3c154f790845da74dcf3a4f9bfdd830d2d32c9ec 100644 --- a/crates/zlog/src/zlog.rs +++ b/crates/zlog/src/zlog.rs @@ -70,15 +70,18 @@ impl log::Log for Zlog { if !self.enabled(record.metadata()) { return; } - let (crate_name_scope, module_scope) = match record.module_path_static() { + let module_path = record.module_path().or(record.file()); + let (crate_name_scope, module_scope) = match module_path { Some(module_path) => { let crate_name = private::extract_crate_name_from_module_path(module_path); - let crate_name_scope = private::scope_new(&[crate_name]); - let module_scope = private::scope_new(&[module_path]); + let crate_name_scope = private::scope_ref_new(&[crate_name]); + let module_scope = private::scope_ref_new(&[module_path]); (crate_name_scope, module_scope) } - // TODO: when do we hit this - None => (private::scope_new(&[]), private::scope_new(&["*unknown*"])), + None => { + // TODO: when do we hit this + (private::scope_new(&[]), private::scope_new(&["*unknown*"])) + } }; let level = record.metadata().level(); if !filter::is_scope_enabled(&crate_name_scope, Some(record.target()), level) { @@ -89,7 +92,7 @@ impl log::Log for Zlog { level, message: record.args(), // PERF(batching): store non-static paths in a cache + leak them and pass static str here - module_path: record.module_path().or(record.file()), + module_path, line: record.line(), }); } @@ -252,6 +255,10 @@ pub mod private { } pub const fn scope_new(scopes: &[&'static str]) -> Scope { + scope_ref_new(scopes) + } + + pub const fn scope_ref_new<'a>(scopes: &[&'a str]) -> ScopeRef<'a> { assert!(scopes.len() <= SCOPE_DEPTH_MAX); let mut scope = [""; SCOPE_DEPTH_MAX]; let mut i = 0; @@ -275,6 +282,7 @@ pub mod private { } pub type Scope = [&'static str; SCOPE_DEPTH_MAX]; +pub type ScopeRef<'a> = [&'a str; SCOPE_DEPTH_MAX]; pub type ScopeAlloc = [String; SCOPE_DEPTH_MAX]; const SCOPE_STRING_SEP_STR: &str = "."; const SCOPE_STRING_SEP_CHAR: char = '.'; From 16666f5357a7cb7ad69d55095f27affafdf06724 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Sat, 6 Dec 2025 20:49:21 +0200 Subject: [PATCH 101/621] Use single `languages::{rust_lang, markdown_lang}` in tests across the codebase (#44282) This allows referencing proper queries and keeping the tests up-to-date. Release Notes: - N/A --- crates/agent/src/tools/grep_tool.rs | 19 +- crates/agent/src/tools/read_file_tool.rs | 46 +-- crates/agent_ui/src/buffer_codegen.rs | 34 +-- crates/collab/src/tests.rs | 17 -- crates/collab/src/tests/editor_tests.rs | 7 +- crates/collab/src/tests/integration_tests.rs | 4 +- crates/debugger_ui/Cargo.toml | 1 + crates/debugger_ui/src/tests/inline_values.rs | 121 ++++---- crates/edit_prediction/src/zeta1.rs | 19 +- .../src/edit_prediction_context_tests.rs | 24 +- crates/edit_prediction_context/src/excerpt.rs | 20 +- crates/editor/src/items.rs | 20 +- crates/language/src/buffer_tests.rs | 183 +++-------- crates/language/src/language.rs | 32 +- .../src/syntax_map/syntax_map_tests.rs | 66 ++-- crates/markdown_preview/Cargo.toml | 1 + .../markdown_preview/src/markdown_parser.rs | 21 +- crates/outline/src/outline.rs | 88 +----- crates/outline_panel/src/outline_panel.rs | 288 ++++-------------- crates/project/src/project_tests.rs | 16 +- crates/vim/src/object.rs | 7 +- crates/zed/src/zed.rs | 63 +--- 22 files changed, 267 insertions(+), 830 deletions(-) diff --git a/crates/agent/src/tools/grep_tool.rs b/crates/agent/src/tools/grep_tool.rs index ec61b013e87ccb3afc133ee0a264e55a6d8baee9..0caba91564fd1fc9e670909490d4e776b8ad6f11 100644 --- a/crates/agent/src/tools/grep_tool.rs +++ b/crates/agent/src/tools/grep_tool.rs @@ -322,7 +322,6 @@ mod tests { use super::*; use gpui::{TestAppContext, UpdateGlobal}; - use language::{Language, LanguageConfig, LanguageMatcher}; use project::{FakeFs, Project}; use serde_json::json; use settings::SettingsStore; @@ -564,7 +563,7 @@ mod tests { let project = Project::test(fs.clone(), [path!("/root").as_ref()], cx).await; project.update(cx, |project, _cx| { - project.languages().add(rust_lang().into()) + project.languages().add(language::rust_lang()) }); project @@ -793,22 +792,6 @@ mod tests { }); } - fn rust_lang() -> Language { - Language::new( - LanguageConfig { - name: "Rust".into(), - matcher: LanguageMatcher { - path_suffixes: vec!["rs".to_string()], - ..Default::default() - }, - ..Default::default() - }, - Some(tree_sitter_rust::LANGUAGE.into()), - ) - .with_outline_query(include_str!("../../../languages/src/rust/outline.scm")) - .unwrap() - } - #[gpui::test] async fn test_grep_security_boundaries(cx: &mut TestAppContext) { init_test(cx); diff --git a/crates/agent/src/tools/read_file_tool.rs b/crates/agent/src/tools/read_file_tool.rs index 4457a6e5ca21a2fc88c76c718160d1d59171e66a..5b19bf36ee3a0949910d217880e2e95c49f021fc 100644 --- a/crates/agent/src/tools/read_file_tool.rs +++ b/crates/agent/src/tools/read_file_tool.rs @@ -302,7 +302,6 @@ mod test { use super::*; use crate::{ContextServerRegistry, Templates, Thread}; use gpui::{AppContext, TestAppContext, UpdateGlobal as _}; - use language::{Language, LanguageConfig, LanguageMatcher, tree_sitter_rust}; use language_model::fake_provider::FakeLanguageModel; use project::{FakeFs, Project}; use prompt_store::ProjectContext; @@ -406,7 +405,7 @@ mod test { .await; let project = Project::test(fs.clone(), [path!("/root").as_ref()], cx).await; let language_registry = project.read_with(cx, |project, _| project.languages().clone()); - language_registry.add(Arc::new(rust_lang())); + language_registry.add(language::rust_lang()); let action_log = cx.new(|_| ActionLog::new(project.clone())); let context_server_registry = cx.new(|cx| ContextServerRegistry::new(project.read(cx).context_server_store(), cx)); @@ -596,49 +595,6 @@ mod test { }); } - fn rust_lang() -> Language { - Language::new( - LanguageConfig { - name: "Rust".into(), - matcher: LanguageMatcher { - path_suffixes: vec!["rs".to_string()], - ..Default::default() - }, - ..Default::default() - }, - Some(tree_sitter_rust::LANGUAGE.into()), - ) - .with_outline_query( - r#" - (line_comment) @annotation - - (struct_item - "struct" @context - name: (_) @name) @item - (enum_item - "enum" @context - name: (_) @name) @item - (enum_variant - name: (_) @name) @item - (field_declaration - name: (_) @name) @item - (impl_item - "impl" @context - trait: (_)? @name - "for"? @context - type: (_) @name - body: (_ "{" (_)* "}")) @item - (function_item - "fn" @context - name: (_) @name) @item - (mod_item - "mod" @context - name: (_) @name) @item - "#, - ) - .unwrap() - } - #[gpui::test] async fn test_read_file_security(cx: &mut TestAppContext) { init_test(cx); diff --git a/crates/agent_ui/src/buffer_codegen.rs b/crates/agent_ui/src/buffer_codegen.rs index 0d014f50294f90aa2bda1f51025c937cc0e2ae56..f7e7884310458e97421768882df57934a19b4430 100644 --- a/crates/agent_ui/src/buffer_codegen.rs +++ b/crates/agent_ui/src/buffer_codegen.rs @@ -1295,8 +1295,9 @@ mod tests { }; use gpui::TestAppContext; use indoc::indoc; - use language::{Buffer, Language, LanguageConfig, LanguageMatcher, Point, tree_sitter_rust}; + use language::{Buffer, Point}; use language_model::{LanguageModelRegistry, TokenUsage}; + use languages::rust_lang; use rand::prelude::*; use settings::SettingsStore; use std::{future, sync::Arc}; @@ -1313,7 +1314,7 @@ mod tests { } } "}; - let buffer = cx.new(|cx| Buffer::local(text, cx).with_language(Arc::new(rust_lang()), cx)); + let buffer = cx.new(|cx| Buffer::local(text, cx).with_language(rust_lang(), cx)); let buffer = cx.new(|cx| MultiBuffer::singleton(buffer, cx)); let range = buffer.read_with(cx, |buffer, cx| { let snapshot = buffer.snapshot(cx); @@ -1375,7 +1376,7 @@ mod tests { le } "}; - let buffer = cx.new(|cx| Buffer::local(text, cx).with_language(Arc::new(rust_lang()), cx)); + let buffer = cx.new(|cx| Buffer::local(text, cx).with_language(rust_lang(), cx)); let buffer = cx.new(|cx| MultiBuffer::singleton(buffer, cx)); let range = buffer.read_with(cx, |buffer, cx| { let snapshot = buffer.snapshot(cx); @@ -1439,7 +1440,7 @@ mod tests { " \n", "}\n" // ); - let buffer = cx.new(|cx| Buffer::local(text, cx).with_language(Arc::new(rust_lang()), cx)); + let buffer = cx.new(|cx| Buffer::local(text, cx).with_language(rust_lang(), cx)); let buffer = cx.new(|cx| MultiBuffer::singleton(buffer, cx)); let range = buffer.read_with(cx, |buffer, cx| { let snapshot = buffer.snapshot(cx); @@ -1555,7 +1556,7 @@ mod tests { let x = 0; } "}; - let buffer = cx.new(|cx| Buffer::local(text, cx).with_language(Arc::new(rust_lang()), cx)); + let buffer = cx.new(|cx| Buffer::local(text, cx).with_language(rust_lang(), cx)); let buffer = cx.new(|cx| MultiBuffer::singleton(buffer, cx)); let range = buffer.read_with(cx, |buffer, cx| { let snapshot = buffer.snapshot(cx); @@ -1672,27 +1673,4 @@ mod tests { }); chunks_tx } - - fn rust_lang() -> Language { - Language::new( - LanguageConfig { - name: "Rust".into(), - matcher: LanguageMatcher { - path_suffixes: vec!["rs".to_string()], - ..Default::default() - }, - ..Default::default() - }, - Some(tree_sitter_rust::LANGUAGE.into()), - ) - .with_indents_query( - r#" - (call_expression) @indent - (field_expression) @indent - (_ "(" ")" @end) @indent - (_ "{" "}" @end) @indent - "#, - ) - .unwrap() - } } diff --git a/crates/collab/src/tests.rs b/crates/collab/src/tests.rs index 7d07360b8042ed54a9f19a82a2876e448e8a14a4..3785ee0b7abaeddeac5c9acb1718407ab5bd54f2 100644 --- a/crates/collab/src/tests.rs +++ b/crates/collab/src/tests.rs @@ -1,5 +1,3 @@ -use std::sync::Arc; - use call::Room; use client::ChannelId; use gpui::{Entity, TestAppContext}; @@ -18,7 +16,6 @@ mod randomized_test_helpers; mod remote_editing_collaboration_tests; mod test_server; -use language::{Language, LanguageConfig, LanguageMatcher, tree_sitter_rust}; pub use randomized_test_helpers::{ RandomizedTest, TestError, UserTestPlan, run_randomized_test, save_randomized_test_plan, }; @@ -51,17 +48,3 @@ fn room_participants(room: &Entity, cx: &mut TestAppContext) -> RoomPartic fn channel_id(room: &Entity, cx: &mut TestAppContext) -> Option { cx.read(|cx| room.read(cx).channel_id()) } - -fn rust_lang() -> Arc { - Arc::new(Language::new( - LanguageConfig { - name: "Rust".into(), - matcher: LanguageMatcher { - path_suffixes: vec!["rs".to_string()], - ..Default::default() - }, - ..Default::default() - }, - Some(tree_sitter_rust::LANGUAGE.into()), - )) -} diff --git a/crates/collab/src/tests/editor_tests.rs b/crates/collab/src/tests/editor_tests.rs index 149a48db7439cc28e76fac5aae8b6e11f0837991..ba92e868126c7f27fb5051021fce44fe43c8d5e7 100644 --- a/crates/collab/src/tests/editor_tests.rs +++ b/crates/collab/src/tests/editor_tests.rs @@ -1,7 +1,4 @@ -use crate::{ - rpc::RECONNECT_TIMEOUT, - tests::{TestServer, rust_lang}, -}; +use crate::{rpc::RECONNECT_TIMEOUT, tests::TestServer}; use call::ActiveCall; use editor::{ DocumentColorsRenderMode, Editor, FETCH_COLORS_DEBOUNCE_TIMEOUT, MultiBufferOffset, RowInfo, @@ -23,7 +20,7 @@ use gpui::{ App, Rgba, SharedString, TestAppContext, UpdateGlobal, VisualContext, VisualTestContext, }; use indoc::indoc; -use language::FakeLspAdapter; +use language::{FakeLspAdapter, rust_lang}; use lsp::LSP_REQUEST_TIMEOUT; use pretty_assertions::assert_eq; use project::{ diff --git a/crates/collab/src/tests/integration_tests.rs b/crates/collab/src/tests/integration_tests.rs index fcda8688d427f3e6b937f00edc7c3586dfdbef36..391e7355ea196dfe25d363472918837ea817f450 100644 --- a/crates/collab/src/tests/integration_tests.rs +++ b/crates/collab/src/tests/integration_tests.rs @@ -2,7 +2,7 @@ use crate::{ rpc::{CLEANUP_TIMEOUT, RECONNECT_TIMEOUT}, tests::{ RoomParticipants, TestClient, TestServer, channel_id, following_tests::join_channel, - room_participants, rust_lang, + room_participants, }, }; use anyhow::{Result, anyhow}; @@ -26,7 +26,7 @@ use language::{ Diagnostic, DiagnosticEntry, DiagnosticSourceKind, FakeLspAdapter, Language, LanguageConfig, LanguageMatcher, LineEnding, OffsetRangeExt, Point, Rope, language_settings::{Formatter, FormatterList}, - tree_sitter_rust, tree_sitter_typescript, + rust_lang, tree_sitter_rust, tree_sitter_typescript, }; use lsp::{LanguageServerId, OneOf}; use parking_lot::Mutex; diff --git a/crates/debugger_ui/Cargo.toml b/crates/debugger_ui/Cargo.toml index 325bcc300ae637ab46c36b7a3e7875e197f7d3d2..25d23b96b897001faec39498c5b08ef08b09a3a1 100644 --- a/crates/debugger_ui/Cargo.toml +++ b/crates/debugger_ui/Cargo.toml @@ -82,6 +82,7 @@ dap_adapters = { workspace = true, features = ["test-support"] } debugger_tools = { workspace = true, features = ["test-support"] } editor = { workspace = true, features = ["test-support"] } gpui = { workspace = true, features = ["test-support"] } +language = { workspace = true, features = ["test-support"] } project = { workspace = true, features = ["test-support"] } tree-sitter-go.workspace = true unindent.workspace = true diff --git a/crates/debugger_ui/src/tests/inline_values.rs b/crates/debugger_ui/src/tests/inline_values.rs index 801e6d43623b50d69ea3ce297c274c2d7e5a8b14..379bc4c98f5341b089b5936ed8571da5a6280723 100644 --- a/crates/debugger_ui/src/tests/inline_values.rs +++ b/crates/debugger_ui/src/tests/inline_values.rs @@ -4,7 +4,7 @@ use dap::{Scope, StackFrame, Variable, requests::Variables}; use editor::{Editor, EditorMode, MultiBuffer}; use gpui::{BackgroundExecutor, TestAppContext, VisualTestContext}; use language::{ - Language, LanguageConfig, LanguageMatcher, tree_sitter_python, tree_sitter_rust, + Language, LanguageConfig, LanguageMatcher, rust_lang, tree_sitter_python, tree_sitter_typescript, }; use project::{FakeFs, Project}; @@ -224,7 +224,7 @@ fn main() { .unwrap(); buffer.update(cx, |buffer, cx| { - buffer.set_language(Some(Arc::new(rust_lang())), cx); + buffer.set_language(Some(rust_lang()), cx); }); let (editor, cx) = cx.add_window_view(|window, cx| { @@ -1521,23 +1521,6 @@ fn main() { }); } -fn rust_lang() -> Language { - let debug_variables_query = include_str!("../../../languages/src/rust/debugger.scm"); - Language::new( - LanguageConfig { - name: "Rust".into(), - matcher: LanguageMatcher { - path_suffixes: vec!["rs".to_string()], - ..Default::default() - }, - ..Default::default() - }, - Some(tree_sitter_rust::LANGUAGE.into()), - ) - .with_debug_variables_query(debug_variables_query) - .unwrap() -} - #[gpui::test] async fn test_python_inline_values(executor: BackgroundExecutor, cx: &mut TestAppContext) { init_test(cx); @@ -1859,21 +1842,23 @@ fn python_lang() -> Language { .unwrap() } -fn go_lang() -> Language { +fn go_lang() -> Arc { let debug_variables_query = include_str!("../../../languages/src/go/debugger.scm"); - Language::new( - LanguageConfig { - name: "Go".into(), - matcher: LanguageMatcher { - path_suffixes: vec!["go".to_string()], + Arc::new( + Language::new( + LanguageConfig { + name: "Go".into(), + matcher: LanguageMatcher { + path_suffixes: vec!["go".to_string()], + ..Default::default() + }, ..Default::default() }, - ..Default::default() - }, - Some(tree_sitter_go::LANGUAGE.into()), + Some(tree_sitter_go::LANGUAGE.into()), + ) + .with_debug_variables_query(debug_variables_query) + .unwrap(), ) - .with_debug_variables_query(debug_variables_query) - .unwrap() } /// Test utility function for inline values testing @@ -1891,7 +1876,7 @@ async fn test_inline_values_util( before: &str, after: &str, active_debug_line: Option, - language: Language, + language: Arc, executor: BackgroundExecutor, cx: &mut TestAppContext, ) { @@ -2091,7 +2076,7 @@ async fn test_inline_values_util( .unwrap(); buffer.update(cx, |buffer, cx| { - buffer.set_language(Some(Arc::new(language)), cx); + buffer.set_language(Some(language), cx); }); let (editor, cx) = cx.add_window_view(|window, cx| { @@ -2276,55 +2261,61 @@ fn main() { .await; } -fn javascript_lang() -> Language { +fn javascript_lang() -> Arc { let debug_variables_query = include_str!("../../../languages/src/javascript/debugger.scm"); - Language::new( - LanguageConfig { - name: "JavaScript".into(), - matcher: LanguageMatcher { - path_suffixes: vec!["js".to_string()], + Arc::new( + Language::new( + LanguageConfig { + name: "JavaScript".into(), + matcher: LanguageMatcher { + path_suffixes: vec!["js".to_string()], + ..Default::default() + }, ..Default::default() }, - ..Default::default() - }, - Some(tree_sitter_typescript::LANGUAGE_TYPESCRIPT.into()), + Some(tree_sitter_typescript::LANGUAGE_TYPESCRIPT.into()), + ) + .with_debug_variables_query(debug_variables_query) + .unwrap(), ) - .with_debug_variables_query(debug_variables_query) - .unwrap() } -fn typescript_lang() -> Language { +fn typescript_lang() -> Arc { let debug_variables_query = include_str!("../../../languages/src/typescript/debugger.scm"); - Language::new( - LanguageConfig { - name: "TypeScript".into(), - matcher: LanguageMatcher { - path_suffixes: vec!["ts".to_string()], + Arc::new( + Language::new( + LanguageConfig { + name: "TypeScript".into(), + matcher: LanguageMatcher { + path_suffixes: vec!["ts".to_string()], + ..Default::default() + }, ..Default::default() }, - ..Default::default() - }, - Some(tree_sitter_typescript::LANGUAGE_TYPESCRIPT.into()), + Some(tree_sitter_typescript::LANGUAGE_TYPESCRIPT.into()), + ) + .with_debug_variables_query(debug_variables_query) + .unwrap(), ) - .with_debug_variables_query(debug_variables_query) - .unwrap() } -fn tsx_lang() -> Language { +fn tsx_lang() -> Arc { let debug_variables_query = include_str!("../../../languages/src/tsx/debugger.scm"); - Language::new( - LanguageConfig { - name: "TSX".into(), - matcher: LanguageMatcher { - path_suffixes: vec!["tsx".to_string()], + Arc::new( + Language::new( + LanguageConfig { + name: "TSX".into(), + matcher: LanguageMatcher { + path_suffixes: vec!["tsx".to_string()], + ..Default::default() + }, ..Default::default() }, - ..Default::default() - }, - Some(tree_sitter_typescript::LANGUAGE_TSX.into()), + Some(tree_sitter_typescript::LANGUAGE_TSX.into()), + ) + .with_debug_variables_query(debug_variables_query) + .unwrap(), ) - .with_debug_variables_query(debug_variables_query) - .unwrap() } #[gpui::test] diff --git a/crates/edit_prediction/src/zeta1.rs b/crates/edit_prediction/src/zeta1.rs index 20f70421810c6d1678f844d1ec4c968b1ca96678..ad630484d392d75849bd33a52a55e63ea77ca23f 100644 --- a/crates/edit_prediction/src/zeta1.rs +++ b/crates/edit_prediction/src/zeta1.rs @@ -561,8 +561,7 @@ mod tests { use super::*; use gpui::{App, AppContext}; use indoc::indoc; - use language::{Buffer, Language, LanguageConfig, LanguageMatcher, tree_sitter_rust}; - use std::sync::Arc; + use language::Buffer; #[gpui::test] fn test_excerpt_for_cursor_position(cx: &mut App) { @@ -591,7 +590,7 @@ mod tests { numbers } "#}; - let buffer = cx.new(|cx| Buffer::local(text, cx).with_language(Arc::new(rust_lang()), cx)); + let buffer = cx.new(|cx| Buffer::local(text, cx).with_language(language::rust_lang(), cx)); let snapshot = buffer.read(cx).snapshot(); // Ensure we try to fit the largest possible syntax scope, resorting to line-based expansion @@ -649,18 +648,4 @@ mod tests { ```"#} ); } - - fn rust_lang() -> Language { - Language::new( - LanguageConfig { - name: "Rust".into(), - matcher: LanguageMatcher { - path_suffixes: vec!["rs".to_string()], - ..Default::default() - }, - ..Default::default() - }, - Some(tree_sitter_rust::LANGUAGE.into()), - ) - } } diff --git a/crates/edit_prediction_context/src/edit_prediction_context_tests.rs b/crates/edit_prediction_context/src/edit_prediction_context_tests.rs index f62df37e551db19145e9ea631b6ab6a16fefda78..dba8d89e593ccb60e7eae5d091708e82debef0f5 100644 --- a/crates/edit_prediction_context/src/edit_prediction_context_tests.rs +++ b/crates/edit_prediction_context/src/edit_prediction_context_tests.rs @@ -2,12 +2,12 @@ use super::*; use futures::channel::mpsc::UnboundedReceiver; use gpui::TestAppContext; use indoc::indoc; -use language::{Language, LanguageConfig, LanguageMatcher, Point, ToPoint as _, tree_sitter_rust}; +use language::{Point, ToPoint as _, rust_lang}; use lsp::FakeLanguageServer; use project::{FakeFs, LocationLink, Project}; use serde_json::json; use settings::SettingsStore; -use std::{fmt::Write as _, sync::Arc}; +use std::fmt::Write as _; use util::{path, test::marked_text_ranges}; #[gpui::test] @@ -508,23 +508,3 @@ fn format_excerpts(buffer: &Buffer, excerpts: &[RelatedExcerpt]) -> String { } output } - -pub(crate) fn rust_lang() -> Arc { - Arc::new( - Language::new( - LanguageConfig { - name: "Rust".into(), - matcher: LanguageMatcher { - path_suffixes: vec!["rs".to_string()], - first_line_pattern: None, - }, - ..Default::default() - }, - Some(tree_sitter_rust::LANGUAGE.into()), - ) - .with_highlights_query(include_str!("../../languages/src/rust/highlights.scm")) - .unwrap() - .with_outline_query(include_str!("../../languages/src/rust/outline.scm")) - .unwrap(), - ) -} diff --git a/crates/edit_prediction_context/src/excerpt.rs b/crates/edit_prediction_context/src/excerpt.rs index 55a3d8f03b277d0ce40f1d2ac947c55abf93f1c9..3fc7eed4ace5a83992bf496aef3e364aea96e215 100644 --- a/crates/edit_prediction_context/src/excerpt.rs +++ b/crates/edit_prediction_context/src/excerpt.rs @@ -419,30 +419,14 @@ fn node_line_end(node: Node) -> Point { mod tests { use super::*; use gpui::{AppContext, TestAppContext}; - use language::{Buffer, Language, LanguageConfig, LanguageMatcher, tree_sitter_rust}; + use language::Buffer; use util::test::{generate_marked_text, marked_text_offsets_by}; fn create_buffer(text: &str, cx: &mut TestAppContext) -> BufferSnapshot { - let buffer = cx.new(|cx| Buffer::local(text, cx).with_language(rust_lang().into(), cx)); + let buffer = cx.new(|cx| Buffer::local(text, cx).with_language(language::rust_lang(), cx)); buffer.read_with(cx, |buffer, _| buffer.snapshot()) } - fn rust_lang() -> Language { - Language::new( - LanguageConfig { - name: "Rust".into(), - matcher: LanguageMatcher { - path_suffixes: vec!["rs".to_string()], - ..Default::default() - }, - ..Default::default() - }, - Some(tree_sitter_rust::LANGUAGE.into()), - ) - .with_outline_query(include_str!("../../languages/src/rust/outline.scm")) - .unwrap() - } - fn cursor_and_excerpt_range(text: &str) -> (String, usize, Range) { let (text, offsets) = marked_text_offsets_by(text, vec!['ˇ', '«', '»']); (text, offsets[&'ˇ'][0], offsets[&'«'][0]..offsets[&'»'][0]) diff --git a/crates/editor/src/items.rs b/crates/editor/src/items.rs index ca8937bebe3d3578c7fe2fdec2c6252bdd395e6d..3b9c17f80f10116f2302bab203966922cbf0bcb2 100644 --- a/crates/editor/src/items.rs +++ b/crates/editor/src/items.rs @@ -1951,7 +1951,7 @@ mod tests { use super::*; use fs::MTime; use gpui::{App, VisualTestContext}; - use language::{LanguageMatcher, TestFile}; + use language::TestFile; use project::FakeFs; use std::path::{Path, PathBuf}; use util::{path, rel_path::RelPath}; @@ -1991,20 +1991,6 @@ mod tests { .unwrap() } - fn rust_language() -> Arc { - Arc::new(language::Language::new( - language::LanguageConfig { - name: "Rust".into(), - matcher: LanguageMatcher { - path_suffixes: vec!["rs".to_string()], - ..Default::default() - }, - ..Default::default() - }, - Some(tree_sitter_rust::LANGUAGE.into()), - )) - } - #[gpui::test] async fn test_deserialize(cx: &mut gpui::TestAppContext) { init_test(cx, |_| {}); @@ -2086,7 +2072,9 @@ mod tests { { let project = Project::test(fs.clone(), [path!("/file.rs").as_ref()], cx).await; // Add Rust to the language, so that we can restore the language of the buffer - project.read_with(cx, |project, _| project.languages().add(rust_language())); + project.read_with(cx, |project, _| { + project.languages().add(languages::rust_lang()) + }); let (workspace, cx) = cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx)); diff --git a/crates/language/src/buffer_tests.rs b/crates/language/src/buffer_tests.rs index e95bc544a56ecf9d561936ca48b10ccffcb23e72..6b5d2450fe72f46b728be0f5b151801fe2e7fa70 100644 --- a/crates/language/src/buffer_tests.rs +++ b/crates/language/src/buffer_tests.rs @@ -6,6 +6,7 @@ use futures::FutureExt as _; use gpui::{App, AppContext as _, BorrowAppContext, Entity}; use gpui::{HighlightStyle, TestAppContext}; use indoc::indoc; +use pretty_assertions::assert_eq; use proto::deserialize_operation; use rand::prelude::*; use regex::RegexBuilder; @@ -46,8 +47,7 @@ fn test_line_endings(cx: &mut gpui::App) { init_settings(cx, |_| {}); cx.new(|cx| { - let mut buffer = - Buffer::local("one\r\ntwo\rthree", cx).with_language(Arc::new(rust_lang()), cx); + let mut buffer = Buffer::local("one\r\ntwo\rthree", cx).with_language(rust_lang(), cx); assert_eq!(buffer.text(), "one\ntwo\nthree"); assert_eq!(buffer.line_ending(), LineEnding::Windows); @@ -608,7 +608,7 @@ async fn test_normalize_whitespace(cx: &mut gpui::TestAppContext) { #[gpui::test] async fn test_reparse(cx: &mut gpui::TestAppContext) { let text = "fn a() {}"; - let buffer = cx.new(|cx| Buffer::local(text, cx).with_language(Arc::new(rust_lang()), cx)); + let buffer = cx.new(|cx| Buffer::local(text, cx).with_language(rust_lang(), cx)); // Wait for the initial text to parse cx.executor().run_until_parked(); @@ -735,7 +735,7 @@ async fn test_reparse(cx: &mut gpui::TestAppContext) { #[gpui::test] async fn test_resetting_language(cx: &mut gpui::TestAppContext) { let buffer = cx.new(|cx| { - let mut buffer = Buffer::local("{}", cx).with_language(Arc::new(rust_lang()), cx); + let mut buffer = Buffer::local("{}", cx).with_language(rust_lang(), cx); buffer.set_sync_parse_timeout(Duration::ZERO); buffer }); @@ -783,11 +783,11 @@ async fn test_outline(cx: &mut gpui::TestAppContext) { "# .unindent(); - let buffer = cx.new(|cx| Buffer::local(text, cx).with_language(Arc::new(rust_lang()), cx)); + let buffer = cx.new(|cx| Buffer::local(text, cx).with_language(rust_lang(), cx)); let snapshot = buffer.update(cx, |buffer, _| buffer.snapshot()); let outline = snapshot.outline(None); - pretty_assertions::assert_eq!( + assert_eq!( outline .items .iter() @@ -819,7 +819,7 @@ async fn test_outline(cx: &mut gpui::TestAppContext) { ("LoggedIn", 2, Some("person: Person, time: Instant,".to_string())), ("person", 3, None), ("time", 3, None), - ("impl Eq for Person", 0, None), + ("impl Eq for Person", 0, Some("".to_string())), ( "impl Drop for Person", 0, @@ -890,7 +890,7 @@ async fn test_outline_nodes_with_newlines(cx: &mut gpui::TestAppContext) { "# .unindent(); - let buffer = cx.new(|cx| Buffer::local(text, cx).with_language(Arc::new(rust_lang()), cx)); + let buffer = cx.new(|cx| Buffer::local(text, cx).with_language(rust_lang(), cx)); let outline = buffer.update(cx, |buffer, _| buffer.snapshot().outline(None)); assert_eq!( @@ -970,7 +970,7 @@ fn test_outline_annotations(cx: &mut App) { "# .unindent(); - let buffer = cx.new(|cx| Buffer::local(text, cx).with_language(Arc::new(rust_lang()), cx)); + let buffer = cx.new(|cx| Buffer::local(text, cx).with_language(rust_lang(), cx)); let outline = buffer.update(cx, |buffer, _| buffer.snapshot().outline(None)); assert_eq!( @@ -1018,7 +1018,7 @@ async fn test_symbols_containing(cx: &mut gpui::TestAppContext) { "# .unindent(); - let buffer = cx.new(|cx| Buffer::local(text, cx).with_language(Arc::new(rust_lang()), cx)); + let buffer = cx.new(|cx| Buffer::local(text, cx).with_language(rust_lang(), cx)); let snapshot = buffer.update(cx, |buffer, _| buffer.snapshot()); // point is at the start of an item @@ -1093,7 +1093,7 @@ async fn test_symbols_containing(cx: &mut gpui::TestAppContext) { " .unindent(), ); - let buffer = cx.new(|cx| Buffer::local(text, cx).with_language(Arc::new(rust_lang()), cx)); + let buffer = cx.new(|cx| Buffer::local(text, cx).with_language(rust_lang(), cx)); let snapshot = buffer.update(cx, |buffer, _| buffer.snapshot()); // note, it would be nice to actually return the method test in this @@ -1112,8 +1112,7 @@ fn test_text_objects(cx: &mut App) { false, ); - let buffer = - cx.new(|cx| Buffer::local(text.clone(), cx).with_language(Arc::new(rust_lang()), cx)); + let buffer = cx.new(|cx| Buffer::local(text.clone(), cx).with_language(rust_lang(), cx)); let snapshot = buffer.update(cx, |buffer, _| buffer.snapshot()); let matches = snapshot @@ -1130,6 +1129,14 @@ fn test_text_objects(cx: &mut App) { "fn say() -> u8 { return /* hi */ 1 }", TextObject::AroundFunction ), + ( + "fn say() -> u8 { return /* hi */ 1 }", + TextObject::InsideClass + ), + ( + "impl Hello {\n fn say() -> u8 { return /* hi */ 1 }\n}", + TextObject::AroundClass + ), ], ) } @@ -1260,7 +1267,12 @@ fn test_enclosing_bracket_ranges(cx: &mut App) { #[gpui::test] fn test_enclosing_bracket_ranges_where_brackets_are_not_outermost_children(cx: &mut App) { let mut assert = |selection_text, bracket_pair_texts| { - assert_bracket_pairs(selection_text, bracket_pair_texts, javascript_lang(), cx) + assert_bracket_pairs( + selection_text, + bracket_pair_texts, + Arc::new(javascript_lang()), + cx, + ) }; assert( @@ -1293,7 +1305,7 @@ fn test_enclosing_bracket_ranges_where_brackets_are_not_outermost_children(cx: & fn test_range_for_syntax_ancestor(cx: &mut App) { cx.new(|cx| { let text = "fn a() { b(|c| {}) }"; - let buffer = Buffer::local(text, cx).with_language(Arc::new(rust_lang()), cx); + let buffer = Buffer::local(text, cx).with_language(rust_lang(), cx); let snapshot = buffer.snapshot(); assert_eq!( @@ -1345,7 +1357,7 @@ fn test_autoindent_with_soft_tabs(cx: &mut App) { cx.new(|cx| { let text = "fn a() {}"; - let mut buffer = Buffer::local(text, cx).with_language(Arc::new(rust_lang()), cx); + let mut buffer = Buffer::local(text, cx).with_language(rust_lang(), cx); buffer.edit([(8..8, "\n\n")], Some(AutoindentMode::EachLine), cx); assert_eq!(buffer.text(), "fn a() {\n \n}"); @@ -1387,7 +1399,7 @@ fn test_autoindent_with_hard_tabs(cx: &mut App) { cx.new(|cx| { let text = "fn a() {}"; - let mut buffer = Buffer::local(text, cx).with_language(Arc::new(rust_lang()), cx); + let mut buffer = Buffer::local(text, cx).with_language(rust_lang(), cx); buffer.edit([(8..8, "\n\n")], Some(AutoindentMode::EachLine), cx); assert_eq!(buffer.text(), "fn a() {\n\t\n}"); @@ -1436,7 +1448,7 @@ fn test_autoindent_does_not_adjust_lines_with_unchanged_suggestion(cx: &mut App) .unindent(), cx, ) - .with_language(Arc::new(rust_lang()), cx); + .with_language(rust_lang(), cx); // Lines 2 and 3 don't match the indentation suggestion. When editing these lines, // their indentation is not adjusted. @@ -1577,7 +1589,7 @@ fn test_autoindent_does_not_adjust_lines_with_unchanged_suggestion(cx: &mut App) .unindent(), cx, ) - .with_language(Arc::new(rust_lang()), cx); + .with_language(rust_lang(), cx); // Insert a closing brace. It is outdented. buffer.edit_via_marked_text( @@ -1640,7 +1652,7 @@ fn test_autoindent_does_not_adjust_lines_within_newly_created_errors(cx: &mut Ap .unindent(), cx, ) - .with_language(Arc::new(rust_lang()), cx); + .with_language(rust_lang(), cx); // Regression test: line does not get outdented due to syntax error buffer.edit_via_marked_text( @@ -1699,7 +1711,7 @@ fn test_autoindent_adjusts_lines_when_only_text_changes(cx: &mut App) { .unindent(), cx, ) - .with_language(Arc::new(rust_lang()), cx); + .with_language(rust_lang(), cx); buffer.edit_via_marked_text( &" @@ -1749,7 +1761,7 @@ fn test_autoindent_with_edit_at_end_of_buffer(cx: &mut App) { cx.new(|cx| { let text = "a\nb"; - let mut buffer = Buffer::local(text, cx).with_language(Arc::new(rust_lang()), cx); + let mut buffer = Buffer::local(text, cx).with_language(rust_lang(), cx); buffer.edit( [(0..1, "\n"), (2..3, "\n")], Some(AutoindentMode::EachLine), @@ -1775,7 +1787,7 @@ fn test_autoindent_multi_line_insertion(cx: &mut App) { " .unindent(); - let mut buffer = Buffer::local(text, cx).with_language(Arc::new(rust_lang()), cx); + let mut buffer = Buffer::local(text, cx).with_language(rust_lang(), cx); buffer.edit( [(Point::new(3, 0)..Point::new(3, 0), "e(\n f()\n);\n")], Some(AutoindentMode::EachLine), @@ -1812,7 +1824,7 @@ fn test_autoindent_block_mode(cx: &mut App) { } "# .unindent(); - let mut buffer = Buffer::local(text, cx).with_language(Arc::new(rust_lang()), cx); + let mut buffer = Buffer::local(text, cx).with_language(rust_lang(), cx); // When this text was copied, both of the quotation marks were at the same // indent level, but the indentation of the first line was not included in @@ -1895,7 +1907,7 @@ fn test_autoindent_block_mode_with_newline(cx: &mut App) { } "# .unindent(); - let mut buffer = Buffer::local(text, cx).with_language(Arc::new(rust_lang()), cx); + let mut buffer = Buffer::local(text, cx).with_language(rust_lang(), cx); // First line contains just '\n', it's indentation is stored in "original_indent_columns" let original_indent_columns = vec![Some(4)]; @@ -1947,7 +1959,7 @@ fn test_autoindent_block_mode_without_original_indent_columns(cx: &mut App) { } "# .unindent(); - let mut buffer = Buffer::local(text, cx).with_language(Arc::new(rust_lang()), cx); + let mut buffer = Buffer::local(text, cx).with_language(rust_lang(), cx); // The original indent columns are not known, so this text is // auto-indented in a block as if the first line was copied in @@ -2038,7 +2050,7 @@ fn test_autoindent_block_mode_multiple_adjacent_ranges(cx: &mut App) { false, ); - let mut buffer = Buffer::local(text, cx).with_language(Arc::new(rust_lang()), cx); + let mut buffer = Buffer::local(text, cx).with_language(rust_lang(), cx); buffer.edit( [ @@ -2052,7 +2064,7 @@ fn test_autoindent_block_mode_multiple_adjacent_ranges(cx: &mut App) { cx, ); - pretty_assertions::assert_eq!( + assert_eq!( buffer.text(), " mod numbers { @@ -2246,7 +2258,7 @@ async fn test_async_autoindents_preserve_preview(cx: &mut TestAppContext) { // Then we request that a preview tab be preserved for the new version, even though it's edited. let buffer = cx.new(|cx| { let text = "fn a() {}"; - let mut buffer = Buffer::local(text, cx).with_language(Arc::new(rust_lang()), cx); + let mut buffer = Buffer::local(text, cx).with_language(rust_lang(), cx); // This causes autoindent to be async. buffer.set_sync_parse_timeout(Duration::ZERO); @@ -2704,7 +2716,7 @@ fn test_language_at_with_hidden_languages(cx: &mut App) { .unindent(); let language_registry = Arc::new(LanguageRegistry::test(cx.background_executor().clone())); - language_registry.add(Arc::new(markdown_lang())); + language_registry.add(markdown_lang()); language_registry.add(Arc::new(markdown_inline_lang())); let mut buffer = Buffer::local(text, cx); @@ -2746,9 +2758,9 @@ fn test_language_at_for_markdown_code_block(cx: &mut App) { .unindent(); let language_registry = Arc::new(LanguageRegistry::test(cx.background_executor().clone())); - language_registry.add(Arc::new(markdown_lang())); + language_registry.add(markdown_lang()); language_registry.add(Arc::new(markdown_inline_lang())); - language_registry.add(Arc::new(rust_lang())); + language_registry.add(rust_lang()); let mut buffer = Buffer::local(text, cx); buffer.set_language_registry(language_registry.clone()); @@ -3145,7 +3157,7 @@ async fn test_preview_edits(cx: &mut TestAppContext) { cx: &mut TestAppContext, assert_fn: impl Fn(HighlightedText), ) { - let buffer = cx.new(|cx| Buffer::local(text, cx).with_language(Arc::new(rust_lang()), cx)); + let buffer = cx.new(|cx| Buffer::local(text, cx).with_language(rust_lang(), cx)); let edits = buffer.read_with(cx, |buffer, _| { edits .into_iter() @@ -3556,7 +3568,7 @@ let word=öäpple.bar你 Öäpple word2-öÄpPlE-Pizza-word ÖÄPPLE word "#; let buffer = cx.new(|cx| { - let buffer = Buffer::local(contents, cx).with_language(Arc::new(rust_lang()), cx); + let buffer = Buffer::local(contents, cx).with_language(rust_lang(), cx); assert_eq!(buffer.text(), contents); buffer.check_invariants(); buffer @@ -3781,78 +3793,6 @@ fn erb_lang() -> Language { .unwrap() } -fn rust_lang() -> Language { - Language::new( - LanguageConfig { - name: "Rust".into(), - matcher: LanguageMatcher { - path_suffixes: vec!["rs".to_string()], - ..Default::default() - }, - ..Default::default() - }, - Some(tree_sitter_rust::LANGUAGE.into()), - ) - .with_indents_query( - r#" - (call_expression) @indent - (field_expression) @indent - (_ "(" ")" @end) @indent - (_ "{" "}" @end) @indent - "#, - ) - .unwrap() - .with_brackets_query( - r#" - ("{" @open "}" @close) - "#, - ) - .unwrap() - .with_text_object_query( - r#" - (function_item - body: (_ - "{" - (_)* @function.inside - "}" )) @function.around - - (line_comment)+ @comment.around - - (block_comment) @comment.around - "#, - ) - .unwrap() - .with_outline_query( - r#" - (line_comment) @annotation - - (struct_item - "struct" @context - name: (_) @name) @item - (enum_item - "enum" @context - name: (_) @name) @item - (enum_variant - name: (_) @name) @item - (field_declaration - name: (_) @name) @item - (impl_item - "impl" @context - trait: (_)? @name - "for"? @context - type: (_) @name - body: (_ "{" (_)* "}")) @item - (function_item - "fn" @context - name: (_) @name) @item - (mod_item - "mod" @context - name: (_) @name) @item - "#, - ) - .unwrap() -} - fn json_lang() -> Language { Language::new( LanguageConfig { @@ -3890,32 +3830,6 @@ fn javascript_lang() -> Language { .unwrap() } -pub fn markdown_lang() -> Language { - Language::new( - LanguageConfig { - name: "Markdown".into(), - matcher: LanguageMatcher { - path_suffixes: vec!["md".into()], - ..Default::default() - }, - ..Default::default() - }, - Some(tree_sitter_md::LANGUAGE.into()), - ) - .with_injection_query( - r#" - (fenced_code_block - (info_string - (language) @injection.language) - (code_fence_content) @injection.content) - - ((inline) @injection.content - (#set! injection.language "markdown-inline")) - "#, - ) - .unwrap() -} - pub fn markdown_inline_lang() -> Language { Language::new( LanguageConfig { @@ -3942,12 +3856,11 @@ fn get_tree_sexp(buffer: &Entity, cx: &mut gpui::TestAppContext) -> Stri fn assert_bracket_pairs( selection_text: &'static str, bracket_pair_texts: Vec<&'static str>, - language: Language, + language: Arc, cx: &mut App, ) { let (expected_text, selection_ranges) = marked_text_ranges(selection_text, false); - let buffer = - cx.new(|cx| Buffer::local(expected_text.clone(), cx).with_language(Arc::new(language), cx)); + let buffer = cx.new(|cx| Buffer::local(expected_text.clone(), cx).with_language(language, cx)); let buffer = buffer.update(cx, |buffer, _cx| buffer.snapshot()); let selection_range = selection_ranges[0].clone(); diff --git a/crates/language/src/language.rs b/crates/language/src/language.rs index 0451be3ee164aa70b549f3502a45f5e52fbafce3..891e4842a49b81659c9e4a9bf42a0655ef30abcb 100644 --- a/crates/language/src/language.rs +++ b/crates/language/src/language.rs @@ -2656,7 +2656,28 @@ pub fn rust_lang() -> Arc { text_objects: Some(Cow::from(include_str!( "../../languages/src/rust/textobjects.scm" ))), - ..LanguageQueries::default() + highlights: Some(Cow::from(include_str!( + "../../languages/src/rust/highlights.scm" + ))), + embedding: Some(Cow::from(include_str!( + "../../languages/src/rust/embedding.scm" + ))), + injections: Some(Cow::from(include_str!( + "../../languages/src/rust/injections.scm" + ))), + overrides: Some(Cow::from(include_str!( + "../../languages/src/rust/overrides.scm" + ))), + redactions: None, + runnables: Some(Cow::from(include_str!( + "../../languages/src/rust/runnables.scm" + ))), + debugger: Some(Cow::from(include_str!( + "../../languages/src/rust/debugger.scm" + ))), + imports: Some(Cow::from(include_str!( + "../../languages/src/rust/imports.scm" + ))), }) .expect("Could not parse queries"); Arc::new(language) @@ -2685,6 +2706,15 @@ pub fn markdown_lang() -> Arc { injections: Some(Cow::from(include_str!( "../../languages/src/markdown/injections.scm" ))), + highlights: Some(Cow::from(include_str!( + "../../languages/src/markdown/highlights.scm" + ))), + indents: Some(Cow::from(include_str!( + "../../languages/src/markdown/indents.scm" + ))), + outline: Some(Cow::from(include_str!( + "../../languages/src/markdown/outline.scm" + ))), ..LanguageQueries::default() }) .expect("Could not parse markdown queries"); diff --git a/crates/language/src/syntax_map/syntax_map_tests.rs b/crates/language/src/syntax_map/syntax_map_tests.rs index 9c4eecad363de386cddc6e943e20e5762634d713..1eb63772760719a381d16795ecde0c4a3293c789 100644 --- a/crates/language/src/syntax_map/syntax_map_tests.rs +++ b/crates/language/src/syntax_map/syntax_map_tests.rs @@ -1,9 +1,9 @@ use super::*; use crate::{ - LanguageConfig, LanguageMatcher, - buffer_tests::{markdown_inline_lang, markdown_lang}, + LanguageConfig, LanguageMatcher, buffer_tests::markdown_inline_lang, markdown_lang, rust_lang, }; use gpui::App; +use pretty_assertions::assert_eq; use rand::rngs::StdRng; use std::{env, ops::Range, sync::Arc}; use text::{Buffer, BufferId, ReplicaId}; @@ -84,7 +84,7 @@ fn test_splice_included_ranges() { #[gpui::test] fn test_syntax_map_layers_for_range(cx: &mut App) { let registry = Arc::new(LanguageRegistry::test(cx.background_executor().clone())); - let language = Arc::new(rust_lang()); + let language = rust_lang(); registry.add(language.clone()); let mut buffer = Buffer::new( @@ -181,11 +181,11 @@ fn test_syntax_map_layers_for_range(cx: &mut App) { #[gpui::test] fn test_dynamic_language_injection(cx: &mut App) { let registry = Arc::new(LanguageRegistry::test(cx.background_executor().clone())); - let markdown = Arc::new(markdown_lang()); + let markdown = markdown_lang(); let markdown_inline = Arc::new(markdown_inline_lang()); registry.add(markdown.clone()); registry.add(markdown_inline.clone()); - registry.add(Arc::new(rust_lang())); + registry.add(rust_lang()); registry.add(Arc::new(ruby_lang())); let mut buffer = Buffer::new( @@ -291,7 +291,7 @@ fn test_typing_multiple_new_injections(cx: &mut App) { assert_capture_ranges( &syntax_map, &buffer, - &["field"], + &["property"], "fn a() { test_macro!(b.«c»(vec![d.«e»])) }", ); } @@ -329,16 +329,16 @@ fn test_pasting_new_injection_line_between_others(cx: &mut App) { assert_capture_ranges( &syntax_map, &buffer, - &["struct"], + &["type"], " fn a() { - b!(«B {}»); - c!(«C {}»); - d!(«D {}»); - h!(«H {}»); - e!(«E {}»); - f!(«F {}»); - g!(«G {}»); + b!(«B» {}); + c!(«C» {}); + d!(«D» {}); + h!(«H» {}); + e!(«E» {}); + f!(«F» {}); + g!(«G» {}); } ", ); @@ -376,7 +376,7 @@ fn test_joining_injections_with_child_injections(cx: &mut App) { assert_capture_ranges( &syntax_map, &buffer, - &["field"], + &["property"], " fn a() { b!( @@ -900,7 +900,7 @@ fn test_random_syntax_map_edits_rust_macros(rng: StdRng, cx: &mut App) { .repeat(2); let registry = Arc::new(LanguageRegistry::test(cx.background_executor().clone())); - let language = Arc::new(rust_lang()); + let language = rust_lang(); registry.add(language.clone()); test_random_edits(text, registry, language, rng); @@ -1147,11 +1147,11 @@ fn test_edit_sequence(language_name: &str, steps: &[&str], cx: &mut App) -> (Buf let registry = Arc::new(LanguageRegistry::test(cx.background_executor().clone())); registry.add(Arc::new(elixir_lang())); registry.add(Arc::new(heex_lang())); - registry.add(Arc::new(rust_lang())); + registry.add(rust_lang()); registry.add(Arc::new(ruby_lang())); registry.add(Arc::new(html_lang())); registry.add(Arc::new(erb_lang())); - registry.add(Arc::new(markdown_lang())); + registry.add(markdown_lang()); registry.add(Arc::new(markdown_inline_lang())); let language = registry @@ -1287,35 +1287,6 @@ fn erb_lang() -> Language { .unwrap() } -fn rust_lang() -> Language { - Language::new( - LanguageConfig { - name: "Rust".into(), - matcher: LanguageMatcher { - path_suffixes: vec!["rs".to_string()], - ..Default::default() - }, - ..Default::default() - }, - Some(tree_sitter_rust::LANGUAGE.into()), - ) - .with_highlights_query( - r#" - (field_identifier) @field - (struct_expression) @struct - "#, - ) - .unwrap() - .with_injection_query( - r#" - (macro_invocation - (token_tree) @injection.content - (#set! injection.language "rust")) - "#, - ) - .unwrap() -} - fn elixir_lang() -> Language { Language::new( LanguageConfig { @@ -1425,6 +1396,7 @@ fn assert_capture_ranges( actual_ranges.push(capture.node.byte_range()); } } + actual_ranges.dedup(); let (text, expected_ranges) = marked_text_ranges(&marked_string.unindent(), false); assert_eq!(text, buffer.text()); diff --git a/crates/markdown_preview/Cargo.toml b/crates/markdown_preview/Cargo.toml index 89e5ec5921a3ad330a75343e980dfeff0f535b00..d61ec00cc8cfd5e04768381b64d5230682924623 100644 --- a/crates/markdown_preview/Cargo.toml +++ b/crates/markdown_preview/Cargo.toml @@ -37,3 +37,4 @@ workspace.workspace = true [dev-dependencies] editor = { workspace = true, features = ["test-support"] } +language = { workspace = true, features = ["test-support"] } diff --git a/crates/markdown_preview/src/markdown_parser.rs b/crates/markdown_preview/src/markdown_parser.rs index 7b3886d10f5c8977f8766bddc39fb81f6d8f316f..b17ee5cac455605ce49d0dd436d163e49f2954bd 100644 --- a/crates/markdown_preview/src/markdown_parser.rs +++ b/crates/markdown_preview/src/markdown_parser.rs @@ -1467,9 +1467,7 @@ mod tests { use ParsedMarkdownListItemType::*; use core::panic; use gpui::{AbsoluteLength, BackgroundExecutor, DefiniteLength}; - use language::{ - HighlightId, Language, LanguageConfig, LanguageMatcher, LanguageRegistry, tree_sitter_rust, - }; + use language::{HighlightId, LanguageRegistry}; use pretty_assertions::assert_eq; async fn parse(input: &str) -> ParsedMarkdown { @@ -3053,7 +3051,7 @@ fn main() { #[gpui::test] async fn test_code_block_with_language(executor: BackgroundExecutor) { let language_registry = Arc::new(LanguageRegistry::test(executor.clone())); - language_registry.add(rust_lang()); + language_registry.add(language::rust_lang()); let parsed = parse_markdown( "\ @@ -3079,21 +3077,6 @@ fn main() { ); } - fn rust_lang() -> Arc { - Arc::new(Language::new( - LanguageConfig { - name: "Rust".into(), - matcher: LanguageMatcher { - path_suffixes: vec!["rs".into()], - ..Default::default() - }, - collapsed_placeholder: " /* ... */ ".to_string(), - ..Default::default() - }, - Some(tree_sitter_rust::LANGUAGE.into()), - )) - } - fn h1(contents: MarkdownParagraph, source_range: Range) -> ParsedMarkdownElement { ParsedMarkdownElement::Heading(ParsedMarkdownHeading { source_range, diff --git a/crates/outline/src/outline.rs b/crates/outline/src/outline.rs index 7127627226d3aa55877f067038b69e6e848e1c3a..1f5cf1edab15a190a9f15d6106190eae637b9f3d 100644 --- a/crates/outline/src/outline.rs +++ b/crates/outline/src/outline.rs @@ -391,7 +391,6 @@ mod tests { use super::*; use gpui::{TestAppContext, VisualTestContext}; use indoc::indoc; - use language::{Language, LanguageConfig, LanguageMatcher}; use project::{FakeFs, Project}; use serde_json::json; use util::{path, rel_path::rel_path}; @@ -418,7 +417,9 @@ mod tests { .await; let project = Project::test(fs, [path!("/dir").as_ref()], cx).await; - project.read_with(cx, |project, _| project.languages().add(rust_lang())); + project.read_with(cx, |project, _| { + project.languages().add(language::rust_lang()) + }); let (workspace, cx) = cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx)); @@ -581,89 +582,6 @@ mod tests { }) } - fn rust_lang() -> Arc { - Arc::new( - Language::new( - LanguageConfig { - name: "Rust".into(), - matcher: LanguageMatcher { - path_suffixes: vec!["rs".to_string()], - ..Default::default() - }, - ..Default::default() - }, - Some(tree_sitter_rust::LANGUAGE.into()), - ) - .with_outline_query( - r#"(struct_item - (visibility_modifier)? @context - "struct" @context - name: (_) @name) @item - - (enum_item - (visibility_modifier)? @context - "enum" @context - name: (_) @name) @item - - (enum_variant - (visibility_modifier)? @context - name: (_) @name) @item - - (impl_item - "impl" @context - trait: (_)? @name - "for"? @context - type: (_) @name) @item - - (trait_item - (visibility_modifier)? @context - "trait" @context - name: (_) @name) @item - - (function_item - (visibility_modifier)? @context - (function_modifiers)? @context - "fn" @context - name: (_) @name) @item - - (function_signature_item - (visibility_modifier)? @context - (function_modifiers)? @context - "fn" @context - name: (_) @name) @item - - (macro_definition - . "macro_rules!" @context - name: (_) @name) @item - - (mod_item - (visibility_modifier)? @context - "mod" @context - name: (_) @name) @item - - (type_item - (visibility_modifier)? @context - "type" @context - name: (_) @name) @item - - (associated_type - "type" @context - name: (_) @name) @item - - (const_item - (visibility_modifier)? @context - "const" @context - name: (_) @name) @item - - (field_declaration - (visibility_modifier)? @context - name: (_) @name) @item -"#, - ) - .unwrap(), - ) - } - #[track_caller] fn assert_single_caret_at_row( editor: &Entity, diff --git a/crates/outline_panel/src/outline_panel.rs b/crates/outline_panel/src/outline_panel.rs index 6e78b8a1e1f573d9870d42c6a5e99c8574e6979a..85cca3c2b1273d6abcd85af6db8df7fdcb411220 100644 --- a/crates/outline_panel/src/outline_panel.rs +++ b/crates/outline_panel/src/outline_panel.rs @@ -5220,7 +5220,7 @@ impl GenerationState { mod tests { use db::indoc; use gpui::{TestAppContext, VisualTestContext, WindowHandle}; - use language::{Language, LanguageConfig, LanguageMatcher, tree_sitter_rust}; + use language::rust_lang; use pretty_assertions::assert_eq; use project::FakeFs; use search::{ @@ -5243,9 +5243,7 @@ mod tests { let root = path!("/rust-analyzer"); populate_with_test_ra_project(&fs, root).await; let project = Project::test(fs.clone(), [Path::new(root)], cx).await; - project.read_with(cx, |project, _| { - project.languages().add(Arc::new(rust_lang())) - }); + project.read_with(cx, |project, _| project.languages().add(rust_lang())); let workspace = add_outline_panel(&project, cx).await; let cx = &mut VisualTestContext::from_window(*workspace, cx); let outline_panel = outline_panel(&workspace, cx); @@ -5478,9 +5476,7 @@ mod tests { let root = path!("/rust-analyzer"); populate_with_test_ra_project(&fs, root).await; let project = Project::test(fs.clone(), [Path::new(root)], cx).await; - project.read_with(cx, |project, _| { - project.languages().add(Arc::new(rust_lang())) - }); + project.read_with(cx, |project, _| project.languages().add(rust_lang())); let workspace = add_outline_panel(&project, cx).await; let cx = &mut VisualTestContext::from_window(*workspace, cx); let outline_panel = outline_panel(&workspace, cx); @@ -5617,9 +5613,7 @@ mod tests { let root = path!("/rust-analyzer"); populate_with_test_ra_project(&fs, root).await; let project = Project::test(fs.clone(), [Path::new(root)], cx).await; - project.read_with(cx, |project, _| { - project.languages().add(Arc::new(rust_lang())) - }); + project.read_with(cx, |project, _| project.languages().add(rust_lang())); let workspace = add_outline_panel(&project, cx).await; let cx = &mut VisualTestContext::from_window(*workspace, cx); let outline_panel = outline_panel(&workspace, cx); @@ -5816,7 +5810,8 @@ mod tests { outline_panel.selected_entry(), cx, ), - "fn_lifetime_fn.rs <==== selected" + "outline: pub(super) fn hints +outline: fn hints_lifetimes_named <==== selected" ); assert_eq!( selected_row_text(&new_active_editor, cx), @@ -6029,24 +6024,7 @@ struct OutlineEntryExcerpt { ) .await; let project = Project::test(fs.clone(), [Path::new(root)], cx).await; - project.read_with(cx, |project, _| { - project.languages().add(Arc::new( - rust_lang() - .with_outline_query( - r#" - (struct_item - (visibility_modifier)? @context - "struct" @context - name: (_) @name) @item - - (field_declaration - (visibility_modifier)? @context - name: (_) @name) @item -"#, - ) - .unwrap(), - )) - }); + project.read_with(cx, |project, _| project.languages().add(rust_lang())); let workspace = add_outline_panel(&project, cx).await; let cx = &mut VisualTestContext::from_window(*workspace, cx); let outline_panel = outline_panel(&workspace, cx); @@ -6992,35 +6970,6 @@ outline: struct OutlineEntryExcerpt .await; } - fn rust_lang() -> Language { - Language::new( - LanguageConfig { - name: "Rust".into(), - matcher: LanguageMatcher { - path_suffixes: vec!["rs".to_string()], - ..Default::default() - }, - ..Default::default() - }, - Some(tree_sitter_rust::LANGUAGE.into()), - ) - .with_highlights_query( - r#" - (field_identifier) @field - (struct_expression) @struct - "#, - ) - .unwrap() - .with_injection_query( - r#" - (macro_invocation - (token_tree) @injection.content - (#set! injection.language "rust")) - "#, - ) - .unwrap() - } - fn snapshot(outline_panel: &OutlinePanel, cx: &App) -> MultiBufferSnapshot { outline_panel .active_editor() @@ -7086,44 +7035,7 @@ outline: struct OutlineEntryExcerpt .await; let project = Project::test(fs.clone(), ["/test".as_ref()], cx).await; - project.read_with(cx, |project, _| { - project.languages().add(Arc::new( - rust_lang() - .with_outline_query( - r#" - (struct_item - (visibility_modifier)? @context - "struct" @context - name: (_) @name) @item - (impl_item - "impl" @context - trait: (_)? @context - "for"? @context - type: (_) @context - body: (_)) @item - (function_item - (visibility_modifier)? @context - "fn" @context - name: (_) @name - parameters: (_) @context) @item - (mod_item - (visibility_modifier)? @context - "mod" @context - name: (_) @name) @item - (enum_item - (visibility_modifier)? @context - "enum" @context - name: (_) @name) @item - (field_declaration - (visibility_modifier)? @context - name: (_) @name - ":" @context - type: (_) @context) @item - "#, - ) - .unwrap(), - )) - }); + project.read_with(cx, |project, _| project.languages().add(rust_lang())); let workspace = add_outline_panel(&project, cx).await; let cx = &mut VisualTestContext::from_window(*workspace, cx); let outline_panel = outline_panel(&workspace, cx); @@ -7174,15 +7086,15 @@ outline: struct OutlineEntryExcerpt " outline: mod outer <==== selected outline: pub struct OuterStruct - outline: field: String + outline: field outline: impl OuterStruct - outline: pub fn new() - outline: pub fn method(&self) + outline: pub fn new + outline: pub fn method outline: mod inner - outline: pub fn inner_function() + outline: pub fn inner_function outline: pub struct InnerStruct - outline: value: i32 -outline: fn main()" + outline: value +outline: fn main" ) ); }); @@ -7232,7 +7144,7 @@ outline: fn main()" indoc!( " outline: mod outer <==== selected -outline: fn main()" +outline: fn main" ) ); }); @@ -7257,15 +7169,15 @@ outline: fn main()" " outline: mod outer <==== selected outline: pub struct OuterStruct - outline: field: String + outline: field outline: impl OuterStruct - outline: pub fn new() - outline: pub fn method(&self) + outline: pub fn new + outline: pub fn method outline: mod inner - outline: pub fn inner_function() + outline: pub fn inner_function outline: pub struct InnerStruct - outline: value: i32 -outline: fn main()" + outline: value +outline: fn main" ) ); }); @@ -7321,7 +7233,7 @@ outline: fn main()" indoc!( " outline: mod outer -outline: fn main()" +outline: fn main" ) ); }); @@ -7378,44 +7290,7 @@ outline: fn main()" .await; let project = Project::test(fs.clone(), ["/test".as_ref()], cx).await; - project.read_with(cx, |project, _| { - project.languages().add(Arc::new( - rust_lang() - .with_outline_query( - r#" - (struct_item - (visibility_modifier)? @context - "struct" @context - name: (_) @name) @item - (impl_item - "impl" @context - trait: (_)? @context - "for"? @context - type: (_) @context - body: (_)) @item - (function_item - (visibility_modifier)? @context - "fn" @context - name: (_) @name - parameters: (_) @context) @item - (mod_item - (visibility_modifier)? @context - "mod" @context - name: (_) @name) @item - (enum_item - (visibility_modifier)? @context - "enum" @context - name: (_) @name) @item - (field_declaration - (visibility_modifier)? @context - name: (_) @name - ":" @context - type: (_) @context) @item - "#, - ) - .unwrap(), - )) - }); + project.read_with(cx, |project, _| project.languages().add(rust_lang())); let workspace = add_outline_panel(&project, cx).await; let cx = &mut VisualTestContext::from_window(*workspace, cx); @@ -7462,14 +7337,16 @@ outline: fn main()" indoc!( " outline: struct Config - outline: name: String - outline: value: i32 + outline: name + outline: value outline: impl Config - outline: fn new(name: String) - outline: fn get_value(&self) + outline: fn new + outline: fn get_value outline: enum Status -outline: fn process_config(config: Config) -outline: fn main()" + outline: Active + outline: Inactive +outline: fn process_config +outline: fn main" ) ); }); @@ -7500,14 +7377,16 @@ outline: fn main()" indoc!( " outline: struct Config <==== selected - outline: name: String - outline: value: i32 + outline: name + outline: value outline: impl Config - outline: fn new(name: String) - outline: fn get_value(&self) + outline: fn new + outline: fn get_value outline: enum Status -outline: fn process_config(config: Config) -outline: fn main()" + outline: Active + outline: Inactive +outline: fn process_config +outline: fn main" ) ); }); @@ -7535,11 +7414,13 @@ outline: fn main()" " outline: struct Config <==== selected outline: impl Config - outline: fn new(name: String) - outline: fn get_value(&self) + outline: fn new + outline: fn get_value outline: enum Status -outline: fn process_config(config: Config) -outline: fn main()" + outline: Active + outline: Inactive +outline: fn process_config +outline: fn main" ) ); }); @@ -7566,14 +7447,16 @@ outline: fn main()" indoc!( " outline: struct Config <==== selected - outline: name: String - outline: value: i32 + outline: name + outline: value outline: impl Config - outline: fn new(name: String) - outline: fn get_value(&self) + outline: fn new + outline: fn get_value outline: enum Status -outline: fn process_config(config: Config) -outline: fn main()" + outline: Active + outline: Inactive +outline: fn process_config +outline: fn main" ) ); }); @@ -7622,44 +7505,7 @@ outline: fn main()" .await; let project = Project::test(fs.clone(), ["/test".as_ref()], cx).await; - project.read_with(cx, |project, _| { - project.languages().add(Arc::new( - rust_lang() - .with_outline_query( - r#" - (struct_item - (visibility_modifier)? @context - "struct" @context - name: (_) @name) @item - (impl_item - "impl" @context - trait: (_)? @context - "for"? @context - type: (_) @context - body: (_)) @item - (function_item - (visibility_modifier)? @context - "fn" @context - name: (_) @name - parameters: (_) @context) @item - (mod_item - (visibility_modifier)? @context - "mod" @context - name: (_) @name) @item - (enum_item - (visibility_modifier)? @context - "enum" @context - name: (_) @name) @item - (field_declaration - (visibility_modifier)? @context - name: (_) @name - ":" @context - type: (_) @context) @item - "#, - ) - .unwrap(), - )) - }); + project.read_with(cx, |project, _| project.languages().add(rust_lang())); let workspace = add_outline_panel(&project, cx).await; let cx = &mut VisualTestContext::from_window(*workspace, cx); let outline_panel = outline_panel(&workspace, cx); @@ -7710,15 +7556,15 @@ outline: fn main()" " outline: mod outer <==== selected outline: pub struct OuterStruct - outline: field: String + outline: field outline: impl OuterStruct - outline: pub fn new() - outline: pub fn method(&self) + outline: pub fn new + outline: pub fn method outline: mod inner - outline: pub fn inner_function() + outline: pub fn inner_function outline: pub struct InnerStruct - outline: value: i32 -outline: fn main()" + outline: value +outline: fn main" ) ); }); @@ -7759,7 +7605,7 @@ outline: fn main()" let expected_collapsed_output = indoc!( " outline: mod outer <==== selected - outline: fn main()" + outline: fn main" ); outline_panel.update(cx, |panel, cx| { @@ -7787,15 +7633,15 @@ outline: fn main()" " outline: mod outer <==== selected outline: pub struct OuterStruct - outline: field: String + outline: field outline: impl OuterStruct - outline: pub fn new() - outline: pub fn method(&self) + outline: pub fn new + outline: pub fn method outline: mod inner - outline: pub fn inner_function() + outline: pub fn inner_function outline: pub struct InnerStruct - outline: value: i32 - outline: fn main()" + outline: value + outline: fn main" ); outline_panel.update(cx, |panel, cx| { diff --git a/crates/project/src/project_tests.rs b/crates/project/src/project_tests.rs index 8adba2dea16391c35096c487c4eff0098d52df56..24b2280edee55a0131c73f6b91b3cea7adc6bbad 100644 --- a/crates/project/src/project_tests.rs +++ b/crates/project/src/project_tests.rs @@ -28,7 +28,7 @@ use language::{ ManifestName, ManifestProvider, ManifestQuery, OffsetRangeExt, Point, ToPoint, ToolchainList, ToolchainLister, language_settings::{LanguageSettingsContent, language_settings}, - tree_sitter_rust, tree_sitter_typescript, + rust_lang, tree_sitter_typescript, }; use lsp::{ DiagnosticSeverity, DocumentChanges, FileOperationFilter, NumberOrString, TextDocumentEdit, @@ -10468,20 +10468,6 @@ fn js_lang() -> Arc { )) } -fn rust_lang() -> Arc { - Arc::new(Language::new( - LanguageConfig { - name: "Rust".into(), - matcher: LanguageMatcher { - path_suffixes: vec!["rs".to_string()], - ..Default::default() - }, - ..Default::default() - }, - Some(tree_sitter_rust::LANGUAGE.into()), - )) -} - fn python_lang(fs: Arc) -> Arc { struct PythonMootToolchainLister(Arc); #[async_trait] diff --git a/crates/vim/src/object.rs b/crates/vim/src/object.rs index 2f5ccac07bfe5f6f11b048e317523292dd74294d..f11386d02d6846343645b6c7514603f16396163c 100644 --- a/crates/vim/src/object.rs +++ b/crates/vim/src/object.rs @@ -2382,9 +2382,10 @@ mod test { Mode::Insert, ); - cx.set_state("let a = (test::call(), 'p', my_macro!{ˇ});", Mode::Normal); - cx.simulate_keystrokes("c a a"); - cx.assert_state("let a = (test::call(), 'p'ˇ);", Mode::Insert); + // TODO regressed with the up-to-date Rust grammar. + // cx.set_state("let a = (test::call(), 'p', my_macro!{ˇ});", Mode::Normal); + // cx.simulate_keystrokes("c a a"); + // cx.assert_state("let a = (test::call(), 'p'ˇ);", Mode::Insert); cx.set_state("let a = [test::call(ˇ), 300];", Mode::Normal); cx.simulate_keystrokes("c i a"); diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs index 164d6b8383fe940e3a92d5461edbff878300474a..1361fcdba788752099c8e5b37b51e751fccf4dfd 100644 --- a/crates/zed/src/zed.rs +++ b/crates/zed/src/zed.rs @@ -2255,7 +2255,8 @@ mod tests { Action, AnyWindowHandle, App, AssetSource, BorrowAppContext, TestAppContext, UpdateGlobal, VisualTestContext, WindowHandle, actions, }; - use language::{LanguageMatcher, LanguageRegistry}; + use language::LanguageRegistry; + use languages::{markdown_lang, rust_lang}; use pretty_assertions::{assert_eq, assert_ne}; use project::{Project, ProjectPath}; use semver::Version; @@ -2895,9 +2896,7 @@ mod tests { .await; let project = Project::test(app_state.fs.clone(), [path!("/root").as_ref()], cx).await; - project.update(cx, |project, _cx| { - project.languages().add(markdown_language()) - }); + project.update(cx, |project, _cx| project.languages().add(markdown_lang())); let window = cx.add_window(|window, cx| Workspace::test_new(project, window, cx)); let workspace = window.root(cx).unwrap(); @@ -3327,9 +3326,7 @@ mod tests { .await; let project = Project::test(app_state.fs.clone(), [path!("/root").as_ref()], cx).await; - project.update(cx, |project, _cx| { - project.languages().add(markdown_language()) - }); + project.update(cx, |project, _cx| project.languages().add(markdown_lang())); let window = cx.add_window(|window, cx| Workspace::test_new(project, window, cx)); let workspace = window.root(cx).unwrap(); @@ -3421,9 +3418,7 @@ mod tests { .await; let project = Project::test(app_state.fs.clone(), [path!("/root").as_ref()], cx).await; - project.update(cx, |project, _cx| { - project.languages().add(markdown_language()) - }); + project.update(cx, |project, _cx| project.languages().add(markdown_lang())); let window = cx.add_window(|window, cx| Workspace::test_new(project, window, cx)); let workspace = window.root(cx).unwrap(); @@ -3494,7 +3489,7 @@ mod tests { let project = Project::test(app_state.fs.clone(), [path!("/root").as_ref()], cx).await; project.update(cx, |project, _| { - project.languages().add(markdown_language()); + project.languages().add(markdown_lang()); project.languages().add(rust_lang()); }); let window = cx.add_window(|window, cx| Workspace::test_new(project, window, cx)); @@ -3647,8 +3642,8 @@ mod tests { let project = Project::test(app_state.fs.clone(), [], cx).await; project.update(cx, |project, _| { - project.languages().add(rust_lang()); - project.languages().add(markdown_language()); + project.languages().add(language::rust_lang()); + project.languages().add(language::markdown_lang()); }); let window = cx.add_window(|window, cx| Workspace::test_new(project, window, cx)); @@ -3727,9 +3722,7 @@ mod tests { .await; let project = Project::test(app_state.fs.clone(), [path!("/root").as_ref()], cx).await; - project.update(cx, |project, _cx| { - project.languages().add(markdown_language()) - }); + project.update(cx, |project, _cx| project.languages().add(markdown_lang())); let window = cx.add_window(|window, cx| Workspace::test_new(project, window, cx)); let workspace = window.root(cx).unwrap(); @@ -3831,9 +3824,7 @@ mod tests { .await; let project = Project::test(app_state.fs.clone(), [path!("/root").as_ref()], cx).await; - project.update(cx, |project, _cx| { - project.languages().add(markdown_language()) - }); + project.update(cx, |project, _cx| project.languages().add(markdown_lang())); let workspace = cx.add_window(|window, cx| Workspace::test_new(project.clone(), window, cx)); let pane = workspace @@ -4225,9 +4216,7 @@ mod tests { .await; let project = Project::test(app_state.fs.clone(), [path!("/root").as_ref()], cx).await; - project.update(cx, |project, _cx| { - project.languages().add(markdown_language()) - }); + project.update(cx, |project, _cx| project.languages().add(markdown_lang())); let workspace = cx.add_window(|window, cx| Workspace::test_new(project, window, cx)); let pane = workspace .read_with(cx, |workspace, _| workspace.active_pane().clone()) @@ -4914,7 +4903,7 @@ mod tests { let state = Arc::get_mut(&mut app_state).unwrap(); state.build_window_options = build_window_options; - app_state.languages.add(markdown_language()); + app_state.languages.add(markdown_lang()); gpui_tokio::init(cx); theme::init(theme::LoadThemes::JustBase, cx); @@ -4965,34 +4954,6 @@ mod tests { }) } - fn rust_lang() -> Arc { - Arc::new(language::Language::new( - language::LanguageConfig { - name: "Rust".into(), - matcher: LanguageMatcher { - path_suffixes: vec!["rs".to_string()], - ..Default::default() - }, - ..Default::default() - }, - Some(tree_sitter_rust::LANGUAGE.into()), - )) - } - - fn markdown_language() -> Arc { - Arc::new(language::Language::new( - language::LanguageConfig { - name: "Markdown".into(), - matcher: LanguageMatcher { - path_suffixes: vec!["md".to_string()], - ..Default::default() - }, - ..Default::default() - }, - Some(tree_sitter_md::LANGUAGE.into()), - )) - } - #[track_caller] fn assert_key_bindings_for( window: AnyWindowHandle, From a574ae877922c6451645df7abeef1a2f45d5c572 Mon Sep 17 00:00:00 2001 From: Remco Smits Date: Sat, 6 Dec 2025 20:31:08 +0100 Subject: [PATCH 102/621] debugger: Start work on adding session snapshot feature (#44298) This PR adds the basic logic for a feature that allows you to visit any stopped information back in time. We will follow up with PRs to improve this and actually add UI for it so the UX is better. https://github.com/user-attachments/assets/42d8a5b3-8ab8-471a-bdd0-f579662eadd6 Edit Anthony: We feature flagged this so external users won't be able to access this until the feature is polished Release Notes: - N/A --------- Co-authored-by: Anthony Eid --- Cargo.lock | 1 + crates/debugger_ui/Cargo.toml | 1 + crates/debugger_ui/src/debugger_panel.rs | 37 ++- crates/debugger_ui/src/session/running.rs | 2 +- crates/project/src/debugger/dap_store.rs | 2 +- crates/project/src/debugger/session.rs | 266 ++++++++++++++-------- 6 files changed, 215 insertions(+), 94 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a8f0096a7a1219ee30b287c61efd9f77f4b9d223..0bbde0bdfddb0b11b715bce230cb82cb4c74cb0f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4583,6 +4583,7 @@ dependencies = [ "db", "debugger_tools", "editor", + "feature_flags", "file_icons", "futures 0.3.31", "fuzzy", diff --git a/crates/debugger_ui/Cargo.toml b/crates/debugger_ui/Cargo.toml index 25d23b96b897001faec39498c5b08ef08b09a3a1..fb79b1b0790b28d7204774720bf9c413cfed64e6 100644 --- a/crates/debugger_ui/Cargo.toml +++ b/crates/debugger_ui/Cargo.toml @@ -37,6 +37,7 @@ dap_adapters = { workspace = true, optional = true } db.workspace = true debugger_tools.workspace = true editor.workspace = true +feature_flags.workspace = true file_icons.workspace = true futures.workspace = true fuzzy.workspace = true diff --git a/crates/debugger_ui/src/debugger_panel.rs b/crates/debugger_ui/src/debugger_panel.rs index ffdd4a22e3d092eb5d3d6626dcfe8b167ae03936..fe81ac641196dbbc5ceecaede0785ca72336c261 100644 --- a/crates/debugger_ui/src/debugger_panel.rs +++ b/crates/debugger_ui/src/debugger_panel.rs @@ -15,6 +15,7 @@ use dap::adapters::DebugAdapterName; use dap::{DapRegistry, StartDebuggingRequestArguments}; use dap::{client::SessionId, debugger_settings::DebuggerSettings}; use editor::{Editor, MultiBufferOffset, ToPoint}; +use feature_flags::{FeatureFlag, FeatureFlagAppExt as _}; use gpui::{ Action, App, AsyncWindowContext, ClipboardItem, Context, DismissEvent, Entity, EntityId, EventEmitter, FocusHandle, Focusable, MouseButton, MouseDownEvent, Point, Subscription, Task, @@ -42,6 +43,12 @@ use workspace::{ }; use zed_actions::ToggleFocus; +pub struct DebuggerHistoryFeatureFlag; + +impl FeatureFlag for DebuggerHistoryFeatureFlag { + const NAME: &'static str = "debugger-history"; +} + const DEBUG_PANEL_KEY: &str = "DebugPanel"; pub struct DebugPanel { @@ -284,7 +291,7 @@ impl DebugPanel { } }); - session.update(cx, |session, _| match &mut session.mode { + session.update(cx, |session, _| match &mut session.state { SessionState::Booting(state_task) => { *state_task = Some(boot_task); } @@ -805,6 +812,34 @@ impl DebugPanel { } }), ) + .when(cx.has_flag::(), |this| { + this.child( + IconButton::new( + "debug-back-in-history", + IconName::HistoryRerun, + ) + .icon_size(IconSize::Small) + .on_click( + window.listener_for( + running_state, + |this, _, _window, cx| { + this.session().update(cx, |session, cx| { + let ix = session + .active_history() + .unwrap_or_else(|| { + session.history().len() + }); + + session.go_back_to_history( + Some(ix.saturating_sub(1)), + cx, + ); + }) + }, + ), + ), + ) + }) .child(Divider::vertical()) .child( IconButton::new("debug-restart", IconName::RotateCcw) diff --git a/crates/debugger_ui/src/session/running.rs b/crates/debugger_ui/src/session/running.rs index b82f839edee82f884c1419d44a2344c39c8abd0d..bc99d6ac8e42b0a706df4a09177ae2103d5939e2 100644 --- a/crates/debugger_ui/src/session/running.rs +++ b/crates/debugger_ui/src/session/running.rs @@ -1743,7 +1743,7 @@ impl RunningState { let is_building = self.session.update(cx, |session, cx| { session.shutdown(cx).detach(); - matches!(session.mode, session::SessionState::Booting(_)) + matches!(session.state, session::SessionState::Booting(_)) }); if is_building { diff --git a/crates/project/src/debugger/dap_store.rs b/crates/project/src/debugger/dap_store.rs index a82286441d625561009f4f9259f5c06fe424ff10..4a588e7c436f5f29fffd953b8fce988daa4655d8 100644 --- a/crates/project/src/debugger/dap_store.rs +++ b/crates/project/src/debugger/dap_store.rs @@ -692,7 +692,7 @@ impl DapStore { } VariableLookupKind::Expression => { let Ok(eval_task) = session.read_with(cx, |session, _| { - session.mode.request_dap(EvaluateCommand { + session.state.request_dap(EvaluateCommand { expression: inline_value_location.variable_name.clone(), frame_id: Some(stack_frame_id), source: None, diff --git a/crates/project/src/debugger/session.rs b/crates/project/src/debugger/session.rs index 47fe98827cbc163682ef6f002eff4008967d4ced..a63e9066c9a30233ee1edb15aac13da145cb76b2 100644 --- a/crates/project/src/debugger/session.rs +++ b/crates/project/src/debugger/session.rs @@ -1,7 +1,3 @@ -use crate::debugger::breakpoint_store::BreakpointSessionState; -use crate::debugger::dap_command::{DataBreakpointContext, ReadMemory}; -use crate::debugger::memory::{self, Memory, MemoryIterator, MemoryPageBuilder, PageAddress}; - use super::breakpoint_store::{ BreakpointStore, BreakpointStoreEvent, BreakpointUpdatedReason, SourceBreakpoint, }; @@ -14,6 +10,9 @@ use super::dap_command::{ TerminateCommand, TerminateThreadsCommand, ThreadsCommand, VariablesCommand, }; use super::dap_store::DapStore; +use crate::debugger::breakpoint_store::BreakpointSessionState; +use crate::debugger::dap_command::{DataBreakpointContext, ReadMemory}; +use crate::debugger::memory::{self, Memory, MemoryIterator, MemoryPageBuilder, PageAddress}; use anyhow::{Context as _, Result, anyhow, bail}; use base64::Engine; use collections::{HashMap, HashSet, IndexMap}; @@ -42,15 +41,13 @@ use gpui::{ Task, WeakEntity, }; use http_client::HttpClient; - use node_runtime::NodeRuntime; use remote::RemoteClient; -use rpc::ErrorExt; use serde::{Deserialize, Serialize}; use serde_json::Value; use smol::net::{TcpListener, TcpStream}; use std::any::TypeId; -use std::collections::BTreeMap; +use std::collections::{BTreeMap, VecDeque}; use std::net::Ipv4Addr; use std::ops::RangeInclusive; use std::path::PathBuf; @@ -71,6 +68,9 @@ use util::command::new_smol_command; use util::{ResultExt, debug_panic, maybe}; use worktree::Worktree; +const MAX_TRACKED_OUTPUT_EVENTS: usize = 5000; +const DEBUG_HISTORY_LIMIT: usize = 10; + #[derive(Debug, Copy, Clone, Hash, PartialEq, PartialOrd, Ord, Eq)] #[repr(transparent)] pub struct ThreadId(pub i64); @@ -118,11 +118,11 @@ impl ThreadStatus { } } -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct Thread { dap: dap::Thread, stack_frames: Vec, - stack_frames_error: Option, + stack_frames_error: Option, _has_stopped: bool, } @@ -672,7 +672,18 @@ impl ThreadStates { .any(|status| *status == ThreadStatus::Stopped) } } -const MAX_TRACKED_OUTPUT_EVENTS: usize = 5000; + +// TODO(debugger): Wrap dap types with reference counting so the UI doesn't have to clone them on refresh +#[derive(Default)] +pub struct SessionSnapshot { + threads: IndexMap, + thread_states: ThreadStates, + variables: HashMap>, + stack_frames: IndexMap, + locations: HashMap, + modules: Vec, + loaded_sources: Vec, +} type IsEnabled = bool; @@ -680,23 +691,19 @@ type IsEnabled = bool; pub struct OutputToken(pub usize); /// Represents a current state of a single debug adapter and provides ways to mutate it. pub struct Session { - pub mode: SessionState, + pub state: SessionState, + active_snapshot: SessionSnapshot, + snapshots: VecDeque, + selected_snapshot_index: Option, id: SessionId, label: Option, adapter: DebugAdapterName, pub(super) capabilities: Capabilities, child_session_ids: HashSet, parent_session: Option>, - modules: Vec, - loaded_sources: Vec, output_token: OutputToken, output: Box>, - threads: IndexMap, - thread_states: ThreadStates, watchers: HashMap, - variables: HashMap>, - stack_frames: IndexMap, - locations: HashMap, is_session_terminated: bool, requests: HashMap>>>>, pub(crate) breakpoint_store: Entity, @@ -858,24 +865,20 @@ impl Session { .detach(); Self { - mode: SessionState::Booting(None), + state: SessionState::Booting(None), + snapshots: VecDeque::with_capacity(DEBUG_HISTORY_LIMIT), + selected_snapshot_index: None, + active_snapshot: Default::default(), id: session_id, child_session_ids: HashSet::default(), parent_session, capabilities: Capabilities::default(), watchers: HashMap::default(), - variables: Default::default(), - stack_frames: Default::default(), - thread_states: ThreadStates::default(), output_token: OutputToken(0), output: circular_buffer::CircularBuffer::boxed(), requests: HashMap::default(), - modules: Vec::default(), - loaded_sources: Vec::default(), - threads: IndexMap::default(), background_tasks: Vec::default(), restart_task: None, - locations: Default::default(), is_session_terminated: false, ignore_breakpoints: false, breakpoint_store, @@ -899,7 +902,7 @@ impl Session { } pub fn worktree(&self) -> Option> { - match &self.mode { + match &self.state { SessionState::Booting(_) => None, SessionState::Running(local_mode) => local_mode.worktree.upgrade(), } @@ -960,7 +963,7 @@ impl Session { ) .await?; this.update(cx, |this, cx| { - match &mut this.mode { + match &mut this.state { SessionState::Booting(task) if task.is_some() => { task.take().unwrap().detach_and_log_err(cx); } @@ -969,7 +972,7 @@ impl Session { debug_panic!("Attempting to boot a session that is already running"); } }; - this.mode = SessionState::Running(mode); + this.state = SessionState::Running(mode); cx.emit(SessionStateEvent::Running); })?; @@ -1061,7 +1064,7 @@ impl Session { } pub fn binary(&self) -> Option<&DebugAdapterBinary> { - match &self.mode { + match &self.state { SessionState::Booting(_) => None, SessionState::Running(running_mode) => Some(&running_mode.binary), } @@ -1107,25 +1110,25 @@ impl Session { } pub fn is_started(&self) -> bool { - match &self.mode { + match &self.state { SessionState::Booting(_) => false, SessionState::Running(running) => running.is_started, } } pub fn is_building(&self) -> bool { - matches!(self.mode, SessionState::Booting(_)) + matches!(self.state, SessionState::Booting(_)) } pub fn as_running_mut(&mut self) -> Option<&mut RunningMode> { - match &mut self.mode { + match &mut self.state { SessionState::Running(local_mode) => Some(local_mode), SessionState::Booting(_) => None, } } pub fn as_running(&self) -> Option<&RunningMode> { - match &self.mode { + match &self.state { SessionState::Running(local_mode) => Some(local_mode), SessionState::Booting(_) => None, } @@ -1269,7 +1272,7 @@ impl Session { let adapter_id = self.adapter().to_string(); let request = Initialize { adapter_id }; - let SessionState::Running(running) = &self.mode else { + let SessionState::Running(running) = &self.state else { return Task::ready(Err(anyhow!( "Cannot send initialize request, task still building" ))); @@ -1317,7 +1320,7 @@ impl Session { dap_store: WeakEntity, cx: &mut Context, ) -> Task> { - match &self.mode { + match &self.state { SessionState::Running(local_mode) => { local_mode.initialize_sequence(&self.capabilities, initialize_rx, dap_store, cx) } @@ -1333,10 +1336,12 @@ impl Session { active_thread_id: ThreadId, cx: &mut Context, ) { - match &mut self.mode { + match &mut self.state { SessionState::Running(local_mode) => { if !matches!( - self.thread_states.thread_state(active_thread_id), + self.active_snapshot + .thread_states + .thread_state(active_thread_id), Some(ThreadStatus::Stopped) ) { return; @@ -1411,8 +1416,51 @@ impl Session { }) } + fn session_state(&self) -> &SessionSnapshot { + self.selected_snapshot_index + .and_then(|ix| self.snapshots.get(ix)) + .unwrap_or_else(|| &self.active_snapshot) + } + + fn push_to_history(&mut self) { + if !self.has_ever_stopped() { + return; + } + + while self.snapshots.len() >= DEBUG_HISTORY_LIMIT { + self.snapshots.pop_front(); + } + + self.snapshots + .push_back(std::mem::take(&mut self.active_snapshot)); + } + + pub fn history(&self) -> &VecDeque { + &self.snapshots + } + + pub fn go_back_to_history(&mut self, ix: Option, cx: &mut Context<'_, Session>) { + if self.selected_snapshot_index == ix { + return; + } + + self.selected_snapshot_index = ix; + + if ix.is_some() { + cx.emit(SessionEvent::Stopped(None)); + } + + cx.notify(); + } + + pub fn active_history(&self) -> Option { + self.selected_snapshot_index + } + fn handle_stopped_event(&mut self, event: StoppedEvent, cx: &mut Context) { - self.mode.stopped(); + self.push_to_history(); + + self.state.stopped(); // todo(debugger): Find a clean way to get around the clone let breakpoint_store = self.breakpoint_store.clone(); if let Some((local, path)) = self.as_running_mut().and_then(|local| { @@ -1431,14 +1479,16 @@ impl Session { }; if event.all_threads_stopped.unwrap_or_default() || event.thread_id.is_none() { - self.thread_states.stop_all_threads(); + self.active_snapshot.thread_states.stop_all_threads(); self.invalidate_command_type::(); } // Event if we stopped all threads we still need to insert the thread_id // to our own data if let Some(thread_id) = event.thread_id { - self.thread_states.stop_thread(ThreadId(thread_id)); + self.active_snapshot + .thread_states + .stop_thread(ThreadId(thread_id)); self.invalidate_state( &StackTraceCommand { @@ -1451,8 +1501,8 @@ impl Session { } self.invalidate_generic(); - self.threads.clear(); - self.variables.clear(); + self.active_snapshot.threads.clear(); + self.active_snapshot.variables.clear(); cx.emit(SessionEvent::Stopped( event .thread_id @@ -1474,12 +1524,13 @@ impl Session { Events::Stopped(event) => self.handle_stopped_event(event, cx), Events::Continued(event) => { if event.all_threads_continued.unwrap_or_default() { - self.thread_states.continue_all_threads(); + self.active_snapshot.thread_states.continue_all_threads(); self.breakpoint_store.update(cx, |store, cx| { store.remove_active_position(Some(self.session_id()), cx) }); } else { - self.thread_states + self.active_snapshot + .thread_states .continue_thread(ThreadId(event.thread_id)); } // todo(debugger): We should be able to get away with only invalidating generic if all threads were continued @@ -1496,10 +1547,12 @@ impl Session { match event.reason { dap::ThreadEventReason::Started => { - self.thread_states.continue_thread(thread_id); + self.active_snapshot + .thread_states + .continue_thread(thread_id); } dap::ThreadEventReason::Exited => { - self.thread_states.exit_thread(thread_id); + self.active_snapshot.thread_states.exit_thread(thread_id); } reason => { log::error!("Unhandled thread event reason {:?}", reason); @@ -1526,10 +1579,11 @@ impl Session { Events::Module(event) => { match event.reason { dap::ModuleEventReason::New => { - self.modules.push(event.module); + self.active_snapshot.modules.push(event.module); } dap::ModuleEventReason::Changed => { if let Some(module) = self + .active_snapshot .modules .iter_mut() .find(|other| event.module.id == other.id) @@ -1538,7 +1592,9 @@ impl Session { } } dap::ModuleEventReason::Removed => { - self.modules.retain(|other| event.module.id != other.id); + self.active_snapshot + .modules + .retain(|other| event.module.id != other.id); } } @@ -1612,9 +1668,16 @@ impl Session { ); } - if !self.thread_states.any_stopped_thread() + if self.selected_snapshot_index.is_some() { + return; + } + + if self.is_session_terminated { + return; + } + + if !self.active_snapshot.thread_states.any_stopped_thread() && request.type_id() != TypeId::of::() - || self.is_session_terminated { return; } @@ -1629,7 +1692,7 @@ impl Session { let task = Self::request_inner::>( &self.capabilities, - &self.mode, + &self.state, command, |this, result, cx| { process_result(this, result, cx); @@ -1697,7 +1760,7 @@ impl Session { + 'static, cx: &mut Context, ) -> Task> { - Self::request_inner(&self.capabilities, &self.mode, request, process_result, cx) + Self::request_inner(&self.capabilities, &self.state, request, process_result, cx) } fn invalidate_command_type(&mut self) { @@ -1730,11 +1793,11 @@ impl Session { } pub fn any_stopped_thread(&self) -> bool { - self.thread_states.any_stopped_thread() + self.active_snapshot.thread_states.any_stopped_thread() } pub fn thread_status(&self, thread_id: ThreadId) -> ThreadStatus { - self.thread_states.thread_status(thread_id) + self.active_snapshot.thread_states.thread_status(thread_id) } pub fn threads(&mut self, cx: &mut Context) -> Vec<(dap::Thread, ThreadStatus)> { @@ -1745,7 +1808,7 @@ impl Session { return; }; - this.threads = result + this.active_snapshot.threads = result .into_iter() .map(|thread| (ThreadId(thread.id), Thread::from(thread))) .collect(); @@ -1757,12 +1820,14 @@ impl Session { cx, ); - self.threads + let state = self.session_state(); + state + .threads .values() .map(|thread| { ( thread.dap.clone(), - self.thread_states.thread_status(ThreadId(thread.dap.id)), + state.thread_states.thread_status(ThreadId(thread.dap.id)), ) }) .collect() @@ -1776,14 +1841,14 @@ impl Session { return; }; - this.modules = result; + this.active_snapshot.modules = result; cx.emit(SessionEvent::Modules); cx.notify(); }, cx, ); - &self.modules + &self.session_state().modules } // CodeLLDB returns the size of a pointed-to-memory, which we can use to make the experience of go-to-memory better. @@ -2034,14 +2099,13 @@ impl Session { let Some(result) = result.log_err() else { return; }; - this.loaded_sources = result; + this.active_snapshot.loaded_sources = result; cx.emit(SessionEvent::LoadedSources); cx.notify(); }, cx, ); - - &self.loaded_sources + &self.session_state().loaded_sources } fn fallback_to_manual_restart( @@ -2073,7 +2137,7 @@ impl Session { Some(response) } None => { - this.thread_states.stop_thread(thread_id); + this.active_snapshot.thread_states.stop_thread(thread_id); cx.notify(); None } @@ -2149,10 +2213,10 @@ impl Session { } self.is_session_terminated = true; - self.thread_states.exit_all_threads(); + self.active_snapshot.thread_states.exit_all_threads(); cx.notify(); - let task = match &mut self.mode { + let task = match &mut self.state { SessionState::Running(_) => { if self .capabilities @@ -2213,9 +2277,13 @@ impl Session { } pub fn continue_thread(&mut self, thread_id: ThreadId, cx: &mut Context) { + self.go_back_to_history(None, cx); + let supports_single_thread_execution_requests = self.capabilities.supports_single_thread_execution_requests; - self.thread_states.continue_thread(thread_id); + self.active_snapshot + .thread_states + .continue_thread(thread_id); self.request( ContinueCommand { args: ContinueArguments { @@ -2230,21 +2298,24 @@ impl Session { } pub fn adapter_client(&self) -> Option> { - match self.mode { + match self.state { SessionState::Running(ref local) => Some(local.client.clone()), SessionState::Booting(_) => None, } } pub fn has_ever_stopped(&self) -> bool { - self.mode.has_ever_stopped() + self.state.has_ever_stopped() } + pub fn step_over( &mut self, thread_id: ThreadId, granularity: SteppingGranularity, cx: &mut Context, ) { + self.go_back_to_history(None, cx); + let supports_single_thread_execution_requests = self.capabilities.supports_single_thread_execution_requests; let supports_stepping_granularity = self @@ -2260,7 +2331,7 @@ impl Session { }, }; - self.thread_states.process_step(thread_id); + self.active_snapshot.thread_states.process_step(thread_id); self.request( command, Self::on_step_response::(thread_id), @@ -2275,6 +2346,8 @@ impl Session { granularity: SteppingGranularity, cx: &mut Context, ) { + self.go_back_to_history(None, cx); + let supports_single_thread_execution_requests = self.capabilities.supports_single_thread_execution_requests; let supports_stepping_granularity = self @@ -2290,7 +2363,7 @@ impl Session { }, }; - self.thread_states.process_step(thread_id); + self.active_snapshot.thread_states.process_step(thread_id); self.request( command, Self::on_step_response::(thread_id), @@ -2305,6 +2378,8 @@ impl Session { granularity: SteppingGranularity, cx: &mut Context, ) { + self.go_back_to_history(None, cx); + let supports_single_thread_execution_requests = self.capabilities.supports_single_thread_execution_requests; let supports_stepping_granularity = self @@ -2320,7 +2395,7 @@ impl Session { }, }; - self.thread_states.process_step(thread_id); + self.active_snapshot.thread_states.process_step(thread_id); self.request( command, Self::on_step_response::(thread_id), @@ -2335,6 +2410,8 @@ impl Session { granularity: SteppingGranularity, cx: &mut Context, ) { + self.go_back_to_history(None, cx); + let supports_single_thread_execution_requests = self.capabilities.supports_single_thread_execution_requests; let supports_stepping_granularity = self @@ -2350,7 +2427,7 @@ impl Session { }, }; - self.thread_states.process_step(thread_id); + self.active_snapshot.thread_states.process_step(thread_id); self.request( command, @@ -2365,9 +2442,9 @@ impl Session { thread_id: ThreadId, cx: &mut Context, ) -> Result> { - if self.thread_states.thread_status(thread_id) == ThreadStatus::Stopped + if self.active_snapshot.thread_states.thread_status(thread_id) == ThreadStatus::Stopped && self.requests.contains_key(&ThreadsCommand.type_id()) - && self.threads.contains_key(&thread_id) + && self.active_snapshot.threads.contains_key(&thread_id) // ^ todo(debugger): We need a better way to check that we're not querying stale data // We could still be using an old thread id and have sent a new thread's request // This isn't the biggest concern right now because it hasn't caused any issues outside of tests @@ -2381,7 +2458,8 @@ impl Session { }, move |this, stack_frames, cx| { let entry = - this.threads + this.active_snapshot + .threads .entry(thread_id) .and_modify(|thread| match &stack_frames { Ok(stack_frames) => { @@ -2394,7 +2472,7 @@ impl Session { } Err(error) => { thread.stack_frames.clear(); - thread.stack_frames_error = Some(error.cloned()); + thread.stack_frames_error = Some(error.to_string().into()); } }); debug_assert!( @@ -2402,7 +2480,7 @@ impl Session { "Sent request for thread_id that doesn't exist" ); if let Ok(stack_frames) = stack_frames { - this.stack_frames.extend( + this.active_snapshot.stack_frames.extend( stack_frames .into_iter() .filter(|frame| { @@ -2427,10 +2505,10 @@ impl Session { ); } - match self.threads.get(&thread_id) { + match self.active_snapshot.threads.get(&thread_id) { Some(thread) => { if let Some(error) = &thread.stack_frames_error { - Err(error.cloned()) + Err(anyhow!(error.to_string())) } else { Ok(thread.stack_frames.clone()) } @@ -2457,6 +2535,7 @@ impl Session { } let entry = this + .active_snapshot .stack_frames .entry(stack_frame_id) .and_modify(|stack_frame| { @@ -2474,7 +2553,8 @@ impl Session { ); } - self.stack_frames + self.session_state() + .stack_frames .get(&stack_frame_id) .map(|frame| frame.scopes.as_slice()) .unwrap_or_default() @@ -2486,7 +2566,8 @@ impl Session { globals: bool, locals: bool, ) -> Vec { - let Some(stack_frame) = self.stack_frames.get(&stack_frame_id) else { + let state = self.session_state(); + let Some(stack_frame) = state.stack_frames.get(&stack_frame_id) else { return Vec::new(); }; @@ -2497,7 +2578,7 @@ impl Session { (scope.name.to_lowercase().contains("local") && locals) || (scope.name.to_lowercase().contains("global") && globals) }) - .filter_map(|scope| self.variables.get(&scope.variables_reference)) + .filter_map(|scope| state.variables.get(&scope.variables_reference)) .flatten() .cloned() .collect() @@ -2513,7 +2594,7 @@ impl Session { frame_id: u64, cx: &mut Context, ) -> Task> { - let request = self.mode.request_dap(EvaluateCommand { + let request = self.state.request_dap(EvaluateCommand { expression: expression.to_string(), context: Some(EvaluateArgumentsContext::Watch), frame_id: Some(frame_id), @@ -2570,7 +2651,9 @@ impl Session { return; }; - this.variables.insert(variables_reference, variables); + this.active_snapshot + .variables + .insert(variables_reference, variables); cx.emit(SessionEvent::Variables); cx.emit(SessionEvent::InvalidateInlineValue); @@ -2578,7 +2661,8 @@ impl Session { cx, ); - self.variables + self.session_state() + .variables .get(&variables_reference) .cloned() .unwrap_or_default() @@ -2645,7 +2729,7 @@ impl Session { location_reference: None, }; self.push_output(event); - let request = self.mode.request_dap(EvaluateCommand { + let request = self.state.request_dap(EvaluateCommand { expression, context, frame_id, @@ -2705,15 +2789,15 @@ impl Session { let Some(response) = response.log_err() else { return; }; - this.locations.insert(reference, response); + this.active_snapshot.locations.insert(reference, response); }, cx, ); - self.locations.get(&reference).cloned() + self.session_state().locations.get(&reference).cloned() } pub fn is_attached(&self) -> bool { - let SessionState::Running(local_mode) = &self.mode else { + let SessionState::Running(local_mode) = &self.state else { return false; }; local_mode.binary.request_args.request == StartDebuggingRequestArgumentsRequest::Attach @@ -2749,7 +2833,7 @@ impl Session { } pub fn thread_state(&self, thread_id: ThreadId) -> Option { - self.thread_states.thread_state(thread_id) + self.session_state().thread_states.thread_state(thread_id) } pub fn quirks(&self) -> SessionQuirks { From 4577e1bf8fb42ec96d6054f2da4de89df2d822cd Mon Sep 17 00:00:00 2001 From: Remco Smits Date: Sat, 6 Dec 2025 21:34:19 +0100 Subject: [PATCH 103/621] debugger: Get stack frame list working with historic snapshot feature (#44303) This PR fixes an issue where the stack frame list would not update when viewing a historic snapshot. We now also show the right active debug line based on the currently selected history. https://github.com/user-attachments/assets/baccd078-23ed-4db3-9959-f83dc2be8309 Release Notes: - N/A --------- Co-authored-by: Anthony Eid --- .../src/session/running/loaded_source_list.rs | 4 +++- .../src/session/running/module_list.rs | 4 +++- .../src/session/running/stack_frame_list.rs | 4 +++- .../src/session/running/variable_list.rs | 7 ++++++- crates/project/src/debugger/session.rs | 19 +++++++------------ 5 files changed, 22 insertions(+), 16 deletions(-) diff --git a/crates/debugger_ui/src/session/running/loaded_source_list.rs b/crates/debugger_ui/src/session/running/loaded_source_list.rs index 921ebd8b5f5bdfe8a3c8a8f7bb1625bd1ffad7fb..e55fad336b5ee6dfbee1cb0c90ea3d19f561a2ba 100644 --- a/crates/debugger_ui/src/session/running/loaded_source_list.rs +++ b/crates/debugger_ui/src/session/running/loaded_source_list.rs @@ -17,7 +17,9 @@ impl LoadedSourceList { let list = ListState::new(0, gpui::ListAlignment::Top, px(1000.)); let _subscription = cx.subscribe(&session, |this, _, event, cx| match event { - SessionEvent::Stopped(_) | SessionEvent::LoadedSources => { + SessionEvent::Stopped(_) + | SessionEvent::HistoricSnapshotSelected + | SessionEvent::LoadedSources => { this.invalidate = true; cx.notify(); } diff --git a/crates/debugger_ui/src/session/running/module_list.rs b/crates/debugger_ui/src/session/running/module_list.rs index 19f407eb23f8acf0aa665f5119ecfd2156eb685f..7d0228fc6851185d10a3a237257d6244d5a90c76 100644 --- a/crates/debugger_ui/src/session/running/module_list.rs +++ b/crates/debugger_ui/src/session/running/module_list.rs @@ -32,7 +32,9 @@ impl ModuleList { let focus_handle = cx.focus_handle(); let _subscription = cx.subscribe(&session, |this, _, event, cx| match event { - SessionEvent::Stopped(_) | SessionEvent::Modules => { + SessionEvent::Stopped(_) + | SessionEvent::HistoricSnapshotSelected + | SessionEvent::Modules => { if this._rebuild_task.is_some() { this.schedule_rebuild(cx); } diff --git a/crates/debugger_ui/src/session/running/stack_frame_list.rs b/crates/debugger_ui/src/session/running/stack_frame_list.rs index 96a910af4dd0ac901c6802c139ddd5b8b3d728bc..5ecdc0f74be97c01ace933fd3513535040599bac 100644 --- a/crates/debugger_ui/src/session/running/stack_frame_list.rs +++ b/crates/debugger_ui/src/session/running/stack_frame_list.rs @@ -97,7 +97,9 @@ impl StackFrameList { SessionEvent::Threads => { this.schedule_refresh(false, window, cx); } - SessionEvent::Stopped(..) | SessionEvent::StackTrace => { + SessionEvent::Stopped(..) + | SessionEvent::StackTrace + | SessionEvent::HistoricSnapshotSelected => { this.schedule_refresh(true, window, cx); } _ => {} diff --git a/crates/debugger_ui/src/session/running/variable_list.rs b/crates/debugger_ui/src/session/running/variable_list.rs index 1b455b59d7d12712a3d4adc713a6ed15e8166c6e..7b23cd685d93e6353d68dc57cd3998099ea56ad7 100644 --- a/crates/debugger_ui/src/session/running/variable_list.rs +++ b/crates/debugger_ui/src/session/running/variable_list.rs @@ -217,6 +217,12 @@ impl VariableList { let _subscriptions = vec![ cx.subscribe(&stack_frame_list, Self::handle_stack_frame_list_events), cx.subscribe(&session, |this, _, event, cx| match event { + SessionEvent::HistoricSnapshotSelected => { + this.selection.take(); + this.edited_path.take(); + this.selected_stack_frame_id.take(); + this.build_entries(cx); + } SessionEvent::Stopped(_) => { this.selection.take(); this.edited_path.take(); @@ -225,7 +231,6 @@ impl VariableList { SessionEvent::Variables | SessionEvent::Watchers => { this.build_entries(cx); } - _ => {} }), cx.on_focus_out(&focus_handle, window, |this, _, _, cx| { diff --git a/crates/project/src/debugger/session.rs b/crates/project/src/debugger/session.rs index a63e9066c9a30233ee1edb15aac13da145cb76b2..9d4d307f990bfc5f00190f74ce3f1f957e71bacc 100644 --- a/crates/project/src/debugger/session.rs +++ b/crates/project/src/debugger/session.rs @@ -808,6 +808,7 @@ pub enum SessionEvent { }, DataBreakpointInfo, ConsoleOutput, + HistoricSnapshotSelected, } #[derive(Clone, Debug, PartialEq, Eq)] @@ -1447,7 +1448,7 @@ impl Session { self.selected_snapshot_index = ix; if ix.is_some() { - cx.emit(SessionEvent::Stopped(None)); + cx.emit(SessionEvent::HistoricSnapshotSelected); } cx.notify(); @@ -1668,16 +1669,10 @@ impl Session { ); } - if self.selected_snapshot_index.is_some() { - return; - } - - if self.is_session_terminated { - return; - } - - if !self.active_snapshot.thread_states.any_stopped_thread() - && request.type_id() != TypeId::of::() + if (!self.active_snapshot.thread_states.any_stopped_thread() + && request.type_id() != TypeId::of::()) + || self.selected_snapshot_index.is_some() + || self.is_session_terminated { return; } @@ -2505,7 +2500,7 @@ impl Session { ); } - match self.active_snapshot.threads.get(&thread_id) { + match self.session_state().threads.get(&thread_id) { Some(thread) => { if let Some(error) = &thread.stack_frames_error { Err(anyhow!(error.to_string())) From ef76f07b1ec8e4bdf996666b5522c08add4b2288 Mon Sep 17 00:00:00 2001 From: Remco Smits Date: Sat, 6 Dec 2025 22:08:33 +0100 Subject: [PATCH 104/621] debugger: Make historic snapshot button a dropdown menu (#44307) This allows users to select any snapshot in the debugger history feature and go back to the active session snapshot. We also change variable names to use hsitoric snapshot instead of history and move the snapshot icon to the back of the debugger top control strip. https://github.com/user-attachments/assets/805de8d0-30c1-4719-8af7-2d47e1df1da4 Release Notes: - N/A Co-authored-by: Anthony Eid --- crates/debugger_ui/src/debugger_panel.rs | 212 ++++++++++++------ .../src/session/running/stack_frame_list.rs | 1 - crates/project/src/debugger/session.rs | 24 +- .../ui/src/components/button/split_button.rs | 32 ++- 4 files changed, 190 insertions(+), 79 deletions(-) diff --git a/crates/debugger_ui/src/debugger_panel.rs b/crates/debugger_ui/src/debugger_panel.rs index fe81ac641196dbbc5ceecaede0785ca72336c261..bdb308aafd0d2899f17bef732ac38239c4df6dda 100644 --- a/crates/debugger_ui/src/debugger_panel.rs +++ b/crates/debugger_ui/src/debugger_panel.rs @@ -17,9 +17,9 @@ use dap::{client::SessionId, debugger_settings::DebuggerSettings}; use editor::{Editor, MultiBufferOffset, ToPoint}; use feature_flags::{FeatureFlag, FeatureFlagAppExt as _}; use gpui::{ - Action, App, AsyncWindowContext, ClipboardItem, Context, DismissEvent, Entity, EntityId, - EventEmitter, FocusHandle, Focusable, MouseButton, MouseDownEvent, Point, Subscription, Task, - WeakEntity, anchored, deferred, + Action, App, AsyncWindowContext, ClipboardItem, Context, Corner, DismissEvent, Entity, + EntityId, EventEmitter, FocusHandle, Focusable, MouseButton, MouseDownEvent, Point, + Subscription, Task, WeakEntity, anchored, deferred, }; use itertools::Itertools as _; @@ -32,7 +32,9 @@ use settings::Settings; use std::sync::{Arc, LazyLock}; use task::{DebugScenario, TaskContext}; use tree_sitter::{Query, StreamingIterator as _}; -use ui::{ContextMenu, Divider, PopoverMenuHandle, Tab, Tooltip, prelude::*}; +use ui::{ + ContextMenu, Divider, PopoverMenu, PopoverMenuHandle, SplitButton, Tab, Tooltip, prelude::*, +}; use util::rel_path::RelPath; use util::{ResultExt, debug_panic, maybe}; use workspace::SplitDirection; @@ -669,6 +671,12 @@ impl DebugPanel { ) }; + let thread_status = active_session + .as_ref() + .map(|session| session.read(cx).running_state()) + .and_then(|state| state.read(cx).thread_status(cx)) + .unwrap_or(project::debugger::session::ThreadStatus::Exited); + Some( div.w_full() .py_1() @@ -686,10 +694,6 @@ impl DebugPanel { .as_ref() .map(|session| session.read(cx).running_state()), |this, running_state| { - let thread_status = - running_state.read(cx).thread_status(cx).unwrap_or( - project::debugger::session::ThreadStatus::Exited, - ); let capabilities = running_state.read(cx).capabilities(cx); let supports_detach = running_state.read(cx).session().read(cx).is_attached(); @@ -812,34 +816,6 @@ impl DebugPanel { } }), ) - .when(cx.has_flag::(), |this| { - this.child( - IconButton::new( - "debug-back-in-history", - IconName::HistoryRerun, - ) - .icon_size(IconSize::Small) - .on_click( - window.listener_for( - running_state, - |this, _, _window, cx| { - this.session().update(cx, |session, cx| { - let ix = session - .active_history() - .unwrap_or_else(|| { - session.history().len() - }); - - session.go_back_to_history( - Some(ix.saturating_sub(1)), - cx, - ); - }) - }, - ), - ), - ) - }) .child(Divider::vertical()) .child( IconButton::new("debug-restart", IconName::RotateCcw) @@ -906,36 +882,53 @@ impl DebugPanel { } }), ) + .when(supports_detach, |div| { + div.child( + IconButton::new( + "debug-disconnect", + IconName::DebugDetach, + ) + .disabled( + thread_status != ThreadStatus::Stopped + && thread_status != ThreadStatus::Running, + ) + .icon_size(IconSize::Small) + .on_click(window.listener_for( + running_state, + |this, _, _, cx| { + this.detach_client(cx); + }, + )) + .tooltip({ + let focus_handle = focus_handle.clone(); + move |_window, cx| { + Tooltip::for_action_in( + "Detach", + &Detach, + &focus_handle, + cx, + ) + } + }), + ) + }) .when( - supports_detach, - |div| { - div.child( - IconButton::new( - "debug-disconnect", - IconName::DebugDetach, - ) - .disabled( - thread_status != ThreadStatus::Stopped - && thread_status != ThreadStatus::Running, + cx.has_flag::(), + |this| { + this.child(Divider::vertical()).child( + SplitButton::new( + self.render_history_button( + &running_state, + thread_status, + window, + ), + self.render_history_toggle_button( + thread_status, + &running_state, + ) + .into_any_element(), ) - .icon_size(IconSize::Small) - .on_click(window.listener_for( - running_state, - |this, _, _, cx| { - this.detach_client(cx); - }, - )) - .tooltip({ - let focus_handle = focus_handle.clone(); - move |_window, cx| { - Tooltip::for_action_in( - "Detach", - &Detach, - &focus_handle, - cx, - ) - } - }), + .style(ui::SplitButtonStyle::Outlined), ) }, ) @@ -1352,6 +1345,97 @@ impl DebugPanel { }); } } + + fn render_history_button( + &self, + running_state: &Entity, + thread_status: ThreadStatus, + window: &mut Window, + ) -> IconButton { + IconButton::new("debug-back-in-history", IconName::HistoryRerun) + .icon_size(IconSize::Small) + .on_click(window.listener_for(running_state, |this, _, _window, cx| { + this.session().update(cx, |session, cx| { + let ix = session + .active_snapshot_index() + .unwrap_or_else(|| session.historic_snapshots().len()); + + session.select_historic_snapshot(Some(ix.saturating_sub(1)), cx); + }) + })) + .disabled( + thread_status == ThreadStatus::Running || thread_status == ThreadStatus::Stepping, + ) + } + + fn render_history_toggle_button( + &self, + thread_status: ThreadStatus, + running_state: &Entity, + ) -> impl IntoElement { + PopoverMenu::new("debug-back-in-history-menu") + .trigger( + ui::ButtonLike::new_rounded_right("debug-back-in-history-menu-trigger") + .layer(ui::ElevationIndex::ModalSurface) + .size(ui::ButtonSize::None) + .child( + div() + .px_1() + .child(Icon::new(IconName::ChevronDown).size(IconSize::XSmall)), + ) + .disabled( + thread_status == ThreadStatus::Running + || thread_status == ThreadStatus::Stepping, + ), + ) + .menu({ + let running_state = running_state.clone(); + move |window, cx| { + let handler = + |ix: Option, running_state: Entity, cx: &mut App| { + running_state.update(cx, |state, cx| { + state.session().update(cx, |session, cx| { + session.select_historic_snapshot(ix, cx); + }) + }) + }; + + let running_state = running_state.clone(); + Some(ContextMenu::build( + window, + cx, + move |mut context_menu, _window, cx| { + let history = running_state + .read(cx) + .session() + .read(cx) + .historic_snapshots(); + + context_menu = context_menu.entry("Current State", None, { + let running_state = running_state.clone(); + move |_window, cx| { + handler(None, running_state.clone(), cx); + } + }); + context_menu = context_menu.separator(); + + for (ix, _) in history.iter().enumerate().rev() { + context_menu = + context_menu.entry(format!("history-{}", ix + 1), None, { + let running_state = running_state.clone(); + move |_window, cx| { + handler(Some(ix), running_state.clone(), cx); + } + }); + } + + context_menu + }, + )) + } + }) + .anchor(Corner::TopRight) + } } async fn register_session_inner( diff --git a/crates/debugger_ui/src/session/running/stack_frame_list.rs b/crates/debugger_ui/src/session/running/stack_frame_list.rs index 5ecdc0f74be97c01ace933fd3513535040599bac..a715e2248d14e253a9762c1bcf9f50c1db09d64c 100644 --- a/crates/debugger_ui/src/session/running/stack_frame_list.rs +++ b/crates/debugger_ui/src/session/running/stack_frame_list.rs @@ -227,7 +227,6 @@ impl StackFrameList { } this.update_in(cx, |this, window, cx| { this.build_entries(select_first, window, cx); - cx.notify(); }) .ok(); }) diff --git a/crates/project/src/debugger/session.rs b/crates/project/src/debugger/session.rs index 9d4d307f990bfc5f00190f74ce3f1f957e71bacc..65e903e178f6bb010c34315c1c5d5a7bf9cbe44e 100644 --- a/crates/project/src/debugger/session.rs +++ b/crates/project/src/debugger/session.rs @@ -1436,15 +1436,23 @@ impl Session { .push_back(std::mem::take(&mut self.active_snapshot)); } - pub fn history(&self) -> &VecDeque { + pub fn historic_snapshots(&self) -> &VecDeque { &self.snapshots } - pub fn go_back_to_history(&mut self, ix: Option, cx: &mut Context<'_, Session>) { + pub fn select_historic_snapshot(&mut self, ix: Option, cx: &mut Context) { if self.selected_snapshot_index == ix { return; } + if self + .selected_snapshot_index + .is_some_and(|ix| self.snapshots.len() <= ix) + { + debug_panic!("Attempted to select a debug session with an out of bounds index"); + return; + } + self.selected_snapshot_index = ix; if ix.is_some() { @@ -1454,7 +1462,7 @@ impl Session { cx.notify(); } - pub fn active_history(&self) -> Option { + pub fn active_snapshot_index(&self) -> Option { self.selected_snapshot_index } @@ -2272,7 +2280,7 @@ impl Session { } pub fn continue_thread(&mut self, thread_id: ThreadId, cx: &mut Context) { - self.go_back_to_history(None, cx); + self.select_historic_snapshot(None, cx); let supports_single_thread_execution_requests = self.capabilities.supports_single_thread_execution_requests; @@ -2309,7 +2317,7 @@ impl Session { granularity: SteppingGranularity, cx: &mut Context, ) { - self.go_back_to_history(None, cx); + self.select_historic_snapshot(None, cx); let supports_single_thread_execution_requests = self.capabilities.supports_single_thread_execution_requests; @@ -2341,7 +2349,7 @@ impl Session { granularity: SteppingGranularity, cx: &mut Context, ) { - self.go_back_to_history(None, cx); + self.select_historic_snapshot(None, cx); let supports_single_thread_execution_requests = self.capabilities.supports_single_thread_execution_requests; @@ -2373,7 +2381,7 @@ impl Session { granularity: SteppingGranularity, cx: &mut Context, ) { - self.go_back_to_history(None, cx); + self.select_historic_snapshot(None, cx); let supports_single_thread_execution_requests = self.capabilities.supports_single_thread_execution_requests; @@ -2405,7 +2413,7 @@ impl Session { granularity: SteppingGranularity, cx: &mut Context, ) { - self.go_back_to_history(None, cx); + self.select_historic_snapshot(None, cx); let supports_single_thread_execution_requests = self.capabilities.supports_single_thread_execution_requests; diff --git a/crates/ui/src/components/button/split_button.rs b/crates/ui/src/components/button/split_button.rs index 14b9fd153cd5ad662467c75ff81700587667cee3..48f06ff3789e69b6d19cde2322932f4bd6e89f97 100644 --- a/crates/ui/src/components/button/split_button.rs +++ b/crates/ui/src/components/button/split_button.rs @@ -4,7 +4,7 @@ use gpui::{ }; use theme::ActiveTheme; -use crate::{ElevationIndex, h_flex}; +use crate::{ElevationIndex, IconButton, h_flex}; use super::ButtonLike; @@ -15,6 +15,23 @@ pub enum SplitButtonStyle { Transparent, } +pub enum SplitButtonKind { + ButtonLike(ButtonLike), + IconButton(IconButton), +} + +impl From for SplitButtonKind { + fn from(icon_button: IconButton) -> Self { + Self::IconButton(icon_button) + } +} + +impl From for SplitButtonKind { + fn from(button_like: ButtonLike) -> Self { + Self::ButtonLike(button_like) + } +} + /// /// A button with two parts: a primary action on the left and a secondary action on the right. /// /// The left side is a [`ButtonLike`] with the main action, while the right side can contain @@ -23,15 +40,15 @@ pub enum SplitButtonStyle { /// The two sections are visually separated by a divider, but presented as a unified control. #[derive(IntoElement)] pub struct SplitButton { - pub left: ButtonLike, - pub right: AnyElement, + left: SplitButtonKind, + right: AnyElement, style: SplitButtonStyle, } impl SplitButton { - pub fn new(left: ButtonLike, right: AnyElement) -> Self { + pub fn new(left: impl Into, right: AnyElement) -> Self { Self { - left, + left: left.into(), right, style: SplitButtonStyle::Filled, } @@ -56,7 +73,10 @@ impl RenderOnce for SplitButton { this.border_1() .border_color(cx.theme().colors().border.opacity(0.8)) }) - .child(div().flex_grow().child(self.left)) + .child(div().flex_grow().child(match self.left { + SplitButtonKind::ButtonLike(button) => button.into_any_element(), + SplitButtonKind::IconButton(icon) => icon.into_any_element(), + })) .child( div() .h_full() From 9f344f093e1b5fee08937111569b106dbeee2410 Mon Sep 17 00:00:00 2001 From: Kunall Banerjee Date: Sat, 6 Dec 2025 19:14:13 -0500 Subject: [PATCH 105/621] docs: Point to the right URL for Astro LSP (#44314) The original URL points to a deprecated repo. Release Notes: - N/A --- docs/src/languages/astro.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/languages/astro.md b/docs/src/languages/astro.md index 5691a0de4844b2e2d924713d523f4651da6fe984..cbfe8de74e7444e2e02f6240265e00eb043a2084 100644 --- a/docs/src/languages/astro.md +++ b/docs/src/languages/astro.md @@ -3,7 +3,7 @@ Astro support is available through the [Astro extension](https://github.com/zed-extensions/astro). - Tree-sitter: [virchau13/tree-sitter-astro](https://github.com/virchau13/tree-sitter-astro) -- Language Server: [withastro/language-tools](https://github.com/withastro/language-tools) +- Language Server: [withastro/language-tools](https://github.com/withastro/astro/tree/main/packages/language-tools/language-server) + ```json + + ``` + + + validations: + required: false - type: textarea attributes: label: (for AI issues) Model provider details From e03fa114a7d419d267a96216f28d28164c17ac06 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Fri, 12 Dec 2025 12:53:15 +0100 Subject: [PATCH 230/621] remote: Remove unnecessary and incorrect single quote in `MasterProcess` (#44697) Closes https://github.com/zed-industries/zed/issues/43992 Release Notes: - Fixed remoting not working on some linux and mac systems --- crates/remote/src/transport/ssh.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/remote/src/transport/ssh.rs b/crates/remote/src/transport/ssh.rs index 5cd426d7be560c9bdb493477e6be51404836e0a8..9412549f20d68e999889ed0062397d85abe99d6e 100644 --- a/crates/remote/src/transport/ssh.rs +++ b/crates/remote/src/transport/ssh.rs @@ -116,7 +116,7 @@ impl MasterProcess { .args(additional_args) .args(args); - master_process.arg(format!("ControlPath='{}'", socket_path.display())); + master_process.arg(format!("ControlPath={}", socket_path.display())); let process = master_process.arg(&url).spawn()?; From a07ea1a2726d5d11ee25f12365412b6a4a0b627b Mon Sep 17 00:00:00 2001 From: Xiaobo Liu Date: Fri, 12 Dec 2025 20:33:49 +0800 Subject: [PATCH 231/621] util: Avoid redundant Arc allocation in SanitizedPath::from_arc (#44479) Release Notes: - N/A Signed-off-by: Xiaobo Liu --- crates/util/src/paths.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/crates/util/src/paths.rs b/crates/util/src/paths.rs index f8e3e557152a24a6be8bb4cdad3a86d2256a764e..a54f91c7a0392748cb64c984559cf1ce25c2a7d8 100644 --- a/crates/util/src/paths.rs +++ b/crates/util/src/paths.rs @@ -227,9 +227,16 @@ impl SanitizedPath { #[cfg(not(target_os = "windows"))] return unsafe { mem::transmute::, Arc>(path) }; - // TODO: could avoid allocating here if dunce::simplified results in the same path #[cfg(target_os = "windows")] - return Self::new(&path).into(); + { + let simplified = dunce::simplified(path.as_ref()); + if simplified == path.as_ref() { + // safe because `Path` and `SanitizedPath` have the same repr and Drop impl + unsafe { mem::transmute::, Arc>(path) } + } else { + Self::unchecked_new(simplified).into() + } + } } pub fn new_arc + ?Sized>(path: &T) -> Arc { From 610cc1b1385e3ef4ca5e12f8783aeb6feda25b2f Mon Sep 17 00:00:00 2001 From: Agus Zubiaga Date: Fri, 12 Dec 2025 09:43:16 -0300 Subject: [PATCH 232/621] edit prediction cli: Cargo-style progress output (#44675) Release Notes: - N/A --- Cargo.lock | 1 + crates/edit_prediction_cli/Cargo.toml | 1 + .../edit_prediction_cli/src/format_prompt.rs | 8 +- .../edit_prediction_cli/src/load_project.rs | 49 ++- crates/edit_prediction_cli/src/main.rs | 47 ++- crates/edit_prediction_cli/src/predict.rs | 46 ++- crates/edit_prediction_cli/src/progress.rs | 372 ++++++++++++++++++ .../src/retrieve_context.rs | 37 +- crates/edit_prediction_cli/src/score.rs | 5 + 9 files changed, 509 insertions(+), 57 deletions(-) create mode 100644 crates/edit_prediction_cli/src/progress.rs diff --git a/Cargo.lock b/Cargo.lock index 7631b8f4c5d46437452ca1b42dfc1a2609cb0c54..2447303bacc666324a99c54247ab70f950d3bb0c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5179,6 +5179,7 @@ dependencies = [ "language_model", "language_models", "languages", + "libc", "log", "node_runtime", "paths", diff --git a/crates/edit_prediction_cli/Cargo.toml b/crates/edit_prediction_cli/Cargo.toml index 14f146a122b55b5a05529d4a32302a6dd65825d7..61e55e09a3b0b46a7d6ad0338be3ab76c1e08401 100644 --- a/crates/edit_prediction_cli/Cargo.toml +++ b/crates/edit_prediction_cli/Cargo.toml @@ -34,6 +34,7 @@ language_extension.workspace = true language_model.workspace = true language_models.workspace = true languages = { workspace = true, features = ["load-grammars"] } +libc.workspace = true log.workspace = true node_runtime.workspace = true paths.workspace = true diff --git a/crates/edit_prediction_cli/src/format_prompt.rs b/crates/edit_prediction_cli/src/format_prompt.rs index 598d98fdb7646585641dd9fc47668506935644f4..2225f1d294144753408968c6f464988378e2691d 100644 --- a/crates/edit_prediction_cli/src/format_prompt.rs +++ b/crates/edit_prediction_cli/src/format_prompt.rs @@ -3,6 +3,7 @@ use crate::{ example::{Example, ExamplePrompt}, headless::EpAppState, load_project::run_load_project, + progress::{Progress, Step}, retrieve_context::run_context_retrieval, }; use edit_prediction::{ @@ -17,9 +18,12 @@ pub async fn run_format_prompt( example: &mut Example, prompt_format: PromptFormat, app_state: Arc, + progress: Arc, mut cx: AsyncApp, ) { - run_context_retrieval(example, app_state.clone(), cx.clone()).await; + run_context_retrieval(example, app_state.clone(), progress.clone(), cx.clone()).await; + + let _step_progress = progress.start(Step::FormatPrompt, &example.name); match prompt_format { PromptFormat::Teacher => { @@ -31,7 +35,7 @@ pub async fn run_format_prompt( }); } PromptFormat::Zeta2 => { - run_load_project(example, app_state, cx.clone()).await; + run_load_project(example, app_state, progress.clone(), cx.clone()).await; let ep_store = cx .update(|cx| EditPredictionStore::try_global(cx).unwrap()) diff --git a/crates/edit_prediction_cli/src/load_project.rs b/crates/edit_prediction_cli/src/load_project.rs index 3e0b34241164801a30f959f759e1c0419ba324ff..895105966713f653a0ce8277387276a0ae40a4bc 100644 --- a/crates/edit_prediction_cli/src/load_project.rs +++ b/crates/edit_prediction_cli/src/load_project.rs @@ -2,6 +2,7 @@ use crate::{ example::{Example, ExampleBuffer, ExampleState}, headless::EpAppState, paths::{REPOS_DIR, WORKTREES_DIR}, + progress::{InfoStyle, Progress, Step, StepProgress}, }; use anyhow::{Result, anyhow}; use collections::HashMap; @@ -24,30 +25,47 @@ use std::{ use util::{paths::PathStyle, rel_path::RelPath}; use zeta_prompt::CURSOR_MARKER; -pub async fn run_load_project(example: &mut Example, app_state: Arc, mut cx: AsyncApp) { +pub async fn run_load_project( + example: &mut Example, + app_state: Arc, + progress: Arc, + mut cx: AsyncApp, +) { if example.state.is_some() { return; } - let project = setup_project(example, &app_state, &mut cx).await; + let progress = progress.start(Step::LoadProject, &example.name); + + let project = setup_project(example, &app_state, &progress, &mut cx).await; let _open_buffers = apply_edit_history(example, &project, &mut cx) .await .unwrap(); let (buffer, cursor_position) = cursor_position(example, &project, &mut cx).await; - example.buffer = buffer + let (example_buffer, language_name) = buffer .read_with(&cx, |buffer, _cx| { let cursor_point = cursor_position.to_point(&buffer); - Some(ExampleBuffer { - content: buffer.text(), - cursor_row: cursor_point.row, - cursor_column: cursor_point.column, - cursor_offset: cursor_position.to_offset(&buffer), - }) + let language_name = buffer + .language() + .map(|l| l.name().to_string()) + .unwrap_or_else(|| "Unknown".to_string()); + ( + ExampleBuffer { + content: buffer.text(), + cursor_row: cursor_point.row, + cursor_column: cursor_point.column, + cursor_offset: cursor_position.to_offset(&buffer), + }, + language_name, + ) }) .unwrap(); + progress.set_info(language_name, InfoStyle::Normal); + + example.buffer = Some(example_buffer); example.state = Some(ExampleState { buffer, project, @@ -131,13 +149,14 @@ async fn cursor_position( async fn setup_project( example: &mut Example, app_state: &Arc, + step_progress: &Arc, cx: &mut AsyncApp, ) -> Entity { let ep_store = cx .update(|cx| EditPredictionStore::try_global(cx).unwrap()) .unwrap(); - let worktree_path = setup_worktree(example).await; + let worktree_path = setup_worktree(example, step_progress).await; if let Some(project) = app_state.project_cache.get(&example.repository_url) { ep_store @@ -158,7 +177,7 @@ async fn setup_project( .update(cx, |buffer, cx| buffer.reload(cx)) .unwrap() .await - .unwrap(); + .ok(); } return project; } @@ -208,7 +227,7 @@ async fn setup_project( project } -pub async fn setup_worktree(example: &Example) -> PathBuf { +async fn setup_worktree(example: &Example, step_progress: &Arc) -> PathBuf { let (repo_owner, repo_name) = example.repo_name().expect("failed to get repo name"); let repo_dir = REPOS_DIR.join(repo_owner.as_ref()).join(repo_name.as_ref()); let worktree_path = WORKTREES_DIR @@ -217,7 +236,7 @@ pub async fn setup_worktree(example: &Example) -> PathBuf { let repo_lock = lock_repo(&repo_dir).await; if !repo_dir.is_dir() { - eprintln!("Cloning repository {}", example.repository_url); + step_progress.set_substatus(format!("cloning {}", repo_name)); fs::create_dir_all(&repo_dir).unwrap(); run_git(&repo_dir, &["init"]).await.unwrap(); run_git( @@ -237,6 +256,7 @@ pub async fn setup_worktree(example: &Example) -> PathBuf { let revision = if let Ok(revision) = revision { revision } else { + step_progress.set_substatus("fetching"); if run_git( &repo_dir, &["fetch", "--depth", "1", "origin", &example.revision], @@ -253,6 +273,7 @@ pub async fn setup_worktree(example: &Example) -> PathBuf { }; // Create the worktree for this example if needed. + step_progress.set_substatus("preparing worktree"); if worktree_path.is_dir() { run_git(&worktree_path, &["clean", "--force", "-d"]) .await @@ -288,6 +309,7 @@ pub async fn setup_worktree(example: &Example) -> PathBuf { // Apply the uncommitted diff for this example. if !example.uncommitted_diff.is_empty() { + step_progress.set_substatus("applying diff"); let mut apply_process = smol::process::Command::new("git") .current_dir(&worktree_path) .args(&["apply", "-"]) @@ -314,6 +336,7 @@ pub async fn setup_worktree(example: &Example) -> PathBuf { } } + step_progress.clear_substatus(); worktree_path } diff --git a/crates/edit_prediction_cli/src/main.rs b/crates/edit_prediction_cli/src/main.rs index 1091f0acfa182b95ed18bc6d560aaf7bca6225c7..b053af128c82c1aeefb35756ec28bc22a3ff2387 100644 --- a/crates/edit_prediction_cli/src/main.rs +++ b/crates/edit_prediction_cli/src/main.rs @@ -7,6 +7,7 @@ mod load_project; mod metrics; mod paths; mod predict; +mod progress; mod retrieve_context; mod score; @@ -15,8 +16,6 @@ use edit_prediction::EditPredictionStore; use gpui::Application; use reqwest_client::ReqwestClient; use serde::{Deserialize, Serialize}; -use std::sync::atomic::AtomicUsize; -use std::sync::atomic::Ordering::SeqCst; use std::{path::PathBuf, sync::Arc}; use crate::distill::run_distill; @@ -24,6 +23,7 @@ use crate::example::{group_examples_by_repo, read_examples, write_examples}; use crate::format_prompt::run_format_prompt; use crate::load_project::run_load_project; use crate::predict::run_prediction; +use crate::progress::Progress; use crate::retrieve_context::run_context_retrieval; use crate::score::run_scoring; @@ -112,7 +112,7 @@ impl EpArgs { } fn main() { - zlog::init(); + let _ = zlog::try_init(Some("error".into())); zlog::init_output_stderr(); let args = EpArgs::parse(); @@ -151,33 +151,41 @@ fn main() { predict::sync_batches(&args.provider).await }; - let example_count = examples.len(); - let example_ix = AtomicUsize::new(0); - let mut grouped_examples = group_examples_by_repo(&mut examples); + let total_examples = examples.len(); + let progress = Progress::new(total_examples); + let mut grouped_examples = group_examples_by_repo(&mut examples); let example_batches = grouped_examples.chunks_mut(args.max_parallelism); + for example_batch in example_batches { let futures = example_batch.into_iter().map(|repo_examples| async { for example in repo_examples.iter_mut() { - eprintln!( - "Processing example: {}/{}", - example_ix.load(SeqCst) + 1, - example_count - ); - example_ix.fetch_add(1, SeqCst); match &command { Command::ParseExample => {} Command::LoadProject => { - run_load_project(example, app_state.clone(), cx.clone()).await; + run_load_project( + example, + app_state.clone(), + progress.clone(), + cx.clone(), + ) + .await; } Command::Context => { - run_context_retrieval(example, app_state.clone(), cx.clone()).await; + run_context_retrieval( + example, + app_state.clone(), + progress.clone(), + cx.clone(), + ) + .await; } Command::FormatPrompt(args) => { run_format_prompt( example, args.prompt_format, app_state.clone(), + progress.clone(), cx.clone(), ) .await; @@ -188,6 +196,7 @@ fn main() { Some(args.provider), args.repetitions, app_state.clone(), + progress.clone(), cx.clone(), ) .await; @@ -196,7 +205,14 @@ fn main() { run_distill(example).await; } Command::Score(args) | Command::Eval(args) => { - run_scoring(example, &args, app_state.clone(), cx.clone()).await; + run_scoring( + example, + &args, + app_state.clone(), + progress.clone(), + cx.clone(), + ) + .await; } Command::Clean => { unreachable!() @@ -206,6 +222,7 @@ fn main() { }); futures::future::join_all(futures).await; } + progress.clear(); if args.output.is_some() || !matches!(command, Command::Eval(_)) { write_examples(&examples, output.as_ref()); diff --git a/crates/edit_prediction_cli/src/predict.rs b/crates/edit_prediction_cli/src/predict.rs index 4ff3e1d947fd886633108cbba0d32909f72304e4..14628a896273f7ff11166a1daac248598e198847 100644 --- a/crates/edit_prediction_cli/src/predict.rs +++ b/crates/edit_prediction_cli/src/predict.rs @@ -6,6 +6,7 @@ use crate::{ headless::EpAppState, load_project::run_load_project, paths::{LATEST_EXAMPLE_RUN_DIR, RUN_DIR}, + progress::{InfoStyle, Progress, Step}, retrieve_context::run_context_retrieval, }; use edit_prediction::{DebugEvent, EditPredictionStore}; @@ -24,29 +25,41 @@ pub async fn run_prediction( provider: Option, repetition_count: usize, app_state: Arc, + progress: Arc, mut cx: AsyncApp, ) { if !example.predictions.is_empty() { return; } - run_context_retrieval(example, app_state.clone(), cx.clone()).await; - let provider = provider.unwrap(); + run_context_retrieval(example, app_state.clone(), progress.clone(), cx.clone()).await; + if matches!( provider, PredictionProvider::Teacher | PredictionProvider::TeacherNonBatching ) { + let _step_progress = progress.start(Step::Predict, &example.name); + if example.prompt.is_none() { - run_format_prompt(example, PromptFormat::Teacher, app_state.clone(), cx).await; + run_format_prompt( + example, + PromptFormat::Teacher, + app_state.clone(), + progress, + cx, + ) + .await; } let batched = matches!(provider, PredictionProvider::Teacher); return predict_anthropic(example, repetition_count, batched).await; } - run_load_project(example, app_state.clone(), cx.clone()).await; + run_load_project(example, app_state.clone(), progress.clone(), cx.clone()).await; + + let _step_progress = progress.start(Step::Predict, &example.name); if matches!( provider, @@ -181,18 +194,31 @@ pub async fn run_prediction( .await .unwrap(); + let actual_patch = prediction + .and_then(|prediction| { + let prediction = prediction.prediction.ok()?; + prediction.edit_preview.as_unified_diff(&prediction.edits) + }) + .unwrap_or_default(); + + let has_prediction = !actual_patch.is_empty(); + updated_example .lock() .unwrap() .predictions .last_mut() .unwrap() - .actual_patch = prediction - .and_then(|prediction| { - let prediction = prediction.prediction.ok()?; - prediction.edit_preview.as_unified_diff(&prediction.edits) - }) - .unwrap_or_default(); + .actual_patch = actual_patch; + + if ix == repetition_count - 1 { + let (info, style) = if has_prediction { + ("predicted", InfoStyle::Normal) + } else { + ("no prediction", InfoStyle::Warning) + }; + _step_progress.set_info(info, style); + } } ep_store diff --git a/crates/edit_prediction_cli/src/progress.rs b/crates/edit_prediction_cli/src/progress.rs new file mode 100644 index 0000000000000000000000000000000000000000..5cd906d89a20813676b09af0d2cbeca532c5ba12 --- /dev/null +++ b/crates/edit_prediction_cli/src/progress.rs @@ -0,0 +1,372 @@ +use std::{ + borrow::Cow, + collections::HashMap, + io::{IsTerminal, Write}, + sync::{Arc, Mutex}, + time::{Duration, Instant}, +}; + +pub struct Progress { + inner: Mutex, +} + +struct ProgressInner { + completed: Vec, + in_progress: HashMap, + is_tty: bool, + terminal_width: usize, + max_example_name_len: usize, + status_lines_displayed: usize, + total_examples: usize, +} + +#[derive(Clone)] +struct InProgressTask { + step: Step, + started_at: Instant, + substatus: Option, + info: Option<(String, InfoStyle)>, +} + +struct CompletedTask { + step: Step, + example_name: String, + duration: Duration, + info: Option<(String, InfoStyle)>, +} + +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] +pub enum Step { + LoadProject, + Context, + FormatPrompt, + Predict, + Score, +} + +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum InfoStyle { + Normal, + Warning, +} + +impl Step { + pub fn label(&self) -> &'static str { + match self { + Step::LoadProject => "Load", + Step::Context => "Context", + Step::FormatPrompt => "Format", + Step::Predict => "Predict", + Step::Score => "Score", + } + } + + fn color_code(&self) -> &'static str { + match self { + Step::LoadProject => "\x1b[33m", + Step::Context => "\x1b[35m", + Step::FormatPrompt => "\x1b[34m", + Step::Predict => "\x1b[32m", + Step::Score => "\x1b[31m", + } + } +} + +const RIGHT_MARGIN: usize = 4; + +impl Progress { + pub fn new(total_examples: usize) -> Arc { + Arc::new(Self { + inner: Mutex::new(ProgressInner { + completed: Vec::new(), + in_progress: HashMap::new(), + is_tty: std::io::stderr().is_terminal(), + terminal_width: get_terminal_width(), + max_example_name_len: 0, + status_lines_displayed: 0, + total_examples, + }), + }) + } + + pub fn start(self: &Arc, step: Step, example_name: &str) -> Arc { + { + let mut inner = self.inner.lock().unwrap(); + + Self::clear_status_lines(&mut inner); + + inner.max_example_name_len = inner.max_example_name_len.max(example_name.len()); + + inner.in_progress.insert( + example_name.to_string(), + InProgressTask { + step, + started_at: Instant::now(), + substatus: None, + info: None, + }, + ); + + Self::print_status_lines(&mut inner); + } + + Arc::new(StepProgress { + progress: self.clone(), + step, + example_name: example_name.to_string(), + }) + } + + pub fn finish(&self, step: Step, example_name: &str) { + let mut inner = self.inner.lock().unwrap(); + + let task = inner.in_progress.remove(example_name); + if let Some(task) = task { + if task.step == step { + inner.completed.push(CompletedTask { + step: task.step, + example_name: example_name.to_string(), + duration: task.started_at.elapsed(), + info: task.info, + }); + + Self::clear_status_lines(&mut inner); + Self::print_completed(&inner, inner.completed.last().unwrap()); + Self::print_status_lines(&mut inner); + } else { + inner.in_progress.insert(example_name.to_string(), task); + } + } + } + + fn clear_status_lines(inner: &mut ProgressInner) { + if inner.is_tty && inner.status_lines_displayed > 0 { + // Move up and clear each line we previously displayed + for _ in 0..inner.status_lines_displayed { + eprint!("\x1b[A\x1b[K"); + } + let _ = std::io::stderr().flush(); + inner.status_lines_displayed = 0; + } + } + + fn print_completed(inner: &ProgressInner, task: &CompletedTask) { + let duration = format_duration(task.duration); + let name_width = inner.max_example_name_len; + + if inner.is_tty { + let reset = "\x1b[0m"; + let bold = "\x1b[1m"; + let dim = "\x1b[2m"; + + let yellow = "\x1b[33m"; + let info_part = task + .info + .as_ref() + .map(|(s, style)| { + if *style == InfoStyle::Warning { + format!("{yellow}{s}{reset}") + } else { + s.to_string() + } + }) + .unwrap_or_default(); + + let prefix = format!( + "{bold}{color}{label:>12}{reset} {name:12} {name: = inner.in_progress.iter().collect(); + tasks.sort_by_key(|(name, _)| *name); + + let mut lines_printed = 0; + + for (name, task) in tasks.iter() { + let elapsed = format_duration(task.started_at.elapsed()); + let substatus_part = task + .substatus + .as_ref() + .map(|s| truncate_with_ellipsis(s, 30)) + .unwrap_or_default(); + + let step_label = task.step.label(); + let step_color = task.step.color_code(); + let name_width = inner.max_example_name_len; + + let prefix = format!( + "{bold}{step_color}{step_label:>12}{reset} {name:, + step: Step, + example_name: String, +} + +impl StepProgress { + pub fn set_substatus(&self, substatus: impl Into>) { + let mut inner = self.progress.inner.lock().unwrap(); + if let Some(task) = inner.in_progress.get_mut(&self.example_name) { + task.substatus = Some(substatus.into().into_owned()); + Progress::clear_status_lines(&mut inner); + Progress::print_status_lines(&mut inner); + } + } + + pub fn clear_substatus(&self) { + let mut inner = self.progress.inner.lock().unwrap(); + if let Some(task) = inner.in_progress.get_mut(&self.example_name) { + task.substatus = None; + Progress::clear_status_lines(&mut inner); + Progress::print_status_lines(&mut inner); + } + } + + pub fn set_info(&self, info: impl Into, style: InfoStyle) { + let mut inner = self.progress.inner.lock().unwrap(); + if let Some(task) = inner.in_progress.get_mut(&self.example_name) { + task.info = Some((info.into(), style)); + } + } +} + +impl Drop for StepProgress { + fn drop(&mut self) { + self.progress.finish(self.step, &self.example_name); + } +} + +#[cfg(unix)] +fn get_terminal_width() -> usize { + unsafe { + let mut winsize: libc::winsize = std::mem::zeroed(); + if libc::ioctl(libc::STDERR_FILENO, libc::TIOCGWINSZ, &mut winsize) == 0 + && winsize.ws_col > 0 + { + winsize.ws_col as usize + } else { + 80 + } + } +} + +#[cfg(not(unix))] +fn get_terminal_width() -> usize { + 80 +} + +fn strip_ansi_len(s: &str) -> usize { + let mut len = 0; + let mut in_escape = false; + for c in s.chars() { + if c == '\x1b' { + in_escape = true; + } else if in_escape { + if c == 'm' { + in_escape = false; + } + } else { + len += 1; + } + } + len +} + +fn truncate_with_ellipsis(s: &str, max_len: usize) -> String { + if s.len() <= max_len { + s.to_string() + } else { + format!("{}…", &s[..max_len.saturating_sub(1)]) + } +} + +fn format_duration(duration: Duration) -> String { + const MINUTE_IN_MILLIS: f32 = 60. * 1000.; + + let millis = duration.as_millis() as f32; + if millis < 1000.0 { + format!("{}ms", millis) + } else if millis < MINUTE_IN_MILLIS { + format!("{:.1}s", millis / 1_000.0) + } else { + format!("{:.1}m", millis / MINUTE_IN_MILLIS) + } +} diff --git a/crates/edit_prediction_cli/src/retrieve_context.rs b/crates/edit_prediction_cli/src/retrieve_context.rs index 0ef7a4676e30189f1417c0a8c339e8ac7f76e0ef..83b5906e976ca3a1a6bdff6a96c36713eef08058 100644 --- a/crates/edit_prediction_cli/src/retrieve_context.rs +++ b/crates/edit_prediction_cli/src/retrieve_context.rs @@ -2,6 +2,7 @@ use crate::{ example::{Example, ExampleContext}, headless::EpAppState, load_project::run_load_project, + progress::{InfoStyle, Progress, Step, StepProgress}, }; use collections::HashSet; use edit_prediction::{DebugEvent, EditPredictionStore}; @@ -9,18 +10,22 @@ use futures::{FutureExt as _, StreamExt as _, channel::mpsc}; use gpui::{AsyncApp, Entity}; use language::Buffer; use project::Project; -use std::{sync::Arc, time::Duration}; +use std::sync::Arc; +use std::time::Duration; pub async fn run_context_retrieval( example: &mut Example, app_state: Arc, + progress: Arc, mut cx: AsyncApp, ) { if example.context.is_some() { return; } - run_load_project(example, app_state.clone(), cx.clone()).await; + run_load_project(example, app_state.clone(), progress.clone(), cx.clone()).await; + + let step_progress = progress.start(Step::Context, &example.name); let state = example.state.as_ref().unwrap(); let project = state.project.clone(); @@ -30,7 +35,7 @@ pub async fn run_context_retrieval( project.register_buffer_with_language_servers(&state.buffer, cx) }) .unwrap(); - wait_for_language_servers_to_start(example, &project, &state.buffer, &mut cx).await; + wait_for_language_servers_to_start(&project, &state.buffer, &step_progress, &mut cx).await; let ep_store = cx .update(|cx| EditPredictionStore::try_global(cx).unwrap()) @@ -58,19 +63,20 @@ pub async fn run_context_retrieval( .update(&mut cx, |store, cx| store.context_for_project(&project, cx)) .unwrap(); + let excerpt_count: usize = context_files.iter().map(|f| f.excerpts.len()).sum(); + step_progress.set_info(format!("{} excerpts", excerpt_count), InfoStyle::Normal); + example.context = Some(ExampleContext { files: context_files, }); } async fn wait_for_language_servers_to_start( - example: &Example, project: &Entity, buffer: &Entity, + step_progress: &Arc, cx: &mut AsyncApp, ) { - let log_prefix = format!("{} | ", example.name); - let lsp_store = project .read_with(cx, |project, _| project.lsp_store()) .unwrap(); @@ -89,11 +95,7 @@ async fn wait_for_language_servers_to_start( }) .unwrap_or_default(); - eprintln!( - "{}⏵ Waiting for {} language servers", - log_prefix, - language_server_ids.len() - ); + step_progress.set_substatus(format!("waiting for {} LSPs", language_server_ids.len())); let timeout = cx .background_executor() @@ -102,10 +104,10 @@ async fn wait_for_language_servers_to_start( let (mut tx, mut rx) = mpsc::channel(language_server_ids.len()); let added_subscription = cx.subscribe(project, { - let log_prefix = log_prefix.clone(); + let step_progress = step_progress.clone(); move |_, event, _| match event { project::Event::LanguageServerAdded(language_server_id, name, _) => { - eprintln!("{}+ Language server started: {}", log_prefix, name); + step_progress.set_substatus(format!("LSP started: {}", name)); tx.try_send(*language_server_id).ok(); } _ => {} @@ -137,7 +139,7 @@ async fn wait_for_language_servers_to_start( let (mut tx, mut rx) = mpsc::channel(language_server_ids.len()); let subscriptions = [ cx.subscribe(&lsp_store, { - let log_prefix = log_prefix.clone(); + let step_progress = step_progress.clone(); move |_, event, _| { if let project::LspStoreEvent::LanguageServerUpdate { message: @@ -150,12 +152,12 @@ async fn wait_for_language_servers_to_start( .. } = event { - eprintln!("{}⟲ {message}", log_prefix) + step_progress.set_substatus(message.clone()); } } }), cx.subscribe(project, { - let log_prefix = log_prefix.clone(); + let step_progress = step_progress.clone(); move |_, event, cx| match event { project::Event::DiskBasedDiagnosticsFinished { language_server_id } => { let lsp_store = lsp_store.read(cx); @@ -163,7 +165,7 @@ async fn wait_for_language_servers_to_start( .language_server_adapter_for_id(*language_server_id) .unwrap() .name(); - eprintln!("{}⚑ Language server idle: {}", log_prefix, name); + step_progress.set_substatus(format!("LSP idle: {}", name)); tx.try_send(*language_server_id).ok(); } _ => {} @@ -192,4 +194,5 @@ async fn wait_for_language_servers_to_start( } drop(subscriptions); + step_progress.clear_substatus(); } diff --git a/crates/edit_prediction_cli/src/score.rs b/crates/edit_prediction_cli/src/score.rs index 88ec5d5831c763b604c53d762a1ea9722e7279cb..23086dcc6e9279820216961ef0fe9fc65c3ea3eb 100644 --- a/crates/edit_prediction_cli/src/score.rs +++ b/crates/edit_prediction_cli/src/score.rs @@ -4,6 +4,7 @@ use crate::{ headless::EpAppState, metrics::{self, ClassificationMetrics}, predict::run_prediction, + progress::{Progress, Step}, }; use edit_prediction::udiff::DiffLine; use gpui::AsyncApp; @@ -13,6 +14,7 @@ pub async fn run_scoring( example: &mut Example, args: &PredictArgs, app_state: Arc, + progress: Arc, cx: AsyncApp, ) { run_prediction( @@ -20,10 +22,13 @@ pub async fn run_scoring( Some(args.provider), args.repetitions, app_state, + progress.clone(), cx, ) .await; + let _progress = progress.start(Step::Score, &example.name); + let expected_patch = parse_patch(&example.expected_patch); let mut scores = vec![]; From 18d344e118e6ac7f9ab3dcbec0b95663ab914bf5 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Fri, 12 Dec 2025 14:15:50 +0100 Subject: [PATCH 233/621] language: Make `TreeSitterData` only shared between snapshots of the same version (#44198) Currently we have a single cache for this data shared between all snapshots which is incorrect, as we might update the cache to a new version while having old snapshots around which then may try to access new data with old offsets/rows. Release Notes: - N/A *or* Added/Fixed/Improved ... --- crates/editor/src/bracket_colorization.rs | 4 +- crates/language/src/buffer.rs | 273 +++++++++++----------- crates/language/src/buffer/row_chunk.rs | 2 +- crates/text/src/text.rs | 9 +- 4 files changed, 145 insertions(+), 143 deletions(-) diff --git a/crates/editor/src/bracket_colorization.rs b/crates/editor/src/bracket_colorization.rs index e4933b3ad5d8a2cae80e882abaa2eb34dfd3a429..4879c5e9ce703227d3c03f4d3373512769b1515c 100644 --- a/crates/editor/src/bracket_colorization.rs +++ b/crates/editor/src/bracket_colorization.rs @@ -45,7 +45,7 @@ impl Editor { let bracket_matches_by_accent = self.visible_excerpts(false, cx).into_iter().fold( HashMap::default(), - |mut acc, (excerpt_id, (buffer, buffer_version, buffer_range))| { + |mut acc, (excerpt_id, (buffer, _, buffer_range))| { let buffer_snapshot = buffer.read(cx).snapshot(); if language_settings::language_settings( buffer_snapshot.language().map(|language| language.name()), @@ -62,7 +62,7 @@ impl Editor { let brackets_by_accent = buffer_snapshot .fetch_bracket_ranges( buffer_range.start..buffer_range.end, - Some((&buffer_version, fetched_chunks)), + Some(fetched_chunks), ) .into_iter() .flat_map(|(chunk_range, pairs)| { diff --git a/crates/language/src/buffer.rs b/crates/language/src/buffer.rs index 7bf62b5aa43c60a7ecee756dd66066682ac09077..22fcbf5ee85c0f42de8097526df4a5fdc383ac35 100644 --- a/crates/language/src/buffer.rs +++ b/crates/language/src/buffer.rs @@ -22,8 +22,8 @@ pub use crate::{ proto, }; use anyhow::{Context as _, Result}; +use clock::Lamport; pub use clock::ReplicaId; -use clock::{Global, Lamport}; use collections::{HashMap, HashSet}; use fs::MTime; use futures::channel::oneshot; @@ -33,7 +33,7 @@ use gpui::{ }; use lsp::{LanguageServerId, NumberOrString}; -use parking_lot::{Mutex, RawMutex, lock_api::MutexGuard}; +use parking_lot::Mutex; use serde::{Deserialize, Serialize}; use serde_json::Value; use settings::WorktreeId; @@ -130,29 +130,37 @@ pub struct Buffer { has_unsaved_edits: Cell<(clock::Global, bool)>, change_bits: Vec>>, _subscriptions: Vec, - tree_sitter_data: Arc>, + tree_sitter_data: Arc, } -#[derive(Debug, Clone)] +#[derive(Debug)] pub struct TreeSitterData { chunks: RowChunks, - brackets_by_chunks: Vec>>>, + brackets_by_chunks: Mutex>>>>, } const MAX_ROWS_IN_A_CHUNK: u32 = 50; impl TreeSitterData { - fn clear(&mut self) { - self.brackets_by_chunks = vec![None; self.chunks.len()]; + fn clear(&mut self, snapshot: text::BufferSnapshot) { + self.chunks = RowChunks::new(snapshot, MAX_ROWS_IN_A_CHUNK); + self.brackets_by_chunks.get_mut().clear(); + self.brackets_by_chunks + .get_mut() + .resize(self.chunks.len(), None); } fn new(snapshot: text::BufferSnapshot) -> Self { let chunks = RowChunks::new(snapshot, MAX_ROWS_IN_A_CHUNK); Self { - brackets_by_chunks: vec![None; chunks.len()], + brackets_by_chunks: Mutex::new(vec![None; chunks.len()]), chunks, } } + + fn version(&self) -> &clock::Global { + self.chunks.version() + } } #[derive(Copy, Clone, Debug, PartialEq, Eq)] @@ -176,7 +184,7 @@ pub struct BufferSnapshot { remote_selections: TreeMap, language: Option>, non_text_state_update_count: usize, - tree_sitter_data: Arc>, + tree_sitter_data: Arc, } /// The kind and amount of indentation in a particular line. For now, @@ -1062,7 +1070,7 @@ impl Buffer { let tree_sitter_data = TreeSitterData::new(snapshot); Self { saved_mtime, - tree_sitter_data: Arc::new(Mutex::new(tree_sitter_data)), + tree_sitter_data: Arc::new(tree_sitter_data), saved_version: buffer.version(), preview_version: buffer.version(), reload_task: None, @@ -1119,7 +1127,7 @@ impl Buffer { file: None, diagnostics: Default::default(), remote_selections: Default::default(), - tree_sitter_data: Arc::new(Mutex::new(tree_sitter_data)), + tree_sitter_data: Arc::new(tree_sitter_data), language, non_text_state_update_count: 0, } @@ -1141,7 +1149,7 @@ impl Buffer { BufferSnapshot { text, syntax, - tree_sitter_data: Arc::new(Mutex::new(tree_sitter_data)), + tree_sitter_data: Arc::new(tree_sitter_data), file: None, diagnostics: Default::default(), remote_selections: Default::default(), @@ -1170,7 +1178,7 @@ impl Buffer { BufferSnapshot { text, syntax, - tree_sitter_data: Arc::new(Mutex::new(tree_sitter_data)), + tree_sitter_data: Arc::new(tree_sitter_data), file: None, diagnostics: Default::default(), remote_selections: Default::default(), @@ -1187,10 +1195,16 @@ impl Buffer { syntax_map.interpolate(&text); let syntax = syntax_map.snapshot(); + let tree_sitter_data = if self.text.version() != *self.tree_sitter_data.version() { + Arc::new(TreeSitterData::new(text.clone())) + } else { + self.tree_sitter_data.clone() + }; + BufferSnapshot { text, syntax, - tree_sitter_data: self.tree_sitter_data.clone(), + tree_sitter_data, file: self.file.clone(), remote_selections: self.remote_selections.clone(), diagnostics: self.diagnostics.clone(), @@ -1624,6 +1638,16 @@ impl Buffer { self.sync_parse_timeout = timeout; } + fn invalidate_tree_sitter_data(&mut self, snapshot: text::BufferSnapshot) { + match Arc::get_mut(&mut self.tree_sitter_data) { + Some(tree_sitter_data) => tree_sitter_data.clear(snapshot), + None => { + let tree_sitter_data = TreeSitterData::new(snapshot); + self.tree_sitter_data = Arc::new(tree_sitter_data) + } + } + } + /// Called after an edit to synchronize the buffer's main parse tree with /// the buffer's new underlying state. /// @@ -1648,6 +1672,9 @@ impl Buffer { /// for the same buffer, we only initiate a new parse if we are not already /// parsing in the background. pub fn reparse(&mut self, cx: &mut Context, may_block: bool) { + if self.text.version() != *self.tree_sitter_data.version() { + self.invalidate_tree_sitter_data(self.text.snapshot()); + } if self.reparse.is_some() { return; } @@ -1749,7 +1776,9 @@ impl Buffer { self.syntax_map.lock().did_parse(syntax_snapshot); self.request_autoindent(cx); self.parse_status.0.send(ParseStatus::Idle).unwrap(); - self.tree_sitter_data.lock().clear(); + if self.text.version() != *self.tree_sitter_data.version() { + self.invalidate_tree_sitter_data(self.text.snapshot()); + } cx.emit(BufferEvent::Reparsed); cx.notify(); } @@ -4281,155 +4310,123 @@ impl BufferSnapshot { pub fn fetch_bracket_ranges( &self, range: Range, - known_chunks: Option<(&Global, &HashSet>)>, + known_chunks: Option<&HashSet>>, ) -> HashMap, Vec>> { - let mut tree_sitter_data = self.latest_tree_sitter_data().clone(); - - let known_chunks = match known_chunks { - Some((known_version, known_chunks)) => { - if !tree_sitter_data - .chunks - .version() - .changed_since(known_version) - { - known_chunks.clone() - } else { - HashSet::default() - } - } - None => HashSet::default(), - }; - - let mut new_bracket_matches = HashMap::default(); let mut all_bracket_matches = HashMap::default(); - for chunk in tree_sitter_data + for chunk in self + .tree_sitter_data .chunks .applicable_chunks(&[self.anchor_before(range.start)..self.anchor_after(range.end)]) { - if known_chunks.contains(&chunk.row_range()) { + if known_chunks.is_some_and(|chunks| chunks.contains(&chunk.row_range())) { continue; } - let Some(chunk_range) = tree_sitter_data.chunks.chunk_range(chunk) else { + let Some(chunk_range) = self.tree_sitter_data.chunks.chunk_range(chunk) else { continue; }; - let chunk_range = chunk_range.to_offset(&tree_sitter_data.chunks.snapshot); - - let bracket_matches = match tree_sitter_data.brackets_by_chunks[chunk.id].take() { - Some(cached_brackets) => cached_brackets, - None => { - let mut all_brackets = Vec::new(); - let mut opens = Vec::new(); - let mut color_pairs = Vec::new(); - - let mut matches = - self.syntax - .matches(chunk_range.clone(), &self.text, |grammar| { - grammar.brackets_config.as_ref().map(|c| &c.query) - }); - let configs = matches - .grammars() - .iter() - .map(|grammar| grammar.brackets_config.as_ref().unwrap()) - .collect::>(); - - while let Some(mat) = matches.peek() { - let mut open = None; - let mut close = None; - let syntax_layer_depth = mat.depth; - let config = configs[mat.grammar_index]; - let pattern = &config.patterns[mat.pattern_index]; - for capture in mat.captures { - if capture.index == config.open_capture_ix { - open = Some(capture.node.byte_range()); - } else if capture.index == config.close_capture_ix { - close = Some(capture.node.byte_range()); - } - } + let chunk_range = chunk_range.to_offset(&self); - matches.advance(); + if let Some(cached_brackets) = + &self.tree_sitter_data.brackets_by_chunks.lock()[chunk.id] + { + all_bracket_matches.insert(chunk.row_range(), cached_brackets.clone()); + continue; + } - let Some((open_range, close_range)) = open.zip(close) else { - continue; - }; + let mut all_brackets = Vec::new(); + let mut opens = Vec::new(); + let mut color_pairs = Vec::new(); - let bracket_range = open_range.start..=close_range.end; - if !bracket_range.overlaps(&chunk_range) { - continue; - } + let mut matches = self + .syntax + .matches(chunk_range.clone(), &self.text, |grammar| { + grammar.brackets_config.as_ref().map(|c| &c.query) + }); + let configs = matches + .grammars() + .iter() + .map(|grammar| grammar.brackets_config.as_ref().unwrap()) + .collect::>(); + + while let Some(mat) = matches.peek() { + let mut open = None; + let mut close = None; + let syntax_layer_depth = mat.depth; + let config = configs[mat.grammar_index]; + let pattern = &config.patterns[mat.pattern_index]; + for capture in mat.captures { + if capture.index == config.open_capture_ix { + open = Some(capture.node.byte_range()); + } else if capture.index == config.close_capture_ix { + close = Some(capture.node.byte_range()); + } + } - let index = all_brackets.len(); - all_brackets.push(BracketMatch { - open_range: open_range.clone(), - close_range: close_range.clone(), - newline_only: pattern.newline_only, - syntax_layer_depth, - color_index: None, - }); + matches.advance(); - // Certain languages have "brackets" that are not brackets, e.g. tags. and such - // bracket will match the entire tag with all text inside. - // For now, avoid highlighting any pair that has more than single char in each bracket. - // We need to colorize `` bracket pairs, so cannot make this check stricter. - let should_color = !pattern.rainbow_exclude - && (open_range.len() == 1 || close_range.len() == 1); - if should_color { - opens.push(open_range.clone()); - color_pairs.push((open_range, close_range, index)); - } - } + let Some((open_range, close_range)) = open.zip(close) else { + continue; + }; - opens.sort_by_key(|r| (r.start, r.end)); - opens.dedup_by(|a, b| a.start == b.start && a.end == b.end); - color_pairs.sort_by_key(|(_, close, _)| close.end); + let bracket_range = open_range.start..=close_range.end; + if !bracket_range.overlaps(&chunk_range) { + continue; + } - let mut open_stack = Vec::new(); - let mut open_index = 0; - for (open, close, index) in color_pairs { - while open_index < opens.len() && opens[open_index].start < close.start { - open_stack.push(opens[open_index].clone()); - open_index += 1; - } + let index = all_brackets.len(); + all_brackets.push(BracketMatch { + open_range: open_range.clone(), + close_range: close_range.clone(), + newline_only: pattern.newline_only, + syntax_layer_depth, + color_index: None, + }); - if open_stack.last() == Some(&open) { - let depth_index = open_stack.len() - 1; - all_brackets[index].color_index = Some(depth_index); - open_stack.pop(); - } - } + // Certain languages have "brackets" that are not brackets, e.g. tags. and such + // bracket will match the entire tag with all text inside. + // For now, avoid highlighting any pair that has more than single char in each bracket. + // We need to colorize `` bracket pairs, so cannot make this check stricter. + let should_color = + !pattern.rainbow_exclude && (open_range.len() == 1 || close_range.len() == 1); + if should_color { + opens.push(open_range.clone()); + color_pairs.push((open_range, close_range, index)); + } + } - all_brackets.sort_by_key(|bracket_match| { - (bracket_match.open_range.start, bracket_match.open_range.end) - }); - new_bracket_matches.insert(chunk.id, all_brackets.clone()); - all_brackets + opens.sort_by_key(|r| (r.start, r.end)); + opens.dedup_by(|a, b| a.start == b.start && a.end == b.end); + color_pairs.sort_by_key(|(_, close, _)| close.end); + + let mut open_stack = Vec::new(); + let mut open_index = 0; + for (open, close, index) in color_pairs { + while open_index < opens.len() && opens[open_index].start < close.start { + open_stack.push(opens[open_index].clone()); + open_index += 1; } - }; - all_bracket_matches.insert(chunk.row_range(), bracket_matches); - } - let mut latest_tree_sitter_data = self.latest_tree_sitter_data(); - if latest_tree_sitter_data.chunks.version() == &self.version { - for (chunk_id, new_matches) in new_bracket_matches { - let old_chunks = &mut latest_tree_sitter_data.brackets_by_chunks[chunk_id]; - if old_chunks.is_none() { - *old_chunks = Some(new_matches); + if open_stack.last() == Some(&open) { + let depth_index = open_stack.len() - 1; + all_brackets[index].color_index = Some(depth_index); + open_stack.pop(); } } - } - all_bracket_matches - } + all_brackets.sort_by_key(|bracket_match| { + (bracket_match.open_range.start, bracket_match.open_range.end) + }); - fn latest_tree_sitter_data(&self) -> MutexGuard<'_, RawMutex, TreeSitterData> { - let mut tree_sitter_data = self.tree_sitter_data.lock(); - if self - .version - .changed_since(tree_sitter_data.chunks.version()) - { - *tree_sitter_data = TreeSitterData::new(self.text.clone()); + if let empty_slot @ None = + &mut self.tree_sitter_data.brackets_by_chunks.lock()[chunk.id] + { + *empty_slot = Some(all_brackets.clone()); + } + all_bracket_matches.insert(chunk.row_range(), all_brackets); } - tree_sitter_data + + all_bracket_matches } pub fn all_bracket_ranges( diff --git a/crates/language/src/buffer/row_chunk.rs b/crates/language/src/buffer/row_chunk.rs index 7589c5ac078b9443c3dfd501abb0e6d79cb74581..e4ef5227e690a9912257ea00edc2b5f722326ae3 100644 --- a/crates/language/src/buffer/row_chunk.rs +++ b/crates/language/src/buffer/row_chunk.rs @@ -19,7 +19,7 @@ use crate::BufferRow; /// #[derive(Clone)] pub struct RowChunks { - pub(crate) snapshot: text::BufferSnapshot, + snapshot: text::BufferSnapshot, chunks: Arc<[RowChunk]>, } diff --git a/crates/text/src/text.rs b/crates/text/src/text.rs index 31eed1e926d49584e0e71a494555284c66a4e255..6f570d61d8b743c2703ba221009ccc9e4727c87a 100644 --- a/crates/text/src/text.rs +++ b/crates/text/src/text.rs @@ -2321,8 +2321,13 @@ impl BufferSnapshot { } else if anchor.is_max() { self.visible_text.len() } else { - debug_assert!(anchor.buffer_id == Some(self.remote_id)); - debug_assert!(self.version.observed(anchor.timestamp)); + debug_assert_eq!(anchor.buffer_id, Some(self.remote_id)); + debug_assert!( + self.version.observed(anchor.timestamp), + "Anchor timestamp {:?} not observed by buffer {:?}", + anchor.timestamp, + self.version + ); let anchor_key = InsertionFragmentKey { timestamp: anchor.timestamp, split_offset: anchor.offset, From 47c30b6da7a7ffe48718c18bc9e09d3788de165d Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Fri, 12 Dec 2025 14:28:25 +0100 Subject: [PATCH 234/621] git: Revert "Ignore whitespace in git blame invocation" (#44648) Reverts zed-industries/zed#35960 cc @cole-miller --------- Co-authored-by: Cole Miller --- crates/fs/src/fake_git_repo.rs | 8 +++++++- crates/fs/src/fs.rs | 23 ++--------------------- crates/git/src/blame.rs | 10 ++++++---- crates/git/src/repository.rs | 16 ++++++++++++++-- crates/project/src/git_store.rs | 3 ++- crates/text/src/text.rs | 19 +++++++++++++++++++ 6 files changed, 50 insertions(+), 29 deletions(-) diff --git a/crates/fs/src/fake_git_repo.rs b/crates/fs/src/fake_git_repo.rs index 83c563fc0dc3dfdb83dec15092c4cf4ac8a41a14..be9b84ff6acd5e13080148f15103b8a21111de7a 100644 --- a/crates/fs/src/fake_git_repo.rs +++ b/crates/fs/src/fake_git_repo.rs @@ -23,6 +23,7 @@ use std::{ path::PathBuf, sync::{Arc, LazyLock}, }; +use text::LineEnding; use util::{paths::PathStyle, rel_path::RelPath}; pub static LOAD_INDEX_TEXT_TASK: LazyLock = LazyLock::new(TaskLabel::new); @@ -452,7 +453,12 @@ impl GitRepository for FakeGitRepository { }) } - fn blame(&self, path: RepoPath, _content: Rope) -> BoxFuture<'_, Result> { + fn blame( + &self, + path: RepoPath, + _content: Rope, + _line_ending: LineEnding, + ) -> BoxFuture<'_, Result> { self.with_state_async(false, move |state| { state .blames diff --git a/crates/fs/src/fs.rs b/crates/fs/src/fs.rs index 5be94ab6302b0a950b91e32dc43da374f0c62f29..e8357e359696bfcfbc7cfd829f84222c1303402a 100644 --- a/crates/fs/src/fs.rs +++ b/crates/fs/src/fs.rs @@ -803,7 +803,7 @@ impl Fs for RealFs { } let file = smol::fs::File::create(path).await?; let mut writer = smol::io::BufWriter::with_capacity(buffer_size, file); - for chunk in chunks(text, line_ending) { + for chunk in text::chunks_with_line_ending(text, line_ending) { writer.write_all(chunk.as_bytes()).await?; } writer.flush().await?; @@ -2555,7 +2555,7 @@ impl Fs for FakeFs { async fn save(&self, path: &Path, text: &Rope, line_ending: LineEnding) -> Result<()> { self.simulate_random_delay().await; let path = normalize_path(path); - let content = chunks(text, line_ending).collect::(); + let content = text::chunks_with_line_ending(text, line_ending).collect::(); if let Some(path) = path.parent() { self.create_dir(path).await?; } @@ -2773,25 +2773,6 @@ impl Fs for FakeFs { } } -fn chunks(rope: &Rope, line_ending: LineEnding) -> impl Iterator { - rope.chunks().flat_map(move |chunk| { - let mut newline = false; - let end_with_newline = chunk.ends_with('\n').then_some(line_ending.as_str()); - chunk - .lines() - .flat_map(move |line| { - let ending = if newline { - Some(line_ending.as_str()) - } else { - None - }; - newline = true; - ending.into_iter().chain([line]) - }) - .chain(end_with_newline) - }) -} - pub fn normalize_path(path: &Path) -> PathBuf { let mut components = path.components().peekable(); let mut ret = if let Some(c @ Component::Prefix(..)) = components.peek().cloned() { diff --git a/crates/git/src/blame.rs b/crates/git/src/blame.rs index 6325eacc8201d812d14dfdf4853f4004e22c263e..c3bbeff3f7d15d84b779f2ab92cb89799f63c4e8 100644 --- a/crates/git/src/blame.rs +++ b/crates/git/src/blame.rs @@ -8,7 +8,7 @@ use gpui::SharedString; use serde::{Deserialize, Serialize}; use std::process::Stdio; use std::{ops::Range, path::Path}; -use text::Rope; +use text::{LineEnding, Rope}; use time::OffsetDateTime; use time::UtcOffset; use time::macros::format_description; @@ -35,8 +35,10 @@ impl Blame { working_directory: &Path, path: &RepoPath, content: &Rope, + line_ending: LineEnding, ) -> Result { - let output = run_git_blame(git_binary, working_directory, path, content).await?; + let output = + run_git_blame(git_binary, working_directory, path, content, line_ending).await?; let mut entries = parse_git_blame(&output)?; entries.sort_unstable_by(|a, b| a.range.start.cmp(&b.range.start)); @@ -63,12 +65,12 @@ async fn run_git_blame( working_directory: &Path, path: &RepoPath, contents: &Rope, + line_ending: LineEnding, ) -> Result { let mut child = util::command::new_smol_command(git_binary) .current_dir(working_directory) .arg("blame") .arg("--incremental") - .arg("-w") .arg("--contents") .arg("-") .arg(path.as_unix_str()) @@ -83,7 +85,7 @@ async fn run_git_blame( .as_mut() .context("failed to get pipe to stdin of git blame command")?; - for chunk in contents.chunks() { + for chunk in text::chunks_with_line_ending(contents, line_ending) { stdin.write_all(chunk.as_bytes()).await?; } stdin.flush().await?; diff --git a/crates/git/src/repository.rs b/crates/git/src/repository.rs index 9f77ddc7cfc8e9e8d4ebca836e12f86496dc7c0b..c3dd0995ff83d4bfdd494e4b5c192ff5999c21f8 100644 --- a/crates/git/src/repository.rs +++ b/crates/git/src/repository.rs @@ -14,6 +14,7 @@ use rope::Rope; use schemars::JsonSchema; use serde::Deserialize; use smol::io::{AsyncBufReadExt, AsyncReadExt, BufReader}; +use text::LineEnding; use std::collections::HashSet; use std::ffi::{OsStr, OsString}; @@ -487,7 +488,12 @@ pub trait GitRepository: Send + Sync { fn show(&self, commit: String) -> BoxFuture<'_, Result>; fn load_commit(&self, commit: String, cx: AsyncApp) -> BoxFuture<'_, Result>; - fn blame(&self, path: RepoPath, content: Rope) -> BoxFuture<'_, Result>; + fn blame( + &self, + path: RepoPath, + content: Rope, + line_ending: LineEnding, + ) -> BoxFuture<'_, Result>; fn file_history(&self, path: RepoPath) -> BoxFuture<'_, Result>; fn file_history_paginated( &self, @@ -1512,7 +1518,12 @@ impl GitRepository for RealGitRepository { .boxed() } - fn blame(&self, path: RepoPath, content: Rope) -> BoxFuture<'_, Result> { + fn blame( + &self, + path: RepoPath, + content: Rope, + line_ending: LineEnding, + ) -> BoxFuture<'_, Result> { let working_directory = self.working_directory(); let git_binary_path = self.any_git_binary_path.clone(); let executor = self.executor.clone(); @@ -1524,6 +1535,7 @@ impl GitRepository for RealGitRepository { &working_directory?, &path, &content, + line_ending, ) .await }) diff --git a/crates/project/src/git_store.rs b/crates/project/src/git_store.rs index ae39cc331c3dae44261392e1a4d1782901443795..c73ab914b788fb92e69ea3a47db5446223098c2d 100644 --- a/crates/project/src/git_store.rs +++ b/crates/project/src/git_store.rs @@ -1031,6 +1031,7 @@ impl GitStore { Some(version) => buffer.rope_for_version(version), None => buffer.as_rope().clone(), }; + let line_ending = buffer.line_ending(); let version = version.unwrap_or(buffer.version()); let buffer_id = buffer.remote_id(); @@ -1042,7 +1043,7 @@ impl GitStore { .map_err(|err| anyhow::anyhow!(err))?; match repository_state { RepositoryState::Local(LocalRepositoryState { backend, .. }) => backend - .blame(repo_path.clone(), content) + .blame(repo_path.clone(), content, line_ending) .await .with_context(|| format!("Failed to blame {:?}", repo_path.as_ref())) .map(Some), diff --git a/crates/text/src/text.rs b/crates/text/src/text.rs index 6f570d61d8b743c2703ba221009ccc9e4727c87a..866552e4e5d9039a9517a556323a4ba7a89fcee1 100644 --- a/crates/text/src/text.rs +++ b/crates/text/src/text.rs @@ -3387,6 +3387,25 @@ impl LineEnding { } } +pub fn chunks_with_line_ending(rope: &Rope, line_ending: LineEnding) -> impl Iterator { + rope.chunks().flat_map(move |chunk| { + let mut newline = false; + let end_with_newline = chunk.ends_with('\n').then_some(line_ending.as_str()); + chunk + .lines() + .flat_map(move |line| { + let ending = if newline { + Some(line_ending.as_str()) + } else { + None + }; + newline = true; + ending.into_iter().chain([line]) + }) + .chain(end_with_newline) + }) +} + #[cfg(debug_assertions)] pub mod debug { use super::*; From 8bd4d866b94d3f0786f4c8d30d38c17f3149f921 Mon Sep 17 00:00:00 2001 From: localcc Date: Fri, 12 Dec 2025 05:51:11 -0800 Subject: [PATCH 235/621] Windows/send keystrokes (#44707) Closes #41176 Release Notes: - Fixed SendKeystrokes mapping on windows Co-authored-by: Kirill Bulatov --- crates/workspace/src/workspace.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index c445ed7822428ebc140a1685c619526d0a2b0ac5..d2a9ef71fc7fc2aacb1fc2f9be41ce001f5cef5e 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -2452,6 +2452,12 @@ impl Workspace { .0 .split(' ') .flat_map(|k| Keystroke::parse(k).log_err()) + .map(|k| { + cx.keyboard_mapper() + .map_key_equivalent(k, true) + .inner() + .clone() + }) .collect(); let _ = self.send_keystrokes_impl(keystrokes, window, cx); } From 4d0e760b04a6c4a4016885cb00a10d712bc099f5 Mon Sep 17 00:00:00 2001 From: Agus Zubiaga Date: Fri, 12 Dec 2025 11:03:08 -0300 Subject: [PATCH 236/621] edit prediction cli: Progress output cleanup (#44708) - Limit status lines to 10 in case `max_parallelism` is specified with a grater value - Handle logging gracefully rather than writing over it when clearing status lines Release Notes: - N/A --- Cargo.lock | 1 - crates/edit_prediction_cli/Cargo.toml | 1 - .../edit_prediction_cli/src/format_prompt.rs | 7 +- .../edit_prediction_cli/src/load_project.rs | 13 +- crates/edit_prediction_cli/src/main.rs | 35 +--- crates/edit_prediction_cli/src/predict.rs | 18 +- crates/edit_prediction_cli/src/progress.rs | 198 +++++++++++++----- .../src/retrieve_context.rs | 7 +- crates/edit_prediction_cli/src/score.rs | 4 +- 9 files changed, 173 insertions(+), 111 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2447303bacc666324a99c54247ab70f950d3bb0c..928e9f1a1db069d4e14cb80fe909aa22ac93e1ea 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5201,7 +5201,6 @@ dependencies = [ "wasmtime", "watch", "zeta_prompt", - "zlog", ] [[package]] diff --git a/crates/edit_prediction_cli/Cargo.toml b/crates/edit_prediction_cli/Cargo.toml index 61e55e09a3b0b46a7d6ad0338be3ab76c1e08401..811808c72304f4c11a9858e61395e46024b83f1e 100644 --- a/crates/edit_prediction_cli/Cargo.toml +++ b/crates/edit_prediction_cli/Cargo.toml @@ -56,7 +56,6 @@ watch.workspace = true edit_prediction = { workspace = true, features = ["cli-support"] } wasmtime.workspace = true zeta_prompt.workspace = true -zlog.workspace = true # Wasmtime is included as a dependency in order to enable the same # features that are enabled in Zed. diff --git a/crates/edit_prediction_cli/src/format_prompt.rs b/crates/edit_prediction_cli/src/format_prompt.rs index 2225f1d294144753408968c6f464988378e2691d..017e11a54c77e06bde7b74ed3f924692e33cd480 100644 --- a/crates/edit_prediction_cli/src/format_prompt.rs +++ b/crates/edit_prediction_cli/src/format_prompt.rs @@ -18,12 +18,11 @@ pub async fn run_format_prompt( example: &mut Example, prompt_format: PromptFormat, app_state: Arc, - progress: Arc, mut cx: AsyncApp, ) { - run_context_retrieval(example, app_state.clone(), progress.clone(), cx.clone()).await; + run_context_retrieval(example, app_state.clone(), cx.clone()).await; - let _step_progress = progress.start(Step::FormatPrompt, &example.name); + let _step_progress = Progress::global().start(Step::FormatPrompt, &example.name); match prompt_format { PromptFormat::Teacher => { @@ -35,7 +34,7 @@ pub async fn run_format_prompt( }); } PromptFormat::Zeta2 => { - run_load_project(example, app_state, progress.clone(), cx.clone()).await; + run_load_project(example, app_state, cx.clone()).await; let ep_store = cx .update(|cx| EditPredictionStore::try_global(cx).unwrap()) diff --git a/crates/edit_prediction_cli/src/load_project.rs b/crates/edit_prediction_cli/src/load_project.rs index 895105966713f653a0ce8277387276a0ae40a4bc..4d98ae9f3b85f4e6253d9ead4d846ed3d9deee89 100644 --- a/crates/edit_prediction_cli/src/load_project.rs +++ b/crates/edit_prediction_cli/src/load_project.rs @@ -25,17 +25,12 @@ use std::{ use util::{paths::PathStyle, rel_path::RelPath}; use zeta_prompt::CURSOR_MARKER; -pub async fn run_load_project( - example: &mut Example, - app_state: Arc, - progress: Arc, - mut cx: AsyncApp, -) { +pub async fn run_load_project(example: &mut Example, app_state: Arc, mut cx: AsyncApp) { if example.state.is_some() { return; } - let progress = progress.start(Step::LoadProject, &example.name); + let progress = Progress::global().start(Step::LoadProject, &example.name); let project = setup_project(example, &app_state, &progress, &mut cx).await; @@ -149,7 +144,7 @@ async fn cursor_position( async fn setup_project( example: &mut Example, app_state: &Arc, - step_progress: &Arc, + step_progress: &StepProgress, cx: &mut AsyncApp, ) -> Entity { let ep_store = cx @@ -227,7 +222,7 @@ async fn setup_project( project } -async fn setup_worktree(example: &Example, step_progress: &Arc) -> PathBuf { +async fn setup_worktree(example: &Example, step_progress: &StepProgress) -> PathBuf { let (repo_owner, repo_name) = example.repo_name().expect("failed to get repo name"); let repo_dir = REPOS_DIR.join(repo_owner.as_ref()).join(repo_name.as_ref()); let worktree_path = WORKTREES_DIR diff --git a/crates/edit_prediction_cli/src/main.rs b/crates/edit_prediction_cli/src/main.rs index b053af128c82c1aeefb35756ec28bc22a3ff2387..075f8862e6f86276a0df550c6d27f8c15a5d1293 100644 --- a/crates/edit_prediction_cli/src/main.rs +++ b/crates/edit_prediction_cli/src/main.rs @@ -32,7 +32,7 @@ use crate::score::run_scoring; struct EpArgs { #[arg(long, default_value_t = false)] printenv: bool, - #[clap(long, default_value_t = 10)] + #[clap(long, default_value_t = 10, global = true)] max_parallelism: usize, #[command(subcommand)] command: Option, @@ -112,8 +112,6 @@ impl EpArgs { } fn main() { - let _ = zlog::try_init(Some("error".into())); - zlog::init_output_stderr(); let args = EpArgs::parse(); if args.printenv { @@ -152,7 +150,7 @@ fn main() { }; let total_examples = examples.len(); - let progress = Progress::new(total_examples); + Progress::global().set_total_examples(total_examples); let mut grouped_examples = group_examples_by_repo(&mut examples); let example_batches = grouped_examples.chunks_mut(args.max_parallelism); @@ -163,29 +161,16 @@ fn main() { match &command { Command::ParseExample => {} Command::LoadProject => { - run_load_project( - example, - app_state.clone(), - progress.clone(), - cx.clone(), - ) - .await; + run_load_project(example, app_state.clone(), cx.clone()).await; } Command::Context => { - run_context_retrieval( - example, - app_state.clone(), - progress.clone(), - cx.clone(), - ) - .await; + run_context_retrieval(example, app_state.clone(), cx.clone()).await; } Command::FormatPrompt(args) => { run_format_prompt( example, args.prompt_format, app_state.clone(), - progress.clone(), cx.clone(), ) .await; @@ -196,7 +181,6 @@ fn main() { Some(args.provider), args.repetitions, app_state.clone(), - progress.clone(), cx.clone(), ) .await; @@ -205,14 +189,7 @@ fn main() { run_distill(example).await; } Command::Score(args) | Command::Eval(args) => { - run_scoring( - example, - &args, - app_state.clone(), - progress.clone(), - cx.clone(), - ) - .await; + run_scoring(example, &args, app_state.clone(), cx.clone()).await; } Command::Clean => { unreachable!() @@ -222,7 +199,7 @@ fn main() { }); futures::future::join_all(futures).await; } - progress.clear(); + Progress::global().clear(); if args.output.is_some() || !matches!(command, Command::Eval(_)) { write_examples(&examples, output.as_ref()); diff --git a/crates/edit_prediction_cli/src/predict.rs b/crates/edit_prediction_cli/src/predict.rs index 14628a896273f7ff11166a1daac248598e198847..3f690266e3165b2d52f642457e7aebf959a40a03 100644 --- a/crates/edit_prediction_cli/src/predict.rs +++ b/crates/edit_prediction_cli/src/predict.rs @@ -25,7 +25,6 @@ pub async fn run_prediction( provider: Option, repetition_count: usize, app_state: Arc, - progress: Arc, mut cx: AsyncApp, ) { if !example.predictions.is_empty() { @@ -34,32 +33,25 @@ pub async fn run_prediction( let provider = provider.unwrap(); - run_context_retrieval(example, app_state.clone(), progress.clone(), cx.clone()).await; + run_context_retrieval(example, app_state.clone(), cx.clone()).await; if matches!( provider, PredictionProvider::Teacher | PredictionProvider::TeacherNonBatching ) { - let _step_progress = progress.start(Step::Predict, &example.name); + let _step_progress = Progress::global().start(Step::Predict, &example.name); if example.prompt.is_none() { - run_format_prompt( - example, - PromptFormat::Teacher, - app_state.clone(), - progress, - cx, - ) - .await; + run_format_prompt(example, PromptFormat::Teacher, app_state.clone(), cx).await; } let batched = matches!(provider, PredictionProvider::Teacher); return predict_anthropic(example, repetition_count, batched).await; } - run_load_project(example, app_state.clone(), progress.clone(), cx.clone()).await; + run_load_project(example, app_state.clone(), cx.clone()).await; - let _step_progress = progress.start(Step::Predict, &example.name); + let _step_progress = Progress::global().start(Step::Predict, &example.name); if matches!( provider, diff --git a/crates/edit_prediction_cli/src/progress.rs b/crates/edit_prediction_cli/src/progress.rs index 5cd906d89a20813676b09af0d2cbeca532c5ba12..8195485d70c70c0cbfb38e2de83a055598d5e4e5 100644 --- a/crates/edit_prediction_cli/src/progress.rs +++ b/crates/edit_prediction_cli/src/progress.rs @@ -2,10 +2,12 @@ use std::{ borrow::Cow, collections::HashMap, io::{IsTerminal, Write}, - sync::{Arc, Mutex}, + sync::{Arc, Mutex, OnceLock}, time::{Duration, Instant}, }; +use log::{Level, Log, Metadata, Record}; + pub struct Progress { inner: Mutex, } @@ -18,6 +20,7 @@ struct ProgressInner { max_example_name_len: usize, status_lines_displayed: usize, total_examples: usize, + last_line_is_logging: bool, } #[derive(Clone)] @@ -72,70 +75,114 @@ impl Step { } } +static GLOBAL: OnceLock> = OnceLock::new(); +static LOGGER: ProgressLogger = ProgressLogger; + const RIGHT_MARGIN: usize = 4; +const MAX_STATUS_LINES: usize = 10; impl Progress { - pub fn new(total_examples: usize) -> Arc { - Arc::new(Self { - inner: Mutex::new(ProgressInner { - completed: Vec::new(), - in_progress: HashMap::new(), - is_tty: std::io::stderr().is_terminal(), - terminal_width: get_terminal_width(), - max_example_name_len: 0, - status_lines_displayed: 0, - total_examples, - }), - }) + /// Returns the global Progress instance, initializing it if necessary. + pub fn global() -> Arc { + GLOBAL + .get_or_init(|| { + let progress = Arc::new(Self { + inner: Mutex::new(ProgressInner { + completed: Vec::new(), + in_progress: HashMap::new(), + is_tty: std::io::stderr().is_terminal(), + terminal_width: get_terminal_width(), + max_example_name_len: 0, + status_lines_displayed: 0, + total_examples: 0, + last_line_is_logging: false, + }), + }); + let _ = log::set_logger(&LOGGER); + log::set_max_level(log::LevelFilter::Error); + progress + }) + .clone() } - pub fn start(self: &Arc, step: Step, example_name: &str) -> Arc { - { - let mut inner = self.inner.lock().unwrap(); + pub fn set_total_examples(&self, total: usize) { + let mut inner = self.inner.lock().unwrap(); + inner.total_examples = total; + } - Self::clear_status_lines(&mut inner); + /// Prints a message to stderr, clearing and redrawing status lines to avoid corruption. + /// This should be used for any output that needs to appear above the status lines. + fn log(&self, message: &str) { + let mut inner = self.inner.lock().unwrap(); + Self::clear_status_lines(&mut inner); - inner.max_example_name_len = inner.max_example_name_len.max(example_name.len()); + if !inner.last_line_is_logging { + let reset = "\x1b[0m"; + let dim = "\x1b[2m"; + let divider = "─".repeat(inner.terminal_width.saturating_sub(RIGHT_MARGIN)); + eprintln!("{dim}{divider}{reset}"); + inner.last_line_is_logging = true; + } - inner.in_progress.insert( - example_name.to_string(), - InProgressTask { - step, - started_at: Instant::now(), - substatus: None, - info: None, - }, - ); + eprintln!("{}", message); + } - Self::print_status_lines(&mut inner); - } + pub fn start(self: &Arc, step: Step, example_name: &str) -> StepProgress { + let mut inner = self.inner.lock().unwrap(); + + Self::clear_status_lines(&mut inner); + + inner.max_example_name_len = inner.max_example_name_len.max(example_name.len()); + inner.in_progress.insert( + example_name.to_string(), + InProgressTask { + step, + started_at: Instant::now(), + substatus: None, + info: None, + }, + ); + + Self::print_status_lines(&mut inner); - Arc::new(StepProgress { + StepProgress { progress: self.clone(), step, example_name: example_name.to_string(), - }) + } } - pub fn finish(&self, step: Step, example_name: &str) { + fn finish(&self, step: Step, example_name: &str) { let mut inner = self.inner.lock().unwrap(); - let task = inner.in_progress.remove(example_name); - if let Some(task) = task { - if task.step == step { - inner.completed.push(CompletedTask { - step: task.step, - example_name: example_name.to_string(), - duration: task.started_at.elapsed(), - info: task.info, - }); + let Some(task) = inner.in_progress.remove(example_name) else { + return; + }; - Self::clear_status_lines(&mut inner); - Self::print_completed(&inner, inner.completed.last().unwrap()); - Self::print_status_lines(&mut inner); - } else { - inner.in_progress.insert(example_name.to_string(), task); - } + if task.step == step { + inner.completed.push(CompletedTask { + step: task.step, + example_name: example_name.to_string(), + duration: task.started_at.elapsed(), + info: task.info, + }); + + Self::clear_status_lines(&mut inner); + Self::print_logging_closing_divider(&mut inner); + Self::print_completed(&inner, inner.completed.last().unwrap()); + Self::print_status_lines(&mut inner); + } else { + inner.in_progress.insert(example_name.to_string(), task); + } + } + + fn print_logging_closing_divider(inner: &mut ProgressInner) { + if inner.last_line_is_logging { + let reset = "\x1b[0m"; + let dim = "\x1b[2m"; + let divider = "─".repeat(inner.terminal_width.saturating_sub(RIGHT_MARGIN)); + eprintln!("{dim}{divider}{reset}"); + inner.last_line_is_logging = false; } } @@ -234,9 +281,10 @@ impl Progress { let mut tasks: Vec<_> = inner.in_progress.iter().collect(); tasks.sort_by_key(|(name, _)| *name); + let total_tasks = tasks.len(); let mut lines_printed = 0; - for (name, task) in tasks.iter() { + for (name, task) in tasks.iter().take(MAX_STATUS_LINES) { let elapsed = format_duration(task.started_at.elapsed()); let substatus_part = task .substatus @@ -265,6 +313,13 @@ impl Progress { lines_printed += 1; } + // Show "+N more" on its own line if there are more tasks + if total_tasks > MAX_STATUS_LINES { + let remaining = total_tasks - MAX_STATUS_LINES; + eprintln!("{:>12} +{remaining} more", ""); + lines_printed += 1; + } + inner.status_lines_displayed = lines_printed + 1; // +1 for the divider line let _ = std::io::stderr().flush(); } @@ -314,6 +369,53 @@ impl Drop for StepProgress { } } +struct ProgressLogger; + +impl Log for ProgressLogger { + fn enabled(&self, metadata: &Metadata) -> bool { + metadata.level() <= Level::Info + } + + fn log(&self, record: &Record) { + if !self.enabled(record.metadata()) { + return; + } + + let level_color = match record.level() { + Level::Error => "\x1b[31m", + Level::Warn => "\x1b[33m", + Level::Info => "\x1b[32m", + Level::Debug => "\x1b[34m", + Level::Trace => "\x1b[35m", + }; + let reset = "\x1b[0m"; + let bold = "\x1b[1m"; + + let level_label = match record.level() { + Level::Error => "Error", + Level::Warn => "Warn", + Level::Info => "Info", + Level::Debug => "Debug", + Level::Trace => "Trace", + }; + + let message = format!( + "{bold}{level_color}{level_label:>12}{reset} {}", + record.args() + ); + + if let Some(progress) = GLOBAL.get() { + progress.log(&message); + } else { + eprintln!("{}", message); + } + } + + fn flush(&self) { + let _ = std::io::stderr().flush(); + } +} + #[cfg(unix)] fn get_terminal_width() -> usize { unsafe { diff --git a/crates/edit_prediction_cli/src/retrieve_context.rs b/crates/edit_prediction_cli/src/retrieve_context.rs index 83b5906e976ca3a1a6bdff6a96c36713eef08058..c066cf3caa9ece27144222ef94e3ac72c2285be8 100644 --- a/crates/edit_prediction_cli/src/retrieve_context.rs +++ b/crates/edit_prediction_cli/src/retrieve_context.rs @@ -16,16 +16,17 @@ use std::time::Duration; pub async fn run_context_retrieval( example: &mut Example, app_state: Arc, - progress: Arc, mut cx: AsyncApp, ) { if example.context.is_some() { return; } - run_load_project(example, app_state.clone(), progress.clone(), cx.clone()).await; + run_load_project(example, app_state.clone(), cx.clone()).await; - let step_progress = progress.start(Step::Context, &example.name); + let step_progress: Arc = Progress::global() + .start(Step::Context, &example.name) + .into(); let state = example.state.as_ref().unwrap(); let project = state.project.clone(); diff --git a/crates/edit_prediction_cli/src/score.rs b/crates/edit_prediction_cli/src/score.rs index 23086dcc6e9279820216961ef0fe9fc65c3ea3eb..b87d8e4df24c8cb12676ed71fe1ea930a841791d 100644 --- a/crates/edit_prediction_cli/src/score.rs +++ b/crates/edit_prediction_cli/src/score.rs @@ -14,7 +14,6 @@ pub async fn run_scoring( example: &mut Example, args: &PredictArgs, app_state: Arc, - progress: Arc, cx: AsyncApp, ) { run_prediction( @@ -22,12 +21,11 @@ pub async fn run_scoring( Some(args.provider), args.repetitions, app_state, - progress.clone(), cx, ) .await; - let _progress = progress.start(Step::Score, &example.name); + let _progress = Progress::global().start(Step::Score, &example.name); let expected_patch = parse_patch(&example.expected_patch); From 636d11ebec8e74f0f0c173e858597fb57ccfa0b9 Mon Sep 17 00:00:00 2001 From: localcc Date: Fri, 12 Dec 2025 06:32:30 -0800 Subject: [PATCH 237/621] Multiple priority scheduler (#44701) Improves the scheduler by allowing tasks to have a set priority which will significantly improve responsiveness. Release notes: - N/A --------- Co-authored-by: Yara Co-authored-by: dvdsk --- Cargo.lock | 1 + crates/gpui/Cargo.toml | 5 +- crates/gpui/build.rs | 2 + crates/gpui/src/app.rs | 27 +- crates/gpui/src/app/context.rs | 23 +- crates/gpui/src/executor.rs | 170 ++++++++- crates/gpui/src/gpui.rs | 9 +- crates/gpui/src/platform.rs | 12 +- crates/gpui/src/platform/linux/dispatcher.rs | 329 +++++++++++++++--- crates/gpui/src/platform/linux/platform.rs | 10 +- .../gpui/src/platform/linux/wayland/client.rs | 10 +- crates/gpui/src/platform/linux/x11/client.rs | 8 +- crates/gpui/src/platform/mac/dispatcher.rs | 145 +++++++- crates/gpui/src/platform/test/dispatcher.rs | 12 +- .../gpui/src/platform/windows/dispatcher.rs | 85 +++-- crates/gpui/src/platform/windows/events.rs | 3 +- crates/gpui/src/platform/windows/platform.rs | 24 +- crates/gpui/src/platform/windows/window.rs | 4 +- crates/gpui/src/profiler.rs | 16 + crates/gpui/src/queue.rs | 329 ++++++++++++++++++ crates/gpui/src/window.rs | 38 +- crates/repl/src/repl.rs | 4 +- crates/worktree/src/worktree.rs | 5 +- typos.toml | 2 + 24 files changed, 1118 insertions(+), 155 deletions(-) create mode 100644 crates/gpui/src/queue.rs diff --git a/Cargo.lock b/Cargo.lock index 928e9f1a1db069d4e14cb80fe909aa22ac93e1ea..981f59cb5eae413f165fdee7e8cce7c827b8c25c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7239,6 +7239,7 @@ dependencies = [ "libc", "log", "lyon", + "mach2 0.5.0", "media", "metal", "naga", diff --git a/crates/gpui/Cargo.toml b/crates/gpui/Cargo.toml index 4985cc07383aac56d6975fa09a410a0cee6c549d..8fc37978683357e53ed9f9c3cf587fcd704431e2 100644 --- a/crates/gpui/Cargo.toml +++ b/crates/gpui/Cargo.toml @@ -21,7 +21,6 @@ default = ["font-kit", "wayland", "x11", "windows-manifest"] test-support = [ "leak-detection", "collections/test-support", - "rand", "util/test-support", "http_client/test-support", "wayland", @@ -109,7 +108,7 @@ parking = "2.0.0" parking_lot.workspace = true postage.workspace = true profiling.workspace = true -rand = { optional = true, workspace = true } +rand.workspace = true raw-window-handle = "0.6" refineable.workspace = true resvg = { version = "0.45.0", default-features = false, features = [ @@ -158,8 +157,10 @@ media.workspace = true objc.workspace = true objc2 = { version = "0.6", optional = true } objc2-metal = { version = "0.3", optional = true } +mach2.workspace = true #TODO: replace with "objc2" metal.workspace = true +flume = "0.11" [target.'cfg(any(target_os = "linux", target_os = "freebsd", target_os = "macos"))'.dependencies] pathfinder_geometry = "0.5" diff --git a/crates/gpui/build.rs b/crates/gpui/build.rs index ec35ec0bc63113582a945c71198cd7bc14301dcc..c7ae7ac9f239f2f6ce3880f9329f2ba92b2174f3 100644 --- a/crates/gpui/build.rs +++ b/crates/gpui/build.rs @@ -84,6 +84,8 @@ mod macos { .allowlist_var("_dispatch_main_q") .allowlist_var("_dispatch_source_type_data_add") .allowlist_var("DISPATCH_QUEUE_PRIORITY_HIGH") + .allowlist_var("DISPATCH_QUEUE_PRIORITY_DEFAULT") + .allowlist_var("DISPATCH_QUEUE_PRIORITY_LOW") .allowlist_var("DISPATCH_TIME_NOW") .allowlist_function("dispatch_get_global_queue") .allowlist_function("dispatch_async_f") diff --git a/crates/gpui/src/app.rs b/crates/gpui/src/app.rs index 2f4c7611dcf9d24302b3dda1d05c4c2b8711a68d..f7c57ef015e73618b8cfd9d5da8dbb717905577b 100644 --- a/crates/gpui/src/app.rs +++ b/crates/gpui/src/app.rs @@ -38,10 +38,11 @@ use crate::{ AssetSource, BackgroundExecutor, Bounds, ClipboardItem, CursorStyle, DispatchPhase, DisplayId, EventEmitter, FocusHandle, FocusMap, ForegroundExecutor, Global, KeyBinding, KeyContext, Keymap, Keystroke, LayoutId, Menu, MenuItem, OwnedMenu, PathPromptOptions, Pixels, Platform, - PlatformDisplay, PlatformKeyboardLayout, PlatformKeyboardMapper, Point, PromptBuilder, - PromptButton, PromptHandle, PromptLevel, Render, RenderImage, RenderablePromptHandle, - Reservation, ScreenCaptureSource, SharedString, SubscriberSet, Subscription, SvgRenderer, Task, - TextSystem, Window, WindowAppearance, WindowHandle, WindowId, WindowInvalidator, + PlatformDisplay, PlatformKeyboardLayout, PlatformKeyboardMapper, Point, Priority, + PromptBuilder, PromptButton, PromptHandle, PromptLevel, Render, RenderImage, + RenderablePromptHandle, Reservation, ScreenCaptureSource, SharedString, SubscriberSet, + Subscription, SvgRenderer, Task, TextSystem, Window, WindowAppearance, WindowHandle, WindowId, + WindowInvalidator, colors::{Colors, GlobalColors}, current_platform, hash, init_app_menus, }; @@ -1494,6 +1495,24 @@ impl App { .spawn(async move { f(&mut cx).await }) } + /// Spawns the future returned by the given function on the main thread with + /// the given priority. The closure will be invoked with [AsyncApp], which + /// allows the application state to be accessed across await points. + pub fn spawn_with_priority(&self, priority: Priority, f: AsyncFn) -> Task + where + AsyncFn: AsyncFnOnce(&mut AsyncApp) -> R + 'static, + R: 'static, + { + if self.quitting { + debug_panic!("Can't spawn on main thread after on_app_quit") + }; + + let mut cx = self.to_async(); + + self.foreground_executor + .spawn_with_priority(priority, async move { f(&mut cx).await }) + } + /// Schedules the given function to be run at the end of the current effect cycle, allowing entities /// that are currently on the stack to be returned to the app. pub fn defer(&mut self, f: impl FnOnce(&mut App) + 'static) { diff --git a/crates/gpui/src/app/context.rs b/crates/gpui/src/app/context.rs index 65bb5521e32bb6fcfac2bcd95009949499589df1..27ccbecaf83cafe7bf7562c32a164268a74a396b 100644 --- a/crates/gpui/src/app/context.rs +++ b/crates/gpui/src/app/context.rs @@ -1,7 +1,7 @@ use crate::{ AnyView, AnyWindowHandle, AppContext, AsyncApp, DispatchPhase, Effect, EntityId, EventEmitter, - FocusHandle, FocusOutEvent, Focusable, Global, KeystrokeObserver, Reservation, SubscriberSet, - Subscription, Task, WeakEntity, WeakFocusHandle, Window, WindowHandle, + FocusHandle, FocusOutEvent, Focusable, Global, KeystrokeObserver, Priority, Reservation, + SubscriberSet, Subscription, Task, WeakEntity, WeakFocusHandle, Window, WindowHandle, }; use anyhow::Result; use futures::FutureExt; @@ -667,6 +667,25 @@ impl<'a, T: 'static> Context<'a, T> { window.spawn(self, async move |cx| f(view, cx).await) } + /// Schedule a future to be run asynchronously with the given priority. + /// The given callback is invoked with a [`WeakEntity`] to avoid leaking the entity for a long-running process. + /// It's also given an [`AsyncWindowContext`], which can be used to access the state of the entity across await points. + /// The returned future will be polled on the main thread. + #[track_caller] + pub fn spawn_in_with_priority( + &self, + priority: Priority, + window: &Window, + f: AsyncFn, + ) -> Task + where + R: 'static, + AsyncFn: AsyncFnOnce(WeakEntity, &mut AsyncWindowContext) -> R + 'static, + { + let view = self.weak_entity(); + window.spawn_with_priority(priority, self, async move |cx| f(view, cx).await) + } + /// Register a callback to be invoked when the given global state changes. pub fn observe_global_in( &mut self, diff --git a/crates/gpui/src/executor.rs b/crates/gpui/src/executor.rs index 30d3777b96c820c6b7248995df4cc9ef6b821bd0..a219a20e92819f7d510ff9e93bce493f7ca723c9 100644 --- a/crates/gpui/src/executor.rs +++ b/crates/gpui/src/executor.rs @@ -1,4 +1,4 @@ -use crate::{App, PlatformDispatcher, RunnableMeta, RunnableVariant}; +use crate::{App, PlatformDispatcher, RunnableMeta, RunnableVariant, TaskTiming, profiler}; use async_task::Runnable; use futures::channel::mpsc; use parking_lot::{Condvar, Mutex}; @@ -47,6 +47,52 @@ pub struct ForegroundExecutor { not_send: PhantomData>, } +/// Realtime task priority +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] +#[repr(u8)] +pub enum RealtimePriority { + /// Audio task + Audio, + /// Other realtime task + #[default] + Other, +} + +/// Task priority +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] +#[repr(u8)] +pub enum Priority { + /// Realtime priority + /// + /// Spawning a task with this priority will spin it off on a separate thread dedicated just to that task. + Realtime(RealtimePriority), + /// High priority + /// + /// Only use for tasks that are critical to the user experience / responsiveness of the editor. + High, + /// Medium priority, probably suits most of your use cases. + #[default] + Medium, + /// Low priority + /// + /// Prioritize this for background work that can come in large quantities + /// to not starve the executor of resources for high priority tasks + Low, +} + +impl Priority { + #[allow(dead_code)] + pub(crate) const fn probability(&self) -> u32 { + match self { + // realtime priorities are not considered for probability scheduling + Priority::Realtime(_) => 0, + Priority::High => 60, + Priority::Medium => 30, + Priority::Low => 10, + } + } +} + /// Task is a primitive that allows work to happen in the background. /// /// It implements [`Future`] so you can `.await` on it. @@ -152,7 +198,20 @@ impl BackgroundExecutor { where R: Send + 'static, { - self.spawn_internal::(Box::pin(future), None) + self.spawn_with_priority(Priority::default(), future) + } + + /// Enqueues the given future to be run to completion on a background thread. + #[track_caller] + pub fn spawn_with_priority( + &self, + priority: Priority, + future: impl Future + Send + 'static, + ) -> Task + where + R: Send + 'static, + { + self.spawn_internal::(Box::pin(future), None, priority) } /// Enqueues the given future to be run to completion on a background thread and blocking the current task on it. @@ -199,7 +258,13 @@ impl BackgroundExecutor { let _notify_guard = NotifyOnDrop(pair); future.await }, - move |runnable| dispatcher.dispatch(RunnableVariant::Meta(runnable), None), + move |runnable| { + dispatcher.dispatch( + RunnableVariant::Meta(runnable), + None, + Priority::default(), + ) + }, ) }; runnable.schedule(); @@ -217,7 +282,7 @@ impl BackgroundExecutor { where R: Send + 'static, { - self.spawn_internal::(Box::pin(future), Some(label)) + self.spawn_internal::(Box::pin(future), Some(label), Priority::default()) } #[track_caller] @@ -225,15 +290,55 @@ impl BackgroundExecutor { &self, future: AnyFuture, label: Option, + priority: Priority, ) -> Task { let dispatcher = self.dispatcher.clone(); - let location = core::panic::Location::caller(); - let (runnable, task) = async_task::Builder::new() - .metadata(RunnableMeta { location }) - .spawn( - move |_| future, - move |runnable| dispatcher.dispatch(RunnableVariant::Meta(runnable), label), + let (runnable, task) = if let Priority::Realtime(realtime) = priority { + let location = core::panic::Location::caller(); + let (mut tx, rx) = flume::bounded::>(1); + + dispatcher.spawn_realtime( + realtime, + Box::new(move || { + while let Ok(runnable) = rx.recv() { + let start = Instant::now(); + let location = runnable.metadata().location; + let mut timing = TaskTiming { + location, + start, + end: None, + }; + profiler::add_task_timing(timing); + + runnable.run(); + + let end = Instant::now(); + timing.end = Some(end); + profiler::add_task_timing(timing); + } + }), ); + + async_task::Builder::new() + .metadata(RunnableMeta { location }) + .spawn( + move |_| future, + move |runnable| { + let _ = tx.send(runnable); + }, + ) + } else { + let location = core::panic::Location::caller(); + async_task::Builder::new() + .metadata(RunnableMeta { location }) + .spawn( + move |_| future, + move |runnable| { + dispatcher.dispatch(RunnableVariant::Meta(runnable), label, priority) + }, + ) + }; + runnable.schedule(); Task(TaskState::Spawned(task)) } @@ -406,11 +511,28 @@ impl BackgroundExecutor { where F: FnOnce(&mut Scope<'scope>), { - let mut scope = Scope::new(self.clone()); + let mut scope = Scope::new(self.clone(), Priority::default()); (scheduler)(&mut scope); let spawned = mem::take(&mut scope.futures) .into_iter() - .map(|f| self.spawn(f)) + .map(|f| self.spawn_with_priority(scope.priority, f)) + .collect::>(); + for task in spawned { + task.await; + } + } + + /// Scoped lets you start a number of tasks and waits + /// for all of them to complete before returning. + pub async fn scoped_priority<'scope, F>(&self, priority: Priority, scheduler: F) + where + F: FnOnce(&mut Scope<'scope>), + { + let mut scope = Scope::new(self.clone(), priority); + (scheduler)(&mut scope); + let spawned = mem::take(&mut scope.futures) + .into_iter() + .map(|f| self.spawn_with_priority(scope.priority, f)) .collect::>(); for task in spawned { task.await; @@ -546,6 +668,19 @@ impl ForegroundExecutor { /// Enqueues the given Task to run on the main thread at some point in the future. #[track_caller] pub fn spawn(&self, future: impl Future + 'static) -> Task + where + R: 'static, + { + self.spawn_with_priority(Priority::default(), future) + } + + /// Enqueues the given Task to run on the main thread at some point in the future. + #[track_caller] + pub fn spawn_with_priority( + &self, + priority: Priority, + future: impl Future + 'static, + ) -> Task where R: 'static, { @@ -557,16 +692,19 @@ impl ForegroundExecutor { dispatcher: Arc, future: AnyLocalFuture, location: &'static core::panic::Location<'static>, + priority: Priority, ) -> Task { let (runnable, task) = spawn_local_with_source_location( future, - move |runnable| dispatcher.dispatch_on_main_thread(RunnableVariant::Meta(runnable)), + move |runnable| { + dispatcher.dispatch_on_main_thread(RunnableVariant::Meta(runnable), priority) + }, RunnableMeta { location }, ); runnable.schedule(); Task(TaskState::Spawned(task)) } - inner::(dispatcher, Box::pin(future), location) + inner::(dispatcher, Box::pin(future), location, priority) } } @@ -642,6 +780,7 @@ where /// Scope manages a set of tasks that are enqueued and waited on together. See [`BackgroundExecutor::scoped`]. pub struct Scope<'a> { executor: BackgroundExecutor, + priority: Priority, futures: Vec + Send + 'static>>>, tx: Option>, rx: mpsc::Receiver<()>, @@ -649,10 +788,11 @@ pub struct Scope<'a> { } impl<'a> Scope<'a> { - fn new(executor: BackgroundExecutor) -> Self { + fn new(executor: BackgroundExecutor, priority: Priority) -> Self { let (tx, rx) = mpsc::channel(1); Self { executor, + priority, tx: Some(tx), rx, futures: Default::default(), diff --git a/crates/gpui/src/gpui.rs b/crates/gpui/src/gpui.rs index bc70362047d7826519f6f7c734b7c5a84281b31f..e5c726f58e117b76e2dbb2976089d5788baa848e 100644 --- a/crates/gpui/src/gpui.rs +++ b/crates/gpui/src/gpui.rs @@ -31,6 +31,8 @@ mod path_builder; mod platform; pub mod prelude; mod profiler; +#[cfg(any(target_os = "windows", target_os = "linux"))] +mod queue; mod scene; mod shared_string; mod shared_uri; @@ -89,16 +91,20 @@ pub use keymap::*; pub use path_builder::*; pub use platform::*; pub use profiler::*; +#[cfg(any(target_os = "windows", target_os = "linux"))] +pub(crate) use queue::{PriorityQueueReceiver, PriorityQueueSender}; pub use refineable::*; pub use scene::*; pub use shared_string::*; pub use shared_uri::*; pub use smol::Timer; +use std::{any::Any, future::Future}; pub use style::*; pub use styled::*; pub use subscription::*; pub use svg_renderer::*; pub(crate) use tab_stop::*; +use taffy::TaffyLayoutEngine; pub use taffy::{AvailableSpace, LayoutId}; #[cfg(any(test, feature = "test-support"))] pub use test::*; @@ -109,9 +115,6 @@ pub use util::{FutureExt, Timeout, arc_cow::ArcCow}; pub use view::*; pub use window::*; -use std::{any::Any, future::Future}; -use taffy::TaffyLayoutEngine; - /// The context trait, allows the different contexts in GPUI to be used /// interchangeably for certain operations. pub trait AppContext { diff --git a/crates/gpui/src/platform.rs b/crates/gpui/src/platform.rs index 922cfd13c16d098380c39f8d2d1f72e66624b78f..f120e075fea7f9336e2f6e10c51611d8ba03564d 100644 --- a/crates/gpui/src/platform.rs +++ b/crates/gpui/src/platform.rs @@ -39,9 +39,10 @@ use crate::{ Action, AnyWindowHandle, App, AsyncWindowContext, BackgroundExecutor, Bounds, DEFAULT_WINDOW_SIZE, DevicePixels, DispatchEventResult, Font, FontId, FontMetrics, FontRun, ForegroundExecutor, GlyphId, GpuSpecs, ImageSource, Keymap, LineLayout, Pixels, PlatformInput, - Point, RenderGlyphParams, RenderImage, RenderImageParams, RenderSvgParams, Scene, ShapedGlyph, - ShapedRun, SharedString, Size, SvgRenderer, SystemWindowTab, Task, TaskLabel, TaskTiming, - ThreadTaskTimings, Window, WindowControlArea, hash, point, px, size, + Point, Priority, RealtimePriority, RenderGlyphParams, RenderImage, RenderImageParams, + RenderSvgParams, Scene, ShapedGlyph, ShapedRun, SharedString, Size, SvgRenderer, + SystemWindowTab, Task, TaskLabel, TaskTiming, ThreadTaskTimings, Window, WindowControlArea, + hash, point, px, size, }; use anyhow::Result; use async_task::Runnable; @@ -587,9 +588,10 @@ pub trait PlatformDispatcher: Send + Sync { fn get_all_timings(&self) -> Vec; fn get_current_thread_timings(&self) -> Vec; fn is_main_thread(&self) -> bool; - fn dispatch(&self, runnable: RunnableVariant, label: Option); - fn dispatch_on_main_thread(&self, runnable: RunnableVariant); + fn dispatch(&self, runnable: RunnableVariant, label: Option, priority: Priority); + fn dispatch_on_main_thread(&self, runnable: RunnableVariant, priority: Priority); fn dispatch_after(&self, duration: Duration, runnable: RunnableVariant); + fn spawn_realtime(&self, priority: RealtimePriority, f: Box); fn now(&self) -> Instant { Instant::now() diff --git a/crates/gpui/src/platform/linux/dispatcher.rs b/crates/gpui/src/platform/linux/dispatcher.rs index d0c32140f3642e037df326f4e2beae16c59dd883..d88eefd2c8a7fc648b20f7a2e520fe40158acd51 100644 --- a/crates/gpui/src/platform/linux/dispatcher.rs +++ b/crates/gpui/src/platform/linux/dispatcher.rs @@ -1,9 +1,10 @@ use crate::{ - GLOBAL_THREAD_TIMINGS, PlatformDispatcher, RunnableVariant, THREAD_TIMINGS, TaskLabel, - TaskTiming, ThreadTaskTimings, + GLOBAL_THREAD_TIMINGS, PlatformDispatcher, Priority, PriorityQueueReceiver, + PriorityQueueSender, RealtimePriority, RunnableVariant, THREAD_TIMINGS, TaskLabel, TaskTiming, + ThreadTaskTimings, profiler, }; use calloop::{ - EventLoop, + EventLoop, PostAction, channel::{self, Sender}, timer::TimeoutAction, }; @@ -19,9 +20,9 @@ struct TimerAfter { } pub(crate) struct LinuxDispatcher { - main_sender: Sender, + main_sender: PriorityQueueCalloopSender, timer_sender: Sender, - background_sender: flume::Sender, + background_sender: PriorityQueueSender, _background_threads: Vec>, main_thread_id: thread::ThreadId, } @@ -29,18 +30,20 @@ pub(crate) struct LinuxDispatcher { const MIN_THREADS: usize = 2; impl LinuxDispatcher { - pub fn new(main_sender: Sender) -> Self { - let (background_sender, background_receiver) = flume::unbounded::(); + pub fn new(main_sender: PriorityQueueCalloopSender) -> Self { + let (background_sender, background_receiver) = PriorityQueueReceiver::new(); let thread_count = std::thread::available_parallelism().map_or(MIN_THREADS, |i| i.get().max(MIN_THREADS)); + // These thread should really be lower prio then the foreground + // executor let mut background_threads = (0..thread_count) .map(|i| { - let receiver = background_receiver.clone(); + let mut receiver = background_receiver.clone(); std::thread::Builder::new() .name(format!("Worker-{i}")) .spawn(move || { - for runnable in receiver { + for runnable in receiver.iter() { let start = Instant::now(); let mut location = match runnable { @@ -51,7 +54,7 @@ impl LinuxDispatcher { start, end: None, }; - Self::add_task_timing(timing); + profiler::add_task_timing(timing); runnable.run(); timing @@ -63,7 +66,7 @@ impl LinuxDispatcher { start, end: None, }; - Self::add_task_timing(timing); + profiler::add_task_timing(timing); runnable.run(); timing @@ -72,7 +75,7 @@ impl LinuxDispatcher { let end = Instant::now(); location.end = Some(end); - Self::add_task_timing(location); + profiler::add_task_timing(location); log::trace!( "background thread {}: ran runnable. took: {:?}", @@ -113,7 +116,7 @@ impl LinuxDispatcher { start, end: None, }; - Self::add_task_timing(timing); + profiler::add_task_timing(timing); runnable.run(); timing @@ -124,7 +127,7 @@ impl LinuxDispatcher { start, end: None, }; - Self::add_task_timing(timing); + profiler::add_task_timing(timing); runnable.run(); timing @@ -133,7 +136,7 @@ impl LinuxDispatcher { let end = Instant::now(); timing.end = Some(end); - Self::add_task_timing(timing); + profiler::add_task_timing(timing); } TimeoutAction::Drop }, @@ -157,22 +160,6 @@ impl LinuxDispatcher { main_thread_id: thread::current().id(), } } - - pub(crate) fn add_task_timing(timing: TaskTiming) { - THREAD_TIMINGS.with(|timings| { - let mut timings = timings.lock(); - let timings = &mut timings.timings; - - if let Some(last_timing) = timings.iter_mut().rev().next() { - if last_timing.location == timing.location { - last_timing.end = timing.end; - return; - } - } - - timings.push_back(timing); - }); - } } impl PlatformDispatcher for LinuxDispatcher { @@ -199,22 +186,26 @@ impl PlatformDispatcher for LinuxDispatcher { thread::current().id() == self.main_thread_id } - fn dispatch(&self, runnable: RunnableVariant, _: Option) { - self.background_sender.send(runnable).unwrap(); + fn dispatch(&self, runnable: RunnableVariant, _: Option, priority: Priority) { + self.background_sender + .send(priority, runnable) + .unwrap_or_else(|_| panic!("blocking sender returned without value")); } - fn dispatch_on_main_thread(&self, runnable: RunnableVariant) { - self.main_sender.send(runnable).unwrap_or_else(|runnable| { - // NOTE: Runnable may wrap a Future that is !Send. - // - // This is usually safe because we only poll it on the main thread. - // However if the send fails, we know that: - // 1. main_receiver has been dropped (which implies the app is shutting down) - // 2. we are on a background thread. - // It is not safe to drop something !Send on the wrong thread, and - // the app will exit soon anyway, so we must forget the runnable. - std::mem::forget(runnable); - }); + fn dispatch_on_main_thread(&self, runnable: RunnableVariant, priority: Priority) { + self.main_sender + .send(priority, runnable) + .unwrap_or_else(|runnable| { + // NOTE: Runnable may wrap a Future that is !Send. + // + // This is usually safe because we only poll it on the main thread. + // However if the send fails, we know that: + // 1. main_receiver has been dropped (which implies the app is shutting down) + // 2. we are on a background thread. + // It is not safe to drop something !Send on the wrong thread, and + // the app will exit soon anyway, so we must forget the runnable. + std::mem::forget(runnable); + }); } fn dispatch_after(&self, duration: Duration, runnable: RunnableVariant) { @@ -222,4 +213,252 @@ impl PlatformDispatcher for LinuxDispatcher { .send(TimerAfter { duration, runnable }) .ok(); } + + fn spawn_realtime(&self, priority: RealtimePriority, f: Box) { + std::thread::spawn(move || { + // SAFETY: always safe to call + let thread_id = unsafe { libc::pthread_self() }; + + let policy = match priority { + RealtimePriority::Audio => libc::SCHED_FIFO, + RealtimePriority::Other => libc::SCHED_RR, + }; + let sched_priority = match priority { + RealtimePriority::Audio => 65, + RealtimePriority::Other => 45, + }; + + let sched_param = libc::sched_param { sched_priority }; + // SAFETY: sched_param is a valid initialized structure + let result = unsafe { libc::pthread_setschedparam(thread_id, policy, &sched_param) }; + if result != 0 { + log::warn!("failed to set realtime thread priority to {:?}", priority); + } + + f(); + }); + } +} + +pub struct PriorityQueueCalloopSender { + sender: PriorityQueueSender, + ping: calloop::ping::Ping, +} + +impl PriorityQueueCalloopSender { + fn new(tx: PriorityQueueSender, ping: calloop::ping::Ping) -> Self { + Self { sender: tx, ping } + } + + fn send(&self, priority: Priority, item: T) -> Result<(), crate::queue::SendError> { + let res = self.sender.send(priority, item); + if res.is_ok() { + self.ping.ping(); + } + res + } +} + +impl Drop for PriorityQueueCalloopSender { + fn drop(&mut self) { + self.ping.ping(); + } +} + +pub struct PriorityQueueCalloopReceiver { + receiver: PriorityQueueReceiver, + source: calloop::ping::PingSource, + ping: calloop::ping::Ping, +} + +impl PriorityQueueCalloopReceiver { + pub fn new() -> (PriorityQueueCalloopSender, Self) { + let (ping, source) = calloop::ping::make_ping().expect("Failed to create a Ping."); + + let (tx, rx) = PriorityQueueReceiver::new(); + + ( + PriorityQueueCalloopSender::new(tx, ping.clone()), + Self { + receiver: rx, + source, + ping, + }, + ) + } } + +use calloop::channel::Event; + +#[derive(Debug)] +pub struct ChannelError(calloop::ping::PingError); + +impl std::fmt::Display for ChannelError { + #[cfg_attr(feature = "nightly_coverage", coverage(off))] + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + std::fmt::Display::fmt(&self.0, f) + } +} + +impl std::error::Error for ChannelError { + #[cfg_attr(feature = "nightly_coverage", coverage(off))] + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + Some(&self.0) + } +} + +impl calloop::EventSource for PriorityQueueCalloopReceiver { + type Event = Event; + type Metadata = (); + type Ret = (); + type Error = ChannelError; + + fn process_events( + &mut self, + readiness: calloop::Readiness, + token: calloop::Token, + mut callback: F, + ) -> Result + where + F: FnMut(Self::Event, &mut Self::Metadata) -> Self::Ret, + { + let mut clear_readiness = false; + let mut disconnected = false; + + let action = self + .source + .process_events(readiness, token, |(), &mut ()| { + let mut is_empty = true; + + let mut receiver = self.receiver.clone(); + for runnable in receiver.try_iter() { + match runnable { + Ok(r) => { + callback(Event::Msg(r), &mut ()); + is_empty = false; + } + Err(_) => { + disconnected = true; + } + } + } + + if disconnected { + callback(Event::Closed, &mut ()); + } + + if is_empty { + clear_readiness = true; + } + }) + .map_err(ChannelError)?; + + if disconnected { + Ok(PostAction::Remove) + } else if clear_readiness { + Ok(action) + } else { + // Re-notify the ping source so we can try again. + self.ping.ping(); + Ok(PostAction::Continue) + } + } + + fn register( + &mut self, + poll: &mut calloop::Poll, + token_factory: &mut calloop::TokenFactory, + ) -> calloop::Result<()> { + self.source.register(poll, token_factory) + } + + fn reregister( + &mut self, + poll: &mut calloop::Poll, + token_factory: &mut calloop::TokenFactory, + ) -> calloop::Result<()> { + self.source.reregister(poll, token_factory) + } + + fn unregister(&mut self, poll: &mut calloop::Poll) -> calloop::Result<()> { + self.source.unregister(poll) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn calloop_works() { + let mut event_loop = calloop::EventLoop::try_new().unwrap(); + let handle = event_loop.handle(); + + let (tx, rx) = PriorityQueueCalloopReceiver::new(); + + struct Data { + got_msg: bool, + got_closed: bool, + } + + let mut data = Data { + got_msg: false, + got_closed: false, + }; + + let _channel_token = handle + .insert_source(rx, move |evt, &mut (), data: &mut Data| match evt { + Event::Msg(()) => { + data.got_msg = true; + } + + Event::Closed => { + data.got_closed = true; + } + }) + .unwrap(); + + // nothing is sent, nothing is received + event_loop + .dispatch(Some(::std::time::Duration::ZERO), &mut data) + .unwrap(); + + assert!(!data.got_msg); + assert!(!data.got_closed); + // a message is send + + tx.send(Priority::Medium, ()).unwrap(); + event_loop + .dispatch(Some(::std::time::Duration::ZERO), &mut data) + .unwrap(); + + assert!(data.got_msg); + assert!(!data.got_closed); + + // the sender is dropped + drop(tx); + event_loop + .dispatch(Some(::std::time::Duration::ZERO), &mut data) + .unwrap(); + + assert!(data.got_msg); + assert!(data.got_closed); + } +} + +// running 1 test +// test platform::linux::dispatcher::tests::tomato ... FAILED + +// failures: + +// ---- platform::linux::dispatcher::tests::tomato stdout ---- +// [crates/gpui/src/platform/linux/dispatcher.rs:262:9] +// returning 1 tasks to process +// [crates/gpui/src/platform/linux/dispatcher.rs:480:75] evt = Msg( +// (), +// ) +// returning 0 tasks to process + +// thread 'platform::linux::dispatcher::tests::tomato' (478301) panicked at crates/gpui/src/platform/linux/dispatcher.rs:515:9: +// assertion failed: data.got_closed +// note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/crates/gpui/src/platform/linux/platform.rs b/crates/gpui/src/platform/linux/platform.rs index 51a1d5f5849d387a3f5855c12f50fce0a95d1cf4..06a81ec342e9d528a081456583f3ba0f3fb77b6f 100644 --- a/crates/gpui/src/platform/linux/platform.rs +++ b/crates/gpui/src/platform/linux/platform.rs @@ -14,7 +14,7 @@ use std::{ }; use anyhow::{Context as _, anyhow}; -use calloop::{LoopSignal, channel::Channel}; +use calloop::LoopSignal; use futures::channel::oneshot; use util::ResultExt as _; use util::command::{new_smol_command, new_std_command}; @@ -25,8 +25,8 @@ use crate::{ Action, AnyWindowHandle, BackgroundExecutor, ClipboardItem, CursorStyle, DisplayId, ForegroundExecutor, Keymap, LinuxDispatcher, Menu, MenuItem, OwnedMenu, PathPromptOptions, Pixels, Platform, PlatformDisplay, PlatformKeyboardLayout, PlatformKeyboardMapper, - PlatformTextSystem, PlatformWindow, Point, Result, RunnableVariant, Task, WindowAppearance, - WindowParams, px, + PlatformTextSystem, PlatformWindow, Point, PriorityQueueCalloopReceiver, Result, + RunnableVariant, Task, WindowAppearance, WindowParams, px, }; #[cfg(any(feature = "wayland", feature = "x11"))] @@ -149,8 +149,8 @@ pub(crate) struct LinuxCommon { } impl LinuxCommon { - pub fn new(signal: LoopSignal) -> (Self, Channel) { - let (main_sender, main_receiver) = calloop::channel::channel::(); + pub fn new(signal: LoopSignal) -> (Self, PriorityQueueCalloopReceiver) { + let (main_sender, main_receiver) = PriorityQueueCalloopReceiver::new(); #[cfg(any(feature = "wayland", feature = "x11"))] let text_system = Arc::new(crate::CosmicTextSystem::new()); diff --git a/crates/gpui/src/platform/linux/wayland/client.rs b/crates/gpui/src/platform/linux/wayland/client.rs index 1a7011c582ab162c8ed6c7277d3dd1f5b8c60239..0e7bf8fbf8880baf5876027e6e764d7411932577 100644 --- a/crates/gpui/src/platform/linux/wayland/client.rs +++ b/crates/gpui/src/platform/linux/wayland/client.rs @@ -77,10 +77,10 @@ use crate::{ LinuxKeyboardLayout, Modifiers, ModifiersChangedEvent, MouseButton, MouseDownEvent, MouseExitEvent, MouseMoveEvent, MouseUpEvent, NavigationDirection, Pixels, PlatformDisplay, PlatformInput, PlatformKeyboardLayout, Point, ResultExt as _, SCROLL_LINES, ScrollDelta, - ScrollWheelEvent, Size, TouchPhase, WindowParams, point, px, size, + ScrollWheelEvent, Size, TouchPhase, WindowParams, point, profiler, px, size, }; use crate::{ - LinuxDispatcher, RunnableVariant, TaskTiming, + RunnableVariant, TaskTiming, platform::{PlatformWindow, blade::BladeContext}, }; use crate::{ @@ -503,7 +503,7 @@ impl WaylandClient { start, end: None, }; - LinuxDispatcher::add_task_timing(timing); + profiler::add_task_timing(timing); runnable.run(); timing @@ -515,7 +515,7 @@ impl WaylandClient { start, end: None, }; - LinuxDispatcher::add_task_timing(timing); + profiler::add_task_timing(timing); runnable.run(); timing @@ -524,7 +524,7 @@ impl WaylandClient { let end = Instant::now(); timing.end = Some(end); - LinuxDispatcher::add_task_timing(timing); + profiler::add_task_timing(timing); }); } } diff --git a/crates/gpui/src/platform/linux/x11/client.rs b/crates/gpui/src/platform/linux/x11/client.rs index aa16dc7ad1d9030665ace646ba2ac295df8c27b3..60400dada57775a295fdb36c7f1ddd9dd8b83a67 100644 --- a/crates/gpui/src/platform/linux/x11/client.rs +++ b/crates/gpui/src/platform/linux/x11/client.rs @@ -1,4 +1,4 @@ -use crate::{Capslock, LinuxDispatcher, ResultExt as _, RunnableVariant, TaskTiming, xcb_flush}; +use crate::{Capslock, ResultExt as _, RunnableVariant, TaskTiming, profiler, xcb_flush}; use anyhow::{Context as _, anyhow}; use ashpd::WindowIdentifier; use calloop::{ @@ -322,7 +322,7 @@ impl X11Client { start, end: None, }; - LinuxDispatcher::add_task_timing(timing); + profiler::add_task_timing(timing); runnable.run(); timing @@ -334,7 +334,7 @@ impl X11Client { start, end: None, }; - LinuxDispatcher::add_task_timing(timing); + profiler::add_task_timing(timing); runnable.run(); timing @@ -343,7 +343,7 @@ impl X11Client { let end = Instant::now(); timing.end = Some(end); - LinuxDispatcher::add_task_timing(timing); + profiler::add_task_timing(timing); }); } } diff --git a/crates/gpui/src/platform/mac/dispatcher.rs b/crates/gpui/src/platform/mac/dispatcher.rs index 8a2f42234eea960669cb212853c437ec680a7fd7..1dfea82d58cbf2387571cabdcd7fbcfcf785c735 100644 --- a/crates/gpui/src/platform/mac/dispatcher.rs +++ b/crates/gpui/src/platform/mac/dispatcher.rs @@ -3,11 +3,22 @@ #![allow(non_snake_case)] use crate::{ - GLOBAL_THREAD_TIMINGS, PlatformDispatcher, RunnableMeta, RunnableVariant, THREAD_TIMINGS, - TaskLabel, TaskTiming, ThreadTaskTimings, + GLOBAL_THREAD_TIMINGS, PlatformDispatcher, Priority, RealtimePriority, RunnableMeta, + RunnableVariant, THREAD_TIMINGS, TaskLabel, TaskTiming, ThreadTaskTimings, }; +use anyhow::Context; use async_task::Runnable; +use mach2::{ + kern_return::KERN_SUCCESS, + mach_time::mach_timebase_info_data_t, + thread_policy::{ + THREAD_EXTENDED_POLICY, THREAD_EXTENDED_POLICY_COUNT, THREAD_PRECEDENCE_POLICY, + THREAD_PRECEDENCE_POLICY_COUNT, THREAD_TIME_CONSTRAINT_POLICY, + THREAD_TIME_CONSTRAINT_POLICY_COUNT, thread_extended_policy_data_t, + thread_precedence_policy_data_t, thread_time_constraint_policy_data_t, + }, +}; use objc::{ class, msg_send, runtime::{BOOL, YES}, @@ -15,9 +26,11 @@ use objc::{ }; use std::{ ffi::c_void, + mem::MaybeUninit, ptr::{NonNull, addr_of}, time::{Duration, Instant}, }; +use util::ResultExt; /// All items in the generated file are marked as pub, so we're gonna wrap it in a separate mod to prevent /// these pub items from leaking into public API. @@ -56,7 +69,7 @@ impl PlatformDispatcher for MacDispatcher { is_main_thread == YES } - fn dispatch(&self, runnable: RunnableVariant, _: Option) { + fn dispatch(&self, runnable: RunnableVariant, _: Option, priority: Priority) { let (context, trampoline) = match runnable { RunnableVariant::Meta(runnable) => ( runnable.into_raw().as_ptr() as *mut c_void, @@ -67,16 +80,24 @@ impl PlatformDispatcher for MacDispatcher { Some(trampoline_compat as unsafe extern "C" fn(*mut c_void)), ), }; + + let queue_priority = match priority { + Priority::Realtime(_) => unreachable!(), + Priority::High => DISPATCH_QUEUE_PRIORITY_HIGH as isize, + Priority::Medium => DISPATCH_QUEUE_PRIORITY_DEFAULT as isize, + Priority::Low => DISPATCH_QUEUE_PRIORITY_LOW as isize, + }; + unsafe { dispatch_async_f( - dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH.try_into().unwrap(), 0), + dispatch_get_global_queue(queue_priority, 0), context, trampoline, ); } } - fn dispatch_on_main_thread(&self, runnable: RunnableVariant) { + fn dispatch_on_main_thread(&self, runnable: RunnableVariant, _priority: Priority) { let (context, trampoline) = match runnable { RunnableVariant::Meta(runnable) => ( runnable.into_raw().as_ptr() as *mut c_void, @@ -110,6 +131,120 @@ impl PlatformDispatcher for MacDispatcher { dispatch_after_f(when, queue, context, trampoline); } } + + fn spawn_realtime(&self, priority: RealtimePriority, f: Box) { + std::thread::spawn(move || { + match priority { + RealtimePriority::Audio => set_audio_thread_priority(), + RealtimePriority::Other => set_high_thread_priority(), + } + .context(format!("for priority {:?}", priority)) + .log_err(); + + f(); + }); + } +} + +fn set_high_thread_priority() -> anyhow::Result<()> { + // SAFETY: always safe to call + let thread_id = unsafe { libc::pthread_self() }; + + // SAFETY: all sched_param members are valid when initialized to zero. + let mut sched_param = unsafe { MaybeUninit::::zeroed().assume_init() }; + sched_param.sched_priority = 45; + + let result = unsafe { libc::pthread_setschedparam(thread_id, libc::SCHED_FIFO, &sched_param) }; + if result != 0 { + anyhow::bail!("failed to set realtime thread priority") + } + + Ok(()) +} + +fn set_audio_thread_priority() -> anyhow::Result<()> { + // https://chromium.googlesource.com/chromium/chromium/+/master/base/threading/platform_thread_mac.mm#93 + + // SAFETY: always safe to call + let thread_id = unsafe { libc::pthread_self() }; + + // SAFETY: thread_id is a valid thread id + let thread_id = unsafe { libc::pthread_mach_thread_np(thread_id) }; + + // Fixed priority thread + let mut policy = thread_extended_policy_data_t { timeshare: 0 }; + + // SAFETY: thread_id is a valid thread id + // SAFETY: thread_extended_policy_data_t is passed as THREAD_EXTENDED_POLICY + let result = unsafe { + mach2::thread_policy::thread_policy_set( + thread_id, + THREAD_EXTENDED_POLICY, + &mut policy as *mut _ as *mut _, + THREAD_EXTENDED_POLICY_COUNT, + ) + }; + + if result != KERN_SUCCESS { + anyhow::bail!("failed to set thread extended policy"); + } + + // relatively high priority + let mut precedence = thread_precedence_policy_data_t { importance: 63 }; + + // SAFETY: thread_id is a valid thread id + // SAFETY: thread_precedence_policy_data_t is passed as THREAD_PRECEDENCE_POLICY + let result = unsafe { + mach2::thread_policy::thread_policy_set( + thread_id, + THREAD_PRECEDENCE_POLICY, + &mut precedence as *mut _ as *mut _, + THREAD_PRECEDENCE_POLICY_COUNT, + ) + }; + + if result != KERN_SUCCESS { + anyhow::bail!("failed to set thread precedence policy"); + } + + const GUARANTEED_AUDIO_DUTY_CYCLE: f32 = 0.75; + const MAX_AUDIO_DUTY_CYCLE: f32 = 0.85; + + // ~128 frames @ 44.1KHz + const TIME_QUANTUM: f32 = 2.9; + + const AUDIO_TIME_NEEDED: f32 = GUARANTEED_AUDIO_DUTY_CYCLE * TIME_QUANTUM; + const MAX_TIME_ALLOWED: f32 = MAX_AUDIO_DUTY_CYCLE * TIME_QUANTUM; + + let mut timebase_info = mach_timebase_info_data_t { numer: 0, denom: 0 }; + // SAFETY: timebase_info is a valid pointer to a mach_timebase_info_data_t struct + unsafe { mach2::mach_time::mach_timebase_info(&mut timebase_info) }; + + let ms_to_abs_time = ((timebase_info.denom as f32) / (timebase_info.numer as f32)) * 1000000f32; + + let mut time_constraints = thread_time_constraint_policy_data_t { + period: (TIME_QUANTUM * ms_to_abs_time) as u32, + computation: (AUDIO_TIME_NEEDED * ms_to_abs_time) as u32, + constraint: (MAX_TIME_ALLOWED * ms_to_abs_time) as u32, + preemptible: 0, + }; + + // SAFETY: thread_id is a valid thread id + // SAFETY: thread_precedence_pthread_time_constraint_policy_data_t is passed as THREAD_TIME_CONSTRAINT_POLICY + let result = unsafe { + mach2::thread_policy::thread_policy_set( + thread_id, + THREAD_TIME_CONSTRAINT_POLICY, + &mut time_constraints as *mut _ as *mut _, + THREAD_TIME_CONSTRAINT_POLICY_COUNT, + ) + }; + + if result != KERN_SUCCESS { + anyhow::bail!("failed to set thread time constraint policy"); + } + + Ok(()) } extern "C" fn trampoline(runnable: *mut c_void) { diff --git a/crates/gpui/src/platform/test/dispatcher.rs b/crates/gpui/src/platform/test/dispatcher.rs index 538aacda83a095449193db6aab63f3a06189ef7a..c271430586106abc93e0bb3258c9e25a06b12383 100644 --- a/crates/gpui/src/platform/test/dispatcher.rs +++ b/crates/gpui/src/platform/test/dispatcher.rs @@ -1,4 +1,4 @@ -use crate::{PlatformDispatcher, RunnableVariant, TaskLabel}; +use crate::{PlatformDispatcher, Priority, RunnableVariant, TaskLabel}; use backtrace::Backtrace; use collections::{HashMap, HashSet, VecDeque}; use parking::Unparker; @@ -284,7 +284,7 @@ impl PlatformDispatcher for TestDispatcher { state.start_time + state.time } - fn dispatch(&self, runnable: RunnableVariant, label: Option) { + fn dispatch(&self, runnable: RunnableVariant, label: Option, _priority: Priority) { { let mut state = self.state.lock(); if label.is_some_and(|label| state.deprioritized_task_labels.contains(&label)) { @@ -296,7 +296,7 @@ impl PlatformDispatcher for TestDispatcher { self.unpark_all(); } - fn dispatch_on_main_thread(&self, runnable: RunnableVariant) { + fn dispatch_on_main_thread(&self, runnable: RunnableVariant, _priority: Priority) { self.state .lock() .foreground @@ -318,4 +318,10 @@ impl PlatformDispatcher for TestDispatcher { fn as_test(&self) -> Option<&TestDispatcher> { Some(self) } + + fn spawn_realtime(&self, _priority: crate::RealtimePriority, f: Box) { + std::thread::spawn(move || { + f(); + }); + } } diff --git a/crates/gpui/src/platform/windows/dispatcher.rs b/crates/gpui/src/platform/windows/dispatcher.rs index 6214e60e5b4b178c20b1fff655f4ac8b49be3f4c..0720d414c9b44dec4a3bab5b50fd7dde47991989 100644 --- a/crates/gpui/src/platform/windows/dispatcher.rs +++ b/crates/gpui/src/platform/windows/dispatcher.rs @@ -4,24 +4,31 @@ use std::{ time::{Duration, Instant}, }; -use flume::Sender; +use anyhow::Context; use util::ResultExt; use windows::{ - System::Threading::{ThreadPool, ThreadPoolTimer, TimerElapsedHandler, WorkItemHandler}, + System::Threading::{ + ThreadPool, ThreadPoolTimer, TimerElapsedHandler, WorkItemHandler, WorkItemPriority, + }, Win32::{ Foundation::{LPARAM, WPARAM}, + System::Threading::{ + GetCurrentThread, HIGH_PRIORITY_CLASS, SetPriorityClass, SetThreadPriority, + THREAD_PRIORITY_HIGHEST, THREAD_PRIORITY_TIME_CRITICAL, + }, UI::WindowsAndMessaging::PostMessageW, }, }; use crate::{ - GLOBAL_THREAD_TIMINGS, HWND, PlatformDispatcher, RunnableVariant, SafeHwnd, THREAD_TIMINGS, - TaskLabel, TaskTiming, ThreadTaskTimings, WM_GPUI_TASK_DISPATCHED_ON_MAIN_THREAD, + GLOBAL_THREAD_TIMINGS, HWND, PlatformDispatcher, Priority, PriorityQueueSender, + RealtimePriority, RunnableVariant, SafeHwnd, THREAD_TIMINGS, TaskLabel, TaskTiming, + ThreadTaskTimings, WM_GPUI_TASK_DISPATCHED_ON_MAIN_THREAD, profiler, }; pub(crate) struct WindowsDispatcher { pub(crate) wake_posted: AtomicBool, - main_sender: Sender, + main_sender: PriorityQueueSender, main_thread_id: ThreadId, pub(crate) platform_window_handle: SafeHwnd, validation_number: usize, @@ -29,7 +36,7 @@ pub(crate) struct WindowsDispatcher { impl WindowsDispatcher { pub(crate) fn new( - main_sender: Sender, + main_sender: PriorityQueueSender, platform_window_handle: HWND, validation_number: usize, ) -> Self { @@ -45,7 +52,7 @@ impl WindowsDispatcher { } } - fn dispatch_on_threadpool(&self, runnable: RunnableVariant) { + fn dispatch_on_threadpool(&self, priority: WorkItemPriority, runnable: RunnableVariant) { let handler = { let mut task_wrapper = Some(runnable); WorkItemHandler::new(move |_| { @@ -53,7 +60,8 @@ impl WindowsDispatcher { Ok(()) }) }; - ThreadPool::RunAsync(&handler).log_err(); + + ThreadPool::RunWithPriorityAsync(&handler, priority).log_err(); } fn dispatch_on_threadpool_after(&self, runnable: RunnableVariant, duration: Duration) { @@ -79,7 +87,7 @@ impl WindowsDispatcher { start, end: None, }; - Self::add_task_timing(timing); + profiler::add_task_timing(timing); runnable.run(); @@ -91,7 +99,7 @@ impl WindowsDispatcher { start, end: None, }; - Self::add_task_timing(timing); + profiler::add_task_timing(timing); runnable.run(); @@ -102,23 +110,7 @@ impl WindowsDispatcher { let end = Instant::now(); timing.end = Some(end); - Self::add_task_timing(timing); - } - - pub(crate) fn add_task_timing(timing: TaskTiming) { - THREAD_TIMINGS.with(|timings| { - let mut timings = timings.lock(); - let timings = &mut timings.timings; - - if let Some(last_timing) = timings.iter_mut().rev().next() { - if last_timing.location == timing.location { - last_timing.end = timing.end; - return; - } - } - - timings.push_back(timing); - }); + profiler::add_task_timing(timing); } } @@ -146,15 +138,22 @@ impl PlatformDispatcher for WindowsDispatcher { current().id() == self.main_thread_id } - fn dispatch(&self, runnable: RunnableVariant, label: Option) { - self.dispatch_on_threadpool(runnable); + fn dispatch(&self, runnable: RunnableVariant, label: Option, priority: Priority) { + let priority = match priority { + Priority::Realtime(_) => unreachable!(), + Priority::High => WorkItemPriority::High, + Priority::Medium => WorkItemPriority::Normal, + Priority::Low => WorkItemPriority::Low, + }; + self.dispatch_on_threadpool(priority, runnable); + if let Some(label) = label { log::debug!("TaskLabel: {label:?}"); } } - fn dispatch_on_main_thread(&self, runnable: RunnableVariant) { - match self.main_sender.send(runnable) { + fn dispatch_on_main_thread(&self, runnable: RunnableVariant, priority: Priority) { + match self.main_sender.send(priority, runnable) { Ok(_) => { if !self.wake_posted.swap(true, Ordering::AcqRel) { unsafe { @@ -185,4 +184,28 @@ impl PlatformDispatcher for WindowsDispatcher { fn dispatch_after(&self, duration: Duration, runnable: RunnableVariant) { self.dispatch_on_threadpool_after(runnable, duration); } + + fn spawn_realtime(&self, priority: RealtimePriority, f: Box) { + std::thread::spawn(move || { + // SAFETY: always safe to call + let thread_handle = unsafe { GetCurrentThread() }; + + let thread_priority = match priority { + RealtimePriority::Audio => THREAD_PRIORITY_TIME_CRITICAL, + RealtimePriority::Other => THREAD_PRIORITY_HIGHEST, + }; + + // SAFETY: thread_handle is a valid handle to a thread + unsafe { SetPriorityClass(thread_handle, HIGH_PRIORITY_CLASS) } + .context("thread priority class") + .log_err(); + + // SAFETY: thread_handle is a valid handle to a thread + unsafe { SetThreadPriority(thread_handle, thread_priority) } + .context("thread priority") + .log_err(); + + f(); + }); + } } diff --git a/crates/gpui/src/platform/windows/events.rs b/crates/gpui/src/platform/windows/events.rs index e6fa6006eb95ec45f1634cb72ef63e2f622455a7..f648f45cf4bf632ae07784de8bdc1503f88d6177 100644 --- a/crates/gpui/src/platform/windows/events.rs +++ b/crates/gpui/src/platform/windows/events.rs @@ -243,7 +243,8 @@ impl WindowsWindowInner { fn handle_timer_msg(&self, handle: HWND, wparam: WPARAM) -> Option { if wparam.0 == SIZE_MOVE_LOOP_TIMER_ID { - for runnable in self.main_receiver.drain() { + let mut runnables = self.main_receiver.clone().try_iter(); + while let Some(Ok(runnable)) = runnables.next() { WindowsDispatcher::execute_runnable(runnable); } self.handle_paint_msg(handle) diff --git a/crates/gpui/src/platform/windows/platform.rs b/crates/gpui/src/platform/windows/platform.rs index af0cb89ecc94da70cc42c8d4c397aeb2a811d6fb..fa847bca6b404538a9f75b757bf53a2e4e2a1418 100644 --- a/crates/gpui/src/platform/windows/platform.rs +++ b/crates/gpui/src/platform/windows/platform.rs @@ -51,7 +51,7 @@ struct WindowsPlatformInner { raw_window_handles: std::sync::Weak>>, // The below members will never change throughout the entire lifecycle of the app. validation_number: usize, - main_receiver: flume::Receiver, + main_receiver: PriorityQueueReceiver, dispatcher: Arc, } @@ -98,7 +98,7 @@ impl WindowsPlatform { OleInitialize(None).context("unable to initialize Windows OLE")?; } let directx_devices = DirectXDevices::new().context("Creating DirectX devices")?; - let (main_sender, main_receiver) = flume::unbounded::(); + let (main_sender, main_receiver) = PriorityQueueReceiver::new(); let validation_number = if usize::BITS == 64 { rand::random::() as usize } else { @@ -857,22 +857,24 @@ impl WindowsPlatformInner { } break 'tasks; } - match self.main_receiver.try_recv() { - Err(_) => break 'timeout_loop, - Ok(runnable) => WindowsDispatcher::execute_runnable(runnable), + let mut main_receiver = self.main_receiver.clone(); + match main_receiver.try_pop() { + Ok(Some(runnable)) => WindowsDispatcher::execute_runnable(runnable), + _ => break 'timeout_loop, } } // Someone could enqueue a Runnable here. The flag is still true, so they will not PostMessage. // We need to check for those Runnables after we clear the flag. self.dispatcher.wake_posted.store(false, Ordering::Release); - match self.main_receiver.try_recv() { - Err(_) => break 'tasks, - Ok(runnable) => { + let mut main_receiver = self.main_receiver.clone(); + match main_receiver.try_pop() { + Ok(Some(runnable)) => { self.dispatcher.wake_posted.store(true, Ordering::Release); WindowsDispatcher::execute_runnable(runnable); } + _ => break 'tasks, } } @@ -934,7 +936,7 @@ pub(crate) struct WindowCreationInfo { pub(crate) windows_version: WindowsVersion, pub(crate) drop_target_helper: IDropTargetHelper, pub(crate) validation_number: usize, - pub(crate) main_receiver: flume::Receiver, + pub(crate) main_receiver: PriorityQueueReceiver, pub(crate) platform_window_handle: HWND, pub(crate) disable_direct_composition: bool, pub(crate) directx_devices: DirectXDevices, @@ -947,8 +949,8 @@ struct PlatformWindowCreateContext { inner: Option>>, raw_window_handles: std::sync::Weak>>, validation_number: usize, - main_sender: Option>, - main_receiver: Option>, + main_sender: Option>, + main_receiver: Option>, directx_devices: Option, dispatcher: Option>, } diff --git a/crates/gpui/src/platform/windows/window.rs b/crates/gpui/src/platform/windows/window.rs index 7ef92b4150e69424b68e9417dda377aa7f2e9cc0..0cfa812b288406c5b4afcea37949eed3918f5c91 100644 --- a/crates/gpui/src/platform/windows/window.rs +++ b/crates/gpui/src/platform/windows/window.rs @@ -81,7 +81,7 @@ pub(crate) struct WindowsWindowInner { pub(crate) executor: ForegroundExecutor, pub(crate) windows_version: WindowsVersion, pub(crate) validation_number: usize, - pub(crate) main_receiver: flume::Receiver, + pub(crate) main_receiver: PriorityQueueReceiver, pub(crate) platform_window_handle: HWND, } @@ -362,7 +362,7 @@ struct WindowCreateContext { windows_version: WindowsVersion, drop_target_helper: IDropTargetHelper, validation_number: usize, - main_receiver: flume::Receiver, + main_receiver: PriorityQueueReceiver, platform_window_handle: HWND, appearance: WindowAppearance, disable_direct_composition: bool, diff --git a/crates/gpui/src/profiler.rs b/crates/gpui/src/profiler.rs index 4e3f00c412cd19c8269497ff292ce9dbdd785fbe..73f435d7e798c78d6c7320a49da804ebe703c434 100644 --- a/crates/gpui/src/profiler.rs +++ b/crates/gpui/src/profiler.rs @@ -216,3 +216,19 @@ impl Drop for ThreadTimings { thread_timings.swap_remove(index); } } + +pub(crate) fn add_task_timing(timing: TaskTiming) { + THREAD_TIMINGS.with(|timings| { + let mut timings = timings.lock(); + let timings = &mut timings.timings; + + if let Some(last_timing) = timings.iter_mut().rev().next() { + if last_timing.location == timing.location { + last_timing.end = timing.end; + return; + } + } + + timings.push_back(timing); + }); +} diff --git a/crates/gpui/src/queue.rs b/crates/gpui/src/queue.rs new file mode 100644 index 0000000000000000000000000000000000000000..3a4ef912ffd5fb85b80384454f7afd84cecb1648 --- /dev/null +++ b/crates/gpui/src/queue.rs @@ -0,0 +1,329 @@ +use std::{ + fmt, + iter::FusedIterator, + sync::{Arc, atomic::AtomicUsize}, +}; + +use rand::{Rng, SeedableRng, rngs::SmallRng}; + +use crate::Priority; + +struct PriorityQueues { + high_priority: Vec, + medium_priority: Vec, + low_priority: Vec, +} + +impl PriorityQueues { + fn is_empty(&self) -> bool { + self.high_priority.is_empty() + && self.medium_priority.is_empty() + && self.low_priority.is_empty() + } +} + +struct PriorityQueueState { + queues: parking_lot::Mutex>, + condvar: parking_lot::Condvar, + receiver_count: AtomicUsize, + sender_count: AtomicUsize, +} + +impl PriorityQueueState { + fn send(&self, priority: Priority, item: T) -> Result<(), SendError> { + if self + .receiver_count + .load(std::sync::atomic::Ordering::Relaxed) + == 0 + { + return Err(SendError(item)); + } + + let mut queues = self.queues.lock(); + match priority { + Priority::Realtime(_) => unreachable!(), + Priority::High => queues.high_priority.push(item), + Priority::Medium => queues.medium_priority.push(item), + Priority::Low => queues.low_priority.push(item), + }; + self.condvar.notify_one(); + Ok(()) + } + + fn recv<'a>(&'a self) -> Result>, RecvError> { + let mut queues = self.queues.lock(); + + let sender_count = self.sender_count.load(std::sync::atomic::Ordering::Relaxed); + if queues.is_empty() && sender_count == 0 { + return Err(crate::queue::RecvError); + } + + // parking_lot doesn't do spurious wakeups so an if is fine + if queues.is_empty() { + self.condvar.wait(&mut queues); + } + + Ok(queues) + } + + fn try_recv<'a>( + &'a self, + ) -> Result>>, RecvError> { + let mut queues = self.queues.lock(); + + let sender_count = self.sender_count.load(std::sync::atomic::Ordering::Relaxed); + if queues.is_empty() && sender_count == 0 { + return Err(crate::queue::RecvError); + } + + if queues.is_empty() { + Ok(None) + } else { + Ok(Some(queues)) + } + } +} + +pub(crate) struct PriorityQueueSender { + state: Arc>, +} + +impl PriorityQueueSender { + fn new(state: Arc>) -> Self { + Self { state } + } + + pub(crate) fn send(&self, priority: Priority, item: T) -> Result<(), SendError> { + self.state.send(priority, item)?; + Ok(()) + } +} + +impl Drop for PriorityQueueSender { + fn drop(&mut self) { + self.state + .sender_count + .fetch_sub(1, std::sync::atomic::Ordering::AcqRel); + } +} + +pub(crate) struct PriorityQueueReceiver { + state: Arc>, + rand: SmallRng, + disconnected: bool, +} + +impl Clone for PriorityQueueReceiver { + fn clone(&self) -> Self { + self.state + .receiver_count + .fetch_add(1, std::sync::atomic::Ordering::AcqRel); + Self { + state: Arc::clone(&self.state), + rand: SmallRng::seed_from_u64(0), + disconnected: self.disconnected, + } + } +} + +pub(crate) struct SendError(T); + +impl fmt::Debug for SendError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_tuple("SendError").field(&self.0).finish() + } +} + +#[derive(Debug)] +pub(crate) struct RecvError; + +#[allow(dead_code)] +impl PriorityQueueReceiver { + pub(crate) fn new() -> (PriorityQueueSender, Self) { + let state = PriorityQueueState { + queues: parking_lot::Mutex::new(PriorityQueues { + high_priority: Vec::new(), + medium_priority: Vec::new(), + low_priority: Vec::new(), + }), + condvar: parking_lot::Condvar::new(), + receiver_count: AtomicUsize::new(1), + sender_count: AtomicUsize::new(1), + }; + let state = Arc::new(state); + + let sender = PriorityQueueSender::new(Arc::clone(&state)); + + let receiver = PriorityQueueReceiver { + state, + rand: SmallRng::seed_from_u64(0), + disconnected: false, + }; + + (sender, receiver) + } + + /// Tries to pop one element from the priority queue without blocking. + /// + /// This will early return if there are no elements in the queue. + /// + /// This method is best suited if you only intend to pop one element, for better performance + /// on large queues see [`Self::try_iter`] + /// + /// # Errors + /// + /// If the sender was dropped + pub(crate) fn try_pop(&mut self) -> Result, RecvError> { + self.pop_inner(false) + } + + /// Pops an element from the priority queue blocking if necessary. + /// + /// This method is best suited if you only intend to pop one element, for better performance + /// on large queues see [`Self::iter``] + /// + /// # Errors + /// + /// If the sender was dropped + pub(crate) fn pop(&mut self) -> Result { + self.pop_inner(true).map(|e| e.unwrap()) + } + + /// Returns an iterator over the elements of the queue + /// this iterator will end when all elements have been consumed and will not wait for new ones. + pub(crate) fn try_iter(self) -> TryIter { + TryIter { + receiver: self, + ended: false, + } + } + + /// Returns an iterator over the elements of the queue + /// this iterator will wait for new elements if the queue is empty. + pub(crate) fn iter(self) -> Iter { + Iter(self) + } + + #[inline(always)] + // algorithm is the loaded die from biased coin from + // https://www.keithschwarz.com/darts-dice-coins/ + fn pop_inner(&mut self, block: bool) -> Result, RecvError> { + use Priority as P; + + let mut queues = if !block { + let Some(queues) = self.state.try_recv()? else { + return Ok(None); + }; + queues + } else { + self.state.recv()? + }; + + let high = P::High.probability() * !queues.high_priority.is_empty() as u32; + let medium = P::Medium.probability() * !queues.medium_priority.is_empty() as u32; + let low = P::Low.probability() * !queues.low_priority.is_empty() as u32; + let mut mass = high + medium + low; //% + + if !queues.high_priority.is_empty() { + let flip = self.rand.random_ratio(P::High.probability(), mass); + if flip { + return Ok(queues.high_priority.pop()); + } + mass -= P::High.probability(); + } + + if !queues.medium_priority.is_empty() { + let flip = self.rand.random_ratio(P::Medium.probability(), mass); + if flip { + return Ok(queues.medium_priority.pop()); + } + mass -= P::Medium.probability(); + } + + if !queues.low_priority.is_empty() { + let flip = self.rand.random_ratio(P::Low.probability(), mass); + if flip { + return Ok(queues.low_priority.pop()); + } + } + + Ok(None) + } +} + +impl Drop for PriorityQueueReceiver { + fn drop(&mut self) { + self.state + .receiver_count + .fetch_sub(1, std::sync::atomic::Ordering::AcqRel); + } +} + +/// If None is returned the sender disconnected +pub(crate) struct Iter(PriorityQueueReceiver); +impl Iterator for Iter { + type Item = T; + + fn next(&mut self) -> Option { + self.0.pop_inner(true).ok().flatten() + } +} +impl FusedIterator for Iter {} + +/// If None is returned there are no more elements in the queue +pub(crate) struct TryIter { + receiver: PriorityQueueReceiver, + ended: bool, +} +impl Iterator for TryIter { + type Item = Result; + + fn next(&mut self) -> Option { + if self.ended { + return None; + } + + let res = self.receiver.pop_inner(false); + self.ended = res.is_err(); + + res.transpose() + } +} +impl FusedIterator for TryIter {} + +#[cfg(test)] +mod tests { + use collections::HashSet; + + use super::*; + + #[test] + fn all_tasks_get_yielded() { + let (tx, mut rx) = PriorityQueueReceiver::new(); + tx.send(Priority::Medium, 20).unwrap(); + tx.send(Priority::High, 30).unwrap(); + tx.send(Priority::Low, 10).unwrap(); + tx.send(Priority::Medium, 21).unwrap(); + tx.send(Priority::High, 31).unwrap(); + + drop(tx); + + assert_eq!( + rx.iter().collect::>(), + [30, 31, 20, 21, 10].into_iter().collect::>() + ) + } + + #[test] + fn new_high_prio_task_get_scheduled_quickly() { + let (tx, mut rx) = PriorityQueueReceiver::new(); + for _ in 0..100 { + tx.send(Priority::Low, 1).unwrap(); + } + + assert_eq!(rx.pop().unwrap(), 1); + tx.send(Priority::High, 3).unwrap(); + assert_eq!(rx.pop().unwrap(), 3); + assert_eq!(rx.pop().unwrap(), 1); + } +} diff --git a/crates/gpui/src/window.rs b/crates/gpui/src/window.rs index 1006b49c98d9d6c442c1406a6af6b0a7040e0b43..54fe99c2634f5afa2e1f1e224e969c21d4c38e34 100644 --- a/crates/gpui/src/window.rs +++ b/crates/gpui/src/window.rs @@ -9,14 +9,15 @@ use crate::{ KeyBinding, KeyContext, KeyDownEvent, KeyEvent, Keystroke, KeystrokeEvent, LayoutId, LineLayoutIndex, Modifiers, ModifiersChangedEvent, MonochromeSprite, MouseButton, MouseEvent, MouseMoveEvent, MouseUpEvent, Path, Pixels, PlatformAtlas, PlatformDisplay, PlatformInput, - PlatformInputHandler, PlatformWindow, Point, PolychromeSprite, PromptButton, PromptLevel, Quad, - Render, RenderGlyphParams, RenderImage, RenderImageParams, RenderSvgParams, Replay, ResizeEdge, - SMOOTH_SVG_SCALE_FACTOR, SUBPIXEL_VARIANTS_X, SUBPIXEL_VARIANTS_Y, ScaledPixels, Scene, Shadow, - SharedString, Size, StrikethroughStyle, Style, SubscriberSet, Subscription, SystemWindowTab, - SystemWindowTabController, TabStopMap, TaffyLayoutEngine, Task, TextStyle, TextStyleRefinement, - TransformationMatrix, Underline, UnderlineStyle, WindowAppearance, WindowBackgroundAppearance, - WindowBounds, WindowControls, WindowDecorations, WindowOptions, WindowParams, WindowTextSystem, - point, prelude::*, px, rems, size, transparent_black, + PlatformInputHandler, PlatformWindow, Point, PolychromeSprite, Priority, PromptButton, + PromptLevel, Quad, Render, RenderGlyphParams, RenderImage, RenderImageParams, RenderSvgParams, + Replay, ResizeEdge, SMOOTH_SVG_SCALE_FACTOR, SUBPIXEL_VARIANTS_X, SUBPIXEL_VARIANTS_Y, + ScaledPixels, Scene, Shadow, SharedString, Size, StrikethroughStyle, Style, SubscriberSet, + Subscription, SystemWindowTab, SystemWindowTabController, TabStopMap, TaffyLayoutEngine, Task, + TextStyle, TextStyleRefinement, TransformationMatrix, Underline, UnderlineStyle, + WindowAppearance, WindowBackgroundAppearance, WindowBounds, WindowControls, WindowDecorations, + WindowOptions, WindowParams, WindowTextSystem, point, prelude::*, px, rems, size, + transparent_black, }; use anyhow::{Context as _, Result, anyhow}; use collections::{FxHashMap, FxHashSet}; @@ -1725,6 +1726,27 @@ impl Window { }) } + /// Spawn the future returned by the given closure on the application thread + /// pool, with the given priority. The closure is provided a handle to the + /// current window and an `AsyncWindowContext` for use within your future. + #[track_caller] + pub fn spawn_with_priority( + &self, + priority: Priority, + cx: &App, + f: AsyncFn, + ) -> Task + where + R: 'static, + AsyncFn: AsyncFnOnce(&mut AsyncWindowContext) -> R + 'static, + { + let handle = self.handle; + cx.spawn_with_priority(priority, async move |app| { + let mut async_window_cx = AsyncWindowContext::new_context(app.clone(), handle); + f(&mut async_window_cx).await + }) + } + fn bounds_changed(&mut self, cx: &mut App) { self.scale_factor = self.platform_window.scale_factor(); self.viewport_size = self.platform_window.content_size(); diff --git a/crates/repl/src/repl.rs b/crates/repl/src/repl.rs index db21e198cc726df306bd94503615aa8633e0cbd6..346cca0211e43d6f254cb8300f8b0dae546b6004 100644 --- a/crates/repl/src/repl.rs +++ b/crates/repl/src/repl.rs @@ -12,7 +12,7 @@ mod session; use std::{sync::Arc, time::Duration}; use async_dispatcher::{Dispatcher, Runnable, set_dispatcher}; -use gpui::{App, PlatformDispatcher, RunnableVariant}; +use gpui::{App, PlatformDispatcher, Priority, RunnableVariant}; use project::Fs; pub use runtimelib::ExecutionState; @@ -46,7 +46,7 @@ fn zed_dispatcher(cx: &mut App) -> impl Dispatcher { impl Dispatcher for ZedDispatcher { fn dispatch(&self, runnable: Runnable) { self.dispatcher - .dispatch(RunnableVariant::Compat(runnable), None); + .dispatch(RunnableVariant::Compat(runnable), None, Priority::default()); } fn dispatch_after(&self, duration: Duration, runnable: Runnable) { diff --git a/crates/worktree/src/worktree.rs b/crates/worktree/src/worktree.rs index d6e75e20fc425235f9ad22e85cb79f1585aac7d1..e1ce31c038de9136109c3c8566e5e497dfa4f239 100644 --- a/crates/worktree/src/worktree.rs +++ b/crates/worktree/src/worktree.rs @@ -22,7 +22,8 @@ use git::{ COMMIT_MESSAGE, DOT_GIT, FSMONITOR_DAEMON, GITIGNORE, INDEX_LOCK, LFS_DIR, status::GitSummary, }; use gpui::{ - App, AppContext as _, AsyncApp, BackgroundExecutor, Context, Entity, EventEmitter, Task, + App, AppContext as _, AsyncApp, BackgroundExecutor, Context, Entity, EventEmitter, Priority, + Task, }; use ignore::IgnoreStack; use language::DiskState; @@ -4144,7 +4145,7 @@ impl BackgroundScanner { let progress_update_count = AtomicUsize::new(0); self.executor - .scoped(|scope| { + .scoped_priority(Priority::Low, |scope| { for _ in 0..self.executor.num_cpus() { scope.spawn(async { let mut last_progress_update_count = 0; diff --git a/typos.toml b/typos.toml index cfc4ec86a853d1aeb16ca41fefd1d9fe368659d1..20a7b511a85676e3c5e49c23cab71c52e471cee9 100644 --- a/typos.toml +++ b/typos.toml @@ -52,6 +52,8 @@ extend-exclude = [ "crates/project_panel/benches/linux_repo_snapshot.txt", # Some multibuffer test cases have word fragments that register as typos "crates/multi_buffer/src/multi_buffer_tests.rs", + # Macos apis + "crates/gpui/src/platform/mac/dispatcher.rs", ] [default] From a698f1bf63b90df6c553fbffb430d978b9d44048 Mon Sep 17 00:00:00 2001 From: localcc Date: Fri, 12 Dec 2025 06:49:29 -0800 Subject: [PATCH 238/621] Fix Bounds::contains (#44711) Closes #11643 Release Notes: - Fixed double hover state on windows Co-authored-by: Kirill Bulatov --- crates/gpui/src/geometry.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/gpui/src/geometry.rs b/crates/gpui/src/geometry.rs index 4daec6d15367f3e12bab3cba658ccb3f261e9f46..f466624dfb91af9b4a33421ea15827ebe2559665 100644 --- a/crates/gpui/src/geometry.rs +++ b/crates/gpui/src/geometry.rs @@ -1416,9 +1416,9 @@ where /// ``` pub fn contains(&self, point: &Point) -> bool { point.x >= self.origin.x - && point.x <= self.origin.x.clone() + self.size.width.clone() + && point.x < self.origin.x.clone() + self.size.width.clone() && point.y >= self.origin.y - && point.y <= self.origin.y.clone() + self.size.height.clone() + && point.y < self.origin.y.clone() + self.size.height.clone() } /// Checks if this bounds is completely contained within another bounds. From 60f4aa333be1b2661c1a60d5750701122c6c5d8c Mon Sep 17 00:00:00 2001 From: Agus Zubiaga Date: Fri, 12 Dec 2025 14:15:58 -0300 Subject: [PATCH 239/621] edit prediction cli: Improve error handling (#44718) We were panicking whenever something went wrong with an example in the CLI. This can be very disruptive when running many examples, and e.g a single request fails. Instead, if running more than one example, errors will now be logged alongside instructions to explore and re-run the example by itself. CleanShot 2025-12-12 at 13 32 04@2x You can still opt in to stop as soon as en error occurs with the new `--failfast` argument. Release Notes: - N/A --- crates/edit_prediction_cli/src/distill.rs | 16 +- .../edit_prediction_cli/src/format_prompt.rs | 67 ++--- .../edit_prediction_cli/src/load_project.rs | 248 ++++++++---------- crates/edit_prediction_cli/src/main.rs | 243 ++++++++++++----- crates/edit_prediction_cli/src/paths.rs | 2 + crates/edit_prediction_cli/src/predict.rs | 120 ++++----- crates/edit_prediction_cli/src/progress.rs | 58 +++- .../src/retrieve_context.rs | 67 +++-- crates/edit_prediction_cli/src/score.rs | 5 +- 9 files changed, 478 insertions(+), 348 deletions(-) diff --git a/crates/edit_prediction_cli/src/distill.rs b/crates/edit_prediction_cli/src/distill.rs index 495b3cd88cbd05ad1917517580b913aacf4fb107..085c5f744a1837cbb97f4c33b6f89b6031088e2b 100644 --- a/crates/edit_prediction_cli/src/distill.rs +++ b/crates/edit_prediction_cli/src/distill.rs @@ -1,14 +1,22 @@ +use anyhow::{Result, anyhow}; use std::mem; use crate::example::Example; -pub async fn run_distill(example: &mut Example) { - let [prediction]: [_; 1] = mem::take(&mut example.predictions) - .try_into() - .expect("Run predict first with a single repetition"); +pub async fn run_distill(example: &mut Example) -> Result<()> { + let [prediction]: [_; 1] = + mem::take(&mut example.predictions) + .try_into() + .map_err(|preds: Vec<_>| { + anyhow!( + "Example has {} predictions, but it should have exactly one", + preds.len() + ) + })?; example.expected_patch = prediction.actual_patch; example.prompt = None; example.predictions = Vec::new(); example.score = Vec::new(); + Ok(()) } diff --git a/crates/edit_prediction_cli/src/format_prompt.rs b/crates/edit_prediction_cli/src/format_prompt.rs index 017e11a54c77e06bde7b74ed3f924692e33cd480..f8fd9b2023a84abcf59bcb5ba54d2d228a0c6484 100644 --- a/crates/edit_prediction_cli/src/format_prompt.rs +++ b/crates/edit_prediction_cli/src/format_prompt.rs @@ -6,6 +6,7 @@ use crate::{ progress::{Progress, Step}, retrieve_context::run_context_retrieval, }; +use anyhow::{Context as _, Result, ensure}; use edit_prediction::{ EditPredictionStore, zeta2::{zeta2_output_for_patch, zeta2_prompt_input}, @@ -19,8 +20,8 @@ pub async fn run_format_prompt( prompt_format: PromptFormat, app_state: Arc, mut cx: AsyncApp, -) { - run_context_retrieval(example, app_state.clone(), cx.clone()).await; +) -> Result<()> { + run_context_retrieval(example, app_state.clone(), cx.clone()).await?; let _step_progress = Progress::global().start(Step::FormatPrompt, &example.name); @@ -34,29 +35,33 @@ pub async fn run_format_prompt( }); } PromptFormat::Zeta2 => { - run_load_project(example, app_state, cx.clone()).await; + run_load_project(example, app_state, cx.clone()).await?; - let ep_store = cx - .update(|cx| EditPredictionStore::try_global(cx).unwrap()) - .unwrap(); + let ep_store = cx.update(|cx| { + EditPredictionStore::try_global(cx).context("EditPredictionStore not initialized") + })??; - let state = example.state.as_ref().unwrap(); - let snapshot = state - .buffer - .read_with(&cx, |buffer, _| buffer.snapshot()) - .unwrap(); + let state = example.state.as_ref().context("state must be set")?; + let snapshot = state.buffer.read_with(&cx, |buffer, _| buffer.snapshot())?; let project = state.project.clone(); - let (_, input) = ep_store - .update(&mut cx, |ep_store, _cx| { - zeta2_prompt_input( - &snapshot, - example.context.as_ref().unwrap().files.clone(), - ep_store.edit_history_for_project(&project), - example.cursor_path.clone(), - example.buffer.as_ref().unwrap().cursor_offset, - ) - }) - .unwrap(); + let (_, input) = ep_store.update(&mut cx, |ep_store, _cx| { + anyhow::Ok(zeta2_prompt_input( + &snapshot, + example + .context + .as_ref() + .context("context must be set")? + .files + .clone(), + ep_store.edit_history_for_project(&project), + example.cursor_path.clone(), + example + .buffer + .as_ref() + .context("buffer must be set")? + .cursor_offset, + )) + })??; let prompt = format_zeta_prompt(&input); let expected_output = zeta2_output_for_patch(&input, &example.expected_patch.clone()); example.prompt = Some(ExamplePrompt { @@ -66,6 +71,7 @@ pub async fn run_format_prompt( }); } }; + Ok(()) } pub struct TeacherPrompt; @@ -91,7 +97,7 @@ impl TeacherPrompt { prompt } - pub fn parse(example: &Example, response: &str) -> String { + pub fn parse(example: &Example, response: &str) -> Result { // Ideally, we should always be able to find cursor position in the retrieved context. // In reality, sometimes we don't find it for these reasons: // 1. `example.cursor_position` contains _more_ context than included in the retrieved context @@ -102,7 +108,7 @@ impl TeacherPrompt { let cursor_file = &example .buffer .as_ref() - .expect("`buffer` should be filled in in the context collection step") + .context("`buffer` should be filled in in the context collection step")? .content; // Extract updated (new) editable region from the model response @@ -111,9 +117,10 @@ impl TeacherPrompt { // Reconstruct old editable region we sent to the model let old_editable_region = Self::format_editable_region(example); let old_editable_region = Self::extract_editable_region(&old_editable_region); - if !cursor_file.contains(&old_editable_region) { - panic!("Something's wrong: editable_region is not found in the cursor file") - } + ensure!( + cursor_file.contains(&old_editable_region), + "Something's wrong: editable_region is not found in the cursor file" + ); // Apply editable region to a larger context and compute diff. // This is needed to get a better context lines around the editable region @@ -128,7 +135,7 @@ impl TeacherPrompt { diff = diff, }; - diff + Ok(diff) } fn format_edit_history(edit_history: &str) -> String { @@ -152,9 +159,7 @@ impl TeacherPrompt { } fn format_context(example: &Example) -> String { - if example.context.is_none() { - panic!("Missing context retriever step"); - } + assert!(example.context.is_some(), "Missing context retriever step"); let mut prompt = String::new(); zeta_prompt::write_related_files(&mut prompt, &example.context.as_ref().unwrap().files); diff --git a/crates/edit_prediction_cli/src/load_project.rs b/crates/edit_prediction_cli/src/load_project.rs index 4d98ae9f3b85f4e6253d9ead4d846ed3d9deee89..4517e6ccbebca76a7ba8ce73322d6467000fc189 100644 --- a/crates/edit_prediction_cli/src/load_project.rs +++ b/crates/edit_prediction_cli/src/load_project.rs @@ -4,7 +4,7 @@ use crate::{ paths::{REPOS_DIR, WORKTREES_DIR}, progress::{InfoStyle, Progress, Step, StepProgress}, }; -use anyhow::{Result, anyhow}; +use anyhow::{Context as _, Result}; use collections::HashMap; use edit_prediction::EditPredictionStore; use edit_prediction::udiff::OpenedBuffers; @@ -25,38 +25,38 @@ use std::{ use util::{paths::PathStyle, rel_path::RelPath}; use zeta_prompt::CURSOR_MARKER; -pub async fn run_load_project(example: &mut Example, app_state: Arc, mut cx: AsyncApp) { +pub async fn run_load_project( + example: &mut Example, + app_state: Arc, + mut cx: AsyncApp, +) -> Result<()> { if example.state.is_some() { - return; + return Ok(()); } let progress = Progress::global().start(Step::LoadProject, &example.name); - let project = setup_project(example, &app_state, &progress, &mut cx).await; - - let _open_buffers = apply_edit_history(example, &project, &mut cx) - .await - .unwrap(); - - let (buffer, cursor_position) = cursor_position(example, &project, &mut cx).await; - let (example_buffer, language_name) = buffer - .read_with(&cx, |buffer, _cx| { - let cursor_point = cursor_position.to_point(&buffer); - let language_name = buffer - .language() - .map(|l| l.name().to_string()) - .unwrap_or_else(|| "Unknown".to_string()); - ( - ExampleBuffer { - content: buffer.text(), - cursor_row: cursor_point.row, - cursor_column: cursor_point.column, - cursor_offset: cursor_position.to_offset(&buffer), - }, - language_name, - ) - }) - .unwrap(); + let project = setup_project(example, &app_state, &progress, &mut cx).await?; + + let _open_buffers = apply_edit_history(example, &project, &mut cx).await?; + + let (buffer, cursor_position) = cursor_position(example, &project, &mut cx).await?; + let (example_buffer, language_name) = buffer.read_with(&cx, |buffer, _cx| { + let cursor_point = cursor_position.to_point(&buffer); + let language_name = buffer + .language() + .map(|l| l.name().to_string()) + .unwrap_or_else(|| "Unknown".to_string()); + ( + ExampleBuffer { + content: buffer.text(), + cursor_row: cursor_point.row, + cursor_column: cursor_point.column, + cursor_offset: cursor_position.to_offset(&buffer), + }, + language_name, + ) + })?; progress.set_info(language_name, InfoStyle::Normal); @@ -67,16 +67,15 @@ pub async fn run_load_project(example: &mut Example, app_state: Arc, cursor_position, _open_buffers, }); + Ok(()) } async fn cursor_position( example: &Example, project: &Entity, cx: &mut AsyncApp, -) -> (Entity, Anchor) { - let language_registry = project - .read_with(cx, |project, _| project.languages().clone()) - .unwrap(); +) -> Result<(Entity, Anchor)> { + let language_registry = project.read_with(cx, |project, _| project.languages().clone())?; let result = language_registry .load_language_for_file_path(&example.cursor_path) .await; @@ -84,17 +83,18 @@ async fn cursor_position( if let Err(error) = result && !error.is::() { - panic!("Failed to load language for file path: {}", error); + return Err(error); } - let worktree = project - .read_with(cx, |project, cx| { - project.visible_worktrees(cx).next().unwrap() - }) - .unwrap(); + let worktree = project.read_with(cx, |project, cx| { + project + .visible_worktrees(cx) + .next() + .context("No visible worktrees") + })??; let cursor_path = RelPath::new(&example.cursor_path, PathStyle::Posix) - .unwrap() + .context("Failed to create RelPath")? .into_arc(); let cursor_buffer = project .update(cx, |project, cx| { @@ -105,15 +105,12 @@ async fn cursor_position( }, cx, ) - }) - .unwrap() - .await - .unwrap(); + })? + .await?; let cursor_offset_within_excerpt = example .cursor_position .find(CURSOR_MARKER) - .ok_or_else(|| anyhow!("missing cursor marker")) - .unwrap(); + .context("missing cursor marker")?; let mut cursor_excerpt = example.cursor_position.clone(); cursor_excerpt.replace_range( cursor_offset_within_excerpt..(cursor_offset_within_excerpt + CURSOR_MARKER.len()), @@ -123,22 +120,21 @@ async fn cursor_position( let text = buffer.text(); let mut matches = text.match_indices(&cursor_excerpt); - let (excerpt_offset, _) = matches.next().unwrap_or_else(|| { - panic!( + let (excerpt_offset, _) = matches.next().with_context(|| { + format!( "\nExcerpt:\n\n{cursor_excerpt}\nBuffer text:\n{text}\n.Example: {}\nCursor excerpt did not exist in buffer.", example.name - ); - }); - assert!(matches.next().is_none(), "More than one cursor position match found for {}", &example.name); - excerpt_offset - }).unwrap(); + ) + })?; + anyhow::ensure!(matches.next().is_none(), "More than one cursor position match found for {}", &example.name); + Ok(excerpt_offset) + })??; let cursor_offset = excerpt_offset + cursor_offset_within_excerpt; - let cursor_anchor = cursor_buffer - .read_with(cx, |buffer, _| buffer.anchor_after(cursor_offset)) - .unwrap(); + let cursor_anchor = + cursor_buffer.read_with(cx, |buffer, _| buffer.anchor_after(cursor_offset))?; - (cursor_buffer, cursor_anchor) + Ok((cursor_buffer, cursor_anchor)) } async fn setup_project( @@ -146,67 +142,54 @@ async fn setup_project( app_state: &Arc, step_progress: &StepProgress, cx: &mut AsyncApp, -) -> Entity { +) -> Result> { let ep_store = cx - .update(|cx| EditPredictionStore::try_global(cx).unwrap()) - .unwrap(); + .update(|cx| EditPredictionStore::try_global(cx))? + .context("Store should be initialized at init")?; - let worktree_path = setup_worktree(example, step_progress).await; + let worktree_path = setup_worktree(example, step_progress).await?; if let Some(project) = app_state.project_cache.get(&example.repository_url) { - ep_store - .update(cx, |ep_store, _| { - ep_store.clear_history_for_project(&project); - }) - .unwrap(); - let buffer_store = project - .read_with(cx, |project, _| project.buffer_store().clone()) - .unwrap(); - let buffers = buffer_store - .read_with(cx, |buffer_store, _| { - buffer_store.buffers().collect::>() - }) - .unwrap(); + ep_store.update(cx, |ep_store, _| { + ep_store.clear_history_for_project(&project); + })?; + let buffer_store = project.read_with(cx, |project, _| project.buffer_store().clone())?; + let buffers = buffer_store.read_with(cx, |buffer_store, _| { + buffer_store.buffers().collect::>() + })?; for buffer in buffers { buffer - .update(cx, |buffer, cx| buffer.reload(cx)) - .unwrap() + .update(cx, |buffer, cx| buffer.reload(cx))? .await .ok(); } - return project; + return Ok(project); } - let project = cx - .update(|cx| { - Project::local( - app_state.client.clone(), - app_state.node_runtime.clone(), - app_state.user_store.clone(), - app_state.languages.clone(), - app_state.fs.clone(), - None, - cx, - ) - }) - .unwrap(); + let project = cx.update(|cx| { + Project::local( + app_state.client.clone(), + app_state.node_runtime.clone(), + app_state.user_store.clone(), + app_state.languages.clone(), + app_state.fs.clone(), + None, + cx, + ) + })?; project .update(cx, |project, cx| { project.disable_worktree_scanner(cx); project.create_worktree(&worktree_path, true, cx) - }) - .unwrap() - .await - .unwrap(); + })? + .await?; app_state .project_cache .insert(example.repository_url.clone(), project.clone()); - let buffer_store = project - .read_with(cx, |project, _| project.buffer_store().clone()) - .unwrap(); + let buffer_store = project.read_with(cx, |project, _| project.buffer_store().clone())?; cx.subscribe(&buffer_store, { let project = project.clone(); move |_, event, cx| match event { @@ -215,15 +198,14 @@ async fn setup_project( } _ => {} } - }) - .unwrap() + })? .detach(); - project + Ok(project) } -async fn setup_worktree(example: &Example, step_progress: &StepProgress) -> PathBuf { - let (repo_owner, repo_name) = example.repo_name().expect("failed to get repo name"); +async fn setup_worktree(example: &Example, step_progress: &StepProgress) -> Result { + let (repo_owner, repo_name) = example.repo_name().context("failed to get repo name")?; let repo_dir = REPOS_DIR.join(repo_owner.as_ref()).join(repo_name.as_ref()); let worktree_path = WORKTREES_DIR .join(repo_owner.as_ref()) @@ -232,14 +214,13 @@ async fn setup_worktree(example: &Example, step_progress: &StepProgress) -> Path if !repo_dir.is_dir() { step_progress.set_substatus(format!("cloning {}", repo_name)); - fs::create_dir_all(&repo_dir).unwrap(); - run_git(&repo_dir, &["init"]).await.unwrap(); + fs::create_dir_all(&repo_dir)?; + run_git(&repo_dir, &["init"]).await?; run_git( &repo_dir, &["remote", "add", "origin", &example.repository_url], ) - .await - .unwrap(); + .await?; } // Resolve the example to a revision, fetching it if needed. @@ -259,34 +240,25 @@ async fn setup_worktree(example: &Example, step_progress: &StepProgress) -> Path .await .is_err() { - run_git(&repo_dir, &["fetch", "origin"]).await.unwrap(); + run_git(&repo_dir, &["fetch", "origin"]).await?; } - let revision = run_git(&repo_dir, &["rev-parse", "FETCH_HEAD"]) - .await - .unwrap(); + let revision = run_git(&repo_dir, &["rev-parse", "FETCH_HEAD"]).await?; revision }; // Create the worktree for this example if needed. step_progress.set_substatus("preparing worktree"); if worktree_path.is_dir() { - run_git(&worktree_path, &["clean", "--force", "-d"]) - .await - .unwrap(); - run_git(&worktree_path, &["reset", "--hard", "HEAD"]) - .await - .unwrap(); - run_git(&worktree_path, &["checkout", revision.as_str()]) - .await - .unwrap(); + run_git(&worktree_path, &["clean", "--force", "-d"]).await?; + run_git(&worktree_path, &["reset", "--hard", "HEAD"]).await?; + run_git(&worktree_path, &["checkout", revision.as_str()]).await?; } else { let worktree_path_string = worktree_path.to_string_lossy(); run_git( &repo_dir, &["branch", "-f", &example.name, revision.as_str()], ) - .await - .unwrap(); + .await?; run_git( &repo_dir, &[ @@ -297,8 +269,7 @@ async fn setup_worktree(example: &Example, step_progress: &StepProgress) -> Path &example.name, ], ) - .await - .unwrap(); + .await?; } drop(repo_lock); @@ -309,30 +280,25 @@ async fn setup_worktree(example: &Example, step_progress: &StepProgress) -> Path .current_dir(&worktree_path) .args(&["apply", "-"]) .stdin(std::process::Stdio::piped()) - .spawn() - .unwrap(); - - let mut stdin = apply_process.stdin.take().unwrap(); - stdin - .write_all(example.uncommitted_diff.as_bytes()) - .await - .unwrap(); - stdin.close().await.unwrap(); + .spawn()?; + + let mut stdin = apply_process.stdin.take().context("Failed to get stdin")?; + stdin.write_all(example.uncommitted_diff.as_bytes()).await?; + stdin.close().await?; drop(stdin); - let apply_result = apply_process.output().await.unwrap(); - if !apply_result.status.success() { - panic!( - "Failed to apply uncommitted diff patch with status: {}\nstderr:\n{}\nstdout:\n{}", - apply_result.status, - String::from_utf8_lossy(&apply_result.stderr), - String::from_utf8_lossy(&apply_result.stdout), - ); - } + let apply_result = apply_process.output().await?; + anyhow::ensure!( + apply_result.status.success(), + "Failed to apply uncommitted diff patch with status: {}\nstderr:\n{}\nstdout:\n{}", + apply_result.status, + String::from_utf8_lossy(&apply_result.stderr), + String::from_utf8_lossy(&apply_result.stdout), + ); } step_progress.clear_substatus(); - worktree_path + Ok(worktree_path) } async fn apply_edit_history( diff --git a/crates/edit_prediction_cli/src/main.rs b/crates/edit_prediction_cli/src/main.rs index 075f8862e6f86276a0df550c6d27f8c15a5d1293..3b185103390016f60fc4f621f280d16a58c363e5 100644 --- a/crates/edit_prediction_cli/src/main.rs +++ b/crates/edit_prediction_cli/src/main.rs @@ -16,12 +16,14 @@ use edit_prediction::EditPredictionStore; use gpui::Application; use reqwest_client::ReqwestClient; use serde::{Deserialize, Serialize}; +use std::fmt::Display; use std::{path::PathBuf, sync::Arc}; use crate::distill::run_distill; use crate::example::{group_examples_by_repo, read_examples, write_examples}; use crate::format_prompt::run_format_prompt; use crate::load_project::run_load_project; +use crate::paths::FAILED_EXAMPLES_DIR; use crate::predict::run_prediction; use crate::progress::Progress; use crate::retrieve_context::run_context_retrieval; @@ -42,6 +44,8 @@ struct EpArgs { output: Option, #[arg(long, short, global = true)] in_place: bool, + #[arg(long, short, global = true)] + failfast: bool, } #[derive(Subcommand, Debug)] @@ -67,6 +71,58 @@ enum Command { Clean, } +impl Display for Command { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Command::ParseExample => write!(f, "parse-example"), + Command::LoadProject => write!(f, "load-project"), + Command::Context => write!(f, "context"), + Command::FormatPrompt(format_prompt_args) => write!( + f, + "format-prompt --prompt-format={}", + format_prompt_args + .prompt_format + .to_possible_value() + .unwrap() + .get_name() + ), + Command::Predict(predict_args) => { + write!( + f, + "predict --provider={:?}", + predict_args + .provider + .to_possible_value() + .unwrap() + .get_name() + ) + } + Command::Score(predict_args) => { + write!( + f, + "score --provider={:?}", + predict_args + .provider + .to_possible_value() + .unwrap() + .get_name() + ) + } + Command::Distill => write!(f, "distill"), + Command::Eval(predict_args) => write!( + f, + "eval --provider={:?}", + predict_args + .provider + .to_possible_value() + .unwrap() + .get_name() + ), + Command::Clean => write!(f, "clean"), + } + } +} + #[derive(Debug, Args)] struct FormatPromptArgs { #[clap(long)] @@ -145,71 +201,140 @@ fn main() { EditPredictionStore::global(&app_state.client, &app_state.user_store, cx); cx.spawn(async move |cx| { - if let Command::Predict(args) = &command { - predict::sync_batches(&args.provider).await - }; - - let total_examples = examples.len(); - Progress::global().set_total_examples(total_examples); - - let mut grouped_examples = group_examples_by_repo(&mut examples); - let example_batches = grouped_examples.chunks_mut(args.max_parallelism); - - for example_batch in example_batches { - let futures = example_batch.into_iter().map(|repo_examples| async { - for example in repo_examples.iter_mut() { - match &command { - Command::ParseExample => {} - Command::LoadProject => { - run_load_project(example, app_state.clone(), cx.clone()).await; - } - Command::Context => { - run_context_retrieval(example, app_state.clone(), cx.clone()).await; - } - Command::FormatPrompt(args) => { - run_format_prompt( - example, - args.prompt_format, - app_state.clone(), - cx.clone(), - ) - .await; - } - Command::Predict(args) => { - run_prediction( - example, - Some(args.provider), - args.repetitions, - app_state.clone(), - cx.clone(), - ) - .await; - } - Command::Distill => { - run_distill(example).await; - } - Command::Score(args) | Command::Eval(args) => { - run_scoring(example, &args, app_state.clone(), cx.clone()).await; + let result = async { + if let Command::Predict(args) = &command { + predict::sync_batches(&args.provider).await?; + } + + let total_examples = examples.len(); + Progress::global().set_total_examples(total_examples); + + let mut grouped_examples = group_examples_by_repo(&mut examples); + let example_batches = grouped_examples.chunks_mut(args.max_parallelism); + + for example_batch in example_batches { + let futures = example_batch.into_iter().map(|repo_examples| async { + for example in repo_examples.iter_mut() { + let result = async { + match &command { + Command::ParseExample => {} + Command::LoadProject => { + run_load_project(example, app_state.clone(), cx.clone()) + .await?; + } + Command::Context => { + run_context_retrieval( + example, + app_state.clone(), + cx.clone(), + ) + .await?; + } + Command::FormatPrompt(args) => { + run_format_prompt( + example, + args.prompt_format, + app_state.clone(), + cx.clone(), + ) + .await?; + } + Command::Predict(args) => { + run_prediction( + example, + Some(args.provider), + args.repetitions, + app_state.clone(), + cx.clone(), + ) + .await?; + } + Command::Distill => { + run_distill(example).await?; + } + Command::Score(args) | Command::Eval(args) => { + run_scoring(example, &args, app_state.clone(), cx.clone()) + .await?; + } + Command::Clean => { + unreachable!() + } + } + anyhow::Ok(()) } - Command::Clean => { - unreachable!() + .await; + + if let Err(e) = result { + Progress::global().increment_failed(); + let failed_example_path = + FAILED_EXAMPLES_DIR.join(format!("{}.json", example.name)); + app_state + .fs + .write( + &failed_example_path, + &serde_json::to_vec_pretty(&example).unwrap(), + ) + .await + .unwrap(); + let err_path = + FAILED_EXAMPLES_DIR.join(format!("{}_err.txt", example.name)); + app_state + .fs + .write(&err_path, e.to_string().as_bytes()) + .await + .unwrap(); + + let msg = format!( + indoc::indoc! {" + While processing {}: + + {:?} + + Written to: \x1b[36m{}\x1b[0m + + Explore this example data with: + fx \x1b[36m{}\x1b[0m + + Re-run this example with: + cargo run -p edit_prediction_cli -- {} \x1b[36m{}\x1b[0m + "}, + example.name, + e, + err_path.display(), + failed_example_path.display(), + command, + failed_example_path.display(), + ); + if args.failfast || total_examples == 1 { + Progress::global().finalize(); + panic!("{}", msg); + } else { + log::error!("{}", msg); + } } } - } - }); - futures::future::join_all(futures).await; - } - Progress::global().clear(); + }); + futures::future::join_all(futures).await; + } + Progress::global().finalize(); - if args.output.is_some() || !matches!(command, Command::Eval(_)) { - write_examples(&examples, output.as_ref()); + if args.output.is_some() || !matches!(command, Command::Eval(_)) { + write_examples(&examples, output.as_ref()); + } + + match &command { + Command::Predict(args) => predict::sync_batches(&args.provider).await?, + Command::Eval(_) => score::print_report(&examples), + _ => (), + }; + + anyhow::Ok(()) } + .await; - match &command { - Command::Predict(args) => predict::sync_batches(&args.provider).await, - Command::Eval(_) => score::print_report(&examples), - _ => (), - }; + if let Err(e) = result { + panic!("Fatal error: {:?}", e); + } let _ = cx.update(|cx| cx.quit()); }) diff --git a/crates/edit_prediction_cli/src/paths.rs b/crates/edit_prediction_cli/src/paths.rs index 0f470fae556b6d61739ab77083d7edbedf77ef89..e5d420d0e3dbeda9c50b8e5a3683238149dbc604 100644 --- a/crates/edit_prediction_cli/src/paths.rs +++ b/crates/edit_prediction_cli/src/paths.rs @@ -18,6 +18,8 @@ pub static RUN_DIR: LazyLock = LazyLock::new(|| { }); pub static LATEST_EXAMPLE_RUN_DIR: LazyLock = LazyLock::new(|| DATA_DIR.join("latest")); pub static LLM_CACHE_DB: LazyLock = LazyLock::new(|| CACHE_DIR.join("llm_cache.sqlite")); +pub static FAILED_EXAMPLES_DIR: LazyLock = + LazyLock::new(|| ensure_dir(&RUN_DIR.join("failed"))); fn ensure_dir(path: &Path) -> PathBuf { std::fs::create_dir_all(path).expect("Failed to create directory"); diff --git a/crates/edit_prediction_cli/src/predict.rs b/crates/edit_prediction_cli/src/predict.rs index 3f690266e3165b2d52f642457e7aebf959a40a03..3e6104e3a8afc3adc609df094a70fc34138c1619 100644 --- a/crates/edit_prediction_cli/src/predict.rs +++ b/crates/edit_prediction_cli/src/predict.rs @@ -9,6 +9,7 @@ use crate::{ progress::{InfoStyle, Progress, Step}, retrieve_context::run_context_retrieval, }; +use anyhow::Context as _; use edit_prediction::{DebugEvent, EditPredictionStore}; use futures::{FutureExt as _, StreamExt as _, future::Shared}; use gpui::{AppContext as _, AsyncApp, Task}; @@ -26,14 +27,14 @@ pub async fn run_prediction( repetition_count: usize, app_state: Arc, mut cx: AsyncApp, -) { +) -> anyhow::Result<()> { if !example.predictions.is_empty() { - return; + return Ok(()); } - let provider = provider.unwrap(); + let provider = provider.context("provider is required")?; - run_context_retrieval(example, app_state.clone(), cx.clone()).await; + run_context_retrieval(example, app_state.clone(), cx.clone()).await?; if matches!( provider, @@ -42,14 +43,14 @@ pub async fn run_prediction( let _step_progress = Progress::global().start(Step::Predict, &example.name); if example.prompt.is_none() { - run_format_prompt(example, PromptFormat::Teacher, app_state.clone(), cx).await; + run_format_prompt(example, PromptFormat::Teacher, app_state.clone(), cx).await?; } let batched = matches!(provider, PredictionProvider::Teacher); return predict_anthropic(example, repetition_count, batched).await; } - run_load_project(example, app_state.clone(), cx.clone()).await; + run_load_project(example, app_state.clone(), cx.clone()).await?; let _step_progress = Progress::global().start(Step::Predict, &example.name); @@ -62,10 +63,9 @@ pub async fn run_prediction( .get_or_init(|| { let client = app_state.client.clone(); cx.spawn(async move |cx| { - client - .sign_in_with_optional_connect(true, cx) - .await - .unwrap(); + if let Err(e) = client.sign_in_with_optional_connect(true, cx).await { + eprintln!("Authentication failed: {}", e); + } }) .shared() }) @@ -73,33 +73,30 @@ pub async fn run_prediction( .await; } - let ep_store = cx - .update(|cx| EditPredictionStore::try_global(cx).unwrap()) - .unwrap(); - - ep_store - .update(&mut cx, |store, _cx| { - let model = match provider { - PredictionProvider::Zeta1 => edit_prediction::EditPredictionModel::Zeta1, - PredictionProvider::Zeta2 => edit_prediction::EditPredictionModel::Zeta2, - PredictionProvider::Sweep => edit_prediction::EditPredictionModel::Sweep, - PredictionProvider::Mercury => edit_prediction::EditPredictionModel::Mercury, - PredictionProvider::Teacher | PredictionProvider::TeacherNonBatching => { - unreachable!() - } - }; - store.set_edit_prediction_model(model); - }) - .unwrap(); - let state = example.state.as_ref().unwrap(); + let ep_store = cx.update(|cx| { + EditPredictionStore::try_global(cx).context("EditPredictionStore not initialized") + })??; + + ep_store.update(&mut cx, |store, _cx| { + let model = match provider { + PredictionProvider::Zeta1 => edit_prediction::EditPredictionModel::Zeta1, + PredictionProvider::Zeta2 => edit_prediction::EditPredictionModel::Zeta2, + PredictionProvider::Sweep => edit_prediction::EditPredictionModel::Sweep, + PredictionProvider::Mercury => edit_prediction::EditPredictionModel::Mercury, + PredictionProvider::Teacher | PredictionProvider::TeacherNonBatching => { + unreachable!() + } + }; + store.set_edit_prediction_model(model); + })?; + let state = example.state.as_ref().context("state must be set")?; let run_dir = RUN_DIR.join(&example.name); let updated_example = Arc::new(Mutex::new(example.clone())); let current_run_ix = Arc::new(AtomicUsize::new(0)); - let mut debug_rx = ep_store - .update(&mut cx, |store, cx| store.debug_info(&state.project, cx)) - .unwrap(); + let mut debug_rx = + ep_store.update(&mut cx, |store, cx| store.debug_info(&state.project, cx))?; let debug_task = cx.background_spawn({ let updated_example = updated_example.clone(); let current_run_ix = current_run_ix.clone(); @@ -153,14 +150,14 @@ pub async fn run_prediction( run_dir.clone() }; - fs::create_dir_all(&run_dir).unwrap(); + fs::create_dir_all(&run_dir)?; if LATEST_EXAMPLE_RUN_DIR.is_symlink() { - fs::remove_file(&*LATEST_EXAMPLE_RUN_DIR).unwrap(); + fs::remove_file(&*LATEST_EXAMPLE_RUN_DIR)?; } #[cfg(unix)] - std::os::unix::fs::symlink(&run_dir, &*LATEST_EXAMPLE_RUN_DIR).unwrap(); + std::os::unix::fs::symlink(&run_dir, &*LATEST_EXAMPLE_RUN_DIR)?; #[cfg(windows)] - std::os::windows::fs::symlink_dir(&run_dir, &*LATEST_EXAMPLE_RUN_DIR).unwrap(); + std::os::windows::fs::symlink_dir(&run_dir, &*LATEST_EXAMPLE_RUN_DIR)?; updated_example .lock() @@ -181,10 +178,8 @@ pub async fn run_prediction( cloud_llm_client::PredictEditsRequestTrigger::Cli, cx, ) - }) - .unwrap() - .await - .unwrap(); + })? + .await?; let actual_patch = prediction .and_then(|prediction| { @@ -213,20 +208,23 @@ pub async fn run_prediction( } } - ep_store - .update(&mut cx, |store, _| { - store.remove_project(&state.project); - }) - .unwrap(); - debug_task.await.unwrap(); + ep_store.update(&mut cx, |store, _| { + store.remove_project(&state.project); + })?; + debug_task.await?; *example = Arc::into_inner(updated_example) - .unwrap() + .ok_or_else(|| anyhow::anyhow!("Failed to unwrap Arc"))? .into_inner() - .unwrap(); + .map_err(|_| anyhow::anyhow!("Failed to unwrap Mutex"))?; + Ok(()) } -async fn predict_anthropic(example: &mut Example, _repetition_count: usize, batched: bool) { +async fn predict_anthropic( + example: &mut Example, + _repetition_count: usize, + batched: bool, +) -> anyhow::Result<()> { let llm_model_name = "claude-sonnet-4-5"; let max_tokens = 16384; let llm_client = if batched { @@ -234,12 +232,9 @@ async fn predict_anthropic(example: &mut Example, _repetition_count: usize, batc } else { AnthropicClient::plain() }; - let llm_client = llm_client.expect("Failed to create LLM client"); + let llm_client = llm_client.context("Failed to create LLM client")?; - let prompt = example - .prompt - .as_ref() - .unwrap_or_else(|| panic!("Prompt is required for an example {}", &example.name)); + let prompt = example.prompt.as_ref().context("Prompt is required")?; let messages = vec![anthropic::Message { role: anthropic::Role::User, @@ -251,11 +246,10 @@ async fn predict_anthropic(example: &mut Example, _repetition_count: usize, batc let Some(response) = llm_client .generate(llm_model_name, max_tokens, messages) - .await - .unwrap() + .await? else { // Request stashed for batched processing - return; + return Ok(()); }; let actual_output = response @@ -268,7 +262,7 @@ async fn predict_anthropic(example: &mut Example, _repetition_count: usize, batc .collect::>() .join("\n"); - let actual_patch = TeacherPrompt::parse(example, &actual_output); + let actual_patch = TeacherPrompt::parse(example, &actual_output)?; let prediction = ExamplePrediction { actual_patch, @@ -277,19 +271,21 @@ async fn predict_anthropic(example: &mut Example, _repetition_count: usize, batc }; example.predictions.push(prediction); + Ok(()) } -pub async fn sync_batches(provider: &PredictionProvider) { +pub async fn sync_batches(provider: &PredictionProvider) -> anyhow::Result<()> { match provider { PredictionProvider::Teacher => { let cache_path = crate::paths::LLM_CACHE_DB.as_ref(); let llm_client = - AnthropicClient::batch(cache_path).expect("Failed to create LLM client"); + AnthropicClient::batch(cache_path).context("Failed to create LLM client")?; llm_client .sync_batches() .await - .expect("Failed to sync batches"); + .context("Failed to sync batches")?; } _ => (), - } + }; + Ok(()) } diff --git a/crates/edit_prediction_cli/src/progress.rs b/crates/edit_prediction_cli/src/progress.rs index 8195485d70c70c0cbfb38e2de83a055598d5e4e5..ddc710f202cc98e5932c234cb6bebcc93b28171c 100644 --- a/crates/edit_prediction_cli/src/progress.rs +++ b/crates/edit_prediction_cli/src/progress.rs @@ -20,6 +20,7 @@ struct ProgressInner { max_example_name_len: usize, status_lines_displayed: usize, total_examples: usize, + failed_examples: usize, last_line_is_logging: bool, } @@ -78,7 +79,7 @@ impl Step { static GLOBAL: OnceLock> = OnceLock::new(); static LOGGER: ProgressLogger = ProgressLogger; -const RIGHT_MARGIN: usize = 4; +const MARGIN: usize = 4; const MAX_STATUS_LINES: usize = 10; impl Progress { @@ -95,6 +96,7 @@ impl Progress { max_example_name_len: 0, status_lines_displayed: 0, total_examples: 0, + failed_examples: 0, last_line_is_logging: false, }), }); @@ -110,6 +112,11 @@ impl Progress { inner.total_examples = total; } + pub fn increment_failed(&self) { + let mut inner = self.inner.lock().unwrap(); + inner.failed_examples += 1; + } + /// Prints a message to stderr, clearing and redrawing status lines to avoid corruption. /// This should be used for any output that needs to appear above the status lines. fn log(&self, message: &str) { @@ -119,7 +126,7 @@ impl Progress { if !inner.last_line_is_logging { let reset = "\x1b[0m"; let dim = "\x1b[2m"; - let divider = "─".repeat(inner.terminal_width.saturating_sub(RIGHT_MARGIN)); + let divider = "─".repeat(inner.terminal_width.saturating_sub(MARGIN)); eprintln!("{dim}{divider}{reset}"); inner.last_line_is_logging = true; } @@ -180,7 +187,7 @@ impl Progress { if inner.last_line_is_logging { let reset = "\x1b[0m"; let dim = "\x1b[2m"; - let divider = "─".repeat(inner.terminal_width.saturating_sub(RIGHT_MARGIN)); + let divider = "─".repeat(inner.terminal_width.saturating_sub(MARGIN)); eprintln!("{dim}{divider}{reset}"); inner.last_line_is_logging = false; } @@ -229,7 +236,7 @@ impl Progress { let duration_with_margin = format!("{duration} "); let padding_needed = inner .terminal_width - .saturating_sub(RIGHT_MARGIN) + .saturating_sub(MARGIN) .saturating_sub(duration_with_margin.len()) .saturating_sub(strip_ansi_len(&prefix)); let padding = " ".repeat(padding_needed); @@ -263,20 +270,33 @@ impl Progress { // Build the done/in-progress/total label let done_count = inner.completed.len(); let in_progress_count = inner.in_progress.len(); + let failed_count = inner.failed_examples; + + let failed_label = if failed_count > 0 { + format!(" {} failed ", failed_count) + } else { + String::new() + }; + let range_label = format!( " {}/{}/{} ", done_count, in_progress_count, inner.total_examples ); - // Print a divider line with range label aligned with timestamps + // Print a divider line with failed count on left, range label on right + let failed_visible_len = strip_ansi_len(&failed_label); let range_visible_len = range_label.len(); - let left_divider_len = inner + let middle_divider_len = inner .terminal_width - .saturating_sub(RIGHT_MARGIN) + .saturating_sub(MARGIN * 2) + .saturating_sub(failed_visible_len) .saturating_sub(range_visible_len); - let left_divider = "─".repeat(left_divider_len); - let right_divider = "─".repeat(RIGHT_MARGIN); - eprintln!("{dim}{left_divider}{reset}{range_label}{dim}{right_divider}{reset}"); + let left_divider = "─".repeat(MARGIN); + let middle_divider = "─".repeat(middle_divider_len); + let right_divider = "─".repeat(MARGIN); + eprintln!( + "{dim}{left_divider}{reset}{failed_label}{dim}{middle_divider}{reset}{range_label}{dim}{right_divider}{reset}" + ); let mut tasks: Vec<_> = inner.in_progress.iter().collect(); tasks.sort_by_key(|(name, _)| *name); @@ -304,7 +324,7 @@ impl Progress { let duration_with_margin = format!("{elapsed} "); let padding_needed = inner .terminal_width - .saturating_sub(RIGHT_MARGIN) + .saturating_sub(MARGIN) .saturating_sub(duration_with_margin.len()) .saturating_sub(strip_ansi_len(&prefix)); let padding = " ".repeat(padding_needed); @@ -324,9 +344,23 @@ impl Progress { let _ = std::io::stderr().flush(); } - pub fn clear(&self) { + pub fn finalize(&self) { let mut inner = self.inner.lock().unwrap(); Self::clear_status_lines(&mut inner); + + // Print summary if there were failures + if inner.failed_examples > 0 { + let total_processed = inner.completed.len() + inner.failed_examples; + let percentage = if total_processed > 0 { + inner.failed_examples as f64 / total_processed as f64 * 100.0 + } else { + 0.0 + }; + eprintln!( + "\n{} of {} examples failed ({:.1}%)", + inner.failed_examples, total_processed, percentage + ); + } } } diff --git a/crates/edit_prediction_cli/src/retrieve_context.rs b/crates/edit_prediction_cli/src/retrieve_context.rs index c066cf3caa9ece27144222ef94e3ac72c2285be8..a07c7ec8752ff987b8783c4fa15904078bd5612d 100644 --- a/crates/edit_prediction_cli/src/retrieve_context.rs +++ b/crates/edit_prediction_cli/src/retrieve_context.rs @@ -4,6 +4,7 @@ use crate::{ load_project::run_load_project, progress::{InfoStyle, Progress, Step, StepProgress}, }; +use anyhow::Context as _; use collections::HashSet; use edit_prediction::{DebugEvent, EditPredictionStore}; use futures::{FutureExt as _, StreamExt as _, channel::mpsc}; @@ -17,12 +18,12 @@ pub async fn run_context_retrieval( example: &mut Example, app_state: Arc, mut cx: AsyncApp, -) { +) -> anyhow::Result<()> { if example.context.is_some() { - return; + return Ok(()); } - run_load_project(example, app_state.clone(), cx.clone()).await; + run_load_project(example, app_state.clone(), cx.clone()).await?; let step_progress: Arc = Progress::global() .start(Step::Context, &example.name) @@ -31,25 +32,21 @@ pub async fn run_context_retrieval( let state = example.state.as_ref().unwrap(); let project = state.project.clone(); - let _lsp_handle = project - .update(&mut cx, |project, cx| { - project.register_buffer_with_language_servers(&state.buffer, cx) - }) - .unwrap(); - wait_for_language_servers_to_start(&project, &state.buffer, &step_progress, &mut cx).await; - - let ep_store = cx - .update(|cx| EditPredictionStore::try_global(cx).unwrap()) - .unwrap(); - - let mut events = ep_store - .update(&mut cx, |store, cx| { - store.register_buffer(&state.buffer, &project, cx); - store.set_use_context(true); - store.refresh_context(&project, &state.buffer, state.cursor_position, cx); - store.debug_info(&project, cx) - }) - .unwrap(); + let _lsp_handle = project.update(&mut cx, |project, cx| { + project.register_buffer_with_language_servers(&state.buffer, cx) + })?; + wait_for_language_servers_to_start(&project, &state.buffer, &step_progress, &mut cx).await?; + + let ep_store = cx.update(|cx| { + EditPredictionStore::try_global(cx).context("EditPredictionStore not initialized") + })??; + + let mut events = ep_store.update(&mut cx, |store, cx| { + store.register_buffer(&state.buffer, &project, cx); + store.set_use_context(true); + store.refresh_context(&project, &state.buffer, state.cursor_position, cx); + store.debug_info(&project, cx) + })?; while let Some(event) = events.next().await { match event { @@ -60,9 +57,8 @@ pub async fn run_context_retrieval( } } - let context_files = ep_store - .update(&mut cx, |store, cx| store.context_for_project(&project, cx)) - .unwrap(); + let context_files = + ep_store.update(&mut cx, |store, cx| store.context_for_project(&project, cx))?; let excerpt_count: usize = context_files.iter().map(|f| f.excerpts.len()).sum(); step_progress.set_info(format!("{} excerpts", excerpt_count), InfoStyle::Normal); @@ -70,6 +66,7 @@ pub async fn run_context_retrieval( example.context = Some(ExampleContext { files: context_files, }); + Ok(()) } async fn wait_for_language_servers_to_start( @@ -77,10 +74,8 @@ async fn wait_for_language_servers_to_start( buffer: &Entity, step_progress: &Arc, cx: &mut AsyncApp, -) { - let lsp_store = project - .read_with(cx, |project, _| project.lsp_store()) - .unwrap(); +) -> anyhow::Result<()> { + let lsp_store = project.read_with(cx, |project, _| project.lsp_store())?; let (language_server_ids, mut starting_language_server_ids) = buffer .update(cx, |buffer, cx| { @@ -123,7 +118,7 @@ async fn wait_for_language_servers_to_start( } }, _ = timeout.clone().fuse() => { - panic!("LSP wait timed out after 5 minutes"); + return Err(anyhow::anyhow!("LSP wait timed out after 5 minutes")); } } } @@ -132,8 +127,7 @@ async fn wait_for_language_servers_to_start( if !language_server_ids.is_empty() { project - .update(cx, |project, cx| project.save_buffer(buffer.clone(), cx)) - .unwrap() + .update(cx, |project, cx| project.save_buffer(buffer.clone(), cx))? .detach(); } @@ -175,10 +169,8 @@ async fn wait_for_language_servers_to_start( ]; project - .update(cx, |project, cx| project.save_buffer(buffer.clone(), cx)) - .unwrap() - .await - .unwrap(); + .update(cx, |project, cx| project.save_buffer(buffer.clone(), cx))? + .await?; let mut pending_language_server_ids = HashSet::from_iter(language_server_ids.into_iter()); while !pending_language_server_ids.is_empty() { @@ -189,11 +181,12 @@ async fn wait_for_language_servers_to_start( } }, _ = timeout.clone().fuse() => { - panic!("LSP wait timed out after 5 minutes"); + return Err(anyhow::anyhow!("LSP wait timed out after 5 minutes")); } } } drop(subscriptions); step_progress.clear_substatus(); + Ok(()) } diff --git a/crates/edit_prediction_cli/src/score.rs b/crates/edit_prediction_cli/src/score.rs index b87d8e4df24c8cb12676ed71fe1ea930a841791d..314d19b67259e6a4a0fcff932826325f4366ddde 100644 --- a/crates/edit_prediction_cli/src/score.rs +++ b/crates/edit_prediction_cli/src/score.rs @@ -15,7 +15,7 @@ pub async fn run_scoring( args: &PredictArgs, app_state: Arc, cx: AsyncApp, -) { +) -> anyhow::Result<()> { run_prediction( example, Some(args.provider), @@ -23,7 +23,7 @@ pub async fn run_scoring( app_state, cx, ) - .await; + .await?; let _progress = Progress::global().start(Step::Score, &example.name); @@ -43,6 +43,7 @@ pub async fn run_scoring( } example.score = scores; + Ok(()) } fn parse_patch(patch: &str) -> Vec> { From e1d236eaf09bd0120111675962ebebd44e9c6cbf Mon Sep 17 00:00:00 2001 From: Oleksiy Syvokon Date: Fri, 12 Dec 2025 23:18:13 +0200 Subject: [PATCH 240/621] ep: Apply diff to editable region only and edit history fixes (#44737) Release Notes: - N/A --------- Co-authored-by: Max Brunsfeld Co-authored-by: Agus Zubiaga --- crates/edit_prediction/src/edit_prediction.rs | 3 ++- crates/edit_prediction/src/zeta2.rs | 21 +++++++++++-------- .../edit_prediction_cli/src/format_prompt.rs | 6 +++--- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/crates/edit_prediction/src/edit_prediction.rs b/crates/edit_prediction/src/edit_prediction.rs index 6a7c6232d08b15fccacdd80a446432e453a80e20..d9d9c2243d81640a55133843669514d551f64902 100644 --- a/crates/edit_prediction/src/edit_prediction.rs +++ b/crates/edit_prediction/src/edit_prediction.rs @@ -586,10 +586,11 @@ impl EditPredictionStore { pub fn edit_history_for_project( &self, project: &Entity, + cx: &App, ) -> Vec> { self.projects .get(&project.entity_id()) - .map(|project_state| project_state.events.iter().cloned().collect()) + .map(|project_state| project_state.events(cx)) .unwrap_or_default() } diff --git a/crates/edit_prediction/src/zeta2.rs b/crates/edit_prediction/src/zeta2.rs index 8586e6caaea1fdc9c865ddba8894f680d766b4a9..9706e2b9ecd03f6e8ba592210722725f420643d3 100644 --- a/crates/edit_prediction/src/zeta2.rs +++ b/crates/edit_prediction/src/zeta2.rs @@ -228,13 +228,16 @@ pub fn zeta2_prompt_input( } #[cfg(feature = "cli-support")] -pub fn zeta2_output_for_patch(input: &zeta_prompt::ZetaPromptInput, patch: &str) -> String { - eprintln!("{}", patch); - eprintln!("---------------------"); - eprintln!("{}", input.cursor_excerpt); - crate::udiff::apply_diff_to_string( - patch, - &input.cursor_excerpt[input.editable_range_in_excerpt.clone()], - ) - .unwrap() +pub fn zeta2_output_for_patch(input: &zeta_prompt::ZetaPromptInput, patch: &str) -> Result { + let text = &input.cursor_excerpt; + let editable_region = input.editable_range_in_excerpt.clone(); + let old_prefix = &text[..editable_region.start]; + let old_suffix = &text[editable_region.end..]; + + let new = crate::udiff::apply_diff_to_string(patch, text)?; + if !new.starts_with(old_prefix) || !new.ends_with(old_suffix) { + anyhow::bail!("Patch shouldn't affect text outside of editable region"); + } + + Ok(new[editable_region.start..new.len() - old_suffix.len()].to_string()) } diff --git a/crates/edit_prediction_cli/src/format_prompt.rs b/crates/edit_prediction_cli/src/format_prompt.rs index f8fd9b2023a84abcf59bcb5ba54d2d228a0c6484..c778b708b701492b0cc85a0030a1e9d090ce0724 100644 --- a/crates/edit_prediction_cli/src/format_prompt.rs +++ b/crates/edit_prediction_cli/src/format_prompt.rs @@ -44,7 +44,7 @@ pub async fn run_format_prompt( let state = example.state.as_ref().context("state must be set")?; let snapshot = state.buffer.read_with(&cx, |buffer, _| buffer.snapshot())?; let project = state.project.clone(); - let (_, input) = ep_store.update(&mut cx, |ep_store, _cx| { + let (_, input) = ep_store.update(&mut cx, |ep_store, cx| { anyhow::Ok(zeta2_prompt_input( &snapshot, example @@ -53,7 +53,7 @@ pub async fn run_format_prompt( .context("context must be set")? .files .clone(), - ep_store.edit_history_for_project(&project), + ep_store.edit_history_for_project(&project, cx), example.cursor_path.clone(), example .buffer @@ -63,7 +63,7 @@ pub async fn run_format_prompt( )) })??; let prompt = format_zeta_prompt(&input); - let expected_output = zeta2_output_for_patch(&input, &example.expected_patch.clone()); + let expected_output = zeta2_output_for_patch(&input, &example.expected_patch.clone())?; example.prompt = Some(ExamplePrompt { input: prompt, expected_output, From 329ec645da5a92b18a2d152748f0a37ae167db6b Mon Sep 17 00:00:00 2001 From: Xiaobo Liu Date: Sat, 13 Dec 2025 06:27:09 +0800 Subject: [PATCH 241/621] gpui: Fix tab jitter from oversized scrolling (#42434) --- crates/gpui/src/elements/div.rs | 55 +++++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 2 deletions(-) diff --git a/crates/gpui/src/elements/div.rs b/crates/gpui/src/elements/div.rs index 821f155f96d168e5319d9a8981ca4be75df7b854..c80acacce3d714c56dca0cdb65a4477b4c3b3b0e 100644 --- a/crates/gpui/src/elements/div.rs +++ b/crates/gpui/src/elements/div.rs @@ -3193,7 +3193,11 @@ impl ScrollHandle { match active_item.strategy { ScrollStrategy::FirstVisible => { if state.overflow.y == Overflow::Scroll { - if bounds.top() + scroll_offset.y < state.bounds.top() { + let child_height = bounds.size.height; + let viewport_height = state.bounds.size.height; + if child_height > viewport_height { + scroll_offset.y = state.bounds.top() - bounds.top(); + } else if bounds.top() + scroll_offset.y < state.bounds.top() { scroll_offset.y = state.bounds.top() - bounds.top(); } else if bounds.bottom() + scroll_offset.y > state.bounds.bottom() { scroll_offset.y = state.bounds.bottom() - bounds.bottom(); @@ -3206,7 +3210,11 @@ impl ScrollHandle { } if state.overflow.x == Overflow::Scroll { - if bounds.left() + scroll_offset.x < state.bounds.left() { + let child_width = bounds.size.width; + let viewport_width = state.bounds.size.width; + if child_width > viewport_width { + scroll_offset.x = state.bounds.left() - bounds.left(); + } else if bounds.left() + scroll_offset.x < state.bounds.left() { scroll_offset.x = state.bounds.left() - bounds.left(); } else if bounds.right() + scroll_offset.x > state.bounds.right() { scroll_offset.x = state.bounds.right() - bounds.right(); @@ -3268,3 +3276,46 @@ impl ScrollHandle { self.0.borrow().child_bounds.len() } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn scroll_handle_aligns_wide_children_to_left_edge() { + let handle = ScrollHandle::new(); + { + let mut state = handle.0.borrow_mut(); + state.bounds = Bounds::new(point(px(0.), px(0.)), size(px(80.), px(20.))); + state.child_bounds = vec![Bounds::new(point(px(25.), px(0.)), size(px(200.), px(20.)))]; + state.overflow.x = Overflow::Scroll; + state.active_item = Some(ScrollActiveItem { + index: 0, + strategy: ScrollStrategy::default(), + }); + } + + handle.scroll_to_active_item(); + + assert_eq!(handle.offset().x, px(-25.)); + } + + #[test] + fn scroll_handle_aligns_tall_children_to_top_edge() { + let handle = ScrollHandle::new(); + { + let mut state = handle.0.borrow_mut(); + state.bounds = Bounds::new(point(px(0.), px(0.)), size(px(20.), px(80.))); + state.child_bounds = vec![Bounds::new(point(px(0.), px(25.)), size(px(20.), px(200.)))]; + state.overflow.y = Overflow::Scroll; + state.active_item = Some(ScrollActiveItem { + index: 0, + strategy: ScrollStrategy::default(), + }); + } + + handle.scroll_to_active_item(); + + assert_eq!(handle.offset().y, px(-25.)); + } +} From fad06dd00cd6843dcfa284805cda070a18f3681c Mon Sep 17 00:00:00 2001 From: Anthony Eid <56899983+Anthony-Eid@users.noreply.github.com> Date: Fri, 12 Dec 2025 17:59:35 -0500 Subject: [PATCH 242/621] git: Show all branches in branch picker empty state (#44742) This fixes an issue where a user could get confused by the branch picker because it would only show the 10 most recent branches, instead of all branches. Release Notes: - git: Show all branches in branch picker when search field is empty --- crates/git_ui/src/branch_picker.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/crates/git_ui/src/branch_picker.rs b/crates/git_ui/src/branch_picker.rs index 90b5c4bb284112c8a13ad406da2b7424e982298a..8a08736d8bace6a77963c4325406d340903f1b73 100644 --- a/crates/git_ui/src/branch_picker.rs +++ b/crates/git_ui/src/branch_picker.rs @@ -636,7 +636,6 @@ impl PickerDelegate for BranchListDelegate { return Task::ready(()); }; - const RECENT_BRANCHES_COUNT: usize = 10; let display_remotes = self.display_remotes; cx.spawn_in(window, async move |picker, cx| { let mut matches: Vec = if query.is_empty() { @@ -649,7 +648,6 @@ impl PickerDelegate for BranchListDelegate { !branch.is_remote() } }) - .take(RECENT_BRANCHES_COUNT) .map(|branch| Entry::Branch { branch, positions: Vec::new(), From e860252185bbefc30b1a9a051167a42c549bd6b0 Mon Sep 17 00:00:00 2001 From: Marco Mihai Condrache <52580954+marcocondrache@users.noreply.github.com> Date: Sat, 13 Dec 2025 00:01:16 +0100 Subject: [PATCH 243/621] gpui: Improve path rendering and bounds performance (#44655) --- crates/gpui/src/bounds_tree.rs | 464 +++++++++++++++++++++------------ 1 file changed, 297 insertions(+), 167 deletions(-) diff --git a/crates/gpui/src/bounds_tree.rs b/crates/gpui/src/bounds_tree.rs index d621609bf7334801059513e03dfd11b4036ea816..9cf86a2cc9b6def8fbf5ca7e94f7cd19236468cc 100644 --- a/crates/gpui/src/bounds_tree.rs +++ b/crates/gpui/src/bounds_tree.rs @@ -5,14 +5,91 @@ use std::{ ops::{Add, Sub}, }; +/// Maximum children per internal node (R-tree style branching factor). +/// Higher values = shorter tree = fewer cache misses, but more work per node. +const MAX_CHILDREN: usize = 12; + +/// A spatial tree optimized for finding maximum ordering among intersecting bounds. +/// +/// This is an R-tree variant specifically designed for the use case of assigning +/// z-order to overlapping UI elements. Key optimizations: +/// - Tracks the leaf with global max ordering for O(1) fast-path queries +/// - Uses higher branching factor (4) for lower tree height +/// - Aggressive pruning during search based on max_order metadata #[derive(Debug)] pub(crate) struct BoundsTree where U: Clone + Debug + Default + PartialEq, { - root: Option, + /// All nodes stored contiguously for cache efficiency. nodes: Vec>, - stack: Vec, + /// Index of the root node, if any. + root: Option, + /// Index of the leaf with the highest ordering (for fast-path lookups). + max_leaf: Option, + /// Reusable stack for tree traversal during insertion. + insert_path: Vec, + /// Reusable stack for search operations. + search_stack: Vec, +} + +/// A node in the bounds tree. +#[derive(Debug, Clone)] +struct Node +where + U: Clone + Debug + Default + PartialEq, +{ + /// Bounding box containing this node and all descendants. + bounds: Bounds, + /// Maximum ordering value in this subtree. + max_order: u32, + /// Node-specific data. + kind: NodeKind, +} + +#[derive(Debug, Clone)] +enum NodeKind { + /// Leaf node containing actual bounds data. + Leaf { + /// The ordering assigned to this bounds. + order: u32, + }, + /// Internal node with children. + Internal { + /// Indices of child nodes (2 to MAX_CHILDREN). + children: NodeChildren, + }, +} + +/// Fixed-size array for child indices, avoiding heap allocation. +#[derive(Debug, Clone)] +struct NodeChildren { + // Keeps an invariant where the max order child is always at the end + indices: [usize; MAX_CHILDREN], + len: u8, +} + +impl NodeChildren { + fn new() -> Self { + Self { + indices: [0; MAX_CHILDREN], + len: 0, + } + } + + fn push(&mut self, index: usize) { + debug_assert!((self.len as usize) < MAX_CHILDREN); + self.indices[self.len as usize] = index; + self.len += 1; + } + + fn len(&self) -> usize { + self.len as usize + } + + fn as_slice(&self) -> &[usize] { + &self.indices[..self.len as usize] + } } impl BoundsTree @@ -26,158 +103,250 @@ where + Half + Default, { + /// Clears all nodes from the tree. pub fn clear(&mut self) { - self.root = None; self.nodes.clear(); - self.stack.clear(); + self.root = None; + self.max_leaf = None; + self.insert_path.clear(); + self.search_stack.clear(); } + /// Inserts bounds into the tree and returns its assigned ordering. + /// + /// The ordering is one greater than the maximum ordering of any + /// existing bounds that intersect with the new bounds. pub fn insert(&mut self, new_bounds: Bounds) -> u32 { - // If the tree is empty, make the root the new leaf. - let Some(mut index) = self.root else { - let new_node = self.push_leaf(new_bounds, 1); - self.root = Some(new_node); - return 1; + // Find maximum ordering among intersecting bounds + let max_intersecting = self.find_max_ordering(&new_bounds); + let ordering = max_intersecting + 1; + + // Insert the new leaf + let new_leaf_idx = self.insert_leaf(new_bounds, ordering); + + // Update max_leaf tracking + self.max_leaf = match self.max_leaf { + None => Some(new_leaf_idx), + Some(old_idx) if self.nodes[old_idx].max_order < ordering => Some(new_leaf_idx), + some => some, }; - // Search for the best place to add the new leaf based on heuristics. - let mut max_intersecting_ordering = 0; - while let Node::Internal { - left, - right, - bounds: node_bounds, - .. - } = &mut self.nodes[index] - { - let left = *left; - let right = *right; - *node_bounds = node_bounds.union(&new_bounds); - self.stack.push(index); - - // Descend to the best-fit child, based on which one would increase - // the surface area the least. This attempts to keep the tree balanced - // in terms of surface area. If there is an intersection with the other child, - // add its keys to the intersections vector. - let left_cost = new_bounds.union(self.nodes[left].bounds()).half_perimeter(); - let right_cost = new_bounds - .union(self.nodes[right].bounds()) - .half_perimeter(); - if left_cost < right_cost { - max_intersecting_ordering = - self.find_max_ordering(right, &new_bounds, max_intersecting_ordering); - index = left; - } else { - max_intersecting_ordering = - self.find_max_ordering(left, &new_bounds, max_intersecting_ordering); - index = right; + ordering + } + + /// Finds the maximum ordering among all bounds that intersect with the query. + fn find_max_ordering(&mut self, query: &Bounds) -> u32 { + let Some(root_idx) = self.root else { + return 0; + }; + + // Fast path: check if the max-ordering leaf intersects + if let Some(max_idx) = self.max_leaf { + let max_node = &self.nodes[max_idx]; + if query.intersects(&max_node.bounds) { + return max_node.max_order; } } - // We've found a leaf ('index' now refers to a leaf node). - // We'll insert a new parent node above the leaf and attach our new leaf to it. - let sibling = index; - - // Check for collision with the located leaf node - let Node::Leaf { - bounds: sibling_bounds, - order: sibling_ordering, - .. - } = &self.nodes[index] - else { - unreachable!(); - }; - if sibling_bounds.intersects(&new_bounds) { - max_intersecting_ordering = cmp::max(max_intersecting_ordering, *sibling_ordering); + // Slow path: search the tree + self.search_stack.clear(); + self.search_stack.push(root_idx); + + let mut max_found = 0u32; + + while let Some(node_idx) = self.search_stack.pop() { + let node = &self.nodes[node_idx]; + + // Pruning: skip if this subtree can't improve our result + if node.max_order <= max_found { + continue; + } + + // Spatial pruning: skip if bounds don't intersect + if !query.intersects(&node.bounds) { + continue; + } + + match &node.kind { + NodeKind::Leaf { order } => { + max_found = cmp::max(max_found, *order); + } + NodeKind::Internal { children } => { + // Children are maintained with highest max_order at the end. + // Push in forward order to highest (last) is popped first. + for &child_idx in children.as_slice() { + if self.nodes[child_idx].max_order > max_found { + self.search_stack.push(child_idx); + } + } + } + } } - let ordering = max_intersecting_ordering + 1; - let new_node = self.push_leaf(new_bounds, ordering); - let new_parent = self.push_internal(sibling, new_node); + max_found + } - // If there was an old parent, we need to update its children indices. - if let Some(old_parent) = self.stack.last().copied() { - let Node::Internal { left, right, .. } = &mut self.nodes[old_parent] else { - unreachable!(); - }; + /// Inserts a leaf node with the given bounds and ordering. + /// Returns the index of the new leaf. + fn insert_leaf(&mut self, bounds: Bounds, order: u32) -> usize { + let new_leaf_idx = self.nodes.len(); + self.nodes.push(Node { + bounds: bounds.clone(), + max_order: order, + kind: NodeKind::Leaf { order }, + }); - if *left == sibling { - *left = new_parent; + let Some(root_idx) = self.root else { + // Tree is empty, new leaf becomes root + self.root = Some(new_leaf_idx); + return new_leaf_idx; + }; + + // If root is a leaf, create internal node with both + if matches!(self.nodes[root_idx].kind, NodeKind::Leaf { .. }) { + let root_bounds = self.nodes[root_idx].bounds.clone(); + let root_order = self.nodes[root_idx].max_order; + + let mut children = NodeChildren::new(); + // Max end invariant + if order > root_order { + children.push(root_idx); + children.push(new_leaf_idx); } else { - *right = new_parent; + children.push(new_leaf_idx); + children.push(root_idx); } - } else { - // If the old parent was the root, the new parent is the new root. - self.root = Some(new_parent); + + let new_root_idx = self.nodes.len(); + self.nodes.push(Node { + bounds: root_bounds.union(&bounds), + max_order: cmp::max(root_order, order), + kind: NodeKind::Internal { children }, + }); + self.root = Some(new_root_idx); + return new_leaf_idx; } - for node_index in self.stack.drain(..).rev() { - let Node::Internal { - max_order: max_ordering, - .. - } = &mut self.nodes[node_index] - else { - unreachable!() + // Descend to find the best internal node to insert into + self.insert_path.clear(); + let mut current_idx = root_idx; + + loop { + let current = &self.nodes[current_idx]; + let NodeKind::Internal { children } = ¤t.kind else { + unreachable!("Should only traverse internal nodes"); }; - if *max_ordering >= ordering { - break; - } - *max_ordering = ordering; - } - ordering - } + self.insert_path.push(current_idx); + + // Find the best child to descend into + let mut best_child_idx = children.as_slice()[0]; + let mut best_child_pos = 0; + let mut best_cost = bounds + .union(&self.nodes[best_child_idx].bounds) + .half_perimeter(); - fn find_max_ordering(&self, index: usize, bounds: &Bounds, mut max_ordering: u32) -> u32 { - match &self.nodes[index] { - Node::Leaf { - bounds: node_bounds, - order: ordering, - .. - } => { - if bounds.intersects(node_bounds) { - max_ordering = cmp::max(*ordering, max_ordering); + for (pos, &child_idx) in children.as_slice().iter().enumerate().skip(1) { + let cost = bounds.union(&self.nodes[child_idx].bounds).half_perimeter(); + if cost < best_cost { + best_cost = cost; + best_child_idx = child_idx; + best_child_pos = pos; } } - Node::Internal { - left, - right, - bounds: node_bounds, - max_order: node_max_ordering, - .. - } => { - if bounds.intersects(node_bounds) && max_ordering < *node_max_ordering { - let left_max_ordering = self.nodes[*left].max_ordering(); - let right_max_ordering = self.nodes[*right].max_ordering(); - if left_max_ordering > right_max_ordering { - max_ordering = self.find_max_ordering(*left, bounds, max_ordering); - max_ordering = self.find_max_ordering(*right, bounds, max_ordering); + + // Check if best child is a leaf or internal + if matches!(self.nodes[best_child_idx].kind, NodeKind::Leaf { .. }) { + // Best child is a leaf. Check if current node has room for another child. + if children.len() < MAX_CHILDREN { + // Add new leaf directly to this node + let node = &mut self.nodes[current_idx]; + + if let NodeKind::Internal { children } = &mut node.kind { + children.push(new_leaf_idx); + // Swap new leaf only if it has the highest max_order + if order <= node.max_order { + let last = children.len() - 1; + children.indices.swap(last - 1, last); + } + } + + node.bounds = node.bounds.union(&bounds); + node.max_order = cmp::max(node.max_order, order); + break; + } else { + // Node is full, create new internal with [best_leaf, new_leaf] + let sibling_bounds = self.nodes[best_child_idx].bounds.clone(); + let sibling_order = self.nodes[best_child_idx].max_order; + + let mut new_children = NodeChildren::new(); + // Max end invariant + if order > sibling_order { + new_children.push(best_child_idx); + new_children.push(new_leaf_idx); } else { - max_ordering = self.find_max_ordering(*right, bounds, max_ordering); - max_ordering = self.find_max_ordering(*left, bounds, max_ordering); + new_children.push(new_leaf_idx); + new_children.push(best_child_idx); + } + + let new_internal_idx = self.nodes.len(); + let new_internal_max = cmp::max(sibling_order, order); + self.nodes.push(Node { + bounds: sibling_bounds.union(&bounds), + max_order: new_internal_max, + kind: NodeKind::Internal { + children: new_children, + }, + }); + + // Replace the leaf with the new internal in parent + let parent = &mut self.nodes[current_idx]; + if let NodeKind::Internal { children } = &mut parent.kind { + let children_len = children.len(); + + children.indices[best_child_pos] = new_internal_idx; + + // If new internal has highest max_order, swap it to the end + // to maintain sorting invariant + if new_internal_max > parent.max_order { + children.indices.swap(best_child_pos, children_len - 1); + } } + break; } + } else { + // Best child is internal, continue descent + current_idx = best_child_idx; } } - max_ordering - } - fn push_leaf(&mut self, bounds: Bounds, order: u32) -> usize { - self.nodes.push(Node::Leaf { bounds, order }); - self.nodes.len() - 1 - } + // Propagate bounds and max_order updates up the tree + let mut updated_child_idx = None; + for &node_idx in self.insert_path.iter().rev() { + let node = &mut self.nodes[node_idx]; + node.bounds = node.bounds.union(&bounds); - fn push_internal(&mut self, left: usize, right: usize) -> usize { - let left_node = &self.nodes[left]; - let right_node = &self.nodes[right]; - let new_bounds = left_node.bounds().union(right_node.bounds()); - let max_ordering = cmp::max(left_node.max_ordering(), right_node.max_ordering()); - self.nodes.push(Node::Internal { - bounds: new_bounds, - left, - right, - max_order: max_ordering, - }); - self.nodes.len() - 1 + if node.max_order < order { + node.max_order = order; + + // Swap updated child to end (skip first iteration since the invariant is already handled by previous cases) + if let Some(child_idx) = updated_child_idx { + if let NodeKind::Internal { children } = &mut node.kind { + if let Some(pos) = children.as_slice().iter().position(|&c| c == child_idx) + { + let last = children.len() - 1; + if pos != last { + children.indices.swap(pos, last); + } + } + } + } + } + + updated_child_idx = Some(node_idx); + } + + new_leaf_idx } } @@ -187,50 +356,11 @@ where { fn default() -> Self { BoundsTree { - root: None, nodes: Vec::new(), - stack: Vec::new(), - } - } -} - -#[derive(Debug, Clone)] -enum Node -where - U: Clone + Debug + Default + PartialEq, -{ - Leaf { - bounds: Bounds, - order: u32, - }, - Internal { - left: usize, - right: usize, - bounds: Bounds, - max_order: u32, - }, -} - -impl Node -where - U: Clone + Debug + Default + PartialEq, -{ - fn bounds(&self) -> &Bounds { - match self { - Node::Leaf { bounds, .. } => bounds, - Node::Internal { bounds, .. } => bounds, - } - } - - fn max_ordering(&self) -> u32 { - match self { - Node::Leaf { - order: ordering, .. - } => *ordering, - Node::Internal { - max_order: max_ordering, - .. - } => *max_ordering, + root: None, + max_leaf: None, + insert_path: Vec::new(), + search_stack: Vec::new(), } } } From 4754422ef4563754cc3a93b7bfc6db964c3ec5bd Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Sat, 13 Dec 2025 01:38:44 +0100 Subject: [PATCH 244/621] Add angled bracket highlighting for C++ (#44735) Enables rainbow bracket highlighting for angle brackets (< >) in C++. image Release Notes: - Added rainbow bracket coloring for C++ angle brackets (`<>`) --- crates/languages/src/cpp/brackets.scm | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/languages/src/cpp/brackets.scm b/crates/languages/src/cpp/brackets.scm index 2149bddc6c9a7ec04667d03da75580b676e12a28..9eaebba332861ef716902b3827d4940b71f37221 100644 --- a/crates/languages/src/cpp/brackets.scm +++ b/crates/languages/src/cpp/brackets.scm @@ -1,5 +1,6 @@ ("(" @open ")" @close) ("[" @open "]" @close) ("{" @open "}" @close) +("<" @open ">" @close) (("\"" @open "\"" @close) (#set! rainbow.exclude)) (("'" @open "'" @close) (#set! rainbow.exclude)) From 6e0ecbcb07380a607206902dd4ab1d8da49f0ff6 Mon Sep 17 00:00:00 2001 From: Josh Ayres Date: Fri, 12 Dec 2025 16:41:31 -0800 Subject: [PATCH 245/621] docs: Use `relative_line_numbers` instead of `toggle_relative_line_numbers` (#44749) Just a small docs change With the deprecation of `toggle_relative_line_numbers` the docs should reflect that Release Notes: - N/A --- docs/src/vim.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/src/vim.md b/docs/src/vim.md index c9a0cd09f2dafb9f07a26ef07b71205f5ddbdf15..9ba1b059223f147d73398a1ec91e6d818ff92c8a 100644 --- a/docs/src/vim.md +++ b/docs/src/vim.md @@ -566,7 +566,8 @@ You can change the following settings to modify vim mode's behavior: | use_system_clipboard | Determines how system clipboard is used:
  • "always": use for all operations
  • "never": only use when explicitly specified
  • "on_yank": use for yank operations
| "always" | | use_multiline_find | deprecated | | use_smartcase_find | If `true`, `f` and `t` motions are case-insensitive when the target letter is lowercase. | false | -| toggle_relative_line_numbers | If `true`, line numbers are relative in normal mode and absolute in insert mode, giving you the best of both options. | false | +| toggle_relative_line_numbers | deprecated | false | +| relative_line_numbers | If "enabled", line numbers are relative in normal mode and absolute in insert mode, giving you the best of both options. | "disabled" | | custom_digraphs | An object that allows you to add custom digraphs. Read below for an example. | {} | | highlight_on_yank_duration | The duration of the highlight animation(in ms). Set to `0` to disable | 200 | @@ -590,7 +591,7 @@ Here's an example of these settings changed: "default_mode": "insert", "use_system_clipboard": "never", "use_smartcase_find": true, - "toggle_relative_line_numbers": true, + "relative_line_numbers": "enabled", "highlight_on_yank_duration": 50, "custom_digraphs": { "fz": "🧟‍♀️" From 56daba28d40301ee4c05546fadb691d070b7b2b6 Mon Sep 17 00:00:00 2001 From: Michael Benfield Date: Fri, 12 Dec 2025 16:56:06 -0800 Subject: [PATCH 246/621] supports_streaming_tools member (#44753) Release Notes: - N/A --- crates/cloud_llm_client/src/cloud_llm_client.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/cloud_llm_client/src/cloud_llm_client.rs b/crates/cloud_llm_client/src/cloud_llm_client.rs index 917929a985c85610b907e682792e132cb84d8403..2c5b2649000bb071b9d206d9d2c204f1eea9bda1 100644 --- a/crates/cloud_llm_client/src/cloud_llm_client.rs +++ b/crates/cloud_llm_client/src/cloud_llm_client.rs @@ -371,6 +371,8 @@ pub struct LanguageModel { pub supports_images: bool, pub supports_thinking: bool, pub supports_max_mode: bool, + #[serde(default)] + pub supports_streaming_tools: bool, // only used by OpenAI and xAI #[serde(default)] pub supports_parallel_tool_calls: bool, From 0283bfb04949295086b5ce6c892defa9c3ecc008 Mon Sep 17 00:00:00 2001 From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Date: Sat, 13 Dec 2025 13:06:30 -0300 Subject: [PATCH 247/621] Enable configuring edit prediction providers through the settings UI (#44505) - Edit prediction providers can now be configured through the settings UI - Cleaned up the status bar menu to only show _configured_ providers - Added to the status bar icon button tooltip the name of the active provider - Only display the data collection functionality under "Privacy" for the Zed models - Moved the Codestral edit prediction provider out of the Mistral section in the agent panel into the settings UI - Refined and improved UI and states for configuring GitHub Copilot as both an agent and edit prediction provider #### Todos before merge: - [x] UI: Unify with settings UI style and tidy it all up - [x] Unify Copilot modal `impl`s to use separate window - [x] Remove stop light icons from GitHub modal - [x] Make dismiss events work on GitHub modal - [ ] Investigate workarounds to tell if Copilot authenticated even when LSP not running Release Notes: - settings_ui: Added a section for configuring edit prediction providers under AI > Edit Predictions, including Codestral and GitHub Copilot. Once you've updated you can use the following link to open it: zed://settings/edit_predictions.providers --------- Co-authored-by: Ben Kunkle --- Cargo.lock | 8 +- assets/settings/default.json | 5 +- crates/agent_ui/src/agent_configuration.rs | 6 +- crates/copilot/src/copilot.rs | 57 +- crates/copilot/src/sign_in.rs | 660 +++++++++++++----- crates/edit_prediction/Cargo.toml | 1 - crates/edit_prediction/src/edit_prediction.rs | 19 +- crates/edit_prediction/src/mercury.rs | 82 +-- crates/edit_prediction/src/sweep_ai.rs | 73 +- .../src/zed_edit_prediction_delegate.rs | 2 +- crates/edit_prediction_ui/Cargo.toml | 3 +- .../src/edit_prediction_button.rs | 520 ++++++-------- .../src/edit_prediction_ui.rs | 2 - .../src/external_provider_api_token_modal.rs | 86 --- crates/language_model/Cargo.toml | 2 + .../src/api_key.rs | 21 +- crates/language_model/src/language_model.rs | 3 + crates/language_models/Cargo.toml | 1 - crates/language_models/src/language_models.rs | 2 - .../language_models/src/provider/anthropic.rs | 49 +- .../language_models/src/provider/bedrock.rs | 51 +- .../src/provider/copilot_chat.rs | 109 +-- .../language_models/src/provider/deepseek.rs | 49 +- crates/language_models/src/provider/google.rs | 43 +- .../language_models/src/provider/lmstudio.rs | 13 +- .../language_models/src/provider/mistral.rs | 236 ++----- crates/language_models/src/provider/ollama.rs | 49 +- .../language_models/src/provider/open_ai.rs | 56 +- .../src/provider/open_ai_compatible.rs | 28 +- .../src/provider/open_router.rs | 48 +- crates/language_models/src/provider/vercel.rs | 50 +- crates/language_models/src/provider/x_ai.rs | 51 +- crates/language_models/src/ui.rs | 4 - .../src/ui/instruction_list_item.rs | 69 -- .../settings/src/settings_content/language.rs | 4 +- crates/settings_ui/Cargo.toml | 5 +- crates/settings_ui/src/components.rs | 2 + .../settings_ui/src/components/input_field.rs | 1 + .../src/components/section_items.rs | 56 ++ crates/settings_ui/src/page_data.rs | 60 +- crates/settings_ui/src/pages.rs | 2 + .../pages/edit_prediction_provider_setup.rs | 365 ++++++++++ crates/settings_ui/src/settings_ui.rs | 222 +++--- crates/ui/src/components.rs | 4 + crates/ui/src/components/ai.rs | 3 + .../src/components/ai}/configured_api_card.rs | 17 +- .../ai/copilot_configuration_callout.rs | 0 crates/ui/src/components/button.rs | 2 + .../ui/src/components/button/button_link.rs | 102 +++ crates/ui/src/components/divider.rs | 18 +- crates/ui/src/components/inline_code.rs | 64 ++ crates/ui/src/components/label/label_like.rs | 2 +- .../src/components/list/list_bullet_item.rs | 88 ++- crates/workspace/src/notifications.rs | 2 +- crates/zed_env_vars/src/zed_env_vars.rs | 5 +- 55 files changed, 1907 insertions(+), 1575 deletions(-) delete mode 100644 crates/edit_prediction_ui/src/external_provider_api_token_modal.rs rename crates/{language_models => language_model}/src/api_key.rs (95%) delete mode 100644 crates/language_models/src/ui.rs delete mode 100644 crates/language_models/src/ui/instruction_list_item.rs create mode 100644 crates/settings_ui/src/components/section_items.rs create mode 100644 crates/settings_ui/src/pages.rs create mode 100644 crates/settings_ui/src/pages/edit_prediction_provider_setup.rs create mode 100644 crates/ui/src/components/ai.rs rename crates/{language_models/src/ui => ui/src/components/ai}/configured_api_card.rs (84%) create mode 100644 crates/ui/src/components/ai/copilot_configuration_callout.rs create mode 100644 crates/ui/src/components/button/button_link.rs create mode 100644 crates/ui/src/components/inline_code.rs diff --git a/Cargo.lock b/Cargo.lock index 981f59cb5eae413f165fdee7e8cce7c827b8c25c..cc7f8b0a85fd21dd7cae57e1ffc5348d70defbed 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5111,7 +5111,6 @@ dependencies = [ "cloud_llm_client", "collections", "copilot", - "credentials_provider", "ctor", "db", "edit_prediction_context", @@ -5275,7 +5274,6 @@ dependencies = [ "text", "theme", "ui", - "ui_input", "util", "workspace", "zed_actions", @@ -8802,6 +8800,7 @@ dependencies = [ "cloud_api_types", "cloud_llm_client", "collections", + "credentials_provider", "futures 0.3.31", "gpui", "http_client", @@ -8820,6 +8819,7 @@ dependencies = [ "telemetry_events", "thiserror 2.0.17", "util", + "zed_env_vars", ] [[package]] @@ -8876,7 +8876,6 @@ dependencies = [ "util", "vercel", "x_ai", - "zed_env_vars", ] [[package]] @@ -14778,6 +14777,8 @@ dependencies = [ "assets", "bm25", "client", + "copilot", + "edit_prediction", "editor", "feature_flags", "fs", @@ -14786,6 +14787,7 @@ dependencies = [ "gpui", "heck 0.5.0", "language", + "language_models", "log", "menu", "node_runtime", diff --git a/assets/settings/default.json b/assets/settings/default.json index 2eea3c34c6be3f34b5db9d5849b9070c5cfc7963..58564138227f361e5432d377358b18734f250d72 100644 --- a/assets/settings/default.json +++ b/assets/settings/default.json @@ -1410,8 +1410,9 @@ "proxy_no_verify": null, }, "codestral": { - "model": null, - "max_tokens": null, + "api_url": "https://codestral.mistral.ai", + "model": "codestral-latest", + "max_tokens": 150, }, // Whether edit predictions are enabled when editing text threads in the agent panel. // This setting has no effect if globally disabled. diff --git a/crates/agent_ui/src/agent_configuration.rs b/crates/agent_ui/src/agent_configuration.rs index 327f699b4dbf5512a60637d8fce2edfba75280f0..8619b085c00268d6d157dee37411ff36ba4d5680 100644 --- a/crates/agent_ui/src/agent_configuration.rs +++ b/crates/agent_ui/src/agent_configuration.rs @@ -34,9 +34,9 @@ use project::{ }; use settings::{Settings, SettingsStore, update_settings_file}; use ui::{ - Button, ButtonStyle, Chip, CommonAnimationExt, ContextMenu, ContextMenuEntry, Disclosure, - Divider, DividerColor, ElevationIndex, IconName, IconPosition, IconSize, Indicator, LabelSize, - PopoverMenu, Switch, Tooltip, WithScrollbar, prelude::*, + ButtonStyle, Chip, CommonAnimationExt, ContextMenu, ContextMenuEntry, Disclosure, Divider, + DividerColor, ElevationIndex, Indicator, LabelSize, PopoverMenu, Switch, Tooltip, + WithScrollbar, prelude::*, }; use util::ResultExt as _; use workspace::{Workspace, create_and_open_local_file}; diff --git a/crates/copilot/src/copilot.rs b/crates/copilot/src/copilot.rs index 4e6520906074c1384a4e500d89be43659c162718..45f0796bf53acfef1fb1e81146c0de7c5187fb99 100644 --- a/crates/copilot/src/copilot.rs +++ b/crates/copilot/src/copilot.rs @@ -4,7 +4,7 @@ pub mod copilot_responses; pub mod request; mod sign_in; -use crate::sign_in::initiate_sign_in_within_workspace; +use crate::sign_in::initiate_sign_out; use ::fs::Fs; use anyhow::{Context as _, Result, anyhow}; use collections::{HashMap, HashSet}; @@ -28,12 +28,10 @@ use project::DisableAiSettings; use request::StatusNotification; use semver::Version; use serde_json::json; -use settings::Settings; -use settings::SettingsStore; -use sign_in::{reinstall_and_sign_in_within_workspace, sign_out_within_workspace}; -use std::collections::hash_map::Entry; +use settings::{Settings, SettingsStore}; use std::{ any::TypeId, + collections::hash_map::Entry, env, ffi::OsString, mem, @@ -42,12 +40,14 @@ use std::{ sync::Arc, }; use sum_tree::Dimensions; -use util::rel_path::RelPath; -use util::{ResultExt, fs::remove_matching}; +use util::{ResultExt, fs::remove_matching, rel_path::RelPath}; use workspace::Workspace; pub use crate::copilot_edit_prediction_delegate::CopilotEditPredictionDelegate; -pub use crate::sign_in::{CopilotCodeVerification, initiate_sign_in, reinstall_and_sign_in}; +pub use crate::sign_in::{ + ConfigurationMode, ConfigurationView, CopilotCodeVerification, initiate_sign_in, + reinstall_and_sign_in, +}; actions!( copilot, @@ -98,21 +98,14 @@ pub fn init( .detach(); cx.observe_new(|workspace: &mut Workspace, _window, _cx| { - workspace.register_action(|workspace, _: &SignIn, window, cx| { - if let Some(copilot) = Copilot::global(cx) { - let is_reinstall = false; - initiate_sign_in_within_workspace(workspace, copilot, is_reinstall, window, cx); - } + workspace.register_action(|_, _: &SignIn, window, cx| { + initiate_sign_in(window, cx); }); - workspace.register_action(|workspace, _: &Reinstall, window, cx| { - if let Some(copilot) = Copilot::global(cx) { - reinstall_and_sign_in_within_workspace(workspace, copilot, window, cx); - } + workspace.register_action(|_, _: &Reinstall, window, cx| { + reinstall_and_sign_in(window, cx); }); - workspace.register_action(|workspace, _: &SignOut, _window, cx| { - if let Some(copilot) = Copilot::global(cx) { - sign_out_within_workspace(workspace, copilot, cx); - } + workspace.register_action(|_, _: &SignOut, window, cx| { + initiate_sign_out(window, cx); }); }) .detach(); @@ -375,7 +368,7 @@ impl Copilot { } } - fn start_copilot( + pub fn start_copilot( &mut self, check_edit_prediction_provider: bool, awaiting_sign_in_after_start: bool, @@ -563,6 +556,14 @@ impl Copilot { let server = start_language_server.await; this.update(cx, |this, cx| { cx.notify(); + + if env::var("ZED_FORCE_COPILOT_ERROR").is_ok() { + this.server = CopilotServer::Error( + "Forced error for testing (ZED_FORCE_COPILOT_ERROR)".into(), + ); + return; + } + match server { Ok((server, status)) => { this.server = CopilotServer::Running(RunningCopilotServer { @@ -584,7 +585,17 @@ impl Copilot { .ok(); } - pub(crate) fn sign_in(&mut self, cx: &mut Context) -> Task> { + pub fn is_authenticated(&self) -> bool { + return matches!( + self.server, + CopilotServer::Running(RunningCopilotServer { + sign_in_status: SignInStatus::Authorized, + .. + }) + ); + } + + pub fn sign_in(&mut self, cx: &mut Context) -> Task> { if let CopilotServer::Running(server) = &mut self.server { let task = match &server.sign_in_status { SignInStatus::Authorized => Task::ready(Ok(())).shared(), diff --git a/crates/copilot/src/sign_in.rs b/crates/copilot/src/sign_in.rs index 464a114d4ea11bca5597a6a91fd831ade050baaa..0bcb11e18be1994ea92703973ad1278c5d5aa4f8 100644 --- a/crates/copilot/src/sign_in.rs +++ b/crates/copilot/src/sign_in.rs @@ -1,160 +1,151 @@ use crate::{Copilot, Status, request::PromptUserDeviceFlow}; +use anyhow::Context as _; use gpui::{ - Animation, AnimationExt, App, ClipboardItem, Context, DismissEvent, Element, Entity, - EventEmitter, FocusHandle, Focusable, InteractiveElement, IntoElement, MouseDownEvent, - ParentElement, Render, Styled, Subscription, Transformation, Window, div, percentage, svg, + App, ClipboardItem, Context, DismissEvent, Element, Entity, EventEmitter, FocusHandle, + Focusable, InteractiveElement, IntoElement, MouseDownEvent, ParentElement, Render, Styled, + Subscription, Window, WindowBounds, WindowOptions, div, point, }; -use std::time::Duration; -use ui::{Button, Label, Vector, VectorName, prelude::*}; +use ui::{ButtonLike, CommonAnimationExt, ConfiguredApiCard, Vector, VectorName, prelude::*}; use util::ResultExt as _; -use workspace::notifications::NotificationId; -use workspace::{ModalView, Toast, Workspace}; +use workspace::{Toast, Workspace, notifications::NotificationId}; const COPILOT_SIGN_UP_URL: &str = "https://github.com/features/copilot"; +const ERROR_LABEL: &str = + "Copilot had issues starting. You can try reinstalling it and signing in again."; struct CopilotStatusToast; pub fn initiate_sign_in(window: &mut Window, cx: &mut App) { + let is_reinstall = false; + initiate_sign_in_impl(is_reinstall, window, cx) +} + +pub fn initiate_sign_out(window: &mut Window, cx: &mut App) { let Some(copilot) = Copilot::global(cx) else { return; }; - let Some(workspace) = window.root::().flatten() else { - return; - }; - workspace.update(cx, |workspace, cx| { - let is_reinstall = false; - initiate_sign_in_within_workspace(workspace, copilot, is_reinstall, window, cx) - }); + + copilot_toast(Some("Signing out of Copilot…"), window, cx); + + let sign_out_task = copilot.update(cx, |copilot, cx| copilot.sign_out(cx)); + window + .spawn(cx, async move |cx| match sign_out_task.await { + Ok(()) => { + cx.update(|window, cx| copilot_toast(Some("Signed out of Copilot"), window, cx)) + } + Err(err) => cx.update(|window, cx| { + if let Some(workspace) = window.root::().flatten() { + workspace.update(cx, |workspace, cx| { + workspace.show_error(&err, cx); + }) + } else { + log::error!("{:?}", err); + } + }), + }) + .detach(); } pub fn reinstall_and_sign_in(window: &mut Window, cx: &mut App) { let Some(copilot) = Copilot::global(cx) else { return; }; + let _ = copilot.update(cx, |copilot, cx| copilot.reinstall(cx)); + let is_reinstall = true; + initiate_sign_in_impl(is_reinstall, window, cx); +} + +fn open_copilot_code_verification_window(copilot: &Entity, window: &Window, cx: &mut App) { + let current_window_center = window.bounds().center(); + let height = px(450.); + let width = px(350.); + let window_bounds = WindowBounds::Windowed(gpui::bounds( + current_window_center - point(height / 2.0, width / 2.0), + gpui::size(height, width), + )); + cx.open_window( + WindowOptions { + kind: gpui::WindowKind::PopUp, + window_bounds: Some(window_bounds), + is_resizable: false, + is_movable: true, + titlebar: Some(gpui::TitlebarOptions { + appears_transparent: true, + ..Default::default() + }), + ..Default::default() + }, + |window, cx| cx.new(|cx| CopilotCodeVerification::new(&copilot, window, cx)), + ) + .context("Failed to open Copilot code verification window") + .log_err(); +} + +fn copilot_toast(message: Option<&'static str>, window: &Window, cx: &mut App) { + const NOTIFICATION_ID: NotificationId = NotificationId::unique::(); + let Some(workspace) = window.root::().flatten() else { return; }; - workspace.update(cx, |workspace, cx| { - reinstall_and_sign_in_within_workspace(workspace, copilot, window, cx); - }); -} -pub fn reinstall_and_sign_in_within_workspace( - workspace: &mut Workspace, - copilot: Entity, - window: &mut Window, - cx: &mut Context, -) { - let _ = copilot.update(cx, |copilot, cx| copilot.reinstall(cx)); - let is_reinstall = true; - initiate_sign_in_within_workspace(workspace, copilot, is_reinstall, window, cx); + workspace.update(cx, |workspace, cx| match message { + Some(message) => workspace.show_toast(Toast::new(NOTIFICATION_ID, message), cx), + None => workspace.dismiss_toast(&NOTIFICATION_ID, cx), + }); } -pub fn initiate_sign_in_within_workspace( - workspace: &mut Workspace, - copilot: Entity, - is_reinstall: bool, - window: &mut Window, - cx: &mut Context, -) { +pub fn initiate_sign_in_impl(is_reinstall: bool, window: &mut Window, cx: &mut App) { + let Some(copilot) = Copilot::global(cx) else { + return; + }; if matches!(copilot.read(cx).status(), Status::Disabled) { copilot.update(cx, |copilot, cx| copilot.start_copilot(false, true, cx)); } match copilot.read(cx).status() { Status::Starting { task } => { - workspace.show_toast( - Toast::new( - NotificationId::unique::(), - if is_reinstall { - "Copilot is reinstalling..." - } else { - "Copilot is starting..." - }, - ), + copilot_toast( + Some(if is_reinstall { + "Copilot is reinstalling…" + } else { + "Copilot is starting…" + }), + window, cx, ); - cx.spawn_in(window, async move |workspace, cx| { - task.await; - if let Some(copilot) = cx.update(|_window, cx| Copilot::global(cx)).ok().flatten() { - workspace - .update_in(cx, |workspace, window, cx| { - match copilot.read(cx).status() { - Status::Authorized => workspace.show_toast( - Toast::new( - NotificationId::unique::(), - "Copilot has started.", - ), - cx, - ), - _ => { - workspace.dismiss_toast( - &NotificationId::unique::(), - cx, - ); - copilot - .update(cx, |copilot, cx| copilot.sign_in(cx)) - .detach_and_log_err(cx); - workspace.toggle_modal(window, cx, |_, cx| { - CopilotCodeVerification::new(&copilot, cx) - }); - } + window + .spawn(cx, async move |cx| { + task.await; + cx.update(|window, cx| { + let Some(copilot) = Copilot::global(cx) else { + return; + }; + match copilot.read(cx).status() { + Status::Authorized => { + copilot_toast(Some("Copilot has started."), window, cx) } - }) - .log_err(); - } - }) - .detach(); + _ => { + copilot_toast(None, window, cx); + copilot + .update(cx, |copilot, cx| copilot.sign_in(cx)) + .detach_and_log_err(cx); + open_copilot_code_verification_window(&copilot, window, cx); + } + } + }) + .log_err(); + }) + .detach(); } _ => { copilot .update(cx, |copilot, cx| copilot.sign_in(cx)) .detach(); - workspace.toggle_modal(window, cx, |_, cx| { - CopilotCodeVerification::new(&copilot, cx) - }); + open_copilot_code_verification_window(&copilot, window, cx); } } } -pub fn sign_out_within_workspace( - workspace: &mut Workspace, - copilot: Entity, - cx: &mut Context, -) { - workspace.show_toast( - Toast::new( - NotificationId::unique::(), - "Signing out of Copilot...", - ), - cx, - ); - let sign_out_task = copilot.update(cx, |copilot, cx| copilot.sign_out(cx)); - cx.spawn(async move |workspace, cx| match sign_out_task.await { - Ok(()) => { - workspace - .update(cx, |workspace, cx| { - workspace.show_toast( - Toast::new( - NotificationId::unique::(), - "Signed out of Copilot.", - ), - cx, - ) - }) - .ok(); - } - Err(err) => { - workspace - .update(cx, |workspace, cx| { - workspace.show_error(&err, cx); - }) - .ok(); - } - }) - .detach(); -} - pub struct CopilotCodeVerification { status: Status, connect_clicked: bool, @@ -170,23 +161,27 @@ impl Focusable for CopilotCodeVerification { } impl EventEmitter for CopilotCodeVerification {} -impl ModalView for CopilotCodeVerification { - fn on_before_dismiss( - &mut self, - _: &mut Window, - cx: &mut Context, - ) -> workspace::DismissDecision { - self.copilot.update(cx, |copilot, cx| { - if matches!(copilot.status(), Status::SigningIn { .. }) { - copilot.sign_out(cx).detach_and_log_err(cx); + +impl CopilotCodeVerification { + pub fn new(copilot: &Entity, window: &mut Window, cx: &mut Context) -> Self { + window.on_window_should_close(cx, |window, cx| { + if let Some(this) = window.root::().flatten() { + this.update(cx, |this, cx| { + this.before_dismiss(cx); + }); } + true }); - workspace::DismissDecision::Dismiss(true) - } -} + cx.subscribe_in( + &cx.entity(), + window, + |this, _, _: &DismissEvent, window, cx| { + window.remove_window(); + this.before_dismiss(cx); + }, + ) + .detach(); -impl CopilotCodeVerification { - pub fn new(copilot: &Entity, cx: &mut Context) -> Self { let status = copilot.read(cx).status(); Self { status, @@ -215,45 +210,45 @@ impl CopilotCodeVerification { .read_from_clipboard() .map(|item| item.text().as_ref() == Some(&data.user_code)) .unwrap_or(false); - h_flex() - .w_full() - .p_1() - .border_1() - .border_muted(cx) - .rounded_sm() - .cursor_pointer() - .justify_between() - .on_mouse_down(gpui::MouseButton::Left, { + + ButtonLike::new("copy-button") + .full_width() + .style(ButtonStyle::Tinted(ui::TintColor::Accent)) + .size(ButtonSize::Medium) + .child( + h_flex() + .w_full() + .p_1() + .justify_between() + .child(Label::new(data.user_code.clone())) + .child(Label::new(if copied { "Copied!" } else { "Copy" })), + ) + .on_click({ let user_code = data.user_code.clone(); move |_, window, cx| { cx.write_to_clipboard(ClipboardItem::new_string(user_code.clone())); window.refresh(); } }) - .child(div().flex_1().child(Label::new(data.user_code.clone()))) - .child(div().flex_none().px_1().child(Label::new(if copied { - "Copied!" - } else { - "Copy" - }))) } fn render_prompting_modal( connect_clicked: bool, data: &PromptUserDeviceFlow, - cx: &mut Context, ) -> impl Element { let connect_button_label = if connect_clicked { - "Waiting for connection..." + "Waiting for connection…" } else { "Connect to GitHub" }; + v_flex() .flex_1() - .gap_2() + .gap_2p5() .items_center() - .child(Headline::new("Use GitHub Copilot in Zed.").size(HeadlineSize::Large)) + .text_center() + .child(Headline::new("Use GitHub Copilot in Zed").size(HeadlineSize::Large)) .child( Label::new("Using Copilot requires an active subscription on GitHub.") .color(Color::Muted), @@ -261,83 +256,119 @@ impl CopilotCodeVerification { .child(Self::render_device_code(data, cx)) .child( Label::new("Paste this code into GitHub after clicking the button below.") - .size(ui::LabelSize::Small), - ) - .child( - Button::new("connect-button", connect_button_label) - .on_click({ - let verification_uri = data.verification_uri.clone(); - cx.listener(move |this, _, _window, cx| { - cx.open_url(&verification_uri); - this.connect_clicked = true; - }) - }) - .full_width() - .style(ButtonStyle::Filled), + .color(Color::Muted), ) .child( - Button::new("copilot-enable-cancel-button", "Cancel") - .full_width() - .on_click(cx.listener(|_, _, _, cx| { - cx.emit(DismissEvent); - })), + v_flex() + .w_full() + .gap_1() + .child( + Button::new("connect-button", connect_button_label) + .full_width() + .style(ButtonStyle::Outlined) + .size(ButtonSize::Medium) + .on_click({ + let verification_uri = data.verification_uri.clone(); + cx.listener(move |this, _, _window, cx| { + cx.open_url(&verification_uri); + this.connect_clicked = true; + }) + }), + ) + .child( + Button::new("copilot-enable-cancel-button", "Cancel") + .full_width() + .size(ButtonSize::Medium) + .on_click(cx.listener(|_, _, _, cx| { + cx.emit(DismissEvent); + })), + ), ) } fn render_enabled_modal(cx: &mut Context) -> impl Element { v_flex() .gap_2() + .text_center() + .justify_center() .child(Headline::new("Copilot Enabled!").size(HeadlineSize::Large)) - .child(Label::new( - "You can update your settings or sign out from the Copilot menu in the status bar.", - )) + .child(Label::new("You're all set to use GitHub Copilot.").color(Color::Muted)) .child( Button::new("copilot-enabled-done-button", "Done") .full_width() + .style(ButtonStyle::Outlined) + .size(ButtonSize::Medium) .on_click(cx.listener(|_, _, _, cx| cx.emit(DismissEvent))), ) } fn render_unauthorized_modal(cx: &mut Context) -> impl Element { - v_flex() - .child(Headline::new("You must have an active GitHub Copilot subscription.").size(HeadlineSize::Large)) + let description = "Enable Copilot by connecting your existing license once you have subscribed or renewed your subscription."; - .child(Label::new( - "You can enable Copilot by connecting your existing license once you have subscribed or renewed your subscription.", - ).color(Color::Warning)) + v_flex() + .gap_2() + .text_center() + .justify_center() + .child( + Headline::new("You must have an active GitHub Copilot subscription.") + .size(HeadlineSize::Large), + ) + .child(Label::new(description).color(Color::Warning)) .child( Button::new("copilot-subscribe-button", "Subscribe on GitHub") .full_width() + .style(ButtonStyle::Outlined) + .size(ButtonSize::Medium) .on_click(|_, _, cx| cx.open_url(COPILOT_SIGN_UP_URL)), ) .child( Button::new("copilot-subscribe-cancel-button", "Cancel") .full_width() + .size(ButtonSize::Medium) .on_click(cx.listener(|_, _, _, cx| cx.emit(DismissEvent))), ) } - fn render_loading(window: &mut Window, _: &mut Context) -> impl Element { - let loading_icon = svg() - .size_8() - .path(IconName::ArrowCircle.path()) - .text_color(window.text_style().color) - .with_animation( - "icon_circle_arrow", - Animation::new(Duration::from_secs(2)).repeat(), - |svg, delta| svg.with_transformation(Transformation::rotate(percentage(delta))), - ); + fn render_error_modal(_cx: &mut Context) -> impl Element { + v_flex() + .gap_2() + .text_center() + .justify_center() + .child(Headline::new("An Error Happened").size(HeadlineSize::Large)) + .child(Label::new(ERROR_LABEL).color(Color::Muted)) + .child( + Button::new("copilot-subscribe-button", "Reinstall Copilot and Sign In") + .full_width() + .style(ButtonStyle::Outlined) + .size(ButtonSize::Medium) + .icon(IconName::Download) + .icon_color(Color::Muted) + .icon_position(IconPosition::Start) + .icon_size(IconSize::Small) + .on_click(|_, window, cx| reinstall_and_sign_in(window, cx)), + ) + } - h_flex().justify_center().child(loading_icon) + fn before_dismiss( + &mut self, + cx: &mut Context<'_, CopilotCodeVerification>, + ) -> workspace::DismissDecision { + self.copilot.update(cx, |copilot, cx| { + if matches!(copilot.status(), Status::SigningIn { .. }) { + copilot.sign_out(cx).detach_and_log_err(cx); + } + }); + workspace::DismissDecision::Dismiss(true) } } impl Render for CopilotCodeVerification { - fn render(&mut self, window: &mut Window, cx: &mut Context) -> impl IntoElement { + fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { let prompt = match &self.status { - Status::SigningIn { prompt: None } => { - Self::render_loading(window, cx).into_any_element() - } + Status::SigningIn { prompt: None } => Icon::new(IconName::ArrowCircle) + .color(Color::Muted) + .with_rotate_animation(2) + .into_any_element(), Status::SigningIn { prompt: Some(prompt), } => Self::render_prompting_modal(self.connect_clicked, prompt, cx).into_any_element(), @@ -349,17 +380,20 @@ impl Render for CopilotCodeVerification { self.connect_clicked = false; Self::render_enabled_modal(cx).into_any_element() } + Status::Error(..) => Self::render_error_modal(cx).into_any_element(), _ => div().into_any_element(), }; v_flex() - .id("copilot code verification") + .id("copilot_code_verification") .track_focus(&self.focus_handle(cx)) - .elevation_3(cx) - .w_96() - .items_center() - .p_4() + .size_full() + .px_4() + .py_8() .gap_2() + .items_center() + .justify_center() + .elevation_3(cx) .on_action(cx.listener(|_, _: &menu::Cancel, _, cx| { cx.emit(DismissEvent); })) @@ -373,3 +407,243 @@ impl Render for CopilotCodeVerification { .child(prompt) } } + +pub struct ConfigurationView { + copilot_status: Option, + is_authenticated: fn(cx: &App) -> bool, + edit_prediction: bool, + _subscription: Option, +} + +pub enum ConfigurationMode { + Chat, + EditPrediction, +} + +impl ConfigurationView { + pub fn new( + is_authenticated: fn(cx: &App) -> bool, + mode: ConfigurationMode, + cx: &mut Context, + ) -> Self { + let copilot = Copilot::global(cx); + + Self { + copilot_status: copilot.as_ref().map(|copilot| copilot.read(cx).status()), + is_authenticated, + edit_prediction: matches!(mode, ConfigurationMode::EditPrediction), + _subscription: copilot.as_ref().map(|copilot| { + cx.observe(copilot, |this, model, cx| { + this.copilot_status = Some(model.read(cx).status()); + cx.notify(); + }) + }), + } + } +} + +impl ConfigurationView { + fn is_starting(&self) -> bool { + matches!(&self.copilot_status, Some(Status::Starting { .. })) + } + + fn is_signing_in(&self) -> bool { + matches!( + &self.copilot_status, + Some(Status::SigningIn { .. }) + | Some(Status::SignedOut { + awaiting_signing_in: true + }) + ) + } + + fn is_error(&self) -> bool { + matches!(&self.copilot_status, Some(Status::Error(_))) + } + + fn has_no_status(&self) -> bool { + self.copilot_status.is_none() + } + + fn loading_message(&self) -> Option { + if self.is_starting() { + Some("Starting Copilot…".into()) + } else if self.is_signing_in() { + Some("Signing into Copilot…".into()) + } else { + None + } + } + + fn render_loading_button( + &self, + label: impl Into, + edit_prediction: bool, + ) -> impl IntoElement { + ButtonLike::new("loading_button") + .disabled(true) + .style(ButtonStyle::Outlined) + .when(edit_prediction, |this| this.size(ButtonSize::Medium)) + .child( + h_flex() + .w_full() + .gap_1() + .justify_center() + .child( + Icon::new(IconName::ArrowCircle) + .size(IconSize::Small) + .color(Color::Muted) + .with_rotate_animation(4), + ) + .child(Label::new(label)), + ) + } + + fn render_sign_in_button(&self, edit_prediction: bool) -> impl IntoElement { + let label = if edit_prediction { + "Sign in to GitHub" + } else { + "Sign in to use GitHub Copilot" + }; + + Button::new("sign_in", label) + .map(|this| { + if edit_prediction { + this.size(ButtonSize::Medium) + } else { + this.full_width() + } + }) + .style(ButtonStyle::Outlined) + .icon(IconName::Github) + .icon_color(Color::Muted) + .icon_position(IconPosition::Start) + .icon_size(IconSize::Small) + .on_click(|_, window, cx| initiate_sign_in(window, cx)) + } + + fn render_reinstall_button(&self, edit_prediction: bool) -> impl IntoElement { + let label = if edit_prediction { + "Reinstall and Sign in" + } else { + "Reinstall Copilot and Sign in" + }; + + Button::new("reinstall_and_sign_in", label) + .map(|this| { + if edit_prediction { + this.size(ButtonSize::Medium) + } else { + this.full_width() + } + }) + .style(ButtonStyle::Outlined) + .icon(IconName::Download) + .icon_color(Color::Muted) + .icon_position(IconPosition::Start) + .icon_size(IconSize::Small) + .on_click(|_, window, cx| reinstall_and_sign_in(window, cx)) + } + + fn render_for_edit_prediction(&self) -> impl IntoElement { + let container = |description: SharedString, action: AnyElement| { + h_flex() + .pt_2p5() + .w_full() + .justify_between() + .child( + v_flex() + .w_full() + .max_w_1_2() + .child(Label::new("Authenticate To Use")) + .child( + Label::new(description) + .color(Color::Muted) + .size(LabelSize::Small), + ), + ) + .child(action) + }; + + let start_label = "To use Copilot for edit predictions, you need to be logged in to GitHub. Note that your GitHub account must have an active Copilot subscription.".into(); + let no_status_label = "Copilot requires an active GitHub Copilot subscription. Please ensure Copilot is configured and try again, or use a different edit predictions provider.".into(); + + if let Some(msg) = self.loading_message() { + container( + start_label, + self.render_loading_button(msg, true).into_any_element(), + ) + .into_any_element() + } else if self.is_error() { + container( + ERROR_LABEL.into(), + self.render_reinstall_button(true).into_any_element(), + ) + .into_any_element() + } else if self.has_no_status() { + container( + no_status_label, + self.render_sign_in_button(true).into_any_element(), + ) + .into_any_element() + } else { + container( + start_label, + self.render_sign_in_button(true).into_any_element(), + ) + .into_any_element() + } + } + + fn render_for_chat(&self) -> impl IntoElement { + let start_label = "To use Zed's agent with GitHub Copilot, you need to be logged in to GitHub. Note that your GitHub account must have an active Copilot Chat subscription."; + let no_status_label = "Copilot Chat requires an active GitHub Copilot subscription. Please ensure Copilot is configured and try again, or use a different LLM provider."; + + if let Some(msg) = self.loading_message() { + v_flex() + .gap_2() + .child(Label::new(start_label)) + .child(self.render_loading_button(msg, false)) + .into_any_element() + } else if self.is_error() { + v_flex() + .gap_2() + .child(Label::new(ERROR_LABEL)) + .child(self.render_reinstall_button(false)) + .into_any_element() + } else if self.has_no_status() { + v_flex() + .gap_2() + .child(Label::new(no_status_label)) + .child(self.render_sign_in_button(false)) + .into_any_element() + } else { + v_flex() + .gap_2() + .child(Label::new(start_label)) + .child(self.render_sign_in_button(false)) + .into_any_element() + } + } +} + +impl Render for ConfigurationView { + fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { + let is_authenticated = self.is_authenticated; + + if is_authenticated(cx) { + return ConfiguredApiCard::new("Authorized") + .button_label("Sign Out") + .on_click(|_, window, cx| { + initiate_sign_out(window, cx); + }) + .into_any_element(); + } + + if self.edit_prediction { + self.render_for_edit_prediction().into_any_element() + } else { + self.render_for_chat().into_any_element() + } + } +} diff --git a/crates/edit_prediction/Cargo.toml b/crates/edit_prediction/Cargo.toml index 53ddb99bd3f458a540c6593a2b1d6b1b547e463b..5f1799e2dc4bb5460a900664472ad33e3035d4f1 100644 --- a/crates/edit_prediction/Cargo.toml +++ b/crates/edit_prediction/Cargo.toml @@ -23,7 +23,6 @@ client.workspace = true cloud_llm_client.workspace = true collections.workspace = true copilot.workspace = true -credentials_provider.workspace = true db.workspace = true edit_prediction_types.workspace = true edit_prediction_context.workspace = true diff --git a/crates/edit_prediction/src/edit_prediction.rs b/crates/edit_prediction/src/edit_prediction.rs index d9d9c2243d81640a55133843669514d551f64902..8b96466667bbac8fba92549487821f0d450670ac 100644 --- a/crates/edit_prediction/src/edit_prediction.rs +++ b/crates/edit_prediction/src/edit_prediction.rs @@ -72,6 +72,7 @@ pub use crate::prediction::EditPrediction; pub use crate::prediction::EditPredictionId; use crate::prediction::EditPredictionResult; pub use crate::sweep_ai::SweepAi; +pub use language_model::ApiKeyState; pub use telemetry_events::EditPredictionRating; pub use zed_edit_prediction_delegate::ZedEditPredictionDelegate; @@ -536,22 +537,12 @@ impl EditPredictionStore { self.edit_prediction_model = model; } - pub fn has_sweep_api_token(&self) -> bool { - self.sweep_ai - .api_token - .clone() - .now_or_never() - .flatten() - .is_some() + pub fn has_sweep_api_token(&self, cx: &App) -> bool { + self.sweep_ai.api_token.read(cx).has_key() } - pub fn has_mercury_api_token(&self) -> bool { - self.mercury - .api_token - .clone() - .now_or_never() - .flatten() - .is_some() + pub fn has_mercury_api_token(&self, cx: &App) -> bool { + self.mercury.api_token.read(cx).has_key() } #[cfg(feature = "cli-support")] diff --git a/crates/edit_prediction/src/mercury.rs b/crates/edit_prediction/src/mercury.rs index f3a3afc53fc5e175fdbda2dc6b5867da6fd38feb..ac9f8f535572dddb56ffcfde9a5f2040a65cf168 100644 --- a/crates/edit_prediction/src/mercury.rs +++ b/crates/edit_prediction/src/mercury.rs @@ -1,40 +1,34 @@ +use crate::{ + DebugEvent, EditPredictionFinishedDebugEvent, EditPredictionId, EditPredictionModelInput, + EditPredictionStartedDebugEvent, open_ai_response::text_from_response, + prediction::EditPredictionResult, +}; use anyhow::{Context as _, Result}; -use credentials_provider::CredentialsProvider; -use futures::{AsyncReadExt as _, FutureExt, future::Shared}; +use futures::AsyncReadExt as _; use gpui::{ - App, AppContext as _, Task, + App, AppContext as _, Entity, SharedString, Task, http_client::{self, AsyncBody, Method}, }; use language::{OffsetRangeExt as _, ToOffset, ToPoint as _}; +use language_model::{ApiKeyState, EnvVar, env_var}; use std::{mem, ops::Range, path::Path, sync::Arc, time::Instant}; use zeta_prompt::ZetaPromptInput; -use crate::{ - DebugEvent, EditPredictionFinishedDebugEvent, EditPredictionId, EditPredictionModelInput, - EditPredictionStartedDebugEvent, open_ai_response::text_from_response, - prediction::EditPredictionResult, -}; - const MERCURY_API_URL: &str = "https://api.inceptionlabs.ai/v1/edit/completions"; const MAX_CONTEXT_TOKENS: usize = 150; const MAX_REWRITE_TOKENS: usize = 350; pub struct Mercury { - pub api_token: Shared>>, + pub api_token: Entity, } impl Mercury { - pub fn new(cx: &App) -> Self { + pub fn new(cx: &mut App) -> Self { Mercury { - api_token: load_api_token(cx).shared(), + api_token: mercury_api_token(cx), } } - pub fn set_api_token(&mut self, api_token: Option, cx: &mut App) -> Task> { - self.api_token = Task::ready(api_token.clone()).shared(); - store_api_token_in_keychain(api_token, cx) - } - pub(crate) fn request_prediction( &self, EditPredictionModelInput { @@ -48,7 +42,10 @@ impl Mercury { }: EditPredictionModelInput, cx: &mut App, ) -> Task>> { - let Some(api_token) = self.api_token.clone().now_or_never().flatten() else { + self.api_token.update(cx, |key_state, cx| { + _ = key_state.load_if_needed(MERCURY_CREDENTIALS_URL, |s| s, cx); + }); + let Some(api_token) = self.api_token.read(cx).key(&MERCURY_CREDENTIALS_URL) else { return Task::ready(Ok(None)); }; let full_path: Arc = snapshot @@ -299,45 +296,16 @@ fn push_delimited(prompt: &mut String, delimiters: Range<&str>, cb: impl FnOnce( prompt.push_str(delimiters.end); } -pub const MERCURY_CREDENTIALS_URL: &str = "https://api.inceptionlabs.ai/v1/edit/completions"; +pub const MERCURY_CREDENTIALS_URL: SharedString = + SharedString::new_static("https://api.inceptionlabs.ai/v1/edit/completions"); pub const MERCURY_CREDENTIALS_USERNAME: &str = "mercury-api-token"; +pub static MERCURY_TOKEN_ENV_VAR: std::sync::LazyLock = env_var!("MERCURY_AI_TOKEN"); +pub static MERCURY_API_KEY: std::sync::OnceLock> = std::sync::OnceLock::new(); -pub fn load_api_token(cx: &App) -> Task> { - if let Some(api_token) = std::env::var("MERCURY_AI_TOKEN") - .ok() - .filter(|value| !value.is_empty()) - { - return Task::ready(Some(api_token)); - } - let credentials_provider = ::global(cx); - cx.spawn(async move |cx| { - let (_, credentials) = credentials_provider - .read_credentials(MERCURY_CREDENTIALS_URL, &cx) - .await - .ok()??; - String::from_utf8(credentials).ok() - }) -} - -fn store_api_token_in_keychain(api_token: Option, cx: &App) -> Task> { - let credentials_provider = ::global(cx); - - cx.spawn(async move |cx| { - if let Some(api_token) = api_token { - credentials_provider - .write_credentials( - MERCURY_CREDENTIALS_URL, - MERCURY_CREDENTIALS_USERNAME, - api_token.as_bytes(), - cx, - ) - .await - .context("Failed to save Mercury API token to system keychain") - } else { - credentials_provider - .delete_credentials(MERCURY_CREDENTIALS_URL, cx) - .await - .context("Failed to delete Mercury API token from system keychain") - } - }) +pub fn mercury_api_token(cx: &mut App) -> Entity { + MERCURY_API_KEY + .get_or_init(|| { + cx.new(|_| ApiKeyState::new(MERCURY_CREDENTIALS_URL, MERCURY_TOKEN_ENV_VAR.clone())) + }) + .clone() } diff --git a/crates/edit_prediction/src/sweep_ai.rs b/crates/edit_prediction/src/sweep_ai.rs index f65749ceadf6e05fc3b56838c03234b2f83dc51e..7d020c219b47aa8bcf6fb89e516b7f8ff93da497 100644 --- a/crates/edit_prediction/src/sweep_ai.rs +++ b/crates/edit_prediction/src/sweep_ai.rs @@ -1,11 +1,11 @@ -use anyhow::{Context as _, Result}; -use credentials_provider::CredentialsProvider; -use futures::{AsyncReadExt as _, FutureExt, future::Shared}; +use anyhow::Result; +use futures::AsyncReadExt as _; use gpui::{ - App, AppContext as _, Task, + App, AppContext as _, Entity, SharedString, Task, http_client::{self, AsyncBody, Method}, }; use language::{Point, ToOffset as _}; +use language_model::{ApiKeyState, EnvVar, env_var}; use lsp::DiagnosticSeverity; use serde::{Deserialize, Serialize}; use std::{ @@ -20,30 +20,28 @@ use crate::{EditPredictionId, EditPredictionModelInput, prediction::EditPredicti const SWEEP_API_URL: &str = "https://autocomplete.sweep.dev/backend/next_edit_autocomplete"; pub struct SweepAi { - pub api_token: Shared>>, + pub api_token: Entity, pub debug_info: Arc, } impl SweepAi { - pub fn new(cx: &App) -> Self { + pub fn new(cx: &mut App) -> Self { SweepAi { - api_token: load_api_token(cx).shared(), + api_token: sweep_api_token(cx), debug_info: debug_info(cx), } } - pub fn set_api_token(&mut self, api_token: Option, cx: &mut App) -> Task> { - self.api_token = Task::ready(api_token.clone()).shared(); - store_api_token_in_keychain(api_token, cx) - } - pub fn request_prediction_with_sweep( &self, inputs: EditPredictionModelInput, cx: &mut App, ) -> Task>> { let debug_info = self.debug_info.clone(); - let Some(api_token) = self.api_token.clone().now_or_never().flatten() else { + self.api_token.update(cx, |key_state, cx| { + _ = key_state.load_if_needed(SWEEP_CREDENTIALS_URL, |s| s, cx); + }); + let Some(api_token) = self.api_token.read(cx).key(&SWEEP_CREDENTIALS_URL) else { return Task::ready(Ok(None)); }; let full_path: Arc = inputs @@ -270,47 +268,18 @@ impl SweepAi { } } -pub const SWEEP_CREDENTIALS_URL: &str = "https://autocomplete.sweep.dev"; +pub const SWEEP_CREDENTIALS_URL: SharedString = + SharedString::new_static("https://autocomplete.sweep.dev"); pub const SWEEP_CREDENTIALS_USERNAME: &str = "sweep-api-token"; +pub static SWEEP_AI_TOKEN_ENV_VAR: std::sync::LazyLock = env_var!("SWEEP_AI_TOKEN"); +pub static SWEEP_API_KEY: std::sync::OnceLock> = std::sync::OnceLock::new(); -pub fn load_api_token(cx: &App) -> Task> { - if let Some(api_token) = std::env::var("SWEEP_AI_TOKEN") - .ok() - .filter(|value| !value.is_empty()) - { - return Task::ready(Some(api_token)); - } - let credentials_provider = ::global(cx); - cx.spawn(async move |cx| { - let (_, credentials) = credentials_provider - .read_credentials(SWEEP_CREDENTIALS_URL, &cx) - .await - .ok()??; - String::from_utf8(credentials).ok() - }) -} - -fn store_api_token_in_keychain(api_token: Option, cx: &App) -> Task> { - let credentials_provider = ::global(cx); - - cx.spawn(async move |cx| { - if let Some(api_token) = api_token { - credentials_provider - .write_credentials( - SWEEP_CREDENTIALS_URL, - SWEEP_CREDENTIALS_USERNAME, - api_token.as_bytes(), - cx, - ) - .await - .context("Failed to save Sweep API token to system keychain") - } else { - credentials_provider - .delete_credentials(SWEEP_CREDENTIALS_URL, cx) - .await - .context("Failed to delete Sweep API token from system keychain") - } - }) +pub fn sweep_api_token(cx: &mut App) -> Entity { + SWEEP_API_KEY + .get_or_init(|| { + cx.new(|_| ApiKeyState::new(SWEEP_CREDENTIALS_URL, SWEEP_AI_TOKEN_ENV_VAR.clone())) + }) + .clone() } #[derive(Debug, Clone, Serialize)] diff --git a/crates/edit_prediction/src/zed_edit_prediction_delegate.rs b/crates/edit_prediction/src/zed_edit_prediction_delegate.rs index 6dcf7092240de64381ded611b47c2dd5940d6770..0a87ca661435de4d22e6f258c30ff406f0deecc2 100644 --- a/crates/edit_prediction/src/zed_edit_prediction_delegate.rs +++ b/crates/edit_prediction/src/zed_edit_prediction_delegate.rs @@ -100,7 +100,7 @@ impl EditPredictionDelegate for ZedEditPredictionDelegate { ) -> bool { let store = self.store.read(cx); if store.edit_prediction_model == EditPredictionModel::Sweep { - store.has_sweep_api_token() + store.has_sweep_api_token(cx) } else { true } diff --git a/crates/edit_prediction_ui/Cargo.toml b/crates/edit_prediction_ui/Cargo.toml index d6fc45512132197a3b9e7bd200c3005efa52ae10..63d674250001483bb8963ce62b44af524686399e 100644 --- a/crates/edit_prediction_ui/Cargo.toml +++ b/crates/edit_prediction_ui/Cargo.toml @@ -20,8 +20,8 @@ cloud_llm_client.workspace = true codestral.workspace = true command_palette_hooks.workspace = true copilot.workspace = true -edit_prediction.workspace = true edit_prediction_types.workspace = true +edit_prediction.workspace = true editor.workspace = true feature_flags.workspace = true fs.workspace = true @@ -41,7 +41,6 @@ telemetry.workspace = true text.workspace = true theme.workspace = true ui.workspace = true -ui_input.workspace = true util.workspace = true workspace.workspace = true zed_actions.workspace = true diff --git a/crates/edit_prediction_ui/src/edit_prediction_button.rs b/crates/edit_prediction_ui/src/edit_prediction_button.rs index 04c7614689c5fdc076ab0aa9c4b4fe7d68e2f582..b008f09ec8886086578b571b3655dac566fb6c5d 100644 --- a/crates/edit_prediction_ui/src/edit_prediction_button.rs +++ b/crates/edit_prediction_ui/src/edit_prediction_button.rs @@ -3,7 +3,9 @@ use client::{Client, UserStore, zed_urls}; use cloud_llm_client::UsageLimit; use codestral::CodestralEditPredictionDelegate; use copilot::{Copilot, Status}; -use edit_prediction::{MercuryFeatureFlag, SweepFeatureFlag, Zeta2FeatureFlag}; +use edit_prediction::{ + EditPredictionStore, MercuryFeatureFlag, SweepFeatureFlag, Zeta2FeatureFlag, +}; use edit_prediction_types::EditPredictionDelegateHandle; use editor::{ Editor, MultiBufferOffset, SelectionEffects, actions::ShowEditPrediction, scroll::Autoscroll, @@ -42,12 +44,9 @@ use workspace::{ StatusItemView, Toast, Workspace, create_and_open_local_file, item::ItemHandle, notifications::NotificationId, }; -use zed_actions::OpenBrowser; +use zed_actions::{OpenBrowser, OpenSettingsAt}; -use crate::{ - ExternalProviderApiKeyModal, RatePredictions, - rate_prediction_modal::PredictEditsRatePredictionsFeatureFlag, -}; +use crate::{RatePredictions, rate_prediction_modal::PredictEditsRatePredictionsFeatureFlag}; actions!( edit_prediction, @@ -248,45 +247,21 @@ impl Render for EditPredictionButton { EditPredictionProvider::Codestral => { let enabled = self.editor_enabled.unwrap_or(true); let has_api_key = CodestralEditPredictionDelegate::has_api_key(cx); - let fs = self.fs.clone(); let this = cx.weak_entity(); + let tooltip_meta = if has_api_key { + "Powered by Codestral" + } else { + "Missing API key for Codestral" + }; + div().child( PopoverMenu::new("codestral") .menu(move |window, cx| { - if has_api_key { - this.update(cx, |this, cx| { - this.build_codestral_context_menu(window, cx) - }) - .ok() - } else { - Some(ContextMenu::build(window, cx, |menu, _, _| { - let fs = fs.clone(); - - menu.entry( - "Configure Codestral API Key", - None, - move |window, cx| { - window.dispatch_action( - zed_actions::agent::OpenSettings.boxed_clone(), - cx, - ); - }, - ) - .separator() - .entry( - "Use Zed AI instead", - None, - move |_, cx| { - set_completion_provider( - fs.clone(), - cx, - EditPredictionProvider::Zed, - ) - }, - ) - })) - } + this.update(cx, |this, cx| { + this.build_codestral_context_menu(window, cx) + }) + .ok() }) .anchor(Corner::BottomRight) .trigger_with_tooltip( @@ -304,7 +279,14 @@ impl Render for EditPredictionButton { cx.theme().colors().status_bar_background, )) }), - move |_window, cx| Tooltip::for_action("Codestral", &ToggleMenu, cx), + move |_window, cx| { + Tooltip::with_meta( + "Edit Prediction", + Some(&ToggleMenu), + tooltip_meta, + cx, + ) + }, ) .with_handle(self.popover_menu_handle.clone()), ) @@ -313,6 +295,7 @@ impl Render for EditPredictionButton { let enabled = self.editor_enabled.unwrap_or(true); let ep_icon; + let tooltip_meta; let mut missing_token = false; match provider { @@ -320,15 +303,25 @@ impl Render for EditPredictionButton { EXPERIMENTAL_SWEEP_EDIT_PREDICTION_PROVIDER_NAME, ) => { ep_icon = IconName::SweepAi; + tooltip_meta = if missing_token { + "Missing API key for Sweep" + } else { + "Powered by Sweep" + }; missing_token = edit_prediction::EditPredictionStore::try_global(cx) - .is_some_and(|ep_store| !ep_store.read(cx).has_sweep_api_token()); + .is_some_and(|ep_store| !ep_store.read(cx).has_sweep_api_token(cx)); } EditPredictionProvider::Experimental( EXPERIMENTAL_MERCURY_EDIT_PREDICTION_PROVIDER_NAME, ) => { ep_icon = IconName::Inception; missing_token = edit_prediction::EditPredictionStore::try_global(cx) - .is_some_and(|ep_store| !ep_store.read(cx).has_mercury_api_token()); + .is_some_and(|ep_store| !ep_store.read(cx).has_mercury_api_token(cx)); + tooltip_meta = if missing_token { + "Missing API key for Mercury" + } else { + "Powered by Mercury" + }; } _ => { ep_icon = if enabled { @@ -336,6 +329,7 @@ impl Render for EditPredictionButton { } else { IconName::ZedPredictDisabled }; + tooltip_meta = "Powered by Zeta" } }; @@ -400,33 +394,26 @@ impl Render for EditPredictionButton { }) .when(!self.popover_menu_handle.is_deployed(), |element| { let user = user.clone(); + element.tooltip(move |_window, cx| { - if enabled { + let description = if enabled { if show_editor_predictions { - Tooltip::for_action("Edit Prediction", &ToggleMenu, cx) + tooltip_meta } else if user.is_none() { - Tooltip::with_meta( - "Edit Prediction", - Some(&ToggleMenu), - "Sign In To Use", - cx, - ) + "Sign In To Use" } else { - Tooltip::with_meta( - "Edit Prediction", - Some(&ToggleMenu), - "Hidden For This File", - cx, - ) + "Hidden For This File" } } else { - Tooltip::with_meta( - "Edit Prediction", - Some(&ToggleMenu), - "Disabled For This File", - cx, - ) - } + "Disabled For This File" + }; + + Tooltip::with_meta( + "Edit Prediction", + Some(&ToggleMenu), + description, + cx, + ) }) }); @@ -519,6 +506,12 @@ impl EditPredictionButton { providers.push(EditPredictionProvider::Zed); + if cx.has_flag::() { + providers.push(EditPredictionProvider::Experimental( + EXPERIMENTAL_ZETA2_EDIT_PREDICTION_PROVIDER_NAME, + )); + } + if let Some(copilot) = Copilot::global(cx) { if matches!(copilot.read(cx).status(), Status::Authorized) { providers.push(EditPredictionProvider::Copilot); @@ -537,24 +530,28 @@ impl EditPredictionButton { providers.push(EditPredictionProvider::Codestral); } - if cx.has_flag::() { + let ep_store = EditPredictionStore::try_global(cx); + + if cx.has_flag::() + && ep_store + .as_ref() + .is_some_and(|ep_store| ep_store.read(cx).has_sweep_api_token(cx)) + { providers.push(EditPredictionProvider::Experimental( EXPERIMENTAL_SWEEP_EDIT_PREDICTION_PROVIDER_NAME, )); } - if cx.has_flag::() { + if cx.has_flag::() + && ep_store + .as_ref() + .is_some_and(|ep_store| ep_store.read(cx).has_mercury_api_token(cx)) + { providers.push(EditPredictionProvider::Experimental( EXPERIMENTAL_MERCURY_EDIT_PREDICTION_PROVIDER_NAME, )); } - if cx.has_flag::() { - providers.push(EditPredictionProvider::Experimental( - EXPERIMENTAL_ZETA2_EDIT_PREDICTION_PROVIDER_NAME, - )); - } - providers } @@ -562,13 +559,10 @@ impl EditPredictionButton { &self, mut menu: ContextMenu, current_provider: EditPredictionProvider, - cx: &App, + cx: &mut App, ) -> ContextMenu { let available_providers = self.get_available_providers(cx); - const ZED_AI_CALLOUT: &str = - "Zed's edit prediction is powered by Zeta, an open-source, dataset mode."; - let providers: Vec<_> = available_providers .into_iter() .filter(|p| *p != EditPredictionProvider::None) @@ -581,153 +575,32 @@ impl EditPredictionButton { let is_current = provider == current_provider; let fs = self.fs.clone(); - menu = match provider { - EditPredictionProvider::Zed => menu.item( - ContextMenuEntry::new("Zed AI") - .toggleable(IconPosition::Start, is_current) - .documentation_aside( - DocumentationSide::Left, - DocumentationEdge::Bottom, - |_| Label::new(ZED_AI_CALLOUT).into_any_element(), - ) - .handler(move |_, cx| { - set_completion_provider(fs.clone(), cx, provider); - }), - ), - EditPredictionProvider::Copilot => menu.item( - ContextMenuEntry::new("GitHub Copilot") - .toggleable(IconPosition::Start, is_current) - .handler(move |_, cx| { - set_completion_provider(fs.clone(), cx, provider); - }), - ), - EditPredictionProvider::Supermaven => menu.item( - ContextMenuEntry::new("Supermaven") - .toggleable(IconPosition::Start, is_current) - .handler(move |_, cx| { - set_completion_provider(fs.clone(), cx, provider); - }), - ), - EditPredictionProvider::Codestral => menu.item( - ContextMenuEntry::new("Codestral") - .toggleable(IconPosition::Start, is_current) - .handler(move |_, cx| { - set_completion_provider(fs.clone(), cx, provider); - }), - ), + let name = match provider { + EditPredictionProvider::Zed => "Zed AI", + EditPredictionProvider::Copilot => "GitHub Copilot", + EditPredictionProvider::Supermaven => "Supermaven", + EditPredictionProvider::Codestral => "Codestral", EditPredictionProvider::Experimental( EXPERIMENTAL_SWEEP_EDIT_PREDICTION_PROVIDER_NAME, - ) => { - let has_api_token = edit_prediction::EditPredictionStore::try_global(cx) - .map_or(false, |ep_store| ep_store.read(cx).has_sweep_api_token()); - - let should_open_modal = !has_api_token || is_current; - - let entry = if has_api_token { - ContextMenuEntry::new("Sweep") - .toggleable(IconPosition::Start, is_current) - } else { - ContextMenuEntry::new("Sweep") - .icon(IconName::XCircle) - .icon_color(Color::Error) - .documentation_aside( - DocumentationSide::Left, - DocumentationEdge::Bottom, - |_| { - Label::new("Click to configure your Sweep API token") - .into_any_element() - }, - ) - }; - - let entry = entry.handler(move |window, cx| { - if should_open_modal { - if let Some(workspace) = window.root::().flatten() { - workspace.update(cx, |workspace, cx| { - workspace.toggle_modal(window, cx, |window, cx| { - ExternalProviderApiKeyModal::new( - window, - cx, - |api_key, store, cx| { - store - .sweep_ai - .set_api_token(api_key, cx) - .detach_and_log_err(cx); - }, - ) - }); - }); - }; - } else { - set_completion_provider(fs.clone(), cx, provider); - } - }); - - menu.item(entry) - } + ) => "Sweep", EditPredictionProvider::Experimental( EXPERIMENTAL_MERCURY_EDIT_PREDICTION_PROVIDER_NAME, - ) => { - let has_api_token = edit_prediction::EditPredictionStore::try_global(cx) - .map_or(false, |ep_store| ep_store.read(cx).has_mercury_api_token()); - - let should_open_modal = !has_api_token || is_current; - - let entry = if has_api_token { - ContextMenuEntry::new("Mercury") - .toggleable(IconPosition::Start, is_current) - } else { - ContextMenuEntry::new("Mercury") - .icon(IconName::XCircle) - .icon_color(Color::Error) - .documentation_aside( - DocumentationSide::Left, - DocumentationEdge::Bottom, - |_| { - Label::new("Click to configure your Mercury API token") - .into_any_element() - }, - ) - }; - - let entry = entry.handler(move |window, cx| { - if should_open_modal { - if let Some(workspace) = window.root::().flatten() { - workspace.update(cx, |workspace, cx| { - workspace.toggle_modal(window, cx, |window, cx| { - ExternalProviderApiKeyModal::new( - window, - cx, - |api_key, store, cx| { - store - .mercury - .set_api_token(api_key, cx) - .detach_and_log_err(cx); - }, - ) - }); - }); - }; - } else { - set_completion_provider(fs.clone(), cx, provider); - } - }); - - menu.item(entry) - } + ) => "Mercury", EditPredictionProvider::Experimental( EXPERIMENTAL_ZETA2_EDIT_PREDICTION_PROVIDER_NAME, - ) => menu.item( - ContextMenuEntry::new("Zeta2") - .toggleable(IconPosition::Start, is_current) - .handler(move |_, cx| { - set_completion_provider(fs.clone(), cx, provider); - }), - ), + ) => "Zeta2", EditPredictionProvider::None | EditPredictionProvider::Experimental(_) => { continue; } }; + + menu = menu.item( + ContextMenuEntry::new(name) + .toggleable(IconPosition::Start, is_current) + .handler(move |_, cx| { + set_completion_provider(fs.clone(), cx, provider); + }), + ) } } @@ -832,14 +705,7 @@ impl EditPredictionButton { let subtle_mode = matches!(current_mode, EditPredictionsMode::Subtle); let eager_mode = matches!(current_mode, EditPredictionsMode::Eager); - if matches!( - provider, - EditPredictionProvider::Zed - | EditPredictionProvider::Copilot - | EditPredictionProvider::Supermaven - | EditPredictionProvider::Codestral - ) { - menu = menu + menu = menu .separator() .header("Display Modes") .item( @@ -868,104 +734,111 @@ impl EditPredictionButton { } }), ); - } menu = menu.separator().header("Privacy"); - if let Some(provider) = &self.edit_prediction_provider { - let data_collection = provider.data_collection_state(cx); - - if data_collection.is_supported() { - let provider = provider.clone(); - let enabled = data_collection.is_enabled(); - let is_open_source = data_collection.is_project_open_source(); - let is_collecting = data_collection.is_enabled(); - let (icon_name, icon_color) = if is_open_source && is_collecting { - (IconName::Check, Color::Success) - } else { - (IconName::Check, Color::Accent) - }; - - menu = menu.item( - ContextMenuEntry::new("Training Data Collection") - .toggleable(IconPosition::Start, data_collection.is_enabled()) - .icon(icon_name) - .icon_color(icon_color) - .documentation_aside(DocumentationSide::Left, DocumentationEdge::Top, move |cx| { - let (msg, label_color, icon_name, icon_color) = match (is_open_source, is_collecting) { - (true, true) => ( - "Project identified as open source, and you're sharing data.", - Color::Default, - IconName::Check, - Color::Success, - ), - (true, false) => ( - "Project identified as open source, but you're not sharing data.", - Color::Muted, - IconName::Close, - Color::Muted, - ), - (false, true) => ( - "Project not identified as open source. No data captured.", - Color::Muted, - IconName::Close, - Color::Muted, - ), - (false, false) => ( - "Project not identified as open source, and setting turned off.", - Color::Muted, - IconName::Close, - Color::Muted, - ), - }; - v_flex() - .gap_2() - .child( - Label::new(indoc!{ - "Help us improve our open dataset model by sharing data from open source repositories. \ - Zed must detect a license file in your repo for this setting to take effect. \ - Files with sensitive data and secrets are excluded by default." - }) - ) - .child( - h_flex() - .items_start() - .pt_2() - .pr_1() - .flex_1() - .gap_1p5() - .border_t_1() - .border_color(cx.theme().colors().border_variant) - .child(h_flex().flex_shrink_0().h(line_height).child(Icon::new(icon_name).size(IconSize::XSmall).color(icon_color))) - .child(div().child(msg).w_full().text_sm().text_color(label_color.color(cx))) - ) - .into_any_element() - }) - .handler(move |_, cx| { - provider.toggle_data_collection(cx); - - if !enabled { - telemetry::event!( - "Data Collection Enabled", - source = "Edit Prediction Status Menu" - ); - } else { - telemetry::event!( - "Data Collection Disabled", - source = "Edit Prediction Status Menu" - ); - } - }) - ); + if matches!( + provider, + EditPredictionProvider::Zed + | EditPredictionProvider::Experimental( + EXPERIMENTAL_ZETA2_EDIT_PREDICTION_PROVIDER_NAME, + ) + ) { + if let Some(provider) = &self.edit_prediction_provider { + let data_collection = provider.data_collection_state(cx); + + if data_collection.is_supported() { + let provider = provider.clone(); + let enabled = data_collection.is_enabled(); + let is_open_source = data_collection.is_project_open_source(); + let is_collecting = data_collection.is_enabled(); + let (icon_name, icon_color) = if is_open_source && is_collecting { + (IconName::Check, Color::Success) + } else { + (IconName::Check, Color::Accent) + }; - if is_collecting && !is_open_source { menu = menu.item( - ContextMenuEntry::new("No data captured.") - .disabled(true) - .icon(IconName::Close) - .icon_color(Color::Error) - .icon_size(IconSize::Small), + ContextMenuEntry::new("Training Data Collection") + .toggleable(IconPosition::Start, data_collection.is_enabled()) + .icon(icon_name) + .icon_color(icon_color) + .documentation_aside(DocumentationSide::Left, DocumentationEdge::Top, move |cx| { + let (msg, label_color, icon_name, icon_color) = match (is_open_source, is_collecting) { + (true, true) => ( + "Project identified as open source, and you're sharing data.", + Color::Default, + IconName::Check, + Color::Success, + ), + (true, false) => ( + "Project identified as open source, but you're not sharing data.", + Color::Muted, + IconName::Close, + Color::Muted, + ), + (false, true) => ( + "Project not identified as open source. No data captured.", + Color::Muted, + IconName::Close, + Color::Muted, + ), + (false, false) => ( + "Project not identified as open source, and setting turned off.", + Color::Muted, + IconName::Close, + Color::Muted, + ), + }; + v_flex() + .gap_2() + .child( + Label::new(indoc!{ + "Help us improve our open dataset model by sharing data from open source repositories. \ + Zed must detect a license file in your repo for this setting to take effect. \ + Files with sensitive data and secrets are excluded by default." + }) + ) + .child( + h_flex() + .items_start() + .pt_2() + .pr_1() + .flex_1() + .gap_1p5() + .border_t_1() + .border_color(cx.theme().colors().border_variant) + .child(h_flex().flex_shrink_0().h(line_height).child(Icon::new(icon_name).size(IconSize::XSmall).color(icon_color))) + .child(div().child(msg).w_full().text_sm().text_color(label_color.color(cx))) + ) + .into_any_element() + }) + .handler(move |_, cx| { + provider.toggle_data_collection(cx); + + if !enabled { + telemetry::event!( + "Data Collection Enabled", + source = "Edit Prediction Status Menu" + ); + } else { + telemetry::event!( + "Data Collection Disabled", + source = "Edit Prediction Status Menu" + ); + } + }) ); + + if is_collecting && !is_open_source { + menu = menu.item( + ContextMenuEntry::new("No data captured.") + .disabled(true) + .icon(IconName::Close) + .icon_color(Color::Error) + .icon_size(IconSize::Small), + ); + } } } } @@ -1087,10 +960,7 @@ impl EditPredictionButton { let menu = self.add_provider_switching_section(menu, EditPredictionProvider::Codestral, cx); - menu.separator() - .entry("Configure Codestral API Key", None, move |window, cx| { - window.dispatch_action(zed_actions::agent::OpenSettings.boxed_clone(), cx); - }) + menu }) } @@ -1210,6 +1080,22 @@ impl EditPredictionButton { } menu = self.add_provider_switching_section(menu, provider, cx); + menu = menu.separator().item( + ContextMenuEntry::new("Configure Providers") + .icon(IconName::Settings) + .icon_position(IconPosition::Start) + .icon_color(Color::Muted) + .handler(move |window, cx| { + window.dispatch_action( + OpenSettingsAt { + path: "edit_predictions.providers".to_string(), + } + .boxed_clone(), + cx, + ); + }), + ); + menu }) } diff --git a/crates/edit_prediction_ui/src/edit_prediction_ui.rs b/crates/edit_prediction_ui/src/edit_prediction_ui.rs index c177b5233c33feb4f5ff82f60bf3fb6981cf3ee8..74c81fbfe16eec7846e70aefd59bbfeb282072dc 100644 --- a/crates/edit_prediction_ui/src/edit_prediction_ui.rs +++ b/crates/edit_prediction_ui/src/edit_prediction_ui.rs @@ -1,6 +1,5 @@ mod edit_prediction_button; mod edit_prediction_context_view; -mod external_provider_api_token_modal; mod rate_prediction_modal; use std::any::{Any as _, TypeId}; @@ -17,7 +16,6 @@ use ui::{App, prelude::*}; use workspace::{SplitDirection, Workspace}; pub use edit_prediction_button::{EditPredictionButton, ToggleMenu}; -pub use external_provider_api_token_modal::ExternalProviderApiKeyModal; use crate::rate_prediction_modal::PredictEditsRatePredictionsFeatureFlag; diff --git a/crates/edit_prediction_ui/src/external_provider_api_token_modal.rs b/crates/edit_prediction_ui/src/external_provider_api_token_modal.rs deleted file mode 100644 index bc312836e9fdd30237156ac532a055d1e23a2589..0000000000000000000000000000000000000000 --- a/crates/edit_prediction_ui/src/external_provider_api_token_modal.rs +++ /dev/null @@ -1,86 +0,0 @@ -use edit_prediction::EditPredictionStore; -use gpui::{ - DismissEvent, Entity, EventEmitter, FocusHandle, Focusable, IntoElement, ParentElement, Render, -}; -use ui::{Button, ButtonStyle, Clickable, Headline, HeadlineSize, prelude::*}; -use ui_input::InputField; -use workspace::ModalView; - -pub struct ExternalProviderApiKeyModal { - api_key_input: Entity, - focus_handle: FocusHandle, - on_confirm: Box, &mut EditPredictionStore, &mut App)>, -} - -impl ExternalProviderApiKeyModal { - pub fn new( - window: &mut Window, - cx: &mut Context, - on_confirm: impl Fn(Option, &mut EditPredictionStore, &mut App) + 'static, - ) -> Self { - let api_key_input = cx.new(|cx| InputField::new(window, cx, "Enter your API key")); - - Self { - api_key_input, - focus_handle: cx.focus_handle(), - on_confirm: Box::new(on_confirm), - } - } - - fn cancel(&mut self, _: &menu::Cancel, _window: &mut Window, cx: &mut Context) { - cx.emit(DismissEvent); - } - - fn confirm(&mut self, _: &menu::Confirm, _window: &mut Window, cx: &mut Context) { - let api_key = self.api_key_input.read(cx).text(cx); - let api_key = (!api_key.trim().is_empty()).then_some(api_key); - - if let Some(ep_store) = EditPredictionStore::try_global(cx) { - ep_store.update(cx, |ep_store, cx| (self.on_confirm)(api_key, ep_store, cx)) - } - - cx.emit(DismissEvent); - } -} - -impl EventEmitter for ExternalProviderApiKeyModal {} - -impl ModalView for ExternalProviderApiKeyModal {} - -impl Focusable for ExternalProviderApiKeyModal { - fn focus_handle(&self, _cx: &App) -> FocusHandle { - self.focus_handle.clone() - } -} - -impl Render for ExternalProviderApiKeyModal { - fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { - v_flex() - .key_context("ExternalApiKeyModal") - .on_action(cx.listener(Self::cancel)) - .on_action(cx.listener(Self::confirm)) - .elevation_2(cx) - .w(px(400.)) - .p_4() - .gap_3() - .child(Headline::new("API Token").size(HeadlineSize::Small)) - .child(self.api_key_input.clone()) - .child( - h_flex() - .justify_end() - .gap_2() - .child(Button::new("cancel", "Cancel").on_click(cx.listener( - |_, _, _window, cx| { - cx.emit(DismissEvent); - }, - ))) - .child( - Button::new("save", "Save") - .style(ButtonStyle::Filled) - .on_click(cx.listener(|this, _, window, cx| { - this.confirm(&menu::Confirm, window, cx); - })), - ), - ) - } -} diff --git a/crates/language_model/Cargo.toml b/crates/language_model/Cargo.toml index 7c6470f4fa0c1eac847c1194e967b451093a76ad..0a6d440a6bbc4cb1f45663d78eecb57bec43f1f5 100644 --- a/crates/language_model/Cargo.toml +++ b/crates/language_model/Cargo.toml @@ -18,6 +18,7 @@ test-support = [] [dependencies] anthropic = { workspace = true, features = ["schemars"] } anyhow.workspace = true +credentials_provider.workspace = true base64.workspace = true client.workspace = true cloud_api_types.workspace = true @@ -41,6 +42,7 @@ smol.workspace = true telemetry_events.workspace = true thiserror.workspace = true util.workspace = true +zed_env_vars.workspace = true [dev-dependencies] gpui = { workspace = true, features = ["test-support"] } diff --git a/crates/language_models/src/api_key.rs b/crates/language_model/src/api_key.rs similarity index 95% rename from crates/language_models/src/api_key.rs rename to crates/language_model/src/api_key.rs index 122234b6ced6d0bf1b7a0d684683c841824ccd2d..754fde069295d8799820020bef286b1a1a3c590c 100644 --- a/crates/language_models/src/api_key.rs +++ b/crates/language_model/src/api_key.rs @@ -2,7 +2,6 @@ use anyhow::{Result, anyhow}; use credentials_provider::CredentialsProvider; use futures::{FutureExt, future}; use gpui::{AsyncApp, Context, SharedString, Task}; -use language_model::AuthenticateError; use std::{ fmt::{Display, Formatter}, sync::Arc, @@ -10,13 +9,16 @@ use std::{ use util::ResultExt as _; use zed_env_vars::EnvVar; +use crate::AuthenticateError; + /// Manages a single API key for a language model provider. API keys either come from environment /// variables or the system keychain. /// /// Keys from the system keychain are associated with a provider URL, and this ensures that they are /// only used with that URL. pub struct ApiKeyState { - url: SharedString, + pub url: SharedString, + env_var: EnvVar, load_status: LoadStatus, load_task: Option>>, } @@ -35,9 +37,10 @@ pub struct ApiKey { } impl ApiKeyState { - pub fn new(url: SharedString) -> Self { + pub fn new(url: SharedString, env_var: EnvVar) -> Self { Self { url, + env_var, load_status: LoadStatus::NotPresent, load_task: None, } @@ -47,6 +50,10 @@ impl ApiKeyState { matches!(self.load_status, LoadStatus::Loaded { .. }) } + pub fn env_var_name(&self) -> &SharedString { + &self.env_var.name + } + pub fn is_from_env_var(&self) -> bool { match &self.load_status { LoadStatus::Loaded(ApiKey { @@ -136,14 +143,13 @@ impl ApiKeyState { pub fn handle_url_change( &mut self, url: SharedString, - env_var: &EnvVar, get_this: impl Fn(&mut Ent) -> &mut Self + Clone + 'static, cx: &mut Context, ) { if url != self.url { if !self.is_from_env_var() { // loading will continue even though this result task is dropped - let _task = self.load_if_needed(url, env_var, get_this, cx); + let _task = self.load_if_needed(url, get_this, cx); } } } @@ -156,7 +162,6 @@ impl ApiKeyState { pub fn load_if_needed( &mut self, url: SharedString, - env_var: &EnvVar, get_this: impl Fn(&mut Ent) -> &mut Self + Clone + 'static, cx: &mut Context, ) -> Task> { @@ -166,10 +171,10 @@ impl ApiKeyState { return Task::ready(Ok(())); } - if let Some(key) = &env_var.value + if let Some(key) = &self.env_var.value && !key.is_empty() { - let api_key = ApiKey::from_env(env_var.name.clone(), key); + let api_key = ApiKey::from_env(self.env_var.name.clone(), key); self.url = url; self.load_status = LoadStatus::Loaded(api_key); self.load_task = None; diff --git a/crates/language_model/src/language_model.rs b/crates/language_model/src/language_model.rs index cb03b84cbf34d3003e53befa518ecd91626a13e9..e158bb256be42291549c2379ae7ec19402166543 100644 --- a/crates/language_model/src/language_model.rs +++ b/crates/language_model/src/language_model.rs @@ -1,3 +1,4 @@ +mod api_key; mod model; mod rate_limiter; mod registry; @@ -30,6 +31,7 @@ use std::{fmt, io}; use thiserror::Error; use util::serde::is_default; +pub use crate::api_key::{ApiKey, ApiKeyState}; pub use crate::model::*; pub use crate::rate_limiter::*; pub use crate::registry::*; @@ -37,6 +39,7 @@ pub use crate::request::*; pub use crate::role::*; pub use crate::telemetry::*; pub use crate::tool_schema::LanguageModelToolSchemaFormat; +pub use zed_env_vars::{EnvVar, env_var}; pub const ANTHROPIC_PROVIDER_ID: LanguageModelProviderId = LanguageModelProviderId::new("anthropic"); diff --git a/crates/language_models/Cargo.toml b/crates/language_models/Cargo.toml index 6c5704312d94e2c98ff62c49d3d5b57c1b274057..5531e698ab7fccae736e800f38b16e35bcd35ac4 100644 --- a/crates/language_models/Cargo.toml +++ b/crates/language_models/Cargo.toml @@ -60,7 +60,6 @@ ui_input.workspace = true util.workspace = true vercel = { workspace = true, features = ["schemars"] } x_ai = { workspace = true, features = ["schemars"] } -zed_env_vars.workspace = true [dev-dependencies] editor = { workspace = true, features = ["test-support"] } diff --git a/crates/language_models/src/language_models.rs b/crates/language_models/src/language_models.rs index d771dba3733540cdb720416c21d5d0cb76b9d3be..1038f5e233e0a5970b0e8bd969a65f6f0e2a7550 100644 --- a/crates/language_models/src/language_models.rs +++ b/crates/language_models/src/language_models.rs @@ -7,10 +7,8 @@ use gpui::{App, Context, Entity}; use language_model::{LanguageModelProviderId, LanguageModelRegistry}; use provider::deepseek::DeepSeekLanguageModelProvider; -mod api_key; pub mod provider; mod settings; -pub mod ui; use crate::provider::anthropic::AnthropicLanguageModelProvider; use crate::provider::bedrock::BedrockLanguageModelProvider; diff --git a/crates/language_models/src/provider/anthropic.rs b/crates/language_models/src/provider/anthropic.rs index 1affe38a08d22e2aaed8c1207513ce41a13b8e59..f9e1e60cf648d3a67cec425ebd1f09ad7b564665 100644 --- a/crates/language_models/src/provider/anthropic.rs +++ b/crates/language_models/src/provider/anthropic.rs @@ -8,25 +8,21 @@ use futures::{FutureExt, Stream, StreamExt, future, future::BoxFuture, stream::B use gpui::{AnyView, App, AsyncApp, Context, Entity, Task}; use http_client::HttpClient; use language_model::{ - AuthenticateError, ConfigurationViewTargetAgent, LanguageModel, - LanguageModelCacheConfiguration, LanguageModelCompletionError, LanguageModelId, - LanguageModelName, LanguageModelProvider, LanguageModelProviderId, LanguageModelProviderName, - LanguageModelProviderState, LanguageModelRequest, LanguageModelToolChoice, - LanguageModelToolResultContent, MessageContent, RateLimiter, Role, + ApiKeyState, AuthenticateError, ConfigurationViewTargetAgent, EnvVar, LanguageModel, + LanguageModelCacheConfiguration, LanguageModelCompletionError, LanguageModelCompletionEvent, + LanguageModelId, LanguageModelName, LanguageModelProvider, LanguageModelProviderId, + LanguageModelProviderName, LanguageModelProviderState, LanguageModelRequest, + LanguageModelToolChoice, LanguageModelToolResultContent, LanguageModelToolUse, MessageContent, + RateLimiter, Role, StopReason, env_var, }; -use language_model::{LanguageModelCompletionEvent, LanguageModelToolUse, StopReason}; use settings::{Settings, SettingsStore}; use std::pin::Pin; use std::str::FromStr; use std::sync::{Arc, LazyLock}; use strum::IntoEnumIterator; -use ui::{List, prelude::*}; +use ui::{ButtonLink, ConfiguredApiCard, List, ListBulletItem, prelude::*}; use ui_input::InputField; use util::ResultExt; -use zed_env_vars::{EnvVar, env_var}; - -use crate::api_key::ApiKeyState; -use crate::ui::{ConfiguredApiCard, InstructionListItem}; pub use settings::AnthropicAvailableModel as AvailableModel; @@ -65,12 +61,8 @@ impl State { fn authenticate(&mut self, cx: &mut Context) -> Task> { let api_url = AnthropicLanguageModelProvider::api_url(cx); - self.api_key_state.load_if_needed( - api_url, - &API_KEY_ENV_VAR, - |this| &mut this.api_key_state, - cx, - ) + self.api_key_state + .load_if_needed(api_url, |this| &mut this.api_key_state, cx) } } @@ -79,17 +71,13 @@ impl AnthropicLanguageModelProvider { let state = cx.new(|cx| { cx.observe_global::(|this: &mut State, cx| { let api_url = Self::api_url(cx); - this.api_key_state.handle_url_change( - api_url, - &API_KEY_ENV_VAR, - |this| &mut this.api_key_state, - cx, - ); + this.api_key_state + .handle_url_change(api_url, |this| &mut this.api_key_state, cx); cx.notify(); }) .detach(); State { - api_key_state: ApiKeyState::new(Self::api_url(cx)), + api_key_state: ApiKeyState::new(Self::api_url(cx), (*API_KEY_ENV_VAR).clone()), } }); @@ -937,14 +925,12 @@ impl Render for ConfigurationView { .child( List::new() .child( - InstructionListItem::new( - "Create one by visiting", - Some("Anthropic's settings"), - Some("https://console.anthropic.com/settings/keys") - ) + ListBulletItem::new("") + .child(Label::new("Create one by visiting")) + .child(ButtonLink::new("Anthropic's settings", "https://console.anthropic.com/settings/keys")) ) .child( - InstructionListItem::text_only("Paste your API key below and hit enter to start using the agent") + ListBulletItem::new("Paste your API key below and hit enter to start using the agent") ) ) .child(self.api_key_editor.clone()) @@ -953,7 +939,8 @@ impl Render for ConfigurationView { format!("You can also assign the {API_KEY_ENV_VAR_NAME} environment variable and restart Zed."), ) .size(LabelSize::Small) - .color(Color::Muted), + .color(Color::Muted) + .mt_0p5(), ) .into_any_element() } else { diff --git a/crates/language_models/src/provider/bedrock.rs b/crates/language_models/src/provider/bedrock.rs index e478c193a27a9e30301ae9233ea666c8160b25f5..b85a038bb235d97bd9de8614f19764ecabf7bbfe 100644 --- a/crates/language_models/src/provider/bedrock.rs +++ b/crates/language_models/src/provider/bedrock.rs @@ -2,7 +2,6 @@ use std::pin::Pin; use std::str::FromStr; use std::sync::Arc; -use crate::ui::{ConfiguredApiCard, InstructionListItem}; use anyhow::{Context as _, Result, anyhow}; use aws_config::stalled_stream_protection::StalledStreamProtectionConfig; use aws_config::{BehaviorVersion, Region}; @@ -44,7 +43,7 @@ use serde_json::Value; use settings::{BedrockAvailableModel as AvailableModel, Settings, SettingsStore}; use smol::lock::OnceCell; use strum::{EnumIter, IntoEnumIterator, IntoStaticStr}; -use ui::{List, prelude::*}; +use ui::{ButtonLink, ConfiguredApiCard, List, ListBulletItem, prelude::*}; use ui_input::InputField; use util::ResultExt; @@ -1250,18 +1249,14 @@ impl Render for ConfigurationView { .child( List::new() .child( - InstructionListItem::new( - "Grant permissions to the strategy you'll use according to the:", - Some("Prerequisites"), - Some("https://docs.aws.amazon.com/bedrock/latest/userguide/inference-prereq.html"), - ) + ListBulletItem::new("") + .child(Label::new("Grant permissions to the strategy you'll use according to the:")) + .child(ButtonLink::new("Prerequisites", "https://docs.aws.amazon.com/bedrock/latest/userguide/inference-prereq.html")) ) .child( - InstructionListItem::new( - "Select the models you would like access to:", - Some("Bedrock Model Catalog"), - Some("https://us-east-1.console.aws.amazon.com/bedrock/home?region=us-east-1#/modelaccess"), - ) + ListBulletItem::new("") + .child(Label::new("Select the models you would like access to:")) + .child(ButtonLink::new("Bedrock Model Catalog", "https://us-east-1.console.aws.amazon.com/bedrock/home?region=us-east-1#/modelaccess")) ) ) .child(self.render_static_credentials_ui()) @@ -1302,22 +1297,22 @@ impl ConfigurationView { ) .child( List::new() - .child(InstructionListItem::new( - "Create an IAM user in the AWS console with programmatic access", - Some("IAM Console"), - Some("https://us-east-1.console.aws.amazon.com/iam/home?region=us-east-1#/users"), - )) - .child(InstructionListItem::new( - "Attach the necessary Bedrock permissions to this ", - Some("user"), - Some("https://docs.aws.amazon.com/bedrock/latest/userguide/inference-prereq.html"), - )) - .child(InstructionListItem::text_only( - "Copy the access key ID and secret access key when provided", - )) - .child(InstructionListItem::text_only( - "Enter these credentials below", - )), + .child( + ListBulletItem::new("") + .child(Label::new("Create an IAM user in the AWS console with programmatic access")) + .child(ButtonLink::new("IAM Console", "https://us-east-1.console.aws.amazon.com/iam/home?region=us-east-1#/users")) + ) + .child( + ListBulletItem::new("") + .child(Label::new("Attach the necessary Bedrock permissions to this")) + .child(ButtonLink::new("user", "https://docs.aws.amazon.com/bedrock/latest/userguide/inference-prereq.html")) + ) + .child( + ListBulletItem::new("Copy the access key ID and secret access key when provided") + ) + .child( + ListBulletItem::new("Enter these credentials below") + ) ) .child(self.access_key_id_editor.clone()) .child(self.secret_access_key_editor.clone()) diff --git a/crates/language_models/src/provider/copilot_chat.rs b/crates/language_models/src/provider/copilot_chat.rs index 92ac342a39ff04ae42f5b01b5777a5d16563c37f..70198b337e467e1618192e781d3e3be305fea9c5 100644 --- a/crates/language_models/src/provider/copilot_chat.rs +++ b/crates/language_models/src/provider/copilot_chat.rs @@ -14,7 +14,7 @@ use copilot::{Copilot, Status}; use futures::future::BoxFuture; use futures::stream::BoxStream; use futures::{FutureExt, Stream, StreamExt}; -use gpui::{Action, AnyView, App, AsyncApp, Entity, Render, Subscription, Task, svg}; +use gpui::{AnyView, App, AsyncApp, Entity, Subscription, Task}; use http_client::StatusCode; use language::language_settings::all_language_settings; use language_model::{ @@ -26,11 +26,9 @@ use language_model::{ StopReason, TokenUsage, }; use settings::SettingsStore; -use ui::{CommonAnimationExt, prelude::*}; +use ui::prelude::*; use util::debug_panic; -use crate::ui::ConfiguredApiCard; - const PROVIDER_ID: LanguageModelProviderId = LanguageModelProviderId::new("copilot_chat"); const PROVIDER_NAME: LanguageModelProviderName = LanguageModelProviderName::new("GitHub Copilot Chat"); @@ -179,8 +177,18 @@ impl LanguageModelProvider for CopilotChatLanguageModelProvider { _: &mut Window, cx: &mut App, ) -> AnyView { - let state = self.state.clone(); - cx.new(|cx| ConfigurationView::new(state, cx)).into() + cx.new(|cx| { + copilot::ConfigurationView::new( + |cx| { + CopilotChat::global(cx) + .map(|m| m.read(cx).is_authenticated()) + .unwrap_or(false) + }, + copilot::ConfigurationMode::Chat, + cx, + ) + }) + .into() } fn reset_credentials(&self, _cx: &mut App) -> Task> { @@ -1474,92 +1482,3 @@ mod tests { ); } } -struct ConfigurationView { - copilot_status: Option, - state: Entity, - _subscription: Option, -} - -impl ConfigurationView { - pub fn new(state: Entity, cx: &mut Context) -> Self { - let copilot = Copilot::global(cx); - - Self { - copilot_status: copilot.as_ref().map(|copilot| copilot.read(cx).status()), - state, - _subscription: copilot.as_ref().map(|copilot| { - cx.observe(copilot, |this, model, cx| { - this.copilot_status = Some(model.read(cx).status()); - cx.notify(); - }) - }), - } - } -} - -impl Render for ConfigurationView { - fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { - if self.state.read(cx).is_authenticated(cx) { - ConfiguredApiCard::new("Authorized") - .button_label("Sign Out") - .on_click(|_, window, cx| { - window.dispatch_action(copilot::SignOut.boxed_clone(), cx); - }) - .into_any_element() - } else { - let loading_icon = Icon::new(IconName::ArrowCircle).with_rotate_animation(4); - - const ERROR_LABEL: &str = "Copilot Chat requires an active GitHub Copilot subscription. Please ensure Copilot is configured and try again, or use a different Assistant provider."; - - match &self.copilot_status { - Some(status) => match status { - Status::Starting { task: _ } => h_flex() - .gap_2() - .child(loading_icon) - .child(Label::new("Starting Copilot…")) - .into_any_element(), - Status::SigningIn { prompt: _ } - | Status::SignedOut { - awaiting_signing_in: true, - } => h_flex() - .gap_2() - .child(loading_icon) - .child(Label::new("Signing into Copilot…")) - .into_any_element(), - Status::Error(_) => { - const LABEL: &str = "Copilot had issues starting. Please try restarting it. If the issue persists, try reinstalling Copilot."; - v_flex() - .gap_6() - .child(Label::new(LABEL)) - .child(svg().size_8().path(IconName::CopilotError.path())) - .into_any_element() - } - _ => { - const LABEL: &str = "To use Zed's agent with GitHub Copilot, you need to be logged in to GitHub. Note that your GitHub account must have an active Copilot Chat subscription."; - - v_flex() - .gap_2() - .child(Label::new(LABEL)) - .child( - Button::new("sign_in", "Sign in to use GitHub Copilot") - .full_width() - .style(ButtonStyle::Outlined) - .icon_color(Color::Muted) - .icon(IconName::Github) - .icon_position(IconPosition::Start) - .icon_size(IconSize::Small) - .on_click(|_, window, cx| { - copilot::initiate_sign_in(window, cx) - }), - ) - .into_any_element() - } - }, - None => v_flex() - .gap_6() - .child(Label::new(ERROR_LABEL)) - .into_any_element(), - } - } - } -} diff --git a/crates/language_models/src/provider/deepseek.rs b/crates/language_models/src/provider/deepseek.rs index 91b83bb9f1d0f08fe70f5e750ff8ce993a7afd7f..b00a5d82f5665a5c87c662d1af84fbeb9ac07ebb 100644 --- a/crates/language_models/src/provider/deepseek.rs +++ b/crates/language_models/src/provider/deepseek.rs @@ -7,11 +7,11 @@ use futures::{FutureExt, StreamExt, future, future::BoxFuture, stream::BoxStream use gpui::{AnyView, App, AsyncApp, Context, Entity, SharedString, Task, Window}; use http_client::HttpClient; use language_model::{ - AuthenticateError, LanguageModel, LanguageModelCompletionError, LanguageModelCompletionEvent, - LanguageModelId, LanguageModelName, LanguageModelProvider, LanguageModelProviderId, - LanguageModelProviderName, LanguageModelProviderState, LanguageModelRequest, - LanguageModelToolChoice, LanguageModelToolResultContent, LanguageModelToolUse, MessageContent, - RateLimiter, Role, StopReason, TokenUsage, + ApiKeyState, AuthenticateError, EnvVar, LanguageModel, LanguageModelCompletionError, + LanguageModelCompletionEvent, LanguageModelId, LanguageModelName, LanguageModelProvider, + LanguageModelProviderId, LanguageModelProviderName, LanguageModelProviderState, + LanguageModelRequest, LanguageModelToolChoice, LanguageModelToolResultContent, + LanguageModelToolUse, MessageContent, RateLimiter, Role, StopReason, TokenUsage, env_var, }; pub use settings::DeepseekAvailableModel as AvailableModel; use settings::{Settings, SettingsStore}; @@ -19,13 +19,9 @@ use std::pin::Pin; use std::str::FromStr; use std::sync::{Arc, LazyLock}; -use ui::{List, prelude::*}; +use ui::{ButtonLink, ConfiguredApiCard, List, ListBulletItem, prelude::*}; use ui_input::InputField; use util::ResultExt; -use zed_env_vars::{EnvVar, env_var}; - -use crate::ui::ConfiguredApiCard; -use crate::{api_key::ApiKeyState, ui::InstructionListItem}; const PROVIDER_ID: LanguageModelProviderId = LanguageModelProviderId::new("deepseek"); const PROVIDER_NAME: LanguageModelProviderName = LanguageModelProviderName::new("DeepSeek"); @@ -67,12 +63,8 @@ impl State { fn authenticate(&mut self, cx: &mut Context) -> Task> { let api_url = DeepSeekLanguageModelProvider::api_url(cx); - self.api_key_state.load_if_needed( - api_url, - &API_KEY_ENV_VAR, - |this| &mut this.api_key_state, - cx, - ) + self.api_key_state + .load_if_needed(api_url, |this| &mut this.api_key_state, cx) } } @@ -81,17 +73,13 @@ impl DeepSeekLanguageModelProvider { let state = cx.new(|cx| { cx.observe_global::(|this: &mut State, cx| { let api_url = Self::api_url(cx); - this.api_key_state.handle_url_change( - api_url, - &API_KEY_ENV_VAR, - |this| &mut this.api_key_state, - cx, - ); + this.api_key_state + .handle_url_change(api_url, |this| &mut this.api_key_state, cx); cx.notify(); }) .detach(); State { - api_key_state: ApiKeyState::new(Self::api_url(cx)), + api_key_state: ApiKeyState::new(Self::api_url(cx), (*API_KEY_ENV_VAR).clone()), } }); @@ -632,12 +620,15 @@ impl Render for ConfigurationView { .child(Label::new("To use DeepSeek in Zed, you need an API key:")) .child( List::new() - .child(InstructionListItem::new( - "Get your API key from the", - Some("DeepSeek console"), - Some("https://platform.deepseek.com/api_keys"), - )) - .child(InstructionListItem::text_only( + .child( + ListBulletItem::new("") + .child(Label::new("Get your API key from the")) + .child(ButtonLink::new( + "DeepSeek console", + "https://platform.deepseek.com/api_keys", + )), + ) + .child(ListBulletItem::new( "Paste your API key below and hit enter to start using the assistant", )), ) diff --git a/crates/language_models/src/provider/google.rs b/crates/language_models/src/provider/google.rs index c5a5affcd3d9e8c34f6306f86cb5348f86397892..989b99061b6d0f4c6680f08616c55946138ae0fe 100644 --- a/crates/language_models/src/provider/google.rs +++ b/crates/language_models/src/provider/google.rs @@ -9,7 +9,7 @@ use google_ai::{ use gpui::{AnyView, App, AsyncApp, Context, Entity, SharedString, Task, Window}; use http_client::HttpClient; use language_model::{ - AuthenticateError, ConfigurationViewTargetAgent, LanguageModelCompletionError, + AuthenticateError, ConfigurationViewTargetAgent, EnvVar, LanguageModelCompletionError, LanguageModelCompletionEvent, LanguageModelToolChoice, LanguageModelToolSchemaFormat, LanguageModelToolUse, LanguageModelToolUseId, MessageContent, StopReason, }; @@ -28,14 +28,11 @@ use std::sync::{ atomic::{self, AtomicU64}, }; use strum::IntoEnumIterator; -use ui::{List, prelude::*}; +use ui::{ButtonLink, ConfiguredApiCard, List, ListBulletItem, prelude::*}; use ui_input::InputField; use util::ResultExt; -use zed_env_vars::EnvVar; -use crate::api_key::ApiKey; -use crate::api_key::ApiKeyState; -use crate::ui::{ConfiguredApiCard, InstructionListItem}; +use language_model::{ApiKey, ApiKeyState}; const PROVIDER_ID: LanguageModelProviderId = language_model::GOOGLE_PROVIDER_ID; const PROVIDER_NAME: LanguageModelProviderName = language_model::GOOGLE_PROVIDER_NAME; @@ -87,12 +84,8 @@ impl State { fn authenticate(&mut self, cx: &mut Context) -> Task> { let api_url = GoogleLanguageModelProvider::api_url(cx); - self.api_key_state.load_if_needed( - api_url, - &API_KEY_ENV_VAR, - |this| &mut this.api_key_state, - cx, - ) + self.api_key_state + .load_if_needed(api_url, |this| &mut this.api_key_state, cx) } } @@ -101,17 +94,13 @@ impl GoogleLanguageModelProvider { let state = cx.new(|cx| { cx.observe_global::(|this: &mut State, cx| { let api_url = Self::api_url(cx); - this.api_key_state.handle_url_change( - api_url, - &API_KEY_ENV_VAR, - |this| &mut this.api_key_state, - cx, - ); + this.api_key_state + .handle_url_change(api_url, |this| &mut this.api_key_state, cx); cx.notify(); }) .detach(); State { - api_key_state: ApiKeyState::new(Self::api_url(cx)), + api_key_state: ApiKeyState::new(Self::api_url(cx), (*API_KEY_ENV_VAR).clone()), } }); @@ -873,14 +862,14 @@ impl Render for ConfigurationView { }))) .child( List::new() - .child(InstructionListItem::new( - "Create one by visiting", - Some("Google AI's console"), - Some("https://aistudio.google.com/app/apikey"), - )) - .child(InstructionListItem::text_only( - "Paste your API key below and hit enter to start using the assistant", - )), + .child( + ListBulletItem::new("") + .child(Label::new("Create one by visiting")) + .child(ButtonLink::new("Google AI's console", "https://aistudio.google.com/app/apikey")) + ) + .child( + ListBulletItem::new("Paste your API key below and hit enter to start using the agent") + ) ) .child(self.api_key_editor.clone()) .child( diff --git a/crates/language_models/src/provider/lmstudio.rs b/crates/language_models/src/provider/lmstudio.rs index a16bd351a9d779bcba5b2a4111fc62e0dc9dc639..8e42d12db4c24ef6a66ddef470a34c620ed7ee00 100644 --- a/crates/language_models/src/provider/lmstudio.rs +++ b/crates/language_models/src/provider/lmstudio.rs @@ -20,11 +20,10 @@ use settings::{Settings, SettingsStore}; use std::pin::Pin; use std::str::FromStr; use std::{collections::BTreeMap, sync::Arc}; -use ui::{ButtonLike, Indicator, List, prelude::*}; +use ui::{ButtonLike, Indicator, InlineCode, List, ListBulletItem, prelude::*}; use util::ResultExt; use crate::AllLanguageModelSettings; -use crate::ui::InstructionListItem; const LMSTUDIO_DOWNLOAD_URL: &str = "https://lmstudio.ai/download"; const LMSTUDIO_CATALOG_URL: &str = "https://lmstudio.ai/models"; @@ -686,12 +685,14 @@ impl Render for ConfigurationView { .child( v_flex().gap_1().child(Label::new(lmstudio_intro)).child( List::new() - .child(InstructionListItem::text_only( + .child(ListBulletItem::new( "LM Studio needs to be running with at least one model downloaded.", )) - .child(InstructionListItem::text_only( - "To get your first model, try running `lms get qwen2.5-coder-7b`", - )), + .child( + ListBulletItem::new("") + .child(Label::new("To get your first model, try running")) + .child(InlineCode::new("lms get qwen2.5-coder-7b")), + ), ), ) .child( diff --git a/crates/language_models/src/provider/mistral.rs b/crates/language_models/src/provider/mistral.rs index 8372a8c95e579f1d860fd9bb25656731ee2c7e50..1078e2d7f7841d7ad05284e10a9f862236966ebc 100644 --- a/crates/language_models/src/provider/mistral.rs +++ b/crates/language_models/src/provider/mistral.rs @@ -1,31 +1,27 @@ use anyhow::{Result, anyhow}; use collections::BTreeMap; -use fs::Fs; + use futures::{FutureExt, Stream, StreamExt, future, future::BoxFuture, stream::BoxStream}; use gpui::{AnyView, App, AsyncApp, Context, Entity, Global, SharedString, Task, Window}; use http_client::HttpClient; use language_model::{ - AuthenticateError, LanguageModel, LanguageModelCompletionError, LanguageModelCompletionEvent, - LanguageModelId, LanguageModelName, LanguageModelProvider, LanguageModelProviderId, - LanguageModelProviderName, LanguageModelProviderState, LanguageModelRequest, - LanguageModelToolChoice, LanguageModelToolResultContent, LanguageModelToolUse, MessageContent, - RateLimiter, Role, StopReason, TokenUsage, + ApiKeyState, AuthenticateError, EnvVar, LanguageModel, LanguageModelCompletionError, + LanguageModelCompletionEvent, LanguageModelId, LanguageModelName, LanguageModelProvider, + LanguageModelProviderId, LanguageModelProviderName, LanguageModelProviderState, + LanguageModelRequest, LanguageModelToolChoice, LanguageModelToolResultContent, + LanguageModelToolUse, MessageContent, RateLimiter, Role, StopReason, TokenUsage, env_var, }; -use mistral::{CODESTRAL_API_URL, MISTRAL_API_URL, StreamResponse}; +pub use mistral::{CODESTRAL_API_URL, MISTRAL_API_URL, StreamResponse}; pub use settings::MistralAvailableModel as AvailableModel; -use settings::{EditPredictionProvider, Settings, SettingsStore, update_settings_file}; +use settings::{Settings, SettingsStore}; use std::collections::HashMap; use std::pin::Pin; use std::str::FromStr; -use std::sync::{Arc, LazyLock}; +use std::sync::{Arc, LazyLock, OnceLock}; use strum::IntoEnumIterator; -use ui::{List, prelude::*}; +use ui::{ButtonLink, ConfiguredApiCard, List, ListBulletItem, prelude::*}; use ui_input::InputField; use util::ResultExt; -use zed_env_vars::{EnvVar, env_var}; - -use crate::ui::ConfiguredApiCard; -use crate::{api_key::ApiKeyState, ui::InstructionListItem}; const PROVIDER_ID: LanguageModelProviderId = LanguageModelProviderId::new("mistral"); const PROVIDER_NAME: LanguageModelProviderName = LanguageModelProviderName::new("Mistral"); @@ -35,6 +31,7 @@ static API_KEY_ENV_VAR: LazyLock = env_var!(API_KEY_ENV_VAR_NAME); const CODESTRAL_API_KEY_ENV_VAR_NAME: &str = "CODESTRAL_API_KEY"; static CODESTRAL_API_KEY_ENV_VAR: LazyLock = env_var!(CODESTRAL_API_KEY_ENV_VAR_NAME); +static CODESTRAL_API_KEY: OnceLock> = OnceLock::new(); #[derive(Default, Clone, Debug, PartialEq)] pub struct MistralSettings { @@ -44,12 +41,22 @@ pub struct MistralSettings { pub struct MistralLanguageModelProvider { http_client: Arc, - state: Entity, + pub state: Entity, } pub struct State { api_key_state: ApiKeyState, - codestral_api_key_state: ApiKeyState, + codestral_api_key_state: Entity, +} + +pub fn codestral_api_key(cx: &mut App) -> Entity { + return CODESTRAL_API_KEY + .get_or_init(|| { + cx.new(|_| { + ApiKeyState::new(CODESTRAL_API_URL.into(), CODESTRAL_API_KEY_ENV_VAR.clone()) + }) + }) + .clone(); } impl State { @@ -63,39 +70,19 @@ impl State { .store(api_url, api_key, |this| &mut this.api_key_state, cx) } - fn set_codestral_api_key( - &mut self, - api_key: Option, - cx: &mut Context, - ) -> Task> { - self.codestral_api_key_state.store( - CODESTRAL_API_URL.into(), - api_key, - |this| &mut this.codestral_api_key_state, - cx, - ) - } - fn authenticate(&mut self, cx: &mut Context) -> Task> { let api_url = MistralLanguageModelProvider::api_url(cx); - self.api_key_state.load_if_needed( - api_url, - &API_KEY_ENV_VAR, - |this| &mut this.api_key_state, - cx, - ) + self.api_key_state + .load_if_needed(api_url, |this| &mut this.api_key_state, cx) } fn authenticate_codestral( &mut self, cx: &mut Context, ) -> Task> { - self.codestral_api_key_state.load_if_needed( - CODESTRAL_API_URL.into(), - &CODESTRAL_API_KEY_ENV_VAR, - |this| &mut this.codestral_api_key_state, - cx, - ) + self.codestral_api_key_state.update(cx, |state, cx| { + state.load_if_needed(CODESTRAL_API_URL.into(), |state| state, cx) + }) } } @@ -116,18 +103,14 @@ impl MistralLanguageModelProvider { let state = cx.new(|cx| { cx.observe_global::(|this: &mut State, cx| { let api_url = Self::api_url(cx); - this.api_key_state.handle_url_change( - api_url, - &API_KEY_ENV_VAR, - |this| &mut this.api_key_state, - cx, - ); + this.api_key_state + .handle_url_change(api_url, |this| &mut this.api_key_state, cx); cx.notify(); }) .detach(); State { - api_key_state: ApiKeyState::new(Self::api_url(cx)), - codestral_api_key_state: ApiKeyState::new(CODESTRAL_API_URL.into()), + api_key_state: ApiKeyState::new(Self::api_url(cx), (*API_KEY_ENV_VAR).clone()), + codestral_api_key_state: codestral_api_key(cx), } }); @@ -142,7 +125,11 @@ impl MistralLanguageModelProvider { } pub fn codestral_api_key(&self, url: &str, cx: &App) -> Option> { - self.state.read(cx).codestral_api_key_state.key(url) + self.state + .read(cx) + .codestral_api_key_state + .read(cx) + .key(url) } fn create_language_model(&self, model: mistral::Model) -> Arc { @@ -159,7 +146,7 @@ impl MistralLanguageModelProvider { &crate::AllLanguageModelSettings::get_global(cx).mistral } - fn api_url(cx: &App) -> SharedString { + pub fn api_url(cx: &App) -> SharedString { let api_url = &Self::settings(cx).api_url; if api_url.is_empty() { mistral::MISTRAL_API_URL.into() @@ -747,7 +734,6 @@ struct RawToolCall { struct ConfigurationView { api_key_editor: Entity, - codestral_api_key_editor: Entity, state: Entity, load_credentials_task: Option>, } @@ -756,8 +742,6 @@ impl ConfigurationView { fn new(state: Entity, window: &mut Window, cx: &mut Context) -> Self { let api_key_editor = cx.new(|cx| InputField::new(window, cx, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")); - let codestral_api_key_editor = - cx.new(|cx| InputField::new(window, cx, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")); cx.observe(&state, |_, _, cx| { cx.notify(); @@ -774,12 +758,6 @@ impl ConfigurationView { // We don't log an error, because "not signed in" is also an error. let _ = task.await; } - if let Some(task) = state - .update(cx, |state, cx| state.authenticate_codestral(cx)) - .log_err() - { - let _ = task.await; - } this.update(cx, |this, cx| { this.load_credentials_task = None; @@ -791,7 +769,6 @@ impl ConfigurationView { Self { api_key_editor, - codestral_api_key_editor, state, load_credentials_task, } @@ -829,110 +806,9 @@ impl ConfigurationView { .detach_and_log_err(cx); } - fn save_codestral_api_key( - &mut self, - _: &menu::Confirm, - window: &mut Window, - cx: &mut Context, - ) { - let api_key = self - .codestral_api_key_editor - .read(cx) - .text(cx) - .trim() - .to_string(); - if api_key.is_empty() { - return; - } - - // url changes can cause the editor to be displayed again - self.codestral_api_key_editor - .update(cx, |editor, cx| editor.set_text("", window, cx)); - - let state = self.state.clone(); - cx.spawn_in(window, async move |_, cx| { - state - .update(cx, |state, cx| { - state.set_codestral_api_key(Some(api_key), cx) - })? - .await?; - cx.update(|_window, cx| { - set_edit_prediction_provider(EditPredictionProvider::Codestral, cx) - }) - }) - .detach_and_log_err(cx); - } - - fn reset_codestral_api_key(&mut self, window: &mut Window, cx: &mut Context) { - self.codestral_api_key_editor - .update(cx, |editor, cx| editor.set_text("", window, cx)); - - let state = self.state.clone(); - cx.spawn_in(window, async move |_, cx| { - state - .update(cx, |state, cx| state.set_codestral_api_key(None, cx))? - .await?; - cx.update(|_window, cx| set_edit_prediction_provider(EditPredictionProvider::Zed, cx)) - }) - .detach_and_log_err(cx); - } - fn should_render_api_key_editor(&self, cx: &mut Context) -> bool { !self.state.read(cx).is_authenticated() } - - fn render_codestral_api_key_editor(&mut self, cx: &mut Context) -> AnyElement { - let key_state = &self.state.read(cx).codestral_api_key_state; - let should_show_editor = !key_state.has_key(); - let env_var_set = key_state.is_from_env_var(); - let configured_card_label = if env_var_set { - format!("API key set in {CODESTRAL_API_KEY_ENV_VAR_NAME} environment variable") - } else { - "Codestral API key configured".to_string() - }; - - if should_show_editor { - v_flex() - .id("codestral") - .size_full() - .mt_2() - .on_action(cx.listener(Self::save_codestral_api_key)) - .child(Label::new( - "To use Codestral as an edit prediction provider, \ - you need to add a Codestral-specific API key. Follow these steps:", - )) - .child( - List::new() - .child(InstructionListItem::new( - "Create one by visiting", - Some("the Codestral section of Mistral's console"), - Some("https://console.mistral.ai/codestral"), - )) - .child(InstructionListItem::text_only("Paste your API key below and hit enter")), - ) - .child(self.codestral_api_key_editor.clone()) - .child( - Label::new( - format!("You can also assign the {CODESTRAL_API_KEY_ENV_VAR_NAME} environment variable and restart Zed."), - ) - .size(LabelSize::Small).color(Color::Muted), - ).into_any() - } else { - ConfiguredApiCard::new(configured_card_label) - .disabled(env_var_set) - .on_click(cx.listener(|this, _, window, cx| this.reset_api_key(window, cx))) - .when(env_var_set, |this| { - this.tooltip_label(format!( - "To reset your API key, \ - unset the {CODESTRAL_API_KEY_ENV_VAR_NAME} environment variable." - )) - }) - .on_click( - cx.listener(|this, _, window, cx| this.reset_codestral_api_key(window, cx)), - ) - .into_any_element() - } - } } impl Render for ConfigurationView { @@ -958,17 +834,17 @@ impl Render for ConfigurationView { .child(Label::new("To use Zed's agent with Mistral, you need to add an API key. Follow these steps:")) .child( List::new() - .child(InstructionListItem::new( - "Create one by visiting", - Some("Mistral's console"), - Some("https://console.mistral.ai/api-keys"), - )) - .child(InstructionListItem::text_only( - "Ensure your Mistral account has credits", - )) - .child(InstructionListItem::text_only( - "Paste your API key below and hit enter to start using the assistant", - )), + .child( + ListBulletItem::new("") + .child(Label::new("Create one by visiting")) + .child(ButtonLink::new("Mistral's console", "https://console.mistral.ai/api-keys")) + ) + .child( + ListBulletItem::new("Ensure your Mistral account has credits") + ) + .child( + ListBulletItem::new("Paste your API key below and hit enter to start using the assistant") + ), ) .child(self.api_key_editor.clone()) .child( @@ -977,7 +853,6 @@ impl Render for ConfigurationView { ) .size(LabelSize::Small).color(Color::Muted), ) - .child(self.render_codestral_api_key_editor(cx)) .into_any() } else { v_flex() @@ -994,24 +869,11 @@ impl Render for ConfigurationView { )) }), ) - .child(self.render_codestral_api_key_editor(cx)) .into_any() } } } -fn set_edit_prediction_provider(provider: EditPredictionProvider, cx: &mut App) { - let fs = ::global(cx); - update_settings_file(fs, cx, move |settings, _| { - settings - .project - .all_languages - .features - .get_or_insert_default() - .edit_prediction_provider = Some(provider); - }); -} - #[cfg(test)] mod tests { use super::*; diff --git a/crates/language_models/src/provider/ollama.rs b/crates/language_models/src/provider/ollama.rs index 8345db3cce9fc51c487ec039c4257bfb39b162c3..c961001e65be662e0023b3199f68dfbf4989e604 100644 --- a/crates/language_models/src/provider/ollama.rs +++ b/crates/language_models/src/provider/ollama.rs @@ -5,11 +5,11 @@ use futures::{Stream, TryFutureExt, stream}; use gpui::{AnyView, App, AsyncApp, Context, CursorStyle, Entity, Task}; use http_client::HttpClient; use language_model::{ - AuthenticateError, LanguageModel, LanguageModelCompletionError, LanguageModelCompletionEvent, - LanguageModelId, LanguageModelName, LanguageModelProvider, LanguageModelProviderId, - LanguageModelProviderName, LanguageModelProviderState, LanguageModelRequest, - LanguageModelRequestTool, LanguageModelToolChoice, LanguageModelToolUse, - LanguageModelToolUseId, MessageContent, RateLimiter, Role, StopReason, TokenUsage, + ApiKeyState, AuthenticateError, EnvVar, LanguageModel, LanguageModelCompletionError, + LanguageModelCompletionEvent, LanguageModelId, LanguageModelName, LanguageModelProvider, + LanguageModelProviderId, LanguageModelProviderName, LanguageModelProviderState, + LanguageModelRequest, LanguageModelRequestTool, LanguageModelToolChoice, LanguageModelToolUse, + LanguageModelToolUseId, MessageContent, RateLimiter, Role, StopReason, TokenUsage, env_var, }; use menu; use ollama::{ @@ -22,13 +22,13 @@ use std::pin::Pin; use std::sync::LazyLock; use std::sync::atomic::{AtomicU64, Ordering}; use std::{collections::HashMap, sync::Arc}; -use ui::{ButtonLike, ElevationIndex, List, Tooltip, prelude::*}; +use ui::{ + ButtonLike, ButtonLink, ConfiguredApiCard, ElevationIndex, InlineCode, List, ListBulletItem, + Tooltip, prelude::*, +}; use ui_input::InputField; -use zed_env_vars::{EnvVar, env_var}; use crate::AllLanguageModelSettings; -use crate::api_key::ApiKeyState; -use crate::ui::{ConfiguredApiCard, InstructionListItem}; const OLLAMA_DOWNLOAD_URL: &str = "https://ollama.com/download"; const OLLAMA_LIBRARY_URL: &str = "https://ollama.com/library"; @@ -80,12 +80,9 @@ impl State { fn authenticate(&mut self, cx: &mut Context) -> Task> { let api_url = OllamaLanguageModelProvider::api_url(cx); - let task = self.api_key_state.load_if_needed( - api_url, - &API_KEY_ENV_VAR, - |this| &mut this.api_key_state, - cx, - ); + let task = self + .api_key_state + .load_if_needed(api_url, |this| &mut this.api_key_state, cx); // Always try to fetch models - if no API key is needed (local Ollama), it will work // If API key is needed and provided, it will work @@ -185,7 +182,7 @@ impl OllamaLanguageModelProvider { http_client, fetched_models: Default::default(), fetch_model_task: None, - api_key_state: ApiKeyState::new(Self::api_url(cx)), + api_key_state: ApiKeyState::new(Self::api_url(cx), (*API_KEY_ENV_VAR).clone()), } }), }; @@ -733,15 +730,17 @@ impl ConfigurationView { .child(Label::new("To use local Ollama:")) .child( List::new() - .child(InstructionListItem::new( - "Download and install Ollama from", - Some("ollama.com"), - Some("https://ollama.com/download"), - )) - .child(InstructionListItem::text_only( - "Start Ollama and download a model: `ollama run gpt-oss:20b`", - )) - .child(InstructionListItem::text_only( + .child( + ListBulletItem::new("") + .child(Label::new("Download and install Ollama from")) + .child(ButtonLink::new("ollama.com", "https://ollama.com/download")), + ) + .child( + ListBulletItem::new("") + .child(Label::new("Start Ollama and download a model:")) + .child(InlineCode::new("ollama run gpt-oss:20b")), + ) + .child(ListBulletItem::new( "Click 'Connect' below to start using Ollama in Zed", )), ) diff --git a/crates/language_models/src/provider/open_ai.rs b/crates/language_models/src/provider/open_ai.rs index 403b025f518681f335f28e35d11450bef046fca2..afaffba3e53eb2496f9fae795d69b9e9c9f57249 100644 --- a/crates/language_models/src/provider/open_ai.rs +++ b/crates/language_models/src/provider/open_ai.rs @@ -5,11 +5,11 @@ use futures::{FutureExt, StreamExt, future, future::BoxFuture}; use gpui::{AnyView, App, AsyncApp, Context, Entity, SharedString, Task, Window}; use http_client::HttpClient; use language_model::{ - AuthenticateError, LanguageModel, LanguageModelCompletionError, LanguageModelCompletionEvent, - LanguageModelId, LanguageModelName, LanguageModelProvider, LanguageModelProviderId, - LanguageModelProviderName, LanguageModelProviderState, LanguageModelRequest, - LanguageModelToolChoice, LanguageModelToolResultContent, LanguageModelToolUse, MessageContent, - RateLimiter, Role, StopReason, TokenUsage, + ApiKeyState, AuthenticateError, EnvVar, LanguageModel, LanguageModelCompletionError, + LanguageModelCompletionEvent, LanguageModelId, LanguageModelName, LanguageModelProvider, + LanguageModelProviderId, LanguageModelProviderName, LanguageModelProviderState, + LanguageModelRequest, LanguageModelToolChoice, LanguageModelToolResultContent, + LanguageModelToolUse, MessageContent, RateLimiter, Role, StopReason, TokenUsage, env_var, }; use menu; use open_ai::{ @@ -20,13 +20,9 @@ use std::pin::Pin; use std::str::FromStr as _; use std::sync::{Arc, LazyLock}; use strum::IntoEnumIterator; -use ui::{List, prelude::*}; +use ui::{ButtonLink, ConfiguredApiCard, List, ListBulletItem, prelude::*}; use ui_input::InputField; use util::ResultExt; -use zed_env_vars::{EnvVar, env_var}; - -use crate::ui::ConfiguredApiCard; -use crate::{api_key::ApiKeyState, ui::InstructionListItem}; const PROVIDER_ID: LanguageModelProviderId = language_model::OPEN_AI_PROVIDER_ID; const PROVIDER_NAME: LanguageModelProviderName = language_model::OPEN_AI_PROVIDER_NAME; @@ -62,12 +58,8 @@ impl State { fn authenticate(&mut self, cx: &mut Context) -> Task> { let api_url = OpenAiLanguageModelProvider::api_url(cx); - self.api_key_state.load_if_needed( - api_url, - &API_KEY_ENV_VAR, - |this| &mut this.api_key_state, - cx, - ) + self.api_key_state + .load_if_needed(api_url, |this| &mut this.api_key_state, cx) } } @@ -76,17 +68,13 @@ impl OpenAiLanguageModelProvider { let state = cx.new(|cx| { cx.observe_global::(|this: &mut State, cx| { let api_url = Self::api_url(cx); - this.api_key_state.handle_url_change( - api_url, - &API_KEY_ENV_VAR, - |this| &mut this.api_key_state, - cx, - ); + this.api_key_state + .handle_url_change(api_url, |this| &mut this.api_key_state, cx); cx.notify(); }) .detach(); State { - api_key_state: ApiKeyState::new(Self::api_url(cx)), + api_key_state: ApiKeyState::new(Self::api_url(cx), (*API_KEY_ENV_VAR).clone()), } }); @@ -790,17 +778,17 @@ impl Render for ConfigurationView { .child(Label::new("To use Zed's agent with OpenAI, you need to add an API key. Follow these steps:")) .child( List::new() - .child(InstructionListItem::new( - "Create one by visiting", - Some("OpenAI's console"), - Some("https://platform.openai.com/api-keys"), - )) - .child(InstructionListItem::text_only( - "Ensure your OpenAI account has credits", - )) - .child(InstructionListItem::text_only( - "Paste your API key below and hit enter to start using the assistant", - )), + .child( + ListBulletItem::new("") + .child(Label::new("Create one by visiting")) + .child(ButtonLink::new("OpenAI's console", "https://platform.openai.com/api-keys")) + ) + .child( + ListBulletItem::new("Ensure your OpenAI account has credits") + ) + .child( + ListBulletItem::new("Paste your API key below and hit enter to start using the agent") + ), ) .child(self.api_key_editor.clone()) .child( diff --git a/crates/language_models/src/provider/open_ai_compatible.rs b/crates/language_models/src/provider/open_ai_compatible.rs index a30c8bfa5d3a728d6dd388f8e768cd470ee9736d..e6e7a9984da3d48b9e3c0f9571b8e916359fba03 100644 --- a/crates/language_models/src/provider/open_ai_compatible.rs +++ b/crates/language_models/src/provider/open_ai_compatible.rs @@ -4,10 +4,10 @@ use futures::{FutureExt, StreamExt, future, future::BoxFuture}; use gpui::{AnyView, App, AsyncApp, Context, Entity, SharedString, Task, Window}; use http_client::HttpClient; use language_model::{ - AuthenticateError, LanguageModel, LanguageModelCompletionError, LanguageModelCompletionEvent, - LanguageModelId, LanguageModelName, LanguageModelProvider, LanguageModelProviderId, - LanguageModelProviderName, LanguageModelProviderState, LanguageModelRequest, - LanguageModelToolChoice, LanguageModelToolSchemaFormat, RateLimiter, + ApiKeyState, AuthenticateError, EnvVar, LanguageModel, LanguageModelCompletionError, + LanguageModelCompletionEvent, LanguageModelId, LanguageModelName, LanguageModelProvider, + LanguageModelProviderId, LanguageModelProviderName, LanguageModelProviderState, + LanguageModelRequest, LanguageModelToolChoice, LanguageModelToolSchemaFormat, RateLimiter, }; use menu; use open_ai::{ResponseStreamEvent, stream_completion}; @@ -16,9 +16,7 @@ use std::sync::Arc; use ui::{ElevationIndex, Tooltip, prelude::*}; use ui_input::InputField; use util::ResultExt; -use zed_env_vars::EnvVar; -use crate::api_key::ApiKeyState; use crate::provider::open_ai::{OpenAiEventMapper, into_open_ai}; pub use settings::OpenAiCompatibleAvailableModel as AvailableModel; pub use settings::OpenAiCompatibleModelCapabilities as ModelCapabilities; @@ -38,7 +36,6 @@ pub struct OpenAiCompatibleLanguageModelProvider { pub struct State { id: Arc, - api_key_env_var: EnvVar, api_key_state: ApiKeyState, settings: OpenAiCompatibleSettings, } @@ -56,12 +53,8 @@ impl State { fn authenticate(&mut self, cx: &mut Context) -> Task> { let api_url = SharedString::new(self.settings.api_url.clone()); - self.api_key_state.load_if_needed( - api_url, - &self.api_key_env_var, - |this| &mut this.api_key_state, - cx, - ) + self.api_key_state + .load_if_needed(api_url, |this| &mut this.api_key_state, cx) } } @@ -83,7 +76,6 @@ impl OpenAiCompatibleLanguageModelProvider { let api_url = SharedString::new(settings.api_url.as_str()); this.api_key_state.handle_url_change( api_url, - &this.api_key_env_var, |this| &mut this.api_key_state, cx, ); @@ -95,8 +87,10 @@ impl OpenAiCompatibleLanguageModelProvider { let settings = resolve_settings(&id, cx).cloned().unwrap_or_default(); State { id: id.clone(), - api_key_env_var: EnvVar::new(api_key_env_var_name), - api_key_state: ApiKeyState::new(SharedString::new(settings.api_url.as_str())), + api_key_state: ApiKeyState::new( + SharedString::new(settings.api_url.as_str()), + EnvVar::new(api_key_env_var_name), + ), settings, } }); @@ -437,7 +431,7 @@ impl Render for ConfigurationView { fn render(&mut self, _: &mut Window, cx: &mut Context) -> impl IntoElement { let state = self.state.read(cx); let env_var_set = state.api_key_state.is_from_env_var(); - let env_var_name = &state.api_key_env_var.name; + let env_var_name = state.api_key_state.env_var_name(); let api_key_section = if self.should_render_editor(cx) { v_flex() diff --git a/crates/language_models/src/provider/open_router.rs b/crates/language_models/src/provider/open_router.rs index 7b10ebf963033603ede691fa72d2fa523bcdbab9..ad2e90d9dd5f4ece7e2582a867da50f6962c981c 100644 --- a/crates/language_models/src/provider/open_router.rs +++ b/crates/language_models/src/provider/open_router.rs @@ -4,11 +4,12 @@ use futures::{FutureExt, Stream, StreamExt, future, future::BoxFuture}; use gpui::{AnyView, App, AsyncApp, Context, Entity, SharedString, Task}; use http_client::HttpClient; use language_model::{ - AuthenticateError, LanguageModel, LanguageModelCompletionError, LanguageModelCompletionEvent, - LanguageModelId, LanguageModelName, LanguageModelProvider, LanguageModelProviderId, - LanguageModelProviderName, LanguageModelProviderState, LanguageModelRequest, - LanguageModelToolChoice, LanguageModelToolResultContent, LanguageModelToolSchemaFormat, - LanguageModelToolUse, MessageContent, RateLimiter, Role, StopReason, TokenUsage, + ApiKeyState, AuthenticateError, EnvVar, LanguageModel, LanguageModelCompletionError, + LanguageModelCompletionEvent, LanguageModelId, LanguageModelName, LanguageModelProvider, + LanguageModelProviderId, LanguageModelProviderName, LanguageModelProviderState, + LanguageModelRequest, LanguageModelToolChoice, LanguageModelToolResultContent, + LanguageModelToolSchemaFormat, LanguageModelToolUse, MessageContent, RateLimiter, Role, + StopReason, TokenUsage, env_var, }; use open_router::{ Model, ModelMode as OpenRouterModelMode, OPEN_ROUTER_API_URL, ResponseStreamEvent, list_models, @@ -17,13 +18,9 @@ use settings::{OpenRouterAvailableModel as AvailableModel, Settings, SettingsSto use std::pin::Pin; use std::str::FromStr as _; use std::sync::{Arc, LazyLock}; -use ui::{List, prelude::*}; +use ui::{ButtonLink, ConfiguredApiCard, List, ListBulletItem, prelude::*}; use ui_input::InputField; use util::ResultExt; -use zed_env_vars::{EnvVar, env_var}; - -use crate::ui::ConfiguredApiCard; -use crate::{api_key::ApiKeyState, ui::InstructionListItem}; const PROVIDER_ID: LanguageModelProviderId = LanguageModelProviderId::new("openrouter"); const PROVIDER_NAME: LanguageModelProviderName = LanguageModelProviderName::new("OpenRouter"); @@ -62,12 +59,9 @@ impl State { fn authenticate(&mut self, cx: &mut Context) -> Task> { let api_url = OpenRouterLanguageModelProvider::api_url(cx); - let task = self.api_key_state.load_if_needed( - api_url, - &API_KEY_ENV_VAR, - |this| &mut this.api_key_state, - cx, - ); + let task = self + .api_key_state + .load_if_needed(api_url, |this| &mut this.api_key_state, cx); cx.spawn(async move |this, cx| { let result = task.await; @@ -135,7 +129,7 @@ impl OpenRouterLanguageModelProvider { }) .detach(); State { - api_key_state: ApiKeyState::new(Self::api_url(cx)), + api_key_state: ApiKeyState::new(Self::api_url(cx), (*API_KEY_ENV_VAR).clone()), http_client: http_client.clone(), available_models: Vec::new(), fetch_models_task: None, @@ -830,17 +824,15 @@ impl Render for ConfigurationView { .child(Label::new("To use Zed's agent with OpenRouter, you need to add an API key. Follow these steps:")) .child( List::new() - .child(InstructionListItem::new( - "Create an API key by visiting", - Some("OpenRouter's console"), - Some("https://openrouter.ai/keys"), - )) - .child(InstructionListItem::text_only( - "Ensure your OpenRouter account has credits", - )) - .child(InstructionListItem::text_only( - "Paste your API key below and hit enter to start using the assistant", - )), + .child( + ListBulletItem::new("") + .child(Label::new("Create an API key by visiting")) + .child(ButtonLink::new("OpenRouter's console", "https://openrouter.ai/keys")) + ) + .child(ListBulletItem::new("Ensure your OpenRouter account has credits") + ) + .child(ListBulletItem::new("Paste your API key below and hit enter to start using the assistant") + ), ) .child(self.api_key_editor.clone()) .child( diff --git a/crates/language_models/src/provider/vercel.rs b/crates/language_models/src/provider/vercel.rs index 061dc1799922c03952b1a96e2785425f61bcf00b..4dfe848df80123dc4c37d27b81f76db359e076f9 100644 --- a/crates/language_models/src/provider/vercel.rs +++ b/crates/language_models/src/provider/vercel.rs @@ -4,26 +4,20 @@ use futures::{FutureExt, StreamExt, future, future::BoxFuture}; use gpui::{AnyView, App, AsyncApp, Context, Entity, SharedString, Task, Window}; use http_client::HttpClient; use language_model::{ - AuthenticateError, LanguageModel, LanguageModelCompletionError, LanguageModelCompletionEvent, - LanguageModelId, LanguageModelName, LanguageModelProvider, LanguageModelProviderId, - LanguageModelProviderName, LanguageModelProviderState, LanguageModelRequest, - LanguageModelToolChoice, RateLimiter, Role, + ApiKeyState, AuthenticateError, EnvVar, LanguageModel, LanguageModelCompletionError, + LanguageModelCompletionEvent, LanguageModelId, LanguageModelName, LanguageModelProvider, + LanguageModelProviderId, LanguageModelProviderName, LanguageModelProviderState, + LanguageModelRequest, LanguageModelToolChoice, RateLimiter, Role, env_var, }; use open_ai::ResponseStreamEvent; pub use settings::VercelAvailableModel as AvailableModel; use settings::{Settings, SettingsStore}; use std::sync::{Arc, LazyLock}; use strum::IntoEnumIterator; -use ui::{List, prelude::*}; +use ui::{ButtonLink, ConfiguredApiCard, List, ListBulletItem, prelude::*}; use ui_input::InputField; use util::ResultExt; use vercel::{Model, VERCEL_API_URL}; -use zed_env_vars::{EnvVar, env_var}; - -use crate::{ - api_key::ApiKeyState, - ui::{ConfiguredApiCard, InstructionListItem}, -}; const PROVIDER_ID: LanguageModelProviderId = LanguageModelProviderId::new("vercel"); const PROVIDER_NAME: LanguageModelProviderName = LanguageModelProviderName::new("Vercel"); @@ -59,12 +53,8 @@ impl State { fn authenticate(&mut self, cx: &mut Context) -> Task> { let api_url = VercelLanguageModelProvider::api_url(cx); - self.api_key_state.load_if_needed( - api_url, - &API_KEY_ENV_VAR, - |this| &mut this.api_key_state, - cx, - ) + self.api_key_state + .load_if_needed(api_url, |this| &mut this.api_key_state, cx) } } @@ -73,17 +63,13 @@ impl VercelLanguageModelProvider { let state = cx.new(|cx| { cx.observe_global::(|this: &mut State, cx| { let api_url = Self::api_url(cx); - this.api_key_state.handle_url_change( - api_url, - &API_KEY_ENV_VAR, - |this| &mut this.api_key_state, - cx, - ); + this.api_key_state + .handle_url_change(api_url, |this| &mut this.api_key_state, cx); cx.notify(); }) .detach(); State { - api_key_state: ApiKeyState::new(Self::api_url(cx)), + api_key_state: ApiKeyState::new(Self::api_url(cx), (*API_KEY_ENV_VAR).clone()), } }); @@ -472,14 +458,14 @@ impl Render for ConfigurationView { .child(Label::new("To use Zed's agent with Vercel v0, you need to add an API key. Follow these steps:")) .child( List::new() - .child(InstructionListItem::new( - "Create one by visiting", - Some("Vercel v0's console"), - Some("https://v0.dev/chat/settings/keys"), - )) - .child(InstructionListItem::text_only( - "Paste your API key below and hit enter to start using the agent", - )), + .child( + ListBulletItem::new("") + .child(Label::new("Create one by visiting")) + .child(ButtonLink::new("Vercel v0's console", "https://v0.dev/chat/settings/keys")) + ) + .child( + ListBulletItem::new("Paste your API key below and hit enter to start using the agent") + ), ) .child(self.api_key_editor.clone()) .child( diff --git a/crates/language_models/src/provider/x_ai.rs b/crates/language_models/src/provider/x_ai.rs index cc54dfa0dd8a3f2ca6ab2b769a779afa8e73988b..19c50d71cf4e483b68d48c8b982a975f3091ff46 100644 --- a/crates/language_models/src/provider/x_ai.rs +++ b/crates/language_models/src/provider/x_ai.rs @@ -4,26 +4,21 @@ use futures::{FutureExt, StreamExt, future, future::BoxFuture}; use gpui::{AnyView, App, AsyncApp, Context, Entity, Task, Window}; use http_client::HttpClient; use language_model::{ - AuthenticateError, LanguageModel, LanguageModelCompletionError, LanguageModelCompletionEvent, - LanguageModelId, LanguageModelName, LanguageModelProvider, LanguageModelProviderId, - LanguageModelProviderName, LanguageModelProviderState, LanguageModelRequest, - LanguageModelToolChoice, LanguageModelToolSchemaFormat, RateLimiter, Role, + ApiKeyState, AuthenticateError, EnvVar, LanguageModel, LanguageModelCompletionError, + LanguageModelCompletionEvent, LanguageModelId, LanguageModelName, LanguageModelProvider, + LanguageModelProviderId, LanguageModelProviderName, LanguageModelProviderState, + LanguageModelRequest, LanguageModelToolChoice, LanguageModelToolSchemaFormat, RateLimiter, + Role, env_var, }; use open_ai::ResponseStreamEvent; pub use settings::XaiAvailableModel as AvailableModel; use settings::{Settings, SettingsStore}; use std::sync::{Arc, LazyLock}; use strum::IntoEnumIterator; -use ui::{List, prelude::*}; +use ui::{ButtonLink, ConfiguredApiCard, List, ListBulletItem, prelude::*}; use ui_input::InputField; use util::ResultExt; use x_ai::{Model, XAI_API_URL}; -use zed_env_vars::{EnvVar, env_var}; - -use crate::{ - api_key::ApiKeyState, - ui::{ConfiguredApiCard, InstructionListItem}, -}; const PROVIDER_ID: LanguageModelProviderId = LanguageModelProviderId::new("x_ai"); const PROVIDER_NAME: LanguageModelProviderName = LanguageModelProviderName::new("xAI"); @@ -59,12 +54,8 @@ impl State { fn authenticate(&mut self, cx: &mut Context) -> Task> { let api_url = XAiLanguageModelProvider::api_url(cx); - self.api_key_state.load_if_needed( - api_url, - &API_KEY_ENV_VAR, - |this| &mut this.api_key_state, - cx, - ) + self.api_key_state + .load_if_needed(api_url, |this| &mut this.api_key_state, cx) } } @@ -73,17 +64,13 @@ impl XAiLanguageModelProvider { let state = cx.new(|cx| { cx.observe_global::(|this: &mut State, cx| { let api_url = Self::api_url(cx); - this.api_key_state.handle_url_change( - api_url, - &API_KEY_ENV_VAR, - |this| &mut this.api_key_state, - cx, - ); + this.api_key_state + .handle_url_change(api_url, |this| &mut this.api_key_state, cx); cx.notify(); }) .detach(); State { - api_key_state: ApiKeyState::new(Self::api_url(cx)), + api_key_state: ApiKeyState::new(Self::api_url(cx), (*API_KEY_ENV_VAR).clone()), } }); @@ -474,14 +461,14 @@ impl Render for ConfigurationView { .child(Label::new("To use Zed's agent with xAI, you need to add an API key. Follow these steps:")) .child( List::new() - .child(InstructionListItem::new( - "Create one by visiting", - Some("xAI console"), - Some("https://console.x.ai/team/default/api-keys"), - )) - .child(InstructionListItem::text_only( - "Paste your API key below and hit enter to start using the agent", - )), + .child( + ListBulletItem::new("") + .child(Label::new("Create one by visiting")) + .child(ButtonLink::new("xAI console", "https://console.x.ai/team/default/api-keys")) + ) + .child( + ListBulletItem::new("Paste your API key below and hit enter to start using the agent") + ), ) .child(self.api_key_editor.clone()) .child( diff --git a/crates/language_models/src/ui.rs b/crates/language_models/src/ui.rs deleted file mode 100644 index 1d7796ecc2b6c2a78b3ebc02dc9cd29bd8cfa2c6..0000000000000000000000000000000000000000 --- a/crates/language_models/src/ui.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub mod configured_api_card; -pub mod instruction_list_item; -pub use configured_api_card::ConfiguredApiCard; -pub use instruction_list_item::InstructionListItem; diff --git a/crates/language_models/src/ui/instruction_list_item.rs b/crates/language_models/src/ui/instruction_list_item.rs deleted file mode 100644 index bdb5fbe242ee902dc98a37addfaa0f103ef9ad20..0000000000000000000000000000000000000000 --- a/crates/language_models/src/ui/instruction_list_item.rs +++ /dev/null @@ -1,69 +0,0 @@ -use gpui::{AnyElement, IntoElement, ParentElement, SharedString}; -use ui::{ListItem, prelude::*}; - -/// A reusable list item component for adding LLM provider configuration instructions -pub struct InstructionListItem { - label: SharedString, - button_label: Option, - button_link: Option, -} - -impl InstructionListItem { - pub fn new( - label: impl Into, - button_label: Option>, - button_link: Option>, - ) -> Self { - Self { - label: label.into(), - button_label: button_label.map(|l| l.into()), - button_link: button_link.map(|l| l.into()), - } - } - - pub fn text_only(label: impl Into) -> Self { - Self { - label: label.into(), - button_label: None, - button_link: None, - } - } -} - -impl IntoElement for InstructionListItem { - type Element = AnyElement; - - fn into_element(self) -> Self::Element { - let item_content = if let (Some(button_label), Some(button_link)) = - (self.button_label, self.button_link) - { - let link = button_link; - let unique_id = SharedString::from(format!("{}-button", self.label)); - - h_flex() - .flex_wrap() - .child(Label::new(self.label)) - .child( - Button::new(unique_id, button_label) - .style(ButtonStyle::Subtle) - .icon(IconName::ArrowUpRight) - .icon_size(IconSize::Small) - .icon_color(Color::Muted) - .on_click(move |_, _window, cx| cx.open_url(&link)), - ) - .into_any_element() - } else { - Label::new(self.label).into_any_element() - }; - - ListItem::new("list-item") - .selectable(false) - .start_slot( - Icon::new(IconName::Dash) - .size(IconSize::XSmall) - .color(Color::Hidden), - ) - .child(div().w_full().child(item_content)) - .into_any_element() - } -} diff --git a/crates/settings/src/settings_content/language.rs b/crates/settings/src/settings_content/language.rs index 25ff60e9f46cf797b815227222a3d27a6353c396..f9c85f18f380a7ad82b0d8bc202fe3763ba3a832 100644 --- a/crates/settings/src/settings_content/language.rs +++ b/crates/settings/src/settings_content/language.rs @@ -186,22 +186,20 @@ pub struct CopilotSettingsContent { pub enterprise_uri: Option, } +#[with_fallible_options] #[derive(Clone, Debug, Default, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)] pub struct CodestralSettingsContent { /// Model to use for completions. /// /// Default: "codestral-latest" - #[serde(default)] pub model: Option, /// Maximum tokens to generate. /// /// Default: 150 - #[serde(default)] pub max_tokens: Option, /// Api URL to use for completions. /// /// Default: "https://codestral.mistral.ai" - #[serde(default)] pub api_url: Option, } diff --git a/crates/settings_ui/Cargo.toml b/crates/settings_ui/Cargo.toml index b5a259a3b9f901f4885b1cde8ad1e933efb263c0..256ec2de557e903405d1c3431ef44e98d757d3c6 100644 --- a/crates/settings_ui/Cargo.toml +++ b/crates/settings_ui/Cargo.toml @@ -18,6 +18,9 @@ test-support = [] [dependencies] anyhow.workspace = true bm25 = "2.3.2" +copilot.workspace = true +edit_prediction.workspace = true +language_models.workspace = true editor.workspace = true feature_flags.workspace = true fs.workspace = true @@ -38,8 +41,8 @@ strum.workspace = true telemetry.workspace = true theme.workspace = true title_bar.workspace = true -ui.workspace = true ui_input.workspace = true +ui.workspace = true util.workspace = true workspace.workspace = true zed_actions.workspace = true diff --git a/crates/settings_ui/src/components.rs b/crates/settings_ui/src/components.rs index b073372ac9b625036252e0a1722a960c8f6b3c45..f9754b0c749a77423930ef881e5b60ad3535b83d 100644 --- a/crates/settings_ui/src/components.rs +++ b/crates/settings_ui/src/components.rs @@ -2,10 +2,12 @@ mod dropdown; mod font_picker; mod icon_theme_picker; mod input_field; +mod section_items; mod theme_picker; pub use dropdown::*; pub use font_picker::font_picker; pub use icon_theme_picker::icon_theme_picker; pub use input_field::*; +pub use section_items::*; pub use theme_picker::theme_picker; diff --git a/crates/settings_ui/src/components/input_field.rs b/crates/settings_ui/src/components/input_field.rs index 57917c321127baf2e96e3862106461331afaf86f..575da7f7ae13f8a304b23d57dd41607e7b7c512a 100644 --- a/crates/settings_ui/src/components/input_field.rs +++ b/crates/settings_ui/src/components/input_field.rs @@ -13,6 +13,7 @@ pub struct SettingsInputField { tab_index: Option, } +// TODO: Update the `ui_input::InputField` to use `window.use_state` and `RenceOnce` and remove this component impl SettingsInputField { pub fn new() -> Self { Self { diff --git a/crates/settings_ui/src/components/section_items.rs b/crates/settings_ui/src/components/section_items.rs new file mode 100644 index 0000000000000000000000000000000000000000..69559d24f447f3d218b296600ed1ecdd9bf1dc30 --- /dev/null +++ b/crates/settings_ui/src/components/section_items.rs @@ -0,0 +1,56 @@ +use gpui::{IntoElement, ParentElement, Styled}; +use ui::{Divider, DividerColor, prelude::*}; + +#[derive(IntoElement)] +pub struct SettingsSectionHeader { + icon: Option, + label: SharedString, + no_padding: bool, +} + +impl SettingsSectionHeader { + pub fn new(label: impl Into) -> Self { + Self { + label: label.into(), + icon: None, + no_padding: false, + } + } + + pub fn icon(mut self, icon: IconName) -> Self { + self.icon = Some(icon); + self + } + + pub fn no_padding(mut self, no_padding: bool) -> Self { + self.no_padding = no_padding; + self + } +} + +impl RenderOnce for SettingsSectionHeader { + fn render(self, _: &mut Window, cx: &mut App) -> impl IntoElement { + let label = Label::new(self.label) + .size(LabelSize::Small) + .color(Color::Muted) + .buffer_font(cx); + + v_flex() + .w_full() + .when(!self.no_padding, |this| this.px_8()) + .gap_1p5() + .map(|this| { + if self.icon.is_some() { + this.child( + h_flex() + .gap_1p5() + .child(Icon::new(self.icon.unwrap()).color(Color::Muted)) + .child(label), + ) + } else { + this.child(label) + } + }) + .child(Divider::horizontal().color(DividerColor::BorderFaded)) + } +} diff --git a/crates/settings_ui/src/page_data.rs b/crates/settings_ui/src/page_data.rs index 8652ccf68b48e8e858b96e4fe69edecd8ae29d25..b03ce327877f7251d41c39ee1eed5d424c18ce84 100644 --- a/crates/settings_ui/src/page_data.rs +++ b/crates/settings_ui/src/page_data.rs @@ -2330,8 +2330,12 @@ pub(crate) fn settings_data(cx: &App) -> Vec { // Note that `crates/json_schema_store` solves the same problem, there is probably a way to unify the two items.push(SettingsPageItem::SectionHeader(LANGUAGES_SECTION_HEADER)); items.extend(all_language_names(cx).into_iter().map(|language_name| { + let link = format!("languages.{language_name}"); SettingsPageItem::SubPageLink(SubPageLink { title: language_name, + description: None, + json_path: Some(link.leak()), + in_json: true, files: USER | PROJECT, render: Arc::new(|this, window, cx| { this.render_sub_page_items( @@ -6013,7 +6017,7 @@ pub(crate) fn settings_data(cx: &App) -> Vec { files: USER, }), SettingsPageItem::SettingItem(SettingItem { - title: "In Text Threads", + title: "Display In Text Threads", description: "Whether edit predictions are enabled when editing text threads in the agent panel.", field: Box::new(SettingField { json_path: Some("edit_prediction.in_text_threads"), @@ -6027,42 +6031,6 @@ pub(crate) fn settings_data(cx: &App) -> Vec { metadata: None, files: USER, }), - SettingsPageItem::SettingItem(SettingItem { - title: "Copilot Provider", - description: "Use GitHub Copilot as your edit prediction provider.", - field: Box::new( - SettingField { - json_path: Some("edit_prediction.copilot_provider"), - pick: |settings_content| { - settings_content.project.all_languages.edit_predictions.as_ref()?.copilot.as_ref() - }, - write: |settings_content, value| { - settings_content.project.all_languages.edit_predictions.get_or_insert_default().copilot = value; - }, - } - .unimplemented(), - ), - metadata: None, - files: USER | PROJECT, - }), - SettingsPageItem::SettingItem(SettingItem { - title: "Codestral Provider", - description: "Use Mistral's Codestral as your edit prediction provider.", - field: Box::new( - SettingField { - json_path: Some("edit_prediction.codestral_provider"), - pick: |settings_content| { - settings_content.project.all_languages.edit_predictions.as_ref()?.codestral.as_ref() - }, - write: |settings_content, value| { - settings_content.project.all_languages.edit_predictions.get_or_insert_default().codestral = value; - }, - } - .unimplemented(), - ), - metadata: None, - files: USER | PROJECT, - }), ] ); items @@ -7485,9 +7453,23 @@ fn non_editor_language_settings_data() -> Vec { fn edit_prediction_language_settings_section() -> Vec { vec![ SettingsPageItem::SectionHeader("Edit Predictions"), + SettingsPageItem::SubPageLink(SubPageLink { + title: "Configure Providers".into(), + json_path: Some("edit_predictions.providers"), + description: Some("Set up different edit prediction providers in complement to Zed's built-in Zeta model.".into()), + in_json: false, + files: USER, + render: Arc::new(|_, window, cx| { + let settings_window = cx.entity(); + let page = window.use_state(cx, |_, _| { + crate::pages::EditPredictionSetupPage::new(settings_window) + }); + page.into_any_element() + }), + }), SettingsPageItem::SettingItem(SettingItem { title: "Show Edit Predictions", - description: "Controls whether edit predictions are shown immediately or manually by triggering `editor::showeditprediction` (false).", + description: "Controls whether edit predictions are shown immediately or manually.", field: Box::new(SettingField { json_path: Some("languages.$(language).show_edit_predictions"), pick: |settings_content| { @@ -7505,7 +7487,7 @@ fn edit_prediction_language_settings_section() -> Vec { files: USER | PROJECT, }), SettingsPageItem::SettingItem(SettingItem { - title: "Edit Predictions Disabled In", + title: "Disable in Language Scopes", description: "Controls whether edit predictions are shown in the given language scopes.", field: Box::new( SettingField { diff --git a/crates/settings_ui/src/pages.rs b/crates/settings_ui/src/pages.rs new file mode 100644 index 0000000000000000000000000000000000000000..2b2c4818c1322216707f38bf93cefffeb14add03 --- /dev/null +++ b/crates/settings_ui/src/pages.rs @@ -0,0 +1,2 @@ +mod edit_prediction_provider_setup; +pub use edit_prediction_provider_setup::EditPredictionSetupPage; diff --git a/crates/settings_ui/src/pages/edit_prediction_provider_setup.rs b/crates/settings_ui/src/pages/edit_prediction_provider_setup.rs new file mode 100644 index 0000000000000000000000000000000000000000..fb8f967613fa195080f62c5ab2ce76a43f3d1e22 --- /dev/null +++ b/crates/settings_ui/src/pages/edit_prediction_provider_setup.rs @@ -0,0 +1,365 @@ +use edit_prediction::{ + ApiKeyState, Zeta2FeatureFlag, + mercury::{MERCURY_CREDENTIALS_URL, mercury_api_token}, + sweep_ai::{SWEEP_CREDENTIALS_URL, sweep_api_token}, +}; +use feature_flags::FeatureFlagAppExt as _; +use gpui::{Entity, ScrollHandle, prelude::*}; +use language_models::provider::mistral::{CODESTRAL_API_URL, codestral_api_key}; +use ui::{ButtonLink, ConfiguredApiCard, WithScrollbar, prelude::*}; + +use crate::{ + SettingField, SettingItem, SettingsFieldMetadata, SettingsPageItem, SettingsWindow, USER, + components::{SettingsInputField, SettingsSectionHeader}, +}; + +pub struct EditPredictionSetupPage { + settings_window: Entity, + scroll_handle: ScrollHandle, +} + +impl EditPredictionSetupPage { + pub fn new(settings_window: Entity) -> Self { + Self { + settings_window, + scroll_handle: ScrollHandle::new(), + } + } +} + +impl Render for EditPredictionSetupPage { + fn render(&mut self, window: &mut Window, cx: &mut Context) -> impl IntoElement { + let settings_window = self.settings_window.clone(); + + let providers = [ + Some(render_github_copilot_provider(window, cx).into_any_element()), + cx.has_flag::().then(|| { + render_api_key_provider( + IconName::Inception, + "Mercury", + "https://platform.inceptionlabs.ai/dashboard/api-keys".into(), + mercury_api_token(cx), + |_cx| MERCURY_CREDENTIALS_URL, + None, + window, + cx, + ) + .into_any_element() + }), + cx.has_flag::().then(|| { + render_api_key_provider( + IconName::SweepAi, + "Sweep", + "https://app.sweep.dev/".into(), + sweep_api_token(cx), + |_cx| SWEEP_CREDENTIALS_URL, + None, + window, + cx, + ) + .into_any_element() + }), + Some( + render_api_key_provider( + IconName::AiMistral, + "Codestral", + "https://console.mistral.ai/codestral".into(), + codestral_api_key(cx), + |cx| language_models::MistralLanguageModelProvider::api_url(cx), + Some(settings_window.update(cx, |settings_window, cx| { + let codestral_settings = codestral_settings(); + settings_window + .render_sub_page_items_section( + codestral_settings.iter().enumerate(), + None, + window, + cx, + ) + .into_any_element() + })), + window, + cx, + ) + .into_any_element(), + ), + ]; + + div() + .size_full() + .vertical_scrollbar_for(&self.scroll_handle, window, cx) + .child( + v_flex() + .id("ep-setup-page") + .min_w_0() + .size_full() + .px_8() + .pb_16() + .overflow_y_scroll() + .track_scroll(&self.scroll_handle) + .children(providers.into_iter().flatten()), + ) + } +} + +fn render_api_key_provider( + icon: IconName, + title: &'static str, + link: SharedString, + api_key_state: Entity, + current_url: fn(&mut App) -> SharedString, + additional_fields: Option, + window: &mut Window, + cx: &mut Context, +) -> impl IntoElement { + let weak_page = cx.weak_entity(); + _ = window.use_keyed_state(title, cx, |_, cx| { + let task = api_key_state.update(cx, |key_state, cx| { + key_state.load_if_needed(current_url(cx), |state| state, cx) + }); + cx.spawn(async move |_, cx| { + task.await.ok(); + weak_page + .update(cx, |_, cx| { + cx.notify(); + }) + .ok(); + }) + }); + + let (has_key, env_var_name, is_from_env_var) = api_key_state.read_with(cx, |state, _| { + ( + state.has_key(), + Some(state.env_var_name().clone()), + state.is_from_env_var(), + ) + }); + + let write_key = move |api_key: Option, cx: &mut App| { + api_key_state + .update(cx, |key_state, cx| { + let url = current_url(cx); + key_state.store(url, api_key, |key_state| key_state, cx) + }) + .detach_and_log_err(cx); + }; + + let base_container = v_flex().id(title).min_w_0().pt_8().gap_1p5(); + let header = SettingsSectionHeader::new(title) + .icon(icon) + .no_padding(true); + let button_link_label = format!("{} dashboard", title); + let description = h_flex() + .min_w_0() + .gap_0p5() + .child( + Label::new("Visit the") + .size(LabelSize::Small) + .color(Color::Muted), + ) + .child( + ButtonLink::new(button_link_label, link) + .no_icon(true) + .label_size(LabelSize::Small) + .label_color(Color::Muted), + ) + .child( + Label::new("to generate an API key.") + .size(LabelSize::Small) + .color(Color::Muted), + ); + let configured_card_label = if is_from_env_var { + "API Key Set in Environment Variable" + } else { + "API Key Configured" + }; + + let container = if has_key { + base_container.child(header).child( + ConfiguredApiCard::new(configured_card_label) + .button_label("Reset Key") + .button_tab_index(0) + .disabled(is_from_env_var) + .when_some(env_var_name, |this, env_var_name| { + this.when(is_from_env_var, |this| { + this.tooltip_label(format!( + "To reset your API key, unset the {} environment variable.", + env_var_name + )) + }) + }) + .on_click(move |_, _, cx| { + write_key(None, cx); + }), + ) + } else { + base_container.child(header).child( + h_flex() + .pt_2p5() + .w_full() + .justify_between() + .child( + v_flex() + .w_full() + .max_w_1_2() + .child(Label::new("API Key")) + .child(description) + .when_some(env_var_name, |this, env_var_name| { + this.child({ + let label = format!( + "Or set the {} env var and restart Zed.", + env_var_name.as_ref() + ); + Label::new(label).size(LabelSize::Small).color(Color::Muted) + }) + }), + ) + .child( + SettingsInputField::new() + .tab_index(0) + .with_placeholder("xxxxxxxxxxxxxxxxxxxx") + .on_confirm(move |api_key, cx| { + write_key(api_key.filter(|key| !key.is_empty()), cx); + }), + ), + ) + }; + + container.when_some(additional_fields, |this, additional_fields| { + this.child( + div() + .map(|this| if has_key { this.mt_1() } else { this.mt_4() }) + .px_neg_8() + .border_t_1() + .border_color(cx.theme().colors().border_variant) + .child(additional_fields), + ) + }) +} + +fn codestral_settings() -> Box<[SettingsPageItem]> { + Box::new([ + SettingsPageItem::SettingItem(SettingItem { + title: "API URL", + description: "The API URL to use for Codestral.", + field: Box::new(SettingField { + pick: |settings| { + settings + .project + .all_languages + .edit_predictions + .as_ref()? + .codestral + .as_ref()? + .api_url + .as_ref() + }, + write: |settings, value| { + settings + .project + .all_languages + .edit_predictions + .get_or_insert_default() + .codestral + .get_or_insert_default() + .api_url = value; + }, + json_path: Some("edit_predictions.codestral.api_url"), + }), + metadata: Some(Box::new(SettingsFieldMetadata { + placeholder: Some(CODESTRAL_API_URL), + ..Default::default() + })), + files: USER, + }), + SettingsPageItem::SettingItem(SettingItem { + title: "Max Tokens", + description: "The maximum number of tokens to generate.", + field: Box::new(SettingField { + pick: |settings| { + settings + .project + .all_languages + .edit_predictions + .as_ref()? + .codestral + .as_ref()? + .max_tokens + .as_ref() + }, + write: |settings, value| { + settings + .project + .all_languages + .edit_predictions + .get_or_insert_default() + .codestral + .get_or_insert_default() + .max_tokens = value; + }, + json_path: Some("edit_predictions.codestral.max_tokens"), + }), + metadata: None, + files: USER, + }), + SettingsPageItem::SettingItem(SettingItem { + title: "Model", + description: "The Codestral model id to use.", + field: Box::new(SettingField { + pick: |settings| { + settings + .project + .all_languages + .edit_predictions + .as_ref()? + .codestral + .as_ref()? + .model + .as_ref() + }, + write: |settings, value| { + settings + .project + .all_languages + .edit_predictions + .get_or_insert_default() + .codestral + .get_or_insert_default() + .model = value; + }, + json_path: Some("edit_predictions.codestral.model"), + }), + metadata: Some(Box::new(SettingsFieldMetadata { + placeholder: Some("codestral-latest"), + ..Default::default() + })), + files: USER, + }), + ]) +} + +pub(crate) fn render_github_copilot_provider( + window: &mut Window, + cx: &mut App, +) -> impl IntoElement { + let configuration_view = window.use_state(cx, |_, cx| { + copilot::ConfigurationView::new( + |cx| { + copilot::Copilot::global(cx) + .is_some_and(|copilot| copilot.read(cx).is_authenticated()) + }, + copilot::ConfigurationMode::EditPrediction, + cx, + ) + }); + + v_flex() + .id("github-copilot") + .min_w_0() + .gap_1p5() + .child( + SettingsSectionHeader::new("GitHub Copilot") + .icon(IconName::Copilot) + .no_padding(true), + ) + .child(configuration_view) +} diff --git a/crates/settings_ui/src/settings_ui.rs b/crates/settings_ui/src/settings_ui.rs index 4464d3bdd951d4b7bf2511cfd718b0f297b8fc78..2c5585af5668a4b224d406413ab700bd8b2e349c 100644 --- a/crates/settings_ui/src/settings_ui.rs +++ b/crates/settings_ui/src/settings_ui.rs @@ -1,5 +1,6 @@ mod components; mod page_data; +mod pages; use anyhow::Result; use editor::{Editor, EditorEvent}; @@ -28,9 +29,8 @@ use std::{ }; use title_bar::platform_title_bar::PlatformTitleBar; use ui::{ - Banner, ContextMenu, Divider, DividerColor, DropdownMenu, DropdownStyle, IconButtonShape, - KeyBinding, KeybindingHint, PopoverMenu, Switch, Tooltip, TreeViewItem, WithScrollbar, - prelude::*, + Banner, ContextMenu, Divider, DropdownMenu, DropdownStyle, IconButtonShape, KeyBinding, + KeybindingHint, PopoverMenu, Switch, Tooltip, TreeViewItem, WithScrollbar, prelude::*, }; use ui_input::{NumberField, NumberFieldType}; use util::{ResultExt as _, paths::PathStyle, rel_path::RelPath}; @@ -38,7 +38,8 @@ use workspace::{AppState, OpenOptions, OpenVisible, Workspace, client_side_decor use zed_actions::{OpenProjectSettings, OpenSettings, OpenSettingsAt}; use crate::components::{ - EnumVariantDropdown, SettingsInputField, font_picker, icon_theme_picker, theme_picker, + EnumVariantDropdown, SettingsInputField, SettingsSectionHeader, font_picker, icon_theme_picker, + theme_picker, }; const NAVBAR_CONTAINER_TAB_INDEX: isize = 0; @@ -613,7 +614,10 @@ pub fn open_settings_editor( app_id: Some(app_id.to_owned()), window_decorations: Some(window_decorations), window_min_size: Some(gpui::Size { - width: px(360.0), + // Don't make the settings window thinner than this, + // otherwise, it gets unusable. Users with smaller res monitors + // can customize the height, but not the width. + width: px(900.0), height: px(240.0), }), window_bounds: Some(WindowBounds::centered(scaled_bounds, cx)), @@ -834,18 +838,9 @@ impl SettingsPageItem { }; match self { - SettingsPageItem::SectionHeader(header) => v_flex() - .w_full() - .px_8() - .gap_1p5() - .child( - Label::new(SharedString::new_static(header)) - .size(LabelSize::Small) - .color(Color::Muted) - .buffer_font(cx), - ) - .child(Divider::horizontal().color(DividerColor::BorderFaded)) - .into_any_element(), + SettingsPageItem::SectionHeader(header) => { + SettingsSectionHeader::new(SharedString::new_static(header)).into_any_element() + } SettingsPageItem::SettingItem(setting_item) => { let (field_with_padding, _) = render_setting_item_inner(setting_item, true, false, cx); @@ -869,9 +864,20 @@ impl SettingsPageItem { .map(apply_padding) .child( v_flex() + .relative() .w_full() .max_w_1_2() - .child(Label::new(sub_page_link.title.clone())), + .child(Label::new(sub_page_link.title.clone())) + .when_some( + sub_page_link.description.as_ref(), + |this, description| { + this.child( + Label::new(description.clone()) + .size(LabelSize::Small) + .color(Color::Muted), + ) + }, + ), ) .child( Button::new( @@ -909,7 +915,13 @@ impl SettingsPageItem { this.push_sub_page(sub_page_link.clone(), header, cx) }) }), - ), + ) + .child(render_settings_item_link( + sub_page_link.title.clone(), + sub_page_link.json_path, + false, + cx, + )), ) .when(!is_last, |this| this.child(Divider::horizontal())) .into_any_element(), @@ -983,20 +995,6 @@ fn render_settings_item( let (found_in_file, _) = setting_item.field.file_set_in(file.clone(), cx); let file_set_in = SettingsUiFile::from_settings(found_in_file.clone()); - let clipboard_has_link = cx - .read_from_clipboard() - .and_then(|entry| entry.text()) - .map_or(false, |maybe_url| { - setting_item.field.json_path().is_some() - && maybe_url.strip_prefix("zed://settings/") == setting_item.field.json_path() - }); - - let (link_icon, link_icon_color) = if clipboard_has_link { - (IconName::Check, Color::Success) - } else { - (IconName::Link, Color::Muted) - }; - h_flex() .id(setting_item.title) .min_w_0() @@ -1056,40 +1054,60 @@ fn render_settings_item( ) .child(control) .when(sub_page_stack().is_empty(), |this| { - // Intentionally using the description to make the icon button - // unique because some items share the same title (e.g., "Font Size") - let icon_button_id = - SharedString::new(format!("copy-link-btn-{}", setting_item.description)); + this.child(render_settings_item_link( + setting_item.description, + setting_item.field.json_path(), + sub_field, + cx, + )) + }) +} - this.child( - div() - .absolute() - .top(rems_from_px(18.)) - .map(|this| { - if sub_field { - this.visible_on_hover("setting-sub-item") - .left(rems_from_px(-8.5)) - } else { - this.visible_on_hover("setting-item") - .left(rems_from_px(-22.)) - } - }) - .child({ - IconButton::new(icon_button_id, link_icon) - .icon_color(link_icon_color) - .icon_size(IconSize::Small) - .shape(IconButtonShape::Square) - .tooltip(Tooltip::text("Copy Link")) - .when_some(setting_item.field.json_path(), |this, path| { - this.on_click(cx.listener(move |_, _, _, cx| { - let link = format!("zed://settings/{}", path); - cx.write_to_clipboard(ClipboardItem::new_string(link)); - cx.notify(); - })) - }) - }), - ) +fn render_settings_item_link( + id: impl Into, + json_path: Option<&'static str>, + sub_field: bool, + cx: &mut Context<'_, SettingsWindow>, +) -> impl IntoElement { + let clipboard_has_link = cx + .read_from_clipboard() + .and_then(|entry| entry.text()) + .map_or(false, |maybe_url| { + json_path.is_some() && maybe_url.strip_prefix("zed://settings/") == json_path + }); + + let (link_icon, link_icon_color) = if clipboard_has_link { + (IconName::Check, Color::Success) + } else { + (IconName::Link, Color::Muted) + }; + + div() + .absolute() + .top(rems_from_px(18.)) + .map(|this| { + if sub_field { + this.visible_on_hover("setting-sub-item") + .left(rems_from_px(-8.5)) + } else { + this.visible_on_hover("setting-item") + .left(rems_from_px(-22.)) + } }) + .child( + IconButton::new((id.into(), "copy-link-btn"), link_icon) + .icon_color(link_icon_color) + .icon_size(IconSize::Small) + .shape(IconButtonShape::Square) + .tooltip(Tooltip::text("Copy Link")) + .when_some(json_path, |this, path| { + this.on_click(cx.listener(move |_, _, _, cx| { + let link = format!("zed://settings/{}", path); + cx.write_to_clipboard(ClipboardItem::new_string(link)); + cx.notify(); + })) + }), + ) } struct SettingItem { @@ -1175,6 +1193,12 @@ impl PartialEq for SettingItem { #[derive(Clone)] struct SubPageLink { title: SharedString, + description: Option, + /// See [`SettingField.json_path`] + json_path: Option<&'static str>, + /// Whether or not the settings in this sub page are configurable in settings.json + /// Removes the "Edit in settings.json" button from the page. + in_json: bool, files: FileMask, render: Arc< dyn Fn(&mut SettingsWindow, &mut Window, &mut Context) -> AnyElement @@ -1835,6 +1859,7 @@ impl SettingsWindow { header_str = *header; } SettingsPageItem::SubPageLink(sub_page_link) => { + json_path = sub_page_link.json_path; documents.push(bm25::Document { id: key_index, contents: [page.title, header_str, sub_page_link.title.as_ref()] @@ -2758,19 +2783,49 @@ impl SettingsWindow { page_content } - fn render_sub_page_items<'a, Items: Iterator>( + fn render_sub_page_items<'a, Items>( &self, items: Items, page_index: Option, window: &mut Window, cx: &mut Context, - ) -> impl IntoElement { - let mut page_content = v_flex() + ) -> impl IntoElement + where + Items: Iterator, + { + let page_content = v_flex() .id("settings-ui-page") .size_full() .overflow_y_scroll() .track_scroll(&self.sub_page_scroll_handle); + self.render_sub_page_items_in(page_content, items, page_index, window, cx) + } + fn render_sub_page_items_section<'a, Items>( + &self, + items: Items, + page_index: Option, + window: &mut Window, + cx: &mut Context, + ) -> impl IntoElement + where + Items: Iterator, + { + let page_content = v_flex().id("settings-ui-sub-page-section").size_full(); + self.render_sub_page_items_in(page_content, items, page_index, window, cx) + } + + fn render_sub_page_items_in<'a, Items>( + &self, + mut page_content: Stateful
, + items: Items, + page_index: Option, + window: &mut Window, + cx: &mut Context, + ) -> impl IntoElement + where + Items: Iterator, + { let items: Vec<_> = items.collect(); let items_len = items.len(); let mut section_header = None; @@ -2871,18 +2926,25 @@ impl SettingsWindow { ) .child(self.render_sub_page_breadcrumbs()), ) - .child( - Button::new("open-in-settings-file", "Edit in settings.json") - .tab_index(0_isize) - .style(ButtonStyle::OutlinedGhost) - .tooltip(Tooltip::for_action_title_in( - "Edit in settings.json", - &OpenCurrentFile, - &self.focus_handle, - )) - .on_click(cx.listener(|this, _, window, cx| { - this.open_current_settings_file(window, cx); - })), + .when( + sub_page_stack() + .last() + .is_none_or(|sub_page| sub_page.link.in_json), + |this| { + this.child( + Button::new("open-in-settings-file", "Edit in settings.json") + .tab_index(0_isize) + .style(ButtonStyle::OutlinedGhost) + .tooltip(Tooltip::for_action_title_in( + "Edit in settings.json", + &OpenCurrentFile, + &self.focus_handle, + )) + .on_click(cx.listener(|this, _, window, cx| { + this.open_current_settings_file(window, cx); + })), + ) + }, ) .into_any_element(); diff --git a/crates/ui/src/components.rs b/crates/ui/src/components.rs index b6318f18c973ca5ca7eefa1ba39517ef65cad6df..c9cb943277c6c6a5e6bc1b472040c31d9caac45c 100644 --- a/crates/ui/src/components.rs +++ b/crates/ui/src/components.rs @@ -1,3 +1,4 @@ +mod ai; mod avatar; mod banner; mod button; @@ -16,6 +17,7 @@ mod icon; mod image; mod indent_guides; mod indicator; +mod inline_code; mod keybinding; mod keybinding_hint; mod label; @@ -43,6 +45,7 @@ mod tree_view_item; #[cfg(feature = "stories")] mod stories; +pub use ai::*; pub use avatar::*; pub use banner::*; pub use button::*; @@ -61,6 +64,7 @@ pub use icon::*; pub use image::*; pub use indent_guides::*; pub use indicator::*; +pub use inline_code::*; pub use keybinding::*; pub use keybinding_hint::*; pub use label::*; diff --git a/crates/ui/src/components/ai.rs b/crates/ui/src/components/ai.rs new file mode 100644 index 0000000000000000000000000000000000000000..e36361b7b06559c1442b86acf26b6694bb950d82 --- /dev/null +++ b/crates/ui/src/components/ai.rs @@ -0,0 +1,3 @@ +mod configured_api_card; + +pub use configured_api_card::*; diff --git a/crates/language_models/src/ui/configured_api_card.rs b/crates/ui/src/components/ai/configured_api_card.rs similarity index 84% rename from crates/language_models/src/ui/configured_api_card.rs rename to crates/ui/src/components/ai/configured_api_card.rs index 063ac1717f3aa5de1a448e26c94df7530fec588f..37f9ac7602d676906565a911f1bbca6d2b40f755 100644 --- a/crates/language_models/src/ui/configured_api_card.rs +++ b/crates/ui/src/components/ai/configured_api_card.rs @@ -1,10 +1,11 @@ +use crate::{Tooltip, prelude::*}; use gpui::{ClickEvent, IntoElement, ParentElement, SharedString}; -use ui::{Tooltip, prelude::*}; #[derive(IntoElement)] pub struct ConfiguredApiCard { label: SharedString, button_label: Option, + button_tab_index: Option, tooltip_label: Option, disabled: bool, on_click: Option>, @@ -15,6 +16,7 @@ impl ConfiguredApiCard { Self { label: label.into(), button_label: None, + button_tab_index: None, tooltip_label: None, disabled: false, on_click: None, @@ -43,6 +45,11 @@ impl ConfiguredApiCard { self.disabled = disabled; self } + + pub fn button_tab_index(mut self, tab_index: isize) -> Self { + self.button_tab_index = Some(tab_index); + self + } } impl RenderOnce for ConfiguredApiCard { @@ -51,23 +58,27 @@ impl RenderOnce for ConfiguredApiCard { let button_id = SharedString::new(format!("id-{}", button_label)); h_flex() + .min_w_0() .mt_0p5() .p_1() .justify_between() .rounded_md() + .flex_wrap() .border_1() .border_color(cx.theme().colors().border) .bg(cx.theme().colors().background) .child( h_flex() - .flex_1() .min_w_0() .gap_1() .child(Icon::new(IconName::Check).color(Color::Success)) - .child(Label::new(self.label).truncate()), + .child(Label::new(self.label)), ) .child( Button::new(button_id, button_label) + .when_some(self.button_tab_index, |elem, tab_index| { + elem.tab_index(tab_index) + }) .label_size(LabelSize::Small) .icon(IconName::Undo) .icon_size(IconSize::Small) diff --git a/crates/ui/src/components/ai/copilot_configuration_callout.rs b/crates/ui/src/components/ai/copilot_configuration_callout.rs new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/crates/ui/src/components/button.rs b/crates/ui/src/components/button.rs index 23e7702f6241b6ca0d4074936ee20da26531fbed..d56a9c09d3b57ba607b6837b16af31d240e58663 100644 --- a/crates/ui/src/components/button.rs +++ b/crates/ui/src/components/button.rs @@ -1,12 +1,14 @@ mod button; mod button_icon; mod button_like; +mod button_link; mod icon_button; mod split_button; mod toggle_button; pub use button::*; pub use button_like::*; +pub use button_link::*; pub use icon_button::*; pub use split_button::*; pub use toggle_button::*; diff --git a/crates/ui/src/components/button/button_link.rs b/crates/ui/src/components/button/button_link.rs new file mode 100644 index 0000000000000000000000000000000000000000..caffe2772bce394be6899b1f9b3b686c3927a530 --- /dev/null +++ b/crates/ui/src/components/button/button_link.rs @@ -0,0 +1,102 @@ +use gpui::{IntoElement, Window, prelude::*}; + +use crate::{ButtonLike, prelude::*}; + +/// A button that takes an underline to look like a regular web link. +/// It also contains an arrow icon to communicate the link takes you out of Zed. +/// +/// # Usage Example +/// +/// ``` +/// use ui::ButtonLink; +/// +/// let button_link = ButtonLink::new("Click me", "https://example.com"); +/// ``` +#[derive(IntoElement, RegisterComponent)] +pub struct ButtonLink { + label: SharedString, + label_size: LabelSize, + label_color: Color, + link: String, + no_icon: bool, +} + +impl ButtonLink { + pub fn new(label: impl Into, link: impl Into) -> Self { + Self { + link: link.into(), + label: label.into(), + label_size: LabelSize::Default, + label_color: Color::Default, + no_icon: false, + } + } + + pub fn no_icon(mut self, no_icon: bool) -> Self { + self.no_icon = no_icon; + self + } + + pub fn label_size(mut self, label_size: LabelSize) -> Self { + self.label_size = label_size; + self + } + + pub fn label_color(mut self, label_color: Color) -> Self { + self.label_color = label_color; + self + } +} + +impl RenderOnce for ButtonLink { + fn render(self, _window: &mut Window, _cx: &mut App) -> impl IntoElement { + let id = format!("{}-{}", self.label, self.link); + + ButtonLike::new(id) + .size(ButtonSize::None) + .child( + h_flex() + .gap_0p5() + .child( + Label::new(self.label) + .size(self.label_size) + .color(self.label_color) + .underline(), + ) + .when(!self.no_icon, |this| { + this.child( + Icon::new(IconName::ArrowUpRight) + .size(IconSize::Small) + .color(Color::Muted), + ) + }), + ) + .on_click(move |_, _, cx| cx.open_url(&self.link)) + .into_any_element() + } +} + +impl Component for ButtonLink { + fn scope() -> ComponentScope { + ComponentScope::Navigation + } + + fn description() -> Option<&'static str> { + Some("A button that opens a URL.") + } + + fn preview(_window: &mut Window, _cx: &mut App) -> Option { + Some( + v_flex() + .gap_6() + .child( + example_group(vec![single_example( + "Simple", + ButtonLink::new("zed.dev", "https://zed.dev").into_any_element(), + )]) + .vertical(), + ) + .into_any_element(), + ) + } +} diff --git a/crates/ui/src/components/divider.rs b/crates/ui/src/components/divider.rs index d6101f23203072a27febd0f8b8391af75b41d7f3..cc7ad19875d2817d98076812bb7b9ea101341107 100644 --- a/crates/ui/src/components/divider.rs +++ b/crates/ui/src/components/divider.rs @@ -144,12 +144,18 @@ impl Divider { impl RenderOnce for Divider { fn render(self, _: &mut Window, cx: &mut App) -> impl IntoElement { let base = match self.direction { - DividerDirection::Horizontal => { - div().h_px().w_full().when(self.inset, |this| this.mx_1p5()) - } - DividerDirection::Vertical => { - div().w_px().h_full().when(self.inset, |this| this.my_1p5()) - } + DividerDirection::Horizontal => div() + .min_w_0() + .flex_none() + .h_px() + .w_full() + .when(self.inset, |this| this.mx_1p5()), + DividerDirection::Vertical => div() + .min_w_0() + .flex_none() + .w_px() + .h_full() + .when(self.inset, |this| this.my_1p5()), }; match self.style { diff --git a/crates/ui/src/components/inline_code.rs b/crates/ui/src/components/inline_code.rs new file mode 100644 index 0000000000000000000000000000000000000000..43507127fef478e5a38cfad2d84446673af15f2e --- /dev/null +++ b/crates/ui/src/components/inline_code.rs @@ -0,0 +1,64 @@ +use crate::prelude::*; +use gpui::{AnyElement, IntoElement, ParentElement, Styled}; + +/// InlineCode mimics the way inline code is rendered when wrapped in backticks in Markdown. +/// +/// # Usage Example +/// +/// ``` +/// use ui::InlineCode; +/// +/// let InlineCode = InlineCode::new("
hey
"); +/// ``` +#[derive(IntoElement, RegisterComponent)] +pub struct InlineCode { + label: SharedString, + label_size: LabelSize, +} + +impl InlineCode { + pub fn new(label: impl Into) -> Self { + Self { + label: label.into(), + label_size: LabelSize::Default, + } + } + + /// Sets the size of the label. + pub fn label_size(mut self, size: LabelSize) -> Self { + self.label_size = size; + self + } +} + +impl RenderOnce for InlineCode { + fn render(self, _: &mut Window, cx: &mut App) -> impl IntoElement { + h_flex() + .min_w_0() + .px_0p5() + .overflow_hidden() + .bg(cx.theme().colors().text.opacity(0.05)) + .child(Label::new(self.label).size(self.label_size).buffer_font(cx)) + } +} + +impl Component for InlineCode { + fn scope() -> ComponentScope { + ComponentScope::DataDisplay + } + + fn preview(_window: &mut Window, _cx: &mut App) -> Option { + Some( + v_flex() + .gap_6() + .child( + example_group(vec![single_example( + "Simple", + InlineCode::new("zed.dev").into_any_element(), + )]) + .vertical(), + ) + .into_any_element(), + ) + } +} diff --git a/crates/ui/src/components/label/label_like.rs b/crates/ui/src/components/label/label_like.rs index 1fa6b14c83d8359df234f33ecb9318c88e3a2714..e51d65c3b6c8ecb38ba26a1926c3bfdbb988a1f8 100644 --- a/crates/ui/src/components/label/label_like.rs +++ b/crates/ui/src/components/label/label_like.rs @@ -227,7 +227,7 @@ impl RenderOnce for LabelLike { .get_or_insert_with(Default::default) .underline = Some(UnderlineStyle { thickness: px(1.), - color: None, + color: Some(cx.theme().colors().text_muted.opacity(0.4)), wavy: false, }); this diff --git a/crates/ui/src/components/list/list_bullet_item.rs b/crates/ui/src/components/list/list_bullet_item.rs index 17731488f7139522bf19aeaab18fb395d1eb68b0..934f0853dbe18b8231e15073766b6c84c1896546 100644 --- a/crates/ui/src/components/list/list_bullet_item.rs +++ b/crates/ui/src/components/list/list_bullet_item.rs @@ -1,18 +1,33 @@ -use crate::{ListItem, prelude::*}; -use component::{Component, ComponentScope, example_group_with_title, single_example}; +use crate::{ButtonLink, ListItem, prelude::*}; +use component::{Component, ComponentScope, example_group, single_example}; use gpui::{IntoElement, ParentElement, SharedString}; #[derive(IntoElement, RegisterComponent)] pub struct ListBulletItem { label: SharedString, + label_color: Option, + children: Vec, } impl ListBulletItem { pub fn new(label: impl Into) -> Self { Self { label: label.into(), + label_color: None, + children: Vec::new(), } } + + pub fn label_color(mut self, color: Color) -> Self { + self.label_color = Some(color); + self + } +} + +impl ParentElement for ListBulletItem { + fn extend(&mut self, elements: impl IntoIterator) { + self.children.extend(elements) + } } impl RenderOnce for ListBulletItem { @@ -34,7 +49,18 @@ impl RenderOnce for ListBulletItem { .color(Color::Hidden), ), ) - .child(div().w_full().min_w_0().child(Label::new(self.label))), + .map(|this| { + if !self.children.is_empty() { + this.child(h_flex().gap_0p5().flex_wrap().children(self.children)) + } else { + this.child( + div().w_full().min_w_0().child( + Label::new(self.label) + .color(self.label_color.unwrap_or(Color::Default)), + ), + ) + } + }), ) .into_any_element() } @@ -46,37 +72,43 @@ impl Component for ListBulletItem { } fn description() -> Option<&'static str> { - Some("A list item with a bullet point indicator for unordered lists.") + Some("A list item with a dash indicator for unordered lists.") } fn preview(_window: &mut Window, _cx: &mut App) -> Option { + let basic_examples = vec![ + single_example( + "Simple", + ListBulletItem::new("First bullet item").into_any_element(), + ), + single_example( + "Multiple Lines", + v_flex() + .child(ListBulletItem::new("First item")) + .child(ListBulletItem::new("Second item")) + .child(ListBulletItem::new("Third item")) + .into_any_element(), + ), + single_example( + "Long Text", + ListBulletItem::new( + "A longer bullet item that demonstrates text wrapping behavior", + ) + .into_any_element(), + ), + single_example( + "With Link", + ListBulletItem::new("") + .child(Label::new("Create a Zed account by")) + .child(ButtonLink::new("visiting the website", "https://zed.dev")) + .into_any_element(), + ), + ]; + Some( v_flex() .gap_6() - .child(example_group_with_title( - "Bullet Items", - vec![ - single_example( - "Simple", - ListBulletItem::new("First bullet item").into_any_element(), - ), - single_example( - "Multiple Lines", - v_flex() - .child(ListBulletItem::new("First item")) - .child(ListBulletItem::new("Second item")) - .child(ListBulletItem::new("Third item")) - .into_any_element(), - ), - single_example( - "Long Text", - ListBulletItem::new( - "A longer bullet item that demonstrates text wrapping behavior", - ) - .into_any_element(), - ), - ], - )) + .child(example_group(basic_examples).vertical()) .into_any_element(), ) } diff --git a/crates/workspace/src/notifications.rs b/crates/workspace/src/notifications.rs index cfdc730b4db5be8e2f4a317dcf7e12072af40a88..6d37ea4d2a50637ae7c2e0287ae8f371e3b47aba 100644 --- a/crates/workspace/src/notifications.rs +++ b/crates/workspace/src/notifications.rs @@ -41,7 +41,7 @@ pub enum NotificationId { impl NotificationId { /// Returns a unique [`NotificationId`] for the given type. - pub fn unique() -> Self { + pub const fn unique() -> Self { Self::Unique(TypeId::of::()) } diff --git a/crates/zed_env_vars/src/zed_env_vars.rs b/crates/zed_env_vars/src/zed_env_vars.rs index 53b9c22bb207e81831d1d9ae6087d1a297331d3f..e601cc9536602ac943bd76bf1bfd8b8ac8979dd9 100644 --- a/crates/zed_env_vars/src/zed_env_vars.rs +++ b/crates/zed_env_vars/src/zed_env_vars.rs @@ -5,6 +5,7 @@ use std::sync::LazyLock; /// When true, Zed will use in-memory databases instead of persistent storage. pub static ZED_STATELESS: LazyLock = bool_env_var!("ZED_STATELESS"); +#[derive(Clone)] pub struct EnvVar { pub name: SharedString, /// Value of the environment variable. Also `None` when set to an empty string. @@ -30,7 +31,7 @@ impl EnvVar { #[macro_export] macro_rules! env_var { ($name:expr) => { - LazyLock::new(|| $crate::EnvVar::new(($name).into())) + ::std::sync::LazyLock::new(|| $crate::EnvVar::new(($name).into())) }; } @@ -39,6 +40,6 @@ macro_rules! env_var { #[macro_export] macro_rules! bool_env_var { ($name:expr) => { - LazyLock::new(|| $crate::EnvVar::new(($name).into()).value.is_some()) + ::std::sync::LazyLock::new(|| $crate::EnvVar::new(($name).into()).value.is_some()) }; } From dad6481e0241a252d59f296c57e757bb230280fb Mon Sep 17 00:00:00 2001 From: Cole Miller Date: Sat, 13 Dec 2025 21:51:58 -0500 Subject: [PATCH 248/621] Disambiguate branch name in title bar (#44793) Add the repository name when: - there's more than one repository, and - the name of the active repository doesn't match the name of the project (to avoid stuttering with the adjacent project switcher button) Release Notes: - The branch name in the title bar now includes the name of the current repository when needed to disambiguate. --- crates/title_bar/src/title_bar.rs | 60 ++++++++++++++++++++----------- 1 file changed, 39 insertions(+), 21 deletions(-) diff --git a/crates/title_bar/src/title_bar.rs b/crates/title_bar/src/title_bar.rs index 680c455e73ab135f418f199f06415fff79100ea5..bd606e4a021eaad30b95322d785e23d694734c06 100644 --- a/crates/title_bar/src/title_bar.rs +++ b/crates/title_bar/src/title_bar.rs @@ -167,7 +167,7 @@ impl Render for TitleBar { .child(self.render_project_name(cx)) }) .when(title_bar_settings.show_branch_name, |title_bar| { - title_bar.children(self.render_project_branch(cx)) + title_bar.children(self.render_project_repo(cx)) }) }) }) @@ -319,6 +319,27 @@ impl TitleBar { } } + fn project_name(&self, cx: &Context) -> Option { + self.project + .read(cx) + .visible_worktrees(cx) + .map(|worktree| { + let worktree = worktree.read(cx); + let settings_location = SettingsLocation { + worktree_id: worktree.id(), + path: RelPath::empty(), + }; + + let settings = WorktreeSettings::get(Some(settings_location), cx); + let name = match &settings.project_name { + Some(name) => name.as_str(), + None => worktree.root_name_str(), + }; + SharedString::new(name) + }) + .next() + } + fn render_remote_project_connection(&self, cx: &mut Context) -> Option { let options = self.project.read(cx).remote_connection_options(cx)?; let host: SharedString = options.display_name().into(); @@ -451,27 +472,10 @@ impl TitleBar { } pub fn render_project_name(&self, cx: &mut Context) -> impl IntoElement { - let name = self - .project - .read(cx) - .visible_worktrees(cx) - .map(|worktree| { - let worktree = worktree.read(cx); - let settings_location = SettingsLocation { - worktree_id: worktree.id(), - path: RelPath::empty(), - }; - - let settings = WorktreeSettings::get(Some(settings_location), cx); - match &settings.project_name { - Some(name) => name.as_str(), - None => worktree.root_name_str(), - } - }) - .next(); + let name = self.project_name(cx); let is_project_selected = name.is_some(); let name = if let Some(name) = name { - util::truncate_and_trailoff(name, MAX_PROJECT_NAME_LENGTH) + util::truncate_and_trailoff(&name, MAX_PROJECT_NAME_LENGTH) } else { "Open recent project".to_string() }; @@ -500,9 +504,10 @@ impl TitleBar { })) } - pub fn render_project_branch(&self, cx: &mut Context) -> Option { + pub fn render_project_repo(&self, cx: &mut Context) -> Option { let settings = TitleBarSettings::get_global(cx); let repository = self.project.read(cx).active_repository(cx)?; + let repository_count = self.project.read(cx).repositories(cx).len(); let workspace = self.workspace.upgrade()?; let repo = repository.read(cx); let branch_name = repo @@ -519,6 +524,19 @@ impl TitleBar { .collect::() }) })?; + let project_name = self.project_name(cx); + let repo_name = repo + .work_directory_abs_path + .file_name() + .and_then(|name| name.to_str()) + .map(SharedString::new); + let show_repo_name = + repository_count > 1 && repo.branch.is_some() && repo_name != project_name; + let branch_name = if let Some(repo_name) = repo_name.filter(|_| show_repo_name) { + format!("{repo_name}/{branch_name}") + } else { + branch_name + }; Some( Button::new("project_branch_trigger", branch_name) From 488fa0254772b72709875e37802cef0955f67e26 Mon Sep 17 00:00:00 2001 From: Michael Benfield Date: Sat, 13 Dec 2025 19:22:20 -0800 Subject: [PATCH 249/621] Streaming tool use for inline assistant (#44751) Depends on: https://github.com/zed-industries/zed/pull/44753 Release Notes: - N/A --------- Co-authored-by: Mikayla Maki --- assets/prompts/content_prompt_v2.hbs | 3 +- assets/settings/default.json | 2 + crates/agent_settings/src/agent_settings.rs | 4 + crates/agent_ui/src/agent_ui.rs | 1 + crates/agent_ui/src/buffer_codegen.rs | 304 +++++++++++++----- crates/agent_ui/src/inline_assistant.rs | 52 --- crates/anthropic/src/anthropic.rs | 14 + crates/feature_flags/src/flags.rs | 6 +- crates/language_model/src/language_model.rs | 20 ++ .../language_models/src/provider/anthropic.rs | 4 + crates/language_models/src/provider/cloud.rs | 4 + crates/prompt_store/src/prompts.rs | 2 +- crates/settings/src/settings_content/agent.rs | 11 +- 13 files changed, 282 insertions(+), 145 deletions(-) diff --git a/assets/prompts/content_prompt_v2.hbs b/assets/prompts/content_prompt_v2.hbs index e1b6ddc6f023e9e97c9bb851473ac02e989c8feb..87376f49f12f0e27cc61e9f9747d9de6bfde43cb 100644 --- a/assets/prompts/content_prompt_v2.hbs +++ b/assets/prompts/content_prompt_v2.hbs @@ -39,6 +39,5 @@ Only make changes that are necessary to fulfill the prompt, leave everything els Start at the indentation level in the original file in the rewritten {{content_type}}. -You must use one of the provided tools to make the rewrite or to provide an explanation as to why the user's request cannot be fulfilled. It is an error if -you simply send back unstructured text. If you need to make a statement or ask a question you must use one of the tools to do so. +IMPORTANT: You MUST use one of the provided tools to make the rewrite or to provide an explanation as to why the user's request cannot be fulfilled. You MUST NOT send back unstructured text. If you need to make a statement or ask a question you MUST use one of the tools to do so. It is an error if you try to make a change that cannot be made simply by editing the rewrite_section. diff --git a/assets/settings/default.json b/assets/settings/default.json index 58564138227f361e5432d377358b18734f250d72..a5180c9e2eaca9be49fa832e32e001d15d65df8f 100644 --- a/assets/settings/default.json +++ b/assets/settings/default.json @@ -896,6 +896,8 @@ "default_width": 380, }, "agent": { + // Whether the inline assistant should use streaming tools, when available + "inline_assistant_use_streaming_tools": true, // Whether the agent is enabled. "enabled": true, // What completion mode to start new threads in, if available. Can be 'normal' or 'burn'. diff --git a/crates/agent_settings/src/agent_settings.rs b/crates/agent_settings/src/agent_settings.rs index 084ac7c3e7a1be4920126f857145e64b65a255dd..5dab085a255fe399d5f529791614d51f8b4cc78b 100644 --- a/crates/agent_settings/src/agent_settings.rs +++ b/crates/agent_settings/src/agent_settings.rs @@ -28,6 +28,7 @@ pub struct AgentSettings { pub default_height: Pixels, pub default_model: Option, pub inline_assistant_model: Option, + pub inline_assistant_use_streaming_tools: bool, pub commit_message_model: Option, pub thread_summary_model: Option, pub inline_alternatives: Vec, @@ -155,6 +156,9 @@ impl Settings for AgentSettings { default_height: px(agent.default_height.unwrap()), default_model: Some(agent.default_model.unwrap()), inline_assistant_model: agent.inline_assistant_model, + inline_assistant_use_streaming_tools: agent + .inline_assistant_use_streaming_tools + .unwrap_or(true), commit_message_model: agent.commit_message_model, thread_summary_model: agent.thread_summary_model, inline_alternatives: agent.inline_alternatives.unwrap_or_default(), diff --git a/crates/agent_ui/src/agent_ui.rs b/crates/agent_ui/src/agent_ui.rs index b6f7517ed934cf6cac8eefc262233b845169de9f..eb7785fad59894012251c84319af7fca306f2882 100644 --- a/crates/agent_ui/src/agent_ui.rs +++ b/crates/agent_ui/src/agent_ui.rs @@ -445,6 +445,7 @@ mod tests { default_height: px(600.), default_model: None, inline_assistant_model: None, + inline_assistant_use_streaming_tools: false, commit_message_model: None, thread_summary_model: None, inline_alternatives: vec![], diff --git a/crates/agent_ui/src/buffer_codegen.rs b/crates/agent_ui/src/buffer_codegen.rs index 1cd7bec7b5b2c24cfbcf01a20091e8a07608e73a..e2c67a04167d7080a6f94b9ee2a8fae516d487d7 100644 --- a/crates/agent_ui/src/buffer_codegen.rs +++ b/crates/agent_ui/src/buffer_codegen.rs @@ -1,23 +1,26 @@ use crate::{context::LoadedContext, inline_prompt_editor::CodegenStatus}; use agent_settings::AgentSettings; use anyhow::{Context as _, Result}; + use client::telemetry::Telemetry; use cloud_llm_client::CompletionIntent; use collections::HashSet; use editor::{Anchor, AnchorRangeExt, MultiBuffer, MultiBufferSnapshot, ToOffset as _, ToPoint}; -use feature_flags::{FeatureFlagAppExt as _, InlineAssistantV2FeatureFlag}; +use feature_flags::{FeatureFlagAppExt as _, InlineAssistantUseToolFeatureFlag}; use futures::{ SinkExt, Stream, StreamExt, TryStreamExt as _, channel::mpsc, future::{LocalBoxFuture, Shared}, join, + stream::BoxStream, }; use gpui::{App, AppContext as _, AsyncApp, Context, Entity, EventEmitter, Subscription, Task}; use language::{Buffer, IndentKind, Point, TransactionId, line_diff}; use language_model::{ - LanguageModel, LanguageModelCompletionError, LanguageModelRegistry, LanguageModelRequest, - LanguageModelRequestMessage, LanguageModelRequestTool, LanguageModelTextStream, Role, - report_assistant_event, + LanguageModel, LanguageModelCompletionError, LanguageModelCompletionEvent, + LanguageModelRegistry, LanguageModelRequest, LanguageModelRequestMessage, + LanguageModelRequestTool, LanguageModelTextStream, LanguageModelToolChoice, + LanguageModelToolUse, Role, TokenUsage, report_assistant_event, }; use multi_buffer::MultiBufferRow; use parking_lot::Mutex; @@ -25,6 +28,7 @@ use prompt_store::PromptBuilder; use rope::Rope; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; +use settings::Settings as _; use smol::future::FutureExt; use std::{ cmp, @@ -46,6 +50,7 @@ pub struct FailureMessageInput { /// A brief message to the user explaining why you're unable to fulfill the request or to ask a question about the request. /// /// The message may use markdown formatting if you wish. + #[serde(default)] pub message: String, } @@ -56,9 +61,11 @@ pub struct RewriteSectionInput { /// /// The description may use markdown formatting if you wish. /// This is optional - if the edit is simple or obvious, you should leave it empty. + #[serde(default)] pub description: String, /// The text to replace the section with. + #[serde(default)] pub replacement_text: String, } @@ -379,6 +386,12 @@ impl CodegenAlternative { &self.last_equal_ranges } + fn use_streaming_tools(model: &dyn LanguageModel, cx: &App) -> bool { + model.supports_streaming_tools() + && cx.has_flag::() + && AgentSettings::get_global(cx).inline_assistant_use_streaming_tools + } + pub fn start( &mut self, user_prompt: String, @@ -398,11 +411,17 @@ impl CodegenAlternative { let telemetry_id = model.telemetry_id(); let provider_id = model.provider_id(); - if cx.has_flag::() { + if Self::use_streaming_tools(model.as_ref(), cx) { let request = self.build_request(&model, user_prompt, context_task, cx)?; - let tool_use = - cx.spawn(async move |_, cx| model.stream_completion_tool(request.await, cx).await); - self.handle_tool_use(telemetry_id, provider_id.to_string(), api_key, tool_use, cx); + let completion_events = + cx.spawn(async move |_, cx| model.stream_completion(request.await, cx).await); + self.generation = self.handle_completion( + telemetry_id, + provider_id.to_string(), + api_key, + completion_events, + cx, + ); } else { let stream: LocalBoxFuture> = if user_prompt.trim().to_lowercase() == "delete" { @@ -414,13 +433,14 @@ impl CodegenAlternative { }) .boxed_local() }; - self.handle_stream(telemetry_id, provider_id.to_string(), api_key, stream, cx); + self.generation = + self.handle_stream(telemetry_id, provider_id.to_string(), api_key, stream, cx); } Ok(()) } - fn build_request_v2( + fn build_request_tools( &self, model: &Arc, user_prompt: String, @@ -456,7 +476,7 @@ impl CodegenAlternative { let system_prompt = self .builder - .generate_inline_transformation_prompt_v2( + .generate_inline_transformation_prompt_tools( language_name, buffer, range.start.0..range.end.0, @@ -466,6 +486,9 @@ impl CodegenAlternative { let temperature = AgentSettings::temperature_for_model(model, cx); let tool_input_format = model.tool_input_format(); + let tool_choice = model + .supports_tool_choice(LanguageModelToolChoice::Any) + .then_some(LanguageModelToolChoice::Any); Ok(cx.spawn(async move |_cx| { let mut messages = vec![LanguageModelRequestMessage { @@ -508,7 +531,7 @@ impl CodegenAlternative { intent: Some(CompletionIntent::InlineAssist), mode: None, tools, - tool_choice: None, + tool_choice, stop: Vec::new(), temperature, messages, @@ -524,8 +547,8 @@ impl CodegenAlternative { context_task: Shared>>, cx: &mut App, ) -> Result> { - if cx.has_flag::() { - return self.build_request_v2(model, user_prompt, context_task, cx); + if Self::use_streaming_tools(model.as_ref(), cx) { + return self.build_request_tools(model, user_prompt, context_task, cx); } let buffer = self.buffer.read(cx).snapshot(cx); @@ -603,7 +626,7 @@ impl CodegenAlternative { model_api_key: Option, stream: impl 'static + Future>, cx: &mut Context, - ) { + ) -> Task<()> { let start_time = Instant::now(); // Make a new snapshot and re-resolve anchor in case the document was modified. @@ -659,7 +682,8 @@ impl CodegenAlternative { let completion = Arc::new(Mutex::new(String::new())); let completion_clone = completion.clone(); - self.generation = cx.spawn(async move |codegen, cx| { + cx.notify(); + cx.spawn(async move |codegen, cx| { let stream = stream.await; let token_usage = stream @@ -685,6 +709,7 @@ impl CodegenAlternative { stream?.stream.map_err(|error| error.into()), ); futures::pin_mut!(chunks); + let mut diff = StreamingDiff::new(selected_text.to_string()); let mut line_diff = LineDiff::default(); @@ -876,8 +901,7 @@ impl CodegenAlternative { cx.notify(); }) .ok(); - }); - cx.notify(); + }) } pub fn current_completion(&self) -> Option { @@ -1060,21 +1084,29 @@ impl CodegenAlternative { }) } - fn handle_tool_use( + fn handle_completion( &mut self, - _telemetry_id: String, - _provider_id: String, - _api_key: Option, - tool_use: impl 'static - + Future< - Output = Result, + telemetry_id: String, + provider_id: String, + api_key: Option, + completion_stream: Task< + Result< + BoxStream< + 'static, + Result, + >, + LanguageModelCompletionError, + >, >, cx: &mut Context, - ) { + ) -> Task<()> { self.diff = Diff::default(); self.status = CodegenStatus::Pending; - self.generation = cx.spawn(async move |codegen, cx| { + cx.notify(); + // Leaving this in generation so that STOP equivalent events are respected even + // while we're still pre-processing the completion event + cx.spawn(async move |codegen, cx| { let finish_with_status = |status: CodegenStatus, cx: &mut AsyncApp| { let _ = codegen.update(cx, |this, cx| { this.status = status; @@ -1083,76 +1115,176 @@ impl CodegenAlternative { }); }; - let tool_use = tool_use.await; - - match tool_use { - Ok(tool_use) if tool_use.name.as_ref() == "rewrite_section" => { - // Parse the input JSON into RewriteSectionInput - match serde_json::from_value::(tool_use.input) { - Ok(input) => { - // Store the description if non-empty - let description = if !input.description.trim().is_empty() { - Some(input.description.clone()) - } else { - None + let mut completion_events = match completion_stream.await { + Ok(events) => events, + Err(err) => { + finish_with_status(CodegenStatus::Error(err.into()), cx); + return; + } + }; + + let chars_read_so_far = Arc::new(Mutex::new(0usize)); + let tool_to_text_and_message = + move |tool_use: LanguageModelToolUse| -> (Option, Option) { + let mut chars_read_so_far = chars_read_so_far.lock(); + match tool_use.name.as_ref() { + "rewrite_section" => { + let Ok(mut input) = + serde_json::from_value::(tool_use.input) + else { + return (None, None); }; + let value = input.replacement_text[*chars_read_so_far..].to_string(); + *chars_read_so_far = input.replacement_text.len(); + (Some(value), Some(std::mem::take(&mut input.description))) + } + "failure_message" => { + let Ok(mut input) = + serde_json::from_value::(tool_use.input) + else { + return (None, None); + }; + (None, Some(std::mem::take(&mut input.message))) + } + _ => (None, None), + } + }; - // Apply the replacement text to the buffer and compute diff - let batch_diff_task = codegen - .update(cx, |this, cx| { - this.model_explanation = description.map(Into::into); - let range = this.range.clone(); - this.apply_edits( - std::iter::once((range, input.replacement_text)), - cx, - ); - this.reapply_batch_diff(cx) - }) - .ok(); - - // Wait for the diff computation to complete - if let Some(diff_task) = batch_diff_task { - diff_task.await; - } + let mut message_id = None; + let mut first_text = None; + let last_token_usage = Arc::new(Mutex::new(TokenUsage::default())); + let total_text = Arc::new(Mutex::new(String::new())); - finish_with_status(CodegenStatus::Done, cx); - return; + loop { + if let Some(first_event) = completion_events.next().await { + match first_event { + Ok(LanguageModelCompletionEvent::StartMessage { message_id: id }) => { + message_id = Some(id); } - Err(e) => { - finish_with_status(CodegenStatus::Error(e.into()), cx); - return; + Ok(LanguageModelCompletionEvent::ToolUse(tool_use)) + if matches!( + tool_use.name.as_ref(), + "rewrite_section" | "failure_message" + ) => + { + let is_complete = tool_use.is_input_complete; + let (text, message) = tool_to_text_and_message(tool_use); + // Only update the model explanation if the tool use is complete. + // Otherwise the UI element bounces around as it's updated. + if is_complete { + let _ = codegen.update(cx, |this, _cx| { + this.model_explanation = message.map(Into::into); + }); + } + first_text = text; + if first_text.is_some() { + break; + } } - } - } - Ok(tool_use) if tool_use.name.as_ref() == "failure_message" => { - // Handle failure message tool use - match serde_json::from_value::(tool_use.input) { - Ok(input) => { - let _ = codegen.update(cx, |this, _cx| { - // Store the failure message as the tool description - this.model_explanation = Some(input.message.into()); - }); - finish_with_status(CodegenStatus::Done, cx); - return; + Ok(LanguageModelCompletionEvent::UsageUpdate(token_usage)) => { + *last_token_usage.lock() = token_usage; + } + Ok(LanguageModelCompletionEvent::Text(text)) => { + let mut lock = total_text.lock(); + lock.push_str(&text); + } + Ok(e) => { + log::warn!("Unexpected event: {:?}", e); + break; } Err(e) => { finish_with_status(CodegenStatus::Error(e.into()), cx); - return; + break; } } } - Ok(_tool_use) => { - // Unexpected tool. - finish_with_status(CodegenStatus::Done, cx); - return; - } - Err(e) => { - finish_with_status(CodegenStatus::Error(e.into()), cx); - return; - } } - }); - cx.notify(); + + let Some(first_text) = first_text else { + finish_with_status(CodegenStatus::Done, cx); + return; + }; + + let (message_tx, mut message_rx) = futures::channel::mpsc::unbounded(); + + cx.spawn({ + let codegen = codegen.clone(); + async move |cx| { + while let Some(message) = message_rx.next().await { + let _ = codegen.update(cx, |this, _cx| { + this.model_explanation = message; + }); + } + } + }) + .detach(); + + let move_last_token_usage = last_token_usage.clone(); + + let text_stream = Box::pin(futures::stream::once(async { Ok(first_text) }).chain( + completion_events.filter_map(move |e| { + let tool_to_text_and_message = tool_to_text_and_message.clone(); + let last_token_usage = move_last_token_usage.clone(); + let total_text = total_text.clone(); + let mut message_tx = message_tx.clone(); + async move { + match e { + Ok(LanguageModelCompletionEvent::ToolUse(tool_use)) + if matches!( + tool_use.name.as_ref(), + "rewrite_section" | "failure_message" + ) => + { + let is_complete = tool_use.is_input_complete; + let (text, message) = tool_to_text_and_message(tool_use); + if is_complete { + // Again only send the message when complete to not get a bouncing UI element. + let _ = message_tx.send(message.map(Into::into)).await; + } + text.map(Ok) + } + Ok(LanguageModelCompletionEvent::UsageUpdate(token_usage)) => { + *last_token_usage.lock() = token_usage; + None + } + Ok(LanguageModelCompletionEvent::Text(text)) => { + let mut lock = total_text.lock(); + lock.push_str(&text); + None + } + Ok(LanguageModelCompletionEvent::Stop(_reason)) => None, + e => { + log::error!("UNEXPECTED EVENT {:?}", e); + None + } + } + } + }), + )); + + let language_model_text_stream = LanguageModelTextStream { + message_id: message_id, + stream: text_stream, + last_token_usage, + }; + + let Some(task) = codegen + .update(cx, move |codegen, cx| { + codegen.handle_stream( + telemetry_id, + provider_id, + api_key, + async { Ok(language_model_text_stream) }, + cx, + ) + }) + .ok() + else { + return; + }; + + task.await; + }) } } @@ -1679,7 +1811,7 @@ mod tests { ) -> mpsc::UnboundedSender { let (chunks_tx, chunks_rx) = mpsc::unbounded(); codegen.update(cx, |codegen, cx| { - codegen.handle_stream( + codegen.generation = codegen.handle_stream( String::new(), String::new(), None, diff --git a/crates/agent_ui/src/inline_assistant.rs b/crates/agent_ui/src/inline_assistant.rs index 48da85d38554da8227d76d3cbe290e29ef4fc531..ad0f58c162ca720e619e83ca9a3eb65a4be9fe2b 100644 --- a/crates/agent_ui/src/inline_assistant.rs +++ b/crates/agent_ui/src/inline_assistant.rs @@ -1455,60 +1455,8 @@ impl InlineAssistant { let old_snapshot = codegen.snapshot(cx); let old_buffer = codegen.old_buffer(cx); let deleted_row_ranges = codegen.diff(cx).deleted_row_ranges.clone(); - // let model_explanation = codegen.model_explanation(cx); editor.update(cx, |editor, cx| { - // Update tool description block - // if let Some(description) = model_explanation { - // if let Some(block_id) = decorations.model_explanation { - // editor.remove_blocks(HashSet::from_iter([block_id]), None, cx); - // let new_block_id = editor.insert_blocks( - // [BlockProperties { - // style: BlockStyle::Flex, - // placement: BlockPlacement::Below(assist.range.end), - // height: Some(1), - // render: Arc::new({ - // let description = description.clone(); - // move |cx| { - // div() - // .w_full() - // .py_1() - // .px_2() - // .bg(cx.theme().colors().editor_background) - // .border_y_1() - // .border_color(cx.theme().status().info_border) - // .child( - // Label::new(description.clone()) - // .color(Color::Muted) - // .size(LabelSize::Small), - // ) - // .into_any_element() - // } - // }), - // priority: 0, - // }], - // None, - // cx, - // ); - // decorations.model_explanation = new_block_id.into_iter().next(); - // } - // } else if let Some(block_id) = decorations.model_explanation { - // // Hide the block if there's no description - // editor.remove_blocks(HashSet::from_iter([block_id]), None, cx); - // let new_block_id = editor.insert_blocks( - // [BlockProperties { - // style: BlockStyle::Flex, - // placement: BlockPlacement::Below(assist.range.end), - // height: Some(0), - // render: Arc::new(|_cx| div().into_any_element()), - // priority: 0, - // }], - // None, - // cx, - // ); - // decorations.model_explanation = new_block_id.into_iter().next(); - // } - let old_blocks = mem::take(&mut decorations.removed_line_block_ids); editor.remove_blocks(old_blocks, None, cx); diff --git a/crates/anthropic/src/anthropic.rs b/crates/anthropic/src/anthropic.rs index 09b293b122624274b7484026f35d1bcc8e265ece..e976b7f5dc36905d2a32b4cdc04869f3267705fe 100644 --- a/crates/anthropic/src/anthropic.rs +++ b/crates/anthropic/src/anthropic.rs @@ -429,10 +429,24 @@ impl Model { let mut headers = vec![]; match self { + Self::ClaudeOpus4 + | Self::ClaudeOpus4_1 + | Self::ClaudeOpus4_5 + | Self::ClaudeSonnet4 + | Self::ClaudeSonnet4_5 + | Self::ClaudeOpus4Thinking + | Self::ClaudeOpus4_1Thinking + | Self::ClaudeOpus4_5Thinking + | Self::ClaudeSonnet4Thinking + | Self::ClaudeSonnet4_5Thinking => { + // Fine-grained tool streaming for newer models + headers.push("fine-grained-tool-streaming-2025-05-14".to_string()); + } Self::Claude3_7Sonnet | Self::Claude3_7SonnetThinking => { // Try beta token-efficient tool use (supported in Claude 3.7 Sonnet only) // https://docs.anthropic.com/en/docs/build-with-claude/tool-use/token-efficient-tool-use headers.push("token-efficient-tools-2025-02-19".to_string()); + headers.push("fine-grained-tool-streaming-2025-05-14".to_string()); } Self::Custom { extra_beta_headers, .. diff --git a/crates/feature_flags/src/flags.rs b/crates/feature_flags/src/flags.rs index 61d9a34e38de546c79a2dbb5f889e2fddad38480..566d5604149567702e8739d2f3ac9fdc6f5f0de8 100644 --- a/crates/feature_flags/src/flags.rs +++ b/crates/feature_flags/src/flags.rs @@ -12,10 +12,10 @@ impl FeatureFlag for PanicFeatureFlag { const NAME: &'static str = "panic"; } -pub struct InlineAssistantV2FeatureFlag; +pub struct InlineAssistantUseToolFeatureFlag; -impl FeatureFlag for InlineAssistantV2FeatureFlag { - const NAME: &'static str = "inline-assistant-v2"; +impl FeatureFlag for InlineAssistantUseToolFeatureFlag { + const NAME: &'static str = "inline-assistant-use-tool"; fn enabled_for_staff() -> bool { false diff --git a/crates/language_model/src/language_model.rs b/crates/language_model/src/language_model.rs index e158bb256be42291549c2379ae7ec19402166543..09d44b5b408324936af00a2a5e4f1deb4f351434 100644 --- a/crates/language_model/src/language_model.rs +++ b/crates/language_model/src/language_model.rs @@ -612,6 +612,11 @@ pub trait LanguageModel: Send + Sync { false } + /// Returns whether this model or provider supports streaming tool calls; + fn supports_streaming_tools(&self) -> bool { + false + } + fn tool_input_format(&self) -> LanguageModelToolSchemaFormat { LanguageModelToolSchemaFormat::JsonSchema } @@ -766,6 +771,21 @@ pub trait LanguageModelExt: LanguageModel { } impl LanguageModelExt for dyn LanguageModel {} +impl std::fmt::Debug for dyn LanguageModel { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("") + .field("id", &self.id()) + .field("name", &self.name()) + .field("provider_id", &self.provider_id()) + .field("provider_name", &self.provider_name()) + .field("upstream_provider_name", &self.upstream_provider_name()) + .field("upstream_provider_id", &self.upstream_provider_id()) + .field("upstream_provider_id", &self.upstream_provider_id()) + .field("supports_streaming_tools", &self.supports_streaming_tools()) + .finish() + } +} + /// An error that occurred when trying to authenticate the language model provider. #[derive(Debug, Error)] pub enum AuthenticateError { diff --git a/crates/language_models/src/provider/anthropic.rs b/crates/language_models/src/provider/anthropic.rs index f9e1e60cf648d3a67cec425ebd1f09ad7b564665..25ba7615dc23e2561648e173588be6d93c28e295 100644 --- a/crates/language_models/src/provider/anthropic.rs +++ b/crates/language_models/src/provider/anthropic.rs @@ -350,6 +350,10 @@ impl LanguageModel for AnthropicModel { true } + fn supports_streaming_tools(&self) -> bool { + true + } + fn supports_tool_choice(&self, choice: LanguageModelToolChoice) -> bool { match choice { LanguageModelToolChoice::Auto diff --git a/crates/language_models/src/provider/cloud.rs b/crates/language_models/src/provider/cloud.rs index a19a427dbacb32883b1877888ec04899a2b8d427..508a77d38abcf2143170382e945ab6ce31f3a623 100644 --- a/crates/language_models/src/provider/cloud.rs +++ b/crates/language_models/src/provider/cloud.rs @@ -602,6 +602,10 @@ impl LanguageModel for CloudLanguageModel { self.model.supports_images } + fn supports_streaming_tools(&self) -> bool { + self.model.supports_streaming_tools + } + fn supports_tool_choice(&self, choice: LanguageModelToolChoice) -> bool { match choice { LanguageModelToolChoice::Auto diff --git a/crates/prompt_store/src/prompts.rs b/crates/prompt_store/src/prompts.rs index d6a172218a8eb3d4538363e6202a7e721d2b7bc1..847e45742db17fe194d002c26a67380390b68f06 100644 --- a/crates/prompt_store/src/prompts.rs +++ b/crates/prompt_store/src/prompts.rs @@ -286,7 +286,7 @@ impl PromptBuilder { Ok(()) } - pub fn generate_inline_transformation_prompt_v2( + pub fn generate_inline_transformation_prompt_tools( &self, language_name: Option<&LanguageName>, buffer: BufferSnapshot, diff --git a/crates/settings/src/settings_content/agent.rs b/crates/settings/src/settings_content/agent.rs index 2ea9f0cd5788f3312061ec8ffef2a728403463ac..fccc3e09fceb8e05ad3494101a4d23d95257358e 100644 --- a/crates/settings/src/settings_content/agent.rs +++ b/crates/settings/src/settings_content/agent.rs @@ -36,7 +36,13 @@ pub struct AgentSettingsContent { pub default_model: Option, /// Model to use for the inline assistant. Defaults to default_model when not specified. pub inline_assistant_model: Option, - /// Model to use for generating git commit messages. Defaults to default_model when not specified. + /// Model to use for the inline assistant when streaming tools are enabled. + /// + /// Default: true + pub inline_assistant_use_streaming_tools: Option, + /// Model to use for generating git commit messages. + /// + /// Default: true pub commit_message_model: Option, /// Model to use for generating thread summaries. Defaults to default_model when not specified. pub thread_summary_model: Option, @@ -129,6 +135,9 @@ impl AgentSettingsContent { model, }); } + pub fn set_inline_assistant_use_streaming_tools(&mut self, use_tools: bool) { + self.inline_assistant_use_streaming_tools = Some(use_tools); + } pub fn set_commit_message_model(&mut self, provider: String, model: String) { self.commit_message_model = Some(LanguageModelSelection { From f2cc24c5faa8b104334ba7a42d0db92175b0b51e Mon Sep 17 00:00:00 2001 From: Will Garrison Date: Sun, 14 Dec 2025 07:20:33 +0000 Subject: [PATCH 250/621] docs: Add clarifying note about Vim subword motion (#44535) Clarify the docs regarding how operators are affected when subword motion in Vim is activated. Ref: https://github.com/zed-industries/zed/issues/23344#issuecomment-3186025873. Release Notes: - N/A --------- Co-authored-by: Kunall Banerjee --- docs/src/vim.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/src/vim.md b/docs/src/vim.md index 9ba1b059223f147d73398a1ec91e6d818ff92c8a..09baa9b54f7e1aeb5f16777f4292131315d18928 100644 --- a/docs/src/vim.md +++ b/docs/src/vim.md @@ -471,7 +471,7 @@ But you cannot use the same shortcuts to move between all the editor docks (the } ``` -Subword motion, which allows you to navigate and select individual words in camelCase or snake_case, is not enabled by default. To enable it, add these bindings to your keymap. +Subword motion, which allows you to navigate and select individual words in `camelCase` or `snake_case`, is not enabled by default. To enable it, add these bindings to your keymap. ```json [settings] { @@ -485,6 +485,9 @@ Subword motion, which allows you to navigate and select individual words in came } ``` +> Note: Operations like `dw` remain unaffected. If you would like operations to +> also use subword motion, remove `vim_mode != operator` from the `context`. + Vim mode comes with shortcuts to surround the selection in normal mode (`ys`), but it doesn't have a shortcut to add surrounds in visual mode. By default, `shift-s` substitutes the selection (erases the text and enters insert mode). To use `shift-s` to add surrounds in visual mode, you can add the following object to your keymap. ```json [settings] From 6cc947f654f27c80bd1f8b2f68a94abd2892fec7 Mon Sep 17 00:00:00 2001 From: John Tur Date: Sun, 14 Dec 2025 02:45:54 -0500 Subject: [PATCH 251/621] Update `cc` and `cmake` crates (#44797) This fixes the build when Visual Studio 2026 is installed. Release Notes: - N/A --- Cargo.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cc7f8b0a85fd21dd7cae57e1ffc5348d70defbed..834a072a92ff7334338b018eaecbdf7d71c48cdc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2770,9 +2770,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.41" +version = "1.2.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac9fe6cdbb24b6ade63616c0a0688e45bb56732262c158df3c0c4bea4ca47cb7" +checksum = "90583009037521a116abf44494efecd645ba48b6622457080f080b85544e2215" dependencies = [ "find-msvc-tools", "jobserver", @@ -3113,9 +3113,9 @@ dependencies = [ [[package]] name = "cmake" -version = "0.1.54" +version = "0.1.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7caa3f9de89ddbe2c607f4101924c5abec803763ae9534e4f4d7d8f84aa81f0" +checksum = "b042e5d8a74ae91bb0961acd039822472ec99f8ab0948cbf6d1369588f8be586" dependencies = [ "cc", ] @@ -6091,9 +6091,9 @@ dependencies = [ [[package]] name = "find-msvc-tools" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52051878f80a721bb68ebfbc930e07b65ba72f2da88968ea5c06fd6ca3d3a127" +checksum = "3a3076410a55c90011c298b04d0cfa770b00fa04e1e3c97d3f6c9de105a03844" [[package]] name = "fixedbitset" From 00169e0ae21dbc4f6626f3aa03fdf5991a1ac4dc Mon Sep 17 00:00:00 2001 From: Anthony Eid <56899983+Anthony-Eid@users.noreply.github.com> Date: Sun, 14 Dec 2025 07:55:19 -0500 Subject: [PATCH 252/621] git: Fix create remote branch (#44805) Fix a bug where the branch picker would be dismissed before completing the add remote flow, thus making Zed unable to add remote repositories through the branch picker. This bug was caused by the picker always being dismissed on the confirm action, so the fix was stopping the branch modal from being dismissed too early. I also cleaned up the UI a bit and code. 1. Removed the loading field from the Branch delegate because it was never used and the activity indicator will show remote add command if it takes a while. 2. I replaced some async task spawning with the use of `cx.defer`. 3. Added a `add remote name` fake entry when the picker is in the name remote state. I did this so the UI would be consistent with the other states. 4. Added two regression tests. 4.1 One to prevent this bug from occurring again: https://github.com/zed-industries/zed/pull/44742 4.2 Another to prevent the early dismissal bug from occurring 5. Made `init_branch_list_test` param order consistent with Zed's code base ###### Updated UI image Release Notes: - N/A --- Cargo.lock | 1 + crates/git_ui/Cargo.toml | 1 + crates/git_ui/src/branch_picker.rs | 379 +++++++++++++++++------------ 3 files changed, 232 insertions(+), 149 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 834a072a92ff7334338b018eaecbdf7d71c48cdc..e465ff483bcb6cc9528403bbb8f3bd883a6af871 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7045,6 +7045,7 @@ dependencies = [ "picker", "pretty_assertions", "project", + "rand 0.9.2", "recent_projects", "remote", "schemars", diff --git a/crates/git_ui/Cargo.toml b/crates/git_ui/Cargo.toml index beaf192b0ef538fb524ff4986710255040b89f27..6747daa09d2801ad8c05c17fb04cb3ab235cdbff 100644 --- a/crates/git_ui/Cargo.toml +++ b/crates/git_ui/Cargo.toml @@ -74,6 +74,7 @@ gpui = { workspace = true, features = ["test-support"] } indoc.workspace = true pretty_assertions.workspace = true project = { workspace = true, features = ["test-support"] } +rand.workspace = true settings = { workspace = true, features = ["test-support"] } unindent.workspace = true workspace = { workspace = true, features = ["test-support"] } diff --git a/crates/git_ui/src/branch_picker.rs b/crates/git_ui/src/branch_picker.rs index 8a08736d8bace6a77963c4325406d340903f1b73..79cd89d1485f6d99349b43d92c17261cf8a644e2 100644 --- a/crates/git_ui/src/branch_picker.rs +++ b/crates/git_ui/src/branch_picker.rs @@ -6,7 +6,7 @@ use collections::HashSet; use git::repository::Branch; use gpui::http_client::Url; use gpui::{ - Action, App, AsyncApp, Context, DismissEvent, Entity, EventEmitter, FocusHandle, Focusable, + Action, App, Context, DismissEvent, Entity, EventEmitter, FocusHandle, Focusable, InteractiveElement, IntoElement, Modifiers, ModifiersChangedEvent, ParentElement, Render, SharedString, Styled, Subscription, Task, WeakEntity, Window, actions, rems, }; @@ -17,8 +17,8 @@ use settings::Settings; use std::sync::Arc; use time::OffsetDateTime; use ui::{ - CommonAnimationExt, Divider, HighlightedLabel, KeyBinding, ListHeader, ListItem, - ListItemSpacing, Tooltip, prelude::*, + Divider, HighlightedLabel, KeyBinding, ListHeader, ListItem, ListItemSpacing, Tooltip, + prelude::*, }; use util::ResultExt; use workspace::notifications::DetachAndPromptErr; @@ -232,21 +232,12 @@ impl BranchList { window: &mut Window, cx: &mut Context, ) { - self.picker.update(cx, |this, cx| { - this.delegate.display_remotes = !this.delegate.display_remotes; - cx.spawn_in(window, async move |this, cx| { - this.update_in(cx, |picker, window, cx| { - let last_query = picker.delegate.last_query.clone(); - picker.delegate.update_matches(last_query, window, cx) - })? - .await; - - Result::Ok::<_, anyhow::Error>(()) - }) - .detach_and_log_err(cx); + self.picker.update(cx, |picker, cx| { + picker.delegate.branch_filter = picker.delegate.branch_filter.invert(); + picker.update_matches(picker.query(cx), window, cx); + picker.refresh_placeholder(window, cx); + cx.notify(); }); - - cx.notify(); } } impl ModalView for BranchList {} @@ -289,6 +280,10 @@ enum Entry { NewBranch { name: String, }, + NewRemoteName { + name: String, + url: SharedString, + }, } impl Entry { @@ -304,6 +299,7 @@ impl Entry { Entry::Branch { branch, .. } => branch.name(), Entry::NewUrl { url, .. } => url.as_str(), Entry::NewBranch { name, .. } => name.as_str(), + Entry::NewRemoteName { name, .. } => name.as_str(), } } @@ -318,6 +314,23 @@ impl Entry { } } +#[derive(Clone, Copy, PartialEq)] +enum BranchFilter { + /// Only show local branches + Local, + /// Only show remote branches + Remote, +} + +impl BranchFilter { + fn invert(&self) -> Self { + match self { + BranchFilter::Local => BranchFilter::Remote, + BranchFilter::Remote => BranchFilter::Local, + } + } +} + pub struct BranchListDelegate { workspace: Option>, matches: Vec, @@ -328,9 +341,8 @@ pub struct BranchListDelegate { selected_index: usize, last_query: String, modifiers: Modifiers, - display_remotes: bool, + branch_filter: BranchFilter, state: PickerState, - loading: bool, focus_handle: FocusHandle, } @@ -363,9 +375,8 @@ impl BranchListDelegate { selected_index: 0, last_query: Default::default(), modifiers: Default::default(), - display_remotes: false, + branch_filter: BranchFilter::Local, state: PickerState::List, - loading: false, focus_handle: cx.focus_handle(), } } @@ -406,37 +417,13 @@ impl BranchListDelegate { let Some(repo) = self.repo.clone() else { return; }; - cx.spawn(async move |this, cx| { - this.update(cx, |picker, cx| { - picker.delegate.loading = true; - cx.notify(); - }) - .log_err(); - let stop_loader = |this: &WeakEntity>, cx: &mut AsyncApp| { - this.update(cx, |picker, cx| { - picker.delegate.loading = false; - cx.notify(); - }) - .log_err(); - }; - repo.update(cx, |repo, _| repo.create_remote(remote_name, remote_url)) - .inspect_err(|_err| { - stop_loader(&this, cx); - })? - .await - .inspect_err(|_err| { - stop_loader(&this, cx); - })? - .inspect_err(|_err| { - stop_loader(&this, cx); - })?; - stop_loader(&this, cx); - Ok(()) - }) - .detach_and_prompt_err("Failed to create remote", window, cx, |e, _, _cx| { - Some(e.to_string()) - }); + let receiver = repo.update(cx, |repo, _| repo.create_remote(remote_name, remote_url)); + + cx.background_spawn(async move { receiver.await? }) + .detach_and_prompt_err("Failed to create remote", window, cx, |e, _, _cx| { + Some(e.to_string()) + }); cx.emit(DismissEvent); } @@ -528,29 +515,33 @@ impl PickerDelegate for BranchListDelegate { type ListItem = ListItem; fn placeholder_text(&self, _window: &mut Window, _cx: &mut App) -> Arc { - "Select branch…".into() + match self.state { + PickerState::List | PickerState::NewRemote | PickerState::NewBranch => { + match self.branch_filter { + BranchFilter::Local => "Select branch…", + BranchFilter::Remote => "Select remote…", + } + } + PickerState::CreateRemote(_) => "Enter a name for this remote…", + } + .into() + } + + fn no_matches_text(&self, _window: &mut Window, _cx: &mut App) -> Option { + match self.state { + PickerState::CreateRemote(_) => { + Some(SharedString::new_static("Remote name can't be empty")) + } + _ => None, + } } fn render_editor( &self, editor: &Entity, - window: &mut Window, - cx: &mut Context>, + _window: &mut Window, + _cx: &mut Context>, ) -> Div { - cx.update_entity(editor, move |editor, cx| { - let placeholder = match self.state { - PickerState::List | PickerState::NewRemote | PickerState::NewBranch => { - if self.display_remotes { - "Select remote…" - } else { - "Select branch…" - } - } - PickerState::CreateRemote(_) => "Choose a name…", - }; - editor.set_placeholder_text(placeholder, window, cx); - }); - let focus_handle = self.focus_handle.clone(); v_flex() @@ -568,16 +559,14 @@ impl PickerDelegate for BranchListDelegate { .when( self.editor_position() == PickerEditorPosition::End, |this| { - let tooltip_label = if self.display_remotes { - "Turn Off Remote Filter" - } else { - "Filter Remote Branches" + let tooltip_label = match self.branch_filter { + BranchFilter::Local => "Turn Off Remote Filter", + BranchFilter::Remote => "Filter Remote Branches", }; this.gap_1().justify_between().child({ IconButton::new("filter-remotes", IconName::Filter) - .disabled(self.loading) - .toggle_state(self.display_remotes) + .toggle_state(self.branch_filter == BranchFilter::Remote) .tooltip(move |_, cx| { Tooltip::for_action_in( tooltip_label, @@ -636,13 +625,13 @@ impl PickerDelegate for BranchListDelegate { return Task::ready(()); }; - let display_remotes = self.display_remotes; + let display_remotes = self.branch_filter; cx.spawn_in(window, async move |picker, cx| { let mut matches: Vec = if query.is_empty() { all_branches .into_iter() .filter(|branch| { - if display_remotes { + if display_remotes == BranchFilter::Remote { branch.is_remote() } else { !branch.is_remote() @@ -657,7 +646,7 @@ impl PickerDelegate for BranchListDelegate { let branches = all_branches .iter() .filter(|branch| { - if display_remotes { + if display_remotes == BranchFilter::Remote { branch.is_remote() } else { !branch.is_remote() @@ -688,11 +677,19 @@ impl PickerDelegate for BranchListDelegate { }; picker .update(cx, |picker, _| { - if matches!(picker.delegate.state, PickerState::CreateRemote(_)) { + if let PickerState::CreateRemote(url) = &picker.delegate.state { + let query = query.replace(' ', "-"); + if !query.is_empty() { + picker.delegate.matches = vec![Entry::NewRemoteName { + name: query.clone(), + url: url.clone(), + }]; + picker.delegate.selected_index = 0; + } else { + picker.delegate.matches = Vec::new(); + picker.delegate.selected_index = 0; + } picker.delegate.last_query = query; - picker.delegate.matches = Vec::new(); - picker.delegate.selected_index = 0; - return; } @@ -736,13 +733,6 @@ impl PickerDelegate for BranchListDelegate { } fn confirm(&mut self, secondary: bool, window: &mut Window, cx: &mut Context>) { - if let PickerState::CreateRemote(remote_url) = &self.state { - self.create_remote(self.last_query.clone(), remote_url.to_string(), window, cx); - self.state = PickerState::List; - cx.notify(); - return; - } - let Some(entry) = self.matches.get(self.selected_index()) else { return; }; @@ -785,13 +775,19 @@ impl PickerDelegate for BranchListDelegate { self.state = PickerState::CreateRemote(url.clone().into()); self.matches = Vec::new(); self.selected_index = 0; - cx.spawn_in(window, async move |this, cx| { - this.update_in(cx, |picker, window, cx| { - picker.set_query("", window, cx); - }) - }) - .detach_and_log_err(cx); - cx.notify(); + + cx.defer_in(window, |picker, window, cx| { + picker.refresh_placeholder(window, cx); + picker.set_query("", window, cx); + cx.notify(); + }); + + // returning early to prevent dismissing the modal, so a user can enter + // a remote name first. + return; + } + Entry::NewRemoteName { name, url } => { + self.create_remote(name.clone(), url.to_string(), window, cx); } Entry::NewBranch { name } => { let from_branch = if secondary { @@ -842,17 +838,13 @@ impl PickerDelegate for BranchListDelegate { .unwrap_or_else(|| (None, None, None)); let entry_icon = match entry { - Entry::NewUrl { .. } | Entry::NewBranch { .. } => { + Entry::NewUrl { .. } | Entry::NewBranch { .. } | Entry::NewRemoteName { .. } => { Icon::new(IconName::Plus).color(Color::Muted) } - - Entry::Branch { .. } => { - if self.display_remotes { - Icon::new(IconName::Screen).color(Color::Muted) - } else { - Icon::new(IconName::GitBranchAlt).color(Color::Muted) - } - } + Entry::Branch { .. } => match self.branch_filter { + BranchFilter::Local => Icon::new(IconName::GitBranchAlt).color(Color::Muted), + BranchFilter::Remote => Icon::new(IconName::Screen).color(Color::Muted), + }, }; let entry_title = match entry { @@ -864,6 +856,10 @@ impl PickerDelegate for BranchListDelegate { .single_line() .truncate() .into_any_element(), + Entry::NewRemoteName { name, .. } => Label::new(format!("Create Remote: \"{name}\"")) + .single_line() + .truncate() + .into_any_element(), Entry::Branch { branch, positions } => { HighlightedLabel::new(branch.name().to_string(), positions.clone()) .single_line() @@ -873,7 +869,10 @@ impl PickerDelegate for BranchListDelegate { }; let focus_handle = self.focus_handle.clone(); - let is_new_items = matches!(entry, Entry::NewUrl { .. } | Entry::NewBranch { .. }); + let is_new_items = matches!( + entry, + Entry::NewUrl { .. } | Entry::NewBranch { .. } | Entry::NewRemoteName { .. } + ); let delete_branch_button = IconButton::new("delete", IconName::Trash) .tooltip(move |_, cx| { @@ -935,6 +934,9 @@ impl PickerDelegate for BranchListDelegate { Entry::NewUrl { url } => { format!("Based off {url}") } + Entry::NewRemoteName { url, .. } => { + format!("Based off {url}") + } Entry::NewBranch { .. } => { if let Some(current_branch) = self.repo.as_ref().and_then(|repo| { @@ -1033,10 +1035,9 @@ impl PickerDelegate for BranchListDelegate { _cx: &mut Context>, ) -> Option { matches!(self.state, PickerState::List).then(|| { - let label = if self.display_remotes { - "Remote" - } else { - "Local" + let label = match self.branch_filter { + BranchFilter::Local => "Local", + BranchFilter::Remote => "Remote", }; ListHeader::new(label).inset(true).into_any_element() @@ -1047,11 +1048,7 @@ impl PickerDelegate for BranchListDelegate { if self.editor_position() == PickerEditorPosition::End { return None; } - let focus_handle = self.focus_handle.clone(); - let loading_icon = Icon::new(IconName::LoadCircle) - .size(IconSize::Small) - .with_rotate_animation(3); let footer_container = || { h_flex() @@ -1090,7 +1087,6 @@ impl PickerDelegate for BranchListDelegate { .gap_1() .child( Button::new("delete-branch", "Delete") - .disabled(self.loading) .key_binding( KeyBinding::for_action_in( &branch_picker::DeleteBranch, @@ -1138,17 +1134,15 @@ impl PickerDelegate for BranchListDelegate { ) }, ) - } else if self.loading { - this.justify_between() - .child(loading_icon) - .child(delete_and_select_btns) } else { this.justify_between() .child({ let focus_handle = focus_handle.clone(); Button::new("filter-remotes", "Filter Remotes") - .disabled(self.loading) - .toggle_state(self.display_remotes) + .toggle_state(matches!( + self.branch_filter, + BranchFilter::Remote + )) .key_binding( KeyBinding::for_action_in( &branch_picker::FilterRemotes, @@ -1213,14 +1207,15 @@ impl PickerDelegate for BranchListDelegate { footer_container() .justify_end() .child( - Label::new("Choose a name for this remote repository") - .size(LabelSize::Small) - .color(Color::Muted), - ) - .child( - Label::new("Save") - .size(LabelSize::Small) - .color(Color::Muted), + Button::new("branch-from-default", "Confirm") + .key_binding( + KeyBinding::for_action_in(&menu::Confirm, &focus_handle, cx) + .map(|kb| kb.size(rems_from_px(12.))), + ) + .on_click(cx.listener(|this, _, window, cx| { + this.delegate.confirm(false, window, cx); + })) + .disabled(self.last_query.is_empty()), ) .into_any_element(), ), @@ -1237,6 +1232,7 @@ mod tests { use git::repository::{CommitSummary, Remote}; use gpui::{TestAppContext, VisualTestContext}; use project::{FakeFs, Project}; + use rand::{Rng, rngs::StdRng}; use serde_json::json; use settings::SettingsStore; use util::path; @@ -1284,10 +1280,10 @@ mod tests { } fn init_branch_list_test( - cx: &mut TestAppContext, repository: Option>, branches: Vec, - ) -> (VisualTestContext, Entity) { + cx: &mut TestAppContext, + ) -> (Entity, VisualTestContext) { let window = cx.add_window(|window, cx| { let mut delegate = BranchListDelegate::new(None, repository, BranchListStyle::Modal, cx); @@ -1313,7 +1309,7 @@ mod tests { let branch_list = window.root(cx).unwrap(); let cx = VisualTestContext::from_window(*window, cx); - (cx, branch_list) + (branch_list, cx) } async fn init_fake_repository(cx: &mut TestAppContext) -> Entity { @@ -1347,7 +1343,7 @@ mod tests { init_test(cx); let branches = create_test_branches(); - let (mut ctx, branch_list) = init_branch_list_test(cx, None, branches); + let (branch_list, mut ctx) = init_branch_list_test(None, branches, cx); let cx = &mut ctx; branch_list @@ -1423,7 +1419,7 @@ mod tests { .await; cx.run_until_parked(); - let (mut ctx, branch_list) = init_branch_list_test(cx, repository.into(), branches); + let (branch_list, mut ctx) = init_branch_list_test(repository.into(), branches, cx); let cx = &mut ctx; update_branch_list_matches_with_empty_query(&branch_list, cx).await; @@ -1488,12 +1484,12 @@ mod tests { .await; cx.run_until_parked(); - let (mut ctx, branch_list) = init_branch_list_test(cx, repository.into(), branches); + let (branch_list, mut ctx) = init_branch_list_test(repository.into(), branches, cx); let cx = &mut ctx; // Enable remote filter branch_list.update(cx, |branch_list, cx| { branch_list.picker.update(cx, |picker, _cx| { - picker.delegate.display_remotes = true; + picker.delegate.branch_filter = BranchFilter::Remote; }); }); update_branch_list_matches_with_empty_query(&branch_list, cx).await; @@ -1546,7 +1542,7 @@ mod tests { create_test_branch("develop", false, None, Some(700)), ]; - let (mut ctx, branch_list) = init_branch_list_test(cx, None, branches); + let (branch_list, mut ctx) = init_branch_list_test(None, branches, cx); let cx = &mut ctx; update_branch_list_matches_with_empty_query(&branch_list, cx).await; @@ -1573,7 +1569,7 @@ mod tests { let last_match = picker.delegate.matches.last().unwrap(); assert!(!last_match.is_new_branch()); assert!(!last_match.is_new_url()); - picker.delegate.display_remotes = true; + picker.delegate.branch_filter = BranchFilter::Remote; picker.delegate.update_matches(String::new(), window, cx) }) }) @@ -1600,7 +1596,7 @@ mod tests { // Verify the last entry is NOT the "create new branch" option let last_match = picker.delegate.matches.last().unwrap(); assert!(!last_match.is_new_url()); - picker.delegate.display_remotes = true; + picker.delegate.branch_filter = BranchFilter::Remote; picker .delegate .update_matches(String::from("fork"), window, cx) @@ -1629,22 +1625,27 @@ mod tests { #[gpui::test] async fn test_new_branch_creation_with_query(test_cx: &mut TestAppContext) { + const MAIN_BRANCH: &str = "main"; + const FEATURE_BRANCH: &str = "feature"; + const NEW_BRANCH: &str = "new-feature-branch"; + init_test(test_cx); let repository = init_fake_repository(test_cx).await; let branches = vec![ - create_test_branch("main", true, None, Some(1000)), - create_test_branch("feature", false, None, Some(900)), + create_test_branch(MAIN_BRANCH, true, None, Some(1000)), + create_test_branch(FEATURE_BRANCH, false, None, Some(900)), ]; - let (mut ctx, branch_list) = init_branch_list_test(test_cx, repository.into(), branches); + let (branch_list, mut ctx) = init_branch_list_test(repository.into(), branches, test_cx); let cx = &mut ctx; branch_list .update_in(cx, |branch_list, window, cx| { branch_list.picker.update(cx, |picker, cx| { - let query = "new-feature-branch".to_string(); - picker.delegate.update_matches(query, window, cx) + picker + .delegate + .update_matches(NEW_BRANCH.to_string(), window, cx) }) }) .await; @@ -1655,7 +1656,7 @@ mod tests { branch_list.picker.update(cx, |picker, cx| { let last_match = picker.delegate.matches.last().unwrap(); assert!(last_match.is_new_branch()); - assert_eq!(last_match.name(), "new-feature-branch"); + assert_eq!(last_match.name(), NEW_BRANCH); // State is NewBranch because no existing branches fuzzy-match the query assert!(matches!(picker.delegate.state, PickerState::NewBranch)); picker.delegate.confirm(false, window, cx); @@ -1680,11 +1681,11 @@ mod tests { let new_branch = branches .into_iter() - .find(|branch| branch.name() == "new-feature-branch") + .find(|branch| branch.name() == NEW_BRANCH) .expect("new-feature-branch should exist"); assert_eq!( new_branch.ref_name.as_ref(), - "refs/heads/new-feature-branch", + &format!("refs/heads/{NEW_BRANCH}"), "branch ref_name should not have duplicate refs/heads/ prefix" ); } @@ -1695,7 +1696,7 @@ mod tests { let repository = init_fake_repository(cx).await; let branches = vec![create_test_branch("main", true, None, Some(1000))]; - let (mut ctx, branch_list) = init_branch_list_test(cx, repository.into(), branches); + let (branch_list, mut ctx) = init_branch_list_test(repository.into(), branches, cx); let cx = &mut ctx; branch_list @@ -1734,8 +1735,13 @@ mod tests { branch_list.update_in(cx, |branch_list, window, cx| { branch_list.picker.update(cx, |picker, cx| { + assert_eq!(picker.delegate.matches.len(), 1); + assert!(matches!( + picker.delegate.matches.first(), + Some(Entry::NewRemoteName { name, url }) + if name == "my_new_remote" && url.as_ref() == "https://github.com/user/repo.git" + )); picker.delegate.confirm(false, window, cx); - assert_eq!(picker.delegate.matches.len(), 0); }) }); cx.run_until_parked(); @@ -1768,7 +1774,7 @@ mod tests { init_test(cx); let branches = vec![create_test_branch("main_branch", true, None, Some(1000))]; - let (mut ctx, branch_list) = init_branch_list_test(cx, None, branches); + let (branch_list, mut ctx) = init_branch_list_test(None, branches, cx); let cx = &mut ctx; branch_list @@ -1823,4 +1829,79 @@ mod tests { }) }); } + + #[gpui::test] + async fn test_confirm_remote_url_does_not_dismiss(cx: &mut TestAppContext) { + const REMOTE_URL: &str = "https://github.com/user/repo.git"; + + init_test(cx); + let branches = vec![create_test_branch("main", true, None, Some(1000))]; + + let (branch_list, mut ctx) = init_branch_list_test(None, branches, cx); + let cx = &mut ctx; + + let subscription = cx.update(|_, cx| { + cx.subscribe(&branch_list, |_, _: &DismissEvent, _| { + panic!("DismissEvent should not be emitted when confirming a remote URL"); + }) + }); + + branch_list + .update_in(cx, |branch_list, window, cx| { + window.focus(&branch_list.picker_focus_handle); + branch_list.picker.update(cx, |picker, cx| { + picker + .delegate + .update_matches(REMOTE_URL.to_string(), window, cx) + }) + }) + .await; + + cx.run_until_parked(); + + branch_list.update_in(cx, |branch_list, window, cx| { + branch_list.picker.update(cx, |picker, cx| { + let last_match = picker.delegate.matches.last().unwrap(); + assert!(last_match.is_new_url()); + assert!(matches!(picker.delegate.state, PickerState::NewRemote)); + + picker.delegate.confirm(false, window, cx); + + assert!( + matches!(picker.delegate.state, PickerState::CreateRemote(ref url) if url.as_ref() == REMOTE_URL), + "State should transition to CreateRemote with the URL" + ); + }); + + assert!( + branch_list.picker_focus_handle.is_focused(window), + "Branch list picker should still be focused after confirming remote URL" + ); + }); + + cx.run_until_parked(); + + drop(subscription); + } + + #[gpui::test(iterations = 10)] + async fn test_empty_query_displays_all_branches(mut rng: StdRng, cx: &mut TestAppContext) { + init_test(cx); + let branch_count = rng.random_range(13..540); + + let branches: Vec = (0..branch_count) + .map(|i| create_test_branch(&format!("branch-{:02}", i), i == 0, None, Some(i * 100))) + .collect(); + + let (branch_list, mut ctx) = init_branch_list_test(None, branches, cx); + let cx = &mut ctx; + + update_branch_list_matches_with_empty_query(&branch_list, cx).await; + + branch_list.update(cx, |branch_list, cx| { + branch_list.picker.update(cx, |picker, _cx| { + assert_eq!(picker.delegate.matches.len(), branch_count as usize); + }) + }); + } } From e9073eceeba8e1a71e966582566179517591ec6b Mon Sep 17 00:00:00 2001 From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Date: Sun, 14 Dec 2025 10:48:23 -0300 Subject: [PATCH 253/621] agent_ui: Fix fallback icon used for external agents (#44777) When an external agent doesn't provide an icon, we were using different fallback icons in all the places we display icons (settings view, thread new menu, and the thread view toolbar itself). Release Notes: - N/A --- crates/agent_ui/src/agent_configuration.rs | 3 ++- crates/agent_ui/src/agent_panel.rs | 21 +++++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/crates/agent_ui/src/agent_configuration.rs b/crates/agent_ui/src/agent_configuration.rs index 8619b085c00268d6d157dee37411ff36ba4d5680..24f019c605d1b167e62a6e68dfc1f3ed07c73f1c 100644 --- a/crates/agent_ui/src/agent_configuration.rs +++ b/crates/agent_ui/src/agent_configuration.rs @@ -975,7 +975,7 @@ impl AgentConfiguration { let icon = if let Some(icon_path) = agent_server_store.agent_icon(&name) { AgentIcon::Path(icon_path) } else { - AgentIcon::Name(IconName::Ai) + AgentIcon::Name(IconName::Sparkle) }; let display_name = agent_server_store .agent_display_name(&name) @@ -1137,6 +1137,7 @@ impl AgentConfiguration { ) -> impl IntoElement { let id = id.into(); let display_name = display_name.into(); + let icon = match icon { AgentIcon::Name(icon_name) => Icon::new(icon_name) .size(IconSize::Small) diff --git a/crates/agent_ui/src/agent_panel.rs b/crates/agent_ui/src/agent_panel.rs index 2f6a722b471a189eafbc7aadbddb927476e4b3b9..97c7aecb8e34563db0adfa6bdbeda31140fd6cdd 100644 --- a/crates/agent_ui/src/agent_panel.rs +++ b/crates/agent_ui/src/agent_panel.rs @@ -259,7 +259,7 @@ impl AgentType { Self::Gemini => Some(IconName::AiGemini), Self::ClaudeCode => Some(IconName::AiClaude), Self::Codex => Some(IconName::AiOpenAi), - Self::Custom { .. } => Some(IconName::Terminal), + Self::Custom { .. } => Some(IconName::Sparkle), } } } @@ -1851,14 +1851,17 @@ impl AgentPanel { let agent_server_store = self.project.read(cx).agent_server_store().clone(); let focus_handle = self.focus_handle(cx); - // Get custom icon path for selected agent before building menu (to avoid borrow issues) - let selected_agent_custom_icon = + let (selected_agent_custom_icon, selected_agent_label) = if let AgentType::Custom { name, .. } = &self.selected_agent { - agent_server_store - .read(cx) - .agent_icon(&ExternalAgentServerName(name.clone())) + let store = agent_server_store.read(cx); + let icon = store.agent_icon(&ExternalAgentServerName(name.clone())); + + let label = store + .agent_display_name(&ExternalAgentServerName(name.clone())) + .unwrap_or_else(|| self.selected_agent.label()); + (icon, label) } else { - None + (None, self.selected_agent.label()) }; let active_thread = match &self.active_view { @@ -2090,7 +2093,7 @@ impl AgentPanel { if let Some(icon_path) = icon_path { entry = entry.custom_icon_svg(icon_path); } else { - entry = entry.icon(IconName::Terminal); + entry = entry.icon(IconName::Sparkle); } entry = entry .when( @@ -2154,8 +2157,6 @@ impl AgentPanel { } }); - let selected_agent_label = self.selected_agent.label(); - let is_thread_loading = self .active_thread_view() .map(|thread| thread.read(cx).is_loading()) From 13594bd97ec1250d49d99c3587575607837bad97 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Sun, 14 Dec 2025 19:01:22 +0100 Subject: [PATCH 254/621] keymap: More default keymap fixes for windows/linux (#44821) Release Notes: - N/A *or* Added/Fixed/Improved ... --- assets/keymaps/default-linux.json | 2 +- assets/keymaps/default-windows.json | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/assets/keymaps/default-linux.json b/assets/keymaps/default-linux.json index 0bcbb455b502642237347cf9fc36b91eab83f20b..872544cdff0bc03bbafd6b711fa7adb2f5e2d008 100644 --- a/assets/keymaps/default-linux.json +++ b/assets/keymaps/default-linux.json @@ -63,7 +63,6 @@ "delete": "editor::Delete", "tab": "editor::Tab", "shift-tab": "editor::Backtab", - "ctrl-k": "editor::CutToEndOfLine", "ctrl-k ctrl-q": "editor::Rewrap", "ctrl-k q": "editor::Rewrap", "ctrl-backspace": ["editor::DeleteToPreviousWordStart", { "ignore_newlines": false, "ignore_brackets": false }], @@ -501,6 +500,7 @@ "ctrl-k ctrl-i": "editor::Hover", "ctrl-k ctrl-b": "editor::BlameHover", "ctrl-/": ["editor::ToggleComments", { "advance_downwards": false }], + "ctrl-k ctrl-c": ["editor::ToggleComments", { "advance_downwards": false }], "f8": ["editor::GoToDiagnostic", { "severity": { "min": "hint", "max": "error" } }], "shift-f8": ["editor::GoToPreviousDiagnostic", { "severity": { "min": "hint", "max": "error" } }], "f2": "editor::Rename", diff --git a/assets/keymaps/default-windows.json b/assets/keymaps/default-windows.json index 51943ab35587e633a25eb9420c45dff21048330a..ae051f233e344cc6b961612c690ae1b5107fb2c0 100644 --- a/assets/keymaps/default-windows.json +++ b/assets/keymaps/default-windows.json @@ -63,7 +63,6 @@ "delete": "editor::Delete", "tab": "editor::Tab", "shift-tab": "editor::Backtab", - "ctrl-k": "editor::CutToEndOfLine", "ctrl-k ctrl-q": "editor::Rewrap", "ctrl-k q": "editor::Rewrap", "ctrl-backspace": ["editor::DeleteToPreviousWordStart", { "ignore_newlines": false, "ignore_brackets": false }], @@ -465,8 +464,10 @@ "ctrl-k ctrl-w": "workspace::CloseAllItemsAndPanes", "back": "pane::GoBack", "alt--": "pane::GoBack", + "alt-left": "pane::GoBack", "forward": "pane::GoForward", "alt-=": "pane::GoForward", + "alt-right": "pane::GoForward", "f3": "search::SelectNextMatch", "shift-f3": "search::SelectPreviousMatch", "ctrl-shift-f": "project_search::ToggleFocus", @@ -508,6 +509,7 @@ "ctrl-k ctrl-b": "editor::BlameHover", "ctrl-k ctrl-f": "editor::FormatSelections", "ctrl-/": ["editor::ToggleComments", { "advance_downwards": false }], + "ctrl-k ctrl-c": ["editor::ToggleComments", { "advance_downwards": false }], "f8": ["editor::GoToDiagnostic", { "severity": { "min": "hint", "max": "error" } }], "shift-f8": ["editor::GoToPreviousDiagnostic", { "severity": { "min": "hint", "max": "error" } }], "f2": "editor::Rename", From f80ef9a3c52a0d07bc3db536f853b6e0083dfdd3 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Sun, 14 Dec 2025 19:21:50 +0100 Subject: [PATCH 255/621] editor: Fix inlay hovers blinking in sync with cursors (#44822) This change matches how normal hovers are handled (which early return with `None` in this branch) Release Notes: - Fixed hover boxes for inlays blinking in and out without movement when cursor blinking was enabled --- crates/editor/src/hover_popover.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/editor/src/hover_popover.rs b/crates/editor/src/hover_popover.rs index edf10671b9e4c63e2918f6e144ba1b553e44daca..7c3e41e8c2edf721fbcae729069eecb640e2246c 100644 --- a/crates/editor/src/hover_popover.rs +++ b/crates/editor/src/hover_popover.rs @@ -151,7 +151,7 @@ pub fn hover_at_inlay( false }) { - hide_hover(editor, cx); + return; } let hover_popover_delay = EditorSettings::get_global(cx).hover_popover_delay.0; From 26b261a33645f20993fd8f819109b37cabcdc67c Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Sun, 14 Dec 2025 11:47:15 -0700 Subject: [PATCH 256/621] Implement Sum trait for Pixels (#44809) This adds implementations of `std::iter::Sum` for `Pixels`, allowing the use of `.sum()` on iterators of `Pixels` values. ### Changes - Implement `Sum` for `Pixels` (owned values) - Implement `Sum<&Pixels>` for `Pixels` (references) This enables ergonomic patterns like: ```rust let total: Pixels = pixel_values.iter().sum(); ``` --- crates/gpui/src/geometry.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/crates/gpui/src/geometry.rs b/crates/gpui/src/geometry.rs index f466624dfb91af9b4a33421ea15827ebe2559665..fc735ba5e0e7e719ed12b6b1b168ec3ee49e22bb 100644 --- a/crates/gpui/src/geometry.rs +++ b/crates/gpui/src/geometry.rs @@ -2648,6 +2648,18 @@ impl Debug for Pixels { } } +impl std::iter::Sum for Pixels { + fn sum>(iter: I) -> Self { + iter.fold(Self::ZERO, |a, b| a + b) + } +} + +impl<'a> std::iter::Sum<&'a Pixels> for Pixels { + fn sum>(iter: I) -> Self { + iter.fold(Self::ZERO, |a, b| a + *b) + } +} + impl TryFrom<&'_ str> for Pixels { type Error = anyhow::Error; From a51585d2daaa975409a835f43574c8bb5bcc9d5b Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Sun, 14 Dec 2025 12:58:26 -0700 Subject: [PATCH 257/621] Fix race condition in test_collaborating_with_completion (#44806) The test `test_collaborating_with_completion` has a latent race condition that hasn't manifested on CI yet but could cause hangs with certain task orderings. ## The Bug Commit `fd1494c31a` set up LSP request handlers AFTER typing the trigger character: ```rust // Type trigger first - spawns async tasks to send completion request editor_b.update_in(cx_b, |editor, window, cx| { editor.handle_input(".", window, cx); }); // THEN set up handlers (race condition!) fake_language_server .set_request_handler::(...) .next().await.unwrap(); // Waits for handler to receive a request ``` Whether this works depends on task scheduling order, which varies by seed. If the completion request is processed before the handler is registered, the request goes to `on_unhandled_notification` which claims to handle it but sends no response, causing a hang. ## Changes - Move handler setup BEFORE typing the trigger character - Make `TestDispatcher::spawn_realtime` panic to prevent future non-determinism from real OS threads - Add `execution_hash()` and `execution_count()` to TestDispatcher for debugging - Add `DEBUG_SCHEDULER=1` logging for task execution tracing - Document the investigation in `situation.md` cc @localcc @SomeoneToIgnore (authors of related commits) Release Notes: - N/A --------- Co-authored-by: Kirill Bulatov --- crates/collab/src/tests/editor_tests.rs | 109 ++++++++++++------------ 1 file changed, 54 insertions(+), 55 deletions(-) diff --git a/crates/collab/src/tests/editor_tests.rs b/crates/collab/src/tests/editor_tests.rs index ba92e868126c7f27fb5051021fce44fe43c8d5e7..4e6cdb0e79aba494bd01137cc262a097a084217e 100644 --- a/crates/collab/src/tests/editor_tests.rs +++ b/crates/collab/src/tests/editor_tests.rs @@ -312,6 +312,49 @@ async fn test_collaborating_with_completion(cx_a: &mut TestAppContext, cx_b: &mu "Rust", FakeLspAdapter { capabilities: capabilities.clone(), + initializer: Some(Box::new(|fake_server| { + fake_server.set_request_handler::( + |params, _| async move { + assert_eq!( + params.text_document_position.text_document.uri, + lsp::Uri::from_file_path(path!("/a/main.rs")).unwrap(), + ); + assert_eq!( + params.text_document_position.position, + lsp::Position::new(0, 14), + ); + + Ok(Some(lsp::CompletionResponse::Array(vec![ + lsp::CompletionItem { + label: "first_method(…)".into(), + detail: Some("fn(&mut self, B) -> C".into()), + text_edit: Some(lsp::CompletionTextEdit::Edit(lsp::TextEdit { + new_text: "first_method($1)".to_string(), + range: lsp::Range::new( + lsp::Position::new(0, 14), + lsp::Position::new(0, 14), + ), + })), + insert_text_format: Some(lsp::InsertTextFormat::SNIPPET), + ..Default::default() + }, + lsp::CompletionItem { + label: "second_method(…)".into(), + detail: Some("fn(&mut self, C) -> D".into()), + text_edit: Some(lsp::CompletionTextEdit::Edit(lsp::TextEdit { + new_text: "second_method()".to_string(), + range: lsp::Range::new( + lsp::Position::new(0, 14), + lsp::Position::new(0, 14), + ), + })), + insert_text_format: Some(lsp::InsertTextFormat::SNIPPET), + ..Default::default() + }, + ]))) + }, + ); + })), ..FakeLspAdapter::default() }, ), @@ -320,6 +363,11 @@ async fn test_collaborating_with_completion(cx_a: &mut TestAppContext, cx_b: &mu FakeLspAdapter { name: "fake-analyzer", capabilities: capabilities.clone(), + initializer: Some(Box::new(|fake_server| { + fake_server.set_request_handler::( + |_, _| async move { Ok(None) }, + ); + })), ..FakeLspAdapter::default() }, ), @@ -373,6 +421,7 @@ async fn test_collaborating_with_completion(cx_a: &mut TestAppContext, cx_b: &mu let fake_language_server = fake_language_servers[0].next().await.unwrap(); let second_fake_language_server = fake_language_servers[1].next().await.unwrap(); cx_a.background_executor.run_until_parked(); + cx_b.background_executor.run_until_parked(); buffer_b.read_with(cx_b, |buffer, _| { assert!(!buffer.completion_triggers().is_empty()) @@ -387,58 +436,9 @@ async fn test_collaborating_with_completion(cx_a: &mut TestAppContext, cx_b: &mu }); cx_b.focus(&editor_b); - // Receive a completion request as the host's language server. - // Return some completions from the host's language server. - cx_a.executor().start_waiting(); - fake_language_server - .set_request_handler::(|params, _| async move { - assert_eq!( - params.text_document_position.text_document.uri, - lsp::Uri::from_file_path(path!("/a/main.rs")).unwrap(), - ); - assert_eq!( - params.text_document_position.position, - lsp::Position::new(0, 14), - ); - - Ok(Some(lsp::CompletionResponse::Array(vec![ - lsp::CompletionItem { - label: "first_method(…)".into(), - detail: Some("fn(&mut self, B) -> C".into()), - text_edit: Some(lsp::CompletionTextEdit::Edit(lsp::TextEdit { - new_text: "first_method($1)".to_string(), - range: lsp::Range::new( - lsp::Position::new(0, 14), - lsp::Position::new(0, 14), - ), - })), - insert_text_format: Some(lsp::InsertTextFormat::SNIPPET), - ..Default::default() - }, - lsp::CompletionItem { - label: "second_method(…)".into(), - detail: Some("fn(&mut self, C) -> D".into()), - text_edit: Some(lsp::CompletionTextEdit::Edit(lsp::TextEdit { - new_text: "second_method()".to_string(), - range: lsp::Range::new( - lsp::Position::new(0, 14), - lsp::Position::new(0, 14), - ), - })), - insert_text_format: Some(lsp::InsertTextFormat::SNIPPET), - ..Default::default() - }, - ]))) - }) - .next() - .await - .unwrap(); - second_fake_language_server - .set_request_handler::(|_, _| async move { Ok(None) }) - .next() - .await - .unwrap(); - cx_a.executor().finish_waiting(); + // Allow the completion request to propagate from guest to host to LSP. + cx_b.background_executor.run_until_parked(); + cx_a.background_executor.run_until_parked(); // Open the buffer on the host. let buffer_a = project_a @@ -484,6 +484,7 @@ async fn test_collaborating_with_completion(cx_a: &mut TestAppContext, cx_b: &mu // The additional edit is applied. cx_a.executor().run_until_parked(); + cx_b.executor().run_until_parked(); buffer_a.read_with(cx_a, |buffer, _| { assert_eq!( @@ -641,13 +642,11 @@ async fn test_collaborating_with_completion(cx_a: &mut TestAppContext, cx_b: &mu ), })), insert_text_format: Some(lsp::InsertTextFormat::SNIPPET), - ..Default::default() + ..lsp::CompletionItem::default() }, ]))) }); - cx_b.executor().run_until_parked(); - // Await both language server responses first_lsp_completion.next().await.unwrap(); second_lsp_completion.next().await.unwrap(); From 86aa9abc9036fa94cf2a98aefbefb1d7c71ad699 Mon Sep 17 00:00:00 2001 From: Cole Miller Date: Sun, 14 Dec 2025 21:48:15 -0500 Subject: [PATCH 258/621] git: Avoid removing project excerpts for dirty buffers (#44312) Imitating the approach of #41829. Prevents e.g. reverting a hunk and having that excerpt yanked out from under the cursor. Release Notes: - git: Improved stability of excerpts when editing in the project diff. --- crates/acp_thread/src/diff.rs | 2 +- crates/agent_ui/src/agent_diff.rs | 7 +- crates/editor/src/editor.rs | 40 +--------- crates/editor/src/items.rs | 1 - crates/git_ui/src/project_diff.rs | 114 +++++++++++++++++++++------- crates/multi_buffer/src/path_key.rs | 15 ++-- 6 files changed, 104 insertions(+), 75 deletions(-) diff --git a/crates/acp_thread/src/diff.rs b/crates/acp_thread/src/diff.rs index f17e9d0fce404483ae99efc95bf666586c1f644b..cae1aad90810c217324659d29c065af443494933 100644 --- a/crates/acp_thread/src/diff.rs +++ b/crates/acp_thread/src/diff.rs @@ -166,7 +166,7 @@ impl Diff { } pub fn has_revealed_range(&self, cx: &App) -> bool { - self.multibuffer().read(cx).excerpt_paths().next().is_some() + self.multibuffer().read(cx).paths().next().is_some() } pub fn needs_update(&self, old_text: &str, new_text: &str, cx: &App) -> bool { diff --git a/crates/agent_ui/src/agent_diff.rs b/crates/agent_ui/src/agent_diff.rs index 11acd649ef9df500edf99926e754228e4c41e7bc..06fce64819d3ce66b9e39f2b83cbebefb6ba9698 100644 --- a/crates/agent_ui/src/agent_diff.rs +++ b/crates/agent_ui/src/agent_diff.rs @@ -130,7 +130,12 @@ impl AgentDiffPane { .action_log() .read(cx) .changed_buffers(cx); - let mut paths_to_delete = self.multibuffer.read(cx).paths().collect::>(); + let mut paths_to_delete = self + .multibuffer + .read(cx) + .paths() + .cloned() + .collect::>(); for (buffer, diff_handle) in changed_buffers { if buffer.read(cx).file().is_none() { diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index cddb20d83e0b9066fcfd882aa5325624cbadf92e..923b5dc1540d93bd849f5a50a8d51052f79f93a0 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -22956,10 +22956,7 @@ impl Editor { window: &mut Window, cx: &mut Context, ) { - let workspace = self.workspace(); - let project = self.project(); - let save_tasks = self.buffer().update(cx, |multi_buffer, cx| { - let mut tasks = Vec::new(); + self.buffer().update(cx, |multi_buffer, cx| { for (buffer_id, changes) in revert_changes { if let Some(buffer) = multi_buffer.buffer(buffer_id) { buffer.update(cx, |buffer, cx| { @@ -22971,44 +22968,9 @@ impl Editor { cx, ); }); - - if let Some(project) = - project.filter(|_| multi_buffer.all_diff_hunks_expanded()) - { - project.update(cx, |project, cx| { - tasks.push((buffer.clone(), project.save_buffer(buffer, cx))); - }) - } } } - tasks }); - cx.spawn_in(window, async move |_, cx| { - for (buffer, task) in save_tasks { - let result = task.await; - if result.is_err() { - let Some(path) = buffer - .read_with(cx, |buffer, cx| buffer.project_path(cx)) - .ok() - else { - continue; - }; - if let Some((workspace, path)) = workspace.as_ref().zip(path) { - let Some(task) = cx - .update_window_entity(workspace, |workspace, window, cx| { - workspace - .open_path_preview(path, None, false, false, false, window, cx) - }) - .ok() - else { - continue; - }; - task.await.log_err(); - } - } - } - }) - .detach(); self.change_selections(SelectionEffects::no_scroll(), window, cx, |selections| { selections.refresh() }); diff --git a/crates/editor/src/items.rs b/crates/editor/src/items.rs index 3b9c17f80f10116f2302bab203966922cbf0bcb2..cfbb7c975c844f08d76a5568f1e02dfe3d7d74f1 100644 --- a/crates/editor/src/items.rs +++ b/crates/editor/src/items.rs @@ -842,7 +842,6 @@ impl Item for Editor { .map(|handle| handle.read(cx).base_buffer().unwrap_or(handle.clone())) .collect::>(); - // let mut buffers_to_save = let buffers_to_save = if self.buffer.read(cx).is_singleton() && !options.autosave { buffers } else { diff --git a/crates/git_ui/src/project_diff.rs b/crates/git_ui/src/project_diff.rs index f40d70da6494cf8491c1d3d7909a288e5f99023c..3f689567327e280f7e9911699e10159340ddb8d5 100644 --- a/crates/git_ui/src/project_diff.rs +++ b/crates/git_ui/src/project_diff.rs @@ -74,6 +74,13 @@ pub struct ProjectDiff { _subscription: Subscription, } +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum RefreshReason { + DiffChanged, + StatusesChanged, + EditorSaved, +} + const CONFLICT_SORT_PREFIX: u64 = 1; const TRACKED_SORT_PREFIX: u64 = 2; const NEW_SORT_PREFIX: u64 = 3; @@ -278,7 +285,7 @@ impl ProjectDiff { BranchDiffEvent::FileListChanged => { this._task = window.spawn(cx, { let this = cx.weak_entity(); - async |cx| Self::refresh(this, cx).await + async |cx| Self::refresh(this, RefreshReason::StatusesChanged, cx).await }) } }, @@ -297,7 +304,7 @@ impl ProjectDiff { this._task = { window.spawn(cx, { let this = cx.weak_entity(); - async |cx| Self::refresh(this, cx).await + async |cx| Self::refresh(this, RefreshReason::StatusesChanged, cx).await }) } } @@ -308,7 +315,7 @@ impl ProjectDiff { let task = window.spawn(cx, { let this = cx.weak_entity(); - async |cx| Self::refresh(this, cx).await + async |cx| Self::refresh(this, RefreshReason::StatusesChanged, cx).await }); Self { @@ -448,19 +455,27 @@ impl ProjectDiff { window: &mut Window, cx: &mut Context, ) { - if let EditorEvent::SelectionsChanged { local: true } = event { - let Some(project_path) = self.active_path(cx) else { - return; - }; - self.workspace - .update(cx, |workspace, cx| { - if let Some(git_panel) = workspace.panel::(cx) { - git_panel.update(cx, |git_panel, cx| { - git_panel.select_entry_by_path(project_path, window, cx) - }) - } - }) - .ok(); + match event { + EditorEvent::SelectionsChanged { local: true } => { + let Some(project_path) = self.active_path(cx) else { + return; + }; + self.workspace + .update(cx, |workspace, cx| { + if let Some(git_panel) = workspace.panel::(cx) { + git_panel.update(cx, |git_panel, cx| { + git_panel.select_entry_by_path(project_path, window, cx) + }) + } + }) + .ok(); + } + EditorEvent::Saved => { + self._task = cx.spawn_in(window, async move |this, cx| { + Self::refresh(this, RefreshReason::EditorSaved, cx).await + }); + } + _ => {} } if editor.focus_handle(cx).contains_focused(window, cx) && self.multibuffer.read(cx).is_empty() @@ -482,7 +497,7 @@ impl ProjectDiff { let subscription = cx.subscribe_in(&diff, window, move |this, _, _, window, cx| { this._task = window.spawn(cx, { let this = cx.weak_entity(); - async |cx| Self::refresh(this, cx).await + async |cx| Self::refresh(this, RefreshReason::DiffChanged, cx).await }) }); self.buffer_diff_subscriptions @@ -581,14 +596,23 @@ impl ProjectDiff { } } - pub async fn refresh(this: WeakEntity, cx: &mut AsyncWindowContext) -> Result<()> { + pub async fn refresh( + this: WeakEntity, + reason: RefreshReason, + cx: &mut AsyncWindowContext, + ) -> Result<()> { let mut path_keys = Vec::new(); let buffers_to_load = this.update(cx, |this, cx| { let (repo, buffers_to_load) = this.branch_diff.update(cx, |branch_diff, cx| { let load_buffers = branch_diff.load_buffers(cx); (branch_diff.repo().cloned(), load_buffers) }); - let mut previous_paths = this.multibuffer.read(cx).paths().collect::>(); + let mut previous_paths = this + .multibuffer + .read(cx) + .paths() + .cloned() + .collect::>(); if let Some(repo) = repo { let repo = repo.read(cx); @@ -605,8 +629,20 @@ impl ProjectDiff { this.multibuffer.update(cx, |multibuffer, cx| { for path in previous_paths { + if let Some(buffer) = multibuffer.buffer_for_path(&path, cx) { + let skip = match reason { + RefreshReason::DiffChanged | RefreshReason::EditorSaved => { + buffer.read(cx).is_dirty() + } + RefreshReason::StatusesChanged => false, + }; + if skip { + continue; + } + } + this.buffer_diff_subscriptions.remove(&path.path); - multibuffer.remove_excerpts_for_path(path, cx); + multibuffer.remove_excerpts_for_path(path.clone(), cx); } }); buffers_to_load @@ -619,7 +655,27 @@ impl ProjectDiff { yield_now().await; cx.update(|window, cx| { this.update(cx, |this, cx| { - this.register_buffer(path_key, entry.file_status, buffer, diff, window, cx) + let multibuffer = this.multibuffer.read(cx); + let skip = multibuffer.buffer(buffer.read(cx).remote_id()).is_some() + && multibuffer + .diff_for(buffer.read(cx).remote_id()) + .is_some_and(|prev_diff| prev_diff.entity_id() == diff.entity_id()) + && match reason { + RefreshReason::DiffChanged | RefreshReason::EditorSaved => { + buffer.read(cx).is_dirty() + } + RefreshReason::StatusesChanged => false, + }; + if !skip { + this.register_buffer( + path_key, + entry.file_status, + buffer, + diff, + window, + cx, + ) + } }) .ok(); })?; @@ -637,7 +693,7 @@ impl ProjectDiff { pub fn excerpt_paths(&self, cx: &App) -> Vec> { self.multibuffer .read(cx) - .excerpt_paths() + .paths() .map(|key| key.path.clone()) .collect() } @@ -1650,9 +1706,13 @@ mod tests { .unindent(), ); - editor.update_in(cx, |editor, window, cx| { - editor.git_restore(&Default::default(), window, cx); - }); + editor + .update_in(cx, |editor, window, cx| { + editor.git_restore(&Default::default(), window, cx); + editor.save(SaveOptions::default(), project.clone(), window, cx) + }) + .await + .unwrap(); cx.run_until_parked(); assert_state_with_diff(&editor, cx, &"ˇ".unindent()); @@ -1841,8 +1901,8 @@ mod tests { cx, &" - original - + ˇdifferent - " + + different + ˇ" .unindent(), ); } diff --git a/crates/multi_buffer/src/path_key.rs b/crates/multi_buffer/src/path_key.rs index 119194d088c946941b13ffab3f6f2b3ea126cd09..10d4088fd4bc28449c8a4ee74095ad31a45fbcf3 100644 --- a/crates/multi_buffer/src/path_key.rs +++ b/crates/multi_buffer/src/path_key.rs @@ -43,8 +43,8 @@ impl PathKey { } impl MultiBuffer { - pub fn paths(&self) -> impl Iterator + '_ { - self.excerpts_by_path.keys().cloned() + pub fn paths(&self) -> impl Iterator + '_ { + self.excerpts_by_path.keys() } pub fn remove_excerpts_for_path(&mut self, path: PathKey, cx: &mut Context) { @@ -58,15 +58,18 @@ impl MultiBuffer { } } - pub fn location_for_path(&self, path: &PathKey, cx: &App) -> Option { + pub fn buffer_for_path(&self, path: &PathKey, cx: &App) -> Option> { let excerpt_id = self.excerpts_by_path.get(path)?.first()?; let snapshot = self.read(cx); let excerpt = snapshot.excerpt(*excerpt_id)?; - Some(Anchor::in_buffer(excerpt.id, excerpt.range.context.start)) + self.buffer(excerpt.buffer_id) } - pub fn excerpt_paths(&self) -> impl Iterator { - self.excerpts_by_path.keys() + pub fn location_for_path(&self, path: &PathKey, cx: &App) -> Option { + let excerpt_id = self.excerpts_by_path.get(path)?.first()?; + let snapshot = self.read(cx); + let excerpt = snapshot.excerpt(*excerpt_id)?; + Some(Anchor::in_buffer(excerpt.id, excerpt.range.context.start)) } /// Sets excerpts, returns `true` if at least one new excerpt was added. From d7da5d3efdd2283cb70035e2e6c0a40d8cf02a0b Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Sun, 14 Dec 2025 20:07:44 -0800 Subject: [PATCH 259/621] Finish inline telemetry changes (#44842) Closes #ISSUE Release Notes: - N/A --- Cargo.lock | 4 +- crates/agent_ui/Cargo.toml | 1 - crates/agent_ui/src/agent_ui.rs | 11 +- crates/agent_ui/src/buffer_codegen.rs | 148 +++++----- crates/agent_ui/src/inline_assistant.rs | 125 ++++---- crates/agent_ui/src/inline_prompt_editor.rs | 276 ++++++++++-------- crates/agent_ui/src/terminal_codegen.rs | 66 +++-- .../agent_ui/src/terminal_inline_assistant.rs | 83 +++--- crates/agent_ui/src/text_thread_editor.rs | 1 - crates/assistant_text_thread/Cargo.toml | 2 +- .../src/assistant_text_thread_tests.rs | 9 - .../assistant_text_thread/src/text_thread.rs | 52 ++-- .../src/text_thread_store.rs | 14 +- crates/language_model/Cargo.toml | 1 - crates/language_model/src/telemetry.rs | 124 +++++--- crates/settings_ui/src/settings_ui.rs | 7 - 16 files changed, 499 insertions(+), 425 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e465ff483bcb6cc9528403bbb8f3bd883a6af871..436da4aef8c0849a61336a9645639c17da731029 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -388,7 +388,6 @@ dependencies = [ "streaming_diff", "task", "telemetry", - "telemetry_events", "terminal", "terminal_view", "text", @@ -894,7 +893,7 @@ dependencies = [ "settings", "smallvec", "smol", - "telemetry_events", + "telemetry", "text", "ui", "unindent", @@ -8817,7 +8816,6 @@ dependencies = [ "serde_json", "settings", "smol", - "telemetry_events", "thiserror 2.0.17", "util", "zed_env_vars", diff --git a/crates/agent_ui/Cargo.toml b/crates/agent_ui/Cargo.toml index 2af0ce6fbd2b636d19d9cb8e544851514800313c..b235799635ce81b02fd6fcd5d4d7a53a6957eb77 100644 --- a/crates/agent_ui/Cargo.toml +++ b/crates/agent_ui/Cargo.toml @@ -84,7 +84,6 @@ smol.workspace = true streaming_diff.workspace = true task.workspace = true telemetry.workspace = true -telemetry_events.workspace = true terminal.workspace = true terminal_view.workspace = true text.workspace = true diff --git a/crates/agent_ui/src/agent_ui.rs b/crates/agent_ui/src/agent_ui.rs index eb7785fad59894012251c84319af7fca306f2882..cd6113bfa6c611c8d2a6b9d43294e77737b7a9ae 100644 --- a/crates/agent_ui/src/agent_ui.rs +++ b/crates/agent_ui/src/agent_ui.rs @@ -216,7 +216,7 @@ pub fn init( is_eval: bool, cx: &mut App, ) { - assistant_text_thread::init(client.clone(), cx); + assistant_text_thread::init(client, cx); rules_library::init(cx); if !is_eval { // Initializing the language model from the user settings messes with the eval, so we only initialize them when @@ -229,13 +229,8 @@ pub fn init( TextThreadEditor::init(cx); register_slash_commands(cx); - inline_assistant::init( - fs.clone(), - prompt_builder.clone(), - client.telemetry().clone(), - cx, - ); - terminal_inline_assistant::init(fs.clone(), prompt_builder, client.telemetry().clone(), cx); + inline_assistant::init(fs.clone(), prompt_builder.clone(), cx); + terminal_inline_assistant::init(fs.clone(), prompt_builder, cx); cx.observe_new(move |workspace, window, cx| { ConfigureContextServerModal::register(workspace, language_registry.clone(), window, cx) }) diff --git a/crates/agent_ui/src/buffer_codegen.rs b/crates/agent_ui/src/buffer_codegen.rs index e2c67a04167d7080a6f94b9ee2a8fae516d487d7..bb05d5e04deb06f82dfc8e5dae0d871648f1d11e 100644 --- a/crates/agent_ui/src/buffer_codegen.rs +++ b/crates/agent_ui/src/buffer_codegen.rs @@ -1,8 +1,8 @@ use crate::{context::LoadedContext, inline_prompt_editor::CodegenStatus}; use agent_settings::AgentSettings; use anyhow::{Context as _, Result}; +use uuid::Uuid; -use client::telemetry::Telemetry; use cloud_llm_client::CompletionIntent; use collections::HashSet; use editor::{Anchor, AnchorRangeExt, MultiBuffer, MultiBufferSnapshot, ToOffset as _, ToPoint}; @@ -15,12 +15,12 @@ use futures::{ stream::BoxStream, }; use gpui::{App, AppContext as _, AsyncApp, Context, Entity, EventEmitter, Subscription, Task}; -use language::{Buffer, IndentKind, Point, TransactionId, line_diff}; +use language::{Buffer, IndentKind, LanguageName, Point, TransactionId, line_diff}; use language_model::{ LanguageModel, LanguageModelCompletionError, LanguageModelCompletionEvent, LanguageModelRegistry, LanguageModelRequest, LanguageModelRequestMessage, LanguageModelRequestTool, LanguageModelTextStream, LanguageModelToolChoice, - LanguageModelToolUse, Role, TokenUsage, report_assistant_event, + LanguageModelToolUse, Role, TokenUsage, }; use multi_buffer::MultiBufferRow; use parking_lot::Mutex; @@ -41,7 +41,6 @@ use std::{ time::Instant, }; use streaming_diff::{CharOperation, LineDiff, LineOperation, StreamingDiff}; -use telemetry_events::{AssistantEventData, AssistantKind, AssistantPhase}; use ui::SharedString; /// Use this tool to provide a message to the user when you're unable to complete a task. @@ -77,9 +76,9 @@ pub struct BufferCodegen { buffer: Entity, range: Range, initial_transaction_id: Option, - telemetry: Arc, builder: Arc, pub is_insertion: bool, + session_id: Uuid, } impl BufferCodegen { @@ -87,7 +86,7 @@ impl BufferCodegen { buffer: Entity, range: Range, initial_transaction_id: Option, - telemetry: Arc, + session_id: Uuid, builder: Arc, cx: &mut Context, ) -> Self { @@ -96,8 +95,8 @@ impl BufferCodegen { buffer.clone(), range.clone(), false, - Some(telemetry.clone()), builder.clone(), + session_id, cx, ) }); @@ -110,8 +109,8 @@ impl BufferCodegen { buffer, range, initial_transaction_id, - telemetry, builder, + session_id, }; this.activate(0, cx); this @@ -134,6 +133,10 @@ impl BufferCodegen { &self.alternatives[self.active_alternative] } + pub fn language_name(&self, cx: &App) -> Option { + self.active_alternative().read(cx).language_name(cx) + } + pub fn status<'a>(&self, cx: &'a App) -> &'a CodegenStatus { &self.active_alternative().read(cx).status } @@ -192,8 +195,8 @@ impl BufferCodegen { self.buffer.clone(), self.range.clone(), false, - Some(self.telemetry.clone()), self.builder.clone(), + self.session_id, cx, ) })); @@ -256,6 +259,10 @@ impl BufferCodegen { pub fn selected_text<'a>(&self, cx: &'a App) -> Option<&'a str> { self.active_alternative().read(cx).selected_text() } + + pub fn session_id(&self) -> Uuid { + self.session_id + } } impl EventEmitter for BufferCodegen {} @@ -271,7 +278,6 @@ pub struct CodegenAlternative { status: CodegenStatus, generation: Task<()>, diff: Diff, - telemetry: Option>, _subscription: gpui::Subscription, builder: Arc, active: bool, @@ -282,6 +288,7 @@ pub struct CodegenAlternative { selected_text: Option, pub message_id: Option, pub model_explanation: Option, + session_id: Uuid, } impl EventEmitter for CodegenAlternative {} @@ -291,8 +298,8 @@ impl CodegenAlternative { buffer: Entity, range: Range, active: bool, - telemetry: Option>, builder: Arc, + session_id: Uuid, cx: &mut Context, ) -> Self { let snapshot = buffer.read(cx).snapshot(cx); @@ -331,7 +338,6 @@ impl CodegenAlternative { status: CodegenStatus::Idle, generation: Task::ready(()), diff: Diff::default(), - telemetry, builder, active: active, edits: Vec::new(), @@ -341,10 +347,18 @@ impl CodegenAlternative { completion: None, selected_text: None, model_explanation: None, + session_id, _subscription: cx.subscribe(&buffer, Self::handle_buffer_event), } } + pub fn language_name(&self, cx: &App) -> Option { + self.old_buffer + .read(cx) + .language() + .map(|language| language.name()) + } + pub fn set_active(&mut self, active: bool, cx: &mut Context) { if active != self.active { self.active = active; @@ -407,34 +421,28 @@ impl CodegenAlternative { self.edit_position = Some(self.range.start.bias_right(&self.snapshot)); - let api_key = model.api_key(cx); - let telemetry_id = model.telemetry_id(); - let provider_id = model.provider_id(); - if Self::use_streaming_tools(model.as_ref(), cx) { let request = self.build_request(&model, user_prompt, context_task, cx)?; - let completion_events = - cx.spawn(async move |_, cx| model.stream_completion(request.await, cx).await); - self.generation = self.handle_completion( - telemetry_id, - provider_id.to_string(), - api_key, - completion_events, - cx, - ); + let completion_events = cx.spawn({ + let model = model.clone(); + async move |_, cx| model.stream_completion(request.await, cx).await + }); + self.generation = self.handle_completion(model, completion_events, cx); } else { let stream: LocalBoxFuture> = if user_prompt.trim().to_lowercase() == "delete" { async { Ok(LanguageModelTextStream::default()) }.boxed_local() } else { let request = self.build_request(&model, user_prompt, context_task, cx)?; - cx.spawn(async move |_, cx| { - Ok(model.stream_completion_text(request.await, cx).await?) + cx.spawn({ + let model = model.clone(); + async move |_, cx| { + Ok(model.stream_completion_text(request.await, cx).await?) + } }) .boxed_local() }; - self.generation = - self.handle_stream(telemetry_id, provider_id.to_string(), api_key, stream, cx); + self.generation = self.handle_stream(model, stream, cx); } Ok(()) @@ -621,12 +629,14 @@ impl CodegenAlternative { pub fn handle_stream( &mut self, - model_telemetry_id: String, - model_provider_id: String, - model_api_key: Option, + model: Arc, stream: impl 'static + Future>, cx: &mut Context, ) -> Task<()> { + let anthropic_reporter = language_model::AnthropicEventReporter::new(&model, cx); + let session_id = self.session_id; + let model_telemetry_id = model.telemetry_id(); + let model_provider_id = model.provider_id().to_string(); let start_time = Instant::now(); // Make a new snapshot and re-resolve anchor in case the document was modified. @@ -664,8 +674,6 @@ impl CodegenAlternative { } } - let http_client = cx.http_client(); - let telemetry = self.telemetry.clone(); let language_name = { let multibuffer = self.buffer.read(cx); let snapshot = multibuffer.snapshot(cx); @@ -698,10 +706,11 @@ impl CodegenAlternative { let model_telemetry_id = model_telemetry_id.clone(); let model_provider_id = model_provider_id.clone(); let (mut diff_tx, mut diff_rx) = mpsc::channel(1); - let executor = cx.background_executor().clone(); let message_id = message_id.clone(); - let line_based_stream_diff: Task> = - cx.background_spawn(async move { + let line_based_stream_diff: Task> = cx.background_spawn({ + let anthropic_reporter = anthropic_reporter.clone(); + let language_name = language_name.clone(); + async move { let mut response_latency = None; let request_start = Instant::now(); let diff = async { @@ -798,27 +807,30 @@ impl CodegenAlternative { let result = diff.await; let error_message = result.as_ref().err().map(|error| error.to_string()); - report_assistant_event( - AssistantEventData { - conversation_id: None, - message_id, - kind: AssistantKind::Inline, - phase: AssistantPhase::Response, - model: model_telemetry_id, - model_provider: model_provider_id, - response_latency, - error_message, - language_name: language_name.map(|name| name.to_proto()), - }, - telemetry, - http_client, - model_api_key, - &executor, + telemetry::event!( + "Assistant Responded", + kind = "inline", + phase = "response", + session_id = session_id.to_string(), + model = model_telemetry_id, + model_provider = model_provider_id, + language_name = language_name.as_ref().map(|n| n.to_string()), + message_id = message_id.as_deref(), + response_latency = response_latency, + error_message = error_message.as_deref(), ); + anthropic_reporter.report(language_model::AnthropicEventData { + completion_type: language_model::AnthropicCompletionType::Editor, + event: language_model::AnthropicEventType::Response, + language_name: language_name.map(|n| n.to_string()), + message_id, + }); + result?; Ok(()) - }); + } + }); while let Some((char_ops, line_ops)) = diff_rx.next().await { codegen.update(cx, |codegen, cx| { @@ -1086,9 +1098,7 @@ impl CodegenAlternative { fn handle_completion( &mut self, - telemetry_id: String, - provider_id: String, - api_key: Option, + model: Arc, completion_stream: Task< Result< BoxStream< @@ -1270,13 +1280,7 @@ impl CodegenAlternative { let Some(task) = codegen .update(cx, move |codegen, cx| { - codegen.handle_stream( - telemetry_id, - provider_id, - api_key, - async { Ok(language_model_text_stream) }, - cx, - ) + codegen.handle_stream(model, async { Ok(language_model_text_stream) }, cx) }) .ok() else { @@ -1448,6 +1452,7 @@ mod tests { use gpui::TestAppContext; use indoc::indoc; use language::{Buffer, Point}; + use language_model::fake_provider::FakeLanguageModel; use language_model::{LanguageModelRegistry, TokenUsage}; use languages::rust_lang; use rand::prelude::*; @@ -1478,8 +1483,8 @@ mod tests { buffer.clone(), range.clone(), true, - None, prompt_builder, + Uuid::new_v4(), cx, ) }); @@ -1540,8 +1545,8 @@ mod tests { buffer.clone(), range.clone(), true, - None, prompt_builder, + Uuid::new_v4(), cx, ) }); @@ -1604,8 +1609,8 @@ mod tests { buffer.clone(), range.clone(), true, - None, prompt_builder, + Uuid::new_v4(), cx, ) }); @@ -1668,8 +1673,8 @@ mod tests { buffer.clone(), range.clone(), true, - None, prompt_builder, + Uuid::new_v4(), cx, ) }); @@ -1720,8 +1725,8 @@ mod tests { buffer.clone(), range.clone(), false, - None, prompt_builder, + Uuid::new_v4(), cx, ) }); @@ -1810,11 +1815,10 @@ mod tests { cx: &mut TestAppContext, ) -> mpsc::UnboundedSender { let (chunks_tx, chunks_rx) = mpsc::unbounded(); + let model = Arc::new(FakeLanguageModel::default()); codegen.update(cx, |codegen, cx| { codegen.generation = codegen.handle_stream( - String::new(), - String::new(), - None, + model, future::ready(Ok(LanguageModelTextStream { message_id: None, stream: chunks_rx.map(Ok).boxed(), diff --git a/crates/agent_ui/src/inline_assistant.rs b/crates/agent_ui/src/inline_assistant.rs index ad0f58c162ca720e619e83ca9a3eb65a4be9fe2b..0eb96b3712623cc08632ede6c7836ed09499c02d 100644 --- a/crates/agent_ui/src/inline_assistant.rs +++ b/crates/agent_ui/src/inline_assistant.rs @@ -1,8 +1,11 @@ +use language_model::AnthropicEventData; +use language_model::report_anthropic_event; use std::cmp; use std::mem; use std::ops::Range; use std::rc::Rc; use std::sync::Arc; +use uuid::Uuid; use crate::context::load_context; use crate::mention_set::MentionSet; @@ -15,7 +18,6 @@ use crate::{ use agent::HistoryStore; use agent_settings::AgentSettings; use anyhow::{Context as _, Result}; -use client::telemetry::Telemetry; use collections::{HashMap, HashSet, VecDeque, hash_map}; use editor::EditorSnapshot; use editor::MultiBufferOffset; @@ -38,15 +40,13 @@ use gpui::{ WeakEntity, Window, point, }; use language::{Buffer, Point, Selection, TransactionId}; -use language_model::{ - ConfigurationError, ConfiguredModel, LanguageModelRegistry, report_assistant_event, -}; +use language_model::{ConfigurationError, ConfiguredModel, LanguageModelRegistry}; use multi_buffer::MultiBufferRow; use parking_lot::Mutex; use project::{CodeAction, DisableAiSettings, LspAction, Project, ProjectTransaction}; use prompt_store::{PromptBuilder, PromptStore}; use settings::{Settings, SettingsStore}; -use telemetry_events::{AssistantEventData, AssistantKind, AssistantPhase}; + use terminal_view::{TerminalView, terminal_panel::TerminalPanel}; use text::{OffsetRangeExt, ToPoint as _}; use ui::prelude::*; @@ -54,13 +54,8 @@ use util::{RangeExt, ResultExt, maybe}; use workspace::{ItemHandle, Toast, Workspace, dock::Panel, notifications::NotificationId}; use zed_actions::agent::OpenSettings; -pub fn init( - fs: Arc, - prompt_builder: Arc, - telemetry: Arc, - cx: &mut App, -) { - cx.set_global(InlineAssistant::new(fs, prompt_builder, telemetry)); +pub fn init(fs: Arc, prompt_builder: Arc, cx: &mut App) { + cx.set_global(InlineAssistant::new(fs, prompt_builder)); cx.observe_global::(|cx| { if DisableAiSettings::get_global(cx).disable_ai { @@ -100,7 +95,6 @@ pub struct InlineAssistant { confirmed_assists: HashMap>, prompt_history: VecDeque, prompt_builder: Arc, - telemetry: Arc, fs: Arc, _inline_assistant_completions: Option>>, } @@ -108,11 +102,7 @@ pub struct InlineAssistant { impl Global for InlineAssistant {} impl InlineAssistant { - pub fn new( - fs: Arc, - prompt_builder: Arc, - telemetry: Arc, - ) -> Self { + pub fn new(fs: Arc, prompt_builder: Arc) -> Self { Self { next_assist_id: InlineAssistId::default(), next_assist_group_id: InlineAssistGroupId::default(), @@ -122,7 +112,6 @@ impl InlineAssistant { confirmed_assists: HashMap::default(), prompt_history: VecDeque::default(), prompt_builder, - telemetry, fs, _inline_assistant_completions: None, } @@ -457,17 +446,25 @@ impl InlineAssistant { codegen_ranges.push(anchor_range); if let Some(model) = LanguageModelRegistry::read_global(cx).inline_assistant_model() { - self.telemetry.report_assistant_event(AssistantEventData { - conversation_id: None, - kind: AssistantKind::Inline, - phase: AssistantPhase::Invoked, - message_id: None, - model: model.model.telemetry_id(), - model_provider: model.provider.id().to_string(), - response_latency: None, - error_message: None, - language_name: buffer.language().map(|language| language.name().to_proto()), - }); + telemetry::event!( + "Assistant Invoked", + kind = "inline", + phase = "invoked", + model = model.model.telemetry_id(), + model_provider = model.provider.id().to_string(), + language_name = buffer.language().map(|language| language.name().to_proto()) + ); + + report_anthropic_event( + &model.model, + AnthropicEventData { + completion_type: language_model::AnthropicCompletionType::Editor, + event: language_model::AnthropicEventType::Invoked, + language_name: buffer.language().map(|language| language.name().to_proto()), + message_id: None, + }, + cx, + ); } } @@ -491,6 +488,7 @@ impl InlineAssistant { let snapshot = editor.update(cx, |editor, cx| editor.snapshot(window, cx)); let assist_group_id = self.next_assist_group_id.post_inc(); + let session_id = Uuid::new_v4(); let prompt_buffer = cx.new(|cx| { MultiBuffer::singleton( cx.new(|cx| Buffer::local(initial_prompt.unwrap_or_default(), cx)), @@ -508,7 +506,7 @@ impl InlineAssistant { editor.read(cx).buffer().clone(), range.clone(), initial_transaction_id, - self.telemetry.clone(), + session_id, self.prompt_builder.clone(), cx, ) @@ -522,6 +520,7 @@ impl InlineAssistant { self.prompt_history.clone(), prompt_buffer.clone(), codegen.clone(), + session_id, self.fs.clone(), thread_store.clone(), prompt_store.clone(), @@ -1069,8 +1068,6 @@ impl InlineAssistant { } let active_alternative = assist.codegen.read(cx).active_alternative().clone(); - let message_id = active_alternative.read(cx).message_id.clone(); - if let Some(model) = LanguageModelRegistry::read_global(cx).inline_assistant_model() { let language_name = assist.editor.upgrade().and_then(|editor| { let multibuffer = editor.read(cx).buffer().read(cx); @@ -1079,28 +1076,49 @@ impl InlineAssistant { ranges .first() .and_then(|(buffer, _, _)| buffer.language()) - .map(|language| language.name()) + .map(|language| language.name().0.to_string()) }); - report_assistant_event( - AssistantEventData { - conversation_id: None, - kind: AssistantKind::Inline, + + let codegen = assist.codegen.read(cx); + let session_id = codegen.session_id(); + let message_id = active_alternative.read(cx).message_id.clone(); + let model_telemetry_id = model.model.telemetry_id(); + let model_provider_id = model.model.provider_id().to_string(); + + let (phase, event_type, anthropic_event_type) = if undo { + ( + "rejected", + "Assistant Response Rejected", + language_model::AnthropicEventType::Reject, + ) + } else { + ( + "accepted", + "Assistant Response Accepted", + language_model::AnthropicEventType::Accept, + ) + }; + + telemetry::event!( + event_type, + phase, + session_id = session_id.to_string(), + kind = "inline", + model = model_telemetry_id, + model_provider = model_provider_id, + language_name = language_name, + message_id = message_id.as_deref(), + ); + + report_anthropic_event( + &model.model, + language_model::AnthropicEventData { + completion_type: language_model::AnthropicCompletionType::Editor, + event: anthropic_event_type, + language_name, message_id, - phase: if undo { - AssistantPhase::Rejected - } else { - AssistantPhase::Accepted - }, - model: model.model.telemetry_id(), - model_provider: model.model.provider_id().to_string(), - response_latency: None, - error_message: None, - language_name: language_name.map(|name| name.to_proto()), }, - Some(self.telemetry.clone()), - cx.http_client(), - model.model.api_key(cx), - cx.background_executor(), + cx, ); } @@ -2036,8 +2054,7 @@ pub mod test { cx.set_http_client(http); Client::production(cx) }); - let mut inline_assistant = - InlineAssistant::new(fs.clone(), prompt_builder, client.telemetry().clone()); + let mut inline_assistant = InlineAssistant::new(fs.clone(), prompt_builder); let (tx, mut completion_rx) = mpsc::unbounded(); inline_assistant.set_completion_receiver(tx); diff --git a/crates/agent_ui/src/inline_prompt_editor.rs b/crates/agent_ui/src/inline_prompt_editor.rs index 4856d4024c94856e8dee91c048fe6ce72e79a7b8..e262cda87899b0314c9fd8909f5718b4fd7dbfda 100644 --- a/crates/agent_ui/src/inline_prompt_editor.rs +++ b/crates/agent_ui/src/inline_prompt_editor.rs @@ -8,7 +8,7 @@ use editor::{ ContextMenuOptions, Editor, EditorElement, EditorEvent, EditorMode, EditorStyle, MultiBuffer, actions::{MoveDown, MoveUp}, }; -use feature_flags::{FeatureFlag, FeatureFlagAppExt}; +use feature_flags::{FeatureFlagAppExt, InlineAssistantUseToolFeatureFlag}; use fs::Fs; use gpui::{ AnyElement, App, ClipboardItem, Context, Entity, EventEmitter, FocusHandle, Focusable, @@ -20,10 +20,10 @@ use parking_lot::Mutex; use project::Project; use prompt_store::PromptStore; use settings::Settings; +use std::cmp; use std::ops::Range; use std::rc::Rc; use std::sync::Arc; -use std::{cmp, mem}; use theme::ThemeSettings; use ui::utils::WithRemSize; use ui::{IconButtonShape, KeyBinding, PopoverMenuHandle, Tooltip, prelude::*}; @@ -44,54 +44,15 @@ use crate::{CycleNextInlineAssist, CyclePreviousInlineAssist, ModelUsageContext} actions!(inline_assistant, [ThumbsUpResult, ThumbsDownResult]); -pub struct InlineAssistRatingFeatureFlag; - -impl FeatureFlag for InlineAssistRatingFeatureFlag { - const NAME: &'static str = "inline-assist-rating"; - - fn enabled_for_staff() -> bool { - false - } -} - -enum RatingState { +enum CompletionState { Pending, - GeneratedCompletion(Option), - Rated(Uuid), + Generated { completion_text: Option }, + Rated, } -impl RatingState { - fn is_pending(&self) -> bool { - matches!(self, RatingState::Pending) - } - - fn rating_id(&self) -> Option { - match self { - RatingState::Pending => None, - RatingState::GeneratedCompletion(_) => None, - RatingState::Rated(id) => Some(*id), - } - } - - fn rate(&mut self) -> (Uuid, Option) { - let id = Uuid::new_v4(); - let old_state = mem::replace(self, RatingState::Rated(id)); - let completion = match old_state { - RatingState::Pending => None, - RatingState::GeneratedCompletion(completion) => completion, - RatingState::Rated(_) => None, - }; - - (id, completion) - } - - fn reset(&mut self) { - *self = RatingState::Pending; - } - - fn generated_completion(&mut self, generated_completion: Option) { - *self = RatingState::GeneratedCompletion(generated_completion); - } +struct SessionState { + session_id: Uuid, + completion: CompletionState, } pub struct PromptEditor { @@ -109,7 +70,7 @@ pub struct PromptEditor { _codegen_subscription: Subscription, editor_subscriptions: Vec, show_rate_limit_notice: bool, - rated: RatingState, + session_state: SessionState, _phantom: std::marker::PhantomData, } @@ -487,7 +448,7 @@ impl PromptEditor { } self.edited_since_done = true; - self.rated.reset(); + self.session_state.completion = CompletionState::Pending; cx.notify(); } EditorEvent::Blurred => { @@ -559,109 +520,165 @@ impl PromptEditor { fn confirm(&mut self, _: &menu::Confirm, _window: &mut Window, cx: &mut Context) { match self.codegen_status(cx) { CodegenStatus::Idle => { + self.fire_started_telemetry(cx); cx.emit(PromptEditorEvent::StartRequested); } CodegenStatus::Pending => {} CodegenStatus::Done => { if self.edited_since_done { + self.fire_started_telemetry(cx); cx.emit(PromptEditorEvent::StartRequested); } else { cx.emit(PromptEditorEvent::ConfirmRequested { execute: false }); } } CodegenStatus::Error(_) => { + self.fire_started_telemetry(cx); cx.emit(PromptEditorEvent::StartRequested); } } } - fn thumbs_up(&mut self, _: &ThumbsUpResult, _window: &mut Window, cx: &mut Context) { - if self.rated.is_pending() { - self.toast("Still generating...", None, cx); + fn fire_started_telemetry(&self, cx: &Context) { + let Some(model) = LanguageModelRegistry::read_global(cx).inline_assistant_model() else { return; - } - - if let Some(rating_id) = self.rated.rating_id() { - self.toast("Already rated this completion", Some(rating_id), cx); - return; - } + }; - let (rating_id, completion) = self.rated.rate(); + let model_telemetry_id = model.model.telemetry_id(); + let model_provider_id = model.provider.id().to_string(); - let selected_text = match &self.mode { + let (kind, language_name) = match &self.mode { PromptEditorMode::Buffer { codegen, .. } => { - codegen.read(cx).selected_text(cx).map(|s| s.to_string()) + let codegen = codegen.read(cx); + ( + "inline", + codegen.language_name(cx).map(|name| name.to_string()), + ) } - PromptEditorMode::Terminal { .. } => None, + PromptEditorMode::Terminal { .. } => ("inline_terminal", None), }; - let model_info = self.model_selector.read(cx).active_model(cx); - let model_id = { - let Some(configured_model) = model_info else { - self.toast("No configured model", None, cx); - return; - }; + telemetry::event!( + "Assistant Started", + session_id = self.session_state.session_id.to_string(), + kind = kind, + phase = "started", + model = model_telemetry_id, + model_provider = model_provider_id, + language_name = language_name, + ); + } - configured_model.model.telemetry_id() - }; + fn thumbs_up(&mut self, _: &ThumbsUpResult, _window: &mut Window, cx: &mut Context) { + match &self.session_state.completion { + CompletionState::Pending => { + self.toast("Can't rate, still generating...", None, cx); + return; + } + CompletionState::Rated => { + self.toast( + "Already rated this completion", + Some(self.session_state.session_id), + cx, + ); + return; + } + CompletionState::Generated { completion_text } => { + let model_info = self.model_selector.read(cx).active_model(cx); + let model_id = { + let Some(configured_model) = model_info else { + self.toast("No configured model", None, cx); + return; + }; + configured_model.model.telemetry_id() + }; - let prompt = self.editor.read(cx).text(cx); + let selected_text = match &self.mode { + PromptEditorMode::Buffer { codegen, .. } => { + codegen.read(cx).selected_text(cx).map(|s| s.to_string()) + } + PromptEditorMode::Terminal { .. } => None, + }; - telemetry::event!( - "Inline Assistant Rated", - rating = "positive", - model = model_id, - prompt = prompt, - completion = completion, - selected_text = selected_text, - rating_id = rating_id.to_string() - ); + let prompt = self.editor.read(cx).text(cx); - cx.notify(); - } + let kind = match &self.mode { + PromptEditorMode::Buffer { .. } => "inline", + PromptEditorMode::Terminal { .. } => "inline_terminal", + }; - fn thumbs_down(&mut self, _: &ThumbsDownResult, _window: &mut Window, cx: &mut Context) { - if self.rated.is_pending() { - self.toast("Still generating...", None, cx); - return; - } - if let Some(rating_id) = self.rated.rating_id() { - self.toast("Already rated this completion", Some(rating_id), cx); - return; - } + telemetry::event!( + "Inline Assistant Rated", + rating = "positive", + session_id = self.session_state.session_id.to_string(), + kind = kind, + model = model_id, + prompt = prompt, + completion = completion_text, + selected_text = selected_text, + ); - let (rating_id, completion) = self.rated.rate(); + self.session_state.completion = CompletionState::Rated; - let selected_text = match &self.mode { - PromptEditorMode::Buffer { codegen, .. } => { - codegen.read(cx).selected_text(cx).map(|s| s.to_string()) + cx.notify(); } - PromptEditorMode::Terminal { .. } => None, - }; + } + } - let model_info = self.model_selector.read(cx).active_model(cx); - let model_telemetry_id = { - let Some(configured_model) = model_info else { - self.toast("No configured model", None, cx); + fn thumbs_down(&mut self, _: &ThumbsDownResult, _window: &mut Window, cx: &mut Context) { + match &self.session_state.completion { + CompletionState::Pending => { + self.toast("Can't rate, still generating...", None, cx); return; - }; + } + CompletionState::Rated => { + self.toast( + "Already rated this completion", + Some(self.session_state.session_id), + cx, + ); + return; + } + CompletionState::Generated { completion_text } => { + let model_info = self.model_selector.read(cx).active_model(cx); + let model_telemetry_id = { + let Some(configured_model) = model_info else { + self.toast("No configured model", None, cx); + return; + }; + configured_model.model.telemetry_id() + }; - configured_model.model.telemetry_id() - }; + let selected_text = match &self.mode { + PromptEditorMode::Buffer { codegen, .. } => { + codegen.read(cx).selected_text(cx).map(|s| s.to_string()) + } + PromptEditorMode::Terminal { .. } => None, + }; - let prompt = self.editor.read(cx).text(cx); + let prompt = self.editor.read(cx).text(cx); - telemetry::event!( - "Inline Assistant Rated", - rating = "negative", - model = model_telemetry_id, - prompt = prompt, - completion = completion, - selected_text = selected_text, - rating_id = rating_id.to_string() - ); + let kind = match &self.mode { + PromptEditorMode::Buffer { .. } => "inline", + PromptEditorMode::Terminal { .. } => "inline_terminal", + }; + + telemetry::event!( + "Inline Assistant Rated", + rating = "negative", + session_id = self.session_state.session_id.to_string(), + kind = kind, + model = model_telemetry_id, + prompt = prompt, + completion = completion_text, + selected_text = selected_text, + ); + + self.session_state.completion = CompletionState::Rated; - cx.notify(); + cx.notify(); + } + } } fn toast(&mut self, msg: &str, uuid: Option, cx: &mut Context<'_, PromptEditor>) { @@ -795,8 +812,8 @@ impl PromptEditor { .into_any_element(), ] } else { - let show_rating_buttons = cx.has_flag::(); - let rated = self.rated.rating_id().is_some(); + let show_rating_buttons = cx.has_flag::(); + let rated = matches!(self.session_state.completion, CompletionState::Rated); let accept = IconButton::new("accept", IconName::Check) .icon_color(Color::Info) @@ -1120,6 +1137,7 @@ impl PromptEditor { prompt_history: VecDeque, prompt_buffer: Entity, codegen: Entity, + session_id: Uuid, fs: Arc, history_store: Entity, prompt_store: Option>, @@ -1190,7 +1208,10 @@ impl PromptEditor { editor_subscriptions: Vec::new(), show_rate_limit_notice: false, mode, - rated: RatingState::Pending, + session_state: SessionState { + session_id, + completion: CompletionState::Pending, + }, _phantom: Default::default(), }; @@ -1210,13 +1231,15 @@ impl PromptEditor { .update(cx, |editor, _| editor.set_read_only(false)); } CodegenStatus::Pending => { - self.rated.reset(); + self.session_state.completion = CompletionState::Pending; self.editor .update(cx, |editor, _| editor.set_read_only(true)); } CodegenStatus::Done => { let completion = codegen.read(cx).active_completion(cx); - self.rated.generated_completion(completion); + self.session_state.completion = CompletionState::Generated { + completion_text: completion, + }; self.edited_since_done = false; self.editor .update(cx, |editor, _| editor.set_read_only(false)); @@ -1272,6 +1295,7 @@ impl PromptEditor { prompt_history: VecDeque, prompt_buffer: Entity, codegen: Entity, + session_id: Uuid, fs: Arc, history_store: Entity, prompt_store: Option>, @@ -1337,7 +1361,10 @@ impl PromptEditor { editor_subscriptions: Vec::new(), mode, show_rate_limit_notice: false, - rated: RatingState::Pending, + session_state: SessionState { + session_id, + completion: CompletionState::Pending, + }, _phantom: Default::default(), }; this.count_lines(cx); @@ -1377,13 +1404,14 @@ impl PromptEditor { .update(cx, |editor, _| editor.set_read_only(false)); } CodegenStatus::Pending => { - self.rated = RatingState::Pending; + self.session_state.completion = CompletionState::Pending; self.editor .update(cx, |editor, _| editor.set_read_only(true)); } CodegenStatus::Done | CodegenStatus::Error(_) => { - self.rated - .generated_completion(codegen.read(cx).completion()); + self.session_state.completion = CompletionState::Generated { + completion_text: codegen.read(cx).completion(), + }; self.edited_since_done = false; self.editor .update(cx, |editor, _| editor.set_read_only(false)); diff --git a/crates/agent_ui/src/terminal_codegen.rs b/crates/agent_ui/src/terminal_codegen.rs index cc99471f7f3037cb94ff23979036bd6c2026e2f0..e93d3d3991378ddb4156b264be1f0a5ab4d4faac 100644 --- a/crates/agent_ui/src/terminal_codegen.rs +++ b/crates/agent_ui/src/terminal_codegen.rs @@ -1,37 +1,38 @@ use crate::inline_prompt_editor::CodegenStatus; -use client::telemetry::Telemetry; use futures::{SinkExt, StreamExt, channel::mpsc}; use gpui::{App, AppContext as _, Context, Entity, EventEmitter, Task}; -use language_model::{ - ConfiguredModel, LanguageModelRegistry, LanguageModelRequest, report_assistant_event, -}; -use std::{sync::Arc, time::Instant}; -use telemetry_events::{AssistantEventData, AssistantKind, AssistantPhase}; +use language_model::{ConfiguredModel, LanguageModelRegistry, LanguageModelRequest}; +use std::time::Instant; use terminal::Terminal; +use uuid::Uuid; pub struct TerminalCodegen { pub status: CodegenStatus, - pub telemetry: Option>, terminal: Entity, generation: Task<()>, pub message_id: Option, transaction: Option, + session_id: Uuid, } impl EventEmitter for TerminalCodegen {} impl TerminalCodegen { - pub fn new(terminal: Entity, telemetry: Option>) -> Self { + pub fn new(terminal: Entity, session_id: Uuid) -> Self { Self { terminal, - telemetry, status: CodegenStatus::Idle, generation: Task::ready(()), message_id: None, transaction: None, + session_id, } } + pub fn session_id(&self) -> Uuid { + self.session_id + } + pub fn start(&mut self, prompt_task: Task, cx: &mut Context) { let Some(ConfiguredModel { model, .. }) = LanguageModelRegistry::read_global(cx).inline_assistant_model() @@ -39,15 +40,15 @@ impl TerminalCodegen { return; }; - let model_api_key = model.api_key(cx); - let http_client = cx.http_client(); - let telemetry = self.telemetry.clone(); + let anthropic_reporter = language_model::AnthropicEventReporter::new(&model, cx); + let session_id = self.session_id; + let model_telemetry_id = model.telemetry_id(); + let model_provider_id = model.provider_id().to_string(); + self.status = CodegenStatus::Pending; self.transaction = Some(TerminalTransaction::start(self.terminal.clone())); self.generation = cx.spawn(async move |this, cx| { let prompt = prompt_task.await; - let model_telemetry_id = model.telemetry_id(); - let model_provider_id = model.provider_id(); let response = model.stream_completion_text(prompt, cx).await; let generate = async { let message_id = response @@ -59,7 +60,7 @@ impl TerminalCodegen { let task = cx.background_spawn({ let message_id = message_id.clone(); - let executor = cx.background_executor().clone(); + let anthropic_reporter = anthropic_reporter.clone(); async move { let mut response_latency = None; let request_start = Instant::now(); @@ -79,24 +80,27 @@ impl TerminalCodegen { let result = task.await; let error_message = result.as_ref().err().map(|error| error.to_string()); - report_assistant_event( - AssistantEventData { - conversation_id: None, - kind: AssistantKind::InlineTerminal, - message_id, - phase: AssistantPhase::Response, - model: model_telemetry_id, - model_provider: model_provider_id.to_string(), - response_latency, - error_message, - language_name: None, - }, - telemetry, - http_client, - model_api_key, - &executor, + + telemetry::event!( + "Assistant Responded", + session_id = session_id.to_string(), + kind = "inline_terminal", + phase = "response", + model = model_telemetry_id, + model_provider = model_provider_id, + language_name = Option::<&str>::None, + message_id = message_id, + response_latency = response_latency, + error_message = error_message, ); + anthropic_reporter.report(language_model::AnthropicEventData { + completion_type: language_model::AnthropicCompletionType::Terminal, + event: language_model::AnthropicEventType::Response, + language_name: None, + message_id, + }); + result?; anyhow::Ok(()) } diff --git a/crates/agent_ui/src/terminal_inline_assistant.rs b/crates/agent_ui/src/terminal_inline_assistant.rs index 43ea697bece318699f350259a0e2e38d1a4f4d8d..84a74242b80d0b2f8479b3c6dbca1c7d0bb2cb6d 100644 --- a/crates/agent_ui/src/terminal_inline_assistant.rs +++ b/crates/agent_ui/src/terminal_inline_assistant.rs @@ -8,7 +8,7 @@ use crate::{ use agent::HistoryStore; use agent_settings::AgentSettings; use anyhow::{Context as _, Result}; -use client::telemetry::Telemetry; + use cloud_llm_client::CompletionIntent; use collections::{HashMap, VecDeque}; use editor::{MultiBuffer, actions::SelectAll}; @@ -17,24 +17,19 @@ use gpui::{App, Entity, Focusable, Global, Subscription, Task, UpdateGlobal, Wea use language::Buffer; use language_model::{ ConfiguredModel, LanguageModelRegistry, LanguageModelRequest, LanguageModelRequestMessage, - Role, report_assistant_event, + Role, report_anthropic_event, }; use project::Project; use prompt_store::{PromptBuilder, PromptStore}; use std::sync::Arc; -use telemetry_events::{AssistantEventData, AssistantKind, AssistantPhase}; use terminal_view::TerminalView; use ui::prelude::*; use util::ResultExt; +use uuid::Uuid; use workspace::{Toast, Workspace, notifications::NotificationId}; -pub fn init( - fs: Arc, - prompt_builder: Arc, - telemetry: Arc, - cx: &mut App, -) { - cx.set_global(TerminalInlineAssistant::new(fs, prompt_builder, telemetry)); +pub fn init(fs: Arc, prompt_builder: Arc, cx: &mut App) { + cx.set_global(TerminalInlineAssistant::new(fs, prompt_builder)); } const DEFAULT_CONTEXT_LINES: usize = 50; @@ -44,7 +39,6 @@ pub struct TerminalInlineAssistant { next_assist_id: TerminalInlineAssistId, assists: HashMap, prompt_history: VecDeque, - telemetry: Option>, fs: Arc, prompt_builder: Arc, } @@ -52,16 +46,11 @@ pub struct TerminalInlineAssistant { impl Global for TerminalInlineAssistant {} impl TerminalInlineAssistant { - pub fn new( - fs: Arc, - prompt_builder: Arc, - telemetry: Arc, - ) -> Self { + pub fn new(fs: Arc, prompt_builder: Arc) -> Self { Self { next_assist_id: TerminalInlineAssistId::default(), assists: HashMap::default(), prompt_history: VecDeque::default(), - telemetry: Some(telemetry), fs, prompt_builder, } @@ -80,13 +69,14 @@ impl TerminalInlineAssistant { ) { let terminal = terminal_view.read(cx).terminal().clone(); let assist_id = self.next_assist_id.post_inc(); + let session_id = Uuid::new_v4(); let prompt_buffer = cx.new(|cx| { MultiBuffer::singleton( cx.new(|cx| Buffer::local(initial_prompt.unwrap_or_default(), cx)), cx, ) }); - let codegen = cx.new(|_| TerminalCodegen::new(terminal, self.telemetry.clone())); + let codegen = cx.new(|_| TerminalCodegen::new(terminal, session_id)); let prompt_editor = cx.new(|cx| { PromptEditor::new_terminal( @@ -94,6 +84,7 @@ impl TerminalInlineAssistant { self.prompt_history.clone(), prompt_buffer.clone(), codegen, + session_id, self.fs.clone(), thread_store.clone(), prompt_store.clone(), @@ -309,27 +300,45 @@ impl TerminalInlineAssistant { LanguageModelRegistry::read_global(cx).inline_assistant_model() { let codegen = assist.codegen.read(cx); - let executor = cx.background_executor().clone(); - report_assistant_event( - AssistantEventData { - conversation_id: None, - kind: AssistantKind::InlineTerminal, - message_id: codegen.message_id.clone(), - phase: if undo { - AssistantPhase::Rejected - } else { - AssistantPhase::Accepted - }, - model: model.telemetry_id(), - model_provider: model.provider_id().to_string(), - response_latency: None, - error_message: None, + let session_id = codegen.session_id(); + let message_id = codegen.message_id.clone(); + let model_telemetry_id = model.telemetry_id(); + let model_provider_id = model.provider_id().to_string(); + + let (phase, event_type, anthropic_event_type) = if undo { + ( + "rejected", + "Assistant Response Rejected", + language_model::AnthropicEventType::Reject, + ) + } else { + ( + "accepted", + "Assistant Response Accepted", + language_model::AnthropicEventType::Accept, + ) + }; + + // Fire Zed telemetry + telemetry::event!( + event_type, + kind = "inline_terminal", + phase = phase, + model = model_telemetry_id, + model_provider = model_provider_id, + message_id = message_id, + session_id = session_id, + ); + + report_anthropic_event( + &model, + language_model::AnthropicEventData { + completion_type: language_model::AnthropicCompletionType::Terminal, + event: anthropic_event_type, language_name: None, + message_id, }, - codegen.telemetry.clone(), - cx.http_client(), - model.api_key(cx), - &executor, + cx, ); } diff --git a/crates/agent_ui/src/text_thread_editor.rs b/crates/agent_ui/src/text_thread_editor.rs index fb9ee5e49e22fe7b70c02537a3e9a60394ddcc6f..5e3f348c17de3cd0dae9f5fe41a2477211d6ddd8 100644 --- a/crates/agent_ui/src/text_thread_editor.rs +++ b/crates/agent_ui/src/text_thread_editor.rs @@ -3324,7 +3324,6 @@ mod tests { let mut text_thread = TextThread::local( registry, None, - None, prompt_builder.clone(), Arc::new(SlashCommandWorkingSet::default()), cx, diff --git a/crates/assistant_text_thread/Cargo.toml b/crates/assistant_text_thread/Cargo.toml index 7c8fcca3bfa81f6f2de570fa68ecc795cb81b257..5ad429758ea1785ecb4fcecb2f3ad83a71afda0d 100644 --- a/crates/assistant_text_thread/Cargo.toml +++ b/crates/assistant_text_thread/Cargo.toml @@ -46,7 +46,7 @@ serde_json.workspace = true settings.workspace = true smallvec.workspace = true smol.workspace = true -telemetry_events.workspace = true +telemetry.workspace = true text.workspace = true ui.workspace = true util.workspace = true diff --git a/crates/assistant_text_thread/src/assistant_text_thread_tests.rs b/crates/assistant_text_thread/src/assistant_text_thread_tests.rs index 0743641bf5ce33850f28987d834b2e79771cff6f..7232a03c212a9dfc4bfe9bcce4a78667d9210ad8 100644 --- a/crates/assistant_text_thread/src/assistant_text_thread_tests.rs +++ b/crates/assistant_text_thread/src/assistant_text_thread_tests.rs @@ -50,7 +50,6 @@ fn test_inserting_and_removing_messages(cx: &mut App) { TextThread::local( registry, None, - None, prompt_builder.clone(), Arc::new(SlashCommandWorkingSet::default()), cx, @@ -189,7 +188,6 @@ fn test_message_splitting(cx: &mut App) { TextThread::local( registry.clone(), None, - None, prompt_builder.clone(), Arc::new(SlashCommandWorkingSet::default()), cx, @@ -294,7 +292,6 @@ fn test_messages_for_offsets(cx: &mut App) { TextThread::local( registry, None, - None, prompt_builder.clone(), Arc::new(SlashCommandWorkingSet::default()), cx, @@ -405,7 +402,6 @@ async fn test_slash_commands(cx: &mut TestAppContext) { TextThread::local( registry.clone(), None, - None, prompt_builder.clone(), Arc::new(SlashCommandWorkingSet::default()), cx, @@ -677,7 +673,6 @@ async fn test_serialization(cx: &mut TestAppContext) { TextThread::local( registry.clone(), None, - None, prompt_builder.clone(), Arc::new(SlashCommandWorkingSet::default()), cx, @@ -724,7 +719,6 @@ async fn test_serialization(cx: &mut TestAppContext) { prompt_builder.clone(), Arc::new(SlashCommandWorkingSet::default()), None, - None, cx, ) }); @@ -780,7 +774,6 @@ async fn test_random_context_collaboration(cx: &mut TestAppContext, mut rng: Std prompt_builder.clone(), Arc::new(SlashCommandWorkingSet::default()), None, - None, cx, ) }); @@ -1041,7 +1034,6 @@ fn test_mark_cache_anchors(cx: &mut App) { TextThread::local( registry, None, - None, prompt_builder.clone(), Arc::new(SlashCommandWorkingSet::default()), cx, @@ -1368,7 +1360,6 @@ fn setup_context_editor_with_fake_model( TextThread::local( registry, None, - None, prompt_builder.clone(), Arc::new(SlashCommandWorkingSet::default()), cx, diff --git a/crates/assistant_text_thread/src/text_thread.rs b/crates/assistant_text_thread/src/text_thread.rs index b808d9fb0019ccad25366d9ae60cc1f765126c74..5ec72eb0814f9ac09aba36f52d6f011af5b47249 100644 --- a/crates/assistant_text_thread/src/text_thread.rs +++ b/crates/assistant_text_thread/src/text_thread.rs @@ -5,7 +5,7 @@ use assistant_slash_command::{ SlashCommandResult, SlashCommandWorkingSet, }; use assistant_slash_commands::FileCommandMetadata; -use client::{self, ModelRequestUsage, RequestUsage, proto, telemetry::Telemetry}; +use client::{self, ModelRequestUsage, RequestUsage, proto}; use clock::ReplicaId; use cloud_llm_client::{CompletionIntent, UsageLimit}; use collections::{HashMap, HashSet}; @@ -19,10 +19,11 @@ use gpui::{ use itertools::Itertools as _; use language::{AnchorRangeExt, Bias, Buffer, LanguageRegistry, OffsetRangeExt, Point, ToOffset}; use language_model::{ - LanguageModel, LanguageModelCacheConfiguration, LanguageModelCompletionEvent, - LanguageModelImage, LanguageModelRegistry, LanguageModelRequest, LanguageModelRequestMessage, + AnthropicCompletionType, AnthropicEventData, AnthropicEventType, LanguageModel, + LanguageModelCacheConfiguration, LanguageModelCompletionEvent, LanguageModelImage, + LanguageModelRegistry, LanguageModelRequest, LanguageModelRequestMessage, LanguageModelToolUseId, MessageContent, PaymentRequiredError, Role, StopReason, - report_assistant_event, + report_anthropic_event, }; use open_ai::Model as OpenAiModel; use paths::text_threads_dir; @@ -40,7 +41,7 @@ use std::{ sync::Arc, time::{Duration, Instant}, }; -use telemetry_events::{AssistantEventData, AssistantKind, AssistantPhase}; + use text::{BufferSnapshot, ToPoint}; use ui::IconName; use util::{ResultExt, TryFutureExt, post_inc}; @@ -686,7 +687,6 @@ pub struct TextThread { pending_cache_warming_task: Task>, path: Option>, _subscriptions: Vec, - telemetry: Option>, language_registry: Arc, project: Option>, prompt_builder: Arc, @@ -709,7 +709,6 @@ impl TextThread { pub fn local( language_registry: Arc, project: Option>, - telemetry: Option>, prompt_builder: Arc, slash_commands: Arc, cx: &mut Context, @@ -722,7 +721,6 @@ impl TextThread { prompt_builder, slash_commands, project, - telemetry, cx, ) } @@ -743,7 +741,6 @@ impl TextThread { prompt_builder: Arc, slash_commands: Arc, project: Option>, - telemetry: Option>, cx: &mut Context, ) -> Self { let buffer = cx.new(|_cx| { @@ -784,7 +781,6 @@ impl TextThread { completion_mode: AgentSettings::get_global(cx).preferred_completion_mode, path: None, buffer, - telemetry, project, language_registry, slash_commands, @@ -874,7 +870,6 @@ impl TextThread { prompt_builder: Arc, slash_commands: Arc, project: Option>, - telemetry: Option>, cx: &mut Context, ) -> Self { let id = saved_context.id.clone().unwrap_or_else(TextThreadId::new); @@ -886,7 +881,6 @@ impl TextThread { prompt_builder, slash_commands, project, - telemetry, cx, ); this.path = Some(path); @@ -2212,24 +2206,26 @@ impl TextThread { .read(cx) .language() .map(|language| language.name()); - report_assistant_event( - AssistantEventData { - conversation_id: Some(this.id.0.clone()), - kind: AssistantKind::Panel, - phase: AssistantPhase::Response, - message_id: None, - model: model.telemetry_id(), - model_provider: model.provider_id().to_string(), - response_latency, - error_message, - language_name: language_name.map(|name| name.to_proto()), - }, - this.telemetry.clone(), - cx.http_client(), - model.api_key(cx), - cx.background_executor(), + + telemetry::event!( + "Assistant Responded", + conversation_id = this.id.0.clone(), + kind = "panel", + phase = "response", + model = model.telemetry_id(), + model_provider = model.provider_id().to_string(), + response_latency, + error_message, + language_name = language_name.as_ref().map(|name| name.to_proto()), ); + report_anthropic_event(&model, AnthropicEventData { + completion_type: AnthropicCompletionType::Panel, + event: AnthropicEventType::Response, + language_name: language_name.map(|name| name.to_proto()), + message_id: None, + }, cx); + if let Ok(stop_reason) = result { match stop_reason { StopReason::ToolUse => {} diff --git a/crates/assistant_text_thread/src/text_thread_store.rs b/crates/assistant_text_thread/src/text_thread_store.rs index 71fabed503e8c04a8865bed72c28ae5b30e75574..483baa73134334162ea30d269a1f955dd8fe023a 100644 --- a/crates/assistant_text_thread/src/text_thread_store.rs +++ b/crates/assistant_text_thread/src/text_thread_store.rs @@ -4,7 +4,7 @@ use crate::{ }; use anyhow::{Context as _, Result}; use assistant_slash_command::{SlashCommandId, SlashCommandWorkingSet}; -use client::{Client, TypedEnvelope, proto, telemetry::Telemetry}; +use client::{Client, TypedEnvelope, proto}; use clock::ReplicaId; use collections::HashMap; use context_server::ContextServerId; @@ -48,7 +48,6 @@ pub struct TextThreadStore { fs: Arc, languages: Arc, slash_commands: Arc, - telemetry: Arc, _watch_updates: Task>, client: Arc, project: WeakEntity, @@ -88,7 +87,6 @@ impl TextThreadStore { ) -> Task>> { let fs = project.read(cx).fs().clone(); let languages = project.read(cx).languages().clone(); - let telemetry = project.read(cx).client().telemetry().clone(); cx.spawn(async move |cx| { const CONTEXT_WATCH_DURATION: Duration = Duration::from_millis(100); let (mut events, _) = fs.watch(text_threads_dir(), CONTEXT_WATCH_DURATION).await; @@ -102,7 +100,6 @@ impl TextThreadStore { fs, languages, slash_commands, - telemetry, _watch_updates: cx.spawn(async move |this, cx| { async move { while events.next().await.is_some() { @@ -143,7 +140,6 @@ impl TextThreadStore { fs: project.read(cx).fs().clone(), languages: project.read(cx).languages().clone(), slash_commands: Arc::default(), - telemetry: project.read(cx).client().telemetry().clone(), _watch_updates: Task::ready(None), client: project.read(cx).client(), project: project.downgrade(), @@ -379,7 +375,6 @@ impl TextThreadStore { TextThread::local( self.languages.clone(), Some(self.project.clone()), - Some(self.telemetry.clone()), self.prompt_builder.clone(), self.slash_commands.clone(), cx, @@ -402,7 +397,7 @@ impl TextThreadStore { let capability = project.capability(); let language_registry = self.languages.clone(); let project = self.project.clone(); - let telemetry = self.telemetry.clone(); + let prompt_builder = self.prompt_builder.clone(); let slash_commands = self.slash_commands.clone(); let request = self.client.request(proto::CreateContext { project_id }); @@ -419,7 +414,6 @@ impl TextThreadStore { prompt_builder, slash_commands, Some(project), - Some(telemetry), cx, ) })?; @@ -457,7 +451,6 @@ impl TextThreadStore { let fs = self.fs.clone(); let languages = self.languages.clone(); let project = self.project.clone(); - let telemetry = self.telemetry.clone(); let load = cx.background_spawn({ let path = path.clone(); async move { @@ -478,7 +471,6 @@ impl TextThreadStore { prompt_builder, slash_commands, Some(project), - Some(telemetry), cx, ) })?; @@ -568,7 +560,6 @@ impl TextThreadStore { let capability = project.capability(); let language_registry = self.languages.clone(); let project = self.project.clone(); - let telemetry = self.telemetry.clone(); let request = self.client.request(proto::OpenContext { project_id, context_id: text_thread_id.to_proto(), @@ -587,7 +578,6 @@ impl TextThreadStore { prompt_builder, slash_commands, Some(project), - Some(telemetry), cx, ) })?; diff --git a/crates/language_model/Cargo.toml b/crates/language_model/Cargo.toml index 0a6d440a6bbc4cb1f45663d78eecb57bec43f1f5..e472521074109216bd243f5875dcc325cc9b3fed 100644 --- a/crates/language_model/Cargo.toml +++ b/crates/language_model/Cargo.toml @@ -39,7 +39,6 @@ serde.workspace = true serde_json.workspace = true settings.workspace = true smol.workspace = true -telemetry_events.workspace = true thiserror.workspace = true util.workspace = true zed_env_vars.workspace = true diff --git a/crates/language_model/src/telemetry.rs b/crates/language_model/src/telemetry.rs index ccdcb0ad0cdf0d830d0163f39afad478377fe01d..6d7f4df7f644115cae7b2148f4d78fde19674344 100644 --- a/crates/language_model/src/telemetry.rs +++ b/crates/language_model/src/telemetry.rs @@ -1,41 +1,101 @@ use crate::ANTHROPIC_PROVIDER_ID; use anthropic::ANTHROPIC_API_URL; use anyhow::{Context as _, anyhow}; -use client::telemetry::Telemetry; use gpui::BackgroundExecutor; use http_client::{AsyncBody, HttpClient, Method, Request as HttpRequest}; use std::env; use std::sync::Arc; -use telemetry_events::{AssistantEventData, AssistantKind, AssistantPhase}; use util::ResultExt; -pub fn report_assistant_event( - event: AssistantEventData, - telemetry: Option>, - client: Arc, - model_api_key: Option, - executor: &BackgroundExecutor, +#[derive(Clone, Debug)] +pub struct AnthropicEventData { + pub completion_type: AnthropicCompletionType, + pub event: AnthropicEventType, + pub language_name: Option, + pub message_id: Option, +} + +#[derive(Clone, Debug)] +pub enum AnthropicCompletionType { + Editor, + Terminal, + Panel, +} + +#[derive(Clone, Debug)] +pub enum AnthropicEventType { + Invoked, + Response, + Accept, + Reject, +} + +impl AnthropicCompletionType { + fn as_str(&self) -> &'static str { + match self { + Self::Editor => "natural_language_completion_in_editor", + Self::Terminal => "natural_language_completion_in_terminal", + Self::Panel => "conversation_message", + } + } +} + +impl AnthropicEventType { + fn as_str(&self) -> &'static str { + match self { + Self::Invoked => "invoke", + Self::Response => "response", + Self::Accept => "accept", + Self::Reject => "reject", + } + } +} + +pub fn report_anthropic_event( + model: &Arc, + event: AnthropicEventData, + cx: &gpui::App, ) { - if let Some(telemetry) = telemetry.as_ref() { - telemetry.report_assistant_event(event.clone()); - if telemetry.metrics_enabled() && event.model_provider == ANTHROPIC_PROVIDER_ID.0 { - if let Some(api_key) = model_api_key { - executor - .spawn(async move { - report_anthropic_event(event, client, api_key) - .await - .log_err(); - }) - .detach(); - } else { - log::error!("Cannot send Anthropic telemetry because API key is missing"); - } + let reporter = AnthropicEventReporter::new(model, cx); + reporter.report(event); +} + +#[derive(Clone)] +pub struct AnthropicEventReporter { + http_client: Arc, + executor: BackgroundExecutor, + api_key: Option, + is_anthropic: bool, +} + +impl AnthropicEventReporter { + pub fn new(model: &Arc, cx: &gpui::App) -> Self { + Self { + http_client: cx.http_client(), + executor: cx.background_executor().clone(), + api_key: model.api_key(cx), + is_anthropic: model.provider_id() == ANTHROPIC_PROVIDER_ID, } } + + pub fn report(&self, event: AnthropicEventData) { + if !self.is_anthropic { + return; + } + let Some(api_key) = self.api_key.clone() else { + return; + }; + let client = self.http_client.clone(); + self.executor + .spawn(async move { + send_anthropic_event(event, client, api_key).await.log_err(); + }) + .detach(); + } } -async fn report_anthropic_event( - event: AssistantEventData, +async fn send_anthropic_event( + event: AnthropicEventData, client: Arc, api_key: String, ) -> anyhow::Result<()> { @@ -45,18 +105,10 @@ async fn report_anthropic_event( .uri(uri) .header("X-Api-Key", api_key) .header("Content-Type", "application/json"); - let serialized_event: serde_json::Value = serde_json::json!({ - "completion_type": match event.kind { - AssistantKind::Inline => "natural_language_completion_in_editor", - AssistantKind::InlineTerminal => "natural_language_completion_in_terminal", - AssistantKind::Panel => "conversation_message", - }, - "event": match event.phase { - AssistantPhase::Response => "response", - AssistantPhase::Invoked => "invoke", - AssistantPhase::Accepted => "accept", - AssistantPhase::Rejected => "reject", - }, + + let serialized_event = serde_json::json!({ + "completion_type": event.completion_type.as_str(), + "event": event.event.as_str(), "metadata": { "language_name": event.language_name, "message_id": event.message_id, diff --git a/crates/settings_ui/src/settings_ui.rs b/crates/settings_ui/src/settings_ui.rs index 2c5585af5668a4b224d406413ab700bd8b2e349c..bfc60cc1ea21525effa5347431d90ee219064d24 100644 --- a/crates/settings_ui/src/settings_ui.rs +++ b/crates/settings_ui/src/settings_ui.rs @@ -4,7 +4,6 @@ mod pages; use anyhow::Result; use editor::{Editor, EditorEvent}; -use feature_flags::FeatureFlag; use fuzzy::StringMatchCandidate; use gpui::{ Action, App, ClipboardItem, DEFAULT_ADDITIONAL_WINDOW_SIZE, Div, Entity, FocusHandle, @@ -370,12 +369,6 @@ struct SettingsFieldMetadata { should_do_titlecase: Option, } -pub struct SettingsUiFeatureFlag; - -impl FeatureFlag for SettingsUiFeatureFlag { - const NAME: &'static str = "settings-ui"; -} - pub fn init(cx: &mut App) { init_renderers(cx); From b8e40e6fdb61fc108f2db7372b3a38655b101875 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Sun, 14 Dec 2025 20:50:48 -0800 Subject: [PATCH 260/621] Add an action for capturing your last edit as an edit prediction example (#44841) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR adds a staff-only button to the edit prediction menu for capturing your current editing session as edit prediction example file. When you click that button, it opens a markdown tab with the example. By default, the most recent change that you've made is used as the expected patch, and all of the previous events are used as the editing history. Screenshot 2025-12-14 at 6 58 33 PM Release Notes: - N/A --- Cargo.lock | 5 +- crates/edit_prediction/Cargo.toml | 1 + crates/edit_prediction/src/edit_prediction.rs | 146 +++++++++--- .../src/edit_prediction_tests.rs | 97 +++++++- crates/edit_prediction/src/example_spec.rs | 212 ++++++++++++++++++ crates/edit_prediction_cli/Cargo.toml | 1 - crates/edit_prediction_cli/src/distill.rs | 2 +- crates/edit_prediction_cli/src/example.rs | 169 ++------------ .../edit_prediction_cli/src/format_prompt.rs | 19 +- .../edit_prediction_cli/src/load_project.rs | 42 ++-- crates/edit_prediction_cli/src/main.rs | 8 +- crates/edit_prediction_cli/src/predict.rs | 6 +- .../src/retrieve_context.rs | 2 +- crates/edit_prediction_cli/src/score.rs | 6 +- crates/edit_prediction_ui/Cargo.toml | 3 + .../src/edit_prediction_button.rs | 12 +- .../src/edit_prediction_ui.rs | 208 ++++++++++++++++- 17 files changed, 711 insertions(+), 228 deletions(-) create mode 100644 crates/edit_prediction/src/example_spec.rs diff --git a/Cargo.lock b/Cargo.lock index 436da4aef8c0849a61336a9645639c17da731029..dd57996c7ef6dd711c1e67725d1bdfd86d277729 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5130,6 +5130,7 @@ dependencies = [ "postage", "pretty_assertions", "project", + "pulldown-cmark 0.12.2", "rand 0.9.2", "regex", "release_channel", @@ -5184,7 +5185,6 @@ dependencies = [ "pretty_assertions", "project", "prompt_store", - "pulldown-cmark 0.12.2", "release_channel", "reqwest_client", "serde", @@ -5256,9 +5256,11 @@ dependencies = [ "feature_flags", "fs", "futures 0.3.31", + "git", "gpui", "indoc", "language", + "log", "lsp", "markdown", "menu", @@ -5272,6 +5274,7 @@ dependencies = [ "telemetry", "text", "theme", + "time", "ui", "util", "workspace", diff --git a/crates/edit_prediction/Cargo.toml b/crates/edit_prediction/Cargo.toml index 5f1799e2dc4bb5460a900664472ad33e3035d4f1..2d5fb36a581f7bd17bb76f79791c276c86c9c631 100644 --- a/crates/edit_prediction/Cargo.toml +++ b/crates/edit_prediction/Cargo.toml @@ -41,6 +41,7 @@ open_ai.workspace = true postage.workspace = true pretty_assertions.workspace = true project.workspace = true +pulldown-cmark.workspace = true rand.workspace = true regex.workspace = true release_channel.workspace = true diff --git a/crates/edit_prediction/src/edit_prediction.rs b/crates/edit_prediction/src/edit_prediction.rs index 8b96466667bbac8fba92549487821f0d450670ac..ff15d04cc1c0f8e7bbeb7f2a29b520a8ec32097a 100644 --- a/crates/edit_prediction/src/edit_prediction.rs +++ b/crates/edit_prediction/src/edit_prediction.rs @@ -25,7 +25,7 @@ use gpui::{ prelude::*, }; use language::language_settings::all_language_settings; -use language::{Anchor, Buffer, File, Point, ToPoint}; +use language::{Anchor, Buffer, File, Point, TextBufferSnapshot, ToPoint}; use language::{BufferSnapshot, OffsetRangeExt}; use language_model::{LlmApiToken, RefreshLlmTokenListener}; use project::{Project, ProjectPath, WorktreeId}; @@ -47,7 +47,8 @@ use thiserror::Error; use util::{RangeExt as _, ResultExt as _}; use workspace::notifications::{ErrorMessagePrompt, NotificationId, show_app_notification}; -mod cursor_excerpt; +pub mod cursor_excerpt; +pub mod example_spec; mod license_detection; pub mod mercury; mod onboarding_modal; @@ -89,6 +90,7 @@ actions!( /// Maximum number of events to track. const EVENT_COUNT_MAX: usize = 6; const CHANGE_GROUPING_LINE_SPAN: u32 = 8; +const LAST_CHANGE_GROUPING_TIME: Duration = Duration::from_secs(1); const ZED_PREDICT_DATA_COLLECTION_CHOICE: &str = "zed_predict_data_collection_choice"; const REJECT_REQUEST_DEBOUNCE: Duration = Duration::from_secs(15); @@ -265,6 +267,19 @@ impl ProjectState { .collect() } + pub fn events_split_by_pause(&self, cx: &App) -> Vec> { + self.events + .iter() + .cloned() + .chain(self.last_event.as_ref().iter().flat_map(|event| { + let (one, two) = event.split_by_pause(); + let one = one.finalize(&self.license_detection_watchers, cx); + let two = two.and_then(|two| two.finalize(&self.license_detection_watchers, cx)); + one.into_iter().chain(two) + })) + .collect() + } + fn cancel_pending_prediction( &mut self, pending_prediction: PendingPrediction, @@ -385,15 +400,21 @@ impl std::ops::Deref for BufferEditPrediction<'_> { } struct RegisteredBuffer { - snapshot: BufferSnapshot, + file: Option>, + snapshot: TextBufferSnapshot, last_position: Option, _subscriptions: [gpui::Subscription; 2], } +#[derive(Clone)] struct LastEvent { - old_snapshot: BufferSnapshot, - new_snapshot: BufferSnapshot, + old_snapshot: TextBufferSnapshot, + new_snapshot: TextBufferSnapshot, + old_file: Option>, + new_file: Option>, end_edit_anchor: Option, + snapshot_after_last_editing_pause: Option, + last_edit_time: Option, } impl LastEvent { @@ -402,19 +423,19 @@ impl LastEvent { license_detection_watchers: &HashMap>, cx: &App, ) -> Option> { - let path = buffer_path_with_id_fallback(&self.new_snapshot, cx); - let old_path = buffer_path_with_id_fallback(&self.old_snapshot, cx); - - let file = self.new_snapshot.file(); - let old_file = self.old_snapshot.file(); - - let in_open_source_repo = [file, old_file].iter().all(|file| { - file.is_some_and(|file| { - license_detection_watchers - .get(&file.worktree_id(cx)) - .is_some_and(|watcher| watcher.is_project_open_source()) - }) - }); + let path = buffer_path_with_id_fallback(self.new_file.as_ref(), &self.new_snapshot, cx); + let old_path = buffer_path_with_id_fallback(self.old_file.as_ref(), &self.old_snapshot, cx); + + let in_open_source_repo = + [self.new_file.as_ref(), self.old_file.as_ref()] + .iter() + .all(|file| { + file.is_some_and(|file| { + license_detection_watchers + .get(&file.worktree_id(cx)) + .is_some_and(|watcher| watcher.is_project_open_source()) + }) + }); let diff = language::unified_diff(&self.old_snapshot.text(), &self.new_snapshot.text()); @@ -431,10 +452,42 @@ impl LastEvent { })) } } + + pub fn split_by_pause(&self) -> (LastEvent, Option) { + let Some(boundary_snapshot) = self.snapshot_after_last_editing_pause.as_ref() else { + return (self.clone(), None); + }; + + let before = LastEvent { + old_snapshot: self.old_snapshot.clone(), + new_snapshot: boundary_snapshot.clone(), + old_file: self.old_file.clone(), + new_file: self.new_file.clone(), + end_edit_anchor: self.end_edit_anchor, + snapshot_after_last_editing_pause: None, + last_edit_time: self.last_edit_time, + }; + + let after = LastEvent { + old_snapshot: boundary_snapshot.clone(), + new_snapshot: self.new_snapshot.clone(), + old_file: self.old_file.clone(), + new_file: self.new_file.clone(), + end_edit_anchor: self.end_edit_anchor, + snapshot_after_last_editing_pause: None, + last_edit_time: self.last_edit_time, + }; + + (before, Some(after)) + } } -fn buffer_path_with_id_fallback(snapshot: &BufferSnapshot, cx: &App) -> Arc { - if let Some(file) = snapshot.file() { +fn buffer_path_with_id_fallback( + file: Option<&Arc>, + snapshot: &TextBufferSnapshot, + cx: &App, +) -> Arc { + if let Some(file) = file { file.full_path(cx).into() } else { Path::new(&format!("untitled-{}", snapshot.remote_id())).into() @@ -585,6 +638,17 @@ impl EditPredictionStore { .unwrap_or_default() } + pub fn edit_history_for_project_with_pause_split_last_event( + &self, + project: &Entity, + cx: &App, + ) -> Vec> { + self.projects + .get(&project.entity_id()) + .map(|project_state| project_state.events_split_by_pause(cx)) + .unwrap_or_default() + } + pub fn context_for_project<'a>( &'a self, project: &Entity, @@ -802,10 +866,13 @@ impl EditPredictionStore { match project_state.registered_buffers.entry(buffer_id) { hash_map::Entry::Occupied(entry) => entry.into_mut(), hash_map::Entry::Vacant(entry) => { - let snapshot = buffer.read(cx).snapshot(); + let buf = buffer.read(cx); + let snapshot = buf.text_snapshot(); + let file = buf.file().cloned(); let project_entity_id = project.entity_id(); entry.insert(RegisteredBuffer { snapshot, + file, last_position: None, _subscriptions: [ cx.subscribe(buffer, { @@ -840,11 +907,14 @@ impl EditPredictionStore { let project_state = self.get_or_init_project(project, cx); let registered_buffer = Self::register_buffer_impl(project_state, buffer, project, cx); - let new_snapshot = buffer.read(cx).snapshot(); + let buf = buffer.read(cx); + let new_file = buf.file().cloned(); + let new_snapshot = buf.text_snapshot(); if new_snapshot.version == registered_buffer.snapshot.version { return; } + let old_file = mem::replace(&mut registered_buffer.file, new_file.clone()); let old_snapshot = mem::replace(&mut registered_buffer.snapshot, new_snapshot.clone()); let end_edit_anchor = new_snapshot .anchored_edits_since::(&old_snapshot.version) @@ -852,20 +922,16 @@ impl EditPredictionStore { .map(|(_, range)| range.end); let events = &mut project_state.events; - if let Some(LastEvent { - new_snapshot: last_new_snapshot, - end_edit_anchor: last_end_edit_anchor, - .. - }) = project_state.last_event.as_mut() - { + let now = cx.background_executor().now(); + if let Some(last_event) = project_state.last_event.as_mut() { let is_next_snapshot_of_same_buffer = old_snapshot.remote_id() - == last_new_snapshot.remote_id() - && old_snapshot.version == last_new_snapshot.version; + == last_event.new_snapshot.remote_id() + && old_snapshot.version == last_event.new_snapshot.version; let should_coalesce = is_next_snapshot_of_same_buffer && end_edit_anchor .as_ref() - .zip(last_end_edit_anchor.as_ref()) + .zip(last_event.end_edit_anchor.as_ref()) .is_some_and(|(a, b)| { let a = a.to_point(&new_snapshot); let b = b.to_point(&new_snapshot); @@ -873,8 +939,18 @@ impl EditPredictionStore { }); if should_coalesce { - *last_end_edit_anchor = end_edit_anchor; - *last_new_snapshot = new_snapshot; + let pause_elapsed = last_event + .last_edit_time + .map(|t| now.duration_since(t) >= LAST_CHANGE_GROUPING_TIME) + .unwrap_or(false); + if pause_elapsed { + last_event.snapshot_after_last_editing_pause = + Some(last_event.new_snapshot.clone()); + } + + last_event.end_edit_anchor = end_edit_anchor; + last_event.new_snapshot = new_snapshot; + last_event.last_edit_time = Some(now); return; } } @@ -888,9 +964,13 @@ impl EditPredictionStore { } project_state.last_event = Some(LastEvent { + old_file, + new_file, old_snapshot, new_snapshot, end_edit_anchor, + snapshot_after_last_editing_pause: None, + last_edit_time: Some(now), }); } diff --git a/crates/edit_prediction/src/edit_prediction_tests.rs b/crates/edit_prediction/src/edit_prediction_tests.rs index 9e4baa78ef4564ce4348ef1b51085ba0a6abdffc..5067aa0050d7a0831ca7668d17188fa6d41637b9 100644 --- a/crates/edit_prediction/src/edit_prediction_tests.rs +++ b/crates/edit_prediction/src/edit_prediction_tests.rs @@ -304,11 +304,102 @@ async fn test_request_events(cx: &mut TestAppContext) { let prediction = prediction_task.await.unwrap().unwrap().prediction.unwrap(); assert_eq!(prediction.edits.len(), 1); + assert_eq!(prediction.edits[0].1.as_ref(), " are you?"); +} + +#[gpui::test] +async fn test_edit_history_getter_pause_splits_last_event(cx: &mut TestAppContext) { + let (ep_store, _requests) = init_test_with_fake_client(cx); + let fs = FakeFs::new(cx.executor()); + fs.insert_tree( + "/root", + json!({ + "foo.md": "Hello!\n\nBye\n" + }), + ) + .await; + let project = Project::test(fs, vec![path!("/root").as_ref()], cx).await; + + let buffer = project + .update(cx, |project, cx| { + let path = project.find_project_path(path!("root/foo.md"), cx).unwrap(); + project.open_buffer(path, cx) + }) + .await + .unwrap(); + + ep_store.update(cx, |ep_store, cx| { + ep_store.register_buffer(&buffer, &project, cx); + }); + + // First burst: insert "How" + buffer.update(cx, |buffer, cx| { + buffer.edit(vec![(7..7, "How")], None, cx); + }); + + // Simulate a pause longer than the grouping threshold (e.g. 500ms). + cx.executor().advance_clock(LAST_CHANGE_GROUPING_TIME * 2); + cx.run_until_parked(); + + // Second burst: append " are you?" immediately after "How" on the same line. + // + // Keeping both bursts on the same line ensures the existing line-span coalescing logic + // groups them into a single `LastEvent`, allowing the pause-split getter to return two diffs. + buffer.update(cx, |buffer, cx| { + buffer.edit(vec![(10..10, " are you?")], None, cx); + }); + + // A second edit shortly after the first post-pause edit ensures the last edit timestamp is + // advanced after the pause boundary is recorded, making pause-splitting deterministic. + buffer.update(cx, |buffer, cx| { + buffer.edit(vec![(19..19, "!")], None, cx); + }); + + // Without time-based splitting, there is one event. + let events = ep_store.update(cx, |ep_store, cx| { + ep_store.edit_history_for_project(&project, cx) + }); + assert_eq!(events.len(), 1); + let zeta_prompt::Event::BufferChange { diff, .. } = events[0].as_ref(); assert_eq!( - prediction.edits[0].0.to_point(&snapshot).start, - language::Point::new(1, 3) + diff.as_str(), + indoc! {" + @@ -1,3 +1,3 @@ + Hello! + - + +How are you?! + Bye + "} + ); + + // With time-based splitting, there are two distinct events. + let events = ep_store.update(cx, |ep_store, cx| { + ep_store.edit_history_for_project_with_pause_split_last_event(&project, cx) + }); + assert_eq!(events.len(), 2); + let zeta_prompt::Event::BufferChange { diff, .. } = events[0].as_ref(); + assert_eq!( + diff.as_str(), + indoc! {" + @@ -1,3 +1,3 @@ + Hello! + - + +How + Bye + "} + ); + + let zeta_prompt::Event::BufferChange { diff, .. } = events[1].as_ref(); + assert_eq!( + diff.as_str(), + indoc! {" + @@ -1,3 +1,3 @@ + Hello! + -How + +How are you?! + Bye + "} ); - assert_eq!(prediction.edits[0].1.as_ref(), " are you?"); } #[gpui::test] diff --git a/crates/edit_prediction/src/example_spec.rs b/crates/edit_prediction/src/example_spec.rs new file mode 100644 index 0000000000000000000000000000000000000000..bf221b576b890f1200c4ee3c095f73edaea71462 --- /dev/null +++ b/crates/edit_prediction/src/example_spec.rs @@ -0,0 +1,212 @@ +use serde::{Deserialize, Serialize}; +use std::{fmt::Write as _, mem, path::Path, sync::Arc}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct ExampleSpec { + #[serde(default)] + pub name: String, + pub repository_url: String, + pub revision: String, + #[serde(default)] + pub uncommitted_diff: String, + pub cursor_path: Arc, + pub cursor_position: String, + pub edit_history: String, + pub expected_patch: String, +} + +const UNCOMMITTED_DIFF_HEADING: &str = "Uncommitted Diff"; +const EDIT_HISTORY_HEADING: &str = "Edit History"; +const CURSOR_POSITION_HEADING: &str = "Cursor Position"; +const EXPECTED_PATCH_HEADING: &str = "Expected Patch"; +const EXPECTED_CONTEXT_HEADING: &str = "Expected Context"; +const REPOSITORY_URL_FIELD: &str = "repository_url"; +const REVISION_FIELD: &str = "revision"; + +impl ExampleSpec { + /// Format this example spec as markdown. + pub fn to_markdown(&self) -> String { + let mut markdown = String::new(); + + _ = writeln!(markdown, "# {}", self.name); + markdown.push('\n'); + + _ = writeln!(markdown, "repository_url = {}", self.repository_url); + _ = writeln!(markdown, "revision = {}", self.revision); + markdown.push('\n'); + + if !self.uncommitted_diff.is_empty() { + _ = writeln!(markdown, "## {}", UNCOMMITTED_DIFF_HEADING); + _ = writeln!(markdown); + _ = writeln!(markdown, "```diff"); + markdown.push_str(&self.uncommitted_diff); + if !markdown.ends_with('\n') { + markdown.push('\n'); + } + _ = writeln!(markdown, "```"); + markdown.push('\n'); + } + + _ = writeln!(markdown, "## {}", EDIT_HISTORY_HEADING); + _ = writeln!(markdown); + + if self.edit_history.is_empty() { + _ = writeln!(markdown, "(No edit history)"); + _ = writeln!(markdown); + } else { + _ = writeln!(markdown, "```diff"); + markdown.push_str(&self.edit_history); + if !markdown.ends_with('\n') { + markdown.push('\n'); + } + _ = writeln!(markdown, "```"); + markdown.push('\n'); + } + + _ = writeln!(markdown, "## {}", CURSOR_POSITION_HEADING); + _ = writeln!(markdown); + _ = writeln!(markdown, "```{}", self.cursor_path.to_string_lossy()); + markdown.push_str(&self.cursor_position); + if !markdown.ends_with('\n') { + markdown.push('\n'); + } + _ = writeln!(markdown, "```"); + markdown.push('\n'); + + _ = writeln!(markdown, "## {}", EXPECTED_PATCH_HEADING); + markdown.push('\n'); + _ = writeln!(markdown, "```diff"); + markdown.push_str(&self.expected_patch); + if !markdown.ends_with('\n') { + markdown.push('\n'); + } + _ = writeln!(markdown, "```"); + markdown.push('\n'); + + markdown + } + + /// Parse an example spec from markdown. + pub fn from_markdown(name: String, input: &str) -> anyhow::Result { + use pulldown_cmark::{CodeBlockKind, CowStr, Event, HeadingLevel, Parser, Tag, TagEnd}; + + let parser = Parser::new(input); + + let mut spec = ExampleSpec { + name, + repository_url: String::new(), + revision: String::new(), + uncommitted_diff: String::new(), + cursor_path: Path::new("").into(), + cursor_position: String::new(), + edit_history: String::new(), + expected_patch: String::new(), + }; + + let mut text = String::new(); + let mut block_info: CowStr = "".into(); + + #[derive(PartialEq)] + enum Section { + Start, + UncommittedDiff, + EditHistory, + CursorPosition, + ExpectedExcerpts, + ExpectedPatch, + Other, + } + + let mut current_section = Section::Start; + + for event in parser { + match event { + Event::Text(line) => { + text.push_str(&line); + + if let Section::Start = current_section + && let Some((field, value)) = line.split_once('=') + { + match field.trim() { + REPOSITORY_URL_FIELD => { + spec.repository_url = value.trim().to_string(); + } + REVISION_FIELD => { + spec.revision = value.trim().to_string(); + } + _ => {} + } + } + } + Event::End(TagEnd::Heading(HeadingLevel::H2)) => { + let title = mem::take(&mut text); + current_section = if title.eq_ignore_ascii_case(UNCOMMITTED_DIFF_HEADING) { + Section::UncommittedDiff + } else if title.eq_ignore_ascii_case(EDIT_HISTORY_HEADING) { + Section::EditHistory + } else if title.eq_ignore_ascii_case(CURSOR_POSITION_HEADING) { + Section::CursorPosition + } else if title.eq_ignore_ascii_case(EXPECTED_PATCH_HEADING) { + Section::ExpectedPatch + } else if title.eq_ignore_ascii_case(EXPECTED_CONTEXT_HEADING) { + Section::ExpectedExcerpts + } else { + Section::Other + }; + } + Event::End(TagEnd::Heading(HeadingLevel::H3)) => { + mem::take(&mut text); + } + Event::End(TagEnd::Heading(HeadingLevel::H4)) => { + mem::take(&mut text); + } + Event::End(TagEnd::Heading(level)) => { + anyhow::bail!("Unexpected heading level: {level}"); + } + Event::Start(Tag::CodeBlock(kind)) => { + match kind { + CodeBlockKind::Fenced(info) => { + block_info = info; + } + CodeBlockKind::Indented => { + anyhow::bail!("Unexpected indented codeblock"); + } + }; + } + Event::Start(_) => { + text.clear(); + block_info = "".into(); + } + Event::End(TagEnd::CodeBlock) => { + let block_info = block_info.trim(); + match current_section { + Section::UncommittedDiff => { + spec.uncommitted_diff = mem::take(&mut text); + } + Section::EditHistory => { + spec.edit_history.push_str(&mem::take(&mut text)); + } + Section::CursorPosition => { + spec.cursor_path = Path::new(block_info).into(); + spec.cursor_position = mem::take(&mut text); + } + Section::ExpectedExcerpts => { + mem::take(&mut text); + } + Section::ExpectedPatch => { + spec.expected_patch = mem::take(&mut text); + } + Section::Start | Section::Other => {} + } + } + _ => {} + } + } + + if spec.cursor_path.as_ref() == Path::new("") || spec.cursor_position.is_empty() { + anyhow::bail!("Missing cursor position codeblock"); + } + + Ok(spec) + } +} diff --git a/crates/edit_prediction_cli/Cargo.toml b/crates/edit_prediction_cli/Cargo.toml index 811808c72304f4c11a9858e61395e46024b83f1e..b6bace2a2c080626126af96f9ef51e435d6ab8fa 100644 --- a/crates/edit_prediction_cli/Cargo.toml +++ b/crates/edit_prediction_cli/Cargo.toml @@ -40,7 +40,6 @@ node_runtime.workspace = true paths.workspace = true project.workspace = true prompt_store.workspace = true -pulldown-cmark.workspace = true release_channel.workspace = true reqwest_client.workspace = true serde.workspace = true diff --git a/crates/edit_prediction_cli/src/distill.rs b/crates/edit_prediction_cli/src/distill.rs index 085c5f744a1837cbb97f4c33b6f89b6031088e2b..abfe178ae61b6da522f43c93d40b6000800d0e4d 100644 --- a/crates/edit_prediction_cli/src/distill.rs +++ b/crates/edit_prediction_cli/src/distill.rs @@ -14,7 +14,7 @@ pub async fn run_distill(example: &mut Example) -> Result<()> { ) })?; - example.expected_patch = prediction.actual_patch; + example.spec.expected_patch = prediction.actual_patch; example.prompt = None; example.predictions = Vec::new(); example.score = Vec::new(); diff --git a/crates/edit_prediction_cli/src/example.rs b/crates/edit_prediction_cli/src/example.rs index 9499aae0c1ebce7eeca3ef05fedbcf09c960e131..e37619bf224b3fa506516714856cfbc5024ece14 100644 --- a/crates/edit_prediction_cli/src/example.rs +++ b/crates/edit_prediction_cli/src/example.rs @@ -1,6 +1,7 @@ use crate::{PredictionProvider, PromptFormat, metrics::ClassificationMetrics}; use anyhow::{Context as _, Result}; use collections::HashMap; +use edit_prediction::example_spec::ExampleSpec; use edit_prediction::udiff::OpenedBuffers; use gpui::Entity; use http_client::Url; @@ -11,23 +12,14 @@ use std::sync::Arc; use std::{ borrow::Cow, io::{Read, Write}, - mem, path::{Path, PathBuf}, }; use zeta_prompt::RelatedFile; #[derive(Clone, Debug, Serialize, Deserialize)] pub struct Example { - #[serde(default)] - pub name: String, - pub repository_url: String, - pub revision: String, - #[serde(default)] - pub uncommitted_diff: String, - pub cursor_path: Arc, - pub cursor_position: String, - pub edit_history: String, - pub expected_patch: String, + #[serde(flatten)] + pub spec: ExampleSpec, /// The full content of the file where an edit is being predicted, and the /// actual cursor offset. @@ -101,8 +93,9 @@ pub struct ExampleScore { impl Example { pub fn repo_name(&self) -> Result<(Cow<'_, str>, Cow<'_, str>)> { // git@github.com:owner/repo.git - if self.repository_url.contains('@') { + if self.spec.repository_url.contains('@') { let (owner, repo) = self + .spec .repository_url .split_once(':') .context("expected : in git url")? @@ -115,7 +108,7 @@ impl Example { )) // http://github.com/owner/repo.git } else { - let url = Url::parse(&self.repository_url)?; + let url = Url::parse(&self.spec.repository_url)?; let mut segments = url.path_segments().context("empty http url")?; let owner = segments .next() @@ -171,8 +164,8 @@ pub fn read_examples(inputs: &[PathBuf]) -> Vec { serde_json::from_str::(&content).unwrap_or_else(|error| { panic!("Failed to parse example file: {}\n{error}", path.display()) }); - if example.name.is_empty() { - example.name = filename; + if example.spec.name.is_empty() { + example.spec.name = filename; } examples.push(example); } @@ -189,8 +182,8 @@ pub fn read_examples(inputs: &[PathBuf]) -> Vec { line_ix + 1 ) }); - if example.name.is_empty() { - example.name = format!("{filename}-{line_ix}") + if example.spec.name.is_empty() { + example.spec.name = format!("{filename}-{line_ix}") } example }) @@ -225,9 +218,10 @@ pub fn write_examples(examples: &[Example], output_path: Option<&PathBuf>) { pub fn sort_examples_by_repo_and_rev(examples: &mut [Example]) { examples.sort_by(|a, b| { - a.repository_url - .cmp(&b.repository_url) - .then(b.revision.cmp(&a.revision)) + a.spec + .repository_url + .cmp(&b.spec.repository_url) + .then(b.spec.revision.cmp(&a.spec.revision)) }); } @@ -235,145 +229,22 @@ pub fn group_examples_by_repo(examples: &mut [Example]) -> Vec let mut examples_by_repo = HashMap::default(); for example in examples.iter_mut() { examples_by_repo - .entry(example.repository_url.clone()) + .entry(example.spec.repository_url.clone()) .or_insert_with(Vec::new) .push(example); } examples_by_repo.into_values().collect() } -fn parse_markdown_example(id: String, input: &str) -> Result { - use pulldown_cmark::{CodeBlockKind, CowStr, Event, HeadingLevel, Parser, Tag, TagEnd}; - - const UNCOMMITTED_DIFF_HEADING: &str = "Uncommitted Diff"; - const EDIT_HISTORY_HEADING: &str = "Edit History"; - const CURSOR_POSITION_HEADING: &str = "Cursor Position"; - const EXPECTED_PATCH_HEADING: &str = "Expected Patch"; - const EXPECTED_CONTEXT_HEADING: &str = "Expected Context"; - const REPOSITORY_URL_FIELD: &str = "repository_url"; - const REVISION_FIELD: &str = "revision"; - - let parser = Parser::new(input); - - let mut example = Example { - name: id, - repository_url: String::new(), - revision: String::new(), - uncommitted_diff: String::new(), - cursor_path: PathBuf::new().into(), - cursor_position: String::new(), - edit_history: String::new(), - expected_patch: String::new(), +fn parse_markdown_example(name: String, input: &str) -> Result { + let spec = ExampleSpec::from_markdown(name, input)?; + Ok(Example { + spec, buffer: None, context: None, prompt: None, predictions: Vec::new(), score: Vec::new(), state: None, - }; - - let mut text = String::new(); - let mut block_info: CowStr = "".into(); - - #[derive(PartialEq)] - enum Section { - Start, - UncommittedDiff, - EditHistory, - CursorPosition, - ExpectedExcerpts, - ExpectedPatch, - Other, - } - - let mut current_section = Section::Start; - - for event in parser { - match event { - Event::Text(line) => { - text.push_str(&line); - - if let Section::Start = current_section - && let Some((field, value)) = line.split_once('=') - { - match field.trim() { - REPOSITORY_URL_FIELD => { - example.repository_url = value.trim().to_string(); - } - REVISION_FIELD => { - example.revision = value.trim().to_string(); - } - _ => {} - } - } - } - Event::End(TagEnd::Heading(HeadingLevel::H2)) => { - let title = mem::take(&mut text); - current_section = if title.eq_ignore_ascii_case(UNCOMMITTED_DIFF_HEADING) { - Section::UncommittedDiff - } else if title.eq_ignore_ascii_case(EDIT_HISTORY_HEADING) { - Section::EditHistory - } else if title.eq_ignore_ascii_case(CURSOR_POSITION_HEADING) { - Section::CursorPosition - } else if title.eq_ignore_ascii_case(EXPECTED_PATCH_HEADING) { - Section::ExpectedPatch - } else if title.eq_ignore_ascii_case(EXPECTED_CONTEXT_HEADING) { - Section::ExpectedExcerpts - } else { - Section::Other - }; - } - Event::End(TagEnd::Heading(HeadingLevel::H3)) => { - mem::take(&mut text); - } - Event::End(TagEnd::Heading(HeadingLevel::H4)) => { - mem::take(&mut text); - } - Event::End(TagEnd::Heading(level)) => { - anyhow::bail!("Unexpected heading level: {level}"); - } - Event::Start(Tag::CodeBlock(kind)) => { - match kind { - CodeBlockKind::Fenced(info) => { - block_info = info; - } - CodeBlockKind::Indented => { - anyhow::bail!("Unexpected indented codeblock"); - } - }; - } - Event::Start(_) => { - text.clear(); - block_info = "".into(); - } - Event::End(TagEnd::CodeBlock) => { - let block_info = block_info.trim(); - match current_section { - Section::UncommittedDiff => { - example.uncommitted_diff = mem::take(&mut text); - } - Section::EditHistory => { - example.edit_history.push_str(&mem::take(&mut text)); - } - Section::CursorPosition => { - example.cursor_path = Path::new(block_info).into(); - example.cursor_position = mem::take(&mut text); - } - Section::ExpectedExcerpts => { - mem::take(&mut text); - } - Section::ExpectedPatch => { - example.expected_patch = mem::take(&mut text); - } - Section::Start | Section::Other => {} - } - } - _ => {} - } - } - if example.cursor_path.as_ref() == Path::new("") || example.cursor_position.is_empty() { - anyhow::bail!("Missing cursor position codeblock"); - } - - Ok(example) + }) } diff --git a/crates/edit_prediction_cli/src/format_prompt.rs b/crates/edit_prediction_cli/src/format_prompt.rs index c778b708b701492b0cc85a0030a1e9d090ce0724..f543d0799b379403f0caa980df76954649e1aceb 100644 --- a/crates/edit_prediction_cli/src/format_prompt.rs +++ b/crates/edit_prediction_cli/src/format_prompt.rs @@ -23,14 +23,14 @@ pub async fn run_format_prompt( ) -> Result<()> { run_context_retrieval(example, app_state.clone(), cx.clone()).await?; - let _step_progress = Progress::global().start(Step::FormatPrompt, &example.name); + let _step_progress = Progress::global().start(Step::FormatPrompt, &example.spec.name); match prompt_format { PromptFormat::Teacher => { let prompt = TeacherPrompt::format_prompt(example); example.prompt = Some(ExamplePrompt { input: prompt, - expected_output: example.expected_patch.clone(), // TODO + expected_output: example.spec.expected_patch.clone(), // TODO format: prompt_format, }); } @@ -54,7 +54,7 @@ pub async fn run_format_prompt( .files .clone(), ep_store.edit_history_for_project(&project, cx), - example.cursor_path.clone(), + example.spec.cursor_path.clone(), example .buffer .as_ref() @@ -63,7 +63,8 @@ pub async fn run_format_prompt( )) })??; let prompt = format_zeta_prompt(&input); - let expected_output = zeta2_output_for_patch(&input, &example.expected_patch.clone())?; + let expected_output = + zeta2_output_for_patch(&input, &example.spec.expected_patch.clone())?; example.prompt = Some(ExamplePrompt { input: prompt, expected_output, @@ -85,7 +86,7 @@ impl TeacherPrompt { const MAX_HISTORY_LINES: usize = 128; pub fn format_prompt(example: &Example) -> String { - let edit_history = Self::format_edit_history(&example.edit_history); + let edit_history = Self::format_edit_history(&example.spec.edit_history); let context = Self::format_context(example); let editable_region = Self::format_editable_region(example); @@ -131,7 +132,7 @@ impl TeacherPrompt { --- a/{path} +++ b/{path} {diff}", - path = example.cursor_path.to_string_lossy(), + path = example.spec.cursor_path.to_string_lossy(), diff = diff, }; @@ -170,13 +171,13 @@ impl TeacherPrompt { fn format_editable_region(example: &Example) -> String { let mut result = String::new(); - let path_str = example.cursor_path.to_string_lossy(); + let path_str = example.spec.cursor_path.to_string_lossy(); result.push_str(&format!("`````path=\"{path_str}\"\n")); result.push_str(Self::EDITABLE_REGION_START); // TODO: control number of lines around cursor - result.push_str(&example.cursor_position); - if !example.cursor_position.ends_with('\n') { + result.push_str(&example.spec.cursor_position); + if !example.spec.cursor_position.ends_with('\n') { result.push('\n'); } diff --git a/crates/edit_prediction_cli/src/load_project.rs b/crates/edit_prediction_cli/src/load_project.rs index 4517e6ccbebca76a7ba8ce73322d6467000fc189..38f114d726d3626fac89982b7f3a98c55e92ac07 100644 --- a/crates/edit_prediction_cli/src/load_project.rs +++ b/crates/edit_prediction_cli/src/load_project.rs @@ -34,7 +34,7 @@ pub async fn run_load_project( return Ok(()); } - let progress = Progress::global().start(Step::LoadProject, &example.name); + let progress = Progress::global().start(Step::LoadProject, &example.spec.name); let project = setup_project(example, &app_state, &progress, &mut cx).await?; @@ -77,7 +77,7 @@ async fn cursor_position( ) -> Result<(Entity, Anchor)> { let language_registry = project.read_with(cx, |project, _| project.languages().clone())?; let result = language_registry - .load_language_for_file_path(&example.cursor_path) + .load_language_for_file_path(&example.spec.cursor_path) .await; if let Err(error) = result @@ -93,7 +93,7 @@ async fn cursor_position( .context("No visible worktrees") })??; - let cursor_path = RelPath::new(&example.cursor_path, PathStyle::Posix) + let cursor_path = RelPath::new(&example.spec.cursor_path, PathStyle::Posix) .context("Failed to create RelPath")? .into_arc(); let cursor_buffer = project @@ -108,10 +108,11 @@ async fn cursor_position( })? .await?; let cursor_offset_within_excerpt = example + .spec .cursor_position .find(CURSOR_MARKER) .context("missing cursor marker")?; - let mut cursor_excerpt = example.cursor_position.clone(); + let mut cursor_excerpt = example.spec.cursor_position.clone(); cursor_excerpt.replace_range( cursor_offset_within_excerpt..(cursor_offset_within_excerpt + CURSOR_MARKER.len()), "", @@ -123,10 +124,14 @@ async fn cursor_position( let (excerpt_offset, _) = matches.next().with_context(|| { format!( "\nExcerpt:\n\n{cursor_excerpt}\nBuffer text:\n{text}\n.Example: {}\nCursor excerpt did not exist in buffer.", - example.name + example.spec.name ) })?; - anyhow::ensure!(matches.next().is_none(), "More than one cursor position match found for {}", &example.name); + anyhow::ensure!( + matches.next().is_none(), + "More than one cursor position match found for {}", + &example.spec.name + ); Ok(excerpt_offset) })??; @@ -149,7 +154,7 @@ async fn setup_project( let worktree_path = setup_worktree(example, step_progress).await?; - if let Some(project) = app_state.project_cache.get(&example.repository_url) { + if let Some(project) = app_state.project_cache.get(&example.spec.repository_url) { ep_store.update(cx, |ep_store, _| { ep_store.clear_history_for_project(&project); })?; @@ -187,7 +192,7 @@ async fn setup_project( app_state .project_cache - .insert(example.repository_url.clone(), project.clone()); + .insert(example.spec.repository_url.clone(), project.clone()); let buffer_store = project.read_with(cx, |project, _| project.buffer_store().clone())?; cx.subscribe(&buffer_store, { @@ -218,7 +223,7 @@ async fn setup_worktree(example: &Example, step_progress: &StepProgress) -> Resu run_git(&repo_dir, &["init"]).await?; run_git( &repo_dir, - &["remote", "add", "origin", &example.repository_url], + &["remote", "add", "origin", &example.spec.repository_url], ) .await?; } @@ -226,7 +231,10 @@ async fn setup_worktree(example: &Example, step_progress: &StepProgress) -> Resu // Resolve the example to a revision, fetching it if needed. let revision = run_git( &repo_dir, - &["rev-parse", &format!("{}^{{commit}}", example.revision)], + &[ + "rev-parse", + &format!("{}^{{commit}}", example.spec.revision), + ], ) .await; let revision = if let Ok(revision) = revision { @@ -235,7 +243,7 @@ async fn setup_worktree(example: &Example, step_progress: &StepProgress) -> Resu step_progress.set_substatus("fetching"); if run_git( &repo_dir, - &["fetch", "--depth", "1", "origin", &example.revision], + &["fetch", "--depth", "1", "origin", &example.spec.revision], ) .await .is_err() @@ -256,7 +264,7 @@ async fn setup_worktree(example: &Example, step_progress: &StepProgress) -> Resu let worktree_path_string = worktree_path.to_string_lossy(); run_git( &repo_dir, - &["branch", "-f", &example.name, revision.as_str()], + &["branch", "-f", &example.spec.name, revision.as_str()], ) .await?; run_git( @@ -266,7 +274,7 @@ async fn setup_worktree(example: &Example, step_progress: &StepProgress) -> Resu "add", "-f", &worktree_path_string, - &example.name, + &example.spec.name, ], ) .await?; @@ -274,7 +282,7 @@ async fn setup_worktree(example: &Example, step_progress: &StepProgress) -> Resu drop(repo_lock); // Apply the uncommitted diff for this example. - if !example.uncommitted_diff.is_empty() { + if !example.spec.uncommitted_diff.is_empty() { step_progress.set_substatus("applying diff"); let mut apply_process = smol::process::Command::new("git") .current_dir(&worktree_path) @@ -283,7 +291,9 @@ async fn setup_worktree(example: &Example, step_progress: &StepProgress) -> Resu .spawn()?; let mut stdin = apply_process.stdin.take().context("Failed to get stdin")?; - stdin.write_all(example.uncommitted_diff.as_bytes()).await?; + stdin + .write_all(example.spec.uncommitted_diff.as_bytes()) + .await?; stdin.close().await?; drop(stdin); @@ -306,7 +316,7 @@ async fn apply_edit_history( project: &Entity, cx: &mut AsyncApp, ) -> Result { - edit_prediction::udiff::apply_diff(&example.edit_history, project, cx).await + edit_prediction::udiff::apply_diff(&example.spec.edit_history, project, cx).await } thread_local! { diff --git a/crates/edit_prediction_cli/src/main.rs b/crates/edit_prediction_cli/src/main.rs index 3b185103390016f60fc4f621f280d16a58c363e5..dce0fbbed57dbc4b18faf93787cfb8f2341a126a 100644 --- a/crates/edit_prediction_cli/src/main.rs +++ b/crates/edit_prediction_cli/src/main.rs @@ -267,7 +267,7 @@ fn main() { if let Err(e) = result { Progress::global().increment_failed(); let failed_example_path = - FAILED_EXAMPLES_DIR.join(format!("{}.json", example.name)); + FAILED_EXAMPLES_DIR.join(format!("{}.json", example.spec.name)); app_state .fs .write( @@ -276,8 +276,8 @@ fn main() { ) .await .unwrap(); - let err_path = - FAILED_EXAMPLES_DIR.join(format!("{}_err.txt", example.name)); + let err_path = FAILED_EXAMPLES_DIR + .join(format!("{}_err.txt", example.spec.name)); app_state .fs .write(&err_path, e.to_string().as_bytes()) @@ -298,7 +298,7 @@ fn main() { Re-run this example with: cargo run -p edit_prediction_cli -- {} \x1b[36m{}\x1b[0m "}, - example.name, + example.spec.name, e, err_path.display(), failed_example_path.display(), diff --git a/crates/edit_prediction_cli/src/predict.rs b/crates/edit_prediction_cli/src/predict.rs index 3e6104e3a8afc3adc609df094a70fc34138c1619..aa93c5415dea091164a68b76a34242697aac70e3 100644 --- a/crates/edit_prediction_cli/src/predict.rs +++ b/crates/edit_prediction_cli/src/predict.rs @@ -40,7 +40,7 @@ pub async fn run_prediction( provider, PredictionProvider::Teacher | PredictionProvider::TeacherNonBatching ) { - let _step_progress = Progress::global().start(Step::Predict, &example.name); + let _step_progress = Progress::global().start(Step::Predict, &example.spec.name); if example.prompt.is_none() { run_format_prompt(example, PromptFormat::Teacher, app_state.clone(), cx).await?; @@ -52,7 +52,7 @@ pub async fn run_prediction( run_load_project(example, app_state.clone(), cx.clone()).await?; - let _step_progress = Progress::global().start(Step::Predict, &example.name); + let _step_progress = Progress::global().start(Step::Predict, &example.spec.name); if matches!( provider, @@ -90,7 +90,7 @@ pub async fn run_prediction( store.set_edit_prediction_model(model); })?; let state = example.state.as_ref().context("state must be set")?; - let run_dir = RUN_DIR.join(&example.name); + let run_dir = RUN_DIR.join(&example.spec.name); let updated_example = Arc::new(Mutex::new(example.clone())); let current_run_ix = Arc::new(AtomicUsize::new(0)); diff --git a/crates/edit_prediction_cli/src/retrieve_context.rs b/crates/edit_prediction_cli/src/retrieve_context.rs index a07c7ec8752ff987b8783c4fa15904078bd5612d..abba4504edc6c0733ffd8c0677e2e3304d8100fa 100644 --- a/crates/edit_prediction_cli/src/retrieve_context.rs +++ b/crates/edit_prediction_cli/src/retrieve_context.rs @@ -26,7 +26,7 @@ pub async fn run_context_retrieval( run_load_project(example, app_state.clone(), cx.clone()).await?; let step_progress: Arc = Progress::global() - .start(Step::Context, &example.name) + .start(Step::Context, &example.spec.name) .into(); let state = example.state.as_ref().unwrap(); diff --git a/crates/edit_prediction_cli/src/score.rs b/crates/edit_prediction_cli/src/score.rs index 314d19b67259e6a4a0fcff932826325f4366ddde..7b507e6d19c943de92eb0b22c7d24d4026789fed 100644 --- a/crates/edit_prediction_cli/src/score.rs +++ b/crates/edit_prediction_cli/src/score.rs @@ -25,9 +25,9 @@ pub async fn run_scoring( ) .await?; - let _progress = Progress::global().start(Step::Score, &example.name); + let _progress = Progress::global().start(Step::Score, &example.spec.name); - let expected_patch = parse_patch(&example.expected_patch); + let expected_patch = parse_patch(&example.spec.expected_patch); let mut scores = vec![]; @@ -71,7 +71,7 @@ pub fn print_report(examples: &[Example]) { eprintln!( "{:<30} {:>4} {:>4} {:>4} {:>9.2}% {:>7.2}% {:>7.2}% {:>9.2}", - truncate_name(&example.name, 30), + truncate_name(&example.spec.name, 30), line_match.true_positives, line_match.false_positives, line_match.false_negatives, diff --git a/crates/edit_prediction_ui/Cargo.toml b/crates/edit_prediction_ui/Cargo.toml index 63d674250001483bb8963ce62b44af524686399e..b406a450601bef908c27a48be14fe9b1f2204c08 100644 --- a/crates/edit_prediction_ui/Cargo.toml +++ b/crates/edit_prediction_ui/Cargo.toml @@ -15,6 +15,9 @@ doctest = false [dependencies] anyhow.workspace = true buffer_diff.workspace = true +git.workspace = true +log.workspace = true +time.workspace = true client.workspace = true cloud_llm_client.workspace = true codestral.workspace = true diff --git a/crates/edit_prediction_ui/src/edit_prediction_button.rs b/crates/edit_prediction_ui/src/edit_prediction_button.rs index b008f09ec8886086578b571b3655dac566fb6c5d..bbf9f4677df278c014379964e7bdc714e6ce78d8 100644 --- a/crates/edit_prediction_ui/src/edit_prediction_button.rs +++ b/crates/edit_prediction_ui/src/edit_prediction_button.rs @@ -46,7 +46,9 @@ use workspace::{ }; use zed_actions::{OpenBrowser, OpenSettingsAt}; -use crate::{RatePredictions, rate_prediction_modal::PredictEditsRatePredictionsFeatureFlag}; +use crate::{ + CaptureExample, RatePredictions, rate_prediction_modal::PredictEditsRatePredictionsFeatureFlag, +}; actions!( edit_prediction, @@ -899,7 +901,13 @@ impl EditPredictionButton { .context(editor_focus_handle) .when( cx.has_flag::(), - |this| this.action("Rate Predictions", RatePredictions.boxed_clone()), + |this| { + this.action( + "Capture Edit Prediction Example", + CaptureExample.boxed_clone(), + ) + .action("Rate Predictions", RatePredictions.boxed_clone()) + }, ); } diff --git a/crates/edit_prediction_ui/src/edit_prediction_ui.rs b/crates/edit_prediction_ui/src/edit_prediction_ui.rs index 74c81fbfe16eec7846e70aefd59bbfeb282072dc..a762fd22aa7c32779a096fa97b2ea20ef3c9b744 100644 --- a/crates/edit_prediction_ui/src/edit_prediction_ui.rs +++ b/crates/edit_prediction_ui/src/edit_prediction_ui.rs @@ -3,15 +3,24 @@ mod edit_prediction_context_view; mod rate_prediction_modal; use std::any::{Any as _, TypeId}; +use std::path::Path; +use std::sync::Arc; use command_palette_hooks::CommandPaletteFilter; -use edit_prediction::{ResetOnboarding, Zeta2FeatureFlag}; +use edit_prediction::{ + EditPredictionStore, ResetOnboarding, Zeta2FeatureFlag, example_spec::ExampleSpec, +}; use edit_prediction_context_view::EditPredictionContextView; +use editor::Editor; use feature_flags::FeatureFlagAppExt as _; -use gpui::actions; +use git::repository::DiffType; +use gpui::{Window, actions}; +use language::ToPoint as _; +use log; use project::DisableAiSettings; use rate_prediction_modal::RatePredictionsModal; use settings::{Settings as _, SettingsStore}; +use text::ToOffset as _; use ui::{App, prelude::*}; use workspace::{SplitDirection, Workspace}; @@ -32,6 +41,8 @@ actions!( [ /// Opens the rate completions modal. RatePredictions, + /// Captures an ExampleSpec from the current editing session and opens it as Markdown. + CaptureExample, ] ); @@ -45,6 +56,7 @@ pub fn init(cx: &mut App) { } }); + workspace.register_action(capture_edit_prediction_example); workspace.register_action_renderer(|div, _, _, cx| { let has_flag = cx.has_flag::(); div.when(has_flag, |div| { @@ -78,6 +90,7 @@ fn feature_gate_predict_edits_actions(cx: &mut App) { let reset_onboarding_action_types = [TypeId::of::()]; let all_action_types = [ TypeId::of::(), + TypeId::of::(), TypeId::of::(), zed_actions::OpenZedPredictOnboarding.type_id(), TypeId::of::(), @@ -124,3 +137,194 @@ fn feature_gate_predict_edits_actions(cx: &mut App) { }) .detach(); } + +fn capture_edit_prediction_example( + workspace: &mut Workspace, + _: &CaptureExample, + window: &mut Window, + cx: &mut Context, +) { + let Some(ep_store) = EditPredictionStore::try_global(cx) else { + return; + }; + + let project = workspace.project().clone(); + + let (worktree_root, repository) = { + let project_ref = project.read(cx); + let worktree_root = project_ref + .visible_worktrees(cx) + .next() + .map(|worktree| worktree.read(cx).abs_path()); + let repository = project_ref.active_repository(cx); + (worktree_root, repository) + }; + + let (Some(worktree_root), Some(repository)) = (worktree_root, repository) else { + log::error!("CaptureExampleSpec: missing worktree or active repository"); + return; + }; + + let repository_snapshot = repository.read(cx).snapshot(); + if worktree_root.as_ref() != repository_snapshot.work_directory_abs_path.as_ref() { + log::error!( + "repository is not at worktree root (repo={:?}, worktree={:?})", + repository_snapshot.work_directory_abs_path, + worktree_root + ); + return; + } + + let Some(repository_url) = repository_snapshot + .remote_origin_url + .clone() + .or_else(|| repository_snapshot.remote_upstream_url.clone()) + else { + log::error!("active repository has no origin/upstream remote url"); + return; + }; + + let Some(revision) = repository_snapshot + .head_commit + .as_ref() + .map(|commit| commit.sha.to_string()) + else { + log::error!("active repository has no head commit"); + return; + }; + + let mut events = ep_store.update(cx, |store, cx| { + store.edit_history_for_project_with_pause_split_last_event(&project, cx) + }); + + let Some(editor) = workspace.active_item_as::(cx) else { + log::error!("no active editor"); + return; + }; + + let Some(project_path) = editor.read(cx).project_path(cx) else { + log::error!("active editor has no project path"); + return; + }; + + let Some((buffer, cursor_anchor)) = editor + .read(cx) + .buffer() + .read(cx) + .text_anchor_for_position(editor.read(cx).selections.newest_anchor().head(), cx) + else { + log::error!("failed to resolve cursor buffer/anchor"); + return; + }; + + let snapshot = buffer.read(cx).snapshot(); + let cursor_point = cursor_anchor.to_point(&snapshot); + let (_editable_range, context_range) = + edit_prediction::cursor_excerpt::editable_and_context_ranges_for_cursor_position( + cursor_point, + &snapshot, + 100, + 50, + ); + + let cursor_path: Arc = repository + .read(cx) + .project_path_to_repo_path(&project_path, cx) + .map(|repo_path| Path::new(repo_path.as_unix_str()).into()) + .unwrap_or_else(|| Path::new(project_path.path.as_unix_str()).into()); + + let cursor_position = { + let context_start_offset = context_range.start.to_offset(&snapshot); + let cursor_offset = cursor_anchor.to_offset(&snapshot); + let cursor_offset_in_excerpt = cursor_offset.saturating_sub(context_start_offset); + let mut excerpt = snapshot.text_for_range(context_range).collect::(); + if cursor_offset_in_excerpt <= excerpt.len() { + excerpt.insert_str(cursor_offset_in_excerpt, zeta_prompt::CURSOR_MARKER); + } + excerpt + }; + + let markdown_language = workspace + .app_state() + .languages + .language_for_name("Markdown"); + + cx.spawn_in(window, async move |workspace_entity, cx| { + let markdown_language = markdown_language.await?; + + let uncommitted_diff_rx = repository.update(cx, |repository, cx| { + repository.diff(DiffType::HeadToWorktree, cx) + })?; + + let uncommitted_diff = match uncommitted_diff_rx.await { + Ok(Ok(diff)) => diff, + Ok(Err(error)) => { + log::error!("failed to compute uncommitted diff: {error:#}"); + return Ok(()); + } + Err(error) => { + log::error!("uncommitted diff channel dropped: {error:#}"); + return Ok(()); + } + }; + + let mut edit_history = String::new(); + let mut expected_patch = String::new(); + if let Some(last_event) = events.pop() { + for event in &events { + zeta_prompt::write_event(&mut edit_history, event); + if !edit_history.ends_with('\n') { + edit_history.push('\n'); + } + edit_history.push('\n'); + } + + zeta_prompt::write_event(&mut expected_patch, &last_event); + } + + let format = + time::format_description::parse("[year]-[month]-[day] [hour]:[minute]:[second]"); + let name = match format { + Ok(format) => { + let now = time::OffsetDateTime::now_local() + .unwrap_or_else(|_| time::OffsetDateTime::now_utc()); + now.format(&format) + .unwrap_or_else(|_| "unknown-time".to_string()) + } + Err(_) => "unknown-time".to_string(), + }; + + let markdown = ExampleSpec { + name, + repository_url, + revision, + uncommitted_diff, + cursor_path, + cursor_position, + edit_history, + expected_patch, + } + .to_markdown(); + + let buffer = project + .update(cx, |project, cx| project.create_buffer(false, cx))? + .await?; + buffer.update(cx, |buffer, cx| { + buffer.set_text(markdown, cx); + buffer.set_language(Some(markdown_language), cx); + })?; + + workspace_entity.update_in(cx, |workspace, window, cx| { + workspace.add_item_to_active_pane( + Box::new( + cx.new(|cx| Editor::for_buffer(buffer, Some(project.clone()), window, cx)), + ), + None, + true, + window, + cx, + ); + }) + }) + .detach_and_log_err(cx); +} From 0c47984a1940ff7dab1183651788fff0e6b7eb95 Mon Sep 17 00:00:00 2001 From: Michael Benfield Date: Sun, 14 Dec 2025 22:55:41 -0800 Subject: [PATCH 261/621] New evals for inline assistant (#44431) Also factor out some common code in the evals. Release Notes: - N/A --------- Co-authored-by: Mikayla Maki --- crates/agent/src/edit_agent/evals.rs | 1 + crates/agent_ui/Cargo.toml | 5 +- crates/agent_ui/src/agent_ui.rs | 2 - crates/agent_ui/src/buffer_codegen.rs | 184 +++++++----- crates/agent_ui/src/evals.rs | 89 ------ crates/agent_ui/src/inline_assistant.rs | 283 +++++++++++++++--- crates/agent_ui/src/inline_prompt_editor.rs | 12 +- crates/eval_utils/src/eval_utils.rs | 18 ++ crates/feature_flags/src/flags.rs | 2 +- .../language_models/src/provider/mistral.rs | 21 +- 10 files changed, 394 insertions(+), 223 deletions(-) delete mode 100644 crates/agent_ui/src/evals.rs diff --git a/crates/agent/src/edit_agent/evals.rs b/crates/agent/src/edit_agent/evals.rs index edf8a0f671d231b3bfbd29526c256388fd41f85a..01c81e0103a2d3624c7e8eb9b9c587726fcc4876 100644 --- a/crates/agent/src/edit_agent/evals.rs +++ b/crates/agent/src/edit_agent/evals.rs @@ -1343,6 +1343,7 @@ fn run_eval(eval: EvalInput) -> eval_utils::EvalOutput { let test = EditAgentTest::new(&mut cx).await; test.eval(eval, &mut cx).await }); + cx.quit(); match result { Ok(output) => eval_utils::EvalOutput { data: output.to_string(), diff --git a/crates/agent_ui/Cargo.toml b/crates/agent_ui/Cargo.toml index b235799635ce81b02fd6fcd5d4d7a53a6957eb77..38580b4d2c61597718d9fb718a20e52e84222481 100644 --- a/crates/agent_ui/Cargo.toml +++ b/crates/agent_ui/Cargo.toml @@ -13,7 +13,7 @@ path = "src/agent_ui.rs" doctest = false [features] -test-support = ["gpui/test-support", "language/test-support", "reqwest_client"] +test-support = ["assistant_text_thread/test-support", "eval_utils", "gpui/test-support", "language/test-support", "reqwest_client", "workspace/test-support"] unit-eval = [] [dependencies] @@ -40,6 +40,7 @@ component.workspace = true context_server.workspace = true db.workspace = true editor.workspace = true +eval_utils = { workspace = true, optional = true } extension.workspace = true extension_host.workspace = true feature_flags.workspace = true @@ -71,6 +72,7 @@ postage.workspace = true project.workspace = true prompt_store.workspace = true proto.workspace = true +rand.workspace = true release_channel.workspace = true rope.workspace = true rules_library.workspace = true @@ -119,7 +121,6 @@ language_model = { workspace = true, "features" = ["test-support"] } pretty_assertions.workspace = true project = { workspace = true, features = ["test-support"] } semver.workspace = true -rand.workspace = true reqwest_client.workspace = true tree-sitter-md.workspace = true unindent.workspace = true diff --git a/crates/agent_ui/src/agent_ui.rs b/crates/agent_ui/src/agent_ui.rs index cd6113bfa6c611c8d2a6b9d43294e77737b7a9ae..91fccc5fca0221cc72b0972801bf4da382cedee8 100644 --- a/crates/agent_ui/src/agent_ui.rs +++ b/crates/agent_ui/src/agent_ui.rs @@ -7,8 +7,6 @@ mod buffer_codegen; mod completion_provider; mod context; mod context_server_configuration; -#[cfg(test)] -mod evals; mod inline_assistant; mod inline_prompt_editor; mod language_model_selector; diff --git a/crates/agent_ui/src/buffer_codegen.rs b/crates/agent_ui/src/buffer_codegen.rs index bb05d5e04deb06f82dfc8e5dae0d871648f1d11e..235aea092686e669c029e8c9c7741500c23d14cb 100644 --- a/crates/agent_ui/src/buffer_codegen.rs +++ b/crates/agent_ui/src/buffer_codegen.rs @@ -41,7 +41,6 @@ use std::{ time::Instant, }; use streaming_diff::{CharOperation, LineDiff, LineOperation, StreamingDiff}; -use ui::SharedString; /// Use this tool to provide a message to the user when you're unable to complete a task. #[derive(Debug, Serialize, Deserialize, JsonSchema)] @@ -56,16 +55,16 @@ pub struct FailureMessageInput { /// Replaces text in tags with your replacement_text. #[derive(Debug, Serialize, Deserialize, JsonSchema)] pub struct RewriteSectionInput { + /// The text to replace the section with. + #[serde(default)] + pub replacement_text: String, + /// A brief description of the edit you have made. /// /// The description may use markdown formatting if you wish. /// This is optional - if the edit is simple or obvious, you should leave it empty. #[serde(default)] pub description: String, - - /// The text to replace the section with. - #[serde(default)] - pub replacement_text: String, } pub struct BufferCodegen { @@ -287,8 +286,9 @@ pub struct CodegenAlternative { completion: Option, selected_text: Option, pub message_id: Option, - pub model_explanation: Option, session_id: Uuid, + pub description: Option, + pub failure: Option, } impl EventEmitter for CodegenAlternative {} @@ -346,8 +346,9 @@ impl CodegenAlternative { elapsed_time: None, completion: None, selected_text: None, - model_explanation: None, session_id, + description: None, + failure: None, _subscription: cx.subscribe(&buffer, Self::handle_buffer_event), } } @@ -920,6 +921,16 @@ impl CodegenAlternative { self.completion.clone() } + #[cfg(any(test, feature = "test-support"))] + pub fn current_description(&self) -> Option { + self.description.clone() + } + + #[cfg(any(test, feature = "test-support"))] + pub fn current_failure(&self) -> Option { + self.failure.clone() + } + pub fn selected_text(&self) -> Option<&str> { self.selected_text.as_deref() } @@ -1133,32 +1144,69 @@ impl CodegenAlternative { } }; + enum ToolUseOutput { + Rewrite { + text: String, + description: Option, + }, + Failure(String), + } + + enum ModelUpdate { + Description(String), + Failure(String), + } + let chars_read_so_far = Arc::new(Mutex::new(0usize)); - let tool_to_text_and_message = - move |tool_use: LanguageModelToolUse| -> (Option, Option) { - let mut chars_read_so_far = chars_read_so_far.lock(); - match tool_use.name.as_ref() { - "rewrite_section" => { - let Ok(mut input) = - serde_json::from_value::(tool_use.input) - else { - return (None, None); - }; - let value = input.replacement_text[*chars_read_so_far..].to_string(); - *chars_read_so_far = input.replacement_text.len(); - (Some(value), Some(std::mem::take(&mut input.description))) - } - "failure_message" => { - let Ok(mut input) = - serde_json::from_value::(tool_use.input) - else { - return (None, None); - }; - (None, Some(std::mem::take(&mut input.message))) + let process_tool_use = move |tool_use: LanguageModelToolUse| -> Option { + let mut chars_read_so_far = chars_read_so_far.lock(); + let is_complete = tool_use.is_input_complete; + match tool_use.name.as_ref() { + "rewrite_section" => { + let Ok(mut input) = + serde_json::from_value::(tool_use.input) + else { + return None; + }; + let text = input.replacement_text[*chars_read_so_far..].to_string(); + *chars_read_so_far = input.replacement_text.len(); + let description = is_complete + .then(|| { + let desc = std::mem::take(&mut input.description); + if desc.is_empty() { None } else { Some(desc) } + }) + .flatten(); + Some(ToolUseOutput::Rewrite { text, description }) + } + "failure_message" => { + if !is_complete { + return None; } - _ => (None, None), + let Ok(mut input) = + serde_json::from_value::(tool_use.input) + else { + return None; + }; + Some(ToolUseOutput::Failure(std::mem::take(&mut input.message))) } - }; + _ => None, + } + }; + + let (message_tx, mut message_rx) = futures::channel::mpsc::unbounded::(); + + cx.spawn({ + let codegen = codegen.clone(); + async move |cx| { + while let Some(update) = message_rx.next().await { + let _ = codegen.update(cx, |this, _cx| match update { + ModelUpdate::Description(d) => this.description = Some(d), + ModelUpdate::Failure(f) => this.failure = Some(f), + }); + } + } + }) + .detach(); let mut message_id = None; let mut first_text = None; @@ -1171,24 +1219,23 @@ impl CodegenAlternative { Ok(LanguageModelCompletionEvent::StartMessage { message_id: id }) => { message_id = Some(id); } - Ok(LanguageModelCompletionEvent::ToolUse(tool_use)) - if matches!( - tool_use.name.as_ref(), - "rewrite_section" | "failure_message" - ) => - { - let is_complete = tool_use.is_input_complete; - let (text, message) = tool_to_text_and_message(tool_use); - // Only update the model explanation if the tool use is complete. - // Otherwise the UI element bounces around as it's updated. - if is_complete { - let _ = codegen.update(cx, |this, _cx| { - this.model_explanation = message.map(Into::into); - }); - } - first_text = text; - if first_text.is_some() { - break; + Ok(LanguageModelCompletionEvent::ToolUse(tool_use)) => { + if let Some(output) = process_tool_use(tool_use) { + let (text, update) = match output { + ToolUseOutput::Rewrite { text, description } => { + (Some(text), description.map(ModelUpdate::Description)) + } + ToolUseOutput::Failure(message) => { + (None, Some(ModelUpdate::Failure(message))) + } + }; + if let Some(update) = update { + let _ = message_tx.unbounded_send(update); + } + first_text = text; + if first_text.is_some() { + break; + } } } Ok(LanguageModelCompletionEvent::UsageUpdate(token_usage)) => { @@ -1215,41 +1262,30 @@ impl CodegenAlternative { return; }; - let (message_tx, mut message_rx) = futures::channel::mpsc::unbounded(); - - cx.spawn({ - let codegen = codegen.clone(); - async move |cx| { - while let Some(message) = message_rx.next().await { - let _ = codegen.update(cx, |this, _cx| { - this.model_explanation = message; - }); - } - } - }) - .detach(); - let move_last_token_usage = last_token_usage.clone(); let text_stream = Box::pin(futures::stream::once(async { Ok(first_text) }).chain( completion_events.filter_map(move |e| { - let tool_to_text_and_message = tool_to_text_and_message.clone(); + let process_tool_use = process_tool_use.clone(); let last_token_usage = move_last_token_usage.clone(); let total_text = total_text.clone(); let mut message_tx = message_tx.clone(); async move { match e { - Ok(LanguageModelCompletionEvent::ToolUse(tool_use)) - if matches!( - tool_use.name.as_ref(), - "rewrite_section" | "failure_message" - ) => - { - let is_complete = tool_use.is_input_complete; - let (text, message) = tool_to_text_and_message(tool_use); - if is_complete { - // Again only send the message when complete to not get a bouncing UI element. - let _ = message_tx.send(message.map(Into::into)).await; + Ok(LanguageModelCompletionEvent::ToolUse(tool_use)) => { + let Some(output) = process_tool_use(tool_use) else { + return None; + }; + let (text, update) = match output { + ToolUseOutput::Rewrite { text, description } => { + (Some(text), description.map(ModelUpdate::Description)) + } + ToolUseOutput::Failure(message) => { + (None, Some(ModelUpdate::Failure(message))) + } + }; + if let Some(update) = update { + let _ = message_tx.send(update).await; } text.map(Ok) } diff --git a/crates/agent_ui/src/evals.rs b/crates/agent_ui/src/evals.rs deleted file mode 100644 index e82d21bd1fdb02a666c61bdf4754f27e79f92fda..0000000000000000000000000000000000000000 --- a/crates/agent_ui/src/evals.rs +++ /dev/null @@ -1,89 +0,0 @@ -use std::str::FromStr; - -use crate::inline_assistant::test::run_inline_assistant_test; - -use eval_utils::{EvalOutput, NoProcessor}; -use gpui::TestAppContext; -use language_model::{LanguageModelRegistry, SelectedModel}; -use rand::{SeedableRng as _, rngs::StdRng}; - -#[test] -#[cfg_attr(not(feature = "unit-eval"), ignore)] -fn eval_single_cursor_edit() { - eval_utils::eval(20, 1.0, NoProcessor, move || { - run_eval( - &EvalInput { - prompt: "Rename this variable to buffer_text".to_string(), - buffer: indoc::indoc! {" - struct EvalExampleStruct { - text: Strˇing, - prompt: String, - } - "} - .to_string(), - }, - &|_, output| { - let expected = indoc::indoc! {" - struct EvalExampleStruct { - buffer_text: String, - prompt: String, - } - "}; - if output == expected { - EvalOutput { - outcome: eval_utils::OutcomeKind::Passed, - data: "Passed!".to_string(), - metadata: (), - } - } else { - EvalOutput { - outcome: eval_utils::OutcomeKind::Failed, - data: format!("Failed to rename variable, output: {}", output), - metadata: (), - } - } - }, - ) - }); -} - -struct EvalInput { - buffer: String, - prompt: String, -} - -fn run_eval( - input: &EvalInput, - judge: &dyn Fn(&EvalInput, &str) -> eval_utils::EvalOutput<()>, -) -> eval_utils::EvalOutput<()> { - let dispatcher = gpui::TestDispatcher::new(StdRng::from_os_rng()); - let mut cx = TestAppContext::build(dispatcher, None); - cx.skip_drawing(); - - let buffer_text = run_inline_assistant_test( - input.buffer.clone(), - input.prompt.clone(), - |cx| { - // Reconfigure to use a real model instead of the fake one - let model_name = std::env::var("ZED_AGENT_MODEL") - .unwrap_or("anthropic/claude-sonnet-4-latest".into()); - - let selected_model = SelectedModel::from_str(&model_name) - .expect("Invalid model format. Use 'provider/model-id'"); - - log::info!("Selected model: {selected_model:?}"); - - cx.update(|_, cx| { - LanguageModelRegistry::global(cx).update(cx, |registry, cx| { - registry.select_inline_assistant_model(Some(&selected_model), cx); - }); - }); - }, - |_cx| { - log::info!("Waiting for actual response from the LLM..."); - }, - &mut cx, - ); - - judge(input, &buffer_text) -} diff --git a/crates/agent_ui/src/inline_assistant.rs b/crates/agent_ui/src/inline_assistant.rs index 0eb96b3712623cc08632ede6c7836ed09499c02d..d036032e77d74dd905001affd9aba0010bc4f8eb 100644 --- a/crates/agent_ui/src/inline_assistant.rs +++ b/crates/agent_ui/src/inline_assistant.rs @@ -117,14 +117,6 @@ impl InlineAssistant { } } - #[cfg(any(test, feature = "test-support"))] - pub fn set_completion_receiver( - &mut self, - sender: mpsc::UnboundedSender>, - ) { - self._inline_assistant_completions = Some(sender); - } - pub fn register_workspace( &mut self, workspace: &Entity, @@ -1593,6 +1585,27 @@ impl InlineAssistant { .map(InlineAssistTarget::Terminal) } } + + #[cfg(any(test, feature = "test-support"))] + pub fn set_completion_receiver( + &mut self, + sender: mpsc::UnboundedSender>, + ) { + self._inline_assistant_completions = Some(sender); + } + + #[cfg(any(test, feature = "test-support"))] + pub fn get_codegen( + &mut self, + assist_id: InlineAssistId, + cx: &mut App, + ) -> Option> { + self.assists.get(&assist_id).map(|inline_assist| { + inline_assist + .codegen + .update(cx, |codegen, _cx| codegen.active_alternative().clone()) + }) + } } struct EditorInlineAssists { @@ -2014,8 +2027,10 @@ fn merge_ranges(ranges: &mut Vec>, buffer: &MultiBufferSnapshot) { } } -#[cfg(any(test, feature = "test-support"))] +#[cfg(any(test, feature = "unit-eval"))] +#[cfg_attr(not(test), allow(dead_code))] pub mod test { + use std::sync::Arc; use agent::HistoryStore; @@ -2026,7 +2041,6 @@ pub mod test { use futures::channel::mpsc; use gpui::{AppContext, TestAppContext, UpdateGlobal as _}; use language::Buffer; - use language_model::LanguageModelRegistry; use project::Project; use prompt_store::PromptBuilder; use smol::stream::StreamExt as _; @@ -2035,13 +2049,43 @@ pub mod test { use crate::InlineAssistant; + #[derive(Debug)] + pub enum InlineAssistantOutput { + Success { + completion: Option, + description: Option, + full_buffer_text: String, + }, + Failure { + failure: String, + }, + // These fields are used for logging + #[allow(unused)] + Malformed { + completion: Option, + description: Option, + failure: Option, + }, + } + + impl InlineAssistantOutput { + pub fn buffer_text(&self) -> &str { + match self { + InlineAssistantOutput::Success { + full_buffer_text, .. + } => full_buffer_text, + _ => "", + } + } + } + pub fn run_inline_assistant_test( base_buffer: String, prompt: String, setup: SetupF, test: TestF, cx: &mut TestAppContext, - ) -> String + ) -> InlineAssistantOutput where SetupF: FnOnce(&mut gpui::VisualTestContext), TestF: FnOnce(&mut gpui::VisualTestContext), @@ -2133,39 +2177,198 @@ pub mod test { test(cx); - cx.executor() - .block_test(async { completion_rx.next().await }); + let assist_id = cx + .executor() + .block_test(async { completion_rx.next().await }) + .unwrap() + .unwrap(); + + let (completion, description, failure) = cx.update(|_, cx| { + InlineAssistant::update_global(cx, |inline_assistant, cx| { + let codegen = inline_assistant.get_codegen(assist_id, cx).unwrap(); + + let completion = codegen.read(cx).current_completion(); + let description = codegen.read(cx).current_description(); + let failure = codegen.read(cx).current_failure(); - buffer.read_with(cx, |buffer, _| buffer.text()) + (completion, description, failure) + }) + }); + + if failure.is_some() && (completion.is_some() || description.is_some()) { + InlineAssistantOutput::Malformed { + completion, + description, + failure, + } + } else if let Some(failure) = failure { + InlineAssistantOutput::Failure { failure } + } else { + InlineAssistantOutput::Success { + completion, + description, + full_buffer_text: buffer.read_with(cx, |buffer, _| buffer.text()), + } + } } +} - #[allow(unused)] - pub fn test_inline_assistant( - base_buffer: &'static str, - llm_output: &'static str, - cx: &mut TestAppContext, - ) -> String { - run_inline_assistant_test( - base_buffer.to_string(), - "Prompt doesn't matter because we're using a fake model".to_string(), - |cx| { - cx.update(|_, cx| LanguageModelRegistry::test(cx)); - }, - |cx| { - let fake_model = cx.update(|_, cx| { - LanguageModelRegistry::global(cx) - .update(cx, |registry, _| registry.fake_model()) - }); - let fake = fake_model.as_fake(); +#[cfg(any(test, feature = "unit-eval"))] +#[cfg_attr(not(test), allow(dead_code))] +pub mod evals { + use std::str::FromStr; + + use eval_utils::{EvalOutput, NoProcessor}; + use gpui::TestAppContext; + use language_model::{LanguageModelRegistry, SelectedModel}; + use rand::{SeedableRng as _, rngs::StdRng}; + + use crate::inline_assistant::test::{InlineAssistantOutput, run_inline_assistant_test}; + + #[test] + #[cfg_attr(not(feature = "unit-eval"), ignore)] + fn eval_single_cursor_edit() { + run_eval( + 20, + 1.0, + "Rename this variable to buffer_text".to_string(), + indoc::indoc! {" + struct EvalExampleStruct { + text: Strˇing, + prompt: String, + } + "} + .to_string(), + exact_buffer_match(indoc::indoc! {" + struct EvalExampleStruct { + buffer_text: String, + prompt: String, + } + "}), + ); + } - // let fake = fake_model; - fake.send_last_completion_stream_text_chunk(llm_output.to_string()); - fake.end_last_completion_stream(); + #[test] + #[cfg_attr(not(feature = "unit-eval"), ignore)] + fn eval_cant_do() { + run_eval( + 20, + 1.0, + "Rename the struct to EvalExampleStructNope", + indoc::indoc! {" + struct EvalExampleStruct { + text: Strˇing, + prompt: String, + } + "}, + uncertain_output, + ); + } - // Run again to process the model's response - cx.run_until_parked(); - }, - cx, - ) + #[test] + #[cfg_attr(not(feature = "unit-eval"), ignore)] + fn eval_unclear() { + run_eval( + 20, + 1.0, + "Make exactly the change I want you to make", + indoc::indoc! {" + struct EvalExampleStruct { + text: Strˇing, + prompt: String, + } + "}, + uncertain_output, + ); + } + + fn run_eval( + iterations: usize, + expected_pass_ratio: f32, + prompt: impl Into, + buffer: impl Into, + judge: impl Fn(InlineAssistantOutput) -> eval_utils::EvalOutput<()> + Send + Sync + 'static, + ) { + let buffer = buffer.into(); + let prompt = prompt.into(); + + eval_utils::eval(iterations, expected_pass_ratio, NoProcessor, move || { + let dispatcher = gpui::TestDispatcher::new(StdRng::from_os_rng()); + let mut cx = TestAppContext::build(dispatcher, None); + cx.skip_drawing(); + + let output = run_inline_assistant_test( + buffer.clone(), + prompt.clone(), + |cx| { + // Reconfigure to use a real model instead of the fake one + let model_name = std::env::var("ZED_AGENT_MODEL") + .unwrap_or("anthropic/claude-sonnet-4-latest".into()); + + let selected_model = SelectedModel::from_str(&model_name) + .expect("Invalid model format. Use 'provider/model-id'"); + + log::info!("Selected model: {selected_model:?}"); + + cx.update(|_, cx| { + LanguageModelRegistry::global(cx).update(cx, |registry, cx| { + registry.select_inline_assistant_model(Some(&selected_model), cx); + }); + }); + }, + |_cx| { + log::info!("Waiting for actual response from the LLM..."); + }, + &mut cx, + ); + + cx.quit(); + + judge(output) + }); + } + + fn uncertain_output(output: InlineAssistantOutput) -> EvalOutput<()> { + match &output { + o @ InlineAssistantOutput::Success { + completion, + description, + .. + } => { + if description.is_some() && completion.is_none() { + EvalOutput::passed(format!( + "Assistant produced no completion, but a description:\n{}", + description.as_ref().unwrap() + )) + } else { + EvalOutput::failed(format!("Assistant produced a completion:\n{:?}", o)) + } + } + InlineAssistantOutput::Failure { + failure: error_message, + } => EvalOutput::passed(format!( + "Assistant produced a failure message: {}", + error_message + )), + o @ InlineAssistantOutput::Malformed { .. } => { + EvalOutput::failed(format!("Assistant produced a malformed response:\n{:?}", o)) + } + } + } + + fn exact_buffer_match( + correct_output: impl Into, + ) -> impl Fn(InlineAssistantOutput) -> EvalOutput<()> { + let correct_output = correct_output.into(); + move |output| { + if output.buffer_text() == correct_output { + EvalOutput::passed("Assistant output matches") + } else { + EvalOutput::failed(format!( + "Assistant output does not match expected output: {:?}", + output + )) + } + } } } diff --git a/crates/agent_ui/src/inline_prompt_editor.rs b/crates/agent_ui/src/inline_prompt_editor.rs index e262cda87899b0314c9fd8909f5718b4fd7dbfda..278216e28ec6304a9fc596c8456921fb1f1ebdfd 100644 --- a/crates/agent_ui/src/inline_prompt_editor.rs +++ b/crates/agent_ui/src/inline_prompt_editor.rs @@ -101,11 +101,11 @@ impl Render for PromptEditor { let left_gutter_width = gutter.full_width() + (gutter.margin / 2.0); let right_padding = editor_margins.right + RIGHT_PADDING; - let explanation = codegen - .active_alternative() - .read(cx) - .model_explanation - .clone(); + let active_alternative = codegen.active_alternative().read(cx); + let explanation = active_alternative + .description + .clone() + .or_else(|| active_alternative.failure.clone()); (left_gutter_width, right_padding, explanation) } @@ -139,7 +139,7 @@ impl Render for PromptEditor { if let Some(explanation) = &explanation { markdown.update(cx, |markdown, cx| { - markdown.reset(explanation.clone(), cx); + markdown.reset(SharedString::from(explanation), cx); }); } diff --git a/crates/eval_utils/src/eval_utils.rs b/crates/eval_utils/src/eval_utils.rs index 880b1a97e414bbc3219bdf8f7163dbf9b6c9c82b..be3294ed1490d6a602c3a5282d25dbba7d065443 100644 --- a/crates/eval_utils/src/eval_utils.rs +++ b/crates/eval_utils/src/eval_utils.rs @@ -40,6 +40,24 @@ pub struct EvalOutput { pub metadata: M, } +impl EvalOutput { + pub fn passed(message: impl Into) -> Self { + EvalOutput { + outcome: OutcomeKind::Passed, + data: message.into(), + metadata: M::default(), + } + } + + pub fn failed(message: impl Into) -> Self { + EvalOutput { + outcome: OutcomeKind::Failed, + data: message.into(), + metadata: M::default(), + } + } +} + pub struct NoProcessor; impl EvalOutputProcessor for NoProcessor { type Metadata = (); diff --git a/crates/feature_flags/src/flags.rs b/crates/feature_flags/src/flags.rs index 566d5604149567702e8739d2f3ac9fdc6f5f0de8..0d474878f999bc773baff7664ca0305c2031c171 100644 --- a/crates/feature_flags/src/flags.rs +++ b/crates/feature_flags/src/flags.rs @@ -18,6 +18,6 @@ impl FeatureFlag for InlineAssistantUseToolFeatureFlag { const NAME: &'static str = "inline-assistant-use-tool"; fn enabled_for_staff() -> bool { - false + true } } diff --git a/crates/language_models/src/provider/mistral.rs b/crates/language_models/src/provider/mistral.rs index 1078e2d7f7841d7ad05284e10a9f862236966ebc..3e99f32be8224bb2b9973feccb0ce973b58eaaed 100644 --- a/crates/language_models/src/provider/mistral.rs +++ b/crates/language_models/src/provider/mistral.rs @@ -17,7 +17,7 @@ use settings::{Settings, SettingsStore}; use std::collections::HashMap; use std::pin::Pin; use std::str::FromStr; -use std::sync::{Arc, LazyLock, OnceLock}; +use std::sync::{Arc, LazyLock}; use strum::IntoEnumIterator; use ui::{ButtonLink, ConfiguredApiCard, List, ListBulletItem, prelude::*}; use ui_input::InputField; @@ -31,7 +31,6 @@ static API_KEY_ENV_VAR: LazyLock = env_var!(API_KEY_ENV_VAR_NAME); const CODESTRAL_API_KEY_ENV_VAR_NAME: &str = "CODESTRAL_API_KEY"; static CODESTRAL_API_KEY_ENV_VAR: LazyLock = env_var!(CODESTRAL_API_KEY_ENV_VAR_NAME); -static CODESTRAL_API_KEY: OnceLock> = OnceLock::new(); #[derive(Default, Clone, Debug, PartialEq)] pub struct MistralSettings { @@ -49,14 +48,18 @@ pub struct State { codestral_api_key_state: Entity, } +struct CodestralApiKey(Entity); +impl Global for CodestralApiKey {} + pub fn codestral_api_key(cx: &mut App) -> Entity { - return CODESTRAL_API_KEY - .get_or_init(|| { - cx.new(|_| { - ApiKeyState::new(CODESTRAL_API_URL.into(), CODESTRAL_API_KEY_ENV_VAR.clone()) - }) - }) - .clone(); + if cx.has_global::() { + cx.global::().0.clone() + } else { + let api_key_state = cx + .new(|_| ApiKeyState::new(CODESTRAL_API_URL.into(), CODESTRAL_API_KEY_ENV_VAR.clone())); + cx.set_global(CodestralApiKey(api_key_state.clone())); + api_key_state + } } impl State { From 6cab835003e5e083aa3ed8dc61223e0b2cc59026 Mon Sep 17 00:00:00 2001 From: rari404 <138394996+edlsh@users.noreply.github.com> Date: Mon, 15 Dec 2025 02:12:24 -0500 Subject: [PATCH 262/621] terminal: Remove SHLVL from terminal environment to fix incorrect shell level (#44835) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #33958 ## Problem When opening a terminal in Zed, `SHLVL` incorrectly starts at 2 instead of 1. On `workspace: reload`, it increases by 2 instead of 1. ## Root Cause 1. Zed's `shell_env::capture()` spawns a login shell (`-l -i -c`) to capture the user's environment, which increments `SHLVL` 2. The captured `SHLVL` is passed through to the PTY options 3. When alacritty_terminal spawns the user's shell, it increments `SHLVL` again Result: `SHLVL` = captured value + 1 = 2 (when launched from Finder) ## Solution Remove `SHLVL` from the environment in `TerminalBuilder::new()` before passing it to alacritty_terminal. This allows the spawned shell to initialize `SHLVL` to 1 on its own, matching the behavior of standalone terminal emulators like iTerm2, Kitty, and Alacritty. ## Testing - Launch Zed from Finder → open terminal → `echo $SHLVL` → should output `1` - Launch Zed from shell → open terminal → `echo $SHLVL` → should output `1` - `workspace: reload` → open terminal → `echo $SHLVL` → should remain `1` - Tested with bash, zsh, fish Release Notes: - Fixed terminal `$SHLVL` starting at 2 instead of 1 ([#33958](https://github.com/zed-industries/zed/issues/33958)) --- crates/terminal/src/terminal.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/terminal/src/terminal.rs b/crates/terminal/src/terminal.rs index caca93eac5b862450cdaa2aede0fd5491eaaf58f..e6bb454fa296b65de60c25f326bba28f484450f0 100644 --- a/crates/terminal/src/terminal.rs +++ b/crates/terminal/src/terminal.rs @@ -420,6 +420,10 @@ impl TerminalBuilder { ) -> Task> { let version = release_channel::AppVersion::global(cx); let fut = async move { + // Remove SHLVL so the spawned shell initializes it to 1, matching + // the behavior of standalone terminal emulators like iTerm2/Kitty/Alacritty. + env.remove("SHLVL"); + // If the parent environment doesn't have a locale set // (As is the case when launched from a .app on MacOS), // and the Project doesn't have a locale set, then From c2c8b4b9fbf39a6d37447495718022d967483fb7 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Mon, 15 Dec 2025 08:13:08 +0100 Subject: [PATCH 263/621] terminal: Fix hyperlinks for `file://` schemas windows drive URIs (#44847) Closes https://github.com/zed-industries/zed/issues/39189 Release Notes: - Fixed terminal hyperlinking not working for `file://` schemes with windows drive letters --- crates/terminal/Cargo.toml | 2 +- crates/terminal/src/terminal_hyperlinks.rs | 28 +++++++++++++--------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/crates/terminal/Cargo.toml b/crates/terminal/Cargo.toml index 1266c5a6e5c2141be4255530d062f22cd87046fd..9b4302d02fc0a101cc609274b0abc42105402174 100644 --- a/crates/terminal/Cargo.toml +++ b/crates/terminal/Cargo.toml @@ -38,6 +38,7 @@ smol.workspace = true task.workspace = true theme.workspace = true thiserror.workspace = true +url.workspace = true util.workspace = true urlencoding.workspace = true @@ -49,5 +50,4 @@ gpui = { workspace = true, features = ["test-support"] } rand.workspace = true serde_json.workspace = true settings = { workspace = true, features = ["test-support"] } -url.workspace = true util_macros.workspace = true diff --git a/crates/terminal/src/terminal_hyperlinks.rs b/crates/terminal/src/terminal_hyperlinks.rs index 71a1634076b7081cce4f5cbaa155e7eec5d7f57e..cff27c4567cca84b2310723bf73bfda8d58c166d 100644 --- a/crates/terminal/src/terminal_hyperlinks.rs +++ b/crates/terminal/src/terminal_hyperlinks.rs @@ -14,6 +14,7 @@ use std::{ ops::{Index, Range}, time::{Duration, Instant}, }; +use url::Url; const URL_REGEX: &str = r#"(ipfs:|ipns:|magnet:|mailto:|gemini://|gopher://|https://|http://|news:|file://|git://|ssh:|ftp://)[^\u{0000}-\u{001F}\u{007F}-\u{009F}<>"\s{-}\^⟨⟩`']+"#; const WIDE_CHAR_SPACERS: Flags = @@ -128,8 +129,19 @@ pub(super) fn find_from_grid_point( if is_url { // Treat "file://" IRIs like file paths to ensure // that line numbers at the end of the path are - // handled correctly - if let Some(path) = maybe_url_or_path.strip_prefix("file://") { + // handled correctly. + // Use Url::to_file_path() to properly handle Windows drive letters + // (e.g., file:///C:/path -> C:\path) + if maybe_url_or_path.starts_with("file://") { + if let Ok(url) = Url::parse(&maybe_url_or_path) { + if let Ok(path) = url.to_file_path() { + return (path.to_string_lossy().into_owned(), false, word_match); + } + } + // Fallback: strip file:// prefix if URL parsing fails + let path = maybe_url_or_path + .strip_prefix("file://") + .unwrap_or(&maybe_url_or_path); (path.to_string(), false, word_match) } else { (maybe_url_or_path, true, word_match) @@ -1042,8 +1054,9 @@ mod tests { } mod file_iri { - // File IRIs have a ton of use cases, most of which we currently do not support. A few of - // those cases are documented here as tests which are expected to fail. + // File IRIs have a ton of use cases. Absolute file URIs are supported on all platforms, + // including Windows drive letters (e.g., file:///C:/path) and percent-encoded characters. + // Some cases like relative file IRIs are not supported. // See https://en.wikipedia.org/wiki/File_URI_scheme /// [**`c₀, c₁, …, cₙ;`**]ₒₚₜ := use specified terminal widths of `c₀, c₁, …, cₙ` **columns** @@ -1063,7 +1076,6 @@ mod tests { mod issues { #[cfg(not(target_os = "windows"))] #[test] - #[should_panic(expected = "Path = «/test/Ῥόδος/», at grid cells (0, 0)..=(15, 1)")] fn issue_file_iri_with_percent_encoded_characters() { // Non-space characters // file:///test/Ῥόδος/ @@ -1092,18 +1104,12 @@ mod tests { // See https://en.wikipedia.org/wiki/File_URI_scheme // https://github.com/zed-industries/zed/issues/39189 #[test] - #[should_panic( - expected = r#"Path = «C:\\test\\cool\\index.rs», at grid cells (0, 0)..=(9, 1)"# - )] fn issue_39189() { test_file_iri!("file:///C:/test/cool/index.rs"); test_file_iri!("file:///C:/test/cool/"); } #[test] - #[should_panic( - expected = r#"Path = «C:\\test\\Ῥόδος\\», at grid cells (0, 0)..=(16, 1)"# - )] fn issue_file_iri_with_percent_encoded_characters() { // Non-space characters // file:///test/Ῥόδος/ From 82535a5481ff4e6951859b044b69555fade103be Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Mon, 15 Dec 2025 08:14:48 +0100 Subject: [PATCH 264/621] gpui: Fix use of `libc::sched_param` on musl (#44846) Release Notes: - N/A *or* Added/Fixed/Improved ... --- crates/gpui/src/platform/linux/dispatcher.rs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/crates/gpui/src/platform/linux/dispatcher.rs b/crates/gpui/src/platform/linux/dispatcher.rs index d88eefd2c8a7fc648b20f7a2e520fe40158acd51..c8ae7269edd495669baa6ab0e22e745917f143b2 100644 --- a/crates/gpui/src/platform/linux/dispatcher.rs +++ b/crates/gpui/src/platform/linux/dispatcher.rs @@ -1,18 +1,21 @@ -use crate::{ - GLOBAL_THREAD_TIMINGS, PlatformDispatcher, Priority, PriorityQueueReceiver, - PriorityQueueSender, RealtimePriority, RunnableVariant, THREAD_TIMINGS, TaskLabel, TaskTiming, - ThreadTaskTimings, profiler, -}; use calloop::{ EventLoop, PostAction, channel::{self, Sender}, timer::TimeoutAction, }; +use util::ResultExt; + use std::{ + mem::MaybeUninit, thread, time::{Duration, Instant}, }; -use util::ResultExt; + +use crate::{ + GLOBAL_THREAD_TIMINGS, PlatformDispatcher, Priority, PriorityQueueReceiver, + PriorityQueueSender, RealtimePriority, RunnableVariant, THREAD_TIMINGS, TaskLabel, TaskTiming, + ThreadTaskTimings, profiler, +}; struct TimerAfter { duration: Duration, @@ -228,7 +231,10 @@ impl PlatformDispatcher for LinuxDispatcher { RealtimePriority::Other => 45, }; - let sched_param = libc::sched_param { sched_priority }; + // SAFETY: all sched_param members are valid when initialized to zero. + let mut sched_param = + unsafe { MaybeUninit::::zeroed().assume_init() }; + sched_param.sched_priority = sched_priority; // SAFETY: sched_param is a valid initialized structure let result = unsafe { libc::pthread_setschedparam(thread_id, policy, &sched_param) }; if result != 0 { From 63918b8955d0ac846a1c1d2058b026d4d9d122f5 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Mon, 15 Dec 2025 08:16:48 +0100 Subject: [PATCH 265/621] docs: Document implemented `clangd` extensions (#44308) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Zed currently doesn’t support all protocol extensions implemented by `clangd`, but it does support two: - `textDocument/inactiveRegion` - `textDocument/switchSourceHeader` Release Notes: - N/A --------- Co-authored-by: Kunall Banerjee --- docs/src/languages/cpp.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/docs/src/languages/cpp.md b/docs/src/languages/cpp.md index c20dd58335caca45a6923cc0527605d6cc4b5564..629a0ab640e245bdfec41370fa966589728c2c94 100644 --- a/docs/src/languages/cpp.md +++ b/docs/src/languages/cpp.md @@ -158,3 +158,26 @@ You can use CodeLLDB or GDB to debug native binaries. (Make sure that your build } ] ``` + +## Protocol Extensions + +Zed currently implements the following `clangd` [extensions](https://clangd.llvm.org/extensions): + +### Inactive Regions + +Automatically dims inactive sections of code due to preprocessor directives, such as `#if`, `#ifdef`, or `#ifndef` blocks that evaluate to false. + +### Switch Between Source and Header Files + +Allows switching between corresponding C++ source files (e.g., `.cpp`) and header files (e.g., `.h`). +by running the command {#action editor::SwitchSourceHeader} from the command palette or by setting +a keybinding for the `editor::SwitchSourceHeader` action. + +```json [settings] +{ + "context": "Editor", + "bindings": { + "alt-enter": "editor::SwitchSourceHeader" + } +} +``` From 3db2d03bb3cfc4ad8acaa2d644519d2470599d7f Mon Sep 17 00:00:00 2001 From: Xipeng Jin <56369076+xipeng-jin@users.noreply.github.com> Date: Mon, 15 Dec 2025 02:22:58 -0500 Subject: [PATCH 266/621] Stop spawning ACP/MCP servers with interactive shells (#44826) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### Summary: - Ensure the external agents with ACP servers start via non-interactive shells to prevent shell startup noise from corrupting JSON-RPC. - Apply the same tweak to MCP stdio transports so remote context servers aren’t affected by prompts or greetings. ### Description: Switch both ACP and MCP stdio launch paths to call `ShellBuilder::non_interactive()` before building the command. This removes `-i` on POSIX shells, suppressing prompt/title sequences that previously prefixed the first JSON line and caused `serde_json` parse failures. No functional regressions are expected: both code paths only need a shell for Windows/npm script compatibility, not for interactivity. Release Notes: - Fixed external agents that hung on “Loading…” when shell startup output broke JSON-RPC initialization. --- crates/agent_servers/src/acp.rs | 2 +- crates/context_server/src/transport/stdio_transport.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/agent_servers/src/acp.rs b/crates/agent_servers/src/acp.rs index 41aff48a2092645764d598684d13c1ce61704c44..e99855fe8a7241468e93f01fe6c7b6fee161f600 100644 --- a/crates/agent_servers/src/acp.rs +++ b/crates/agent_servers/src/acp.rs @@ -89,7 +89,7 @@ impl AcpConnection { cx: &mut AsyncApp, ) -> Result { let shell = cx.update(|cx| TerminalSettings::get(None, cx).shell.clone())?; - let builder = ShellBuilder::new(&shell, cfg!(windows)); + let builder = ShellBuilder::new(&shell, cfg!(windows)).non_interactive(); let mut child = builder.build_command(Some(command.path.display().to_string()), &command.args); child diff --git a/crates/context_server/src/transport/stdio_transport.rs b/crates/context_server/src/transport/stdio_transport.rs index 031f348294c04381f1e259b20c7cc818844953b4..e675770e9ee50df9993076e6d71c70befa118c4b 100644 --- a/crates/context_server/src/transport/stdio_transport.rs +++ b/crates/context_server/src/transport/stdio_transport.rs @@ -32,7 +32,7 @@ impl StdioTransport { cx: &AsyncApp, ) -> Result { let shell = cx.update(|cx| TerminalSettings::get(None, cx).shell.clone())?; - let builder = ShellBuilder::new(&shell, cfg!(windows)); + let builder = ShellBuilder::new(&shell, cfg!(windows)).non_interactive(); let mut command = builder.build_command(Some(binary.executable.display().to_string()), &binary.args); From 54c4302cdb2c362ec578f447209e505b9af47eeb Mon Sep 17 00:00:00 2001 From: Lay Sheth Date: Mon, 15 Dec 2025 12:54:57 +0530 Subject: [PATCH 267/621] assistant_slash_commands: Fix AI text thread path display bugs on Windows and all platforms (#41880) ## Fix incorrect directory path folding in slash command file collection **Description:** This PR fixes a bug in the `collect_files` function where the directory folding logic (used to compact chains like `.github/workflows`) failed to reset its state when traversing out of a folded branch. **The Issue:** The `folded_directory_names` accumulator was persisting across loop iterations. If the traversal moved from a folded directory (e.g., `.github/workflows`) to a sibling directory (e.g., `.zed`), the sibling would incorrectly inherit the prefix of the previously folded path, resulting in incorrect paths like `.github/.zed`. **The Fix:** * Introduced `folded_directory_path` to track the specific path currently being folded. * Added a check to reset `folded_directory_names` whenever the traversal encounters an entry that is not a child of the currently folded path. * Ensured state is cleared immediately after a folded directory is rendered. **Release Notes:** - Fixed an issue where using slash commands to collect files would sometimes display incorrect directory paths (e.g., showing `.github/.zed` instead of `.zed`) when adjacent directories were automatically folded. --------- Co-authored-by: Lukas Wirth --- Cargo.lock | 1 - crates/assistant_slash_commands/Cargo.toml | 1 - .../src/file_command.rs | 102 ++++-------------- 3 files changed, 19 insertions(+), 85 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dd57996c7ef6dd711c1e67725d1bdfd86d277729..f829bf138a17828d1887409b8f8ea9b48e35f3c1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -834,7 +834,6 @@ dependencies = [ "fs", "futures 0.3.31", "fuzzy", - "globset", "gpui", "html_to_markdown", "http_client", diff --git a/crates/assistant_slash_commands/Cargo.toml b/crates/assistant_slash_commands/Cargo.toml index 85dd92501f93fb79ba1d3f70b3a06f1077356cfa..b2a70449f449f73c7d0017c5d2ba3707e271559a 100644 --- a/crates/assistant_slash_commands/Cargo.toml +++ b/crates/assistant_slash_commands/Cargo.toml @@ -22,7 +22,6 @@ feature_flags.workspace = true fs.workspace = true futures.workspace = true fuzzy.workspace = true -globset.workspace = true gpui.workspace = true html_to_markdown.workspace = true http_client.workspace = true diff --git a/crates/assistant_slash_commands/src/file_command.rs b/crates/assistant_slash_commands/src/file_command.rs index a17e198ed300f00f70d35149cbe0286af3a65a57..ae4e8363b40d520b9ea33e5cba5ffa68d783ab04 100644 --- a/crates/assistant_slash_commands/src/file_command.rs +++ b/crates/assistant_slash_commands/src/file_command.rs @@ -226,10 +226,10 @@ fn collect_files( let Ok(matchers) = glob_inputs .iter() .map(|glob_input| { - custom_path_matcher::PathMatcher::new(&[glob_input.to_owned()]) + util::paths::PathMatcher::new(&[glob_input.to_owned()], project.read(cx).path_style(cx)) .with_context(|| format!("invalid path {glob_input}")) }) - .collect::>>() + .collect::>>() else { return futures::stream::once(async { anyhow::bail!("invalid path"); @@ -250,6 +250,7 @@ fn collect_files( let worktree_id = snapshot.id(); let path_style = snapshot.path_style(); let mut directory_stack: Vec> = Vec::new(); + let mut folded_directory_path: Option> = None; let mut folded_directory_names: Arc = RelPath::empty().into(); let mut is_top_level_directory = true; @@ -277,6 +278,16 @@ fn collect_files( )))?; } + if let Some(folded_path) = &folded_directory_path { + if !entry.path.starts_with(folded_path) { + folded_directory_names = RelPath::empty().into(); + folded_directory_path = None; + if directory_stack.is_empty() { + is_top_level_directory = true; + } + } + } + let filename = entry.path.file_name().unwrap_or_default().to_string(); if entry.is_dir() { @@ -292,13 +303,17 @@ fn collect_files( folded_directory_names = folded_directory_names.join(RelPath::unix(&filename).unwrap()); } + folded_directory_path = Some(entry.path.clone()); continue; } } else { // Skip empty directories folded_directory_names = RelPath::empty().into(); + folded_directory_path = None; continue; } + + // Render the directory (either folded or normal) if folded_directory_names.is_empty() { let label = if is_top_level_directory { is_top_level_directory = false; @@ -334,6 +349,8 @@ fn collect_files( }, )))?; directory_stack.push(entry.path.clone()); + folded_directory_names = RelPath::empty().into(); + folded_directory_path = None; } events_tx.unbounded_send(Ok(SlashCommandEvent::Content( SlashCommandContent::Text { @@ -447,87 +464,6 @@ pub fn build_entry_output_section( } } -/// This contains a small fork of the util::paths::PathMatcher, that is stricter about the prefix -/// check. Only subpaths pass the prefix check, rather than any prefix. -mod custom_path_matcher { - use globset::{Glob, GlobSet, GlobSetBuilder}; - use std::fmt::Debug as _; - use util::{paths::SanitizedPath, rel_path::RelPath}; - - #[derive(Clone, Debug, Default)] - pub struct PathMatcher { - sources: Vec, - sources_with_trailing_slash: Vec, - glob: GlobSet, - } - - impl std::fmt::Display for PathMatcher { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - self.sources.fmt(f) - } - } - - impl PartialEq for PathMatcher { - fn eq(&self, other: &Self) -> bool { - self.sources.eq(&other.sources) - } - } - - impl Eq for PathMatcher {} - - impl PathMatcher { - pub fn new(globs: &[String]) -> Result { - let globs = globs - .iter() - .map(|glob| Glob::new(&SanitizedPath::new(glob).to_string())) - .collect::, _>>()?; - let sources = globs.iter().map(|glob| glob.glob().to_owned()).collect(); - let sources_with_trailing_slash = globs - .iter() - .map(|glob| glob.glob().to_string() + "/") - .collect(); - let mut glob_builder = GlobSetBuilder::new(); - for single_glob in globs { - glob_builder.add(single_glob); - } - let glob = glob_builder.build()?; - Ok(PathMatcher { - glob, - sources, - sources_with_trailing_slash, - }) - } - - pub fn is_match(&self, other: &RelPath) -> bool { - self.sources - .iter() - .zip(self.sources_with_trailing_slash.iter()) - .any(|(source, with_slash)| { - let as_bytes = other.as_unix_str().as_bytes(); - let with_slash = if source.ends_with('/') { - source.as_bytes() - } else { - with_slash.as_bytes() - }; - - as_bytes.starts_with(with_slash) || as_bytes.ends_with(source.as_bytes()) - }) - || self.glob.is_match(other.as_std_path()) - || self.check_with_end_separator(other) - } - - fn check_with_end_separator(&self, path: &RelPath) -> bool { - let path_str = path.as_unix_str(); - let separator = "/"; - if path_str.ends_with(separator) { - false - } else { - self.glob.is_match(path_str.to_string() + separator) - } - } - } -} - pub fn append_buffer_to_output( buffer: &BufferSnapshot, path: Option<&str>, From 6067436e9b52ba68b811e163ab21513be8869496 Mon Sep 17 00:00:00 2001 From: Vasyl Protsiv Date: Mon, 15 Dec 2025 09:25:50 +0200 Subject: [PATCH 268/621] rope: Optimize rope construction (#44345) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I have noticed you care about `SumTree` (and `Rope`) construction performance, hence using rayon for parallelism and careful `Chunk` splitting to avoid reallocation in `Rope::push`. It seemed strange to me that using multi-threading is that beneficial there, so I tried to investigate why the serial version (`SumTree::from_iter`) is slow in the first place. From my analysis I believe there are two main factors here: 1. `SumTree::from_iter` stores temporary `Node` values in a vector instead of heap-allocating them immediately and storing `SumTree` directly, as `SumTree::from_par_iter` does. 2. `Chunk::new` is quite slow: for some reason the compiler does not vectorize it and seems to struggle to optimize u128 shifts (at least on x86_64). For (1) the solution is simple: allocate `Node` immediately after construction, just like `SumTree::from_par_iter`. For (2) I was able to get better codegen by rewriting it into a simpler per-byte loop and splitting computation into smaller chunks to avoid slow u128 shifts. There was a similar effort recently in #43193 using portable_simd (currently nightly only) to optimize `Chunk::push_str`. From what I understand from that discussion, you seem okay with hand-rolled SIMD for specific architectures. If so, then I also provide sse2 implementation for x86_64. Feel free to remove it if you think this is unnecessary. To test performance I used a big CSV file (~1GB, mostly ASCII) and measured `Rope::from` with this program: ```rust fn main() { let text = std::fs::read_to_string("big.csv").unwrap(); let start = std::time::Instant::now(); let rope = rope::Rope::from(text); println!("{}ms, {}", start.elapsed().as_millis(), rope.len()); } ``` Here are results on my machine (Ryzen 7 4800H) | | Parallel | Serial | | ------------ | -------- | ------ | | Before | 1123ms | 9154ms | | After | 497ms | 2081ms | | After (sse2) | 480ms | 1454ms | Since serial performance is now much closer to parallel, I also increased `PARALLEL_THRESHOLD` to 1000. In my tests the parallel version starts to beat serial at around 150 KB strings. This constant might require more tweaking and testing though, especially on ARM64.
cargo bench (SSE2 vs before) ``` Running benches\rope_benchmark.rs (D:\zed\target\release\deps\rope_benchmark-3f8476f7dfb79154.exe) Gnuplot not found, using plotters backend push/4096 time: [43.592 µs 43.658 µs 43.733 µs] thrpt: [89.320 MiB/s 89.473 MiB/s 89.610 MiB/s] change: time: [-78.523% -78.222% -77.854%] (p = 0.00 < 0.05) thrpt: [+351.56% +359.19% +365.61%] Performance has improved. Found 2 outliers among 100 measurements (2.00%) 1 (1.00%) high mild 1 (1.00%) high severe push/65536 time: [632.36 µs 634.03 µs 635.76 µs] thrpt: [98.308 MiB/s 98.576 MiB/s 98.836 MiB/s] change: time: [-51.521% -50.850% -50.325%] (p = 0.00 < 0.05) thrpt: [+101.31% +103.46% +106.28%] Performance has improved. Found 18 outliers among 100 measurements (18.00%) 11 (11.00%) low mild 6 (6.00%) high mild 1 (1.00%) high severe append/4096 time: [11.635 µs 11.664 µs 11.698 µs] thrpt: [333.92 MiB/s 334.89 MiB/s 335.72 MiB/s] change: time: [-24.543% -23.925% -22.660%] (p = 0.00 < 0.05) thrpt: [+29.298% +31.450% +32.525%] Performance has improved. Found 12 outliers among 100 measurements (12.00%) 2 (2.00%) low mild 2 (2.00%) high mild 8 (8.00%) high severe append/65536 time: [1.1287 µs 1.1324 µs 1.1360 µs] thrpt: [53.727 GiB/s 53.900 GiB/s 54.075 GiB/s] change: time: [-44.153% -37.614% -29.834%] (p = 0.00 < 0.05) thrpt: [+42.518% +60.292% +79.061%] Performance has improved. slice/4096 time: [28.340 µs 28.372 µs 28.406 µs] thrpt: [137.52 MiB/s 137.68 MiB/s 137.83 MiB/s] change: time: [-8.0798% -6.3955% -4.4109%] (p = 0.00 < 0.05) thrpt: [+4.6145% +6.8325% +8.7900%] Performance has improved. Found 3 outliers among 100 measurements (3.00%) 1 (1.00%) low mild 1 (1.00%) high mild 1 (1.00%) high severe slice/65536 time: [527.51 µs 528.17 µs 528.90 µs] thrpt: [118.17 MiB/s 118.33 MiB/s 118.48 MiB/s] change: time: [-53.819% -45.431% -34.578%] (p = 0.00 < 0.05) thrpt: [+52.853% +83.256% +116.54%] Performance has improved. Found 5 outliers among 100 measurements (5.00%) 1 (1.00%) low severe 3 (3.00%) low mild 1 (1.00%) high mild bytes_in_range/4096 time: [3.2545 µs 3.2646 µs 3.2797 µs] thrpt: [1.1631 GiB/s 1.1685 GiB/s 1.1721 GiB/s] change: time: [-3.4829% -2.4391% -1.7166%] (p = 0.00 < 0.05) thrpt: [+1.7466% +2.5001% +3.6085%] Performance has improved. Found 8 outliers among 100 measurements (8.00%) 6 (6.00%) high mild 2 (2.00%) high severe bytes_in_range/65536 time: [80.770 µs 80.832 µs 80.904 µs] thrpt: [772.52 MiB/s 773.21 MiB/s 773.80 MiB/s] change: time: [-1.8710% -1.3843% -0.9044%] (p = 0.00 < 0.05) thrpt: [+0.9126% +1.4037% +1.9067%] Change within noise threshold. Found 8 outliers among 100 measurements (8.00%) 5 (5.00%) high mild 3 (3.00%) high severe chars/4096 time: [790.50 ns 791.10 ns 791.88 ns] thrpt: [4.8173 GiB/s 4.8220 GiB/s 4.8257 GiB/s] change: time: [+0.4318% +1.4558% +2.0256%] (p = 0.00 < 0.05) thrpt: [-1.9854% -1.4349% -0.4299%] Change within noise threshold. Found 6 outliers among 100 measurements (6.00%) 1 (1.00%) low severe 1 (1.00%) low mild 2 (2.00%) high mild 2 (2.00%) high severe chars/65536 time: [12.672 µs 12.688 µs 12.703 µs] thrpt: [4.8046 GiB/s 4.8106 GiB/s 4.8164 GiB/s] change: time: [-2.7794% -1.2987% -0.2020%] (p = 0.04 < 0.05) thrpt: [+0.2025% +1.3158% +2.8588%] Change within noise threshold. Found 15 outliers among 100 measurements (15.00%) 1 (1.00%) low mild 12 (12.00%) high mild 2 (2.00%) high severe clip_point/4096 time: [63.009 µs 63.126 µs 63.225 µs] thrpt: [61.783 MiB/s 61.880 MiB/s 61.995 MiB/s] change: time: [+2.0484% +3.2218% +5.2181%] (p = 0.00 < 0.05) thrpt: [-4.9593% -3.1213% -2.0073%] Performance has regressed. Found 13 outliers among 100 measurements (13.00%) 12 (12.00%) low mild 1 (1.00%) high severe Benchmarking clip_point/65536: Warming up for 3.0000 s Warning: Unable to complete 100 samples in 5.0s. You may wish to increase target time to 7.7s, enable flat sampling, or reduce sample count to 50. clip_point/65536 time: [1.2420 ms 1.2430 ms 1.2439 ms] thrpt: [50.246 MiB/s 50.283 MiB/s 50.322 MiB/s] change: time: [-0.3495% -0.0401% +0.1990%] (p = 0.80 > 0.05) thrpt: [-0.1986% +0.0401% +0.3507%] No change in performance detected. Found 7 outliers among 100 measurements (7.00%) 6 (6.00%) high mild 1 (1.00%) high severe point_to_offset/4096 time: [16.104 µs 16.119 µs 16.134 µs] thrpt: [242.11 MiB/s 242.33 MiB/s 242.56 MiB/s] change: time: [-1.3816% -0.2497% +2.2181%] (p = 0.84 > 0.05) thrpt: [-2.1699% +0.2503% +1.4009%] No change in performance detected. Found 6 outliers among 100 measurements (6.00%) 3 (3.00%) low mild 1 (1.00%) high mild 2 (2.00%) high severe point_to_offset/65536 time: [356.28 µs 356.57 µs 356.86 µs] thrpt: [175.14 MiB/s 175.28 MiB/s 175.42 MiB/s] change: time: [-3.7072% -2.3338% -1.4742%] (p = 0.00 < 0.05) thrpt: [+1.4962% +2.3896% +3.8499%] Performance has improved. Found 1 outliers among 100 measurements (1.00%) 1 (1.00%) low mild cursor/4096 time: [18.893 µs 18.934 µs 18.974 µs] thrpt: [205.87 MiB/s 206.31 MiB/s 206.76 MiB/s] change: time: [-2.3645% -2.0729% -1.7931%] (p = 0.00 < 0.05) thrpt: [+1.8259% +2.1168% +2.4218%] Performance has improved. Found 12 outliers among 100 measurements (12.00%) 12 (12.00%) high mild cursor/65536 time: [459.97 µs 460.40 µs 461.04 µs] thrpt: [135.56 MiB/s 135.75 MiB/s 135.88 MiB/s] change: time: [-5.7445% -4.2758% -3.1344%] (p = 0.00 < 0.05) thrpt: [+3.2358% +4.4668% +6.0946%] Performance has improved. Found 2 outliers among 100 measurements (2.00%) 1 (1.00%) high mild 1 (1.00%) high severe append many/small to large time: [38.364 ms 38.620 ms 38.907 ms] thrpt: [313.75 MiB/s 316.08 MiB/s 318.19 MiB/s] change: time: [-0.2042% +1.0954% +2.3334%] (p = 0.10 > 0.05) thrpt: [-2.2802% -1.0836% +0.2046%] No change in performance detected. Found 21 outliers among 100 measurements (21.00%) 9 (9.00%) high mild 12 (12.00%) high severe append many/large to small time: [48.045 ms 48.322 ms 48.648 ms] thrpt: [250.92 MiB/s 252.62 MiB/s 254.07 MiB/s] change: time: [-6.5298% -5.6919% -4.8532%] (p = 0.00 < 0.05) thrpt: [+5.1007% +6.0354% +6.9859%] Performance has improved. Found 11 outliers among 100 measurements (11.00%) 2 (2.00%) high mild 9 (9.00%) high severe ```
Release Notes: - N/A *or* Added/Fixed/Improved ... --- crates/rope/src/chunk.rs | 61 ++++++++++++++++++++++++++------- crates/rope/src/rope.rs | 2 +- crates/sum_tree/src/sum_tree.rs | 22 ++++++------ 3 files changed, 62 insertions(+), 23 deletions(-) diff --git a/crates/rope/src/chunk.rs b/crates/rope/src/chunk.rs index a2a8e8d58df2d5ddc3336e8e56dd8446f4dcf118..c1916768c1f8a0980fb4d5aa1b718483b08c6087 100644 --- a/crates/rope/src/chunk.rs +++ b/crates/rope/src/chunk.rs @@ -47,22 +47,59 @@ impl Chunk { #[inline(always)] pub fn new(text: &str) -> Self { - let mut this = Chunk::default(); - this.push_str(text); - this + let text = ArrayString::from(text).unwrap(); + + const CHUNK_SIZE: usize = 8; + + let mut chars_bytes = [0; MAX_BASE / CHUNK_SIZE]; + let mut newlines_bytes = [0; MAX_BASE / CHUNK_SIZE]; + let mut tabs_bytes = [0; MAX_BASE / CHUNK_SIZE]; + let mut chars_utf16_bytes = [0; MAX_BASE / CHUNK_SIZE]; + + let mut chunk_ix = 0; + + let mut bytes = text.as_bytes(); + while !bytes.is_empty() { + let (chunk, rest) = bytes.split_at(bytes.len().min(CHUNK_SIZE)); + bytes = rest; + + let mut chars = 0; + let mut newlines = 0; + let mut tabs = 0; + let mut chars_utf16 = 0; + + for (ix, &b) in chunk.iter().enumerate() { + chars |= (util::is_utf8_char_boundary(b) as u8) << ix; + newlines |= ((b == b'\n') as u8) << ix; + tabs |= ((b == b'\t') as u8) << ix; + // b >= 240 when we are at the first byte of the 4 byte encoded + // utf-8 code point (U+010000 or greater) it means that it would + // be encoded as two 16-bit code units in utf-16 + chars_utf16 |= ((b >= 240) as u8) << ix; + } + + chars_bytes[chunk_ix] = chars; + newlines_bytes[chunk_ix] = newlines; + tabs_bytes[chunk_ix] = tabs; + chars_utf16_bytes[chunk_ix] = chars_utf16; + + chunk_ix += 1; + } + + let chars = Bitmap::from_le_bytes(chars_bytes); + + Chunk { + text, + chars, + chars_utf16: (Bitmap::from_le_bytes(chars_utf16_bytes) << 1) | chars, + newlines: Bitmap::from_le_bytes(newlines_bytes), + tabs: Bitmap::from_le_bytes(tabs_bytes), + } } #[inline(always)] pub fn push_str(&mut self, text: &str) { - for (char_ix, c) in text.char_indices() { - let ix = self.text.len() + char_ix; - self.chars |= 1 << ix; - self.chars_utf16 |= 1 << ix; - self.chars_utf16 |= (c.len_utf16() as Bitmap) << ix; - self.newlines |= ((c == '\n') as Bitmap) << ix; - self.tabs |= ((c == '\t') as Bitmap) << ix; - } - self.text.push_str(text); + self.append(Chunk::new(text).as_slice()); } #[inline(always)] diff --git a/crates/rope/src/rope.rs b/crates/rope/src/rope.rs index 50f9ba044d90072aa9c6fc2fc4abfd6d0e6b98cb..fba7b96aca83fa05c0d6f3e7992ad7443ec7958a 100644 --- a/crates/rope/src/rope.rs +++ b/crates/rope/src/rope.rs @@ -227,7 +227,7 @@ impl Rope { #[cfg(all(test, not(rust_analyzer)))] const PARALLEL_THRESHOLD: usize = 4; #[cfg(not(all(test, not(rust_analyzer))))] - const PARALLEL_THRESHOLD: usize = 4 * (2 * sum_tree::TREE_BASE); + const PARALLEL_THRESHOLD: usize = 84 * (2 * sum_tree::TREE_BASE); if new_chunks.len() >= PARALLEL_THRESHOLD { self.chunks diff --git a/crates/sum_tree/src/sum_tree.rs b/crates/sum_tree/src/sum_tree.rs index bfc4587969ec67bbda2fb90d34550c7d464317c9..6a76b73c3bbfb922e1b46fc1e228209ddf05b4a5 100644 --- a/crates/sum_tree/src/sum_tree.rs +++ b/crates/sum_tree/src/sum_tree.rs @@ -250,11 +250,11 @@ impl SumTree { ::add_summary(&mut summary, item_summary, cx); } - nodes.push(Node::Leaf { + nodes.push(SumTree(Arc::new(Node::Leaf { summary, items, item_summaries, - }); + }))); } let mut parent_nodes = Vec::new(); @@ -263,25 +263,27 @@ impl SumTree { height += 1; let mut current_parent_node = None; for child_node in nodes.drain(..) { - let parent_node = current_parent_node.get_or_insert_with(|| Node::Internal { - summary: ::zero(cx), - height, - child_summaries: ArrayVec::new(), - child_trees: ArrayVec::new(), + let parent_node = current_parent_node.get_or_insert_with(|| { + SumTree(Arc::new(Node::Internal { + summary: ::zero(cx), + height, + child_summaries: ArrayVec::new(), + child_trees: ArrayVec::new(), + })) }); let Node::Internal { summary, child_summaries, child_trees, .. - } = parent_node + } = Arc::get_mut(&mut parent_node.0).unwrap() else { unreachable!() }; let child_summary = child_node.summary(); ::add_summary(summary, child_summary, cx); child_summaries.push(child_summary.clone()); - child_trees.push(Self(Arc::new(child_node))); + child_trees.push(child_node); if child_trees.len() == 2 * TREE_BASE { parent_nodes.extend(current_parent_node.take()); @@ -295,7 +297,7 @@ impl SumTree { Self::new(cx) } else { debug_assert_eq!(nodes.len(), 1); - Self(Arc::new(nodes.pop().unwrap())) + nodes.pop().unwrap() } } From 38f4e21fe8bb72ceac5f601947919fd4d7d5f61e Mon Sep 17 00:00:00 2001 From: Dmitry Nefedov <113844030+dangooddd@users.noreply.github.com> Date: Mon, 15 Dec 2025 11:40:45 +0300 Subject: [PATCH 269/621] themes: Improve Gruvbox terminal colors (#38536) This PR makes zed terminal gruvbox theme consistent with other terminals themes. Current ansi colors is broken, by not only not using colors from original palette, but also by inverting of bright/normal colors... Currently I took colors from Ghostty (Iterm2 themes), making sure that they are consistent with palette. For dim colors I darken them by decreasing "Value" from HSV representation of colors by 30%. I am open to discussion and willing to implement those changes for light theme after receiving feedback. Examples below: | Before | After | | - | - | | image | image | Script to reproduce: ```bash #!/bin/bash echo "Normal ANSI Colors:" for i in {30..37}; do printf "\e[${i}m Text \e[0m" done echo "" echo "Bright ANSI Colors (Foreground):" for i in {90..97}; do printf "\e[${i}m Text \e[0m" done echo "" echo "Bright ANSI Colors (Background):" for i in {100..107}; do printf "\e[${i}m Text \e[0m" done echo "" echo "Foreground and Background Combinations:" for fg in {30..37}; do for bg in {40..47}; do printf "\e[${fg};${bg}m FB \e[0m" done echo "" done echo "Bright Foreground and Background Combinations:" for fg in {90..97}; do for bg in {100..107}; do printf "\e[${fg};${bg}m FB \e[0m" done echo "" done ``` Release Notes: - Fixed ANSI colors definitions in the Gruvbox theme (thanks @dangooddd) --------- Co-authored-by: Oleksiy Syvokon --- assets/themes/gruvbox/gruvbox.json | 292 ++++++++++++++--------------- 1 file changed, 146 insertions(+), 146 deletions(-) diff --git a/assets/themes/gruvbox/gruvbox.json b/assets/themes/gruvbox/gruvbox.json index 90973fd6c3469a1ef0e698d629376dfaaf3b5a76..16ae188712f7a800ab4fb8a81a2d24cac99da56b 100644 --- a/assets/themes/gruvbox/gruvbox.json +++ b/assets/themes/gruvbox/gruvbox.json @@ -71,33 +71,33 @@ "editor.document_highlight.read_background": "#83a5981a", "editor.document_highlight.write_background": "#92847466", "terminal.background": "#282828ff", - "terminal.foreground": "#fbf1c7ff", + "terminal.foreground": "#ebdbb2ff", "terminal.bright_foreground": "#fbf1c7ff", - "terminal.dim_foreground": "#282828ff", + "terminal.dim_foreground": "#766b5dff", "terminal.ansi.black": "#282828ff", - "terminal.ansi.bright_black": "#73675eff", + "terminal.ansi.bright_black": "#928374ff", "terminal.ansi.dim_black": "#fbf1c7ff", - "terminal.ansi.red": "#fb4a35ff", - "terminal.ansi.bright_red": "#93201dff", - "terminal.ansi.dim_red": "#ffaa95ff", - "terminal.ansi.green": "#b7bb26ff", - "terminal.ansi.bright_green": "#605c1bff", - "terminal.ansi.dim_green": "#e0dc98ff", - "terminal.ansi.yellow": "#f9bd2fff", - "terminal.ansi.bright_yellow": "#91611bff", - "terminal.ansi.dim_yellow": "#fedc9bff", - "terminal.ansi.blue": "#83a598ff", - "terminal.ansi.bright_blue": "#414f4aff", - "terminal.ansi.dim_blue": "#c0d2cbff", - "terminal.ansi.magenta": "#d3869bff", - "terminal.ansi.bright_magenta": "#8e5868ff", - "terminal.ansi.dim_magenta": "#ff9ebbff", - "terminal.ansi.cyan": "#8ec07cff", - "terminal.ansi.bright_cyan": "#45603eff", - "terminal.ansi.dim_cyan": "#c7dfbdff", - "terminal.ansi.white": "#fbf1c7ff", - "terminal.ansi.bright_white": "#ffffffff", - "terminal.ansi.dim_white": "#b0a189ff", + "terminal.ansi.red": "#cc241dff", + "terminal.ansi.bright_red": "#fb4934ff", + "terminal.ansi.dim_red": "#8e1814ff", + "terminal.ansi.green": "#98971aff", + "terminal.ansi.bright_green": "#b8bb26ff", + "terminal.ansi.dim_green": "#6a6912ff", + "terminal.ansi.yellow": "#d79921ff", + "terminal.ansi.bright_yellow": "#fabd2fff", + "terminal.ansi.dim_yellow": "#966a17ff", + "terminal.ansi.blue": "#458588ff", + "terminal.ansi.bright_blue": "#83a598ff", + "terminal.ansi.dim_blue": "#305d5fff", + "terminal.ansi.magenta": "#b16286ff", + "terminal.ansi.bright_magenta": "#d3869bff", + "terminal.ansi.dim_magenta": "#7c455eff", + "terminal.ansi.cyan": "#689d6aff", + "terminal.ansi.bright_cyan": "#8ec07cff", + "terminal.ansi.dim_cyan": "#496e4aff", + "terminal.ansi.white": "#a89984ff", + "terminal.ansi.bright_white": "#fbf1c7ff", + "terminal.ansi.dim_white": "#766b5dff", "link_text.hover": "#83a598ff", "version_control.added": "#b7bb26ff", "version_control.modified": "#f9bd2fff", @@ -478,33 +478,33 @@ "editor.document_highlight.read_background": "#83a5981a", "editor.document_highlight.write_background": "#92847466", "terminal.background": "#1d2021ff", - "terminal.foreground": "#fbf1c7ff", + "terminal.foreground": "#ebdbb2ff", "terminal.bright_foreground": "#fbf1c7ff", - "terminal.dim_foreground": "#1d2021ff", - "terminal.ansi.black": "#1d2021ff", - "terminal.ansi.bright_black": "#73675eff", + "terminal.dim_foreground": "#766b5dff", + "terminal.ansi.black": "#282828ff", + "terminal.ansi.bright_black": "#928374ff", "terminal.ansi.dim_black": "#fbf1c7ff", - "terminal.ansi.red": "#fb4a35ff", - "terminal.ansi.bright_red": "#93201dff", - "terminal.ansi.dim_red": "#ffaa95ff", - "terminal.ansi.green": "#b7bb26ff", - "terminal.ansi.bright_green": "#605c1bff", - "terminal.ansi.dim_green": "#e0dc98ff", - "terminal.ansi.yellow": "#f9bd2fff", - "terminal.ansi.bright_yellow": "#91611bff", - "terminal.ansi.dim_yellow": "#fedc9bff", - "terminal.ansi.blue": "#83a598ff", - "terminal.ansi.bright_blue": "#414f4aff", - "terminal.ansi.dim_blue": "#c0d2cbff", - "terminal.ansi.magenta": "#d3869bff", - "terminal.ansi.bright_magenta": "#8e5868ff", - "terminal.ansi.dim_magenta": "#ff9ebbff", - "terminal.ansi.cyan": "#8ec07cff", - "terminal.ansi.bright_cyan": "#45603eff", - "terminal.ansi.dim_cyan": "#c7dfbdff", - "terminal.ansi.white": "#fbf1c7ff", - "terminal.ansi.bright_white": "#ffffffff", - "terminal.ansi.dim_white": "#b0a189ff", + "terminal.ansi.red": "#cc241dff", + "terminal.ansi.bright_red": "#fb4934ff", + "terminal.ansi.dim_red": "#8e1814ff", + "terminal.ansi.green": "#98971aff", + "terminal.ansi.bright_green": "#b8bb26ff", + "terminal.ansi.dim_green": "#6a6912ff", + "terminal.ansi.yellow": "#d79921ff", + "terminal.ansi.bright_yellow": "#fabd2fff", + "terminal.ansi.dim_yellow": "#966a17ff", + "terminal.ansi.blue": "#458588ff", + "terminal.ansi.bright_blue": "#83a598ff", + "terminal.ansi.dim_blue": "#305d5fff", + "terminal.ansi.magenta": "#b16286ff", + "terminal.ansi.bright_magenta": "#d3869bff", + "terminal.ansi.dim_magenta": "#7c455eff", + "terminal.ansi.cyan": "#689d6aff", + "terminal.ansi.bright_cyan": "#8ec07cff", + "terminal.ansi.dim_cyan": "#496e4aff", + "terminal.ansi.white": "#a89984ff", + "terminal.ansi.bright_white": "#fbf1c7ff", + "terminal.ansi.dim_white": "#766b5dff", "link_text.hover": "#83a598ff", "version_control.added": "#b7bb26ff", "version_control.modified": "#f9bd2fff", @@ -885,33 +885,33 @@ "editor.document_highlight.read_background": "#83a5981a", "editor.document_highlight.write_background": "#92847466", "terminal.background": "#32302fff", - "terminal.foreground": "#fbf1c7ff", + "terminal.foreground": "#ebdbb2ff", "terminal.bright_foreground": "#fbf1c7ff", - "terminal.dim_foreground": "#32302fff", - "terminal.ansi.black": "#32302fff", - "terminal.ansi.bright_black": "#73675eff", + "terminal.dim_foreground": "#766b5dff", + "terminal.ansi.black": "#282828ff", + "terminal.ansi.bright_black": "#928374ff", "terminal.ansi.dim_black": "#fbf1c7ff", - "terminal.ansi.red": "#fb4a35ff", - "terminal.ansi.bright_red": "#93201dff", - "terminal.ansi.dim_red": "#ffaa95ff", - "terminal.ansi.green": "#b7bb26ff", - "terminal.ansi.bright_green": "#605c1bff", - "terminal.ansi.dim_green": "#e0dc98ff", - "terminal.ansi.yellow": "#f9bd2fff", - "terminal.ansi.bright_yellow": "#91611bff", - "terminal.ansi.dim_yellow": "#fedc9bff", - "terminal.ansi.blue": "#83a598ff", - "terminal.ansi.bright_blue": "#414f4aff", - "terminal.ansi.dim_blue": "#c0d2cbff", - "terminal.ansi.magenta": "#d3869bff", - "terminal.ansi.bright_magenta": "#8e5868ff", - "terminal.ansi.dim_magenta": "#ff9ebbff", - "terminal.ansi.cyan": "#8ec07cff", - "terminal.ansi.bright_cyan": "#45603eff", - "terminal.ansi.dim_cyan": "#c7dfbdff", - "terminal.ansi.white": "#fbf1c7ff", - "terminal.ansi.bright_white": "#ffffffff", - "terminal.ansi.dim_white": "#b0a189ff", + "terminal.ansi.red": "#cc241dff", + "terminal.ansi.bright_red": "#fb4934ff", + "terminal.ansi.dim_red": "#8e1814ff", + "terminal.ansi.green": "#98971aff", + "terminal.ansi.bright_green": "#b8bb26ff", + "terminal.ansi.dim_green": "#6a6912ff", + "terminal.ansi.yellow": "#d79921ff", + "terminal.ansi.bright_yellow": "#fabd2fff", + "terminal.ansi.dim_yellow": "#966a17ff", + "terminal.ansi.blue": "#458588ff", + "terminal.ansi.bright_blue": "#83a598ff", + "terminal.ansi.dim_blue": "#305d5fff", + "terminal.ansi.magenta": "#b16286ff", + "terminal.ansi.bright_magenta": "#d3869bff", + "terminal.ansi.dim_magenta": "#7c455eff", + "terminal.ansi.cyan": "#689d6aff", + "terminal.ansi.bright_cyan": "#8ec07cff", + "terminal.ansi.dim_cyan": "#496e4aff", + "terminal.ansi.white": "#a89984ff", + "terminal.ansi.bright_white": "#fbf1c7ff", + "terminal.ansi.dim_white": "#766b5dff", "link_text.hover": "#83a598ff", "version_control.added": "#b7bb26ff", "version_control.modified": "#f9bd2fff", @@ -1295,30 +1295,30 @@ "terminal.foreground": "#282828ff", "terminal.bright_foreground": "#282828ff", "terminal.dim_foreground": "#fbf1c7ff", - "terminal.ansi.black": "#282828ff", - "terminal.ansi.bright_black": "#0b6678ff", - "terminal.ansi.dim_black": "#5f5650ff", - "terminal.ansi.red": "#9d0308ff", - "terminal.ansi.bright_red": "#db8b7aff", - "terminal.ansi.dim_red": "#4e1207ff", - "terminal.ansi.green": "#797410ff", - "terminal.ansi.bright_green": "#bfb787ff", - "terminal.ansi.dim_green": "#3e3a11ff", - "terminal.ansi.yellow": "#b57615ff", - "terminal.ansi.bright_yellow": "#e2b88bff", - "terminal.ansi.dim_yellow": "#5c3a12ff", - "terminal.ansi.blue": "#0b6678ff", - "terminal.ansi.bright_blue": "#8fb0baff", - "terminal.ansi.dim_blue": "#14333bff", - "terminal.ansi.magenta": "#8f3e71ff", - "terminal.ansi.bright_magenta": "#c76da0ff", - "terminal.ansi.dim_magenta": "#5c2848ff", - "terminal.ansi.cyan": "#437b59ff", - "terminal.ansi.bright_cyan": "#9fbca8ff", - "terminal.ansi.dim_cyan": "#253e2eff", - "terminal.ansi.white": "#fbf1c7ff", - "terminal.ansi.bright_white": "#ffffffff", - "terminal.ansi.dim_white": "#b0a189ff", + "terminal.ansi.black": "#fbf1c7ff", + "terminal.ansi.bright_black": "#928374ff", + "terminal.ansi.dim_black": "#7c6f64ff", + "terminal.ansi.red": "#cc241dff", + "terminal.ansi.bright_red": "#9d0006ff", + "terminal.ansi.dim_red": "#c31c16ff", + "terminal.ansi.green": "#98971aff", + "terminal.ansi.bright_green": "#79740eff", + "terminal.ansi.dim_green": "#929015ff", + "terminal.ansi.yellow": "#d79921ff", + "terminal.ansi.bright_yellow": "#b57614ff", + "terminal.ansi.dim_yellow": "#cf8e1aff", + "terminal.ansi.blue": "#458588ff", + "terminal.ansi.bright_blue": "#076678ff", + "terminal.ansi.dim_blue": "#356f77ff", + "terminal.ansi.magenta": "#b16286ff", + "terminal.ansi.bright_magenta": "#8f3f71ff", + "terminal.ansi.dim_magenta": "#a85580ff", + "terminal.ansi.cyan": "#689d6aff", + "terminal.ansi.bright_cyan": "#427b58ff", + "terminal.ansi.dim_cyan": "#5f9166ff", + "terminal.ansi.white": "#7c6f64ff", + "terminal.ansi.bright_white": "#282828ff", + "terminal.ansi.dim_white": "#282828ff", "link_text.hover": "#0b6678ff", "version_control.added": "#797410ff", "version_control.modified": "#b57615ff", @@ -1702,30 +1702,30 @@ "terminal.foreground": "#282828ff", "terminal.bright_foreground": "#282828ff", "terminal.dim_foreground": "#f9f5d7ff", - "terminal.ansi.black": "#282828ff", - "terminal.ansi.bright_black": "#73675eff", - "terminal.ansi.dim_black": "#f9f5d7ff", - "terminal.ansi.red": "#9d0308ff", - "terminal.ansi.bright_red": "#db8b7aff", - "terminal.ansi.dim_red": "#4e1207ff", - "terminal.ansi.green": "#797410ff", - "terminal.ansi.bright_green": "#bfb787ff", - "terminal.ansi.dim_green": "#3e3a11ff", - "terminal.ansi.yellow": "#b57615ff", - "terminal.ansi.bright_yellow": "#e2b88bff", - "terminal.ansi.dim_yellow": "#5c3a12ff", - "terminal.ansi.blue": "#0b6678ff", - "terminal.ansi.bright_blue": "#8fb0baff", - "terminal.ansi.dim_blue": "#14333bff", - "terminal.ansi.magenta": "#8f3e71ff", - "terminal.ansi.bright_magenta": "#c76da0ff", - "terminal.ansi.dim_magenta": "#5c2848ff", - "terminal.ansi.cyan": "#437b59ff", - "terminal.ansi.bright_cyan": "#9fbca8ff", - "terminal.ansi.dim_cyan": "#253e2eff", - "terminal.ansi.white": "#f9f5d7ff", - "terminal.ansi.bright_white": "#ffffffff", - "terminal.ansi.dim_white": "#b0a189ff", + "terminal.ansi.black": "#fbf1c7ff", + "terminal.ansi.bright_black": "#928374ff", + "terminal.ansi.dim_black": "#7c6f64ff", + "terminal.ansi.red": "#cc241dff", + "terminal.ansi.bright_red": "#9d0006ff", + "terminal.ansi.dim_red": "#c31c16ff", + "terminal.ansi.green": "#98971aff", + "terminal.ansi.bright_green": "#79740eff", + "terminal.ansi.dim_green": "#929015ff", + "terminal.ansi.yellow": "#d79921ff", + "terminal.ansi.bright_yellow": "#b57614ff", + "terminal.ansi.dim_yellow": "#cf8e1aff", + "terminal.ansi.blue": "#458588ff", + "terminal.ansi.bright_blue": "#076678ff", + "terminal.ansi.dim_blue": "#356f77ff", + "terminal.ansi.magenta": "#b16286ff", + "terminal.ansi.bright_magenta": "#8f3f71ff", + "terminal.ansi.dim_magenta": "#a85580ff", + "terminal.ansi.cyan": "#689d6aff", + "terminal.ansi.bright_cyan": "#427b58ff", + "terminal.ansi.dim_cyan": "#5f9166ff", + "terminal.ansi.white": "#7c6f64ff", + "terminal.ansi.bright_white": "#282828ff", + "terminal.ansi.dim_white": "#282828ff", "link_text.hover": "#0b6678ff", "version_control.added": "#797410ff", "version_control.modified": "#b57615ff", @@ -2109,30 +2109,30 @@ "terminal.foreground": "#282828ff", "terminal.bright_foreground": "#282828ff", "terminal.dim_foreground": "#f2e5bcff", - "terminal.ansi.black": "#282828ff", - "terminal.ansi.bright_black": "#73675eff", - "terminal.ansi.dim_black": "#f2e5bcff", - "terminal.ansi.red": "#9d0308ff", - "terminal.ansi.bright_red": "#db8b7aff", - "terminal.ansi.dim_red": "#4e1207ff", - "terminal.ansi.green": "#797410ff", - "terminal.ansi.bright_green": "#bfb787ff", - "terminal.ansi.dim_green": "#3e3a11ff", - "terminal.ansi.yellow": "#b57615ff", - "terminal.ansi.bright_yellow": "#e2b88bff", - "terminal.ansi.dim_yellow": "#5c3a12ff", - "terminal.ansi.blue": "#0b6678ff", - "terminal.ansi.bright_blue": "#8fb0baff", - "terminal.ansi.dim_blue": "#14333bff", - "terminal.ansi.magenta": "#8f3e71ff", - "terminal.ansi.bright_magenta": "#c76da0ff", - "terminal.ansi.dim_magenta": "#5c2848ff", - "terminal.ansi.cyan": "#437b59ff", - "terminal.ansi.bright_cyan": "#9fbca8ff", - "terminal.ansi.dim_cyan": "#253e2eff", - "terminal.ansi.white": "#f2e5bcff", - "terminal.ansi.bright_white": "#ffffffff", - "terminal.ansi.dim_white": "#b0a189ff", + "terminal.ansi.black": "#fbf1c7ff", + "terminal.ansi.bright_black": "#928374ff", + "terminal.ansi.dim_black": "#7c6f64ff", + "terminal.ansi.red": "#cc241dff", + "terminal.ansi.bright_red": "#9d0006ff", + "terminal.ansi.dim_red": "#c31c16ff", + "terminal.ansi.green": "#98971aff", + "terminal.ansi.bright_green": "#79740eff", + "terminal.ansi.dim_green": "#929015ff", + "terminal.ansi.yellow": "#d79921ff", + "terminal.ansi.bright_yellow": "#b57614ff", + "terminal.ansi.dim_yellow": "#cf8e1aff", + "terminal.ansi.blue": "#458588ff", + "terminal.ansi.bright_blue": "#076678ff", + "terminal.ansi.dim_blue": "#356f77ff", + "terminal.ansi.magenta": "#b16286ff", + "terminal.ansi.bright_magenta": "#8f3f71ff", + "terminal.ansi.dim_magenta": "#a85580ff", + "terminal.ansi.cyan": "#689d6aff", + "terminal.ansi.bright_cyan": "#427b58ff", + "terminal.ansi.dim_cyan": "#5f9166ff", + "terminal.ansi.white": "#7c6f64ff", + "terminal.ansi.bright_white": "#282828ff", + "terminal.ansi.dim_white": "#282828ff", "link_text.hover": "#0b6678ff", "version_control.added": "#797410ff", "version_control.modified": "#b57615ff", From be57307a6fc094e211a37a634a57e58e9cfb9b7f Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Mon, 15 Dec 2025 00:55:03 -0800 Subject: [PATCH 270/621] Inline assistant finishing touches (#44851) Tighten up evals, make assistant less talkative, get them passing a bit more, improve telemetry, stream in failure messages, and turn it on for staff. Release Notes: - N/A --- crates/agent_ui/src/buffer_codegen.rs | 34 +++++--------- crates/agent_ui/src/inline_assistant.rs | 50 ++++++++++++--------- crates/agent_ui/src/inline_prompt_editor.rs | 24 +++++++--- crates/feature_flags/src/flags.rs | 4 -- crates/markdown/src/markdown.rs | 2 +- 5 files changed, 60 insertions(+), 54 deletions(-) diff --git a/crates/agent_ui/src/buffer_codegen.rs b/crates/agent_ui/src/buffer_codegen.rs index 235aea092686e669c029e8c9c7741500c23d14cb..d8d0efda0fbd70153b02452f6281ee66b90eca92 100644 --- a/crates/agent_ui/src/buffer_codegen.rs +++ b/crates/agent_ui/src/buffer_codegen.rs @@ -42,29 +42,24 @@ use std::{ }; use streaming_diff::{CharOperation, LineDiff, LineOperation, StreamingDiff}; -/// Use this tool to provide a message to the user when you're unable to complete a task. +/// Use this tool when you cannot or should not make a rewrite. This includes: +/// - The user's request is unclear, ambiguous, or nonsensical +/// - The requested change cannot be made by only editing the section #[derive(Debug, Serialize, Deserialize, JsonSchema)] pub struct FailureMessageInput { /// A brief message to the user explaining why you're unable to fulfill the request or to ask a question about the request. - /// - /// The message may use markdown formatting if you wish. #[serde(default)] pub message: String, } /// Replaces text in tags with your replacement_text. +/// Only use this tool when you are confident you understand the user's request and can fulfill it +/// by editing the marked section. #[derive(Debug, Serialize, Deserialize, JsonSchema)] pub struct RewriteSectionInput { /// The text to replace the section with. #[serde(default)] pub replacement_text: String, - - /// A brief description of the edit you have made. - /// - /// The description may use markdown formatting if you wish. - /// This is optional - if the edit is simple or obvious, you should leave it empty. - #[serde(default)] - pub description: String, } pub struct BufferCodegen { @@ -401,7 +396,7 @@ impl CodegenAlternative { &self.last_equal_ranges } - fn use_streaming_tools(model: &dyn LanguageModel, cx: &App) -> bool { + pub fn use_streaming_tools(model: &dyn LanguageModel, cx: &App) -> bool { model.supports_streaming_tools() && cx.has_flag::() && AgentSettings::get_global(cx).inline_assistant_use_streaming_tools @@ -1160,28 +1155,21 @@ impl CodegenAlternative { let chars_read_so_far = Arc::new(Mutex::new(0usize)); let process_tool_use = move |tool_use: LanguageModelToolUse| -> Option { let mut chars_read_so_far = chars_read_so_far.lock(); - let is_complete = tool_use.is_input_complete; match tool_use.name.as_ref() { "rewrite_section" => { - let Ok(mut input) = + let Ok(input) = serde_json::from_value::(tool_use.input) else { return None; }; let text = input.replacement_text[*chars_read_so_far..].to_string(); *chars_read_so_far = input.replacement_text.len(); - let description = is_complete - .then(|| { - let desc = std::mem::take(&mut input.description); - if desc.is_empty() { None } else { Some(desc) } - }) - .flatten(); - Some(ToolUseOutput::Rewrite { text, description }) + Some(ToolUseOutput::Rewrite { + text, + description: None, + }) } "failure_message" => { - if !is_complete { - return None; - } let Ok(mut input) = serde_json::from_value::(tool_use.input) else { diff --git a/crates/agent_ui/src/inline_assistant.rs b/crates/agent_ui/src/inline_assistant.rs index d036032e77d74dd905001affd9aba0010bc4f8eb..6e3ab7a162bc69a5b0ec081b060b4a2ba08b09aa 100644 --- a/crates/agent_ui/src/inline_assistant.rs +++ b/crates/agent_ui/src/inline_assistant.rs @@ -2068,17 +2068,6 @@ pub mod test { }, } - impl InlineAssistantOutput { - pub fn buffer_text(&self) -> &str { - match self { - InlineAssistantOutput::Success { - full_buffer_text, .. - } => full_buffer_text, - _ => "", - } - } - } - pub fn run_inline_assistant_test( base_buffer: String, prompt: String, @@ -2253,7 +2242,7 @@ pub mod evals { fn eval_cant_do() { run_eval( 20, - 1.0, + 0.95, "Rename the struct to EvalExampleStructNope", indoc::indoc! {" struct EvalExampleStruct { @@ -2270,7 +2259,7 @@ pub mod evals { fn eval_unclear() { run_eval( 20, - 1.0, + 0.95, "Make exactly the change I want you to make", indoc::indoc! {" struct EvalExampleStruct { @@ -2360,15 +2349,34 @@ pub mod evals { correct_output: impl Into, ) -> impl Fn(InlineAssistantOutput) -> EvalOutput<()> { let correct_output = correct_output.into(); - move |output| { - if output.buffer_text() == correct_output { - EvalOutput::passed("Assistant output matches") - } else { - EvalOutput::failed(format!( - "Assistant output does not match expected output: {:?}", - output - )) + move |output| match output { + InlineAssistantOutput::Success { + description, + full_buffer_text, + .. + } => { + if full_buffer_text == correct_output && description.is_none() { + EvalOutput::passed("Assistant output matches") + } else if full_buffer_text == correct_output { + EvalOutput::failed(format!( + "Assistant output produced an unescessary description description:\n{:?}", + description + )) + } else { + EvalOutput::failed(format!( + "Assistant output does not match expected output:\n{:?}\ndescription:\n{:?}", + full_buffer_text, description + )) + } } + o @ InlineAssistantOutput::Failure { .. } => EvalOutput::failed(format!( + "Assistant output does not match expected output: {:?}", + o + )), + o @ InlineAssistantOutput::Malformed { .. } => EvalOutput::failed(format!( + "Assistant output does not match expected output: {:?}", + o + )), } } } diff --git a/crates/agent_ui/src/inline_prompt_editor.rs b/crates/agent_ui/src/inline_prompt_editor.rs index 278216e28ec6304a9fc596c8456921fb1f1ebdfd..51e65447b2f888ab70f5942baca108134b239593 100644 --- a/crates/agent_ui/src/inline_prompt_editor.rs +++ b/crates/agent_ui/src/inline_prompt_editor.rs @@ -33,7 +33,7 @@ use workspace::{Toast, Workspace}; use zed_actions::agent::ToggleModelSelector; use crate::agent_model_selector::AgentModelSelector; -use crate::buffer_codegen::BufferCodegen; +use crate::buffer_codegen::{BufferCodegen, CodegenAlternative}; use crate::completion_provider::{ PromptCompletionProvider, PromptCompletionProviderDelegate, PromptContextType, }; @@ -585,12 +585,18 @@ impl PromptEditor { } CompletionState::Generated { completion_text } => { let model_info = self.model_selector.read(cx).active_model(cx); - let model_id = { + let (model_id, use_streaming_tools) = { let Some(configured_model) = model_info else { self.toast("No configured model", None, cx); return; }; - configured_model.model.telemetry_id() + ( + configured_model.model.telemetry_id(), + CodegenAlternative::use_streaming_tools( + configured_model.model.as_ref(), + cx, + ), + ) }; let selected_text = match &self.mode { @@ -616,6 +622,7 @@ impl PromptEditor { prompt = prompt, completion = completion_text, selected_text = selected_text, + use_streaming_tools ); self.session_state.completion = CompletionState::Rated; @@ -641,12 +648,18 @@ impl PromptEditor { } CompletionState::Generated { completion_text } => { let model_info = self.model_selector.read(cx).active_model(cx); - let model_telemetry_id = { + let (model_telemetry_id, use_streaming_tools) = { let Some(configured_model) = model_info else { self.toast("No configured model", None, cx); return; }; - configured_model.model.telemetry_id() + ( + configured_model.model.telemetry_id(), + CodegenAlternative::use_streaming_tools( + configured_model.model.as_ref(), + cx, + ), + ) }; let selected_text = match &self.mode { @@ -672,6 +685,7 @@ impl PromptEditor { prompt = prompt, completion = completion_text, selected_text = selected_text, + use_streaming_tools ); self.session_state.completion = CompletionState::Rated; diff --git a/crates/feature_flags/src/flags.rs b/crates/feature_flags/src/flags.rs index 0d474878f999bc773baff7664ca0305c2031c171..b96b8a04d1412b03f87a011a4ed324e053bf5dc5 100644 --- a/crates/feature_flags/src/flags.rs +++ b/crates/feature_flags/src/flags.rs @@ -16,8 +16,4 @@ pub struct InlineAssistantUseToolFeatureFlag; impl FeatureFlag for InlineAssistantUseToolFeatureFlag { const NAME: &'static str = "inline-assistant-use-tool"; - - fn enabled_for_staff() -> bool { - true - } } diff --git a/crates/markdown/src/markdown.rs b/crates/markdown/src/markdown.rs index 317657ea5f520cee15fc49d462b3f8ac5f0072dc..2e9103787bf2705732e1dad2276ebbdb21c5c2bc 100644 --- a/crates/markdown/src/markdown.rs +++ b/crates/markdown/src/markdown.rs @@ -251,7 +251,7 @@ impl Markdown { self.autoscroll_request = None; self.pending_parse = None; self.should_reparse = false; - self.parsed_markdown = ParsedMarkdown::default(); + // Don't clear parsed_markdown here - keep existing content visible until new parse completes self.parse(cx); } From 213c1b210b9abba5a7cc450692c4be35869fc15f Mon Sep 17 00:00:00 2001 From: godalming123 <68993177+godalming123@users.noreply.github.com> Date: Mon, 15 Dec 2025 10:03:48 +0000 Subject: [PATCH 271/621] Add global search keybinding from helix (#43363) In helix, `space /` activates a global search picker, so I think that it should be the same in zed's helix mode. Release Notes: - Added helix's `space /` keybinding to open a global search menu to zed's helix mode --- assets/keymaps/vim.json | 1 + 1 file changed, 1 insertion(+) diff --git a/assets/keymaps/vim.json b/assets/keymaps/vim.json index 533db14a5f7bba4196f6a45cabfbe5d9052f796a..24cc021709656de204def3ee8b45a790ce7eb1b0 100644 --- a/assets/keymaps/vim.json +++ b/assets/keymaps/vim.json @@ -517,6 +517,7 @@ "space c": "editor::ToggleComments", "space p": "editor::Paste", "space y": "editor::Copy", + "space /": "pane::DeploySearch", // Other ":": "command_palette::Toggle", From 75c71a9fc5da70efb9db4fd5094bcba9e33c68cf Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Mon, 15 Dec 2025 02:14:15 -0800 Subject: [PATCH 272/621] Kick off agent v2 (#44190) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🔜 TODO: - [x] Add a utility pane to the left and right edges of the workspace - [x] Add a maximize button to the left and right side of the pane - [x] Add a new agents pane - [x] Add a feature flag turning these off POV: You're working agentically Screenshot 2025-12-13 at 11 50 14 PM Release Notes: - N/A --------- Co-authored-by: Nathan Sobo Co-authored-by: Zed --- Cargo.lock | 33 + Cargo.toml | 2 + assets/settings/default.json | 2 + crates/agent_settings/src/agent_settings.rs | 4 +- crates/agent_ui/src/agent_ui.rs | 19 +- crates/agent_ui_v2/Cargo.toml | 40 + crates/agent_ui_v2/LICENSE-GPL | 1 + crates/agent_ui_v2/src/agent_thread_pane.rs | 290 +++++++ crates/agent_ui_v2/src/agent_ui_v2.rs | 4 + crates/agent_ui_v2/src/agents_panel.rs | 438 +++++++++++ crates/agent_ui_v2/src/thread_history.rs | 735 ++++++++++++++++++ crates/debugger_ui/src/debugger_panel.rs | 2 +- crates/debugger_ui/src/session/running.rs | 8 +- crates/editor/src/split.rs | 4 +- crates/feature_flags/src/flags.rs | 6 + crates/settings/src/settings_content/agent.rs | 6 +- crates/terminal_view/src/terminal_panel.rs | 15 +- crates/ui/src/components/tab_bar.rs | 48 +- crates/workspace/Cargo.toml | 1 + crates/workspace/src/dock.rs | 102 ++- crates/workspace/src/pane.rs | 105 ++- crates/workspace/src/pane_group.rs | 85 +- crates/workspace/src/utility_pane.rs | 282 +++++++ crates/workspace/src/workspace.rs | 181 ++++- crates/zed/Cargo.toml | 1 + crates/zed/src/main.rs | 1 + crates/zed/src/zed.rs | 133 +++- crates/zed_actions/src/lib.rs | 2 + 28 files changed, 2452 insertions(+), 98 deletions(-) create mode 100644 crates/agent_ui_v2/Cargo.toml create mode 120000 crates/agent_ui_v2/LICENSE-GPL create mode 100644 crates/agent_ui_v2/src/agent_thread_pane.rs create mode 100644 crates/agent_ui_v2/src/agent_ui_v2.rs create mode 100644 crates/agent_ui_v2/src/agents_panel.rs create mode 100644 crates/agent_ui_v2/src/thread_history.rs create mode 100644 crates/workspace/src/utility_pane.rs diff --git a/Cargo.lock b/Cargo.lock index f829bf138a17828d1887409b8f8ea9b48e35f3c1..7933ef3099af76a81200ae99b75fb2ccbc5671c6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -406,6 +406,37 @@ dependencies = [ "zed_actions", ] +[[package]] +name = "agent_ui_v2" +version = "0.1.0" +dependencies = [ + "agent", + "agent_servers", + "agent_settings", + "agent_ui", + "anyhow", + "assistant_text_thread", + "chrono", + "db", + "editor", + "feature_flags", + "fs", + "fuzzy", + "gpui", + "menu", + "project", + "prompt_store", + "serde", + "serde_json", + "settings", + "text", + "time", + "time_format", + "ui", + "util", + "workspace", +] + [[package]] name = "ahash" version = "0.7.8" @@ -20059,6 +20090,7 @@ dependencies = [ "component", "dap", "db", + "feature_flags", "fs", "futures 0.3.31", "gpui", @@ -20475,6 +20507,7 @@ dependencies = [ "activity_indicator", "agent_settings", "agent_ui", + "agent_ui_v2", "anyhow", "ashpd 0.11.0", "askpass", diff --git a/Cargo.toml b/Cargo.toml index 523dce229e6b58d98f0ef36070fb068a7b743367..f3a5fefc7168c5296d032ae89ec5817673d9c333 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,7 @@ members = [ "crates/agent_servers", "crates/agent_settings", "crates/agent_ui", + "crates/agent_ui_v2", "crates/ai_onboarding", "crates/anthropic", "crates/askpass", @@ -242,6 +243,7 @@ action_log = { path = "crates/action_log" } agent = { path = "crates/agent" } activity_indicator = { path = "crates/activity_indicator" } agent_ui = { path = "crates/agent_ui" } +agent_ui_v2 = { path = "crates/agent_ui_v2" } agent_settings = { path = "crates/agent_settings" } agent_servers = { path = "crates/agent_servers" } ai_onboarding = { path = "crates/ai_onboarding" } diff --git a/assets/settings/default.json b/assets/settings/default.json index a5180c9e2eaca9be49fa832e32e001d15d65df8f..0283cdd5bad26e423bb914eb40c070912e30bd36 100644 --- a/assets/settings/default.json +++ b/assets/settings/default.json @@ -906,6 +906,8 @@ "button": true, // Where to dock the agent panel. Can be 'left', 'right' or 'bottom'. "dock": "right", + // Where to dock the agents panel. Can be 'left' or 'right'. + "agents_panel_dock": "left", // Default width when the agent panel is docked to the left or right. "default_width": 640, // Default height when the agent panel is docked to the bottom. diff --git a/crates/agent_settings/src/agent_settings.rs b/crates/agent_settings/src/agent_settings.rs index 5dab085a255fe399d5f529791614d51f8b4cc78b..25ca5c78d6b76145a1b1b5d19ac86246ff419d1d 100644 --- a/crates/agent_settings/src/agent_settings.rs +++ b/crates/agent_settings/src/agent_settings.rs @@ -9,7 +9,7 @@ use project::DisableAiSettings; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use settings::{ - DefaultAgentView, DockPosition, LanguageModelParameters, LanguageModelSelection, + DefaultAgentView, DockPosition, DockSide, LanguageModelParameters, LanguageModelSelection, NotifyWhenAgentWaiting, RegisterSetting, Settings, }; @@ -24,6 +24,7 @@ pub struct AgentSettings { pub enabled: bool, pub button: bool, pub dock: DockPosition, + pub agents_panel_dock: DockSide, pub default_width: Pixels, pub default_height: Pixels, pub default_model: Option, @@ -152,6 +153,7 @@ impl Settings for AgentSettings { enabled: agent.enabled.unwrap(), button: agent.button.unwrap(), dock: agent.dock.unwrap(), + agents_panel_dock: agent.agents_panel_dock.unwrap(), default_width: px(agent.default_width.unwrap()), default_height: px(agent.default_height.unwrap()), default_model: Some(agent.default_model.unwrap()), diff --git a/crates/agent_ui/src/agent_ui.rs b/crates/agent_ui/src/agent_ui.rs index 91fccc5fca0221cc72b0972801bf4da382cedee8..dd8f6912ec9829e7be93ce340d2c8eef8134f897 100644 --- a/crates/agent_ui/src/agent_ui.rs +++ b/crates/agent_ui/src/agent_ui.rs @@ -1,4 +1,4 @@ -mod acp; +pub mod acp; mod agent_configuration; mod agent_diff; mod agent_model_selector; @@ -26,7 +26,7 @@ use agent_settings::{AgentProfileId, AgentSettings}; use assistant_slash_command::SlashCommandRegistry; use client::Client; use command_palette_hooks::CommandPaletteFilter; -use feature_flags::FeatureFlagAppExt as _; +use feature_flags::{AgentV2FeatureFlag, FeatureFlagAppExt as _}; use fs::Fs; use gpui::{Action, App, Entity, SharedString, actions}; use language::{ @@ -244,11 +244,17 @@ pub fn init( update_command_palette_filter(app_cx); }) .detach(); + + cx.on_flags_ready(|_, cx| { + update_command_palette_filter(cx); + }) + .detach(); } fn update_command_palette_filter(cx: &mut App) { let disable_ai = DisableAiSettings::get_global(cx).disable_ai; let agent_enabled = AgentSettings::get_global(cx).enabled; + let agent_v2_enabled = cx.has_flag::(); let edit_prediction_provider = AllLanguageSettings::get_global(cx) .edit_predictions .provider; @@ -269,6 +275,7 @@ fn update_command_palette_filter(cx: &mut App) { if disable_ai { filter.hide_namespace("agent"); + filter.hide_namespace("agents"); filter.hide_namespace("assistant"); filter.hide_namespace("copilot"); filter.hide_namespace("supermaven"); @@ -280,8 +287,10 @@ fn update_command_palette_filter(cx: &mut App) { } else { if agent_enabled { filter.show_namespace("agent"); + filter.show_namespace("agents"); } else { filter.hide_namespace("agent"); + filter.hide_namespace("agents"); } filter.show_namespace("assistant"); @@ -317,6 +326,9 @@ fn update_command_palette_filter(cx: &mut App) { filter.show_namespace("zed_predict_onboarding"); filter.show_action_types(&[TypeId::of::()]); + if !agent_v2_enabled { + filter.hide_action_types(&[TypeId::of::()]); + } } }); } @@ -415,7 +427,7 @@ mod tests { use gpui::{BorrowAppContext, TestAppContext, px}; use project::DisableAiSettings; use settings::{ - DefaultAgentView, DockPosition, NotifyWhenAgentWaiting, Settings, SettingsStore, + DefaultAgentView, DockPosition, DockSide, NotifyWhenAgentWaiting, Settings, SettingsStore, }; #[gpui::test] @@ -434,6 +446,7 @@ mod tests { enabled: true, button: true, dock: DockPosition::Right, + agents_panel_dock: DockSide::Left, default_width: px(300.), default_height: px(600.), default_model: None, diff --git a/crates/agent_ui_v2/Cargo.toml b/crates/agent_ui_v2/Cargo.toml new file mode 100644 index 0000000000000000000000000000000000000000..f24ef47471cdcfe0910cf36c5e220c5276d5f6ae --- /dev/null +++ b/crates/agent_ui_v2/Cargo.toml @@ -0,0 +1,40 @@ +[package] +name = "agent_ui_v2" +version = "0.1.0" +edition.workspace = true +publish.workspace = true +license = "GPL-3.0-or-later" + +[lints] +workspace = true + +[lib] +path = "src/agent_ui_v2.rs" +doctest = false + +[dependencies] +agent.workspace = true +agent_servers.workspace = true +agent_settings.workspace = true +agent_ui.workspace = true +anyhow.workspace = true +assistant_text_thread.workspace = true +chrono.workspace = true +db.workspace = true +editor.workspace = true +feature_flags.workspace = true +fs.workspace = true +fuzzy.workspace = true +gpui.workspace = true +menu.workspace = true +project.workspace = true +prompt_store.workspace = true +serde.workspace = true +serde_json.workspace = true +settings.workspace = true +text.workspace = true +time.workspace = true +time_format.workspace = true +ui.workspace = true +util.workspace = true +workspace.workspace = true diff --git a/crates/agent_ui_v2/LICENSE-GPL b/crates/agent_ui_v2/LICENSE-GPL new file mode 120000 index 0000000000000000000000000000000000000000..e0f9dbd5d63fef1630c297edc4ceba4790be6f02 --- /dev/null +++ b/crates/agent_ui_v2/LICENSE-GPL @@ -0,0 +1 @@ +LICENSE-GPL \ No newline at end of file diff --git a/crates/agent_ui_v2/src/agent_thread_pane.rs b/crates/agent_ui_v2/src/agent_thread_pane.rs new file mode 100644 index 0000000000000000000000000000000000000000..cfe861ef09c51af511554b3d15a1c810a793ed15 --- /dev/null +++ b/crates/agent_ui_v2/src/agent_thread_pane.rs @@ -0,0 +1,290 @@ +use agent::{HistoryEntry, HistoryEntryId, HistoryStore, NativeAgentServer}; +use agent_servers::AgentServer; +use agent_settings::AgentSettings; +use agent_ui::acp::AcpThreadView; +use fs::Fs; +use gpui::{ + Entity, EventEmitter, Focusable, Pixels, SharedString, Subscription, WeakEntity, prelude::*, +}; +use project::Project; +use prompt_store::PromptStore; +use serde::{Deserialize, Serialize}; +use settings::DockSide; +use settings::Settings as _; +use std::rc::Rc; +use std::sync::Arc; +use ui::{ + App, Clickable as _, Context, DynamicSpacing, IconButton, IconName, IconSize, IntoElement, + Label, LabelCommon as _, LabelSize, Render, Tab, Window, div, +}; +use workspace::Workspace; +use workspace::dock::{ClosePane, MinimizePane, UtilityPane, UtilityPanePosition}; +use workspace::utility_pane::UtilityPaneSlot; + +pub const DEFAULT_UTILITY_PANE_WIDTH: Pixels = gpui::px(400.0); + +#[derive(Serialize, Deserialize, Debug, Clone)] +pub enum SerializedHistoryEntryId { + AcpThread(String), + TextThread(String), +} + +impl From for SerializedHistoryEntryId { + fn from(id: HistoryEntryId) -> Self { + match id { + HistoryEntryId::AcpThread(session_id) => { + SerializedHistoryEntryId::AcpThread(session_id.0.to_string()) + } + HistoryEntryId::TextThread(path) => { + SerializedHistoryEntryId::TextThread(path.to_string_lossy().to_string()) + } + } + } +} + +#[derive(Serialize, Deserialize, Debug)] +pub struct SerializedAgentThreadPane { + pub expanded: bool, + pub width: Option, + pub thread_id: Option, +} + +pub enum AgentsUtilityPaneEvent { + StateChanged, +} + +impl EventEmitter for AgentThreadPane {} +impl EventEmitter for AgentThreadPane {} +impl EventEmitter for AgentThreadPane {} + +struct ActiveThreadView { + view: Entity, + thread_id: HistoryEntryId, + _notify: Subscription, +} + +pub struct AgentThreadPane { + focus_handle: gpui::FocusHandle, + expanded: bool, + width: Option, + thread_view: Option, + workspace: WeakEntity, +} + +impl AgentThreadPane { + pub fn new(workspace: WeakEntity, cx: &mut ui::Context) -> Self { + let focus_handle = cx.focus_handle(); + Self { + focus_handle, + expanded: false, + width: None, + thread_view: None, + workspace, + } + } + + pub fn thread_id(&self) -> Option { + self.thread_view.as_ref().map(|tv| tv.thread_id.clone()) + } + + pub fn serialize(&self) -> SerializedAgentThreadPane { + SerializedAgentThreadPane { + expanded: self.expanded, + width: self.width, + thread_id: self.thread_id().map(SerializedHistoryEntryId::from), + } + } + + pub fn open_thread( + &mut self, + entry: HistoryEntry, + fs: Arc, + workspace: WeakEntity, + project: Entity, + history_store: Entity, + prompt_store: Option>, + window: &mut Window, + cx: &mut Context, + ) { + let thread_id = entry.id(); + + let resume_thread = match &entry { + HistoryEntry::AcpThread(thread) => Some(thread.clone()), + HistoryEntry::TextThread(_) => None, + }; + + let agent: Rc = Rc::new(NativeAgentServer::new(fs, history_store.clone())); + + let thread_view = cx.new(|cx| { + AcpThreadView::new( + agent, + resume_thread, + None, + workspace, + project, + history_store, + prompt_store, + true, + window, + cx, + ) + }); + + let notify = cx.observe(&thread_view, |_, _, cx| { + cx.notify(); + }); + + self.thread_view = Some(ActiveThreadView { + view: thread_view, + thread_id, + _notify: notify, + }); + + cx.notify(); + } + + fn title(&self, cx: &App) -> SharedString { + if let Some(active_thread_view) = &self.thread_view { + let thread_view = active_thread_view.view.read(cx); + if let Some(thread) = thread_view.thread() { + let title = thread.read(cx).title(); + if !title.is_empty() { + return title; + } + } + thread_view.title(cx) + } else { + "Thread".into() + } + } + + fn render_header(&self, window: &mut Window, cx: &mut Context) -> impl IntoElement { + let position = self.position(window, cx); + let slot = match position { + UtilityPanePosition::Left => UtilityPaneSlot::Left, + UtilityPanePosition::Right => UtilityPaneSlot::Right, + }; + + let workspace = self.workspace.clone(); + let toggle_icon = self.toggle_icon(cx); + let title = self.title(cx); + + let make_toggle_button = |workspace: WeakEntity, cx: &App| { + div().px(DynamicSpacing::Base06.rems(cx)).child( + IconButton::new("toggle_utility_pane", toggle_icon) + .icon_size(IconSize::Small) + .on_click(move |_, window, cx| { + workspace + .update(cx, |workspace, cx| { + workspace.toggle_utility_pane(slot, window, cx) + }) + .ok(); + }), + ) + }; + + let make_close_button = |id: &'static str, cx: &mut Context| { + let on_click = cx.listener(|this, _: &gpui::ClickEvent, _window, cx| { + cx.emit(ClosePane); + this.thread_view = None; + cx.notify(); + }); + div().px(DynamicSpacing::Base06.rems(cx)).child( + IconButton::new(id, IconName::Close) + .icon_size(IconSize::Small) + .on_click(on_click), + ) + }; + + let make_title_label = |title: SharedString, cx: &App| { + div() + .px(DynamicSpacing::Base06.rems(cx)) + .child(Label::new(title).size(LabelSize::Small)) + }; + + div() + .id("utility-pane-header") + .flex() + .flex_none() + .items_center() + .w_full() + .h(Tab::container_height(cx)) + .when(slot == UtilityPaneSlot::Left, |this| { + this.child(make_toggle_button(workspace.clone(), cx)) + .child(make_title_label(title.clone(), cx)) + .child(div().flex_grow()) + .child(make_close_button("close_utility_pane_left", cx)) + }) + .when(slot == UtilityPaneSlot::Right, |this| { + this.child(make_close_button("close_utility_pane_right", cx)) + .child(make_title_label(title.clone(), cx)) + .child(div().flex_grow()) + .child(make_toggle_button(workspace.clone(), cx)) + }) + } +} + +impl Focusable for AgentThreadPane { + fn focus_handle(&self, cx: &ui::App) -> gpui::FocusHandle { + if let Some(thread_view) = &self.thread_view { + thread_view.view.focus_handle(cx) + } else { + self.focus_handle.clone() + } + } +} + +impl UtilityPane for AgentThreadPane { + fn position(&self, _window: &Window, cx: &App) -> UtilityPanePosition { + match AgentSettings::get_global(cx).agents_panel_dock { + DockSide::Left => UtilityPanePosition::Left, + DockSide::Right => UtilityPanePosition::Right, + } + } + + fn toggle_icon(&self, _cx: &App) -> IconName { + IconName::Thread + } + + fn expanded(&self, _cx: &App) -> bool { + self.expanded + } + + fn set_expanded(&mut self, expanded: bool, cx: &mut Context) { + self.expanded = expanded; + cx.emit(AgentsUtilityPaneEvent::StateChanged); + cx.notify(); + } + + fn width(&self, _cx: &App) -> Pixels { + self.width.unwrap_or(DEFAULT_UTILITY_PANE_WIDTH) + } + + fn set_width(&mut self, width: Option, cx: &mut Context) { + self.width = width; + cx.emit(AgentsUtilityPaneEvent::StateChanged); + cx.notify(); + } +} + +impl Render for AgentThreadPane { + fn render(&mut self, window: &mut Window, cx: &mut Context) -> impl IntoElement { + let content = if let Some(thread_view) = &self.thread_view { + div().size_full().child(thread_view.view.clone()) + } else { + div() + .size_full() + .flex() + .items_center() + .justify_center() + .child(Label::new("Select a thread to view details").size(LabelSize::Default)) + }; + + div() + .size_full() + .flex() + .flex_col() + .child(self.render_header(window, cx)) + .child(content) + } +} diff --git a/crates/agent_ui_v2/src/agent_ui_v2.rs b/crates/agent_ui_v2/src/agent_ui_v2.rs new file mode 100644 index 0000000000000000000000000000000000000000..92a4144e304e9afbdcdde54623a3bbf3c65b8746 --- /dev/null +++ b/crates/agent_ui_v2/src/agent_ui_v2.rs @@ -0,0 +1,4 @@ +mod agent_thread_pane; +mod thread_history; + +pub mod agents_panel; diff --git a/crates/agent_ui_v2/src/agents_panel.rs b/crates/agent_ui_v2/src/agents_panel.rs new file mode 100644 index 0000000000000000000000000000000000000000..ace5e73f56b9eff4292f34263bfe08a94e2d6050 --- /dev/null +++ b/crates/agent_ui_v2/src/agents_panel.rs @@ -0,0 +1,438 @@ +use agent::{HistoryEntry, HistoryEntryId, HistoryStore}; +use agent_settings::AgentSettings; +use anyhow::Result; +use assistant_text_thread::TextThreadStore; +use db::kvp::KEY_VALUE_STORE; +use feature_flags::{AgentV2FeatureFlag, FeatureFlagAppExt}; +use fs::Fs; +use gpui::{ + Action, AsyncWindowContext, Entity, EventEmitter, Focusable, Pixels, Subscription, Task, + WeakEntity, actions, prelude::*, +}; +use project::Project; +use prompt_store::{PromptBuilder, PromptStore}; +use serde::{Deserialize, Serialize}; +use settings::{Settings as _, update_settings_file}; +use std::sync::Arc; +use ui::{App, Context, IconName, IntoElement, ParentElement, Render, Styled, Window}; +use util::ResultExt; +use workspace::{ + Panel, Workspace, + dock::{ClosePane, DockPosition, PanelEvent, UtilityPane}, + utility_pane::{UtilityPaneSlot, utility_slot_for_dock_position}, +}; + +use crate::agent_thread_pane::{ + AgentThreadPane, AgentsUtilityPaneEvent, SerializedAgentThreadPane, SerializedHistoryEntryId, +}; +use crate::thread_history::{AcpThreadHistory, ThreadHistoryEvent}; + +const AGENTS_PANEL_KEY: &str = "agents_panel"; + +#[derive(Serialize, Deserialize, Debug)] +struct SerializedAgentsPanel { + width: Option, + pane: Option, +} + +actions!( + agents, + [ + /// Toggle the visibility of the agents panel. + ToggleAgentsPanel + ] +); + +pub fn init(cx: &mut App) { + cx.observe_new(|workspace: &mut Workspace, _, _| { + workspace.register_action(|workspace, _: &ToggleAgentsPanel, window, cx| { + workspace.toggle_panel_focus::(window, cx); + }); + }) + .detach(); +} + +pub struct AgentsPanel { + focus_handle: gpui::FocusHandle, + workspace: WeakEntity, + project: Entity, + agent_thread_pane: Option>, + history: Entity, + history_store: Entity, + prompt_store: Option>, + fs: Arc, + width: Option, + pending_serialization: Task>, + _subscriptions: Vec, +} + +impl AgentsPanel { + pub fn load( + workspace: WeakEntity, + cx: AsyncWindowContext, + ) -> Task, anyhow::Error>> { + cx.spawn(async move |cx| { + let serialized_panel = cx + .background_spawn(async move { + KEY_VALUE_STORE + .read_kvp(AGENTS_PANEL_KEY) + .ok() + .flatten() + .and_then(|panel| { + serde_json::from_str::(&panel).ok() + }) + }) + .await; + + let (fs, project, prompt_builder) = workspace.update(cx, |workspace, cx| { + let fs = workspace.app_state().fs.clone(); + let project = workspace.project().clone(); + let prompt_builder = PromptBuilder::load(fs.clone(), false, cx); + (fs, project, prompt_builder) + })?; + + let text_thread_store = workspace + .update(cx, |_, cx| { + TextThreadStore::new( + project.clone(), + prompt_builder.clone(), + Default::default(), + cx, + ) + })? + .await?; + + let prompt_store = workspace + .update(cx, |_, cx| PromptStore::global(cx))? + .await + .log_err(); + + workspace.update_in(cx, |_, window, cx| { + cx.new(|cx| { + let mut panel = Self::new( + workspace.clone(), + fs, + project, + prompt_store, + text_thread_store, + window, + cx, + ); + if let Some(serialized_panel) = serialized_panel { + panel.width = serialized_panel.width; + if let Some(serialized_pane) = serialized_panel.pane { + panel.restore_utility_pane(serialized_pane, window, cx); + } + } + panel + }) + }) + }) + } + + fn new( + workspace: WeakEntity, + fs: Arc, + project: Entity, + prompt_store: Option>, + text_thread_store: Entity, + window: &mut Window, + cx: &mut ui::Context, + ) -> Self { + let focus_handle = cx.focus_handle(); + + let history_store = cx.new(|cx| HistoryStore::new(text_thread_store, cx)); + let history = cx.new(|cx| AcpThreadHistory::new(history_store.clone(), window, cx)); + + let this = cx.weak_entity(); + let subscriptions = vec![ + cx.subscribe_in(&history, window, Self::handle_history_event), + cx.on_flags_ready(move |_, cx| { + this.update(cx, |_, cx| { + cx.notify(); + }) + .ok(); + }), + ]; + + Self { + focus_handle, + workspace, + project, + agent_thread_pane: None, + history, + history_store, + prompt_store, + fs, + width: None, + pending_serialization: Task::ready(None), + _subscriptions: subscriptions, + } + } + + fn restore_utility_pane( + &mut self, + serialized_pane: SerializedAgentThreadPane, + window: &mut Window, + cx: &mut Context, + ) { + let Some(thread_id) = &serialized_pane.thread_id else { + return; + }; + + let entry = self + .history_store + .read(cx) + .entries() + .find(|e| match (&e.id(), thread_id) { + ( + HistoryEntryId::AcpThread(session_id), + SerializedHistoryEntryId::AcpThread(id), + ) => session_id.to_string() == *id, + (HistoryEntryId::TextThread(path), SerializedHistoryEntryId::TextThread(id)) => { + path.to_string_lossy() == *id + } + _ => false, + }); + + if let Some(entry) = entry { + self.open_thread( + entry, + serialized_pane.expanded, + serialized_pane.width, + window, + cx, + ); + } + } + + fn handle_utility_pane_event( + &mut self, + _utility_pane: Entity, + event: &AgentsUtilityPaneEvent, + cx: &mut Context, + ) { + match event { + AgentsUtilityPaneEvent::StateChanged => { + self.serialize(cx); + cx.notify(); + } + } + } + + fn handle_close_pane_event( + &mut self, + _utility_pane: Entity, + _event: &ClosePane, + cx: &mut Context, + ) { + self.agent_thread_pane = None; + self.serialize(cx); + cx.notify(); + } + + fn handle_history_event( + &mut self, + _history: &Entity, + event: &ThreadHistoryEvent, + window: &mut Window, + cx: &mut Context, + ) { + match event { + ThreadHistoryEvent::Open(entry) => { + self.open_thread(entry.clone(), true, None, window, cx); + } + } + } + + fn open_thread( + &mut self, + entry: HistoryEntry, + expanded: bool, + width: Option, + window: &mut Window, + cx: &mut Context, + ) { + let entry_id = entry.id(); + + if let Some(existing_pane) = &self.agent_thread_pane { + if existing_pane.read(cx).thread_id() == Some(entry_id) { + existing_pane.update(cx, |pane, cx| { + pane.set_expanded(true, cx); + }); + return; + } + } + + let fs = self.fs.clone(); + let workspace = self.workspace.clone(); + let project = self.project.clone(); + let history_store = self.history_store.clone(); + let prompt_store = self.prompt_store.clone(); + + let agent_thread_pane = cx.new(|cx| { + let mut pane = AgentThreadPane::new(workspace.clone(), cx); + pane.open_thread( + entry, + fs, + workspace.clone(), + project, + history_store, + prompt_store, + window, + cx, + ); + if let Some(width) = width { + pane.set_width(Some(width), cx); + } + pane.set_expanded(expanded, cx); + pane + }); + + let state_subscription = cx.subscribe(&agent_thread_pane, Self::handle_utility_pane_event); + let close_subscription = cx.subscribe(&agent_thread_pane, Self::handle_close_pane_event); + + self._subscriptions.push(state_subscription); + self._subscriptions.push(close_subscription); + + let slot = self.utility_slot(window, cx); + let panel_id = cx.entity_id(); + + if let Some(workspace) = self.workspace.upgrade() { + workspace.update(cx, |workspace, cx| { + workspace.register_utility_pane(slot, panel_id, agent_thread_pane.clone(), cx); + }); + } + + self.agent_thread_pane = Some(agent_thread_pane); + self.serialize(cx); + cx.notify(); + } + + fn utility_slot(&self, window: &Window, cx: &App) -> UtilityPaneSlot { + let position = self.position(window, cx); + utility_slot_for_dock_position(position) + } + + fn re_register_utility_pane(&mut self, window: &mut Window, cx: &mut Context) { + if let Some(pane) = &self.agent_thread_pane { + let slot = self.utility_slot(window, cx); + let panel_id = cx.entity_id(); + let pane = pane.clone(); + + if let Some(workspace) = self.workspace.upgrade() { + workspace.update(cx, |workspace, cx| { + workspace.register_utility_pane(slot, panel_id, pane, cx); + }); + } + } + } + + fn serialize(&mut self, cx: &mut Context) { + let width = self.width; + let pane = self + .agent_thread_pane + .as_ref() + .map(|pane| pane.read(cx).serialize()); + + self.pending_serialization = cx.background_spawn(async move { + KEY_VALUE_STORE + .write_kvp( + AGENTS_PANEL_KEY.into(), + serde_json::to_string(&SerializedAgentsPanel { width, pane }).unwrap(), + ) + .await + .log_err() + }); + } +} + +impl EventEmitter for AgentsPanel {} + +impl Focusable for AgentsPanel { + fn focus_handle(&self, _cx: &ui::App) -> gpui::FocusHandle { + self.focus_handle.clone() + } +} + +impl Panel for AgentsPanel { + fn persistent_name() -> &'static str { + "AgentsPanel" + } + + fn panel_key() -> &'static str { + AGENTS_PANEL_KEY + } + + fn position(&self, _window: &Window, cx: &App) -> DockPosition { + match AgentSettings::get_global(cx).agents_panel_dock { + settings::DockSide::Left => DockPosition::Left, + settings::DockSide::Right => DockPosition::Right, + } + } + + fn position_is_valid(&self, position: DockPosition) -> bool { + position != DockPosition::Bottom + } + + fn set_position( + &mut self, + position: DockPosition, + window: &mut Window, + cx: &mut Context, + ) { + update_settings_file(self.fs.clone(), cx, move |settings, _| { + settings.agent.get_or_insert_default().agents_panel_dock = Some(match position { + DockPosition::Left => settings::DockSide::Left, + DockPosition::Bottom => settings::DockSide::Right, + DockPosition::Right => settings::DockSide::Left, + }); + }); + self.re_register_utility_pane(window, cx); + } + + fn size(&self, window: &Window, cx: &App) -> Pixels { + let settings = AgentSettings::get_global(cx); + match self.position(window, cx) { + DockPosition::Left | DockPosition::Right => { + self.width.unwrap_or(settings.default_width) + } + DockPosition::Bottom => self.width.unwrap_or(settings.default_height), + } + } + + fn set_size(&mut self, size: Option, window: &mut Window, cx: &mut Context) { + match self.position(window, cx) { + DockPosition::Left | DockPosition::Right => self.width = size, + DockPosition::Bottom => {} + } + self.serialize(cx); + cx.notify(); + } + + fn icon(&self, _window: &Window, cx: &App) -> Option { + (self.enabled(cx) && AgentSettings::get_global(cx).button).then_some(IconName::ZedAgent) + } + + fn icon_tooltip(&self, _window: &Window, _cx: &App) -> Option<&'static str> { + Some("Agents Panel") + } + + fn toggle_action(&self) -> Box { + Box::new(ToggleAgentsPanel) + } + + fn activation_priority(&self) -> u32 { + 4 + } + + fn enabled(&self, cx: &App) -> bool { + AgentSettings::get_global(cx).enabled(cx) && cx.has_flag::() + } +} + +impl Render for AgentsPanel { + fn render(&mut self, _window: &mut Window, _cx: &mut Context) -> impl IntoElement { + gpui::div().size_full().child(self.history.clone()) + } +} diff --git a/crates/agent_ui_v2/src/thread_history.rs b/crates/agent_ui_v2/src/thread_history.rs new file mode 100644 index 0000000000000000000000000000000000000000..8f6626814902a9489536439e90041437a527e151 --- /dev/null +++ b/crates/agent_ui_v2/src/thread_history.rs @@ -0,0 +1,735 @@ +use agent::{HistoryEntry, HistoryStore}; +use chrono::{Datelike as _, Local, NaiveDate, TimeDelta}; +use editor::{Editor, EditorEvent}; +use fuzzy::StringMatchCandidate; +use gpui::{ + App, Entity, EventEmitter, FocusHandle, Focusable, ScrollStrategy, Task, + UniformListScrollHandle, Window, actions, uniform_list, +}; +use std::{fmt::Display, ops::Range}; +use text::Bias; +use time::{OffsetDateTime, UtcOffset}; +use ui::{ + HighlightedLabel, IconButtonShape, ListItem, ListItemSpacing, Tab, Tooltip, WithScrollbar, + prelude::*, +}; + +actions!( + agents, + [ + /// Removes all thread history. + RemoveHistory, + /// Removes the currently selected thread. + RemoveSelectedThread, + ] +); + +pub struct AcpThreadHistory { + pub(crate) history_store: Entity, + scroll_handle: UniformListScrollHandle, + selected_index: usize, + hovered_index: Option, + search_editor: Entity, + search_query: SharedString, + visible_items: Vec, + local_timezone: UtcOffset, + confirming_delete_history: bool, + _update_task: Task<()>, + _subscriptions: Vec, +} + +enum ListItemType { + BucketSeparator(TimeBucket), + Entry { + entry: HistoryEntry, + format: EntryTimeFormat, + }, + SearchResult { + entry: HistoryEntry, + positions: Vec, + }, +} + +impl ListItemType { + fn history_entry(&self) -> Option<&HistoryEntry> { + match self { + ListItemType::Entry { entry, .. } => Some(entry), + ListItemType::SearchResult { entry, .. } => Some(entry), + _ => None, + } + } +} + +#[allow(dead_code)] +pub enum ThreadHistoryEvent { + Open(HistoryEntry), +} + +impl EventEmitter for AcpThreadHistory {} + +impl AcpThreadHistory { + pub fn new( + history_store: Entity, + window: &mut Window, + cx: &mut Context, + ) -> Self { + let search_editor = cx.new(|cx| { + let mut editor = Editor::single_line(window, cx); + editor.set_placeholder_text("Search threads...", window, cx); + editor + }); + + let search_editor_subscription = + cx.subscribe(&search_editor, |this, search_editor, event, cx| { + if let EditorEvent::BufferEdited = event { + let query = search_editor.read(cx).text(cx); + if this.search_query != query { + this.search_query = query.into(); + this.update_visible_items(false, cx); + } + } + }); + + let history_store_subscription = cx.observe(&history_store, |this, _, cx| { + this.update_visible_items(true, cx); + }); + + let scroll_handle = UniformListScrollHandle::default(); + + let mut this = Self { + history_store, + scroll_handle, + selected_index: 0, + hovered_index: None, + visible_items: Default::default(), + search_editor, + local_timezone: UtcOffset::from_whole_seconds( + chrono::Local::now().offset().local_minus_utc(), + ) + .unwrap(), + search_query: SharedString::default(), + confirming_delete_history: false, + _subscriptions: vec![search_editor_subscription, history_store_subscription], + _update_task: Task::ready(()), + }; + this.update_visible_items(false, cx); + this + } + + fn update_visible_items(&mut self, preserve_selected_item: bool, cx: &mut Context) { + let entries = self + .history_store + .update(cx, |store, _| store.entries().collect()); + let new_list_items = if self.search_query.is_empty() { + self.add_list_separators(entries, cx) + } else { + self.filter_search_results(entries, cx) + }; + let selected_history_entry = if preserve_selected_item { + self.selected_history_entry().cloned() + } else { + None + }; + + self._update_task = cx.spawn(async move |this, cx| { + let new_visible_items = new_list_items.await; + this.update(cx, |this, cx| { + let new_selected_index = if let Some(history_entry) = selected_history_entry { + let history_entry_id = history_entry.id(); + new_visible_items + .iter() + .position(|visible_entry| { + visible_entry + .history_entry() + .is_some_and(|entry| entry.id() == history_entry_id) + }) + .unwrap_or(0) + } else { + 0 + }; + + this.visible_items = new_visible_items; + this.set_selected_index(new_selected_index, Bias::Right, cx); + cx.notify(); + }) + .ok(); + }); + } + + fn add_list_separators(&self, entries: Vec, cx: &App) -> Task> { + cx.background_spawn(async move { + let mut items = Vec::with_capacity(entries.len() + 1); + let mut bucket = None; + let today = Local::now().naive_local().date(); + + for entry in entries.into_iter() { + let entry_date = entry + .updated_at() + .with_timezone(&Local) + .naive_local() + .date(); + let entry_bucket = TimeBucket::from_dates(today, entry_date); + + if Some(entry_bucket) != bucket { + bucket = Some(entry_bucket); + items.push(ListItemType::BucketSeparator(entry_bucket)); + } + + items.push(ListItemType::Entry { + entry, + format: entry_bucket.into(), + }); + } + items + }) + } + + fn filter_search_results( + &self, + entries: Vec, + cx: &App, + ) -> Task> { + let query = self.search_query.clone(); + cx.background_spawn({ + let executor = cx.background_executor().clone(); + async move { + let mut candidates = Vec::with_capacity(entries.len()); + + for (idx, entry) in entries.iter().enumerate() { + candidates.push(StringMatchCandidate::new(idx, entry.title())); + } + + const MAX_MATCHES: usize = 100; + + let matches = fuzzy::match_strings( + &candidates, + &query, + false, + true, + MAX_MATCHES, + &Default::default(), + executor, + ) + .await; + + matches + .into_iter() + .map(|search_match| ListItemType::SearchResult { + entry: entries[search_match.candidate_id].clone(), + positions: search_match.positions, + }) + .collect() + } + }) + } + + fn search_produced_no_matches(&self) -> bool { + self.visible_items.is_empty() && !self.search_query.is_empty() + } + + fn selected_history_entry(&self) -> Option<&HistoryEntry> { + self.get_history_entry(self.selected_index) + } + + fn get_history_entry(&self, visible_items_ix: usize) -> Option<&HistoryEntry> { + self.visible_items.get(visible_items_ix)?.history_entry() + } + + fn set_selected_index(&mut self, mut index: usize, bias: Bias, cx: &mut Context) { + if self.visible_items.is_empty() { + self.selected_index = 0; + return; + } + while matches!( + self.visible_items.get(index), + None | Some(ListItemType::BucketSeparator(..)) + ) { + index = match bias { + Bias::Left => { + if index == 0 { + self.visible_items.len() - 1 + } else { + index - 1 + } + } + Bias::Right => { + if index >= self.visible_items.len() - 1 { + 0 + } else { + index + 1 + } + } + }; + } + self.selected_index = index; + self.scroll_handle + .scroll_to_item(index, ScrollStrategy::Top); + cx.notify() + } + + pub fn select_previous( + &mut self, + _: &menu::SelectPrevious, + _window: &mut Window, + cx: &mut Context, + ) { + if self.selected_index == 0 { + self.set_selected_index(self.visible_items.len() - 1, Bias::Left, cx); + } else { + self.set_selected_index(self.selected_index - 1, Bias::Left, cx); + } + } + + pub fn select_next( + &mut self, + _: &menu::SelectNext, + _window: &mut Window, + cx: &mut Context, + ) { + if self.selected_index == self.visible_items.len() - 1 { + self.set_selected_index(0, Bias::Right, cx); + } else { + self.set_selected_index(self.selected_index + 1, Bias::Right, cx); + } + } + + fn select_first( + &mut self, + _: &menu::SelectFirst, + _window: &mut Window, + cx: &mut Context, + ) { + self.set_selected_index(0, Bias::Right, cx); + } + + fn select_last(&mut self, _: &menu::SelectLast, _window: &mut Window, cx: &mut Context) { + self.set_selected_index(self.visible_items.len() - 1, Bias::Left, cx); + } + + fn confirm(&mut self, _: &menu::Confirm, _window: &mut Window, cx: &mut Context) { + self.confirm_entry(self.selected_index, cx); + } + + fn confirm_entry(&mut self, ix: usize, cx: &mut Context) { + let Some(entry) = self.get_history_entry(ix) else { + return; + }; + cx.emit(ThreadHistoryEvent::Open(entry.clone())); + } + + fn remove_selected_thread( + &mut self, + _: &RemoveSelectedThread, + _window: &mut Window, + cx: &mut Context, + ) { + self.remove_thread(self.selected_index, cx) + } + + fn remove_thread(&mut self, visible_item_ix: usize, cx: &mut Context) { + let Some(entry) = self.get_history_entry(visible_item_ix) else { + return; + }; + + let task = match entry { + HistoryEntry::AcpThread(thread) => self + .history_store + .update(cx, |this, cx| this.delete_thread(thread.id.clone(), cx)), + HistoryEntry::TextThread(text_thread) => self.history_store.update(cx, |this, cx| { + this.delete_text_thread(text_thread.path.clone(), cx) + }), + }; + task.detach_and_log_err(cx); + } + + fn remove_history(&mut self, _window: &mut Window, cx: &mut Context) { + self.history_store.update(cx, |store, cx| { + store.delete_threads(cx).detach_and_log_err(cx) + }); + self.confirming_delete_history = false; + cx.notify(); + } + + fn prompt_delete_history(&mut self, _window: &mut Window, cx: &mut Context) { + self.confirming_delete_history = true; + cx.notify(); + } + + fn cancel_delete_history(&mut self, _window: &mut Window, cx: &mut Context) { + self.confirming_delete_history = false; + cx.notify(); + } + + fn render_list_items( + &mut self, + range: Range, + _window: &mut Window, + cx: &mut Context, + ) -> Vec { + self.visible_items + .get(range.clone()) + .into_iter() + .flatten() + .enumerate() + .map(|(ix, item)| self.render_list_item(item, range.start + ix, cx)) + .collect() + } + + fn render_list_item(&self, item: &ListItemType, ix: usize, cx: &Context) -> AnyElement { + match item { + ListItemType::Entry { entry, format } => self + .render_history_entry(entry, *format, ix, Vec::default(), cx) + .into_any(), + ListItemType::SearchResult { entry, positions } => self.render_history_entry( + entry, + EntryTimeFormat::DateAndTime, + ix, + positions.clone(), + cx, + ), + ListItemType::BucketSeparator(bucket) => div() + .px(DynamicSpacing::Base06.rems(cx)) + .pt_2() + .pb_1() + .child( + Label::new(bucket.to_string()) + .size(LabelSize::XSmall) + .color(Color::Muted), + ) + .into_any_element(), + } + } + + fn render_history_entry( + &self, + entry: &HistoryEntry, + format: EntryTimeFormat, + ix: usize, + highlight_positions: Vec, + cx: &Context, + ) -> AnyElement { + let selected = ix == self.selected_index; + let hovered = Some(ix) == self.hovered_index; + let timestamp = entry.updated_at().timestamp(); + let thread_timestamp = format.format_timestamp(timestamp, self.local_timezone); + + h_flex() + .w_full() + .pb_1() + .child( + ListItem::new(ix) + .rounded() + .toggle_state(selected) + .spacing(ListItemSpacing::Sparse) + .start_slot( + h_flex() + .w_full() + .gap_2() + .justify_between() + .child( + HighlightedLabel::new(entry.title(), highlight_positions) + .size(LabelSize::Small) + .truncate(), + ) + .child( + Label::new(thread_timestamp) + .color(Color::Muted) + .size(LabelSize::XSmall), + ), + ) + .on_hover(cx.listener(move |this, is_hovered, _window, cx| { + if *is_hovered { + this.hovered_index = Some(ix); + } else if this.hovered_index == Some(ix) { + this.hovered_index = None; + } + + cx.notify(); + })) + .end_slot::(if hovered { + Some( + IconButton::new("delete", IconName::Trash) + .shape(IconButtonShape::Square) + .icon_size(IconSize::XSmall) + .icon_color(Color::Muted) + .tooltip(move |_window, cx| { + Tooltip::for_action("Delete", &RemoveSelectedThread, cx) + }) + .on_click(cx.listener(move |this, _, _, cx| { + this.remove_thread(ix, cx); + cx.stop_propagation() + })), + ) + } else { + None + }) + .on_click(cx.listener(move |this, _, _, cx| this.confirm_entry(ix, cx))), + ) + .into_any_element() + } +} + +impl Focusable for AcpThreadHistory { + fn focus_handle(&self, cx: &App) -> FocusHandle { + self.search_editor.focus_handle(cx) + } +} + +impl Render for AcpThreadHistory { + fn render(&mut self, window: &mut Window, cx: &mut Context) -> impl IntoElement { + let has_no_history = self.history_store.read(cx).is_empty(cx); + + v_flex() + .key_context("ThreadHistory") + .size_full() + .bg(cx.theme().colors().panel_background) + .on_action(cx.listener(Self::select_previous)) + .on_action(cx.listener(Self::select_next)) + .on_action(cx.listener(Self::select_first)) + .on_action(cx.listener(Self::select_last)) + .on_action(cx.listener(Self::confirm)) + .on_action(cx.listener(Self::remove_selected_thread)) + .on_action(cx.listener(|this, _: &RemoveHistory, window, cx| { + this.remove_history(window, cx); + })) + .child( + h_flex() + .h(Tab::container_height(cx)) + .w_full() + .py_1() + .px_2() + .gap_2() + .justify_between() + .border_b_1() + .border_color(cx.theme().colors().border) + .child( + Icon::new(IconName::MagnifyingGlass) + .color(Color::Muted) + .size(IconSize::Small), + ) + .child(self.search_editor.clone()), + ) + .child({ + let view = v_flex() + .id("list-container") + .relative() + .overflow_hidden() + .flex_grow(); + + if has_no_history { + view.justify_center().items_center().child( + Label::new("You don't have any past threads yet.") + .size(LabelSize::Small) + .color(Color::Muted), + ) + } else if self.search_produced_no_matches() { + view.justify_center() + .items_center() + .child(Label::new("No threads match your search.").size(LabelSize::Small)) + } else { + view.child( + uniform_list( + "thread-history", + self.visible_items.len(), + cx.processor(|this, range: Range, window, cx| { + this.render_list_items(range, window, cx) + }), + ) + .p_1() + .pr_4() + .track_scroll(&self.scroll_handle) + .flex_grow(), + ) + .vertical_scrollbar_for(&self.scroll_handle, window, cx) + } + }) + .when(!has_no_history, |this| { + this.child( + h_flex() + .p_2() + .border_t_1() + .border_color(cx.theme().colors().border_variant) + .when(!self.confirming_delete_history, |this| { + this.child( + Button::new("delete_history", "Delete All History") + .full_width() + .style(ButtonStyle::Outlined) + .label_size(LabelSize::Small) + .on_click(cx.listener(|this, _, window, cx| { + this.prompt_delete_history(window, cx); + })), + ) + }) + .when(self.confirming_delete_history, |this| { + this.w_full() + .gap_2() + .flex_wrap() + .justify_between() + .child( + h_flex() + .flex_wrap() + .gap_1() + .child( + Label::new("Delete all threads?") + .size(LabelSize::Small), + ) + .child( + Label::new("You won't be able to recover them later.") + .size(LabelSize::Small) + .color(Color::Muted), + ), + ) + .child( + h_flex() + .gap_1() + .child( + Button::new("cancel_delete", "Cancel") + .label_size(LabelSize::Small) + .on_click(cx.listener(|this, _, window, cx| { + this.cancel_delete_history(window, cx); + })), + ) + .child( + Button::new("confirm_delete", "Delete") + .style(ButtonStyle::Tinted(ui::TintColor::Error)) + .color(Color::Error) + .label_size(LabelSize::Small) + .on_click(cx.listener(|_, _, window, cx| { + window.dispatch_action( + Box::new(RemoveHistory), + cx, + ); + })), + ), + ) + }), + ) + }) + } +} + +#[derive(Clone, Copy)] +pub enum EntryTimeFormat { + DateAndTime, + TimeOnly, +} + +impl EntryTimeFormat { + fn format_timestamp(&self, timestamp: i64, timezone: UtcOffset) -> String { + let timestamp = OffsetDateTime::from_unix_timestamp(timestamp).unwrap(); + + match self { + EntryTimeFormat::DateAndTime => time_format::format_localized_timestamp( + timestamp, + OffsetDateTime::now_utc(), + timezone, + time_format::TimestampFormat::EnhancedAbsolute, + ), + EntryTimeFormat::TimeOnly => time_format::format_time(timestamp.to_offset(timezone)), + } + } +} + +impl From for EntryTimeFormat { + fn from(bucket: TimeBucket) -> Self { + match bucket { + TimeBucket::Today => EntryTimeFormat::TimeOnly, + TimeBucket::Yesterday => EntryTimeFormat::TimeOnly, + TimeBucket::ThisWeek => EntryTimeFormat::DateAndTime, + TimeBucket::PastWeek => EntryTimeFormat::DateAndTime, + TimeBucket::All => EntryTimeFormat::DateAndTime, + } + } +} + +#[derive(PartialEq, Eq, Clone, Copy, Debug)] +enum TimeBucket { + Today, + Yesterday, + ThisWeek, + PastWeek, + All, +} + +impl TimeBucket { + fn from_dates(reference: NaiveDate, date: NaiveDate) -> Self { + if date == reference { + return TimeBucket::Today; + } + + if date == reference - TimeDelta::days(1) { + return TimeBucket::Yesterday; + } + + let week = date.iso_week(); + + if reference.iso_week() == week { + return TimeBucket::ThisWeek; + } + + let last_week = (reference - TimeDelta::days(7)).iso_week(); + + if week == last_week { + return TimeBucket::PastWeek; + } + + TimeBucket::All + } +} + +impl Display for TimeBucket { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + TimeBucket::Today => write!(f, "Today"), + TimeBucket::Yesterday => write!(f, "Yesterday"), + TimeBucket::ThisWeek => write!(f, "This Week"), + TimeBucket::PastWeek => write!(f, "Past Week"), + TimeBucket::All => write!(f, "All"), + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + use chrono::NaiveDate; + + #[test] + fn test_time_bucket_from_dates() { + let today = NaiveDate::from_ymd_opt(2023, 1, 15).unwrap(); + + let date = today; + assert_eq!(TimeBucket::from_dates(today, date), TimeBucket::Today); + + let date = NaiveDate::from_ymd_opt(2023, 1, 14).unwrap(); + assert_eq!(TimeBucket::from_dates(today, date), TimeBucket::Yesterday); + + let date = NaiveDate::from_ymd_opt(2023, 1, 13).unwrap(); + assert_eq!(TimeBucket::from_dates(today, date), TimeBucket::ThisWeek); + + let date = NaiveDate::from_ymd_opt(2023, 1, 11).unwrap(); + assert_eq!(TimeBucket::from_dates(today, date), TimeBucket::ThisWeek); + + let date = NaiveDate::from_ymd_opt(2023, 1, 8).unwrap(); + assert_eq!(TimeBucket::from_dates(today, date), TimeBucket::PastWeek); + + let date = NaiveDate::from_ymd_opt(2023, 1, 5).unwrap(); + assert_eq!(TimeBucket::from_dates(today, date), TimeBucket::PastWeek); + + // All: not in this week or last week + let date = NaiveDate::from_ymd_opt(2023, 1, 1).unwrap(); + assert_eq!(TimeBucket::from_dates(today, date), TimeBucket::All); + + // Test year boundary cases + let new_year = NaiveDate::from_ymd_opt(2023, 1, 1).unwrap(); + + let date = NaiveDate::from_ymd_opt(2022, 12, 31).unwrap(); + assert_eq!( + TimeBucket::from_dates(new_year, date), + TimeBucket::Yesterday + ); + + let date = NaiveDate::from_ymd_opt(2022, 12, 28).unwrap(); + assert_eq!(TimeBucket::from_dates(new_year, date), TimeBucket::ThisWeek); + } +} diff --git a/crates/debugger_ui/src/debugger_panel.rs b/crates/debugger_ui/src/debugger_panel.rs index bdb308aafd0d2899f17bef732ac38239c4df6dda..104a85dc097c575e7a4cd8f4a66a98a8bb6b0d69 100644 --- a/crates/debugger_ui/src/debugger_panel.rs +++ b/crates/debugger_ui/src/debugger_panel.rs @@ -1557,7 +1557,7 @@ impl Panel for DebugPanel { self.sessions_with_children.keys().for_each(|session_item| { session_item.update(cx, |item, cx| { item.running_state() - .update(cx, |state, _| state.invert_axies()) + .update(cx, |state, cx| state.invert_axies(cx)) }) }); } diff --git a/crates/debugger_ui/src/session/running.rs b/crates/debugger_ui/src/session/running.rs index 66e9dd7b434e628898add7056b15c1789e32519c..4898ec95ca3c5b55669896b3c1d898326851c0c3 100644 --- a/crates/debugger_ui/src/session/running.rs +++ b/crates/debugger_ui/src/session/running.rs @@ -348,7 +348,7 @@ pub(crate) fn new_debugger_pane( debug_assert!(_previous_subscription.is_none()); running .panes - .split(&this_pane, &new_pane, split_direction)?; + .split(&this_pane, &new_pane, split_direction, cx)?; anyhow::Ok(new_pane) }) }) @@ -1462,7 +1462,7 @@ impl RunningState { this.serialize_layout(window, cx); match event { Event::Remove { .. } => { - let _did_find_pane = this.panes.remove(source_pane).is_ok(); + let _did_find_pane = this.panes.remove(source_pane, cx).is_ok(); debug_assert!(_did_find_pane); cx.notify(); } @@ -1889,9 +1889,9 @@ impl RunningState { Member::Axis(group_root) } - pub(crate) fn invert_axies(&mut self) { + pub(crate) fn invert_axies(&mut self, cx: &mut App) { self.dock_axis = self.dock_axis.invert(); - self.panes.invert_axies(); + self.panes.invert_axies(cx); } } diff --git a/crates/editor/src/split.rs b/crates/editor/src/split.rs index 8a413a376f2296acdacddc97707a6112e8cd5185..b5090f06dc1e68d609413db31112775e56559689 100644 --- a/crates/editor/src/split.rs +++ b/crates/editor/src/split.rs @@ -194,7 +194,7 @@ impl SplittableEditor { }); let primary_pane = self.panes.first_pane(); self.panes - .split(&primary_pane, &secondary_pane, SplitDirection::Left) + .split(&primary_pane, &secondary_pane, SplitDirection::Left, cx) .unwrap(); cx.notify(); } @@ -203,7 +203,7 @@ impl SplittableEditor { let Some(secondary) = self.secondary.take() else { return; }; - self.panes.remove(&secondary.pane).unwrap(); + self.panes.remove(&secondary.pane, cx).unwrap(); self.primary_editor.update(cx, |primary, cx| { primary.buffer().update(cx, |buffer, _| { buffer.set_filter_mode(None); diff --git a/crates/feature_flags/src/flags.rs b/crates/feature_flags/src/flags.rs index b96b8a04d1412b03f87a011a4ed324e053bf5dc5..1768e43d1d0a88433d61c6390f912377c2ba55e3 100644 --- a/crates/feature_flags/src/flags.rs +++ b/crates/feature_flags/src/flags.rs @@ -17,3 +17,9 @@ pub struct InlineAssistantUseToolFeatureFlag; impl FeatureFlag for InlineAssistantUseToolFeatureFlag { const NAME: &'static str = "inline-assistant-use-tool"; } + +pub struct AgentV2FeatureFlag; + +impl FeatureFlag for AgentV2FeatureFlag { + const NAME: &'static str = "agent-v2"; +} diff --git a/crates/settings/src/settings_content/agent.rs b/crates/settings/src/settings_content/agent.rs index fccc3e09fceb8e05ad3494101a4d23d95257358e..f7a88deb7d8ba88db6497da2cf79035a64446456 100644 --- a/crates/settings/src/settings_content/agent.rs +++ b/crates/settings/src/settings_content/agent.rs @@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize}; use settings_macros::{MergeFrom, with_fallible_options}; use std::{borrow::Cow, path::PathBuf, sync::Arc}; -use crate::DockPosition; +use crate::{DockPosition, DockSide}; #[with_fallible_options] #[derive(Clone, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom, Debug, Default)] @@ -22,6 +22,10 @@ pub struct AgentSettingsContent { /// /// Default: right pub dock: Option, + /// Where to dock the utility pane (the thread view pane). + /// + /// Default: left + pub agents_panel_dock: Option, /// Default width in pixels when the agent panel is docked to the left or right. /// /// Default: 640 diff --git a/crates/terminal_view/src/terminal_panel.rs b/crates/terminal_view/src/terminal_panel.rs index ab89787fc88510f4c92e929d96b51c682ff0af61..fb660e759c75aee9752cbaa3bdc8c8e0a47615e3 100644 --- a/crates/terminal_view/src/terminal_panel.rs +++ b/crates/terminal_view/src/terminal_panel.rs @@ -342,7 +342,7 @@ impl TerminalPanel { pane::Event::RemovedItem { .. } => self.serialize(cx), pane::Event::Remove { focus_on_pane } => { let pane_count_before_removal = self.center.panes().len(); - let _removal_result = self.center.remove(pane); + let _removal_result = self.center.remove(pane, cx); if pane_count_before_removal == 1 { self.center.first_pane().update(cx, |pane, cx| { pane.set_zoomed(false, cx); @@ -393,7 +393,10 @@ impl TerminalPanel { }; panel .update_in(cx, |panel, window, cx| { - panel.center.split(&pane, &new_pane, direction).log_err(); + panel + .center + .split(&pane, &new_pane, direction, cx) + .log_err(); window.focus(&new_pane.focus_handle(cx)); }) .ok(); @@ -415,7 +418,7 @@ impl TerminalPanel { new_pane.update(cx, |pane, cx| { pane.add_item(item, true, true, None, window, cx); }); - self.center.split(&pane, &new_pane, direction).log_err(); + self.center.split(&pane, &new_pane, direction, cx).log_err(); window.focus(&new_pane.focus_handle(cx)); } } @@ -1066,7 +1069,7 @@ impl TerminalPanel { .find_pane_in_direction(&self.active_pane, direction, cx) .cloned() { - self.center.swap(&self.active_pane, &to); + self.center.swap(&self.active_pane, &to, cx); cx.notify(); } } @@ -1074,7 +1077,7 @@ impl TerminalPanel { fn move_pane_to_border(&mut self, direction: SplitDirection, cx: &mut Context) { if self .center - .move_to_border(&self.active_pane, direction) + .move_to_border(&self.active_pane, direction, cx) .unwrap() { cx.notify(); @@ -1189,6 +1192,7 @@ pub fn new_terminal_pane( &this_pane, &new_pane, split_direction, + cx, )?; anyhow::Ok(new_pane) }) @@ -1482,6 +1486,7 @@ impl Render for TerminalPanel { &terminal_panel.active_pane, &new_pane, SplitDirection::Right, + cx, ) .log_err(); let new_pane = new_pane.read(cx); diff --git a/crates/ui/src/components/tab_bar.rs b/crates/ui/src/components/tab_bar.rs index 5d41466e3caadf6697b3c1681a405dafa2fb3101..681f9a726e0d5f4796325a4533fca909617f1e08 100644 --- a/crates/ui/src/components/tab_bar.rs +++ b/crates/ui/src/components/tab_bar.rs @@ -10,6 +10,7 @@ pub struct TabBar { start_children: SmallVec<[AnyElement; 2]>, children: SmallVec<[AnyElement; 2]>, end_children: SmallVec<[AnyElement; 2]>, + pre_end_children: SmallVec<[AnyElement; 2]>, scroll_handle: Option, } @@ -20,6 +21,7 @@ impl TabBar { start_children: SmallVec::new(), children: SmallVec::new(), end_children: SmallVec::new(), + pre_end_children: SmallVec::new(), scroll_handle: None, } } @@ -70,6 +72,15 @@ impl TabBar { self } + pub fn pre_end_child(mut self, end_child: impl IntoElement) -> Self + where + Self: Sized, + { + self.pre_end_children + .push(end_child.into_element().into_any()); + self + } + pub fn end_children(mut self, end_children: impl IntoIterator) -> Self where Self: Sized, @@ -137,18 +148,31 @@ impl RenderOnce for TabBar { .children(self.children), ), ) - .when(!self.end_children.is_empty(), |this| { - this.child( - h_flex() - .flex_none() - .gap(DynamicSpacing::Base04.rems(cx)) - .px(DynamicSpacing::Base06.rems(cx)) - .border_b_1() - .border_l_1() - .border_color(cx.theme().colors().border) - .children(self.end_children), - ) - }) + .when( + !self.end_children.is_empty() || !self.pre_end_children.is_empty(), + |this| { + this.child( + h_flex() + .flex_none() + .gap(DynamicSpacing::Base04.rems(cx)) + .px(DynamicSpacing::Base06.rems(cx)) + .children(self.pre_end_children) + .border_color(cx.theme().colors().border) + .border_b_1() + .when(!self.end_children.is_empty(), |div| { + div.child( + h_flex() + .flex_none() + .pl(DynamicSpacing::Base04.rems(cx)) + .gap(DynamicSpacing::Base04.rems(cx)) + .border_l_1() + .border_color(cx.theme().colors().border) + .children(self.end_children), + ) + }), + ) + }, + ) } } diff --git a/crates/workspace/Cargo.toml b/crates/workspace/Cargo.toml index d5d3016ab2704392c6cc9cc4bcebf6d50701d3be..acf95df37f5d20da65b6e9fa4460ba09b2ea81e3 100644 --- a/crates/workspace/Cargo.toml +++ b/crates/workspace/Cargo.toml @@ -35,6 +35,7 @@ clock.workspace = true collections.workspace = true component.workspace = true db.workspace = true +feature_flags.workspace = true fs.workspace = true futures.workspace = true gpui.workspace = true diff --git a/crates/workspace/src/dock.rs b/crates/workspace/src/dock.rs index dfc341db9c71fd1059853b9480a7e679109ead40..edc5705a28ecd7d378c0f959ac82a6493c82d325 100644 --- a/crates/workspace/src/dock.rs +++ b/crates/workspace/src/dock.rs @@ -1,8 +1,10 @@ use crate::persistence::model::DockData; +use crate::utility_pane::utility_slot_for_dock_position; use crate::{DraggedDock, Event, ModalLayer, Pane}; use crate::{Workspace, status_bar::StatusItemView}; use anyhow::Context as _; use client::proto; + use gpui::{ Action, AnyView, App, Axis, Context, Corner, Entity, EntityId, EventEmitter, FocusHandle, Focusable, IntoElement, KeyContext, MouseButton, MouseDownEvent, MouseUpEvent, ParentElement, @@ -13,6 +15,7 @@ use settings::SettingsStore; use std::sync::Arc; use ui::{ContextMenu, Divider, DividerColor, IconButton, Tooltip, h_flex}; use ui::{prelude::*, right_click_menu}; +use util::ResultExt as _; pub(crate) const RESIZE_HANDLE_SIZE: Pixels = px(6.); @@ -25,6 +28,72 @@ pub enum PanelEvent { pub use proto::PanelId; +pub struct MinimizePane; +pub struct ClosePane; + +pub trait UtilityPane: EventEmitter + EventEmitter + Render { + fn position(&self, window: &Window, cx: &App) -> UtilityPanePosition; + /// The icon to render in the adjacent pane's tab bar for toggling this utility pane + fn toggle_icon(&self, cx: &App) -> IconName; + fn expanded(&self, cx: &App) -> bool; + fn set_expanded(&mut self, expanded: bool, cx: &mut Context); + fn width(&self, cx: &App) -> Pixels; + fn set_width(&mut self, width: Option, cx: &mut Context); +} + +pub trait UtilityPaneHandle: 'static + Send + Sync { + fn position(&self, window: &Window, cx: &App) -> UtilityPanePosition; + fn toggle_icon(&self, cx: &App) -> IconName; + fn expanded(&self, cx: &App) -> bool; + fn set_expanded(&self, expanded: bool, cx: &mut App); + fn width(&self, cx: &App) -> Pixels; + fn set_width(&self, width: Option, cx: &mut App); + fn to_any(&self) -> AnyView; + fn box_clone(&self) -> Box; +} + +impl UtilityPaneHandle for Entity +where + T: UtilityPane, +{ + fn position(&self, window: &Window, cx: &App) -> UtilityPanePosition { + self.read(cx).position(window, cx) + } + + fn toggle_icon(&self, cx: &App) -> IconName { + self.read(cx).toggle_icon(cx) + } + + fn expanded(&self, cx: &App) -> bool { + self.read(cx).expanded(cx) + } + + fn set_expanded(&self, expanded: bool, cx: &mut App) { + self.update(cx, |this, cx| this.set_expanded(expanded, cx)) + } + + fn width(&self, cx: &App) -> Pixels { + self.read(cx).width(cx) + } + + fn set_width(&self, width: Option, cx: &mut App) { + self.update(cx, |this, cx| this.set_width(width, cx)) + } + + fn to_any(&self) -> AnyView { + self.clone().into() + } + + fn box_clone(&self) -> Box { + Box::new(self.clone()) + } +} + +pub enum UtilityPanePosition { + Left, + Right, +} + pub trait Panel: Focusable + EventEmitter + Render + Sized { fn persistent_name() -> &'static str; fn panel_key() -> &'static str; @@ -384,6 +453,13 @@ impl Dock { .position(|entry| entry.panel.remote_id() == Some(panel_id)) } + pub fn panel_for_id(&self, panel_id: EntityId) -> Option<&Arc> { + self.panel_entries + .iter() + .find(|entry| entry.panel.panel_id() == panel_id) + .map(|entry| &entry.panel) + } + pub fn first_enabled_panel_idx(&mut self, cx: &mut Context) -> anyhow::Result { self.panel_entries .iter() @@ -491,6 +567,9 @@ impl Dock { new_dock.update(cx, |new_dock, cx| { new_dock.remove_panel(&panel, window, cx); + }); + + new_dock.update(cx, |new_dock, cx| { let index = new_dock.add_panel(panel.clone(), workspace.clone(), window, cx); if was_visible { @@ -498,6 +577,12 @@ impl Dock { new_dock.activate_panel(index, window, cx); } }); + + workspace + .update(cx, |workspace, cx| { + workspace.serialize_workspace(window, cx); + }) + .ok(); } }), cx.subscribe_in( @@ -586,6 +671,7 @@ impl Dock { ); self.restore_state(window, cx); + if panel.read(cx).starts_open(window, cx) { self.activate_panel(index, window, cx); self.set_open(true, window, cx); @@ -637,6 +723,14 @@ impl Dock { std::cmp::Ordering::Greater => {} } } + + let slot = utility_slot_for_dock_position(self.position); + if let Some(workspace) = self.workspace.upgrade() { + workspace.update(cx, |workspace, cx| { + workspace.clear_utility_pane_if_provider(slot, Entity::entity_id(panel), cx); + }); + } + self.panel_entries.remove(panel_ix); cx.notify(); } @@ -891,7 +985,13 @@ impl Render for PanelButtons { .enumerate() .filter_map(|(i, entry)| { let icon = entry.panel.icon(window, cx)?; - let icon_tooltip = entry.panel.icon_tooltip(window, cx)?; + let icon_tooltip = entry + .panel + .icon_tooltip(window, cx) + .ok_or_else(|| { + anyhow::anyhow!("can't render a panel button without an icon tooltip") + }) + .log_err()?; let name = entry.panel.persistent_name(); let panel = entry.panel.clone(); diff --git a/crates/workspace/src/pane.rs b/crates/workspace/src/pane.rs index e99f8d1dc959def06deebae7c4acc454c9210933..ee57f06937ee2781e8d1b965b5e498f5a31ad80d 100644 --- a/crates/workspace/src/pane.rs +++ b/crates/workspace/src/pane.rs @@ -11,10 +11,12 @@ use crate::{ move_item, notifications::NotifyResultExt, toolbar::Toolbar, + utility_pane::UtilityPaneSlot, workspace_settings::{AutosaveSetting, TabBarSettings, WorkspaceSettings}, }; use anyhow::Result; use collections::{BTreeSet, HashMap, HashSet, VecDeque}; +use feature_flags::{AgentV2FeatureFlag, FeatureFlagAppExt}; use futures::{StreamExt, stream::FuturesUnordered}; use gpui::{ Action, AnyElement, App, AsyncWindowContext, ClickEvent, ClipboardItem, Context, Corner, Div, @@ -396,6 +398,10 @@ pub struct Pane { diagnostic_summary_update: Task<()>, /// If a certain project item wants to get recreated with specific data, it can persist its data before the recreation here. pub project_item_restoration_data: HashMap>, + + pub in_center_group: bool, + pub is_upper_left: bool, + pub is_upper_right: bool, } pub struct ActivationHistoryEntry { @@ -540,6 +546,9 @@ impl Pane { zoom_out_on_close: true, diagnostic_summary_update: Task::ready(()), project_item_restoration_data: HashMap::default(), + in_center_group: false, + is_upper_left: false, + is_upper_right: false, } } @@ -3033,6 +3042,10 @@ impl Pane { } fn render_tab_bar(&mut self, window: &mut Window, cx: &mut Context) -> AnyElement { + let Some(workspace) = self.workspace.upgrade() else { + return gpui::Empty.into_any(); + }; + let focus_handle = self.focus_handle.clone(); let navigate_backward = IconButton::new("navigate_backward", IconName::ArrowLeft) .icon_size(IconSize::Small) @@ -3057,6 +3070,44 @@ impl Pane { } }); + let open_aside_left = { + let workspace = workspace.read(cx); + workspace.utility_pane(UtilityPaneSlot::Left).map(|pane| { + let toggle_icon = pane.toggle_icon(cx); + let workspace_handle = self.workspace.clone(); + + IconButton::new("open_aside_left", toggle_icon) + .icon_size(IconSize::Small) + .on_click(move |_, window, cx| { + workspace_handle + .update(cx, |workspace, cx| { + workspace.toggle_utility_pane(UtilityPaneSlot::Left, window, cx) + }) + .ok(); + }) + .into_any_element() + }) + }; + + let open_aside_right = { + let workspace = workspace.read(cx); + workspace.utility_pane(UtilityPaneSlot::Right).map(|pane| { + let toggle_icon = pane.toggle_icon(cx); + let workspace_handle = self.workspace.clone(); + + IconButton::new("open_aside_right", toggle_icon) + .icon_size(IconSize::Small) + .on_click(move |_, window, cx| { + workspace_handle + .update(cx, |workspace, cx| { + workspace.toggle_utility_pane(UtilityPaneSlot::Right, window, cx) + }) + .ok(); + }) + .into_any_element() + }) + }; + let navigate_forward = IconButton::new("navigate_forward", IconName::ArrowRight) .icon_size(IconSize::Small) .on_click({ @@ -3103,13 +3154,50 @@ impl Pane { let unpinned_tabs = tab_items.split_off(self.pinned_tab_count); let pinned_tabs = tab_items; + let render_aside_toggle_left = cx.has_flag::() + && self + .is_upper_left + .then(|| { + self.workspace.upgrade().and_then(|entity| { + let workspace = entity.read(cx); + workspace + .utility_pane(UtilityPaneSlot::Left) + .map(|pane| !pane.expanded(cx)) + }) + }) + .flatten() + .unwrap_or(false); + + let render_aside_toggle_right = cx.has_flag::() + && self + .is_upper_right + .then(|| { + self.workspace.upgrade().and_then(|entity| { + let workspace = entity.read(cx); + workspace + .utility_pane(UtilityPaneSlot::Right) + .map(|pane| !pane.expanded(cx)) + }) + }) + .flatten() + .unwrap_or(false); + TabBar::new("tab_bar") + .map(|tab_bar| { + if let Some(open_aside_left) = open_aside_left + && render_aside_toggle_left + { + tab_bar.start_child(open_aside_left) + } else { + tab_bar + } + }) .when( self.display_nav_history_buttons.unwrap_or_default(), |tab_bar| { tab_bar - .start_child(navigate_backward) - .start_child(navigate_forward) + .pre_end_child(navigate_backward) + .pre_end_child(navigate_forward) }, ) .map(|tab_bar| { @@ -3196,6 +3284,15 @@ impl Pane { })), ), ) + .map(|tab_bar| { + if let Some(open_aside_right) = open_aside_right + && render_aside_toggle_right + { + tab_bar.end_child(open_aside_right) + } else { + tab_bar + } + }) .into_any_element() } @@ -6664,8 +6761,8 @@ mod tests { let scroll_bounds = tab_bar_scroll_handle.bounds(); let scroll_offset = tab_bar_scroll_handle.offset(); assert!(tab_bounds.right() <= scroll_bounds.right() + scroll_offset.x); - // -39.5 is the magic number for this setup - assert_eq!(scroll_offset.x, px(-39.5)); + // -35.0 is the magic number for this setup + assert_eq!(scroll_offset.x, px(-35.0)); assert!( !tab_bounds.intersects(&new_tab_button_bounds), "Tab should not overlap with the new tab button, if this is failing check if there's been a redesign!" diff --git a/crates/workspace/src/pane_group.rs b/crates/workspace/src/pane_group.rs index c9d98977139ed644cf5f3bfb7eb26d94ca081d19..393ed74e30c9c34bf7cdb22aabf2de2d05aa84f8 100644 --- a/crates/workspace/src/pane_group.rs +++ b/crates/workspace/src/pane_group.rs @@ -28,6 +28,7 @@ const VERTICAL_MIN_SIZE: f32 = 100.; #[derive(Clone)] pub struct PaneGroup { pub root: Member, + pub is_center: bool, } pub struct PaneRenderResult { @@ -37,22 +38,31 @@ pub struct PaneRenderResult { impl PaneGroup { pub fn with_root(root: Member) -> Self { - Self { root } + Self { + root, + is_center: false, + } } pub fn new(pane: Entity) -> Self { Self { root: Member::Pane(pane), + is_center: false, } } + pub fn set_is_center(&mut self, is_center: bool) { + self.is_center = is_center; + } + pub fn split( &mut self, old_pane: &Entity, new_pane: &Entity, direction: SplitDirection, + cx: &mut App, ) -> Result<()> { - match &mut self.root { + let result = match &mut self.root { Member::Pane(pane) => { if pane == old_pane { self.root = Member::new_axis(old_pane.clone(), new_pane.clone(), direction); @@ -62,7 +72,11 @@ impl PaneGroup { } } Member::Axis(axis) => axis.split(old_pane, new_pane, direction), + }; + if result.is_ok() { + self.mark_positions(cx); } + result } pub fn bounding_box_for_pane(&self, pane: &Entity) -> Option> { @@ -90,6 +104,7 @@ impl PaneGroup { &mut self, active_pane: &Entity, direction: SplitDirection, + cx: &mut App, ) -> Result { if let Some(pane) = self.find_pane_at_border(direction) && pane == active_pane @@ -97,7 +112,7 @@ impl PaneGroup { return Ok(false); } - if !self.remove(active_pane)? { + if !self.remove_internal(active_pane)? { return Ok(false); } @@ -110,6 +125,7 @@ impl PaneGroup { 0 }; root.insert_pane(idx, active_pane); + self.mark_positions(cx); return Ok(true); } @@ -119,6 +135,7 @@ impl PaneGroup { vec![Member::Pane(active_pane.clone()), self.root.clone()] }; self.root = Member::Axis(PaneAxis::new(direction.axis(), members)); + self.mark_positions(cx); Ok(true) } @@ -133,7 +150,15 @@ impl PaneGroup { /// - Ok(true) if it found and removed a pane /// - Ok(false) if it found but did not remove the pane /// - Err(_) if it did not find the pane - pub fn remove(&mut self, pane: &Entity) -> Result { + pub fn remove(&mut self, pane: &Entity, cx: &mut App) -> Result { + let result = self.remove_internal(pane); + if let Ok(true) = result { + self.mark_positions(cx); + } + result + } + + fn remove_internal(&mut self, pane: &Entity) -> Result { match &mut self.root { Member::Pane(_) => Ok(false), Member::Axis(axis) => { @@ -151,6 +176,7 @@ impl PaneGroup { direction: Axis, amount: Pixels, bounds: &Bounds, + cx: &mut App, ) { match &mut self.root { Member::Pane(_) => {} @@ -158,22 +184,29 @@ impl PaneGroup { let _ = axis.resize(pane, direction, amount, bounds); } }; + self.mark_positions(cx); } - pub fn reset_pane_sizes(&mut self) { + pub fn reset_pane_sizes(&mut self, cx: &mut App) { match &mut self.root { Member::Pane(_) => {} Member::Axis(axis) => { let _ = axis.reset_pane_sizes(); } }; + self.mark_positions(cx); } - pub fn swap(&mut self, from: &Entity, to: &Entity) { + pub fn swap(&mut self, from: &Entity, to: &Entity, cx: &mut App) { match &mut self.root { Member::Pane(_) => {} Member::Axis(axis) => axis.swap(from, to), }; + self.mark_positions(cx); + } + + pub fn mark_positions(&mut self, cx: &mut App) { + self.root.mark_positions(self.is_center, true, true, cx); } pub fn render( @@ -232,8 +265,9 @@ impl PaneGroup { self.pane_at_pixel_position(target) } - pub fn invert_axies(&mut self) { + pub fn invert_axies(&mut self, cx: &mut App) { self.root.invert_pane_axies(); + self.mark_positions(cx); } } @@ -243,6 +277,43 @@ pub enum Member { Pane(Entity), } +impl Member { + pub fn mark_positions( + &mut self, + in_center_group: bool, + is_upper_left: bool, + is_upper_right: bool, + cx: &mut App, + ) { + match self { + Member::Axis(pane_axis) => { + let len = pane_axis.members.len(); + for (idx, member) in pane_axis.members.iter_mut().enumerate() { + let member_upper_left = match pane_axis.axis { + Axis::Vertical => is_upper_left && idx == 0, + Axis::Horizontal => is_upper_left && idx == 0, + }; + let member_upper_right = match pane_axis.axis { + Axis::Vertical => is_upper_right && idx == 0, + Axis::Horizontal => is_upper_right && idx == len - 1, + }; + member.mark_positions( + in_center_group, + member_upper_left, + member_upper_right, + cx, + ); + } + } + Member::Pane(entity) => entity.update(cx, |pane, _| { + pane.in_center_group = in_center_group; + pane.is_upper_left = is_upper_left; + pane.is_upper_right = is_upper_right; + }), + } + } +} + #[derive(Clone, Copy)] pub struct PaneRenderContext<'a> { pub project: &'a Entity, diff --git a/crates/workspace/src/utility_pane.rs b/crates/workspace/src/utility_pane.rs new file mode 100644 index 0000000000000000000000000000000000000000..2760000216d9164367c58d41d4f1b1893dc8cd75 --- /dev/null +++ b/crates/workspace/src/utility_pane.rs @@ -0,0 +1,282 @@ +use gpui::{ + AppContext as _, EntityId, MouseButton, Pixels, Render, StatefulInteractiveElement, + Subscription, WeakEntity, deferred, px, +}; +use ui::{ + ActiveTheme as _, Context, FluentBuilder as _, InteractiveElement as _, IntoElement, + ParentElement as _, RenderOnce, Styled as _, Window, div, +}; + +use crate::{ + DockPosition, Workspace, + dock::{ClosePane, MinimizePane, UtilityPane, UtilityPaneHandle}, +}; + +pub(crate) const UTILITY_PANE_RESIZE_HANDLE_SIZE: Pixels = px(6.0); +pub(crate) const UTILITY_PANE_MIN_WIDTH: Pixels = px(20.0); + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +pub enum UtilityPaneSlot { + Left, + Right, +} + +struct UtilityPaneSlotState { + panel_id: EntityId, + utility_pane: Box, + _subscriptions: Vec, +} + +#[derive(Default)] +pub struct UtilityPaneState { + left_slot: Option, + right_slot: Option, +} + +#[derive(Clone)] +pub struct DraggedUtilityPane(pub UtilityPaneSlot); + +impl Render for DraggedUtilityPane { + fn render(&mut self, _window: &mut Window, _cx: &mut Context) -> impl IntoElement { + gpui::Empty + } +} + +pub fn utility_slot_for_dock_position(position: DockPosition) -> UtilityPaneSlot { + match position { + DockPosition::Left => UtilityPaneSlot::Left, + DockPosition::Right => UtilityPaneSlot::Right, + DockPosition::Bottom => UtilityPaneSlot::Left, + } +} + +impl Workspace { + pub fn utility_pane(&self, slot: UtilityPaneSlot) -> Option<&dyn UtilityPaneHandle> { + match slot { + UtilityPaneSlot::Left => self + .utility_panes + .left_slot + .as_ref() + .map(|s| s.utility_pane.as_ref()), + UtilityPaneSlot::Right => self + .utility_panes + .right_slot + .as_ref() + .map(|s| s.utility_pane.as_ref()), + } + } + + pub fn toggle_utility_pane( + &mut self, + slot: UtilityPaneSlot, + window: &mut Window, + cx: &mut Context, + ) { + if let Some(handle) = self.utility_pane(slot) { + let current = handle.expanded(cx); + handle.set_expanded(!current, cx); + } + cx.notify(); + self.serialize_workspace(window, cx); + } + + pub fn register_utility_pane( + &mut self, + slot: UtilityPaneSlot, + panel_id: EntityId, + handle: gpui::Entity, + cx: &mut Context, + ) { + let minimize_subscription = + cx.subscribe(&handle, move |this, _, _event: &MinimizePane, cx| { + if let Some(handle) = this.utility_pane(slot) { + handle.set_expanded(false, cx); + } + cx.notify(); + }); + + let close_subscription = cx.subscribe(&handle, move |this, _, _event: &ClosePane, cx| { + this.clear_utility_pane(slot, cx); + }); + + let subscriptions = vec![minimize_subscription, close_subscription]; + let boxed_handle: Box = Box::new(handle); + + match slot { + UtilityPaneSlot::Left => { + self.utility_panes.left_slot = Some(UtilityPaneSlotState { + panel_id, + utility_pane: boxed_handle, + _subscriptions: subscriptions, + }); + } + UtilityPaneSlot::Right => { + self.utility_panes.right_slot = Some(UtilityPaneSlotState { + panel_id, + utility_pane: boxed_handle, + _subscriptions: subscriptions, + }); + } + } + cx.notify(); + } + + pub fn clear_utility_pane(&mut self, slot: UtilityPaneSlot, cx: &mut Context) { + match slot { + UtilityPaneSlot::Left => { + self.utility_panes.left_slot = None; + } + UtilityPaneSlot::Right => { + self.utility_panes.right_slot = None; + } + } + cx.notify(); + } + + pub fn clear_utility_pane_if_provider( + &mut self, + slot: UtilityPaneSlot, + provider_panel_id: EntityId, + cx: &mut Context, + ) { + let should_clear = match slot { + UtilityPaneSlot::Left => self + .utility_panes + .left_slot + .as_ref() + .is_some_and(|slot| slot.panel_id == provider_panel_id), + UtilityPaneSlot::Right => self + .utility_panes + .right_slot + .as_ref() + .is_some_and(|slot| slot.panel_id == provider_panel_id), + }; + + if should_clear { + self.clear_utility_pane(slot, cx); + } + } + + pub fn resize_utility_pane( + &mut self, + slot: UtilityPaneSlot, + new_width: Pixels, + window: &mut Window, + cx: &mut Context, + ) { + if let Some(handle) = self.utility_pane(slot) { + let max_width = self.max_utility_pane_width(window, cx); + let width = new_width.max(UTILITY_PANE_MIN_WIDTH).min(max_width); + handle.set_width(Some(width), cx); + cx.notify(); + self.serialize_workspace(window, cx); + } + } + + pub fn reset_utility_pane_width( + &mut self, + slot: UtilityPaneSlot, + window: &mut Window, + cx: &mut Context, + ) { + if let Some(handle) = self.utility_pane(slot) { + handle.set_width(None, cx); + cx.notify(); + self.serialize_workspace(window, cx); + } + } +} + +#[derive(IntoElement)] +pub struct UtilityPaneFrame { + workspace: WeakEntity, + slot: UtilityPaneSlot, + handle: Box, +} + +impl UtilityPaneFrame { + pub fn new( + slot: UtilityPaneSlot, + handle: Box, + cx: &mut Context, + ) -> Self { + let workspace = cx.weak_entity(); + Self { + workspace, + slot, + handle, + } + } +} + +impl RenderOnce for UtilityPaneFrame { + fn render(self, _window: &mut Window, cx: &mut ui::App) -> impl IntoElement { + let workspace = self.workspace.clone(); + let slot = self.slot; + let width = self.handle.width(cx); + + let create_resize_handle = || { + let workspace_handle = workspace.clone(); + let handle = div() + .id(match slot { + UtilityPaneSlot::Left => "utility-pane-resize-handle-left", + UtilityPaneSlot::Right => "utility-pane-resize-handle-right", + }) + .on_drag(DraggedUtilityPane(slot), move |pane, _, _, cx| { + cx.stop_propagation(); + cx.new(|_| pane.clone()) + }) + .on_mouse_down(MouseButton::Left, move |_, _, cx| { + cx.stop_propagation(); + }) + .on_mouse_up( + MouseButton::Left, + move |e: &gpui::MouseUpEvent, window, cx| { + if e.click_count == 2 { + workspace_handle + .update(cx, |workspace, cx| { + workspace.reset_utility_pane_width(slot, window, cx); + }) + .ok(); + cx.stop_propagation(); + } + }, + ) + .occlude(); + + match slot { + UtilityPaneSlot::Left => deferred( + handle + .absolute() + .right(-UTILITY_PANE_RESIZE_HANDLE_SIZE / 2.) + .top(px(0.)) + .h_full() + .w(UTILITY_PANE_RESIZE_HANDLE_SIZE) + .cursor_col_resize(), + ), + UtilityPaneSlot::Right => deferred( + handle + .absolute() + .left(-UTILITY_PANE_RESIZE_HANDLE_SIZE / 2.) + .top(px(0.)) + .h_full() + .w(UTILITY_PANE_RESIZE_HANDLE_SIZE) + .cursor_col_resize(), + ), + } + }; + + div() + .h_full() + .bg(cx.theme().colors().tab_bar_background) + .w(width) + .border_color(cx.theme().colors().border) + .when(self.slot == UtilityPaneSlot::Left, |this| this.border_r_1()) + .when(self.slot == UtilityPaneSlot::Right, |this| { + this.border_l_1() + }) + .child(create_resize_handle()) + .child(self.handle.to_any()) + .into_any_element() + } +} diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index d2a9ef71fc7fc2aacb1fc2f9be41ce001f5cef5e..56dfb2398997a19e98c339876987419bb925f324 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -15,6 +15,7 @@ pub mod tasks; mod theme_preview; mod toast_layer; mod toolbar; +pub mod utility_pane; mod workspace_settings; pub use crate::notifications::NotificationFrame; @@ -30,6 +31,7 @@ use client::{ }; use collections::{HashMap, HashSet, hash_map}; use dock::{Dock, DockPosition, PanelButtons, PanelHandle, RESIZE_HANDLE_SIZE}; +use feature_flags::{AgentV2FeatureFlag, FeatureFlagAppExt}; use futures::{ Future, FutureExt, StreamExt, channel::{ @@ -126,11 +128,16 @@ pub use workspace_settings::{ }; use zed_actions::{Spawn, feedback::FileBugReport}; -use crate::persistence::{ - SerializedAxis, - model::{DockData, DockStructure, SerializedItem, SerializedPane, SerializedPaneGroup}, +use crate::{ + item::ItemBufferKind, notifications::NotificationId, utility_pane::UTILITY_PANE_MIN_WIDTH, +}; +use crate::{ + persistence::{ + SerializedAxis, + model::{DockData, DockStructure, SerializedItem, SerializedPane, SerializedPaneGroup}, + }, + utility_pane::{DraggedUtilityPane, UtilityPaneFrame, UtilityPaneSlot, UtilityPaneState}, }; -use crate::{item::ItemBufferKind, notifications::NotificationId}; pub const SERIALIZATION_THROTTLE_TIME: Duration = Duration::from_millis(200); @@ -1175,6 +1182,7 @@ pub struct Workspace { scheduled_tasks: Vec>, last_open_dock_positions: Vec, removing: bool, + utility_panes: UtilityPaneState, } impl EventEmitter for Workspace {} @@ -1466,12 +1474,17 @@ impl Workspace { this.update_window_title(window, cx); this.show_initial_notifications(cx); }); + + let mut center = PaneGroup::new(center_pane.clone()); + center.set_is_center(true); + center.mark_positions(cx); + Workspace { weak_self: weak_handle.clone(), zoomed: None, zoomed_position: None, previous_dock_drag_coordinates: None, - center: PaneGroup::new(center_pane.clone()), + center, panes: vec![center_pane.clone()], panes_by_item: Default::default(), active_pane: center_pane.clone(), @@ -1519,6 +1532,7 @@ impl Workspace { scheduled_tasks: Vec::new(), last_open_dock_positions: Vec::new(), removing: false, + utility_panes: UtilityPaneState::default(), } } @@ -3771,7 +3785,7 @@ impl Workspace { let new_pane = self.add_pane(window, cx); if self .center - .split(&split_off_pane, &new_pane, direction) + .split(&split_off_pane, &new_pane, direction, cx) .log_err() .is_none() { @@ -3956,7 +3970,7 @@ impl Workspace { let new_pane = self.add_pane(window, cx); if self .center - .split(&self.active_pane, &new_pane, action.direction) + .split(&self.active_pane, &new_pane, action.direction, cx) .log_err() .is_none() { @@ -4010,7 +4024,7 @@ impl Workspace { pub fn swap_pane_in_direction(&mut self, direction: SplitDirection, cx: &mut Context) { if let Some(to) = self.find_pane_in_direction(direction, cx) { - self.center.swap(&self.active_pane, &to); + self.center.swap(&self.active_pane, &to, cx); cx.notify(); } } @@ -4018,7 +4032,7 @@ impl Workspace { pub fn move_pane_to_border(&mut self, direction: SplitDirection, cx: &mut Context) { if self .center - .move_to_border(&self.active_pane, direction) + .move_to_border(&self.active_pane, direction, cx) .unwrap() { cx.notify(); @@ -4048,13 +4062,13 @@ impl Workspace { } } else { self.center - .resize(&self.active_pane, axis, amount, &self.bounds); + .resize(&self.active_pane, axis, amount, &self.bounds, cx); } cx.notify(); } pub fn reset_pane_sizes(&mut self, cx: &mut Context) { - self.center.reset_pane_sizes(); + self.center.reset_pane_sizes(cx); cx.notify(); } @@ -4240,7 +4254,7 @@ impl Workspace { ) -> Entity { let new_pane = self.add_pane(window, cx); self.center - .split(&pane_to_split, &new_pane, split_direction) + .split(&pane_to_split, &new_pane, split_direction, cx) .unwrap(); cx.notify(); new_pane @@ -4260,7 +4274,7 @@ impl Workspace { new_pane.update(cx, |pane, cx| { pane.add_item(item, true, true, None, window, cx) }); - self.center.split(&pane, &new_pane, direction).unwrap(); + self.center.split(&pane, &new_pane, direction, cx).unwrap(); cx.notify(); } @@ -4285,7 +4299,7 @@ impl Workspace { new_pane.update(cx, |pane, cx| { pane.add_item(clone, true, true, None, window, cx) }); - this.center.split(&pane, &new_pane, direction).unwrap(); + this.center.split(&pane, &new_pane, direction, cx).unwrap(); cx.notify(); new_pane }) @@ -4332,7 +4346,7 @@ impl Workspace { window: &mut Window, cx: &mut Context, ) { - if self.center.remove(&pane).unwrap() { + if self.center.remove(&pane, cx).unwrap() { self.force_remove_pane(&pane, &focus_on, window, cx); self.unfollow_in_pane(&pane, window, cx); self.last_leaders_by_pane.remove(&pane.downgrade()); @@ -5684,6 +5698,9 @@ impl Workspace { // Swap workspace center group workspace.center = PaneGroup::with_root(center_group); + workspace.center.set_is_center(true); + workspace.center.mark_positions(cx); + if let Some(active_pane) = active_pane { workspace.set_active_pane(&active_pane, window, cx); cx.focus_self(window); @@ -6309,6 +6326,7 @@ impl Workspace { left_dock.resize_active_panel(Some(size), window, cx); } }); + self.clamp_utility_pane_widths(window, cx); } fn resize_right_dock(&mut self, new_size: Pixels, window: &mut Window, cx: &mut App) { @@ -6331,6 +6349,7 @@ impl Workspace { right_dock.resize_active_panel(Some(size), window, cx); } }); + self.clamp_utility_pane_widths(window, cx); } fn resize_bottom_dock(&mut self, new_size: Pixels, window: &mut Window, cx: &mut App) { @@ -6345,6 +6364,42 @@ impl Workspace { bottom_dock.resize_active_panel(Some(size), window, cx); } }); + self.clamp_utility_pane_widths(window, cx); + } + + fn max_utility_pane_width(&self, window: &Window, cx: &App) -> Pixels { + let left_dock_width = self + .left_dock + .read(cx) + .active_panel_size(window, cx) + .unwrap_or(px(0.0)); + let right_dock_width = self + .right_dock + .read(cx) + .active_panel_size(window, cx) + .unwrap_or(px(0.0)); + let center_pane_width = self.bounds.size.width - left_dock_width - right_dock_width; + center_pane_width - px(10.0) + } + + fn clamp_utility_pane_widths(&mut self, window: &mut Window, cx: &mut App) { + let max_width = self.max_utility_pane_width(window, cx); + + // Clamp left slot utility pane if it exists + if let Some(handle) = self.utility_pane(UtilityPaneSlot::Left) { + let current_width = handle.width(cx); + if current_width > max_width { + handle.set_width(Some(max_width.max(UTILITY_PANE_MIN_WIDTH)), cx); + } + } + + // Clamp right slot utility pane if it exists + if let Some(handle) = self.utility_pane(UtilityPaneSlot::Right) { + let current_width = handle.width(cx); + if current_width > max_width { + handle.set_width(Some(max_width.max(UTILITY_PANE_MIN_WIDTH)), cx); + } + } } fn toggle_edit_predictions_all_files( @@ -6812,6 +6867,34 @@ impl Render for Workspace { } }, )) + .on_drag_move(cx.listener( + move |workspace, + e: &DragMoveEvent, + window, + cx| { + let slot = e.drag(cx).0; + match slot { + UtilityPaneSlot::Left => { + let left_dock_width = workspace.left_dock.read(cx) + .active_panel_size(window, cx) + .unwrap_or(gpui::px(0.0)); + let new_width = e.event.position.x + - workspace.bounds.left() + - left_dock_width; + workspace.resize_utility_pane(slot, new_width, window, cx); + } + UtilityPaneSlot::Right => { + let right_dock_width = workspace.right_dock.read(cx) + .active_panel_size(window, cx) + .unwrap_or(gpui::px(0.0)); + let new_width = workspace.bounds.right() + - e.event.position.x + - right_dock_width; + workspace.resize_utility_pane(slot, new_width, window, cx); + } + } + }, + )) }) .child({ match bottom_dock_layout { @@ -6831,6 +6914,15 @@ impl Render for Workspace { window, cx, )) + .when(cx.has_flag::(), |this| { + this.when_some(self.utility_pane(UtilityPaneSlot::Left), |this, pane| { + this.when(pane.expanded(cx), |this| { + this.child( + UtilityPaneFrame::new(UtilityPaneSlot::Left, pane.box_clone(), cx) + ) + }) + }) + }) .child( div() .flex() @@ -6872,6 +6964,15 @@ impl Render for Workspace { ), ), ) + .when(cx.has_flag::(), |this| { + this.when_some(self.utility_pane(UtilityPaneSlot::Right), |this, pane| { + this.when(pane.expanded(cx), |this| { + this.child( + UtilityPaneFrame::new(UtilityPaneSlot::Right, pane.box_clone(), cx) + ) + }) + }) + }) .children(self.render_dock( DockPosition::Right, &self.right_dock, @@ -6902,6 +7003,15 @@ impl Render for Workspace { .flex_row() .flex_1() .children(self.render_dock(DockPosition::Left, &self.left_dock, window, cx)) + .when(cx.has_flag::(), |this| { + this.when_some(self.utility_pane(UtilityPaneSlot::Left), |this, pane| { + this.when(pane.expanded(cx), |this| { + this.child( + UtilityPaneFrame::new(UtilityPaneSlot::Left, pane.box_clone(), cx) + ) + }) + }) + }) .child( div() .flex() @@ -6929,6 +7039,13 @@ impl Render for Workspace { .when_some(paddings.1, |this, p| this.child(p.border_l_1())), ) ) + .when_some(self.utility_pane(UtilityPaneSlot::Right), |this, pane| { + this.when(pane.expanded(cx), |this| { + this.child( + UtilityPaneFrame::new(UtilityPaneSlot::Right, pane.box_clone(), cx) + ) + }) + }) ) .child( div() @@ -6953,6 +7070,15 @@ impl Render for Workspace { window, cx, )) + .when(cx.has_flag::(), |this| { + this.when_some(self.utility_pane(UtilityPaneSlot::Left), |this, pane| { + this.when(pane.expanded(cx), |this| { + this.child( + UtilityPaneFrame::new(UtilityPaneSlot::Left, pane.box_clone(), cx) + ) + }) + }) + }) .child( div() .flex() @@ -6991,6 +7117,15 @@ impl Render for Workspace { .when_some(paddings.1, |this, p| this.child(p.border_l_1())), ) ) + .when(cx.has_flag::(), |this| { + this.when_some(self.utility_pane(UtilityPaneSlot::Right), |this, pane| { + this.when(pane.expanded(cx), |this| { + this.child( + UtilityPaneFrame::new(UtilityPaneSlot::Right, pane.box_clone(), cx) + ) + }) + }) + }) .children(self.render_dock(DockPosition::Right, &self.right_dock, window, cx)) ) .child( @@ -7010,6 +7145,13 @@ impl Render for Workspace { window, cx, )) + .when_some(self.utility_pane(UtilityPaneSlot::Left), |this, pane| { + this.when(pane.expanded(cx), |this| { + this.child( + UtilityPaneFrame::new(UtilityPaneSlot::Left, pane.box_clone(), cx) + ) + }) + }) .child( div() .flex() @@ -7047,6 +7189,15 @@ impl Render for Workspace { cx, )), ) + .when(cx.has_flag::(), |this| { + this.when_some(self.utility_pane(UtilityPaneSlot::Right), |this, pane| { + this.when(pane.expanded(cx), |this| { + this.child( + UtilityPaneFrame::new(UtilityPaneSlot::Right, pane.box_clone(), cx) + ) + }) + }) + }) .children(self.render_dock( DockPosition::Right, &self.right_dock, diff --git a/crates/zed/Cargo.toml b/crates/zed/Cargo.toml index 92a274da9640bbe9ee3afefeacd7566c853bdd2d..141de1139fb571020377ef9b115ed8204bad100b 100644 --- a/crates/zed/Cargo.toml +++ b/crates/zed/Cargo.toml @@ -26,6 +26,7 @@ acp_tools.workspace = true activity_indicator.workspace = true agent_settings.workspace = true agent_ui.workspace = true +agent_ui_v2.workspace = true anyhow.workspace = true askpass.workspace = true assets.workspace = true diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rs index dfbc57d293e392f654b0920455e5614dd969bcdb..6d94a15a666c6659f522d4b61962c932347b6304 100644 --- a/crates/zed/src/main.rs +++ b/crates/zed/src/main.rs @@ -597,6 +597,7 @@ pub fn main() { false, cx, ); + agent_ui_v2::agents_panel::init(cx); repl::init(app_state.fs.clone(), cx); recent_projects::init(cx); diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs index 71653124b1c4af993d9878b2b689d07f4f2acd02..3bc05ef540769800ef96a76bcbcfd24b09680192 100644 --- a/crates/zed/src/zed.rs +++ b/crates/zed/src/zed.rs @@ -10,6 +10,7 @@ mod quick_action_bar; pub(crate) mod windows_only_instance; use agent_ui::{AgentDiffToolbar, AgentPanelDelegate}; +use agent_ui_v2::agents_panel::AgentsPanel; use anyhow::Context as _; pub use app_menus::*; use assets::Assets; @@ -81,8 +82,9 @@ use vim_mode_setting::VimModeSetting; use workspace::notifications::{ NotificationId, SuppressEvent, dismiss_app_notification, show_app_notification, }; +use workspace::utility_pane::utility_slot_for_dock_position; use workspace::{ - AppState, NewFile, NewWindow, OpenLog, Toast, Workspace, WorkspaceSettings, + AppState, NewFile, NewWindow, OpenLog, Panel, Toast, Workspace, WorkspaceSettings, create_and_open_local_file, notifications::simple_message_notification::MessageNotification, open_new, }; @@ -679,7 +681,8 @@ fn initialize_panels( add_panel_when_ready(channels_panel, workspace_handle.clone(), cx.clone()), add_panel_when_ready(notification_panel, workspace_handle.clone(), cx.clone()), add_panel_when_ready(debug_panel, workspace_handle.clone(), cx.clone()), - initialize_agent_panel(workspace_handle, prompt_builder, cx.clone()).map(|r| r.log_err()) + initialize_agent_panel(workspace_handle.clone(), prompt_builder, cx.clone()).map(|r| r.log_err()), + initialize_agents_panel(workspace_handle, cx.clone()).map(|r| r.log_err()) ); anyhow::Ok(()) @@ -687,58 +690,65 @@ fn initialize_panels( .detach(); } +fn setup_or_teardown_ai_panel( + workspace: &mut Workspace, + window: &mut Window, + cx: &mut Context, + load_panel: impl FnOnce( + WeakEntity, + AsyncWindowContext, + ) -> Task>> + + 'static, +) -> Task> { + let disable_ai = SettingsStore::global(cx) + .get::(None) + .disable_ai + || cfg!(test); + let existing_panel = workspace.panel::

(cx); + + match (disable_ai, existing_panel) { + (false, None) => cx.spawn_in(window, async move |workspace, cx| { + let panel = load_panel(workspace.clone(), cx.clone()).await?; + workspace.update_in(cx, |workspace, window, cx| { + let disable_ai = SettingsStore::global(cx) + .get::(None) + .disable_ai; + let have_panel = workspace.panel::

(cx).is_some(); + if !disable_ai && !have_panel { + workspace.add_panel(panel, window, cx); + } + }) + }), + (true, Some(existing_panel)) => { + workspace.remove_panel::

(&existing_panel, window, cx); + Task::ready(Ok(())) + } + _ => Task::ready(Ok(())), + } +} + async fn initialize_agent_panel( workspace_handle: WeakEntity, prompt_builder: Arc, mut cx: AsyncWindowContext, ) -> anyhow::Result<()> { - fn setup_or_teardown_agent_panel( - workspace: &mut Workspace, - prompt_builder: Arc, - window: &mut Window, - cx: &mut Context, - ) -> Task> { - let disable_ai = SettingsStore::global(cx) - .get::(None) - .disable_ai - || cfg!(test); - let existing_panel = workspace.panel::(cx); - match (disable_ai, existing_panel) { - (false, None) => cx.spawn_in(window, async move |workspace, cx| { - let panel = - agent_ui::AgentPanel::load(workspace.clone(), prompt_builder, cx.clone()) - .await?; - workspace.update_in(cx, |workspace, window, cx| { - let disable_ai = SettingsStore::global(cx) - .get::(None) - .disable_ai; - let have_panel = workspace.panel::(cx).is_some(); - if !disable_ai && !have_panel { - workspace.add_panel(panel, window, cx); - } - }) - }), - (true, Some(existing_panel)) => { - workspace.remove_panel::(&existing_panel, window, cx); - Task::ready(Ok(())) - } - _ => Task::ready(Ok(())), - } - } - workspace_handle .update_in(&mut cx, |workspace, window, cx| { - setup_or_teardown_agent_panel(workspace, prompt_builder.clone(), window, cx) + let prompt_builder = prompt_builder.clone(); + setup_or_teardown_ai_panel(workspace, window, cx, move |workspace, cx| { + agent_ui::AgentPanel::load(workspace, prompt_builder, cx) + }) })? .await?; workspace_handle.update_in(&mut cx, |workspace, window, cx| { - cx.observe_global_in::(window, { + let prompt_builder = prompt_builder.clone(); + cx.observe_global_in::(window, move |workspace, window, cx| { let prompt_builder = prompt_builder.clone(); - move |workspace, window, cx| { - setup_or_teardown_agent_panel(workspace, prompt_builder.clone(), window, cx) - .detach_and_log_err(cx); - } + setup_or_teardown_ai_panel(workspace, window, cx, move |workspace, cx| { + agent_ui::AgentPanel::load(workspace, prompt_builder, cx) + }) + .detach_and_log_err(cx); }) .detach(); @@ -763,6 +773,31 @@ async fn initialize_agent_panel( anyhow::Ok(()) } +async fn initialize_agents_panel( + workspace_handle: WeakEntity, + mut cx: AsyncWindowContext, +) -> anyhow::Result<()> { + workspace_handle + .update_in(&mut cx, |workspace, window, cx| { + setup_or_teardown_ai_panel(workspace, window, cx, |workspace, cx| { + AgentsPanel::load(workspace, cx) + }) + })? + .await?; + + workspace_handle.update_in(&mut cx, |_workspace, window, cx| { + cx.observe_global_in::(window, move |workspace, window, cx| { + setup_or_teardown_ai_panel(workspace, window, cx, |workspace, cx| { + AgentsPanel::load(workspace, cx) + }) + .detach_and_log_err(cx); + }) + .detach(); + })?; + + anyhow::Ok(()) +} + fn register_actions( app_state: Arc, workspace: &mut Workspace, @@ -1052,6 +1087,18 @@ fn register_actions( workspace.toggle_panel_focus::(window, cx); }, ) + .register_action( + |workspace: &mut Workspace, + _: &zed_actions::agent::ToggleAgentPane, + window: &mut Window, + cx: &mut Context| { + if let Some(panel) = workspace.panel::(cx) { + let position = panel.read(cx).position(window, cx); + let slot = utility_slot_for_dock_position(position); + workspace.toggle_utility_pane(slot, window, cx); + } + }, + ) .register_action({ let app_state = Arc::downgrade(&app_state); move |_, _: &NewWindow, _, cx| { @@ -4714,6 +4761,7 @@ mod tests { "action", "activity_indicator", "agent", + "agents", #[cfg(not(target_os = "macos"))] "app_menu", "assistant", @@ -4941,6 +4989,7 @@ mod tests { false, cx, ); + agent_ui_v2::agents_panel::init(cx); repl::init(app_state.fs.clone(), cx); repl::notebook::init(cx); tasks_ui::init(cx); diff --git a/crates/zed_actions/src/lib.rs b/crates/zed_actions/src/lib.rs index a89e943e021e79058953de46bca57713f51598bc..f69baa03b002fdcac5207f977a23cfc924283e2d 100644 --- a/crates/zed_actions/src/lib.rs +++ b/crates/zed_actions/src/lib.rs @@ -350,6 +350,8 @@ pub mod agent { AddSelectionToThread, /// Resets the agent panel zoom levels (agent UI and buffer font sizes). ResetAgentZoom, + /// Toggles the utility/agent pane open/closed state. + ToggleAgentPane, ] ); } From c952de4bfbbc98a6c11644d7945e7830d802b9e4 Mon Sep 17 00:00:00 2001 From: Abderrahmane TAHRI JOUTI <302837+atahrijouti@users.noreply.github.com> Date: Mon, 15 Dec 2025 11:20:12 +0100 Subject: [PATCH 273/621] Cleanup helix keymaps (#43735) Release Notes: - Add search category to helix keymaps - Cleanup unnecessary comments - Indicate non helix keymap --- assets/keymaps/vim.json | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/assets/keymaps/vim.json b/assets/keymaps/vim.json index 24cc021709656de204def3ee8b45a790ce7eb1b0..34bbd44fc3be6a8bd6fa35944e073f5118d6cd33 100644 --- a/assets/keymaps/vim.json +++ b/assets/keymaps/vim.json @@ -445,9 +445,9 @@ "shift-r": "editor::Paste", "`": "vim::ConvertToLowerCase", "alt-`": "vim::ConvertToUpperCase", - "insert": "vim::InsertBefore", + "insert": "vim::InsertBefore", // not a helix default "shift-u": "editor::Redo", - "ctrl-r": "vim::Redo", + "ctrl-r": "vim::Redo", // not a helix default "y": "vim::HelixYank", "p": "vim::HelixPaste", "shift-p": ["vim::HelixPaste", { "before": true }], @@ -476,6 +476,7 @@ "alt-p": "editor::SelectPreviousSyntaxNode", "alt-n": "editor::SelectNextSyntaxNode", + // Search "n": "vim::HelixSelectNext", "shift-n": "vim::HelixSelectPrevious", @@ -483,27 +484,27 @@ "g e": "vim::EndOfDocument", "g h": "vim::StartOfLine", "g l": "vim::EndOfLine", - "g s": "vim::FirstNonWhitespace", // "g s" default behavior is "space s" + "g s": "vim::FirstNonWhitespace", "g t": "vim::WindowTop", "g c": "vim::WindowMiddle", "g b": "vim::WindowBottom", - "g r": "editor::FindAllReferences", // zed specific + "g r": "editor::FindAllReferences", "g n": "pane::ActivateNextItem", - "shift-l": "pane::ActivateNextItem", + "shift-l": "pane::ActivateNextItem", // not a helix default "g p": "pane::ActivatePreviousItem", - "shift-h": "pane::ActivatePreviousItem", - "g .": "vim::HelixGotoLastModification", // go to last modification + "shift-h": "pane::ActivatePreviousItem", // not a helix default + "g .": "vim::HelixGotoLastModification", // Window mode + "space w v": "pane::SplitDown", + "space w s": "pane::SplitRight", "space w h": "workspace::ActivatePaneLeft", - "space w l": "workspace::ActivatePaneRight", - "space w k": "workspace::ActivatePaneUp", "space w j": "workspace::ActivatePaneDown", + "space w k": "workspace::ActivatePaneUp", + "space w l": "workspace::ActivatePaneRight", "space w q": "pane::CloseActiveItem", - "space w s": "pane::SplitRight", - "space w r": "pane::SplitRight", - "space w v": "pane::SplitDown", - "space w d": "pane::SplitDown", + "space w r": "pane::SplitRight", // not a helix default + "space w d": "pane::SplitDown", // not a helix default // Space mode "space f": "file_finder::Toggle", @@ -525,9 +526,7 @@ "]": ["vim::PushHelixNext", { "around": true }], "[": ["vim::PushHelixPrevious", { "around": true }], "g q": "vim::PushRewrap", - "g w": "vim::PushRewrap" - // "tab": "pane::ActivateNextItem", - // "shift-tab": "pane::ActivatePrevItem", + "g w": "vim::PushRewrap" // not a helix default & clashes with helix `goto_word` } }, { From a78ffdafa9cf1aa111634d753a06628cf6167ab9 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Mon, 15 Dec 2025 11:33:10 +0100 Subject: [PATCH 274/621] search: Retain replace status when re-deploying active search panels (#44862) Closes https://github.com/zed-industries/zed/issues/15918 Release Notes: - Fixed search bars losing their replace state if you re-focus on them via actions or keybinds --- crates/search/src/buffer_search.rs | 14 ++++++++------ crates/search/src/project_search.rs | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/crates/search/src/buffer_search.rs b/crates/search/src/buffer_search.rs index a9c26ac9bad0f524acdb47d6f09c2bd67cb8dfc6..686d385aa07accac168062fa598790b36e80199f 100644 --- a/crates/search/src/buffer_search.rs +++ b/crates/search/src/buffer_search.rs @@ -729,12 +729,14 @@ impl BufferSearchBar { self.search_suggested(window, cx); self.smartcase(window, cx); self.sync_select_next_case_sensitivity(cx); - self.replace_enabled = deploy.replace_enabled; - self.selection_search_enabled = if deploy.selection_search_enabled { - Some(FilteredSearchRange::Default) - } else { - None - }; + self.replace_enabled |= deploy.replace_enabled; + self.selection_search_enabled = + self.selection_search_enabled + .or(if deploy.selection_search_enabled { + Some(FilteredSearchRange::Default) + } else { + None + }); if deploy.focus { let mut handle = self.query_editor.focus_handle(cx); let mut select_query = true; diff --git a/crates/search/src/project_search.rs b/crates/search/src/project_search.rs index a9ca77a5b8bd30b8492cf8f8dfa2b17fdcdb6a5b..278f2e86b7b13fd5a82777054c12ff2e1b6239bb 100644 --- a/crates/search/src/project_search.rs +++ b/crates/search/src/project_search.rs @@ -1147,7 +1147,7 @@ impl ProjectSearchView { }; search.update(cx, |search, cx| { - search.replace_enabled = action.replace_enabled; + search.replace_enabled |= action.replace_enabled; if let Some(query) = query { search.set_query(&query, window, cx); } From dd13c95158b147f4676ea730723e476fb4b1bce7 Mon Sep 17 00:00:00 2001 From: Zachiah Sawyer Date: Mon, 15 Dec 2025 02:40:37 -0800 Subject: [PATCH 275/621] Make `cmd-click` require the modifier on mousedown (#44579) Closes #44537 Release Notes: - Improved Cmd+Click behavior. Now requires Cmd to be pressed before the click starts or it doesn't run --- crates/editor/src/element.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index 653cf291a7ff2ea79152535392241ae94eaf05f3..5a5b32e1755f5a026800f3af3c1cedaf6b11996d 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -1017,10 +1017,16 @@ impl EditorElement { let pending_nonempty_selections = editor.has_pending_nonempty_selection(); let hovered_link_modifier = Editor::is_cmd_or_ctrl_pressed(&event.modifiers(), cx); + let mouse_down_hovered_link_modifier = if let ClickEvent::Mouse(mouse_event) = event { + Editor::is_cmd_or_ctrl_pressed(&mouse_event.down.modifiers, cx) + } else { + true + }; if let Some(mouse_position) = event.mouse_position() && !pending_nonempty_selections && hovered_link_modifier + && mouse_down_hovered_link_modifier && text_hitbox.is_hovered(window) { let point = position_map.point_for_position(mouse_position); From 693b978c8dbeb5683d34d282f6d6f09dc17cf4d5 Mon Sep 17 00:00:00 2001 From: Finn Evers Date: Mon, 15 Dec 2025 11:54:08 +0100 Subject: [PATCH 276/621] proto: Add two language servers and change used grammar (#44440) Closes #43784 Closes #44375 Closes #21057 This PR updates the Proto extension to include support for two new language servers as well as an updated grammar for better highlighting. Release Notes: - Improved Proto support to work better out of the box. --- Cargo.lock | 2 +- assets/settings/default.json | 3 + extensions/proto/Cargo.toml | 2 +- extensions/proto/extension.toml | 13 +- extensions/proto/src/language_servers.rs | 8 ++ extensions/proto/src/language_servers/buf.rs | 114 ++++++++++++++++++ .../protobuf_language_server.rs | 52 ++++++++ .../proto/src/language_servers/protols.rs | 113 +++++++++++++++++ extensions/proto/src/language_servers/util.rs | 19 +++ extensions/proto/src/proto.rs | 86 +++++-------- typos.toml | 3 + 11 files changed, 358 insertions(+), 57 deletions(-) create mode 100644 extensions/proto/src/language_servers.rs create mode 100644 extensions/proto/src/language_servers/buf.rs create mode 100644 extensions/proto/src/language_servers/protobuf_language_server.rs create mode 100644 extensions/proto/src/language_servers/protols.rs create mode 100644 extensions/proto/src/language_servers/util.rs diff --git a/Cargo.lock b/Cargo.lock index 7933ef3099af76a81200ae99b75fb2ccbc5671c6..29de11a496fb25b86fcbc87c1f394c65a8e364b2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -20828,7 +20828,7 @@ dependencies = [ name = "zed_proto" version = "0.2.3" dependencies = [ - "zed_extension_api 0.1.0", + "zed_extension_api 0.7.0", ] [[package]] diff --git a/assets/settings/default.json b/assets/settings/default.json index 0283cdd5bad26e423bb914eb40c070912e30bd36..c4c66f47a6948bc755e588cc37504dc01e954e36 100644 --- a/assets/settings/default.json +++ b/assets/settings/default.json @@ -1932,6 +1932,9 @@ "words": "disabled", }, }, + "Proto": { + "language_servers": ["buf", "!protols", "!protobuf-language-server", "..."] + }, "Python": { "code_actions_on_format": { "source.organizeImports.ruff": true, diff --git a/extensions/proto/Cargo.toml b/extensions/proto/Cargo.toml index 1013d62cfa085275a1230d0816049da6c35ba38a..d4c966a686a1ef0bfa2fe658c45f3b391e54ccee 100644 --- a/extensions/proto/Cargo.toml +++ b/extensions/proto/Cargo.toml @@ -13,4 +13,4 @@ path = "src/proto.rs" crate-type = ["cdylib"] [dependencies] -zed_extension_api = "0.1.0" +zed_extension_api = "0.7.0" diff --git a/extensions/proto/extension.toml b/extensions/proto/extension.toml index 9bb8625065fe957308c47488c4aeb9010a773984..ff8c5758d0c1780031ef850a912d294dcef1a40e 100644 --- a/extensions/proto/extension.toml +++ b/extensions/proto/extension.toml @@ -7,9 +7,18 @@ authors = ["Zed Industries "] repository = "https://github.com/zed-industries/zed" [grammars.proto] -repository = "https://github.com/zed-industries/tree-sitter-proto" -commit = "0848bd30a64be48772e15fbb9d5ba8c0cc5772ad" +repository = "https://github.com/coder3101/tree-sitter-proto" +commit = "a6caac94b5aa36b322b5b70040d5b67132f109d0" + + +[language_servers.buf] +name = "Buf" +languages = ["Proto"] [language_servers.protobuf-language-server] name = "Protobuf Language Server" languages = ["Proto"] + +[language_servers.protols] +name = "Protols" +languages = ["Proto"] diff --git a/extensions/proto/src/language_servers.rs b/extensions/proto/src/language_servers.rs new file mode 100644 index 0000000000000000000000000000000000000000..47a5e72d8aadf5d0286667148f0a7dd95fea10ba --- /dev/null +++ b/extensions/proto/src/language_servers.rs @@ -0,0 +1,8 @@ +mod buf; +mod protobuf_language_server; +mod protols; +mod util; + +pub(crate) use buf::*; +pub(crate) use protobuf_language_server::*; +pub(crate) use protols::*; diff --git a/extensions/proto/src/language_servers/buf.rs b/extensions/proto/src/language_servers/buf.rs new file mode 100644 index 0000000000000000000000000000000000000000..92106298d3d1deb6ed2b0f4194ab09321fa09552 --- /dev/null +++ b/extensions/proto/src/language_servers/buf.rs @@ -0,0 +1,114 @@ +use std::fs; + +use zed_extension_api::{ + self as zed, Architecture, DownloadedFileType, GithubReleaseOptions, Os, Result, + settings::LspSettings, +}; + +use crate::language_servers::util; + +pub(crate) struct BufLsp { + cached_binary_path: Option, +} + +impl BufLsp { + pub(crate) const SERVER_NAME: &str = "buf"; + + pub(crate) fn new() -> Self { + BufLsp { + cached_binary_path: None, + } + } + + pub(crate) fn language_server_binary( + &mut self, + worktree: &zed::Worktree, + ) -> Result { + let binary_settings = LspSettings::for_worktree(Self::SERVER_NAME, worktree) + .ok() + .and_then(|lsp_settings| lsp_settings.binary); + + let args = binary_settings + .as_ref() + .and_then(|binary_settings| binary_settings.arguments.clone()) + .unwrap_or_else(|| ["lsp", "serve"].map(ToOwned::to_owned).into()); + + if let Some(path) = binary_settings.and_then(|binary_settings| binary_settings.path) { + return Ok(zed::Command { + command: path, + args, + env: Default::default(), + }); + } else if let Some(path) = self.cached_binary_path.clone() { + return Ok(zed::Command { + command: path, + args, + env: Default::default(), + }); + } else if let Some(path) = worktree.which(Self::SERVER_NAME) { + self.cached_binary_path = Some(path.clone()); + return Ok(zed::Command { + command: path, + args, + env: Default::default(), + }); + } + + let latest_release = zed::latest_github_release( + "bufbuild/buf", + GithubReleaseOptions { + require_assets: true, + pre_release: false, + }, + )?; + + let (os, arch) = zed::current_platform(); + + let release_suffix = match (os, arch) { + (Os::Mac, Architecture::Aarch64) => "Darwin-arm64", + (Os::Mac, Architecture::X8664) => "Darwin-x86_64", + (Os::Linux, Architecture::Aarch64) => "Linux-aarch64", + (Os::Linux, Architecture::X8664) => "Linux-x86_64", + (Os::Windows, Architecture::Aarch64) => "Windows-arm64.exe", + (Os::Windows, Architecture::X8664) => "Windows-x86_64.exe", + _ => { + return Err("Platform and architecture not supported by buf CLI".to_string()); + } + }; + + let release_name = format!("buf-{release_suffix}"); + + let version_dir = format!("{}-{}", Self::SERVER_NAME, latest_release.version); + fs::create_dir_all(&version_dir).map_err(|_| "Could not create directory")?; + + let binary_path = format!("{version_dir}/buf"); + + let download_target = latest_release + .assets + .into_iter() + .find(|asset| asset.name == release_name) + .ok_or_else(|| { + format!( + "Could not find asset with name {} in buf CLI release", + &release_name + ) + })?; + + zed::download_file( + &download_target.download_url, + &binary_path, + DownloadedFileType::Uncompressed, + )?; + zed::make_file_executable(&binary_path)?; + + util::remove_outdated_versions(Self::SERVER_NAME, &version_dir)?; + + self.cached_binary_path = Some(binary_path.clone()); + + Ok(zed::Command { + command: binary_path, + args, + env: Default::default(), + }) + } +} diff --git a/extensions/proto/src/language_servers/protobuf_language_server.rs b/extensions/proto/src/language_servers/protobuf_language_server.rs new file mode 100644 index 0000000000000000000000000000000000000000..f4b13077f73182dd0c30486ee274ade26ec1e40e --- /dev/null +++ b/extensions/proto/src/language_servers/protobuf_language_server.rs @@ -0,0 +1,52 @@ +use zed_extension_api::{self as zed, Result, settings::LspSettings}; + +pub(crate) struct ProtobufLanguageServer { + cached_binary_path: Option, +} + +impl ProtobufLanguageServer { + pub(crate) const SERVER_NAME: &str = "protobuf-language-server"; + + pub(crate) fn new() -> Self { + ProtobufLanguageServer { + cached_binary_path: None, + } + } + + pub(crate) fn language_server_binary( + &mut self, + worktree: &zed::Worktree, + ) -> Result { + let binary_settings = LspSettings::for_worktree(Self::SERVER_NAME, worktree) + .ok() + .and_then(|lsp_settings| lsp_settings.binary); + + let args = binary_settings + .as_ref() + .and_then(|binary_settings| binary_settings.arguments.clone()) + .unwrap_or_else(|| vec!["-logs".into(), "".into()]); + + if let Some(path) = binary_settings.and_then(|binary_settings| binary_settings.path) { + Ok(zed::Command { + command: path, + args, + env: Default::default(), + }) + } else if let Some(path) = self.cached_binary_path.clone() { + Ok(zed::Command { + command: path, + args, + env: Default::default(), + }) + } else if let Some(path) = worktree.which(Self::SERVER_NAME) { + self.cached_binary_path = Some(path.clone()); + Ok(zed::Command { + command: path, + args, + env: Default::default(), + }) + } else { + Err(format!("{} not found in PATH", Self::SERVER_NAME)) + } + } +} diff --git a/extensions/proto/src/language_servers/protols.rs b/extensions/proto/src/language_servers/protols.rs new file mode 100644 index 0000000000000000000000000000000000000000..90d365eae7d99ccb27d60f774ed700b47323d8d0 --- /dev/null +++ b/extensions/proto/src/language_servers/protols.rs @@ -0,0 +1,113 @@ +use zed_extension_api::{ + self as zed, Architecture, DownloadedFileType, GithubReleaseOptions, Os, Result, + settings::LspSettings, +}; + +use crate::language_servers::util; + +pub(crate) struct ProtoLs { + cached_binary_path: Option, +} + +impl ProtoLs { + pub(crate) const SERVER_NAME: &str = "protols"; + + pub(crate) fn new() -> Self { + ProtoLs { + cached_binary_path: None, + } + } + + pub(crate) fn language_server_binary( + &mut self, + worktree: &zed::Worktree, + ) -> Result { + let binary_settings = LspSettings::for_worktree(Self::SERVER_NAME, worktree) + .ok() + .and_then(|lsp_settings| lsp_settings.binary); + + let args = binary_settings + .as_ref() + .and_then(|binary_settings| binary_settings.arguments.clone()) + .unwrap_or_default(); + + let env = worktree.shell_env(); + + if let Some(path) = binary_settings.and_then(|binary_settings| binary_settings.path) { + return Ok(zed::Command { + command: path, + args, + env, + }); + } else if let Some(path) = self.cached_binary_path.clone() { + return Ok(zed::Command { + command: path, + args, + env, + }); + } else if let Some(path) = worktree.which(Self::SERVER_NAME) { + self.cached_binary_path = Some(path.clone()); + return Ok(zed::Command { + command: path, + args, + env, + }); + } + + let latest_release = zed::latest_github_release( + "coder3101/protols", + GithubReleaseOptions { + require_assets: true, + pre_release: false, + }, + )?; + + let (os, arch) = zed::current_platform(); + + let release_suffix = match (os, arch) { + (Os::Mac, Architecture::Aarch64) => "aarch64-apple-darwin.tar.gz", + (Os::Mac, Architecture::X8664) => "x86_64-apple-darwin.tar.gz", + (Os::Linux, Architecture::Aarch64) => "aarch64-unknown-linux-gnu.tar.gz", + (Os::Linux, Architecture::X8664) => "x86_64-unknown-linux-gnu.tar.gz", + (Os::Windows, Architecture::X8664) => "x86_64-pc-windows-msvc.zip", + _ => { + return Err("Platform and architecture not supported by Protols".to_string()); + } + }; + + let release_name = format!("protols-{release_suffix}"); + + let file_type = if os == Os::Windows { + DownloadedFileType::Zip + } else { + DownloadedFileType::GzipTar + }; + + let version_dir = format!("{}-{}", Self::SERVER_NAME, latest_release.version); + let binary_path = format!("{version_dir}/protols"); + + let download_target = latest_release + .assets + .into_iter() + .find(|asset| asset.name == release_name) + .ok_or_else(|| { + format!( + "Could not find asset with name {} in Protols release", + &release_name + ) + })?; + + zed::download_file(&download_target.download_url, &version_dir, file_type)?; + zed::make_file_executable(&binary_path)?; + + util::remove_outdated_versions(Self::SERVER_NAME, &version_dir)?; + + self.cached_binary_path = Some(binary_path.clone()); + + Ok(zed::Command { + command: binary_path, + args, + env, + }) + } +} diff --git a/extensions/proto/src/language_servers/util.rs b/extensions/proto/src/language_servers/util.rs new file mode 100644 index 0000000000000000000000000000000000000000..3036c9bc3aaf9cc3fccd462fe0ad70aa31892012 --- /dev/null +++ b/extensions/proto/src/language_servers/util.rs @@ -0,0 +1,19 @@ +use std::fs; + +use zed_extension_api::Result; + +pub(super) fn remove_outdated_versions( + language_server_id: &'static str, + version_dir: &str, +) -> Result<()> { + let entries = fs::read_dir(".").map_err(|e| format!("failed to list working directory {e}"))?; + for entry in entries { + let entry = entry.map_err(|e| format!("failed to load directory entry {e}"))?; + if entry.file_name().to_str().is_none_or(|file_name| { + file_name.starts_with(language_server_id) && file_name != version_dir + }) { + fs::remove_dir_all(entry.path()).ok(); + } + } + Ok(()) +} diff --git a/extensions/proto/src/proto.rs b/extensions/proto/src/proto.rs index 36ba0faf5feda66af8824387240e34a730a476b7..07e0ccedcee287f037576db56d5a9d7958ea83f9 100644 --- a/extensions/proto/src/proto.rs +++ b/extensions/proto/src/proto.rs @@ -1,48 +1,22 @@ use zed_extension_api::{self as zed, Result, settings::LspSettings}; -const PROTOBUF_LANGUAGE_SERVER_NAME: &str = "protobuf-language-server"; +use crate::language_servers::{BufLsp, ProtoLs, ProtobufLanguageServer}; -struct ProtobufLanguageServerBinary { - path: String, - args: Option>, -} - -struct ProtobufExtension; - -impl ProtobufExtension { - fn language_server_binary( - &self, - _language_server_id: &zed::LanguageServerId, - worktree: &zed::Worktree, - ) -> Result { - let binary_settings = LspSettings::for_worktree("protobuf-language-server", worktree) - .ok() - .and_then(|lsp_settings| lsp_settings.binary); - let binary_args = binary_settings - .as_ref() - .and_then(|binary_settings| binary_settings.arguments.clone()); - - if let Some(path) = binary_settings.and_then(|binary_settings| binary_settings.path) { - return Ok(ProtobufLanguageServerBinary { - path, - args: binary_args, - }); - } - - if let Some(path) = worktree.which(PROTOBUF_LANGUAGE_SERVER_NAME) { - return Ok(ProtobufLanguageServerBinary { - path, - args: binary_args, - }); - } +mod language_servers; - Err(format!("{PROTOBUF_LANGUAGE_SERVER_NAME} not found in PATH",)) - } +struct ProtobufExtension { + protobuf_language_server: Option, + protols: Option, + buf_lsp: Option, } impl zed::Extension for ProtobufExtension { fn new() -> Self { - Self + Self { + protobuf_language_server: None, + protols: None, + buf_lsp: None, + } } fn language_server_command( @@ -50,14 +24,24 @@ impl zed::Extension for ProtobufExtension { language_server_id: &zed_extension_api::LanguageServerId, worktree: &zed_extension_api::Worktree, ) -> zed_extension_api::Result { - let binary = self.language_server_binary(language_server_id, worktree)?; - Ok(zed::Command { - command: binary.path, - args: binary - .args - .unwrap_or_else(|| vec!["-logs".into(), "".into()]), - env: Default::default(), - }) + match language_server_id.as_ref() { + ProtobufLanguageServer::SERVER_NAME => self + .protobuf_language_server + .get_or_insert_with(ProtobufLanguageServer::new) + .language_server_binary(worktree), + + ProtoLs::SERVER_NAME => self + .protols + .get_or_insert_with(ProtoLs::new) + .language_server_binary(worktree), + + BufLsp::SERVER_NAME => self + .buf_lsp + .get_or_insert_with(BufLsp::new) + .language_server_binary(worktree), + + _ => Err(format!("Unknown language server ID {}", language_server_id)), + } } fn language_server_workspace_configuration( @@ -65,10 +49,8 @@ impl zed::Extension for ProtobufExtension { server_id: &zed::LanguageServerId, worktree: &zed::Worktree, ) -> Result> { - let settings = LspSettings::for_worktree(server_id.as_ref(), worktree) - .ok() - .and_then(|lsp_settings| lsp_settings.settings); - Ok(settings) + LspSettings::for_worktree(server_id.as_ref(), worktree) + .map(|lsp_settings| lsp_settings.settings) } fn language_server_initialization_options( @@ -76,10 +58,8 @@ impl zed::Extension for ProtobufExtension { server_id: &zed::LanguageServerId, worktree: &zed::Worktree, ) -> Result> { - let initialization_options = LspSettings::for_worktree(server_id.as_ref(), worktree) - .ok() - .and_then(|lsp_settings| lsp_settings.initialization_options); - Ok(initialization_options) + LspSettings::for_worktree(server_id.as_ref(), worktree) + .map(|lsp_settings| lsp_settings.initialization_options) } } diff --git a/typos.toml b/typos.toml index 20a7b511a85676e3c5e49c23cab71c52e471cee9..8e42bd674a64d8adc1e684df181c8e4ce67988e9 100644 --- a/typos.toml +++ b/typos.toml @@ -31,6 +31,9 @@ extend-exclude = [ "crates/rpc/src/auth.rs", # glsl isn't recognized by this tool. "extensions/glsl/languages/glsl/", + # Protols is the name of the language server. + "extensions/proto/extension.toml", + "extensions/proto/src/language_servers/protols.rs", # Windows likes its abbreviations. "crates/gpui/src/platform/windows/directx_renderer.rs", "crates/gpui/src/platform/windows/events.rs", From 79d4f7d33d75789a6aaef2f3b82d9a9a20659ed1 Mon Sep 17 00:00:00 2001 From: Finn Evers Date: Mon, 15 Dec 2025 12:01:15 +0100 Subject: [PATCH 277/621] extension_api: Add `digest` to `GithubReleaseAsset` (#44399) Release Notes: - N/A --- crates/extension_api/wit/since_v0.8.0/github.wit | 2 ++ crates/extension_host/src/wasm_host/wit/since_v0_8_0.rs | 1 + crates/project/src/agent_server_store.rs | 6 +++--- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/crates/extension_api/wit/since_v0.8.0/github.wit b/crates/extension_api/wit/since_v0.8.0/github.wit index 21cd5d48056af08441d3bb5aa8547edd97a874d7..6d7e5d952ae921925459f475bceb74d6c384d8be 100644 --- a/crates/extension_api/wit/since_v0.8.0/github.wit +++ b/crates/extension_api/wit/since_v0.8.0/github.wit @@ -13,6 +13,8 @@ interface github { name: string, /// The download URL for the asset. download-url: string, + /// The SHA-256 of the release asset if provided by the GitHub API. + digest: option, } /// The options used to filter down GitHub releases. diff --git a/crates/extension_host/src/wasm_host/wit/since_v0_8_0.rs b/crates/extension_host/src/wasm_host/wit/since_v0_8_0.rs index a2776f9f3b5b055d00787fb59c9bbca582352b1f..b32ab97983642d68aba041ee3afb902a0c5d2455 100644 --- a/crates/extension_host/src/wasm_host/wit/since_v0_8_0.rs +++ b/crates/extension_host/src/wasm_host/wit/since_v0_8_0.rs @@ -783,6 +783,7 @@ impl From<::http_client::github::GithubReleaseAsset> for github::GithubReleaseAs Self { name: value.name, download_url: value.browser_download_url, + digest: value.digest, } } } diff --git a/crates/project/src/agent_server_store.rs b/crates/project/src/agent_server_store.rs index a2cc57beae9702e4d5b495a135e7c357c638c17a..62937476b8eea4b30f02637b3501ea2b56db81a1 100644 --- a/crates/project/src/agent_server_store.rs +++ b/crates/project/src/agent_server_store.rs @@ -1495,7 +1495,7 @@ impl ExternalAgentServer for LocalCodex { let digest = asset .digest .as_deref() - .and_then(|d| d.strip_prefix("sha256:").or(Some(d))); + .map(|d| d.strip_prefix("sha256:").unwrap_or(d)); match ::http_client::github_download::download_server_binary( &*http, &asset.browser_download_url, @@ -1727,10 +1727,10 @@ impl ExternalAgentServer for LocalExtensionArchiveAgent { release.assets.iter().find(|a| a.name == filename) { // Strip "sha256:" prefix if present - asset.digest.as_ref().and_then(|d| { + asset.digest.as_ref().map(|d| { d.strip_prefix("sha256:") .map(|s| s.to_string()) - .or_else(|| Some(d.clone())) + .unwrap_or_else(|| d.clone()) }) } else { None From 2f63543380c8d450e48523e9e3ffd800d8fdde7b Mon Sep 17 00:00:00 2001 From: Oscar Villavicencio Date: Mon, 15 Dec 2025 03:11:26 -0800 Subject: [PATCH 278/621] agent: Disable git pager to avoid hangs (#43277) - Set PAGER='' and GIT_PAGER=cat for agent/terminal commands so pager configs (e.g. delta) don't hang tool output\n\nFixes #42943 Release Notes: - Prevent git pager configs from hanging agent/terminal git commands by forcing PAGER and GIT_PAGER off. --- crates/acp_thread/src/terminal.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/acp_thread/src/terminal.rs b/crates/acp_thread/src/terminal.rs index 2da4125209d3bcf902d23380c5273d9b31902905..f70e044fbc1b380768dbcd807f1833f6fb5cd48b 100644 --- a/crates/acp_thread/src/terminal.rs +++ b/crates/acp_thread/src/terminal.rs @@ -187,8 +187,10 @@ pub async fn create_terminal_entity( Default::default() }; - // Disables paging for `git` and hopefully other commands + // Disable pagers so agent/terminal commands don't hang behind interactive UIs env.insert("PAGER".into(), "".into()); + // Override user core.pager (e.g. delta) which Git prefers over PAGER + env.insert("GIT_PAGER".into(), "cat".into()); env.extend(env_vars); // Use remote shell or default system shell, as appropriate From b633de66f79305541dae194b2b6859ae9fac5c16 Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Mon, 15 Dec 2025 19:12:29 +0800 Subject: [PATCH 279/621] gpui: Improve `cx.on_action` method to support chaining (#44353) Release Notes: - N/A To let `cx.on_action` support chaining like the `on_action` method of Div. https://github.com/zed-industries/zed/blob/ebcb2b2e646f10006dc40167d16e82ae74caa3a2/crates/agent_ui/src/acp/thread_view.rs#L5867-L5872 --- crates/client/src/client.rs | 10 ++-- crates/editor/src/editor.rs | 4 +- crates/gpui/src/app.rs | 6 +- crates/keymap_editor/src/keymap_editor.rs | 4 +- crates/workspace/src/workspace.rs | 71 +++++++++++------------ crates/zed/src/zed.rs | 62 ++++++++++---------- 6 files changed, 79 insertions(+), 78 deletions(-) diff --git a/crates/client/src/client.rs b/crates/client/src/client.rs index 6d6d229b940433ceac4c80f11891319550d269a2..14311d6bbf52ecb6df8dcc4a2fbc9454836a4834 100644 --- a/crates/client/src/client.rs +++ b/crates/client/src/client.rs @@ -150,9 +150,8 @@ pub fn init(client: &Arc, cx: &mut App) { .detach_and_log_err(cx); } } - }); - - cx.on_action({ + }) + .on_action({ let client = client.clone(); move |_: &SignOut, cx| { if let Some(client) = client.upgrade() { @@ -162,9 +161,8 @@ pub fn init(client: &Arc, cx: &mut App) { .detach(); } } - }); - - cx.on_action({ + }) + .on_action({ let client = client; move |_: &Reconnect, cx| { if let Some(client) = client.upgrade() { diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 923b5dc1540d93bd849f5a50a8d51052f79f93a0..29be039cdd182d1d45b0f3189e676d293486089f 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -351,8 +351,8 @@ pub fn init(cx: &mut App) { ) .detach(); } - }); - cx.on_action(move |_: &workspace::NewWindow, cx| { + }) + .on_action(move |_: &workspace::NewWindow, cx| { let app_state = workspace::AppState::global(cx); if let Some(app_state) = app_state.upgrade() { workspace::open_new( diff --git a/crates/gpui/src/app.rs b/crates/gpui/src/app.rs index f7c57ef015e73618b8cfd9d5da8dbb717905577b..aa1acae33b8fb55fc5e2f8fa8c0f5b8bb91758f3 100644 --- a/crates/gpui/src/app.rs +++ b/crates/gpui/src/app.rs @@ -1777,7 +1777,10 @@ impl App { /// Register a global handler for actions invoked via the keyboard. These handlers are run at /// the end of the bubble phase for actions, and so will only be invoked if there are no other /// handlers or if they called `cx.propagate()`. - pub fn on_action(&mut self, listener: impl Fn(&A, &mut Self) + 'static) { + pub fn on_action( + &mut self, + listener: impl Fn(&A, &mut Self) + 'static, + ) -> &mut Self { self.global_action_listeners .entry(TypeId::of::()) .or_default() @@ -1787,6 +1790,7 @@ impl App { listener(action, cx) } })); + self } /// Event handlers propagate events by default. Call this method to stop dispatching to diff --git a/crates/keymap_editor/src/keymap_editor.rs b/crates/keymap_editor/src/keymap_editor.rs index 113d5026eb89587714172ff4c76698bcadb5fd6a..e81b1077c70d4eb3828715a6bcd28dfe564ab188 100644 --- a/crates/keymap_editor/src/keymap_editor.rs +++ b/crates/keymap_editor/src/keymap_editor.rs @@ -123,8 +123,8 @@ pub fn init(cx: &mut App) { }) } - cx.on_action(|_: &OpenKeymap, cx| common(None, cx)); - cx.on_action(|action: &ChangeKeybinding, cx| common(Some(action.action.clone()), cx)); + cx.on_action(|_: &OpenKeymap, cx| common(None, cx)) + .on_action(|action: &ChangeKeybinding, cx| common(Some(action.action.clone()), cx)); register_serializable_item::(cx); } diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index 56dfb2398997a19e98c339876987419bb925f324..0a50faf867c2647874c1c7bb6d7887da6fee1388 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -576,44 +576,43 @@ pub fn init(app_state: Arc, cx: &mut App) { toast_layer::init(cx); history_manager::init(cx); - cx.on_action(|_: &CloseWindow, cx| Workspace::close_global(cx)); - cx.on_action(|_: &Reload, cx| reload(cx)); - - cx.on_action({ - let app_state = Arc::downgrade(&app_state); - move |_: &Open, cx: &mut App| { - if let Some(app_state) = app_state.upgrade() { - prompt_and_open_paths( - app_state, - PathPromptOptions { - files: true, - directories: true, - multiple: true, - prompt: None, - }, - cx, - ); + cx.on_action(|_: &CloseWindow, cx| Workspace::close_global(cx)) + .on_action(|_: &Reload, cx| reload(cx)) + .on_action({ + let app_state = Arc::downgrade(&app_state); + move |_: &Open, cx: &mut App| { + if let Some(app_state) = app_state.upgrade() { + prompt_and_open_paths( + app_state, + PathPromptOptions { + files: true, + directories: true, + multiple: true, + prompt: None, + }, + cx, + ); + } } - } - }); - cx.on_action({ - let app_state = Arc::downgrade(&app_state); - move |_: &OpenFiles, cx: &mut App| { - let directories = cx.can_select_mixed_files_and_dirs(); - if let Some(app_state) = app_state.upgrade() { - prompt_and_open_paths( - app_state, - PathPromptOptions { - files: true, - directories, - multiple: true, - prompt: None, - }, - cx, - ); + }) + .on_action({ + let app_state = Arc::downgrade(&app_state); + move |_: &OpenFiles, cx: &mut App| { + let directories = cx.can_select_mixed_files_and_dirs(); + if let Some(app_state) = app_state.upgrade() { + prompt_and_open_paths( + app_state, + PathPromptOptions { + files: true, + directories, + multiple: true, + prompt: None, + }, + cx, + ); + } } - } - }); + }); } type BuildProjectItemFn = diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs index 3bc05ef540769800ef96a76bcbcfd24b09680192..ed22d7ef510e367b71b2a1057513471a4e32306a 100644 --- a/crates/zed/src/zed.rs +++ b/crates/zed/src/zed.rs @@ -161,15 +161,15 @@ pub fn init(cx: &mut App) { || flag.await { cx.update(|cx| { - cx.on_action(|_: &TestPanic, _| panic!("Ran the TestPanic action")); - cx.on_action(|_: &TestCrash, _| { - unsafe extern "C" { - fn puts(s: *const i8); - } - unsafe { - puts(0xabad1d3a as *const i8); - } - }); + cx.on_action(|_: &TestPanic, _| panic!("Ran the TestPanic action")) + .on_action(|_: &TestCrash, _| { + unsafe extern "C" { + fn puts(s: *const i8); + } + unsafe { + puts(0xabad1d3a as *const i8); + } + }); }) .ok(); }; @@ -179,11 +179,11 @@ pub fn init(cx: &mut App) { with_active_or_new_workspace(cx, |workspace, window, cx| { open_log_file(workspace, window, cx); }); - }); - cx.on_action(|_: &workspace::RevealLogInFileManager, cx| { + }) + .on_action(|_: &workspace::RevealLogInFileManager, cx| { cx.reveal_path(paths::log_file().as_path()); - }); - cx.on_action(|_: &zed_actions::OpenLicenses, cx| { + }) + .on_action(|_: &zed_actions::OpenLicenses, cx| { with_active_or_new_workspace(cx, |workspace, window, cx| { open_bundled_file( workspace, @@ -194,13 +194,13 @@ pub fn init(cx: &mut App) { cx, ); }); - }); - cx.on_action(|_: &zed_actions::OpenTelemetryLog, cx| { + }) + .on_action(|_: &zed_actions::OpenTelemetryLog, cx| { with_active_or_new_workspace(cx, |workspace, window, cx| { open_telemetry_log_file(workspace, window, cx); }); - }); - cx.on_action(|&zed_actions::OpenKeymapFile, cx| { + }) + .on_action(|&zed_actions::OpenKeymapFile, cx| { with_active_or_new_workspace(cx, |_, window, cx| { open_settings_file( paths::keymap_file(), @@ -209,8 +209,8 @@ pub fn init(cx: &mut App) { cx, ); }); - }); - cx.on_action(|_: &OpenSettingsFile, cx| { + }) + .on_action(|_: &OpenSettingsFile, cx| { with_active_or_new_workspace(cx, |_, window, cx| { open_settings_file( paths::settings_file(), @@ -219,13 +219,13 @@ pub fn init(cx: &mut App) { cx, ); }); - }); - cx.on_action(|_: &OpenAccountSettings, cx| { + }) + .on_action(|_: &OpenAccountSettings, cx| { with_active_or_new_workspace(cx, |_, _, cx| { cx.open_url(&zed_urls::account_url(cx)); }); - }); - cx.on_action(|_: &OpenTasks, cx| { + }) + .on_action(|_: &OpenTasks, cx| { with_active_or_new_workspace(cx, |_, window, cx| { open_settings_file( paths::tasks_file(), @@ -234,8 +234,8 @@ pub fn init(cx: &mut App) { cx, ); }); - }); - cx.on_action(|_: &OpenDebugTasks, cx| { + }) + .on_action(|_: &OpenDebugTasks, cx| { with_active_or_new_workspace(cx, |_, window, cx| { open_settings_file( paths::debug_scenarios_file(), @@ -244,8 +244,8 @@ pub fn init(cx: &mut App) { cx, ); }); - }); - cx.on_action(|_: &OpenDefaultSettings, cx| { + }) + .on_action(|_: &OpenDefaultSettings, cx| { with_active_or_new_workspace(cx, |workspace, window, cx| { open_bundled_file( workspace, @@ -256,8 +256,8 @@ pub fn init(cx: &mut App) { cx, ); }); - }); - cx.on_action(|_: &zed_actions::OpenDefaultKeymap, cx| { + }) + .on_action(|_: &zed_actions::OpenDefaultKeymap, cx| { with_active_or_new_workspace(cx, |workspace, window, cx| { open_bundled_file( workspace, @@ -268,8 +268,8 @@ pub fn init(cx: &mut App) { cx, ); }); - }); - cx.on_action(|_: &zed_actions::About, cx| { + }) + .on_action(|_: &zed_actions::About, cx| { with_active_or_new_workspace(cx, |workspace, window, cx| { about(workspace, window, cx); }); From 886832281da80f862dd7f35944c449530fe9dc40 Mon Sep 17 00:00:00 2001 From: Finn Evers Date: Mon, 15 Dec 2025 12:23:55 +0100 Subject: [PATCH 280/621] Fix formatting of default settings (#44867) Another day, another me wishing for [merge queue](https://github.com/user-attachments/assets/ee1c313b-7d26-4d4a-9cc0-f1faeaac8251) Release Notes: - N/A --- assets/settings/default.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/settings/default.json b/assets/settings/default.json index c4c66f47a6948bc755e588cc37504dc01e954e36..2bca46cc38334475c9ccb5ad7862afd9a2f7b9eb 100644 --- a/assets/settings/default.json +++ b/assets/settings/default.json @@ -1933,7 +1933,7 @@ }, }, "Proto": { - "language_servers": ["buf", "!protols", "!protobuf-language-server", "..."] + "language_servers": ["buf", "!protols", "!protobuf-language-server", "..."], }, "Python": { "code_actions_on_format": { From 8fb2bde2c9fb752bd1d21c3c6e66ee5891487600 Mon Sep 17 00:00:00 2001 From: Finn Evers Date: Mon, 15 Dec 2025 12:50:44 +0100 Subject: [PATCH 281/621] html: Bump to v0.3.0 (#44865) Release Notes: - N/A --- Cargo.lock | 2 +- extensions/html/Cargo.toml | 2 +- extensions/html/extension.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 29de11a496fb25b86fcbc87c1f394c65a8e364b2..70686d8a83ab5248d00dfba696663e6e04bd4740 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -20819,7 +20819,7 @@ dependencies = [ [[package]] name = "zed_html" -version = "0.2.3" +version = "0.3.0" dependencies = [ "zed_extension_api 0.7.0", ] diff --git a/extensions/html/Cargo.toml b/extensions/html/Cargo.toml index 22cdb401a7ebcf4bb6afab7702fb81f345b7aa14..2c89f86cb450b7ea8476bffdff003a94b137d213 100644 --- a/extensions/html/Cargo.toml +++ b/extensions/html/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zed_html" -version = "0.2.3" +version = "0.3.0" edition.workspace = true publish.workspace = true license = "Apache-2.0" diff --git a/extensions/html/extension.toml b/extensions/html/extension.toml index 1ded7af6413d0f1990a178a19a4014caadf48240..68ab0e4b9d3f56fca17cbd518d5990edc2ec711a 100644 --- a/extensions/html/extension.toml +++ b/extensions/html/extension.toml @@ -1,7 +1,7 @@ id = "html" name = "HTML" description = "HTML support." -version = "0.2.3" +version = "0.3.0" schema_version = 1 authors = ["Isaac Clayton "] repository = "https://github.com/zed-industries/zed" From 3e8d55739cec84d22093af57790cfb884bd20aa0 Mon Sep 17 00:00:00 2001 From: Finn Evers Date: Mon, 15 Dec 2025 12:51:18 +0100 Subject: [PATCH 282/621] proto: Bump to v0.3.0 (#44866) Release Notes: - N/A --- Cargo.lock | 2 +- extensions/proto/Cargo.toml | 2 +- extensions/proto/extension.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 70686d8a83ab5248d00dfba696663e6e04bd4740..1dfcabfb552e128dfa6b0b47ebb5f33bfa2aa4a6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -20826,7 +20826,7 @@ dependencies = [ [[package]] name = "zed_proto" -version = "0.2.3" +version = "0.3.0" dependencies = [ "zed_extension_api 0.7.0", ] diff --git a/extensions/proto/Cargo.toml b/extensions/proto/Cargo.toml index d4c966a686a1ef0bfa2fe658c45f3b391e54ccee..c3606f668aa01d7a8baa20d54d073a7004a6f8c0 100644 --- a/extensions/proto/Cargo.toml +++ b/extensions/proto/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zed_proto" -version = "0.2.3" +version = "0.3.0" edition.workspace = true publish.workspace = true license = "Apache-2.0" diff --git a/extensions/proto/extension.toml b/extensions/proto/extension.toml index ff8c5758d0c1780031ef850a912d294dcef1a40e..13c4054eef083e131ab311b1ec6e5a63aff545d8 100644 --- a/extensions/proto/extension.toml +++ b/extensions/proto/extension.toml @@ -1,7 +1,7 @@ id = "proto" name = "Proto" description = "Protocol Buffers support." -version = "0.2.3" +version = "0.3.0" schema_version = 1 authors = ["Zed Industries "] repository = "https://github.com/zed-industries/zed" From 59b01651e162a06a0b58bf11c58d8dd89cc022c0 Mon Sep 17 00:00:00 2001 From: Devzeth <47153906+devzeth@users.noreply.github.com> Date: Mon, 15 Dec 2025 12:58:22 +0100 Subject: [PATCH 283/621] ui: Improve focused border color consistency across panels (#44754) The issue is that we aren't consistent in using the same `panel_focus_border` color across zed. Might completely fix my issue: #44750 For focused items in: - outline panel - git panel While these: - project panel - keymap editor tab Are actually using the panel_focused_border option. Not sure if this warrants a release note, feel free to adapt. Release Notes: - N/A --- crates/git_ui/src/git_panel.rs | 4 ++-- crates/outline_panel/src/outline_panel.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs index 81d2a547bf11d91df98935efa0c167d28644e073..20ba1d5b903582214a8b982551f279b07278872e 100644 --- a/crates/git_ui/src/git_panel.rs +++ b/crates/git_ui/src/git_panel.rs @@ -4813,7 +4813,7 @@ impl GitPanel { .items_center() .border_1() .when(selected && self.focus_handle.is_focused(window), |el| { - el.border_color(cx.theme().colors().border_focused) + el.border_color(cx.theme().colors().panel_focused_border) }) .px(rems(0.75)) // ~12px .overflow_hidden() @@ -4977,7 +4977,7 @@ impl GitPanel { .items_center() .border_1() .when(selected && self.focus_handle.is_focused(window), |el| { - el.border_color(cx.theme().colors().border_focused) + el.border_color(cx.theme().colors().panel_focused_border) }) .px(rems(0.75)) .overflow_hidden() diff --git a/crates/outline_panel/src/outline_panel.rs b/crates/outline_panel/src/outline_panel.rs index a787ad5b032ffcabc38790668fd4e0901ac1bebc..943025b1d0a96692f34f2ebcefff83a0ad2ddaee 100644 --- a/crates/outline_panel/src/outline_panel.rs +++ b/crates/outline_panel/src/outline_panel.rs @@ -2610,7 +2610,7 @@ impl OutlinePanel { }) .when( is_active && self.focus_handle.contains_focused(window, cx), - |div| div.border_color(Color::Selected.color(cx)), + |div| div.border_color(cx.theme().colors().panel_focused_border), ) } From bd481dea48e62a08e5420ba4d17662d1ba5f2bb3 Mon Sep 17 00:00:00 2001 From: Xiaobo Liu Date: Mon, 15 Dec 2025 20:06:17 +0800 Subject: [PATCH 284/621] git_ui: Add dismiss button to status toast (#44813) Release Notes: - N/A --------- Signed-off-by: Xiaobo Liu Co-authored-by: Danilo Leal --- crates/git_ui/src/git_panel.rs | 1 + crates/notifications/src/status_toast.rs | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs index 20ba1d5b903582214a8b982551f279b07278872e..527e5062ae45a48c286bffe957821f12705ec60c 100644 --- a/crates/git_ui/src/git_panel.rs +++ b/crates/git_ui/src/git_panel.rs @@ -3598,6 +3598,7 @@ impl GitPanel { .icon(ToastIcon::new(IconName::GitBranchAlt).color(Color::Muted)) .action(text, move |_, cx| cx.open_url(&link)), } + .dismiss_button(true) }); workspace.toggle_status_toast(status_toast, cx) }); diff --git a/crates/notifications/src/status_toast.rs b/crates/notifications/src/status_toast.rs index 7affa93f5a496bd0e436c74e5ff32f8aa871d026..40c5bdc8f85d0b9a46474760954247e8bba76ca9 100644 --- a/crates/notifications/src/status_toast.rs +++ b/crates/notifications/src/status_toast.rs @@ -137,7 +137,8 @@ impl Render for StatusToast { let handle = self.this_handle.clone(); this.child( IconButton::new("dismiss", IconName::Close) - .icon_size(IconSize::XSmall) + .shape(ui::IconButtonShape::Square) + .icon_size(IconSize::Small) .icon_color(Color::Muted) .tooltip(Tooltip::text("Dismiss")) .on_click(move |_click_event, _window, cx| { From 5805f62f1812b3ece91ba8fa00203ccf7a238ad2 Mon Sep 17 00:00:00 2001 From: Devzeth <47153906+devzeth@users.noreply.github.com> Date: Mon, 15 Dec 2025 13:14:43 +0100 Subject: [PATCH 285/621] git_ui: Show missing right border on selected items (#44747) For folders and files basically any selected item in the git panel we draw a border around it. The issue is that the right side of this border wasn't ever visible. In the project_panel.rs file I've saw that the decision was to make the right side border 2 pixels. And this panel doesn't have this issue, no matter which side of the dock is selected. So it was a very easy `look at how we did x do y`. Before: ![image](https://github.com/user-attachments/assets/8ce32728-8ad6-487c-80f5-1c46d9756f4a) After: ![image](https://github.com/user-attachments/assets/998899b4-af98-4cc2-9435-4df6c98c1a50) I don't think it warrants a release note. Release Notes: - N/A --------- Co-authored-by: Danilo Leal --- crates/git_ui/src/git_panel.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs index 527e5062ae45a48c286bffe957821f12705ec60c..cf588d6b0448c2a7c8e7feb50d34c6e405845116 100644 --- a/crates/git_ui/src/git_panel.rs +++ b/crates/git_ui/src/git_panel.rs @@ -4811,8 +4811,8 @@ impl GitPanel { .id(id) .h(self.list_item_height()) .w_full() - .items_center() .border_1() + .border_r_2() .when(selected && self.focus_handle.is_focused(window), |el| { el.border_color(cx.theme().colors().panel_focused_border) }) @@ -4977,6 +4977,7 @@ impl GitPanel { .w_full() .items_center() .border_1() + .border_r_2() .when(selected && self.focus_handle.is_focused(window), |el| { el.border_color(cx.theme().colors().panel_focused_border) }) From c996934b57184a8f8a3b4ac39621de49e181914c Mon Sep 17 00:00:00 2001 From: Kasper Date: Mon, 15 Dec 2025 13:14:57 +0100 Subject: [PATCH 286/621] Helix: Fix visual/textual line up/down (#42676) Release Notes: - Make Helix keybinds use visual line movement for `j`, `Down`, `k` and `Up`, and textual line movement for `g j`, `g Down`, `g k` and `g Up`. --- assets/keymaps/vim.json | 222 +++++++++++++++++++++------------------- 1 file changed, 115 insertions(+), 107 deletions(-) diff --git a/assets/keymaps/vim.json b/assets/keymaps/vim.json index 34bbd44fc3be6a8bd6fa35944e073f5118d6cd33..bbae6e2f4d738ef60b3a1a5ba33a26a9ab68f497 100644 --- a/assets/keymaps/vim.json +++ b/assets/keymaps/vim.json @@ -181,8 +181,8 @@ "ctrl-w space": "editor::OpenExcerptsSplit", "ctrl-w g space": "editor::OpenExcerptsSplit", "ctrl-^": "pane::AlternateFile", - ".": "vim::Repeat" - } + ".": "vim::Repeat", + }, }, { "context": "vim_mode == normal || vim_mode == visual || vim_mode == operator", @@ -223,8 +223,8 @@ "] r": "vim::GoToNextReference", // tree-sitter related commands "[ x": "vim::SelectLargerSyntaxNode", - "] x": "vim::SelectSmallerSyntaxNode" - } + "] x": "vim::SelectSmallerSyntaxNode", + }, }, { "context": "vim_mode == normal", @@ -261,16 +261,16 @@ "[ d": "editor::GoToPreviousDiagnostic", "] c": "editor::GoToHunk", "[ c": "editor::GoToPreviousHunk", - "g c": "vim::PushToggleComments" - } + "g c": "vim::PushToggleComments", + }, }, { "context": "VimControl && VimCount", "bindings": { "0": ["vim::Number", 0], ":": "vim::CountCommand", - "%": "vim::GoToPercentage" - } + "%": "vim::GoToPercentage", + }, }, { "context": "vim_mode == visual", @@ -322,8 +322,8 @@ "g w": "vim::Rewrap", "g ?": "vim::ConvertToRot13", // "g ?": "vim::ConvertToRot47", - "\"": "vim::PushRegister" - } + "\"": "vim::PushRegister", + }, }, { "context": "vim_mode == helix_select", @@ -343,8 +343,8 @@ "ctrl-pageup": "pane::ActivatePreviousItem", "ctrl-pagedown": "pane::ActivateNextItem", ".": "vim::Repeat", - "alt-.": "vim::RepeatFind" - } + "alt-.": "vim::RepeatFind", + }, }, { "context": "vim_mode == insert", @@ -374,8 +374,8 @@ "ctrl-r": "vim::PushRegister", "insert": "vim::ToggleReplace", "ctrl-o": "vim::TemporaryNormal", - "ctrl-s": "editor::ShowSignatureHelp" - } + "ctrl-s": "editor::ShowSignatureHelp", + }, }, { "context": "showing_completions", @@ -383,8 +383,8 @@ "ctrl-d": "vim::ScrollDown", "ctrl-u": "vim::ScrollUp", "ctrl-e": "vim::LineDown", - "ctrl-y": "vim::LineUp" - } + "ctrl-y": "vim::LineUp", + }, }, { "context": "(vim_mode == normal || vim_mode == helix_normal) && !menu", @@ -409,23 +409,31 @@ "shift-s": "vim::SubstituteLine", "\"": "vim::PushRegister", "ctrl-pagedown": "pane::ActivateNextItem", - "ctrl-pageup": "pane::ActivatePreviousItem" - } + "ctrl-pageup": "pane::ActivatePreviousItem", + }, }, { "context": "VimControl && vim_mode == helix_normal && !menu", "bindings": { + "j": ["vim::Down", { "display_lines": true }], + "down": ["vim::Down", { "display_lines": true }], + "k": ["vim::Up", { "display_lines": true }], + "up": ["vim::Up", { "display_lines": true }], + "g j": "vim::Down", + "g down": "vim::Down", + "g k": "vim::Up", + "g up": "vim::Up", "escape": "vim::SwitchToHelixNormalMode", "i": "vim::HelixInsert", "a": "vim::HelixAppend", - "ctrl-[": "editor::Cancel" - } + "ctrl-[": "editor::Cancel", + }, }, { "context": "vim_mode == helix_select && !menu", "bindings": { - "escape": "vim::SwitchToHelixNormalMode" - } + "escape": "vim::SwitchToHelixNormalMode", + }, }, { "context": "(vim_mode == helix_normal || vim_mode == helix_select) && !menu", @@ -526,22 +534,22 @@ "]": ["vim::PushHelixNext", { "around": true }], "[": ["vim::PushHelixPrevious", { "around": true }], "g q": "vim::PushRewrap", - "g w": "vim::PushRewrap" // not a helix default & clashes with helix `goto_word` - } + "g w": "vim::PushRewrap", // not a helix default & clashes with helix `goto_word` + }, }, { "context": "vim_mode == insert && !(showing_code_actions || showing_completions)", "bindings": { "ctrl-p": "editor::ShowWordCompletions", - "ctrl-n": "editor::ShowWordCompletions" - } + "ctrl-n": "editor::ShowWordCompletions", + }, }, { "context": "(vim_mode == insert || vim_mode == normal) && showing_signature_help && !showing_completions", "bindings": { "ctrl-p": "editor::SignatureHelpPrevious", - "ctrl-n": "editor::SignatureHelpNext" - } + "ctrl-n": "editor::SignatureHelpNext", + }, }, { "context": "vim_mode == replace", @@ -557,8 +565,8 @@ "backspace": "vim::UndoReplace", "tab": "vim::Tab", "enter": "vim::Enter", - "insert": "vim::InsertBefore" - } + "insert": "vim::InsertBefore", + }, }, { "context": "vim_mode == waiting", @@ -570,14 +578,14 @@ "escape": "vim::ClearOperators", "ctrl-k": ["vim::PushDigraph", {}], "ctrl-v": ["vim::PushLiteral", {}], - "ctrl-q": ["vim::PushLiteral", {}] - } + "ctrl-q": ["vim::PushLiteral", {}], + }, }, { "context": "Editor && vim_mode == waiting && (vim_operator == ys || vim_operator == cs)", "bindings": { - "escape": "vim::SwitchToNormalMode" - } + "escape": "vim::SwitchToNormalMode", + }, }, { "context": "vim_mode == operator", @@ -585,8 +593,8 @@ "ctrl-c": "vim::ClearOperators", "ctrl-[": "vim::ClearOperators", "escape": "vim::ClearOperators", - "g c": "vim::Comment" - } + "g c": "vim::Comment", + }, }, { "context": "vim_operator == a || vim_operator == i || vim_operator == cs || vim_operator == helix_next || vim_operator == helix_previous", @@ -623,14 +631,14 @@ "shift-i": ["vim::IndentObj", { "include_below": true }], "f": "vim::Method", "c": "vim::Class", - "e": "vim::EntireFile" - } + "e": "vim::EntireFile", + }, }, { "context": "vim_operator == helix_m", "bindings": { - "m": "vim::Matching" - } + "m": "vim::Matching", + }, }, { "context": "vim_operator == helix_next", @@ -647,8 +655,8 @@ "x": "editor::SelectSmallerSyntaxNode", "d": "editor::GoToDiagnostic", "c": "editor::GoToHunk", - "space": "vim::InsertEmptyLineBelow" - } + "space": "vim::InsertEmptyLineBelow", + }, }, { "context": "vim_operator == helix_previous", @@ -665,8 +673,8 @@ "x": "editor::SelectLargerSyntaxNode", "d": "editor::GoToPreviousDiagnostic", "c": "editor::GoToPreviousHunk", - "space": "vim::InsertEmptyLineAbove" - } + "space": "vim::InsertEmptyLineAbove", + }, }, { "context": "vim_operator == c", @@ -674,8 +682,8 @@ "c": "vim::CurrentLine", "x": "vim::Exchange", "d": "editor::Rename", // zed specific - "s": ["vim::PushChangeSurrounds", {}] - } + "s": ["vim::PushChangeSurrounds", {}], + }, }, { "context": "vim_operator == d", @@ -687,36 +695,36 @@ "shift-o": "git::ToggleStaged", "p": "git::Restore", // "d p" "u": "git::StageAndNext", // "d u" - "shift-u": "git::UnstageAndNext" // "d shift-u" - } + "shift-u": "git::UnstageAndNext", // "d shift-u" + }, }, { "context": "vim_operator == gu", "bindings": { "g u": "vim::CurrentLine", - "u": "vim::CurrentLine" - } + "u": "vim::CurrentLine", + }, }, { "context": "vim_operator == gU", "bindings": { "g shift-u": "vim::CurrentLine", - "shift-u": "vim::CurrentLine" - } + "shift-u": "vim::CurrentLine", + }, }, { "context": "vim_operator == g~", "bindings": { "g ~": "vim::CurrentLine", - "~": "vim::CurrentLine" - } + "~": "vim::CurrentLine", + }, }, { "context": "vim_operator == g?", "bindings": { "g ?": "vim::CurrentLine", - "?": "vim::CurrentLine" - } + "?": "vim::CurrentLine", + }, }, { "context": "vim_operator == gq", @@ -724,66 +732,66 @@ "g q": "vim::CurrentLine", "q": "vim::CurrentLine", "g w": "vim::CurrentLine", - "w": "vim::CurrentLine" - } + "w": "vim::CurrentLine", + }, }, { "context": "vim_operator == y", "bindings": { "y": "vim::CurrentLine", "v": "vim::PushForcedMotion", - "s": ["vim::PushAddSurrounds", {}] - } + "s": ["vim::PushAddSurrounds", {}], + }, }, { "context": "vim_operator == ys", "bindings": { - "s": "vim::CurrentLine" - } + "s": "vim::CurrentLine", + }, }, { "context": "vim_operator == >", "bindings": { - ">": "vim::CurrentLine" - } + ">": "vim::CurrentLine", + }, }, { "context": "vim_operator == <", "bindings": { - "<": "vim::CurrentLine" - } + "<": "vim::CurrentLine", + }, }, { "context": "vim_operator == eq", "bindings": { - "=": "vim::CurrentLine" - } + "=": "vim::CurrentLine", + }, }, { "context": "vim_operator == sh", "bindings": { - "!": "vim::CurrentLine" - } + "!": "vim::CurrentLine", + }, }, { "context": "vim_operator == gc", "bindings": { - "c": "vim::CurrentLine" - } + "c": "vim::CurrentLine", + }, }, { "context": "vim_operator == gR", "bindings": { "r": "vim::CurrentLine", - "shift-r": "vim::CurrentLine" - } + "shift-r": "vim::CurrentLine", + }, }, { "context": "vim_operator == cx", "bindings": { "x": "vim::CurrentLine", - "c": "vim::ClearExchange" - } + "c": "vim::ClearExchange", + }, }, { "context": "vim_mode == literal", @@ -825,15 +833,15 @@ "tab": ["vim::Literal", ["tab", "\u0009"]], // zed extensions: "backspace": ["vim::Literal", ["backspace", "\u0008"]], - "delete": ["vim::Literal", ["delete", "\u007F"]] - } + "delete": ["vim::Literal", ["delete", "\u007F"]], + }, }, { "context": "BufferSearchBar && !in_replace", "bindings": { "enter": "vim::SearchSubmit", - "escape": "buffer_search::Dismiss" - } + "escape": "buffer_search::Dismiss", + }, }, { "context": "VimControl && !menu || !Editor && !Terminal", @@ -894,8 +902,8 @@ "ctrl-w ctrl-n": "workspace::NewFileSplitHorizontal", "ctrl-w n": "workspace::NewFileSplitHorizontal", "g t": "vim::GoToTab", - "g shift-t": "vim::GoToPreviousTab" - } + "g shift-t": "vim::GoToPreviousTab", + }, }, { "context": "!Editor && !Terminal", @@ -905,8 +913,8 @@ "] b": "pane::ActivateNextItem", "[ b": "pane::ActivatePreviousItem", "] shift-b": "pane::ActivateLastItem", - "[ shift-b": ["pane::ActivateItem", 0] - } + "[ shift-b": ["pane::ActivateItem", 0], + }, }, { // netrw compatibility @@ -956,8 +964,8 @@ "6": ["vim::Number", 6], "7": ["vim::Number", 7], "8": ["vim::Number", 8], - "9": ["vim::Number", 9] - } + "9": ["vim::Number", 9], + }, }, { "context": "OutlinePanel && not_editing", @@ -965,8 +973,8 @@ "j": "menu::SelectNext", "k": "menu::SelectPrevious", "shift-g": "menu::SelectLast", - "g g": "menu::SelectFirst" - } + "g g": "menu::SelectFirst", + }, }, { "context": "GitPanel && ChangesList", @@ -981,8 +989,8 @@ "x": "git::ToggleStaged", "shift-x": "git::StageAll", "g x": "git::StageRange", - "shift-u": "git::UnstageAll" - } + "shift-u": "git::UnstageAll", + }, }, { "context": "Editor && mode == auto_height && VimControl", @@ -993,8 +1001,8 @@ "#": null, "*": null, "n": null, - "shift-n": null - } + "shift-n": null, + }, }, { "context": "Picker > Editor", @@ -1003,29 +1011,29 @@ "ctrl-u": "editor::DeleteToBeginningOfLine", "ctrl-w": "editor::DeleteToPreviousWordStart", "ctrl-p": "menu::SelectPrevious", - "ctrl-n": "menu::SelectNext" - } + "ctrl-n": "menu::SelectNext", + }, }, { "context": "GitCommit > Editor && VimControl && vim_mode == normal", "bindings": { "ctrl-c": "menu::Cancel", - "escape": "menu::Cancel" - } + "escape": "menu::Cancel", + }, }, { "context": "Editor && edit_prediction", "bindings": { // This is identical to the binding in the base keymap, but the vim bindings above to // "vim::Tab" shadow it, so it needs to be bound again. - "tab": "editor::AcceptEditPrediction" - } + "tab": "editor::AcceptEditPrediction", + }, }, { "context": "MessageEditor > Editor && VimControl", "bindings": { - "enter": "agent::Chat" - } + "enter": "agent::Chat", + }, }, { "context": "os != macos && Editor && edit_prediction_conflict", @@ -1033,8 +1041,8 @@ // alt-l is provided as an alternative to tab/alt-tab. and will be displayed in the UI. This // is because alt-tab may not be available, as it is often used for window switching on Linux // and Windows. - "alt-l": "editor::AcceptEditPrediction" - } + "alt-l": "editor::AcceptEditPrediction", + }, }, { "context": "SettingsWindow > NavigationMenu && !search", @@ -1044,8 +1052,8 @@ "k": "settings_editor::FocusPreviousNavEntry", "j": "settings_editor::FocusNextNavEntry", "g g": "settings_editor::FocusFirstNavEntry", - "shift-g": "settings_editor::FocusLastNavEntry" - } + "shift-g": "settings_editor::FocusLastNavEntry", + }, }, { "context": "MarkdownPreview", @@ -1053,7 +1061,7 @@ "ctrl-u": "markdown::ScrollPageUp", "ctrl-d": "markdown::ScrollPageDown", "ctrl-y": "markdown::ScrollUp", - "ctrl-e": "markdown::ScrollDown" - } - } + "ctrl-e": "markdown::ScrollDown", + }, + }, ] From a61c14cf3b302bd5cdcd4906a0ee884ad5a63623 Mon Sep 17 00:00:00 2001 From: Jake Go Date: Mon, 15 Dec 2025 07:25:17 -0500 Subject: [PATCH 287/621] Add setting to hide user menu in the title bar (#44466) Closes #44417 Release Notes: - Added a setting `show_user_menu` (defaulting to true) which shows or hides the user menu (the one with the user avatar) in title bar. --------- Co-authored-by: Danilo Leal --- assets/settings/default.json | 2 ++ crates/settings/src/settings_content.rs | 4 +++ crates/settings_ui/src/page_data.rs | 42 +++++++++++++++------- crates/title_bar/src/title_bar.rs | 8 +++-- crates/title_bar/src/title_bar_settings.rs | 2 ++ docs/src/configuring-zed.md | 2 ++ docs/src/visual-customization.md | 1 + 7 files changed, 46 insertions(+), 15 deletions(-) diff --git a/assets/settings/default.json b/assets/settings/default.json index 2bca46cc38334475c9ccb5ad7862afd9a2f7b9eb..146915dd1a242e2a8b70ba1010bb5fbe09dbbbbc 100644 --- a/assets/settings/default.json +++ b/assets/settings/default.json @@ -436,6 +436,8 @@ "show_onboarding_banner": true, // Whether to show user picture in the titlebar. "show_user_picture": true, + // Whether to show the user menu in the titlebar. + "show_user_menu": true, // Whether to show the sign in button in the titlebar. "show_sign_in": true, // Whether to show the menus in the titlebar. diff --git a/crates/settings/src/settings_content.rs b/crates/settings/src/settings_content.rs index 743e22b04d9cf87a0d09a73aef879c781a50cca2..ba349b865bf2ac4dfd9d19b22c5693307ebae20a 100644 --- a/crates/settings/src/settings_content.rs +++ b/crates/settings/src/settings_content.rs @@ -286,6 +286,10 @@ pub struct TitleBarSettingsContent { /// /// Default: true pub show_sign_in: Option, + /// Whether to show the user menu button in the title bar. + /// + /// Default: true + pub show_user_menu: Option, /// Whether to show the menus in the title bar. /// /// Default: false diff --git a/crates/settings_ui/src/page_data.rs b/crates/settings_ui/src/page_data.rs index b03ce327877f7251d41c39ee1eed5d424c18ce84..79fc1cc11158399265a184a289fd8d7a71ce8d69 100644 --- a/crates/settings_ui/src/page_data.rs +++ b/crates/settings_ui/src/page_data.rs @@ -2913,40 +2913,58 @@ pub(crate) fn settings_data(cx: &App) -> Vec { files: USER, }), SettingsPageItem::SettingItem(SettingItem { - title: "Show User Picture", - description: "Show user picture in the titlebar.", + title: "Show Sign In", + description: "Show the sign in button in the titlebar.", field: Box::new(SettingField { - json_path: Some("title_bar.show_user_picture"), + json_path: Some("title_bar.show_sign_in"), pick: |settings_content| { + settings_content.title_bar.as_ref()?.show_sign_in.as_ref() + }, + write: |settings_content, value| { settings_content .title_bar - .as_ref()? - .show_user_picture - .as_ref() + .get_or_insert_default() + .show_sign_in = value; + }, + }), + metadata: None, + files: USER, + }), + SettingsPageItem::SettingItem(SettingItem { + title: "Show User Menu", + description: "Show the user menu button in the titlebar.", + field: Box::new(SettingField { + json_path: Some("title_bar.show_user_menu"), + pick: |settings_content| { + settings_content.title_bar.as_ref()?.show_user_menu.as_ref() }, write: |settings_content, value| { settings_content .title_bar .get_or_insert_default() - .show_user_picture = value; + .show_user_menu = value; }, }), metadata: None, files: USER, }), SettingsPageItem::SettingItem(SettingItem { - title: "Show Sign In", - description: "Show the sign in button in the titlebar.", + title: "Show User Picture", + description: "Show user picture in the titlebar.", field: Box::new(SettingField { - json_path: Some("title_bar.show_sign_in"), + json_path: Some("title_bar.show_user_picture"), pick: |settings_content| { - settings_content.title_bar.as_ref()?.show_sign_in.as_ref() + settings_content + .title_bar + .as_ref()? + .show_user_picture + .as_ref() }, write: |settings_content, value| { settings_content .title_bar .get_or_insert_default() - .show_sign_in = value; + .show_user_picture = value; }, }), metadata: None, diff --git a/crates/title_bar/src/title_bar.rs b/crates/title_bar/src/title_bar.rs index bd606e4a021eaad30b95322d785e23d694734c06..5bd47d02691c9a5c7fec968b5ea6e97265b956b2 100644 --- a/crates/title_bar/src/title_bar.rs +++ b/crates/title_bar/src/title_bar.rs @@ -202,9 +202,11 @@ impl Render for TitleBar { .children(self.render_connection_status(status, cx)) .when( user.is_none() && TitleBarSettings::get_global(cx).show_sign_in, - |el| el.child(self.render_sign_in_button(cx)), + |this| this.child(self.render_sign_in_button(cx)), ) - .child(self.render_app_menu_button(cx)) + .when(TitleBarSettings::get_global(cx).show_user_menu, |this| { + this.child(self.render_user_menu_button(cx)) + }) .into_any_element(), ); @@ -685,7 +687,7 @@ impl TitleBar { }) } - pub fn render_app_menu_button(&mut self, cx: &mut Context) -> impl Element { + pub fn render_user_menu_button(&mut self, cx: &mut Context) -> impl Element { let user_store = self.user_store.read(cx); let user = user_store.current_user(); diff --git a/crates/title_bar/src/title_bar_settings.rs b/crates/title_bar/src/title_bar_settings.rs index 29fae4d31eb33ac70a22c21010f09350847439c2..155b7b7bc797567927a70b12c677372cb92c9453 100644 --- a/crates/title_bar/src/title_bar_settings.rs +++ b/crates/title_bar/src/title_bar_settings.rs @@ -8,6 +8,7 @@ pub struct TitleBarSettings { pub show_branch_name: bool, pub show_project_items: bool, pub show_sign_in: bool, + pub show_user_menu: bool, pub show_menus: bool, } @@ -21,6 +22,7 @@ impl Settings for TitleBarSettings { show_branch_name: content.show_branch_name.unwrap(), show_project_items: content.show_project_items.unwrap(), show_sign_in: content.show_sign_in.unwrap(), + show_user_menu: content.show_user_menu.unwrap(), show_menus: content.show_menus.unwrap(), } } diff --git a/docs/src/configuring-zed.md b/docs/src/configuring-zed.md index 477885a4537580aaf562aa596c1a06cae1c65bc8..76c0b528fa106ae087297d3c9191ee70620116ba 100644 --- a/docs/src/configuring-zed.md +++ b/docs/src/configuring-zed.md @@ -4309,6 +4309,7 @@ Run the {#action theme_selector::Toggle} action in the command palette to see a "show_project_items": true, "show_onboarding_banner": true, "show_user_picture": true, + "show_user_menu": true, "show_sign_in": true, "show_menus": false } @@ -4321,6 +4322,7 @@ Run the {#action theme_selector::Toggle} action in the command palette to see a - `show_project_items`: Whether to show the project host and name in the titlebar - `show_onboarding_banner`: Whether to show onboarding banners in the titlebar - `show_user_picture`: Whether to show user picture in the titlebar +- `show_user_menu`: Whether to show the user menu button in the titlebar (the one that displays your avatar by default and contains options like Settings, Keymap, Themes, etc.) - `show_sign_in`: Whether to show the sign in button in the titlebar - `show_menus`: Whether to show the menus in the titlebar diff --git a/docs/src/visual-customization.md b/docs/src/visual-customization.md index e5185719279dde488c40573d94fd842c06860f4d..234776b1d3223a4b8634b42df1973a27c736616c 100644 --- a/docs/src/visual-customization.md +++ b/docs/src/visual-customization.md @@ -118,6 +118,7 @@ To disable this behavior use: "show_project_items": true, // Show/hide project host and name "show_onboarding_banner": true, // Show/hide onboarding banners "show_user_picture": true, // Show/hide user avatar + "show_user_menu": true, // Show/hide app user button "show_sign_in": true, // Show/hide sign-in button "show_menus": false // Show/hide menus }, From 5fe7fd97bd00e8273e1e03bdc37952c82fc0927c Mon Sep 17 00:00:00 2001 From: Lennart Date: Mon, 15 Dec 2025 13:56:07 +0100 Subject: [PATCH 288/621] editor: Fix block cursor offset when selecting text (#42837) Vim visual mode and Helix selection mode both require the cursor to be on the last character of the selection. Until now, this was implemented by offsetting the cursor one character to the left whenever a block cursor is used. (Since the visual modes use a block cursor.) However, this oversees the problem that **some users might want to use the block cursor without being in visual mode**. Meaning that the cursor is offset by one character to the left even though Vim/Helix mode isn't even activated. Since the Vim mode implementation is separate from the `editor` crate the solution is not as straightforward as just checking the current vim mode. Therefore this PR introduces a new `Editor` struct field called `cursor_offset_on_selection`. This field replaces the previous check condition and is set to `true` whenever the Vim mode is changed to a visual mode, and `false` otherwise. Closes #36677 and #20121 Release Notes: - Fixes block and hollow cursor being offset when selecting text --------- Co-authored-by: dino --- crates/editor/src/editor.rs | 8 ++++++++ crates/editor/src/element.rs | 17 +++++++++++------ crates/vim/src/vim.rs | 1 + 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 29be039cdd182d1d45b0f3189e676d293486089f..5149c01ebeb5e52c4eb093de0c1d10690b2a7035 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -1107,6 +1107,9 @@ pub struct Editor { pending_rename: Option, searchable: bool, cursor_shape: CursorShape, + /// Whether the cursor is offset one character to the left when something is + /// selected (needed for vim visual mode) + cursor_offset_on_selection: bool, current_line_highlight: Option, pub collapse_matches: bool, autoindent_mode: Option, @@ -2281,6 +2284,7 @@ impl Editor { cursor_shape: EditorSettings::get_global(cx) .cursor_shape .unwrap_or_default(), + cursor_offset_on_selection: false, current_line_highlight: None, autoindent_mode: Some(AutoindentMode::EachLine), collapse_matches: false, @@ -3095,6 +3099,10 @@ impl Editor { self.cursor_shape } + pub fn set_cursor_offset_on_selection(&mut self, set_cursor_offset_on_selection: bool) { + self.cursor_offset_on_selection = set_cursor_offset_on_selection; + } + pub fn set_current_line_highlight( &mut self, current_line_highlight: Option, diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index 5a5b32e1755f5a026800f3af3c1cedaf6b11996d..ea619140dca36405f35521e316361942c72f644c 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -132,6 +132,7 @@ impl SelectionLayout { fn new( selection: Selection, line_mode: bool, + cursor_offset: bool, cursor_shape: CursorShape, map: &DisplaySnapshot, is_newest: bool, @@ -152,12 +153,9 @@ impl SelectionLayout { } // any vim visual mode (including line mode) - if (cursor_shape == CursorShape::Block || cursor_shape == CursorShape::Hollow) - && !range.is_empty() - && !selection.reversed - { + if cursor_offset && !range.is_empty() && !selection.reversed { if head.column() > 0 { - head = map.clip_point(DisplayPoint::new(head.row(), head.column() - 1), Bias::Left) + head = map.clip_point(DisplayPoint::new(head.row(), head.column() - 1), Bias::Left); } else if head.row().0 > 0 && head != map.max_point() { head = map.clip_point( DisplayPoint::new( @@ -1441,6 +1439,7 @@ impl EditorElement { let layout = SelectionLayout::new( selection, editor.selections.line_mode(), + editor.cursor_offset_on_selection, editor.cursor_shape, &snapshot.display_snapshot, is_newest, @@ -1487,6 +1486,7 @@ impl EditorElement { let drag_cursor_layout = SelectionLayout::new( drop_cursor.clone(), false, + editor.cursor_offset_on_selection, CursorShape::Bar, &snapshot.display_snapshot, false, @@ -1550,6 +1550,7 @@ impl EditorElement { .push(SelectionLayout::new( selection.selection, selection.line_mode, + editor.cursor_offset_on_selection, selection.cursor_shape, &snapshot.display_snapshot, false, @@ -1560,6 +1561,8 @@ impl EditorElement { selections.extend(remote_selections.into_values()); } else if !editor.is_focused(window) && editor.show_cursor_when_unfocused { + let cursor_offset_on_selection = editor.cursor_offset_on_selection; + let layouts = snapshot .buffer_snapshot() .selections_in_range(&(start_anchor..end_anchor), true) @@ -1567,6 +1570,7 @@ impl EditorElement { SelectionLayout::new( selection, line_mode, + cursor_offset_on_selection, cursor_shape, &snapshot.display_snapshot, false, @@ -3290,6 +3294,7 @@ impl EditorElement { SelectionLayout::new( newest, editor.selections.line_mode(), + editor.cursor_offset_on_selection, editor.cursor_shape, &snapshot.display_snapshot, true, @@ -11858,7 +11863,7 @@ mod tests { window .update(cx, |editor, window, cx| { - editor.cursor_shape = CursorShape::Block; + editor.cursor_offset_on_selection = true; editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| { s.select_ranges([ Point::new(0, 0)..Point::new(1, 0), diff --git a/crates/vim/src/vim.rs b/crates/vim/src/vim.rs index 9a9a1a001c32fcf8b22892ce5300d8d2aec3dd37..26fec968fb261fbb80a9f84211357623147ca0f4 100644 --- a/crates/vim/src/vim.rs +++ b/crates/vim/src/vim.rs @@ -1943,6 +1943,7 @@ impl Vim { editor.set_collapse_matches(collapse_matches); editor.set_input_enabled(vim.editor_input_enabled()); editor.set_autoindent(vim.should_autoindent()); + editor.set_cursor_offset_on_selection(vim.mode.is_visual()); editor .selections .set_line_mode(matches!(vim.mode, Mode::VisualLine)); From 63bfb6131f1c36031d891df93acd2521ac38eb02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yara=20=F0=9F=8F=B3=EF=B8=8F=E2=80=8D=E2=9A=A7=EF=B8=8F?= Date: Mon, 15 Dec 2025 14:18:06 +0100 Subject: [PATCH 289/621] scheduler: Fix background threads ending early (#44878) Release Notes: - N/A Co-authored-by: kate --- crates/gpui/src/queue.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/crates/gpui/src/queue.rs b/crates/gpui/src/queue.rs index 3a4ef912ffd5fb85b80384454f7afd84cecb1648..9e9da710977ee80df1853791918eebe5e7f01096 100644 --- a/crates/gpui/src/queue.rs +++ b/crates/gpui/src/queue.rs @@ -58,8 +58,7 @@ impl PriorityQueueState { return Err(crate::queue::RecvError); } - // parking_lot doesn't do spurious wakeups so an if is fine - if queues.is_empty() { + while queues.is_empty() { self.condvar.wait(&mut queues); } @@ -265,7 +264,7 @@ impl Iterator for Iter { type Item = T; fn next(&mut self) -> Option { - self.0.pop_inner(true).ok().flatten() + self.0.pop().ok() } } impl FusedIterator for Iter {} @@ -283,7 +282,7 @@ impl Iterator for TryIter { return None; } - let res = self.receiver.pop_inner(false); + let res = self.receiver.try_pop(); self.ended = res.is_err(); res.transpose() From a3ac59573799d10ec55f88426438a45af08a56fa Mon Sep 17 00:00:00 2001 From: Serophots <47299955+Serophots@users.noreply.github.com> Date: Mon, 15 Dec 2025 13:30:13 +0000 Subject: [PATCH 290/621] gpui: Make refining a `Style` properly refine the `TextStyle` (#42852) ## Motivating problem The gpui API currently has this counter intuitive behaviour ```rust div() .id("hallo") .cursor_pointer() .text_color(white()) .font_weight(FontWeight::SEMIBOLD) .text_size(px(20.0)) .child("hallo") .active(|this| this.text_color(red())) ``` By changing the text_color when the div is active, the current behaviour is to overwrite all of the text styling rather than do a proper refinement of the existing text styling leading to this odd result: The button being active inadvertently changes the font size. https://github.com/user-attachments/assets/1ff51169-0d76-4ee5-bbb0-004eb9ffdf2c ## Solution Previously refining a Style would not recursively refine the TextStyle inside of it, leading to this behaviour: ```rust let mut style = Style::default(); style.refine(&StyleRefinement::default().text_size(px(20.0))); style.refine(&StyleRefinement::default().font_weight(FontWeight::SEMIBOLD)); assert!(style.text_style().unwrap().font_size.is_none()); //assertion passes ``` (As best as I can tell) Style deliberately has `pub text: TextStyleRefinement` storing the `TextStyleRefinement` rather than the absolute `TextStyle` so that these refinements can be elsewhere used in cascading text styles down to element's children. But a consequence of that is that the refine macro was not properly recursively refining the `text` field as it ought to. I've modified the refine macro so that the `#[refineable]` attribute works with `TextStyleRefinement` as well as the usual `TextStyle`. (Perhaps a little bit haphazardly by simply checking whether the name ends in Refinement - there may be a better solution there). This PR resolves the motivating problem and triggers the assertion in the above code as you'd expect. I've compiled zed under these changes and all seems to be in order there. Release Notes: - N/A --------- Co-authored-by: Antonio Scandurra --- crates/acp_tools/src/acp_tools.rs | 4 +- crates/agent_ui/src/acp/thread_view.rs | 4 +- .../src/rate_prediction_modal.rs | 4 +- crates/gpui/src/style.rs | 18 +++ crates/gpui/src/styled.rs | 112 ++++++------------ crates/markdown/examples/markdown_as_child.rs | 4 +- crates/markdown/src/markdown.rs | 14 +-- .../src/derive_refineable.rs | 7 +- crates/refineable/src/refineable.rs | 2 +- crates/ui/src/components/keybinding_hint.rs | 4 +- crates/ui/src/components/label/label_like.rs | 4 +- 11 files changed, 74 insertions(+), 103 deletions(-) diff --git a/crates/acp_tools/src/acp_tools.rs b/crates/acp_tools/src/acp_tools.rs index 0905effce38d1bfd4fa18e1d00169d6c7ef6c2d7..b0d30367da0634dc82f8db96fc099e268aa4790e 100644 --- a/crates/acp_tools/src/acp_tools.rs +++ b/crates/acp_tools/src/acp_tools.rs @@ -371,13 +371,13 @@ impl AcpTools { syntax: cx.theme().syntax().clone(), code_block_overflow_x_scroll: true, code_block: StyleRefinement { - text: Some(TextStyleRefinement { + text: TextStyleRefinement { font_family: Some( theme_settings.buffer_font.family.clone(), ), font_size: Some((base_size * 0.8).into()), ..Default::default() - }), + }, ..Default::default() }, ..Default::default() diff --git a/crates/agent_ui/src/acp/thread_view.rs b/crates/agent_ui/src/acp/thread_view.rs index 63ea9eb279d26ff610c12f9785ef882be61f5e26..6cd2ec2fa3442bbf4961dffb0c4538ac9615d982 100644 --- a/crates/agent_ui/src/acp/thread_view.rs +++ b/crates/agent_ui/src/acp/thread_view.rs @@ -6053,13 +6053,13 @@ fn default_markdown_style( }, border_color: Some(colors.border_variant), background: Some(colors.editor_background.into()), - text: Some(TextStyleRefinement { + text: TextStyleRefinement { font_family: Some(theme_settings.buffer_font.family.clone()), font_fallbacks: theme_settings.buffer_font.fallbacks.clone(), font_features: Some(theme_settings.buffer_font.features.clone()), font_size: Some(buffer_font_size.into()), ..Default::default() - }), + }, ..Default::default() }, inline_code: TextStyleRefinement { diff --git a/crates/edit_prediction_ui/src/rate_prediction_modal.rs b/crates/edit_prediction_ui/src/rate_prediction_modal.rs index 54933fbf904f8fc7146dcce9a6bd3340884cc8bf..22e82bc445b394cc122e1cb1aa3604b45c25d1d1 100644 --- a/crates/edit_prediction_ui/src/rate_prediction_modal.rs +++ b/crates/edit_prediction_ui/src/rate_prediction_modal.rs @@ -510,13 +510,13 @@ impl RatePredictionsModal { base_text_style: window.text_style(), syntax: cx.theme().syntax().clone(), code_block: StyleRefinement { - text: Some(TextStyleRefinement { + text: TextStyleRefinement { font_family: Some( theme_settings.buffer_font.family.clone(), ), font_size: Some(buffer_font_size.into()), ..Default::default() - }), + }, padding: EdgesRefinement { top: Some(DefiniteLength::Absolute( AbsoluteLength::Pixels(px(8.)), diff --git a/crates/gpui/src/style.rs b/crates/gpui/src/style.rs index 42f8f25e47620fe673720055037b7f91f44165a2..446c3ad2a325681a39689577a261ed1ffdde6d5b 100644 --- a/crates/gpui/src/style.rs +++ b/crates/gpui/src/style.rs @@ -252,6 +252,7 @@ pub struct Style { pub box_shadow: Vec, /// The text style of this element + #[refineable] pub text: TextStyleRefinement, /// The mouse cursor style shown when the mouse pointer is over an element. @@ -1469,4 +1470,21 @@ mod tests { ] ); } + + #[perf] + fn test_text_style_refinement() { + let mut style = Style::default(); + style.refine(&StyleRefinement::default().text_size(px(20.0))); + style.refine(&StyleRefinement::default().font_weight(FontWeight::SEMIBOLD)); + + assert_eq!( + Some(AbsoluteLength::from(px(20.0))), + style.text_style().unwrap().font_size + ); + + assert_eq!( + Some(FontWeight::SEMIBOLD), + style.text_style().unwrap().font_weight + ); + } } diff --git a/crates/gpui/src/styled.rs b/crates/gpui/src/styled.rs index 752038c1ed63a1d0d5960bf0a74a1c2fdbc43392..e01649be481e27f89643db2ffb3a9ccd294b9b73 100644 --- a/crates/gpui/src/styled.rs +++ b/crates/gpui/src/styled.rs @@ -64,43 +64,33 @@ pub trait Styled: Sized { /// Sets the whitespace of the element to `normal`. /// [Docs](https://tailwindcss.com/docs/whitespace#normal) fn whitespace_normal(mut self) -> Self { - self.text_style() - .get_or_insert_with(Default::default) - .white_space = Some(WhiteSpace::Normal); + self.text_style().white_space = Some(WhiteSpace::Normal); self } /// Sets the whitespace of the element to `nowrap`. /// [Docs](https://tailwindcss.com/docs/whitespace#nowrap) fn whitespace_nowrap(mut self) -> Self { - self.text_style() - .get_or_insert_with(Default::default) - .white_space = Some(WhiteSpace::Nowrap); + self.text_style().white_space = Some(WhiteSpace::Nowrap); self } /// Sets the truncate overflowing text with an ellipsis (…) if needed. /// [Docs](https://tailwindcss.com/docs/text-overflow#ellipsis) fn text_ellipsis(mut self) -> Self { - self.text_style() - .get_or_insert_with(Default::default) - .text_overflow = Some(TextOverflow::Truncate(ELLIPSIS)); + self.text_style().text_overflow = Some(TextOverflow::Truncate(ELLIPSIS)); self } /// Sets the text overflow behavior of the element. fn text_overflow(mut self, overflow: TextOverflow) -> Self { - self.text_style() - .get_or_insert_with(Default::default) - .text_overflow = Some(overflow); + self.text_style().text_overflow = Some(overflow); self } /// Set the text alignment of the element. fn text_align(mut self, align: TextAlign) -> Self { - self.text_style() - .get_or_insert_with(Default::default) - .text_align = Some(align); + self.text_style().text_align = Some(align); self } @@ -128,7 +118,7 @@ pub trait Styled: Sized { /// Sets number of lines to show before truncating the text. /// [Docs](https://tailwindcss.com/docs/line-clamp) fn line_clamp(mut self, lines: usize) -> Self { - let mut text_style = self.text_style().get_or_insert_with(Default::default); + let mut text_style = self.text_style(); text_style.line_clamp = Some(lines); self.overflow_hidden() } @@ -396,7 +386,7 @@ pub trait Styled: Sized { } /// Returns a mutable reference to the text style that has been configured on this element. - fn text_style(&mut self) -> &mut Option { + fn text_style(&mut self) -> &mut TextStyleRefinement { let style: &mut StyleRefinement = self.style(); &mut style.text } @@ -405,7 +395,7 @@ pub trait Styled: Sized { /// /// This value cascades to its child elements. fn text_color(mut self, color: impl Into) -> Self { - self.text_style().get_or_insert_with(Default::default).color = Some(color.into()); + self.text_style().color = Some(color.into()); self } @@ -413,9 +403,7 @@ pub trait Styled: Sized { /// /// This value cascades to its child elements. fn font_weight(mut self, weight: FontWeight) -> Self { - self.text_style() - .get_or_insert_with(Default::default) - .font_weight = Some(weight); + self.text_style().font_weight = Some(weight); self } @@ -423,9 +411,7 @@ pub trait Styled: Sized { /// /// This value cascades to its child elements. fn text_bg(mut self, bg: impl Into) -> Self { - self.text_style() - .get_or_insert_with(Default::default) - .background_color = Some(bg.into()); + self.text_style().background_color = Some(bg.into()); self } @@ -433,97 +419,77 @@ pub trait Styled: Sized { /// /// This value cascades to its child elements. fn text_size(mut self, size: impl Into) -> Self { - self.text_style() - .get_or_insert_with(Default::default) - .font_size = Some(size.into()); + self.text_style().font_size = Some(size.into()); self } /// Sets the text size to 'extra small'. /// [Docs](https://tailwindcss.com/docs/font-size#setting-the-font-size) fn text_xs(mut self) -> Self { - self.text_style() - .get_or_insert_with(Default::default) - .font_size = Some(rems(0.75).into()); + self.text_style().font_size = Some(rems(0.75).into()); self } /// Sets the text size to 'small'. /// [Docs](https://tailwindcss.com/docs/font-size#setting-the-font-size) fn text_sm(mut self) -> Self { - self.text_style() - .get_or_insert_with(Default::default) - .font_size = Some(rems(0.875).into()); + self.text_style().font_size = Some(rems(0.875).into()); self } /// Sets the text size to 'base'. /// [Docs](https://tailwindcss.com/docs/font-size#setting-the-font-size) fn text_base(mut self) -> Self { - self.text_style() - .get_or_insert_with(Default::default) - .font_size = Some(rems(1.0).into()); + self.text_style().font_size = Some(rems(1.0).into()); self } /// Sets the text size to 'large'. /// [Docs](https://tailwindcss.com/docs/font-size#setting-the-font-size) fn text_lg(mut self) -> Self { - self.text_style() - .get_or_insert_with(Default::default) - .font_size = Some(rems(1.125).into()); + self.text_style().font_size = Some(rems(1.125).into()); self } /// Sets the text size to 'extra large'. /// [Docs](https://tailwindcss.com/docs/font-size#setting-the-font-size) fn text_xl(mut self) -> Self { - self.text_style() - .get_or_insert_with(Default::default) - .font_size = Some(rems(1.25).into()); + self.text_style().font_size = Some(rems(1.25).into()); self } /// Sets the text size to 'extra extra large'. /// [Docs](https://tailwindcss.com/docs/font-size#setting-the-font-size) fn text_2xl(mut self) -> Self { - self.text_style() - .get_or_insert_with(Default::default) - .font_size = Some(rems(1.5).into()); + self.text_style().font_size = Some(rems(1.5).into()); self } /// Sets the text size to 'extra extra extra large'. /// [Docs](https://tailwindcss.com/docs/font-size#setting-the-font-size) fn text_3xl(mut self) -> Self { - self.text_style() - .get_or_insert_with(Default::default) - .font_size = Some(rems(1.875).into()); + self.text_style().font_size = Some(rems(1.875).into()); self } /// Sets the font style of the element to italic. /// [Docs](https://tailwindcss.com/docs/font-style#italicizing-text) fn italic(mut self) -> Self { - self.text_style() - .get_or_insert_with(Default::default) - .font_style = Some(FontStyle::Italic); + self.text_style().font_style = Some(FontStyle::Italic); self } /// Sets the font style of the element to normal (not italic). /// [Docs](https://tailwindcss.com/docs/font-style#displaying-text-normally) fn not_italic(mut self) -> Self { - self.text_style() - .get_or_insert_with(Default::default) - .font_style = Some(FontStyle::Normal); + self.text_style().font_style = Some(FontStyle::Normal); self } /// Sets the text decoration to underline. /// [Docs](https://tailwindcss.com/docs/text-decoration-line#underling-text) fn underline(mut self) -> Self { - let style = self.text_style().get_or_insert_with(Default::default); + let style = self.text_style(); style.underline = Some(UnderlineStyle { thickness: px(1.), ..Default::default() @@ -534,7 +500,7 @@ pub trait Styled: Sized { /// Sets the decoration of the text to have a line through it. /// [Docs](https://tailwindcss.com/docs/text-decoration-line#adding-a-line-through-text) fn line_through(mut self) -> Self { - let style = self.text_style().get_or_insert_with(Default::default); + let style = self.text_style(); style.strikethrough = Some(StrikethroughStyle { thickness: px(1.), ..Default::default() @@ -546,15 +512,13 @@ pub trait Styled: Sized { /// /// This value cascades to its child elements. fn text_decoration_none(mut self) -> Self { - self.text_style() - .get_or_insert_with(Default::default) - .underline = None; + self.text_style().underline = None; self } /// Sets the color for the underline on this element fn text_decoration_color(mut self, color: impl Into) -> Self { - let style = self.text_style().get_or_insert_with(Default::default); + let style = self.text_style(); let underline = style.underline.get_or_insert_with(Default::default); underline.color = Some(color.into()); self @@ -563,7 +527,7 @@ pub trait Styled: Sized { /// Sets the text decoration style to a solid line. /// [Docs](https://tailwindcss.com/docs/text-decoration-style) fn text_decoration_solid(mut self) -> Self { - let style = self.text_style().get_or_insert_with(Default::default); + let style = self.text_style(); let underline = style.underline.get_or_insert_with(Default::default); underline.wavy = false; self @@ -572,7 +536,7 @@ pub trait Styled: Sized { /// Sets the text decoration style to a wavy line. /// [Docs](https://tailwindcss.com/docs/text-decoration-style) fn text_decoration_wavy(mut self) -> Self { - let style = self.text_style().get_or_insert_with(Default::default); + let style = self.text_style(); let underline = style.underline.get_or_insert_with(Default::default); underline.wavy = true; self @@ -581,7 +545,7 @@ pub trait Styled: Sized { /// Sets the text decoration to be 0px thick. /// [Docs](https://tailwindcss.com/docs/text-decoration-thickness) fn text_decoration_0(mut self) -> Self { - let style = self.text_style().get_or_insert_with(Default::default); + let style = self.text_style(); let underline = style.underline.get_or_insert_with(Default::default); underline.thickness = px(0.); self @@ -590,7 +554,7 @@ pub trait Styled: Sized { /// Sets the text decoration to be 1px thick. /// [Docs](https://tailwindcss.com/docs/text-decoration-thickness) fn text_decoration_1(mut self) -> Self { - let style = self.text_style().get_or_insert_with(Default::default); + let style = self.text_style(); let underline = style.underline.get_or_insert_with(Default::default); underline.thickness = px(1.); self @@ -599,7 +563,7 @@ pub trait Styled: Sized { /// Sets the text decoration to be 2px thick. /// [Docs](https://tailwindcss.com/docs/text-decoration-thickness) fn text_decoration_2(mut self) -> Self { - let style = self.text_style().get_or_insert_with(Default::default); + let style = self.text_style(); let underline = style.underline.get_or_insert_with(Default::default); underline.thickness = px(2.); self @@ -608,7 +572,7 @@ pub trait Styled: Sized { /// Sets the text decoration to be 4px thick. /// [Docs](https://tailwindcss.com/docs/text-decoration-thickness) fn text_decoration_4(mut self) -> Self { - let style = self.text_style().get_or_insert_with(Default::default); + let style = self.text_style(); let underline = style.underline.get_or_insert_with(Default::default); underline.thickness = px(4.); self @@ -617,7 +581,7 @@ pub trait Styled: Sized { /// Sets the text decoration to be 8px thick. /// [Docs](https://tailwindcss.com/docs/text-decoration-thickness) fn text_decoration_8(mut self) -> Self { - let style = self.text_style().get_or_insert_with(Default::default); + let style = self.text_style(); let underline = style.underline.get_or_insert_with(Default::default); underline.thickness = px(8.); self @@ -625,17 +589,13 @@ pub trait Styled: Sized { /// Sets the font family of this element and its children. fn font_family(mut self, family_name: impl Into) -> Self { - self.text_style() - .get_or_insert_with(Default::default) - .font_family = Some(family_name.into()); + self.text_style().font_family = Some(family_name.into()); self } /// Sets the font features of this element and its children. fn font_features(mut self, features: FontFeatures) -> Self { - self.text_style() - .get_or_insert_with(Default::default) - .font_features = Some(features); + self.text_style().font_features = Some(features); self } @@ -649,7 +609,7 @@ pub trait Styled: Sized { style, } = font; - let text_style = self.text_style().get_or_insert_with(Default::default); + let text_style = self.text_style(); text_style.font_family = Some(family); text_style.font_features = Some(features); text_style.font_weight = Some(weight); @@ -661,9 +621,7 @@ pub trait Styled: Sized { /// Sets the line height of this element and its children. fn line_height(mut self, line_height: impl Into) -> Self { - self.text_style() - .get_or_insert_with(Default::default) - .line_height = Some(line_height.into()); + self.text_style().line_height = Some(line_height.into()); self } diff --git a/crates/markdown/examples/markdown_as_child.rs b/crates/markdown/examples/markdown_as_child.rs index 6affa243ae5cc5f4cac1dc7fea0af9b9cc183aa6..775e2a141a849636512264dda2628e28254c8e2b 100644 --- a/crates/markdown/examples/markdown_as_child.rs +++ b/crates/markdown/examples/markdown_as_child.rs @@ -54,11 +54,11 @@ impl Render for HelloWorld { ..Default::default() }, code_block: StyleRefinement { - text: Some(gpui::TextStyleRefinement { + text: gpui::TextStyleRefinement { font_family: Some("Zed Mono".into()), background_color: Some(cx.theme().colors().editor_background), ..Default::default() - }), + }, margin: gpui::EdgesRefinement { top: Some(Length::Definite(rems(4.).into())), left: Some(Length::Definite(rems(4.).into())), diff --git a/crates/markdown/src/markdown.rs b/crates/markdown/src/markdown.rs index 2e9103787bf2705732e1dad2276ebbdb21c5c2bc..d6ba3babecf3b6b43155780e569bdc4515762d40 100644 --- a/crates/markdown/src/markdown.rs +++ b/crates/markdown/src/markdown.rs @@ -838,8 +838,7 @@ impl Element for MarkdownElement { heading.style().refine(&self.style.heading); - let text_style = - self.style.heading.text_style().clone().unwrap_or_default(); + let text_style = self.style.heading.text_style().clone(); builder.push_text_style(text_style); builder.push_div(heading, range, markdown_end); @@ -933,10 +932,7 @@ impl Element for MarkdownElement { } }); - if let Some(code_block_text_style) = &self.style.code_block.text - { - builder.push_text_style(code_block_text_style.to_owned()); - } + builder.push_text_style(self.style.code_block.text.to_owned()); builder.push_code_block(language); builder.push_div(code_block, range, markdown_end); } @@ -1091,9 +1087,7 @@ impl Element for MarkdownElement { builder.pop_div(); builder.pop_code_block(); - if self.style.code_block.text.is_some() { - builder.pop_text_style(); - } + builder.pop_text_style(); if let CodeBlockRenderer::Default { copy_button: true, .. @@ -1346,7 +1340,7 @@ fn apply_heading_style( }; if let Some(style) = style_opt { - heading.style().text = Some(style.clone()); + heading.style().text = style.clone(); } } diff --git a/crates/refineable/derive_refineable/src/derive_refineable.rs b/crates/refineable/derive_refineable/src/derive_refineable.rs index ddf3855a4dc5ae6917309ced57391bd244f1b465..c7c8a91ad9b05d054a94c8ca7f55a54c75150d81 100644 --- a/crates/refineable/derive_refineable/src/derive_refineable.rs +++ b/crates/refineable/derive_refineable/src/derive_refineable.rs @@ -528,7 +528,12 @@ fn get_wrapper_type(field: &Field, ty: &Type) -> syn::Type { } else { panic!("Expected struct type for a refineable field"); }; - let refinement_struct_name = format_ident!("{}Refinement", struct_name); + + let refinement_struct_name = if struct_name.to_string().ends_with("Refinement") { + format_ident!("{}", struct_name) + } else { + format_ident!("{}Refinement", struct_name) + }; let generics = if let Type::Path(tp) = ty { &tp.path.segments.last().unwrap().arguments } else { diff --git a/crates/refineable/src/refineable.rs b/crates/refineable/src/refineable.rs index d2a7c3d3f2148ae174be10121dc23b4dbfc5a650..b2305d4b5a7c1e5e45287394a49a258d98767c66 100644 --- a/crates/refineable/src/refineable.rs +++ b/crates/refineable/src/refineable.rs @@ -13,7 +13,7 @@ pub use derive_refineable::Refineable; /// wrapped appropriately: /// /// - **Refineable fields** (marked with `#[refineable]`): Become the corresponding refinement type -/// (e.g., `Bar` becomes `BarRefinement`) +/// (e.g., `Bar` becomes `BarRefinement`, or `BarRefinement` remains `BarRefinement`) /// - **Optional fields** (`Option`): Remain as `Option` /// - **Regular fields**: Become `Option` /// diff --git a/crates/ui/src/components/keybinding_hint.rs b/crates/ui/src/components/keybinding_hint.rs index c998e29f0ed6f5bccab976b11080320d4d65a7dd..7c19953ca43c907070829f7140f97a4fde495b57 100644 --- a/crates/ui/src/components/keybinding_hint.rs +++ b/crates/ui/src/components/keybinding_hint.rs @@ -234,9 +234,7 @@ impl RenderOnce for KeybindingHint { let mut base = h_flex(); - base.text_style() - .get_or_insert_with(Default::default) - .font_style = Some(FontStyle::Italic); + base.text_style().font_style = Some(FontStyle::Italic); base.gap_1() .font_buffer(cx) diff --git a/crates/ui/src/components/label/label_like.rs b/crates/ui/src/components/label/label_like.rs index e51d65c3b6c8ecb38ba26a1926c3bfdbb988a1f8..31fb7bfd88f1343ac6145c86f228bdcbd6a22e10 100644 --- a/crates/ui/src/components/label/label_like.rs +++ b/crates/ui/src/components/label/label_like.rs @@ -223,9 +223,7 @@ impl RenderOnce for LabelLike { }) .when(self.italic, |this| this.italic()) .when(self.underline, |mut this| { - this.text_style() - .get_or_insert_with(Default::default) - .underline = Some(UnderlineStyle { + this.text_style().underline = Some(UnderlineStyle { thickness: px(1.), color: Some(cx.theme().colors().text_muted.opacity(0.4)), wavy: false, From 3bf57dc7790b359d4c49f5639d0bb7b80eed4b17 Mon Sep 17 00:00:00 2001 From: Finn Evers Date: Mon, 15 Dec 2025 14:37:05 +0100 Subject: [PATCH 291/621] Revert "extension_api: Add `digest` to `GithubReleaseAsset`" (#44880) Reverts zed-industries/zed#44399 --- crates/extension_api/wit/since_v0.8.0/github.wit | 2 -- crates/extension_host/src/wasm_host/wit/since_v0_8_0.rs | 1 - crates/project/src/agent_server_store.rs | 6 +++--- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/crates/extension_api/wit/since_v0.8.0/github.wit b/crates/extension_api/wit/since_v0.8.0/github.wit index 6d7e5d952ae921925459f475bceb74d6c384d8be..21cd5d48056af08441d3bb5aa8547edd97a874d7 100644 --- a/crates/extension_api/wit/since_v0.8.0/github.wit +++ b/crates/extension_api/wit/since_v0.8.0/github.wit @@ -13,8 +13,6 @@ interface github { name: string, /// The download URL for the asset. download-url: string, - /// The SHA-256 of the release asset if provided by the GitHub API. - digest: option, } /// The options used to filter down GitHub releases. diff --git a/crates/extension_host/src/wasm_host/wit/since_v0_8_0.rs b/crates/extension_host/src/wasm_host/wit/since_v0_8_0.rs index b32ab97983642d68aba041ee3afb902a0c5d2455..a2776f9f3b5b055d00787fb59c9bbca582352b1f 100644 --- a/crates/extension_host/src/wasm_host/wit/since_v0_8_0.rs +++ b/crates/extension_host/src/wasm_host/wit/since_v0_8_0.rs @@ -783,7 +783,6 @@ impl From<::http_client::github::GithubReleaseAsset> for github::GithubReleaseAs Self { name: value.name, download_url: value.browser_download_url, - digest: value.digest, } } } diff --git a/crates/project/src/agent_server_store.rs b/crates/project/src/agent_server_store.rs index 62937476b8eea4b30f02637b3501ea2b56db81a1..a2cc57beae9702e4d5b495a135e7c357c638c17a 100644 --- a/crates/project/src/agent_server_store.rs +++ b/crates/project/src/agent_server_store.rs @@ -1495,7 +1495,7 @@ impl ExternalAgentServer for LocalCodex { let digest = asset .digest .as_deref() - .map(|d| d.strip_prefix("sha256:").unwrap_or(d)); + .and_then(|d| d.strip_prefix("sha256:").or(Some(d))); match ::http_client::github_download::download_server_binary( &*http, &asset.browser_download_url, @@ -1727,10 +1727,10 @@ impl ExternalAgentServer for LocalExtensionArchiveAgent { release.assets.iter().find(|a| a.name == filename) { // Strip "sha256:" prefix if present - asset.digest.as_ref().map(|d| { + asset.digest.as_ref().and_then(|d| { d.strip_prefix("sha256:") .map(|s| s.to_string()) - .unwrap_or_else(|| d.clone()) + .or_else(|| Some(d.clone())) }) } else { None From 7889aaf3fb74bee4cab6f1ea1715eb08163e6afd Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Mon, 15 Dec 2025 14:44:01 +0100 Subject: [PATCH 292/621] lsp: Support on-type formatting request with newlines (#44882) We called out to `request_on_type_formatting` only in handle_input function, but newlines are actually handled by editor::Newline action. Closes #12383 Release Notes: - Added support for on-type formatting with newlines. --- crates/editor/src/editor.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 5149c01ebeb5e52c4eb093de0c1d10690b2a7035..20a8c75be5dc4f966b0b1002e2979273435fd71c 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -5018,6 +5018,9 @@ impl Editor { this.change_selections(Default::default(), window, cx, |s| s.select(new_selections)); this.refresh_edit_prediction(true, false, window, cx); + if let Some(task) = this.trigger_on_type_formatting("\n".to_owned(), window, cx) { + task.detach_and_log_err(cx); + } }); } @@ -5082,6 +5085,9 @@ impl Editor { } } editor.edit(indent_edits, cx); + if let Some(format) = editor.trigger_on_type_formatting("\n".to_owned(), window, cx) { + format.detach_and_log_err(cx); + } }); } @@ -5144,6 +5150,9 @@ impl Editor { } } editor.edit(indent_edits, cx); + if let Some(format) = editor.trigger_on_type_formatting("\n".to_owned(), window, cx) { + format.detach_and_log_err(cx); + } }); } @@ -5454,7 +5463,7 @@ impl Editor { window: &mut Window, cx: &mut Context, ) -> Option>> { - if input.len() != 1 { + if input.chars().count() != 1 { return None; } From a6b7af3cbdff0ed8a06aa423428d68d78e75379e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yara=20=F0=9F=8F=B3=EF=B8=8F=E2=80=8D=E2=9A=A7=EF=B8=8F?= Date: Mon, 15 Dec 2025 14:58:38 +0100 Subject: [PATCH 293/621] Make LiveKit source use audio priority (#44881) Release Notes: - N/A --- .../src/livekit_client/playback/source.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/crates/livekit_client/src/livekit_client/playback/source.rs b/crates/livekit_client/src/livekit_client/playback/source.rs index cde4b19fda2e053346ad535e7c75b2abda60431a..a258c585285d8adafb1b0039400e6b6e787a509e 100644 --- a/crates/livekit_client/src/livekit_client/playback/source.rs +++ b/crates/livekit_client/src/livekit_client/playback/source.rs @@ -47,14 +47,17 @@ impl LiveKitStream { ); let (queue_input, queue_output) = rodio::queue::queue(true); // spawn rtc stream - let receiver_task = executor.spawn({ - async move { - while let Some(frame) = stream.next().await { - let samples = frame_to_samplesbuffer(frame); - queue_input.append(samples); + let receiver_task = executor.spawn_with_priority( + gpui::Priority::Realtime(gpui::RealtimePriority::Audio), + { + async move { + while let Some(frame) = stream.next().await { + let samples = frame_to_samplesbuffer(frame); + queue_input.append(samples); + } } - } - }); + }, + ); LiveKitStream { _receiver_task: receiver_task, From 07bf685feee40cc541b2764300815a600356188c Mon Sep 17 00:00:00 2001 From: Aaro Luomanen <71641519+aarol@users.noreply.github.com> Date: Mon, 15 Dec 2025 16:03:42 +0200 Subject: [PATCH 294/621] gpui: Support Force Touch go-to-definition on macOS (#40399) Closes #4644 Release Notes: - Adds `MousePressureEvent`, an event that is sent anytime the touchpad pressure changes, into `gpui`. MacOS only. - Triggers go-to-defintion on force clicks in the editor. This is my first contribution, let me know if I've missed something here. --------- Co-authored-by: Anthony Eid Co-authored-by: Antonio Scandurra --- crates/editor/src/editor.rs | 11 ++-- crates/editor/src/element.rs | 45 ++++++++++++++-- crates/editor/src/hover_links.rs | 75 +++++++++++++++++++++++++- crates/gpui/Cargo.toml | 4 ++ crates/gpui/examples/mouse_pressure.rs | 66 +++++++++++++++++++++++ crates/gpui/src/elements/div.rs | 72 +++++++++++++++++++++++-- crates/gpui/src/interactive.rs | 38 +++++++++++++ crates/gpui/src/platform/mac/events.rs | 25 ++++++++- crates/gpui/src/platform/mac/window.rs | 4 ++ crates/gpui/src/window.rs | 3 ++ 10 files changed, 328 insertions(+), 15 deletions(-) create mode 100644 crates/gpui/examples/mouse_pressure.rs diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 20a8c75be5dc4f966b0b1002e2979273435fd71c..afa62e5ff31436ef178a94dc0ff8bedfc2691e60 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -107,10 +107,11 @@ use gpui::{ AvailableSpace, Background, Bounds, ClickEvent, ClipboardEntry, ClipboardItem, Context, DispatchPhase, Edges, Entity, EntityInputHandler, EventEmitter, FocusHandle, FocusOutEvent, Focusable, FontId, FontWeight, Global, HighlightStyle, Hsla, KeyContext, Modifiers, - MouseButton, MouseDownEvent, MouseMoveEvent, PaintQuad, ParentElement, Pixels, Render, - ScrollHandle, SharedString, Size, Stateful, Styled, Subscription, Task, TextRun, TextStyle, - TextStyleRefinement, UTF16Selection, UnderlineStyle, UniformListScrollHandle, WeakEntity, - WeakFocusHandle, Window, div, point, prelude::*, pulsating_between, px, relative, size, + MouseButton, MouseDownEvent, MouseMoveEvent, PaintQuad, ParentElement, Pixels, PressureStage, + Render, ScrollHandle, SharedString, Size, Stateful, Styled, Subscription, Task, TextRun, + TextStyle, TextStyleRefinement, UTF16Selection, UnderlineStyle, UniformListScrollHandle, + WeakEntity, WeakFocusHandle, Window, div, point, prelude::*, pulsating_between, px, relative, + size, }; use hover_links::{HoverLink, HoveredLinkState, find_file}; use hover_popover::{HoverState, hide_hover}; @@ -1121,6 +1122,7 @@ pub struct Editor { remote_id: Option, pub hover_state: HoverState, pending_mouse_down: Option>>>, + prev_pressure_stage: Option, gutter_hovered: bool, hovered_link_state: Option, edit_prediction_provider: Option, @@ -2300,6 +2302,7 @@ impl Editor { remote_id: None, hover_state: HoverState::default(), pending_mouse_down: None, + prev_pressure_stage: None, hovered_link_state: None, edit_prediction_provider: None, active_edit_prediction: None, diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index ea619140dca36405f35521e316361942c72f644c..3b16fa1be173ab1a5edbc9bbaad20a3d6b1493e7 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -48,11 +48,11 @@ use gpui::{ DispatchPhase, Edges, Element, ElementInputHandler, Entity, Focusable as _, FontId, GlobalElementId, Hitbox, HitboxBehavior, Hsla, InteractiveElement, IntoElement, IsZero, KeybindingKeystroke, Length, Modifiers, ModifiersChangedEvent, MouseButton, MouseClickEvent, - MouseDownEvent, MouseMoveEvent, MouseUpEvent, PaintQuad, ParentElement, Pixels, ScrollDelta, - ScrollHandle, ScrollWheelEvent, ShapedLine, SharedString, Size, StatefulInteractiveElement, - Style, Styled, TextRun, TextStyleRefinement, WeakEntity, Window, anchored, deferred, div, fill, - linear_color_stop, linear_gradient, outline, point, px, quad, relative, size, solid_background, - transparent_black, + MouseDownEvent, MouseMoveEvent, MousePressureEvent, MouseUpEvent, PaintQuad, ParentElement, + Pixels, PressureStage, ScrollDelta, ScrollHandle, ScrollWheelEvent, ShapedLine, SharedString, + Size, StatefulInteractiveElement, Style, Styled, TextRun, TextStyleRefinement, WeakEntity, + Window, anchored, deferred, div, fill, linear_color_stop, linear_gradient, outline, point, px, + quad, relative, size, solid_background, transparent_black, }; use itertools::Itertools; use language::{IndentGuideSettings, language_settings::ShowWhitespaceSetting}; @@ -1035,6 +1035,28 @@ impl EditorElement { } } + fn pressure_click( + editor: &mut Editor, + event: &MousePressureEvent, + position_map: &PositionMap, + window: &mut Window, + cx: &mut Context, + ) { + let text_hitbox = &position_map.text_hitbox; + let force_click_possible = + matches!(editor.prev_pressure_stage, Some(PressureStage::Normal)) + && event.stage == PressureStage::Force; + + editor.prev_pressure_stage = Some(event.stage); + + if force_click_possible && text_hitbox.is_hovered(window) { + let point = position_map.point_for_position(event.position); + editor.handle_click_hovered_link(point, event.modifiers, window, cx); + editor.selection_drag_state = SelectionDragState::None; + cx.stop_propagation(); + } + } + fn mouse_dragged( editor: &mut Editor, event: &MouseMoveEvent, @@ -7769,6 +7791,19 @@ impl EditorElement { } }); + window.on_mouse_event({ + let position_map = layout.position_map.clone(); + let editor = self.editor.clone(); + + move |event: &MousePressureEvent, phase, window, cx| { + if phase == DispatchPhase::Bubble { + editor.update(cx, |editor, cx| { + Self::pressure_click(editor, &event, &position_map, window, cx); + }) + } + } + }); + window.on_mouse_event({ let position_map = layout.position_map.clone(); let editor = self.editor.clone(); diff --git a/crates/editor/src/hover_links.rs b/crates/editor/src/hover_links.rs index 9d0261f00f8f7258023b092d4f55d40ac8abcf40..ba361aa04dee3bfa3a819c8afb7061c238681b77 100644 --- a/crates/editor/src/hover_links.rs +++ b/crates/editor/src/hover_links.rs @@ -735,7 +735,7 @@ mod tests { test::editor_lsp_test_context::EditorLspTestContext, }; use futures::StreamExt; - use gpui::Modifiers; + use gpui::{Modifiers, MousePressureEvent, PressureStage}; use indoc::indoc; use lsp::request::{GotoDefinition, GotoTypeDefinition}; use multi_buffer::MultiBufferOffset; @@ -1706,4 +1706,77 @@ mod tests { cx.simulate_click(screen_coord, Modifiers::secondary_key()); cx.update_workspace(|workspace, _, cx| assert_eq!(workspace.items(cx).count(), 1)); } + + #[gpui::test] + async fn test_pressure_links(cx: &mut gpui::TestAppContext) { + init_test(cx, |_| {}); + + let mut cx = EditorLspTestContext::new_rust( + lsp::ServerCapabilities { + hover_provider: Some(lsp::HoverProviderCapability::Simple(true)), + definition_provider: Some(lsp::OneOf::Left(true)), + ..Default::default() + }, + cx, + ) + .await; + + cx.set_state(indoc! {" + fn ˇtest() { do_work(); } + fn do_work() { test(); } + "}); + + // Position the mouse over a symbol that has a definition + let hover_point = cx.pixel_position(indoc! {" + fn test() { do_wˇork(); } + fn do_work() { test(); } + "}); + let symbol_range = cx.lsp_range(indoc! {" + fn test() { «do_work»(); } + fn do_work() { test(); } + "}); + let target_range = cx.lsp_range(indoc! {" + fn test() { do_work(); } + fn «do_work»() { test(); } + "}); + + let mut requests = + cx.set_request_handler::(move |url, _, _| async move { + Ok(Some(lsp::GotoDefinitionResponse::Link(vec![ + lsp::LocationLink { + origin_selection_range: Some(symbol_range), + target_uri: url.clone(), + target_range, + target_selection_range: target_range, + }, + ]))) + }); + + cx.simulate_mouse_move(hover_point, None, Modifiers::none()); + + // First simulate Normal pressure to set up the previous stage + cx.simulate_event(MousePressureEvent { + pressure: 0.5, + stage: PressureStage::Normal, + position: hover_point, + modifiers: Modifiers::none(), + }); + cx.background_executor.run_until_parked(); + + // Now simulate Force pressure to trigger the force click and go-to definition + cx.simulate_event(MousePressureEvent { + pressure: 1.0, + stage: PressureStage::Force, + position: hover_point, + modifiers: Modifiers::none(), + }); + requests.next().await; + cx.background_executor.run_until_parked(); + + // Assert that we navigated to the definition + cx.assert_editor_state(indoc! {" + fn test() { do_work(); } + fn «do_workˇ»() { test(); } + "}); + } } diff --git a/crates/gpui/Cargo.toml b/crates/gpui/Cargo.toml index 8fc37978683357e53ed9f9c3cf587fcd704431e2..da7e660a0171f38b8dd61de1c9323773ded2589b 100644 --- a/crates/gpui/Cargo.toml +++ b/crates/gpui/Cargo.toml @@ -330,3 +330,7 @@ path = "examples/window_shadow.rs" [[example]] name = "grid_layout" path = "examples/grid_layout.rs" + +[[example]] +name = "mouse_pressure" +path = "examples/mouse_pressure.rs" diff --git a/crates/gpui/examples/mouse_pressure.rs b/crates/gpui/examples/mouse_pressure.rs new file mode 100644 index 0000000000000000000000000000000000000000..12790f988eedac3009ae619cadbc6f40c4af2e4b --- /dev/null +++ b/crates/gpui/examples/mouse_pressure.rs @@ -0,0 +1,66 @@ +use gpui::{ + App, Application, Bounds, Context, MousePressureEvent, PressureStage, Window, WindowBounds, + WindowOptions, div, prelude::*, px, rgb, size, +}; + +struct MousePressureExample { + pressure_stage: PressureStage, + pressure_amount: f32, +} + +impl Render for MousePressureExample { + fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { + div() + .flex() + .flex_col() + .gap_3() + .bg(rgb(0x505050)) + .size(px(500.0)) + .justify_center() + .items_center() + .shadow_lg() + .border_1() + .border_color(rgb(0x0000ff)) + .text_xl() + .text_color(rgb(0xffffff)) + .child(format!("Pressure stage: {:?}", &self.pressure_stage)) + .child(format!("Pressure amount: {:.2}", &self.pressure_amount)) + .on_mouse_pressure(cx.listener(Self::on_mouse_pressure)) + } +} + +impl MousePressureExample { + fn on_mouse_pressure( + &mut self, + pressure_event: &MousePressureEvent, + _window: &mut Window, + cx: &mut Context, + ) { + self.pressure_amount = pressure_event.pressure; + self.pressure_stage = pressure_event.stage; + + cx.notify(); + } +} + +fn main() { + Application::new().run(|cx: &mut App| { + let bounds = Bounds::centered(None, size(px(500.), px(500.0)), cx); + + cx.open_window( + WindowOptions { + window_bounds: Some(WindowBounds::Windowed(bounds)), + ..Default::default() + }, + |_, cx| { + cx.new(|_| MousePressureExample { + pressure_stage: PressureStage::Zero, + pressure_amount: 0.0, + }) + }, + ) + .unwrap(); + + cx.activate(true); + }); +} diff --git a/crates/gpui/src/elements/div.rs b/crates/gpui/src/elements/div.rs index c80acacce3d714c56dca0cdb65a4477b4c3b3b0e..374fd2c55a8e1cd5280d6ea9378a64c265a5c508 100644 --- a/crates/gpui/src/elements/div.rs +++ b/crates/gpui/src/elements/div.rs @@ -20,8 +20,8 @@ use crate::{ DispatchPhase, Display, Element, ElementId, Entity, FocusHandle, Global, GlobalElementId, Hitbox, HitboxBehavior, HitboxId, InspectorElementId, IntoElement, IsZero, KeyContext, KeyDownEvent, KeyUpEvent, KeyboardButton, KeyboardClickEvent, LayoutId, ModifiersChangedEvent, - MouseButton, MouseClickEvent, MouseDownEvent, MouseMoveEvent, MouseUpEvent, Overflow, - ParentElement, Pixels, Point, Render, ScrollWheelEvent, SharedString, Size, Style, + MouseButton, MouseClickEvent, MouseDownEvent, MouseMoveEvent, MousePressureEvent, MouseUpEvent, + Overflow, ParentElement, Pixels, Point, Render, ScrollWheelEvent, SharedString, Size, Style, StyleRefinement, Styled, Task, TooltipId, Visibility, Window, WindowControlArea, point, px, size, }; @@ -166,6 +166,38 @@ impl Interactivity { })); } + /// Bind the given callback to the mouse pressure event, during the bubble phase + /// the imperative API equivalent to [`InteractiveElement::on_mouse_pressure`]. + /// + /// See [`Context::listener`](crate::Context::listener) to get access to a view's state from this callback. + pub fn on_mouse_pressure( + &mut self, + listener: impl Fn(&MousePressureEvent, &mut Window, &mut App) + 'static, + ) { + self.mouse_pressure_listeners + .push(Box::new(move |event, phase, hitbox, window, cx| { + if phase == DispatchPhase::Bubble && hitbox.is_hovered(window) { + (listener)(event, window, cx) + } + })); + } + + /// Bind the given callback to the mouse pressure event, during the capture phase + /// the imperative API equivalent to [`InteractiveElement::on_mouse_pressure`]. + /// + /// See [`Context::listener`](crate::Context::listener) to get access to a view's state from this callback. + pub fn capture_mouse_pressure( + &mut self, + listener: impl Fn(&MousePressureEvent, &mut Window, &mut App) + 'static, + ) { + self.mouse_pressure_listeners + .push(Box::new(move |event, phase, hitbox, window, cx| { + if phase == DispatchPhase::Capture && hitbox.is_hovered(window) { + (listener)(event, window, cx) + } + })); + } + /// Bind the given callback to the mouse up event for the given button, during the bubble phase. /// The imperative API equivalent to [`InteractiveElement::on_mouse_up`]. /// @@ -769,6 +801,30 @@ pub trait InteractiveElement: Sized { self } + /// Bind the given callback to the mouse pressure event, during the bubble phase + /// the fluent API equivalent to [`Interactivity::on_mouse_pressure`] + /// + /// See [`Context::listener`](crate::Context::listener) to get access to a view's state from this callback. + fn on_mouse_pressure( + mut self, + listener: impl Fn(&MousePressureEvent, &mut Window, &mut App) + 'static, + ) -> Self { + self.interactivity().on_mouse_pressure(listener); + self + } + + /// Bind the given callback to the mouse pressure event, during the capture phase + /// the fluent API equivalent to [`Interactivity::on_mouse_pressure`] + /// + /// See [`Context::listener`](crate::Context::listener) to get access to a view's state from this callback. + fn capture_mouse_pressure( + mut self, + listener: impl Fn(&MousePressureEvent, &mut Window, &mut App) + 'static, + ) -> Self { + self.interactivity().capture_mouse_pressure(listener); + self + } + /// Bind the given callback to the mouse down event, on any button, during the capture phase, /// when the mouse is outside of the bounds of this element. /// The fluent API equivalent to [`Interactivity::on_mouse_down_out`]. @@ -1197,7 +1253,8 @@ pub(crate) type MouseDownListener = Box; pub(crate) type MouseUpListener = Box; - +pub(crate) type MousePressureListener = + Box; pub(crate) type MouseMoveListener = Box; @@ -1521,6 +1578,7 @@ pub struct Interactivity { pub(crate) group_drag_over_styles: Vec<(TypeId, GroupStyle)>, pub(crate) mouse_down_listeners: Vec, pub(crate) mouse_up_listeners: Vec, + pub(crate) mouse_pressure_listeners: Vec, pub(crate) mouse_move_listeners: Vec, pub(crate) scroll_wheel_listeners: Vec, pub(crate) key_down_listeners: Vec, @@ -1714,6 +1772,7 @@ impl Interactivity { || self.group_hover_style.is_some() || self.hover_listener.is_some() || !self.mouse_up_listeners.is_empty() + || !self.mouse_pressure_listeners.is_empty() || !self.mouse_down_listeners.is_empty() || !self.mouse_move_listeners.is_empty() || !self.click_listeners.is_empty() @@ -2064,6 +2123,13 @@ impl Interactivity { }) } + for listener in self.mouse_pressure_listeners.drain(..) { + let hitbox = hitbox.clone(); + window.on_mouse_event(move |event: &MousePressureEvent, phase, window, cx| { + listener(event, phase, &hitbox, window, cx); + }) + } + for listener in self.mouse_move_listeners.drain(..) { let hitbox = hitbox.clone(); window.on_mouse_event(move |event: &MouseMoveEvent, phase, window, cx| { diff --git a/crates/gpui/src/interactive.rs b/crates/gpui/src/interactive.rs index 03acf81addaad1ae9800ef476a2dc7d13e690cf7..6852b9596a3f74e1d533fc2a7e9a7b7eeab71cda 100644 --- a/crates/gpui/src/interactive.rs +++ b/crates/gpui/src/interactive.rs @@ -174,6 +174,40 @@ pub struct MouseClickEvent { pub up: MouseUpEvent, } +/// The stage of a pressure click event. +#[derive(Clone, Copy, Debug, Default, PartialEq)] +pub enum PressureStage { + /// No pressure. + #[default] + Zero, + /// Normal click pressure. + Normal, + /// High pressure, enough to trigger a force click. + Force, +} + +/// A mouse pressure event from the platform. Generated when a force-sensitive trackpad is pressed hard. +/// Currently only implemented for macOS trackpads. +#[derive(Debug, Clone, Default)] +pub struct MousePressureEvent { + /// Pressure of the current stage as a float between 0 and 1 + pub pressure: f32, + /// The pressure stage of the event. + pub stage: PressureStage, + /// The position of the mouse on the window. + pub position: Point, + /// The modifiers that were held down when the mouse pressure changed. + pub modifiers: Modifiers, +} + +impl Sealed for MousePressureEvent {} +impl InputEvent for MousePressureEvent { + fn to_platform_input(self) -> PlatformInput { + PlatformInput::MousePressure(self) + } +} +impl MouseEvent for MousePressureEvent {} + /// A click event that was generated by a keyboard button being pressed and released. #[derive(Clone, Debug, Default)] pub struct KeyboardClickEvent { @@ -571,6 +605,8 @@ pub enum PlatformInput { MouseDown(MouseDownEvent), /// The mouse was released. MouseUp(MouseUpEvent), + /// Mouse pressure. + MousePressure(MousePressureEvent), /// The mouse was moved. MouseMove(MouseMoveEvent), /// The mouse exited the window. @@ -590,6 +626,7 @@ impl PlatformInput { PlatformInput::MouseDown(event) => Some(event), PlatformInput::MouseUp(event) => Some(event), PlatformInput::MouseMove(event) => Some(event), + PlatformInput::MousePressure(event) => Some(event), PlatformInput::MouseExited(event) => Some(event), PlatformInput::ScrollWheel(event) => Some(event), PlatformInput::FileDrop(event) => Some(event), @@ -604,6 +641,7 @@ impl PlatformInput { PlatformInput::MouseDown(_) => None, PlatformInput::MouseUp(_) => None, PlatformInput::MouseMove(_) => None, + PlatformInput::MousePressure(_) => None, PlatformInput::MouseExited(_) => None, PlatformInput::ScrollWheel(_) => None, PlatformInput::FileDrop(_) => None, diff --git a/crates/gpui/src/platform/mac/events.rs b/crates/gpui/src/platform/mac/events.rs index acc392a5f3429f20931455ea06733376ea0f587a..7a12e8d3d7ccb2e8a2f7b32b81c24a29f650e6e2 100644 --- a/crates/gpui/src/platform/mac/events.rs +++ b/crates/gpui/src/platform/mac/events.rs @@ -1,7 +1,8 @@ use crate::{ Capslock, KeyDownEvent, KeyUpEvent, Keystroke, Modifiers, ModifiersChangedEvent, MouseButton, - MouseDownEvent, MouseExitEvent, MouseMoveEvent, MouseUpEvent, NavigationDirection, Pixels, - PlatformInput, ScrollDelta, ScrollWheelEvent, TouchPhase, + MouseDownEvent, MouseExitEvent, MouseMoveEvent, MousePressureEvent, MouseUpEvent, + NavigationDirection, Pixels, PlatformInput, PressureStage, ScrollDelta, ScrollWheelEvent, + TouchPhase, platform::mac::{ LMGetKbdType, NSStringExt, TISCopyCurrentKeyboardLayoutInputSource, TISGetInputSourceProperty, UCKeyTranslate, kTISPropertyUnicodeKeyLayoutData, @@ -187,6 +188,26 @@ impl PlatformInput { }) }) } + NSEventType::NSEventTypePressure => { + let stage = native_event.stage(); + let pressure = native_event.pressure(); + + window_height.map(|window_height| { + Self::MousePressure(MousePressureEvent { + stage: match stage { + 1 => PressureStage::Normal, + 2 => PressureStage::Force, + _ => PressureStage::Zero, + }, + pressure, + modifiers: read_modifiers(native_event), + position: point( + px(native_event.locationInWindow().x as f32), + window_height - px(native_event.locationInWindow().y as f32), + ), + }) + }) + } // Some mice (like Logitech MX Master) send navigation buttons as swipe events NSEventType::NSEventTypeSwipe => { let navigation_direction = match native_event.phase() { diff --git a/crates/gpui/src/platform/mac/window.rs b/crates/gpui/src/platform/mac/window.rs index 23752fc53edbc1062db19caf13c5c65fc282ca87..53207fb77d16f2e1956f6914889b29ae3ea7bb35 100644 --- a/crates/gpui/src/platform/mac/window.rs +++ b/crates/gpui/src/platform/mac/window.rs @@ -153,6 +153,10 @@ unsafe fn build_classes() { sel!(mouseMoved:), handle_view_event as extern "C" fn(&Object, Sel, id), ); + decl.add_method( + sel!(pressureChangeWithEvent:), + handle_view_event as extern "C" fn(&Object, Sel, id), + ); decl.add_method( sel!(mouseExited:), handle_view_event as extern "C" fn(&Object, Sel, id), diff --git a/crates/gpui/src/window.rs b/crates/gpui/src/window.rs index 54fe99c2634f5afa2e1f1e224e969c21d4c38e34..36e46f6961ae8a1e8581b3c01987f4641377d677 100644 --- a/crates/gpui/src/window.rs +++ b/crates/gpui/src/window.rs @@ -3705,6 +3705,9 @@ impl Window { self.modifiers = mouse_up.modifiers; PlatformInput::MouseUp(mouse_up) } + PlatformInput::MousePressure(mouse_pressure) => { + PlatformInput::MousePressure(mouse_pressure) + } PlatformInput::MouseExited(mouse_exited) => { self.modifiers = mouse_exited.modifiers; PlatformInput::MouseExited(mouse_exited) From 6eb198cabf825071d69ae4bde4de5e0dc487a1d2 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Mon, 15 Dec 2025 15:08:56 +0100 Subject: [PATCH 295/621] Revert "Add Doxygen injection into C and C++ comments" (#44883) Reverts zed-industries/zed#43581 Release notes: - Fixed comment injections not working with C and C++. --- crates/languages/src/c/injections.scm | 5 ++--- crates/languages/src/cpp/injections.scm | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/crates/languages/src/c/injections.scm b/crates/languages/src/c/injections.scm index d7df76b118672e77e3e2a6eacb320aade84c05fa..447897340cc735ed77099b20fd6fc8c52ac19ec8 100644 --- a/crates/languages/src/c/injections.scm +++ b/crates/languages/src/c/injections.scm @@ -1,7 +1,6 @@ ((comment) @injection.content - (#match? @injection.content "^(///|//!|/\\*\\*|/\\*!)(.*)") - (#set! injection.language "doxygen") - (#set! injection.include-children)) + (#set! injection.language "comment") +) (preproc_def value: (preproc_arg) @injection.content diff --git a/crates/languages/src/cpp/injections.scm b/crates/languages/src/cpp/injections.scm index a115a3bffdbe4c522b611f3786ffc95dcecc5cff..160770f3cc1d69f5cb3d1679c8a48726d8d437ed 100644 --- a/crates/languages/src/cpp/injections.scm +++ b/crates/languages/src/cpp/injections.scm @@ -1,7 +1,6 @@ ((comment) @injection.content - (#match? @injection.content "^(///|//!|/\\*\\*|/\\*!)(.*)") - (#set! injection.language "doxygen") - (#set! injection.include-children)) + (#set! injection.language "comment") +) (preproc_def value: (preproc_arg) @injection.content From f4c3a6c23690e0931fffbdca69a1ecada971d737 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Mon, 15 Dec 2025 15:19:33 +0100 Subject: [PATCH 296/621] wsl: Fix folder picker adding wrong slashes (#44886) Closes https://github.com/zed-industries/zed/issues/44508 Release Notes: - Fixed folder picker inserting wrong slashes when remoting from windows to wsl --- crates/file_finder/src/open_path_prompt.rs | 6 +- .../file_finder/src/open_path_prompt_tests.rs | 63 +--------- crates/project/src/project.rs | 8 ++ crates/recent_projects/src/remote_servers.rs | 6 +- .../src/toolchain_selector.rs | 114 +++++++++--------- 5 files changed, 72 insertions(+), 125 deletions(-) diff --git a/crates/file_finder/src/open_path_prompt.rs b/crates/file_finder/src/open_path_prompt.rs index 2ae0c47776acb5c58b7d0919aa7522fb64d923d0..f75d0ee99dc32bc1a1ab812328bba3d36fcb2953 100644 --- a/crates/file_finder/src/open_path_prompt.rs +++ b/crates/file_finder/src/open_path_prompt.rs @@ -44,8 +44,9 @@ impl OpenPathDelegate { tx: oneshot::Sender>>, lister: DirectoryLister, creating_path: bool, - path_style: PathStyle, + cx: &App, ) -> Self { + let path_style = lister.path_style(cx); Self { tx: Some(tx), lister, @@ -216,8 +217,7 @@ impl OpenPathPrompt { cx: &mut Context, ) { workspace.toggle_modal(window, cx, |window, cx| { - let delegate = - OpenPathDelegate::new(tx, lister.clone(), creating_path, PathStyle::local()); + let delegate = OpenPathDelegate::new(tx, lister.clone(), creating_path, cx); let picker = Picker::uniform_list(delegate, window, cx).width(rems(34.)); let query = lister.default_query(cx); picker.set_query(query, window, cx); diff --git a/crates/file_finder/src/open_path_prompt_tests.rs b/crates/file_finder/src/open_path_prompt_tests.rs index dea188034bfa7ae46f5b17c50424b40331fadb75..9af18c8a6bd82b389d4d18a997c3b5fe4a088730 100644 --- a/crates/file_finder/src/open_path_prompt_tests.rs +++ b/crates/file_finder/src/open_path_prompt_tests.rs @@ -5,7 +5,7 @@ use picker::{Picker, PickerDelegate}; use project::Project; use serde_json::json; use ui::rems; -use util::{path, paths::PathStyle}; +use util::path; use workspace::{AppState, Workspace}; use crate::OpenPathDelegate; @@ -37,7 +37,7 @@ async fn test_open_path_prompt(cx: &mut TestAppContext) { let project = Project::test(app_state.fs.clone(), [path!("/root").as_ref()], cx).await; - let (picker, cx) = build_open_path_prompt(project, false, PathStyle::local(), cx); + let (picker, cx) = build_open_path_prompt(project, false, cx); insert_query(path!("sadjaoislkdjasldj"), &picker, cx).await; assert_eq!(collect_match_candidates(&picker, cx), Vec::::new()); @@ -119,7 +119,7 @@ async fn test_open_path_prompt_completion(cx: &mut TestAppContext) { let project = Project::test(app_state.fs.clone(), [path!("/root").as_ref()], cx).await; - let (picker, cx) = build_open_path_prompt(project, false, PathStyle::local(), cx); + let (picker, cx) = build_open_path_prompt(project, false, cx); // Confirm completion for the query "/root", since it's a directory, it should add a trailing slash. let query = path!("/root"); @@ -227,7 +227,7 @@ async fn test_open_path_prompt_on_windows(cx: &mut TestAppContext) { let project = Project::test(app_state.fs.clone(), [path!("/root").as_ref()], cx).await; - let (picker, cx) = build_open_path_prompt(project, false, PathStyle::local(), cx); + let (picker, cx) = build_open_path_prompt(project, false, cx); // Support both forward and backward slashes. let query = "C:/root/"; @@ -295,56 +295,6 @@ async fn test_open_path_prompt_on_windows(cx: &mut TestAppContext) { ); } -#[gpui::test] -#[cfg_attr(not(target_os = "windows"), ignore)] -async fn test_open_path_prompt_on_windows_with_remote(cx: &mut TestAppContext) { - let app_state = init_test(cx); - app_state - .fs - .as_fake() - .insert_tree( - "/root", - json!({ - "a": "A", - "dir1": {}, - "dir2": {} - }), - ) - .await; - - let project = Project::test(app_state.fs.clone(), ["/root".as_ref()], cx).await; - - let (picker, cx) = build_open_path_prompt(project, false, PathStyle::Posix, cx); - - let query = "/root/"; - insert_query(query, &picker, cx).await; - assert_eq!( - collect_match_candidates(&picker, cx), - vec!["./", "a", "dir1", "dir2"] - ); - assert_eq!( - confirm_completion(query, 1, &picker, cx).unwrap(), - "/root/a" - ); - - // Confirm completion for the query "/root/d", selecting the second candidate "dir2", since it's a directory, it should add a trailing slash. - let query = "/root/d"; - insert_query(query, &picker, cx).await; - assert_eq!(collect_match_candidates(&picker, cx), vec!["dir1", "dir2"]); - assert_eq!( - confirm_completion(query, 1, &picker, cx).unwrap(), - "/root/dir2/" - ); - - let query = "/root/d"; - insert_query(query, &picker, cx).await; - assert_eq!(collect_match_candidates(&picker, cx), vec!["dir1", "dir2"]); - assert_eq!( - confirm_completion(query, 0, &picker, cx).unwrap(), - "/root/dir1/" - ); -} - #[gpui::test] async fn test_new_path_prompt(cx: &mut TestAppContext) { let app_state = init_test(cx); @@ -372,7 +322,7 @@ async fn test_new_path_prompt(cx: &mut TestAppContext) { let project = Project::test(app_state.fs.clone(), [path!("/root").as_ref()], cx).await; - let (picker, cx) = build_open_path_prompt(project, true, PathStyle::local(), cx); + let (picker, cx) = build_open_path_prompt(project, true, cx); insert_query(path!("/root"), &picker, cx).await; assert_eq!(collect_match_candidates(&picker, cx), vec!["root"]); @@ -406,16 +356,15 @@ fn init_test(cx: &mut TestAppContext) -> Arc { fn build_open_path_prompt( project: Entity, creating_path: bool, - path_style: PathStyle, cx: &mut TestAppContext, ) -> (Entity>, &mut VisualTestContext) { let (tx, _) = futures::channel::oneshot::channel(); let lister = project::DirectoryLister::Project(project.clone()); - let delegate = OpenPathDelegate::new(tx, lister.clone(), creating_path, path_style); let (workspace, cx) = cx.add_window_view(|window, cx| Workspace::test_new(project, window, cx)); ( workspace.update_in(cx, |_, window, cx| { + let delegate = OpenPathDelegate::new(tx, lister.clone(), creating_path, cx); cx.new(|cx| { let picker = Picker::uniform_list(delegate, window, cx) .width(rems(34.)) diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index ec44a60d71e4b0c1f10ad698f727357e60aa3b85..7e7c1ecb67d2f463cb5b728cbb2a7f1ea2b072e0 100644 --- a/crates/project/src/project.rs +++ b/crates/project/src/project.rs @@ -966,6 +966,14 @@ impl DirectoryLister { } } } + + pub fn path_style(&self, cx: &App) -> PathStyle { + match self { + Self::Local(project, ..) | Self::Project(project, ..) => { + project.read(cx).path_style(cx) + } + } + } } #[cfg(any(test, feature = "test-support"))] diff --git a/crates/recent_projects/src/remote_servers.rs b/crates/recent_projects/src/remote_servers.rs index 32a4ef1a81a06a8b5968f7941edb4ab8ea0a5111..1df3abbeaee41532abcf12f5939db050429c73da 100644 --- a/crates/recent_projects/src/remote_servers.rs +++ b/crates/recent_projects/src/remote_servers.rs @@ -217,14 +217,13 @@ impl ProjectPicker { connection: RemoteConnectionOptions, project: Entity, home_dir: RemotePathBuf, - path_style: PathStyle, workspace: WeakEntity, window: &mut Window, cx: &mut Context, ) -> Entity { let (tx, rx) = oneshot::channel(); let lister = project::DirectoryLister::Project(project.clone()); - let delegate = file_finder::OpenPathDelegate::new(tx, lister, false, path_style); + let delegate = file_finder::OpenPathDelegate::new(tx, lister, false, cx); let picker = cx.new(|cx| { let picker = Picker::uniform_list(delegate, window, cx) @@ -719,7 +718,6 @@ impl RemoteServerProjects { connection_options: remote::RemoteConnectionOptions, project: Entity, home_dir: RemotePathBuf, - path_style: PathStyle, window: &mut Window, cx: &mut Context, workspace: WeakEntity, @@ -732,7 +730,6 @@ impl RemoteServerProjects { connection_options, project, home_dir, - path_style, workspace, window, cx, @@ -1030,7 +1027,6 @@ impl RemoteServerProjects { connection_options, project, home_dir, - path_style, window, cx, weak, diff --git a/crates/toolchain_selector/src/toolchain_selector.rs b/crates/toolchain_selector/src/toolchain_selector.rs index 138f99066f0a80188837de49f6afc67d91d9eeb5..b58b2f8d699f59c15525c452543cf5bdf071ad2c 100644 --- a/crates/toolchain_selector/src/toolchain_selector.rs +++ b/crates/toolchain_selector/src/toolchain_selector.rs @@ -128,67 +128,61 @@ impl AddToolchainState { ) -> (OpenPathDelegate, oneshot::Receiver>>) { let (tx, rx) = oneshot::channel(); let weak = cx.weak_entity(); - let path_style = project.read(cx).path_style(cx); - let lister = - OpenPathDelegate::new(tx, DirectoryLister::Project(project), false, path_style) - .show_hidden() - .with_footer(Arc::new(move |_, cx| { - let error = weak - .read_with(cx, |this, _| { - if let AddState::Path { error, .. } = &this.state { - error.clone() - } else { - None + let lister = OpenPathDelegate::new(tx, DirectoryLister::Project(project), false, cx) + .show_hidden() + .with_footer(Arc::new(move |_, cx| { + let error = weak + .read_with(cx, |this, _| { + if let AddState::Path { error, .. } = &this.state { + error.clone() + } else { + None + } + }) + .ok() + .flatten(); + let is_loading = weak + .read_with(cx, |this, _| { + matches!( + this.state, + AddState::Path { + input_state: PathInputState::Resolving(_), + .. } - }) - .ok() - .flatten(); - let is_loading = weak - .read_with(cx, |this, _| { - matches!( - this.state, - AddState::Path { - input_state: PathInputState::Resolving(_), - .. - } - ) - }) - .unwrap_or_default(); - Some( - v_flex() - .child(Divider::horizontal()) - .child( - h_flex() - .p_1() - .justify_between() - .gap_2() - .child( - Label::new("Select Toolchain Path") - .color(Color::Muted) - .map(|this| { - if is_loading { - this.with_animation( - "select-toolchain-label", - Animation::new(Duration::from_secs(2)) - .repeat() - .with_easing(pulsating_between( - 0.4, 0.8, - )), - |label, delta| label.alpha(delta), - ) - .into_any() - } else { - this.into_any_element() - } - }), - ) - .when_some(error, |this, error| { - this.child(Label::new(error).color(Color::Error)) - }), - ) - .into_any(), - ) - })); + ) + }) + .unwrap_or_default(); + Some( + v_flex() + .child(Divider::horizontal()) + .child( + h_flex() + .p_1() + .justify_between() + .gap_2() + .child(Label::new("Select Toolchain Path").color(Color::Muted).map( + |this| { + if is_loading { + this.with_animation( + "select-toolchain-label", + Animation::new(Duration::from_secs(2)) + .repeat() + .with_easing(pulsating_between(0.4, 0.8)), + |label, delta| label.alpha(delta), + ) + .into_any() + } else { + this.into_any_element() + } + }, + )) + .when_some(error, |this, error| { + this.child(Label::new(error).color(Color::Error)) + }), + ) + .into_any(), + ) + })); (lister, rx) } From 158ebdc5803f9f69dfbfddcd216f04e5bc6001d9 Mon Sep 17 00:00:00 2001 From: William Whittaker Date: Mon, 15 Dec 2025 08:09:10 -0700 Subject: [PATCH 297/621] Allow external handles to be provided to gpui_tokio (#42795) This PR allows for a handle to an existing Tokio runtime to be passed to gpui_tokio's initialization function, which means that Tokio runtimes created externally can be used. Mikayla suggested that the function simply take the runtime from whatever context the initialization function is called from but I think there could reasonably be situations where that isn't the case and this shouldn't have a meaningful impact to code complexity. If you want to use the current context's runtime you can just do `gpui_tokio::init_from_handle(cx, Handle::current());`. This doesn't have an impact on the current users of the crate - the existing `init()` function is functionally unchanged. Release Notes: - N/A --- crates/gpui_tokio/src/gpui_tokio.rs | 47 +++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/crates/gpui_tokio/src/gpui_tokio.rs b/crates/gpui_tokio/src/gpui_tokio.rs index 61dcfc48efb1dfecc04c4a131ddc32691e01e255..9cfa1493af49ee95210edb9669a6ca89095f42cd 100644 --- a/crates/gpui_tokio/src/gpui_tokio.rs +++ b/crates/gpui_tokio/src/gpui_tokio.rs @@ -5,25 +5,48 @@ use util::defer; pub use tokio::task::JoinError; +/// Initializes the Tokio wrapper using a new Tokio runtime with 2 worker threads. +/// +/// If you need more threads (or access to the runtime outside of GPUI), you can create the runtime +/// yourself and pass a Handle to `init_from_handle`. pub fn init(cx: &mut App) { - cx.set_global(GlobalTokio::new()); + let runtime = tokio::runtime::Builder::new_multi_thread() + // Since we now have two executors, let's try to keep our footprint small + .worker_threads(2) + .enable_all() + .build() + .expect("Failed to initialize Tokio"); + + cx.set_global(GlobalTokio::new(RuntimeHolder::Owned(runtime))); +} + +/// Initializes the Tokio wrapper using a Tokio runtime handle. +pub fn init_from_handle(cx: &mut App, handle: tokio::runtime::Handle) { + cx.set_global(GlobalTokio::new(RuntimeHolder::Shared(handle))); +} + +enum RuntimeHolder { + Owned(tokio::runtime::Runtime), + Shared(tokio::runtime::Handle), +} + +impl RuntimeHolder { + pub fn handle(&self) -> &tokio::runtime::Handle { + match self { + RuntimeHolder::Owned(runtime) => runtime.handle(), + RuntimeHolder::Shared(handle) => handle, + } + } } struct GlobalTokio { - runtime: tokio::runtime::Runtime, + runtime: RuntimeHolder, } impl Global for GlobalTokio {} impl GlobalTokio { - fn new() -> Self { - let runtime = tokio::runtime::Builder::new_multi_thread() - // Since we now have two executors, let's try to keep our footprint small - .worker_threads(2) - .enable_all() - .build() - .expect("Failed to initialize Tokio"); - + fn new(runtime: RuntimeHolder) -> Self { Self { runtime } } } @@ -40,7 +63,7 @@ impl Tokio { R: Send + 'static, { cx.read_global(|tokio: &GlobalTokio, cx| { - let join_handle = tokio.runtime.spawn(f); + let join_handle = tokio.runtime.handle().spawn(f); let abort_handle = join_handle.abort_handle(); let cancel = defer(move || { abort_handle.abort(); @@ -62,7 +85,7 @@ impl Tokio { R: Send + 'static, { cx.read_global(|tokio: &GlobalTokio, cx| { - let join_handle = tokio.runtime.spawn(f); + let join_handle = tokio.runtime.handle().spawn(f); let abort_handle = join_handle.abort_handle(); let cancel = defer(move || { abort_handle.abort(); From b71ef540fc0289cb59cdf25fe9733b36ae71c8cf Mon Sep 17 00:00:00 2001 From: Ben Kunkle Date: Mon, 15 Dec 2025 07:09:52 -0800 Subject: [PATCH 298/621] Add trailing commas to all asset jsonc files following #43854 (#44891) Closes #ISSUE Post #43854, we are advertising trailing comma support for our asset `jsonc` files to the JSON LSP. This results in it adding trailing commas on format of these files. This PR batch updates the formatting for these files, so they are not spuriously added as part of other PRs that happen to modify these files Release Notes: - N/A *or* Added/Fixed/Improved ... --- assets/keymaps/default-linux.json | 426 +++++++++--------- assets/keymaps/default-macos.json | 438 +++++++++---------- assets/keymaps/default-windows.json | 424 +++++++++--------- assets/keymaps/initial.json | 6 +- assets/keymaps/linux/atom.json | 34 +- assets/keymaps/linux/cursor.json | 30 +- assets/keymaps/linux/emacs.json | 42 +- assets/keymaps/linux/jetbrains.json | 50 +-- assets/keymaps/linux/sublime_text.json | 26 +- assets/keymaps/macos/atom.json | 34 +- assets/keymaps/macos/cursor.json | 30 +- assets/keymaps/macos/emacs.json | 42 +- assets/keymaps/macos/jetbrains.json | 50 +-- assets/keymaps/macos/sublime_text.json | 26 +- assets/keymaps/macos/textmate.json | 32 +- assets/keymaps/storybook.json | 6 +- assets/settings/initial_debug_tasks.json | 8 +- assets/settings/initial_server_settings.json | 2 +- assets/settings/initial_tasks.json | 4 +- assets/settings/initial_user_settings.json | 4 +- 20 files changed, 857 insertions(+), 857 deletions(-) diff --git a/assets/keymaps/default-linux.json b/assets/keymaps/default-linux.json index 872544cdff0bc03bbafd6b711fa7adb2f5e2d008..342c4b0b7cb9608c13bed2899dd67b3ac0378db5 100644 --- a/assets/keymaps/default-linux.json +++ b/assets/keymaps/default-linux.json @@ -44,15 +44,15 @@ "f11": "zed::ToggleFullScreen", "ctrl-alt-z": "edit_prediction::RatePredictions", "ctrl-alt-shift-i": "edit_prediction::ToggleMenu", - "ctrl-alt-l": "lsp_tool::ToggleMenu" - } + "ctrl-alt-l": "lsp_tool::ToggleMenu", + }, }, { "context": "Picker || menu", "bindings": { "up": "menu::SelectPrevious", - "down": "menu::SelectNext" - } + "down": "menu::SelectNext", + }, }, { "context": "Editor", @@ -124,8 +124,8 @@ "shift-f10": "editor::OpenContextMenu", "ctrl-alt-shift-e": "editor::ToggleEditPrediction", "f9": "editor::ToggleBreakpoint", - "shift-f9": "editor::EditLogBreakpoint" - } + "shift-f9": "editor::EditLogBreakpoint", + }, }, { "context": "Editor && mode == full", @@ -144,44 +144,44 @@ "ctrl-alt-e": "editor::SelectEnclosingSymbol", "ctrl-shift-backspace": "editor::GoToPreviousChange", "ctrl-shift-alt-backspace": "editor::GoToNextChange", - "alt-enter": "editor::OpenSelectionsInMultibuffer" - } + "alt-enter": "editor::OpenSelectionsInMultibuffer", + }, }, { "context": "Editor && mode == full && edit_prediction", "bindings": { "alt-]": "editor::NextEditPrediction", - "alt-[": "editor::PreviousEditPrediction" - } + "alt-[": "editor::PreviousEditPrediction", + }, }, { "context": "Editor && !edit_prediction", "bindings": { - "alt-\\": "editor::ShowEditPrediction" - } + "alt-\\": "editor::ShowEditPrediction", + }, }, { "context": "Editor && mode == auto_height", "bindings": { "ctrl-enter": "editor::Newline", "shift-enter": "editor::Newline", - "ctrl-shift-enter": "editor::NewlineBelow" - } + "ctrl-shift-enter": "editor::NewlineBelow", + }, }, { "context": "Markdown", "bindings": { "copy": "markdown::Copy", "ctrl-insert": "markdown::Copy", - "ctrl-c": "markdown::Copy" - } + "ctrl-c": "markdown::Copy", + }, }, { "context": "Editor && jupyter && !ContextEditor", "bindings": { "ctrl-shift-enter": "repl::Run", - "ctrl-alt-enter": "repl::RunInPlace" - } + "ctrl-alt-enter": "repl::RunInPlace", + }, }, { "context": "Editor && !agent_diff", @@ -189,8 +189,8 @@ "ctrl-k ctrl-r": "git::Restore", "ctrl-alt-y": "git::ToggleStaged", "alt-y": "git::StageAndNext", - "alt-shift-y": "git::UnstageAndNext" - } + "alt-shift-y": "git::UnstageAndNext", + }, }, { "context": "Editor && editor_agent_diff", @@ -199,8 +199,8 @@ "ctrl-n": "agent::Reject", "ctrl-shift-y": "agent::KeepAll", "ctrl-shift-n": "agent::RejectAll", - "shift-ctrl-r": "agent::OpenAgentDiff" - } + "shift-ctrl-r": "agent::OpenAgentDiff", + }, }, { "context": "AgentDiff", @@ -208,8 +208,8 @@ "ctrl-y": "agent::Keep", "ctrl-n": "agent::Reject", "ctrl-shift-y": "agent::KeepAll", - "ctrl-shift-n": "agent::RejectAll" - } + "ctrl-shift-n": "agent::RejectAll", + }, }, { "context": "ContextEditor > Editor", @@ -225,8 +225,8 @@ "ctrl-k c": "assistant::CopyCode", "ctrl-g": "search::SelectNextMatch", "ctrl-shift-g": "search::SelectPreviousMatch", - "ctrl-k l": "agent::OpenRulesLibrary" - } + "ctrl-k l": "agent::OpenRulesLibrary", + }, }, { "context": "AgentPanel", @@ -250,37 +250,37 @@ "alt-enter": "agent::ContinueWithBurnMode", "ctrl-y": "agent::AllowOnce", "ctrl-alt-y": "agent::AllowAlways", - "ctrl-alt-z": "agent::RejectOnce" - } + "ctrl-alt-z": "agent::RejectOnce", + }, }, { "context": "AgentPanel > NavigationMenu", "bindings": { - "shift-backspace": "agent::DeleteRecentlyOpenThread" - } + "shift-backspace": "agent::DeleteRecentlyOpenThread", + }, }, { "context": "AgentPanel > Markdown", "bindings": { "copy": "markdown::CopyAsMarkdown", "ctrl-insert": "markdown::CopyAsMarkdown", - "ctrl-c": "markdown::CopyAsMarkdown" - } + "ctrl-c": "markdown::CopyAsMarkdown", + }, }, { "context": "AgentPanel && text_thread", "bindings": { "ctrl-n": "agent::NewTextThread", - "ctrl-alt-t": "agent::NewThread" - } + "ctrl-alt-t": "agent::NewThread", + }, }, { "context": "AgentPanel && acp_thread", "use_key_equivalents": true, "bindings": { "ctrl-n": "agent::NewExternalAgentThread", - "ctrl-alt-t": "agent::NewThread" - } + "ctrl-alt-t": "agent::NewThread", + }, }, { "context": "MessageEditor && !Picker > Editor && !use_modifier_to_send", @@ -290,8 +290,8 @@ "ctrl-i": "agent::ToggleProfileSelector", "shift-ctrl-r": "agent::OpenAgentDiff", "ctrl-shift-y": "agent::KeepAll", - "ctrl-shift-n": "agent::RejectAll" - } + "ctrl-shift-n": "agent::RejectAll", + }, }, { "context": "MessageEditor && !Picker > Editor && use_modifier_to_send", @@ -301,30 +301,30 @@ "ctrl-i": "agent::ToggleProfileSelector", "shift-ctrl-r": "agent::OpenAgentDiff", "ctrl-shift-y": "agent::KeepAll", - "ctrl-shift-n": "agent::RejectAll" - } + "ctrl-shift-n": "agent::RejectAll", + }, }, { "context": "EditMessageEditor > Editor", "bindings": { "escape": "menu::Cancel", "enter": "menu::Confirm", - "alt-enter": "editor::Newline" - } + "alt-enter": "editor::Newline", + }, }, { "context": "AgentFeedbackMessageEditor > Editor", "bindings": { "escape": "menu::Cancel", "enter": "menu::Confirm", - "alt-enter": "editor::Newline" - } + "alt-enter": "editor::Newline", + }, }, { "context": "AcpThread > ModeSelector", "bindings": { - "ctrl-enter": "menu::Confirm" - } + "ctrl-enter": "menu::Confirm", + }, }, { "context": "AcpThread > Editor && !use_modifier_to_send", @@ -333,8 +333,8 @@ "enter": "agent::Chat", "shift-ctrl-r": "agent::OpenAgentDiff", "ctrl-shift-y": "agent::KeepAll", - "ctrl-shift-n": "agent::RejectAll" - } + "ctrl-shift-n": "agent::RejectAll", + }, }, { "context": "AcpThread > Editor && use_modifier_to_send", @@ -344,14 +344,14 @@ "shift-ctrl-r": "agent::OpenAgentDiff", "ctrl-shift-y": "agent::KeepAll", "ctrl-shift-n": "agent::RejectAll", - "shift-tab": "agent::CycleModeSelector" - } + "shift-tab": "agent::CycleModeSelector", + }, }, { "context": "ThreadHistory", "bindings": { - "backspace": "agent::RemoveSelectedThread" - } + "backspace": "agent::RemoveSelectedThread", + }, }, { "context": "RulesLibrary", @@ -359,8 +359,8 @@ "new": "rules_library::NewRule", "ctrl-n": "rules_library::NewRule", "ctrl-shift-s": "rules_library::ToggleDefaultRule", - "ctrl-w": "workspace::CloseWindow" - } + "ctrl-w": "workspace::CloseWindow", + }, }, { "context": "BufferSearchBar", @@ -373,22 +373,22 @@ "find": "search::FocusSearch", "ctrl-f": "search::FocusSearch", "ctrl-h": "search::ToggleReplace", - "ctrl-l": "search::ToggleSelection" - } + "ctrl-l": "search::ToggleSelection", + }, }, { "context": "BufferSearchBar && in_replace > Editor", "bindings": { "enter": "search::ReplaceNext", - "ctrl-enter": "search::ReplaceAll" - } + "ctrl-enter": "search::ReplaceAll", + }, }, { "context": "BufferSearchBar && !in_replace > Editor", "bindings": { "up": "search::PreviousHistoryQuery", - "down": "search::NextHistoryQuery" - } + "down": "search::NextHistoryQuery", + }, }, { "context": "ProjectSearchBar", @@ -399,22 +399,22 @@ "ctrl-shift-f": "search::FocusSearch", "ctrl-shift-h": "search::ToggleReplace", "alt-ctrl-g": "search::ToggleRegex", - "alt-ctrl-x": "search::ToggleRegex" - } + "alt-ctrl-x": "search::ToggleRegex", + }, }, { "context": "ProjectSearchBar > Editor", "bindings": { "up": "search::PreviousHistoryQuery", - "down": "search::NextHistoryQuery" - } + "down": "search::NextHistoryQuery", + }, }, { "context": "ProjectSearchBar && in_replace > Editor", "bindings": { "enter": "search::ReplaceNext", - "ctrl-alt-enter": "search::ReplaceAll" - } + "ctrl-alt-enter": "search::ReplaceAll", + }, }, { "context": "ProjectSearchView", @@ -422,8 +422,8 @@ "escape": "project_search::ToggleFocus", "ctrl-shift-h": "search::ToggleReplace", "alt-ctrl-g": "search::ToggleRegex", - "alt-ctrl-x": "search::ToggleRegex" - } + "alt-ctrl-x": "search::ToggleRegex", + }, }, { "context": "Pane", @@ -472,8 +472,8 @@ "ctrl-alt-shift-r": "search::ToggleRegex", "ctrl-alt-shift-x": "search::ToggleRegex", "alt-r": "search::ToggleRegex", - "ctrl-k shift-enter": "pane::TogglePinTab" - } + "ctrl-k shift-enter": "pane::TogglePinTab", + }, }, // Bindings from VS Code { @@ -537,31 +537,31 @@ "ctrl-\\": "pane::SplitRight", "ctrl-alt-shift-c": "editor::DisplayCursorNames", "alt-.": "editor::GoToHunk", - "alt-,": "editor::GoToPreviousHunk" - } + "alt-,": "editor::GoToPreviousHunk", + }, }, { "context": "Editor && extension == md", "use_key_equivalents": true, "bindings": { "ctrl-k v": "markdown::OpenPreviewToTheSide", - "ctrl-shift-v": "markdown::OpenPreview" - } + "ctrl-shift-v": "markdown::OpenPreview", + }, }, { "context": "Editor && extension == svg", "use_key_equivalents": true, "bindings": { "ctrl-k v": "svg::OpenPreviewToTheSide", - "ctrl-shift-v": "svg::OpenPreview" - } + "ctrl-shift-v": "svg::OpenPreview", + }, }, { "context": "Editor && mode == full", "bindings": { "ctrl-shift-o": "outline::Toggle", - "ctrl-g": "go_to_line::Toggle" - } + "ctrl-g": "go_to_line::Toggle", + }, }, { "context": "Workspace", @@ -655,28 +655,28 @@ // "foo-bar": ["task::Spawn", { "task_tag": "MyTag" }], "f5": "debugger::Rerun", "ctrl-f4": "workspace::CloseActiveDock", - "ctrl-w": "workspace::CloseActiveDock" - } + "ctrl-w": "workspace::CloseActiveDock", + }, }, { "context": "Workspace && debugger_running", "bindings": { - "f5": "zed::NoAction" - } + "f5": "zed::NoAction", + }, }, { "context": "Workspace && debugger_stopped", "bindings": { - "f5": "debugger::Continue" - } + "f5": "debugger::Continue", + }, }, { "context": "ApplicationMenu", "bindings": { "f10": "menu::Cancel", "left": "app_menu::ActivateMenuLeft", - "right": "app_menu::ActivateMenuRight" - } + "right": "app_menu::ActivateMenuRight", + }, }, // Bindings from Sublime Text { @@ -694,8 +694,8 @@ "ctrl-alt-shift-left": "editor::SelectToPreviousSubwordStart", "ctrl-alt-shift-b": "editor::SelectToPreviousSubwordStart", "ctrl-alt-shift-right": "editor::SelectToNextSubwordEnd", - "ctrl-alt-shift-f": "editor::SelectToNextSubwordEnd" - } + "ctrl-alt-shift-f": "editor::SelectToNextSubwordEnd", + }, }, // Bindings from Atom { @@ -704,37 +704,37 @@ "ctrl-k up": "pane::SplitUp", "ctrl-k down": "pane::SplitDown", "ctrl-k left": "pane::SplitLeft", - "ctrl-k right": "pane::SplitRight" - } + "ctrl-k right": "pane::SplitRight", + }, }, // Bindings that should be unified with bindings for more general actions { "context": "Editor && renaming", "bindings": { - "enter": "editor::ConfirmRename" - } + "enter": "editor::ConfirmRename", + }, }, { "context": "Editor && showing_completions", "bindings": { "enter": "editor::ConfirmCompletion", "shift-enter": "editor::ConfirmCompletionReplace", - "tab": "editor::ComposeCompletion" - } + "tab": "editor::ComposeCompletion", + }, }, { "context": "Editor && in_snippet && has_next_tabstop && !showing_completions", "use_key_equivalents": true, "bindings": { - "tab": "editor::NextSnippetTabstop" - } + "tab": "editor::NextSnippetTabstop", + }, }, { "context": "Editor && in_snippet && has_previous_tabstop && !showing_completions", "use_key_equivalents": true, "bindings": { - "shift-tab": "editor::PreviousSnippetTabstop" - } + "shift-tab": "editor::PreviousSnippetTabstop", + }, }, // Bindings for accepting edit predictions // @@ -746,22 +746,22 @@ "alt-tab": "editor::AcceptEditPrediction", "alt-l": "editor::AcceptEditPrediction", "tab": "editor::AcceptEditPrediction", - "alt-right": "editor::AcceptPartialEditPrediction" - } + "alt-right": "editor::AcceptPartialEditPrediction", + }, }, { "context": "Editor && edit_prediction_conflict", "bindings": { "alt-tab": "editor::AcceptEditPrediction", "alt-l": "editor::AcceptEditPrediction", - "alt-right": "editor::AcceptPartialEditPrediction" - } + "alt-right": "editor::AcceptPartialEditPrediction", + }, }, { "context": "Editor && showing_code_actions", "bindings": { - "enter": "editor::ConfirmCodeAction" - } + "enter": "editor::ConfirmCodeAction", + }, }, { "context": "Editor && (showing_code_actions || showing_completions)", @@ -771,29 +771,29 @@ "ctrl-n": "editor::ContextMenuNext", "down": "editor::ContextMenuNext", "pageup": "editor::ContextMenuFirst", - "pagedown": "editor::ContextMenuLast" - } + "pagedown": "editor::ContextMenuLast", + }, }, { "context": "Editor && showing_signature_help && !showing_completions", "bindings": { "up": "editor::SignatureHelpPrevious", - "down": "editor::SignatureHelpNext" - } + "down": "editor::SignatureHelpNext", + }, }, // Custom bindings { "bindings": { "ctrl-alt-shift-f": "workspace::FollowNextCollaborator", // Only available in debug builds: opens an element inspector for development. - "ctrl-alt-i": "dev::ToggleInspector" - } + "ctrl-alt-i": "dev::ToggleInspector", + }, }, { "context": "!Terminal", "bindings": { - "ctrl-shift-c": "collab_panel::ToggleFocus" - } + "ctrl-shift-c": "collab_panel::ToggleFocus", + }, }, { "context": "!ContextEditor > Editor && mode == full", @@ -805,8 +805,8 @@ "ctrl-f8": "editor::GoToHunk", "ctrl-shift-f8": "editor::GoToPreviousHunk", "ctrl-enter": "assistant::InlineAssist", - "ctrl-:": "editor::ToggleInlayHints" - } + "ctrl-:": "editor::ToggleInlayHints", + }, }, { "context": "PromptEditor", @@ -814,8 +814,8 @@ "ctrl-[": "agent::CyclePreviousInlineAssist", "ctrl-]": "agent::CycleNextInlineAssist", "ctrl-shift-enter": "inline_assistant::ThumbsUpResult", - "ctrl-shift-backspace": "inline_assistant::ThumbsDownResult" - } + "ctrl-shift-backspace": "inline_assistant::ThumbsDownResult", + }, }, { "context": "Prompt", @@ -823,14 +823,14 @@ "left": "menu::SelectPrevious", "right": "menu::SelectNext", "h": "menu::SelectPrevious", - "l": "menu::SelectNext" - } + "l": "menu::SelectNext", + }, }, { "context": "ProjectSearchBar && !in_replace", "bindings": { - "ctrl-enter": "project_search::SearchInNew" - } + "ctrl-enter": "project_search::SearchInNew", + }, }, { "context": "OutlinePanel && not_editing", @@ -847,8 +847,8 @@ "shift-down": "menu::SelectNext", "shift-up": "menu::SelectPrevious", "alt-enter": "editor::OpenExcerpts", - "ctrl-alt-enter": "editor::OpenExcerptsSplit" - } + "ctrl-alt-enter": "editor::OpenExcerptsSplit", + }, }, { "context": "ProjectPanel", @@ -886,14 +886,14 @@ "ctrl-alt-shift-f": "project_panel::NewSearchInDirectory", "shift-down": "menu::SelectNext", "shift-up": "menu::SelectPrevious", - "escape": "menu::Cancel" - } + "escape": "menu::Cancel", + }, }, { "context": "ProjectPanel && not_editing", "bindings": { - "space": "project_panel::Open" - } + "space": "project_panel::Open", + }, }, { "context": "GitPanel && ChangesList", @@ -914,15 +914,15 @@ "backspace": ["git::RestoreFile", { "skip_prompt": false }], "shift-delete": ["git::RestoreFile", { "skip_prompt": false }], "ctrl-backspace": ["git::RestoreFile", { "skip_prompt": false }], - "ctrl-delete": ["git::RestoreFile", { "skip_prompt": false }] - } + "ctrl-delete": ["git::RestoreFile", { "skip_prompt": false }], + }, }, { "context": "GitPanel && CommitEditor", "use_key_equivalents": true, "bindings": { - "escape": "git::Cancel" - } + "escape": "git::Cancel", + }, }, { "context": "GitCommit > Editor", @@ -931,8 +931,8 @@ "enter": "editor::Newline", "ctrl-enter": "git::Commit", "ctrl-shift-enter": "git::Amend", - "alt-l": "git::GenerateCommitMessage" - } + "alt-l": "git::GenerateCommitMessage", + }, }, { "context": "GitPanel", @@ -948,8 +948,8 @@ "ctrl-space": "git::StageAll", "ctrl-shift-space": "git::UnstageAll", "ctrl-enter": "git::Commit", - "ctrl-shift-enter": "git::Amend" - } + "ctrl-shift-enter": "git::Amend", + }, }, { "context": "GitDiff > Editor", @@ -957,14 +957,14 @@ "ctrl-enter": "git::Commit", "ctrl-shift-enter": "git::Amend", "ctrl-space": "git::StageAll", - "ctrl-shift-space": "git::UnstageAll" - } + "ctrl-shift-space": "git::UnstageAll", + }, }, { "context": "AskPass > Editor", "bindings": { - "enter": "menu::Confirm" - } + "enter": "menu::Confirm", + }, }, { "context": "CommitEditor > Editor", @@ -976,16 +976,16 @@ "ctrl-enter": "git::Commit", "ctrl-shift-enter": "git::Amend", "alt-up": "git_panel::FocusChanges", - "alt-l": "git::GenerateCommitMessage" - } + "alt-l": "git::GenerateCommitMessage", + }, }, { "context": "DebugPanel", "bindings": { "ctrl-t": "debugger::ToggleThreadPicker", "ctrl-i": "debugger::ToggleSessionPicker", - "shift-alt-escape": "debugger::ToggleExpandItem" - } + "shift-alt-escape": "debugger::ToggleExpandItem", + }, }, { "context": "VariableList", @@ -997,8 +997,8 @@ "ctrl-alt-c": "variable_list::CopyVariableName", "delete": "variable_list::RemoveWatch", "backspace": "variable_list::RemoveWatch", - "alt-enter": "variable_list::AddWatch" - } + "alt-enter": "variable_list::AddWatch", + }, }, { "context": "BreakpointList", @@ -1006,35 +1006,35 @@ "space": "debugger::ToggleEnableBreakpoint", "backspace": "debugger::UnsetBreakpoint", "left": "debugger::PreviousBreakpointProperty", - "right": "debugger::NextBreakpointProperty" - } + "right": "debugger::NextBreakpointProperty", + }, }, { "context": "CollabPanel && not_editing", "bindings": { "ctrl-backspace": "collab_panel::Remove", - "space": "menu::Confirm" - } + "space": "menu::Confirm", + }, }, { "context": "CollabPanel", "bindings": { "alt-up": "collab_panel::MoveChannelUp", "alt-down": "collab_panel::MoveChannelDown", - "alt-enter": "collab_panel::OpenSelectedChannelNotes" - } + "alt-enter": "collab_panel::OpenSelectedChannelNotes", + }, }, { "context": "(CollabPanel && editing) > Editor", "bindings": { - "space": "collab_panel::InsertSpace" - } + "space": "collab_panel::InsertSpace", + }, }, { "context": "ChannelModal", "bindings": { - "tab": "channel_modal::ToggleMode" - } + "tab": "channel_modal::ToggleMode", + }, }, { "context": "Picker > Editor", @@ -1043,29 +1043,29 @@ "up": "menu::SelectPrevious", "down": "menu::SelectNext", "tab": "picker::ConfirmCompletion", - "alt-enter": ["picker::ConfirmInput", { "secondary": false }] - } + "alt-enter": ["picker::ConfirmInput", { "secondary": false }], + }, }, { "context": "ChannelModal > Picker > Editor", "bindings": { - "tab": "channel_modal::ToggleMode" - } + "tab": "channel_modal::ToggleMode", + }, }, { "context": "ToolchainSelector", "use_key_equivalents": true, "bindings": { - "ctrl-shift-a": "toolchain::AddToolchain" - } + "ctrl-shift-a": "toolchain::AddToolchain", + }, }, { "context": "FileFinder || (FileFinder > Picker > Editor)", "bindings": { "ctrl-p": "file_finder::Toggle", "ctrl-shift-a": "file_finder::ToggleSplitMenu", - "ctrl-shift-i": "file_finder::ToggleFilterMenu" - } + "ctrl-shift-i": "file_finder::ToggleFilterMenu", + }, }, { "context": "FileFinder || (FileFinder > Picker > Editor) || (FileFinder > Picker > menu)", @@ -1074,8 +1074,8 @@ "ctrl-j": "pane::SplitDown", "ctrl-k": "pane::SplitUp", "ctrl-h": "pane::SplitLeft", - "ctrl-l": "pane::SplitRight" - } + "ctrl-l": "pane::SplitRight", + }, }, { "context": "TabSwitcher", @@ -1083,15 +1083,15 @@ "ctrl-shift-tab": "menu::SelectPrevious", "ctrl-up": "menu::SelectPrevious", "ctrl-down": "menu::SelectNext", - "ctrl-backspace": "tab_switcher::CloseSelectedItem" - } + "ctrl-backspace": "tab_switcher::CloseSelectedItem", + }, }, { "context": "StashList || (StashList > Picker > Editor)", "bindings": { "ctrl-shift-backspace": "stash_picker::DropStashItem", - "ctrl-shift-v": "stash_picker::ShowStashItem" - } + "ctrl-shift-v": "stash_picker::ShowStashItem", + }, }, { "context": "Terminal", @@ -1136,58 +1136,58 @@ "ctrl-shift-r": "terminal::RerunTask", "ctrl-alt-r": "terminal::RerunTask", "alt-t": "terminal::RerunTask", - "ctrl-shift-5": "pane::SplitRight" - } + "ctrl-shift-5": "pane::SplitRight", + }, }, { "context": "ZedPredictModal", "bindings": { - "escape": "menu::Cancel" - } + "escape": "menu::Cancel", + }, }, { "context": "ConfigureContextServerModal > Editor", "bindings": { "escape": "menu::Cancel", "enter": "editor::Newline", - "ctrl-enter": "menu::Confirm" - } + "ctrl-enter": "menu::Confirm", + }, }, { "context": "ContextServerToolsModal", "use_key_equivalents": true, "bindings": { - "escape": "menu::Cancel" - } + "escape": "menu::Cancel", + }, }, { "context": "OnboardingAiConfigurationModal", "use_key_equivalents": true, "bindings": { - "escape": "menu::Cancel" - } + "escape": "menu::Cancel", + }, }, { "context": "Diagnostics", "use_key_equivalents": true, "bindings": { - "ctrl-r": "diagnostics::ToggleDiagnosticsRefresh" - } + "ctrl-r": "diagnostics::ToggleDiagnosticsRefresh", + }, }, { "context": "DebugConsole > Editor", "use_key_equivalents": true, "bindings": { "enter": "menu::Confirm", - "alt-enter": "console::WatchExpression" - } + "alt-enter": "console::WatchExpression", + }, }, { "context": "RunModal", "bindings": { "ctrl-tab": "pane::ActivateNextItem", - "ctrl-shift-tab": "pane::ActivatePreviousItem" - } + "ctrl-shift-tab": "pane::ActivatePreviousItem", + }, }, { "context": "MarkdownPreview", @@ -1197,8 +1197,8 @@ "up": "markdown::ScrollUp", "down": "markdown::ScrollDown", "alt-up": "markdown::ScrollUpByItem", - "alt-down": "markdown::ScrollDownByItem" - } + "alt-down": "markdown::ScrollDownByItem", + }, }, { "context": "KeymapEditor", @@ -1212,8 +1212,8 @@ "alt-enter": "keymap_editor::CreateBinding", "ctrl-c": "keymap_editor::CopyAction", "ctrl-shift-c": "keymap_editor::CopyContext", - "ctrl-t": "keymap_editor::ShowMatchingKeybinds" - } + "ctrl-t": "keymap_editor::ShowMatchingKeybinds", + }, }, { "context": "KeystrokeInput", @@ -1221,24 +1221,24 @@ "bindings": { "enter": "keystroke_input::StartRecording", "escape escape escape": "keystroke_input::StopRecording", - "delete": "keystroke_input::ClearKeystrokes" - } + "delete": "keystroke_input::ClearKeystrokes", + }, }, { "context": "KeybindEditorModal", "use_key_equivalents": true, "bindings": { "ctrl-enter": "menu::Confirm", - "escape": "menu::Cancel" - } + "escape": "menu::Cancel", + }, }, { "context": "KeybindEditorModal > Editor", "use_key_equivalents": true, "bindings": { "up": "menu::SelectPrevious", - "down": "menu::SelectNext" - } + "down": "menu::SelectNext", + }, }, { "context": "Onboarding", @@ -1250,8 +1250,8 @@ "ctrl-0": ["zed::ResetUiFontSize", { "persist": false }], "ctrl-enter": "onboarding::Finish", "alt-shift-l": "onboarding::SignIn", - "alt-shift-a": "onboarding::OpenAccount" - } + "alt-shift-a": "onboarding::OpenAccount", + }, }, { "context": "Welcome", @@ -1260,23 +1260,23 @@ "ctrl-=": ["zed::IncreaseUiFontSize", { "persist": false }], "ctrl-+": ["zed::IncreaseUiFontSize", { "persist": false }], "ctrl--": ["zed::DecreaseUiFontSize", { "persist": false }], - "ctrl-0": ["zed::ResetUiFontSize", { "persist": false }] - } + "ctrl-0": ["zed::ResetUiFontSize", { "persist": false }], + }, }, { "context": "InvalidBuffer", "use_key_equivalents": true, "bindings": { - "ctrl-shift-enter": "workspace::OpenWithSystem" - } + "ctrl-shift-enter": "workspace::OpenWithSystem", + }, }, { "context": "GitWorktreeSelector || (GitWorktreeSelector > Picker > Editor)", "use_key_equivalents": true, "bindings": { "ctrl-shift-space": "git::WorktreeFromDefaultOnWindow", - "ctrl-space": "git::WorktreeFromDefault" - } + "ctrl-space": "git::WorktreeFromDefault", + }, }, { "context": "SettingsWindow", @@ -1301,16 +1301,16 @@ "ctrl-9": ["settings_editor::FocusFile", 8], "ctrl-0": ["settings_editor::FocusFile", 9], "ctrl-pageup": "settings_editor::FocusPreviousFile", - "ctrl-pagedown": "settings_editor::FocusNextFile" - } + "ctrl-pagedown": "settings_editor::FocusNextFile", + }, }, { "context": "StashDiff > Editor", "bindings": { "ctrl-space": "git::ApplyCurrentStash", "ctrl-shift-space": "git::PopCurrentStash", - "ctrl-shift-backspace": "git::DropCurrentStash" - } + "ctrl-shift-backspace": "git::DropCurrentStash", + }, }, { "context": "SettingsWindow > NavigationMenu", @@ -1325,22 +1325,22 @@ "pageup": "settings_editor::FocusPreviousRootNavEntry", "pagedown": "settings_editor::FocusNextRootNavEntry", "home": "settings_editor::FocusFirstNavEntry", - "end": "settings_editor::FocusLastNavEntry" - } + "end": "settings_editor::FocusLastNavEntry", + }, }, { "context": "EditPredictionContext > Editor", "bindings": { "alt-left": "dev::EditPredictionContextGoBack", - "alt-right": "dev::EditPredictionContextGoForward" - } + "alt-right": "dev::EditPredictionContextGoForward", + }, }, { "context": "GitBranchSelector || (GitBranchSelector > Picker > Editor)", "use_key_equivalents": true, "bindings": { "ctrl-shift-backspace": "branch_picker::DeleteBranch", - "ctrl-shift-i": "branch_picker::FilterRemotes" - } - } + "ctrl-shift-i": "branch_picker::FilterRemotes", + }, + }, ] diff --git a/assets/keymaps/default-macos.json b/assets/keymaps/default-macos.json index 65ac280ba7f782cef417aef220dacd7f32f9e6ff..50fc0c7222b76c9e5218c47a481442534debe2b0 100644 --- a/assets/keymaps/default-macos.json +++ b/assets/keymaps/default-macos.json @@ -50,8 +50,8 @@ "ctrl-cmd-z": "edit_prediction::RatePredictions", "ctrl-cmd-i": "edit_prediction::ToggleMenu", "ctrl-cmd-l": "lsp_tool::ToggleMenu", - "ctrl-cmd-c": "editor::DisplayCursorNames" - } + "ctrl-cmd-c": "editor::DisplayCursorNames", + }, }, { "context": "Editor", @@ -148,8 +148,8 @@ "shift-f9": "editor::EditLogBreakpoint", "ctrl-f12": "editor::GoToDeclaration", "alt-ctrl-f12": "editor::GoToDeclarationSplit", - "ctrl-cmd-e": "editor::ToggleEditPrediction" - } + "ctrl-cmd-e": "editor::ToggleEditPrediction", + }, }, { "context": "Editor && mode == full", @@ -167,8 +167,8 @@ "cmd->": "agent::AddSelectionToThread", "cmd-<": "assistant::InsertIntoEditor", "cmd-alt-e": "editor::SelectEnclosingSymbol", - "alt-enter": "editor::OpenSelectionsInMultibuffer" - } + "alt-enter": "editor::OpenSelectionsInMultibuffer", + }, }, { "context": "Editor && multibuffer", @@ -177,23 +177,23 @@ "cmd-up": "editor::MoveToStartOfExcerpt", "cmd-down": "editor::MoveToStartOfNextExcerpt", "cmd-shift-up": "editor::SelectToStartOfExcerpt", - "cmd-shift-down": "editor::SelectToStartOfNextExcerpt" - } + "cmd-shift-down": "editor::SelectToStartOfNextExcerpt", + }, }, { "context": "Editor && mode == full && edit_prediction", "use_key_equivalents": true, "bindings": { "alt-tab": "editor::NextEditPrediction", - "alt-shift-tab": "editor::PreviousEditPrediction" - } + "alt-shift-tab": "editor::PreviousEditPrediction", + }, }, { "context": "Editor && !edit_prediction", "use_key_equivalents": true, "bindings": { - "alt-tab": "editor::ShowEditPrediction" - } + "alt-tab": "editor::ShowEditPrediction", + }, }, { "context": "Editor && mode == auto_height", @@ -201,23 +201,23 @@ "bindings": { "ctrl-enter": "editor::Newline", "shift-enter": "editor::Newline", - "ctrl-shift-enter": "editor::NewlineBelow" - } + "ctrl-shift-enter": "editor::NewlineBelow", + }, }, { "context": "Markdown", "use_key_equivalents": true, "bindings": { - "cmd-c": "markdown::Copy" - } + "cmd-c": "markdown::Copy", + }, }, { "context": "Editor && jupyter && !ContextEditor", "use_key_equivalents": true, "bindings": { "ctrl-shift-enter": "repl::Run", - "ctrl-alt-enter": "repl::RunInPlace" - } + "ctrl-alt-enter": "repl::RunInPlace", + }, }, { "context": "Editor && !agent_diff && !AgentPanel", @@ -226,8 +226,8 @@ "cmd-alt-z": "git::Restore", "cmd-alt-y": "git::ToggleStaged", "cmd-y": "git::StageAndNext", - "cmd-shift-y": "git::UnstageAndNext" - } + "cmd-shift-y": "git::UnstageAndNext", + }, }, { "context": "AgentDiff", @@ -236,8 +236,8 @@ "cmd-y": "agent::Keep", "cmd-n": "agent::Reject", "cmd-shift-y": "agent::KeepAll", - "cmd-shift-n": "agent::RejectAll" - } + "cmd-shift-n": "agent::RejectAll", + }, }, { "context": "Editor && editor_agent_diff", @@ -247,8 +247,8 @@ "cmd-n": "agent::Reject", "cmd-shift-y": "agent::KeepAll", "cmd-shift-n": "agent::RejectAll", - "shift-ctrl-r": "agent::OpenAgentDiff" - } + "shift-ctrl-r": "agent::OpenAgentDiff", + }, }, { "context": "ContextEditor > Editor", @@ -264,8 +264,8 @@ "cmd-k c": "assistant::CopyCode", "cmd-g": "search::SelectNextMatch", "cmd-shift-g": "search::SelectPreviousMatch", - "cmd-k l": "agent::OpenRulesLibrary" - } + "cmd-k l": "agent::OpenRulesLibrary", + }, }, { "context": "AgentPanel", @@ -290,37 +290,37 @@ "alt-enter": "agent::ContinueWithBurnMode", "cmd-y": "agent::AllowOnce", "cmd-alt-y": "agent::AllowAlways", - "cmd-alt-z": "agent::RejectOnce" - } + "cmd-alt-z": "agent::RejectOnce", + }, }, { "context": "AgentPanel > NavigationMenu", "bindings": { - "shift-backspace": "agent::DeleteRecentlyOpenThread" - } + "shift-backspace": "agent::DeleteRecentlyOpenThread", + }, }, { "context": "AgentPanel > Markdown", "use_key_equivalents": true, "bindings": { - "cmd-c": "markdown::CopyAsMarkdown" - } + "cmd-c": "markdown::CopyAsMarkdown", + }, }, { "context": "AgentPanel && text_thread", "use_key_equivalents": true, "bindings": { "cmd-n": "agent::NewTextThread", - "cmd-alt-n": "agent::NewExternalAgentThread" - } + "cmd-alt-n": "agent::NewExternalAgentThread", + }, }, { "context": "AgentPanel && acp_thread", "use_key_equivalents": true, "bindings": { "cmd-n": "agent::NewExternalAgentThread", - "cmd-alt-t": "agent::NewThread" - } + "cmd-alt-t": "agent::NewThread", + }, }, { "context": "MessageEditor && !Picker > Editor && !use_modifier_to_send", @@ -331,8 +331,8 @@ "cmd-i": "agent::ToggleProfileSelector", "shift-ctrl-r": "agent::OpenAgentDiff", "cmd-shift-y": "agent::KeepAll", - "cmd-shift-n": "agent::RejectAll" - } + "cmd-shift-n": "agent::RejectAll", + }, }, { "context": "MessageEditor && !Picker > Editor && use_modifier_to_send", @@ -343,8 +343,8 @@ "cmd-i": "agent::ToggleProfileSelector", "shift-ctrl-r": "agent::OpenAgentDiff", "cmd-shift-y": "agent::KeepAll", - "cmd-shift-n": "agent::RejectAll" - } + "cmd-shift-n": "agent::RejectAll", + }, }, { "context": "EditMessageEditor > Editor", @@ -352,8 +352,8 @@ "bindings": { "escape": "menu::Cancel", "enter": "menu::Confirm", - "alt-enter": "editor::Newline" - } + "alt-enter": "editor::Newline", + }, }, { "context": "AgentFeedbackMessageEditor > Editor", @@ -361,20 +361,20 @@ "bindings": { "escape": "menu::Cancel", "enter": "menu::Confirm", - "alt-enter": "editor::Newline" - } + "alt-enter": "editor::Newline", + }, }, { "context": "AgentConfiguration", "bindings": { - "ctrl--": "pane::GoBack" - } + "ctrl--": "pane::GoBack", + }, }, { "context": "AcpThread > ModeSelector", "bindings": { - "cmd-enter": "menu::Confirm" - } + "cmd-enter": "menu::Confirm", + }, }, { "context": "AcpThread > Editor && !use_modifier_to_send", @@ -384,8 +384,8 @@ "shift-ctrl-r": "agent::OpenAgentDiff", "cmd-shift-y": "agent::KeepAll", "cmd-shift-n": "agent::RejectAll", - "shift-tab": "agent::CycleModeSelector" - } + "shift-tab": "agent::CycleModeSelector", + }, }, { "context": "AcpThread > Editor && use_modifier_to_send", @@ -395,20 +395,20 @@ "shift-ctrl-r": "agent::OpenAgentDiff", "cmd-shift-y": "agent::KeepAll", "cmd-shift-n": "agent::RejectAll", - "shift-tab": "agent::CycleModeSelector" - } + "shift-tab": "agent::CycleModeSelector", + }, }, { "context": "ThreadHistory", "bindings": { - "ctrl--": "pane::GoBack" - } + "ctrl--": "pane::GoBack", + }, }, { "context": "ThreadHistory > Editor", "bindings": { - "shift-backspace": "agent::RemoveSelectedThread" - } + "shift-backspace": "agent::RemoveSelectedThread", + }, }, { "context": "RulesLibrary", @@ -416,8 +416,8 @@ "bindings": { "cmd-n": "rules_library::NewRule", "cmd-shift-s": "rules_library::ToggleDefaultRule", - "cmd-w": "workspace::CloseWindow" - } + "cmd-w": "workspace::CloseWindow", + }, }, { "context": "BufferSearchBar", @@ -431,24 +431,24 @@ "cmd-f": "search::FocusSearch", "cmd-alt-f": "search::ToggleReplace", "cmd-alt-l": "search::ToggleSelection", - "cmd-shift-o": "outline::Toggle" - } + "cmd-shift-o": "outline::Toggle", + }, }, { "context": "BufferSearchBar && in_replace > Editor", "use_key_equivalents": true, "bindings": { "enter": "search::ReplaceNext", - "cmd-enter": "search::ReplaceAll" - } + "cmd-enter": "search::ReplaceAll", + }, }, { "context": "BufferSearchBar && !in_replace > Editor", "use_key_equivalents": true, "bindings": { "up": "search::PreviousHistoryQuery", - "down": "search::NextHistoryQuery" - } + "down": "search::NextHistoryQuery", + }, }, { "context": "ProjectSearchBar", @@ -460,24 +460,24 @@ "cmd-shift-f": "search::FocusSearch", "cmd-shift-h": "search::ToggleReplace", "alt-cmd-g": "search::ToggleRegex", - "alt-cmd-x": "search::ToggleRegex" - } + "alt-cmd-x": "search::ToggleRegex", + }, }, { "context": "ProjectSearchBar > Editor", "use_key_equivalents": true, "bindings": { "up": "search::PreviousHistoryQuery", - "down": "search::NextHistoryQuery" - } + "down": "search::NextHistoryQuery", + }, }, { "context": "ProjectSearchBar && in_replace > Editor", "use_key_equivalents": true, "bindings": { "enter": "search::ReplaceNext", - "cmd-enter": "search::ReplaceAll" - } + "cmd-enter": "search::ReplaceAll", + }, }, { "context": "ProjectSearchView", @@ -488,8 +488,8 @@ "shift-enter": "project_search::ToggleAllSearchResults", "cmd-shift-h": "search::ToggleReplace", "alt-cmd-g": "search::ToggleRegex", - "alt-cmd-x": "search::ToggleRegex" - } + "alt-cmd-x": "search::ToggleRegex", + }, }, { "context": "Pane", @@ -519,8 +519,8 @@ "alt-cmd-w": "search::ToggleWholeWord", "alt-cmd-f": "project_search::ToggleFilters", "alt-cmd-x": "search::ToggleRegex", - "cmd-k shift-enter": "pane::TogglePinTab" - } + "cmd-k shift-enter": "pane::TogglePinTab", + }, }, // Bindings from VS Code { @@ -590,24 +590,24 @@ "cmd-.": "editor::ToggleCodeActions", "cmd-k r": "editor::RevealInFileManager", "cmd-k p": "editor::CopyPath", - "cmd-\\": "pane::SplitRight" - } + "cmd-\\": "pane::SplitRight", + }, }, { "context": "Editor && extension == md", "use_key_equivalents": true, "bindings": { "cmd-k v": "markdown::OpenPreviewToTheSide", - "cmd-shift-v": "markdown::OpenPreview" - } + "cmd-shift-v": "markdown::OpenPreview", + }, }, { "context": "Editor && extension == svg", "use_key_equivalents": true, "bindings": { "cmd-k v": "svg::OpenPreviewToTheSide", - "cmd-shift-v": "svg::OpenPreview" - } + "cmd-shift-v": "svg::OpenPreview", + }, }, { "context": "Editor && mode == full", @@ -616,8 +616,8 @@ "cmd-shift-o": "outline::Toggle", "ctrl-g": "go_to_line::Toggle", "cmd-shift-backspace": "editor::GoToPreviousChange", - "cmd-shift-alt-backspace": "editor::GoToNextChange" - } + "cmd-shift-alt-backspace": "editor::GoToNextChange", + }, }, { "context": "Pane", @@ -635,8 +635,8 @@ "ctrl-0": "pane::ActivateLastItem", "ctrl--": "pane::GoBack", "ctrl-_": "pane::GoForward", - "cmd-shift-f": "pane::DeploySearch" - } + "cmd-shift-f": "pane::DeploySearch", + }, }, { "context": "Workspace", @@ -707,8 +707,8 @@ "cmd-k shift-down": "workspace::SwapPaneDown", "cmd-shift-x": "zed::Extensions", "f5": "debugger::Rerun", - "cmd-w": "workspace::CloseActiveDock" - } + "cmd-w": "workspace::CloseActiveDock", + }, }, { "context": "Workspace && !Terminal", @@ -719,27 +719,27 @@ // All task parameters are captured and unchanged between reruns by default. // Use the `"reevaluate_context"` parameter to control this. "cmd-alt-r": ["task::Rerun", { "reevaluate_context": false }], - "ctrl-alt-shift-r": ["task::Spawn", { "reveal_target": "center" }] + "ctrl-alt-shift-r": ["task::Spawn", { "reveal_target": "center" }], // also possible to spawn tasks by name: // "foo-bar": ["task::Spawn", { "task_name": "MyTask", "reveal_target": "dock" }] // or by tag: // "foo-bar": ["task::Spawn", { "task_tag": "MyTag" }], - } + }, }, { "context": "Workspace && debugger_running", "use_key_equivalents": true, "bindings": { "f5": "zed::NoAction", - "f11": "debugger::StepInto" - } + "f11": "debugger::StepInto", + }, }, { "context": "Workspace && debugger_stopped", "use_key_equivalents": true, "bindings": { - "f5": "debugger::Continue" - } + "f5": "debugger::Continue", + }, }, // Bindings from Sublime Text { @@ -760,8 +760,8 @@ "ctrl-alt-shift-left": "editor::SelectToPreviousSubwordStart", "ctrl-alt-shift-b": "editor::SelectToPreviousSubwordStart", "ctrl-alt-shift-right": "editor::SelectToNextSubwordEnd", - "ctrl-alt-shift-f": "editor::SelectToNextSubwordEnd" - } + "ctrl-alt-shift-f": "editor::SelectToNextSubwordEnd", + }, }, // Bindings from Atom { @@ -771,16 +771,16 @@ "cmd-k up": "pane::SplitUp", "cmd-k down": "pane::SplitDown", "cmd-k left": "pane::SplitLeft", - "cmd-k right": "pane::SplitRight" - } + "cmd-k right": "pane::SplitRight", + }, }, // Bindings that should be unified with bindings for more general actions { "context": "Editor && renaming", "use_key_equivalents": true, "bindings": { - "enter": "editor::ConfirmRename" - } + "enter": "editor::ConfirmRename", + }, }, { "context": "Editor && showing_completions", @@ -788,45 +788,45 @@ "bindings": { "enter": "editor::ConfirmCompletion", "shift-enter": "editor::ConfirmCompletionReplace", - "tab": "editor::ComposeCompletion" - } + "tab": "editor::ComposeCompletion", + }, }, { "context": "Editor && in_snippet && has_next_tabstop && !showing_completions", "use_key_equivalents": true, "bindings": { - "tab": "editor::NextSnippetTabstop" - } + "tab": "editor::NextSnippetTabstop", + }, }, { "context": "Editor && in_snippet && has_previous_tabstop && !showing_completions", "use_key_equivalents": true, "bindings": { - "shift-tab": "editor::PreviousSnippetTabstop" - } + "shift-tab": "editor::PreviousSnippetTabstop", + }, }, { "context": "Editor && edit_prediction", "bindings": { "alt-tab": "editor::AcceptEditPrediction", "tab": "editor::AcceptEditPrediction", - "ctrl-cmd-right": "editor::AcceptPartialEditPrediction" - } + "ctrl-cmd-right": "editor::AcceptPartialEditPrediction", + }, }, { "context": "Editor && edit_prediction_conflict", "use_key_equivalents": true, "bindings": { "alt-tab": "editor::AcceptEditPrediction", - "ctrl-cmd-right": "editor::AcceptPartialEditPrediction" - } + "ctrl-cmd-right": "editor::AcceptPartialEditPrediction", + }, }, { "context": "Editor && showing_code_actions", "use_key_equivalents": true, "bindings": { - "enter": "editor::ConfirmCodeAction" - } + "enter": "editor::ConfirmCodeAction", + }, }, { "context": "Editor && (showing_code_actions || showing_completions)", @@ -837,15 +837,15 @@ "down": "editor::ContextMenuNext", "ctrl-n": "editor::ContextMenuNext", "pageup": "editor::ContextMenuFirst", - "pagedown": "editor::ContextMenuLast" - } + "pagedown": "editor::ContextMenuLast", + }, }, { "context": "Editor && showing_signature_help && !showing_completions", "bindings": { "up": "editor::SignatureHelpPrevious", - "down": "editor::SignatureHelpNext" - } + "down": "editor::SignatureHelpNext", + }, }, // Custom bindings { @@ -855,8 +855,8 @@ // TODO: Move this to a dock open action "cmd-shift-c": "collab_panel::ToggleFocus", // Only available in debug builds: opens an element inspector for development. - "cmd-alt-i": "dev::ToggleInspector" - } + "cmd-alt-i": "dev::ToggleInspector", + }, }, { "context": "!ContextEditor > Editor && mode == full", @@ -869,8 +869,8 @@ "cmd-f8": "editor::GoToHunk", "cmd-shift-f8": "editor::GoToPreviousHunk", "ctrl-enter": "assistant::InlineAssist", - "ctrl-:": "editor::ToggleInlayHints" - } + "ctrl-:": "editor::ToggleInlayHints", + }, }, { "context": "PromptEditor", @@ -880,8 +880,8 @@ "ctrl-[": "agent::CyclePreviousInlineAssist", "ctrl-]": "agent::CycleNextInlineAssist", "cmd-shift-enter": "inline_assistant::ThumbsUpResult", - "cmd-shift-backspace": "inline_assistant::ThumbsDownResult" - } + "cmd-shift-backspace": "inline_assistant::ThumbsDownResult", + }, }, { "context": "Prompt", @@ -890,15 +890,15 @@ "left": "menu::SelectPrevious", "right": "menu::SelectNext", "h": "menu::SelectPrevious", - "l": "menu::SelectNext" - } + "l": "menu::SelectNext", + }, }, { "context": "ProjectSearchBar && !in_replace", "use_key_equivalents": true, "bindings": { - "cmd-enter": "project_search::SearchInNew" - } + "cmd-enter": "project_search::SearchInNew", + }, }, { "context": "OutlinePanel && not_editing", @@ -914,8 +914,8 @@ "shift-down": "menu::SelectNext", "shift-up": "menu::SelectPrevious", "alt-enter": "editor::OpenExcerpts", - "cmd-alt-enter": "editor::OpenExcerptsSplit" - } + "cmd-alt-enter": "editor::OpenExcerptsSplit", + }, }, { "context": "ProjectPanel", @@ -945,15 +945,15 @@ "cmd-alt-shift-f": "project_panel::NewSearchInDirectory", "shift-down": "menu::SelectNext", "shift-up": "menu::SelectPrevious", - "escape": "menu::Cancel" - } + "escape": "menu::Cancel", + }, }, { "context": "ProjectPanel && not_editing", "use_key_equivalents": true, "bindings": { - "space": "project_panel::Open" - } + "space": "project_panel::Open", + }, }, { "context": "VariableList", @@ -966,8 +966,8 @@ "cmd-alt-c": "variable_list::CopyVariableName", "delete": "variable_list::RemoveWatch", "backspace": "variable_list::RemoveWatch", - "alt-enter": "variable_list::AddWatch" - } + "alt-enter": "variable_list::AddWatch", + }, }, { "context": "GitPanel && ChangesList", @@ -990,15 +990,15 @@ "backspace": ["git::RestoreFile", { "skip_prompt": false }], "delete": ["git::RestoreFile", { "skip_prompt": false }], "cmd-backspace": ["git::RestoreFile", { "skip_prompt": true }], - "cmd-delete": ["git::RestoreFile", { "skip_prompt": true }] - } + "cmd-delete": ["git::RestoreFile", { "skip_prompt": true }], + }, }, { "context": "GitPanel && CommitEditor", "use_key_equivalents": true, "bindings": { - "escape": "git::Cancel" - } + "escape": "git::Cancel", + }, }, { "context": "GitDiff > Editor", @@ -1007,8 +1007,8 @@ "cmd-enter": "git::Commit", "cmd-shift-enter": "git::Amend", "cmd-ctrl-y": "git::StageAll", - "cmd-ctrl-shift-y": "git::UnstageAll" - } + "cmd-ctrl-shift-y": "git::UnstageAll", + }, }, { "context": "CommitEditor > Editor", @@ -1021,8 +1021,8 @@ "shift-tab": "git_panel::FocusChanges", "alt-up": "git_panel::FocusChanges", "shift-escape": "git::ExpandCommitEditor", - "alt-tab": "git::GenerateCommitMessage" - } + "alt-tab": "git::GenerateCommitMessage", + }, }, { "context": "GitPanel", @@ -1039,8 +1039,8 @@ "cmd-ctrl-y": "git::StageAll", "cmd-ctrl-shift-y": "git::UnstageAll", "cmd-enter": "git::Commit", - "cmd-shift-enter": "git::Amend" - } + "cmd-shift-enter": "git::Amend", + }, }, { "context": "GitCommit > Editor", @@ -1050,16 +1050,16 @@ "escape": "menu::Cancel", "cmd-enter": "git::Commit", "cmd-shift-enter": "git::Amend", - "alt-tab": "git::GenerateCommitMessage" - } + "alt-tab": "git::GenerateCommitMessage", + }, }, { "context": "DebugPanel", "bindings": { "cmd-t": "debugger::ToggleThreadPicker", "cmd-i": "debugger::ToggleSessionPicker", - "shift-alt-escape": "debugger::ToggleExpandItem" - } + "shift-alt-escape": "debugger::ToggleExpandItem", + }, }, { "context": "BreakpointList", @@ -1067,16 +1067,16 @@ "space": "debugger::ToggleEnableBreakpoint", "backspace": "debugger::UnsetBreakpoint", "left": "debugger::PreviousBreakpointProperty", - "right": "debugger::NextBreakpointProperty" - } + "right": "debugger::NextBreakpointProperty", + }, }, { "context": "CollabPanel && not_editing", "use_key_equivalents": true, "bindings": { "ctrl-backspace": "collab_panel::Remove", - "space": "menu::Confirm" - } + "space": "menu::Confirm", + }, }, { "context": "CollabPanel", @@ -1084,22 +1084,22 @@ "bindings": { "alt-up": "collab_panel::MoveChannelUp", "alt-down": "collab_panel::MoveChannelDown", - "alt-enter": "collab_panel::OpenSelectedChannelNotes" - } + "alt-enter": "collab_panel::OpenSelectedChannelNotes", + }, }, { "context": "(CollabPanel && editing) > Editor", "use_key_equivalents": true, "bindings": { - "space": "collab_panel::InsertSpace" - } + "space": "collab_panel::InsertSpace", + }, }, { "context": "ChannelModal", "use_key_equivalents": true, "bindings": { - "tab": "channel_modal::ToggleMode" - } + "tab": "channel_modal::ToggleMode", + }, }, { "context": "Picker > Editor", @@ -1110,30 +1110,30 @@ "down": "menu::SelectNext", "tab": "picker::ConfirmCompletion", "alt-enter": ["picker::ConfirmInput", { "secondary": false }], - "cmd-alt-enter": ["picker::ConfirmInput", { "secondary": true }] - } + "cmd-alt-enter": ["picker::ConfirmInput", { "secondary": true }], + }, }, { "context": "ChannelModal > Picker > Editor", "use_key_equivalents": true, "bindings": { - "tab": "channel_modal::ToggleMode" - } + "tab": "channel_modal::ToggleMode", + }, }, { "context": "ToolchainSelector", "use_key_equivalents": true, "bindings": { - "cmd-shift-a": "toolchain::AddToolchain" - } + "cmd-shift-a": "toolchain::AddToolchain", + }, }, { "context": "FileFinder || (FileFinder > Picker > Editor)", "use_key_equivalents": true, "bindings": { "cmd-shift-a": "file_finder::ToggleSplitMenu", - "cmd-shift-i": "file_finder::ToggleFilterMenu" - } + "cmd-shift-i": "file_finder::ToggleFilterMenu", + }, }, { "context": "FileFinder || (FileFinder > Picker > Editor) || (FileFinder > Picker > menu)", @@ -1143,8 +1143,8 @@ "cmd-j": "pane::SplitDown", "cmd-k": "pane::SplitUp", "cmd-h": "pane::SplitLeft", - "cmd-l": "pane::SplitRight" - } + "cmd-l": "pane::SplitRight", + }, }, { "context": "TabSwitcher", @@ -1153,16 +1153,16 @@ "ctrl-shift-tab": "menu::SelectPrevious", "ctrl-up": "menu::SelectPrevious", "ctrl-down": "menu::SelectNext", - "ctrl-backspace": "tab_switcher::CloseSelectedItem" - } + "ctrl-backspace": "tab_switcher::CloseSelectedItem", + }, }, { "context": "StashList || (StashList > Picker > Editor)", "use_key_equivalents": true, "bindings": { "ctrl-shift-backspace": "stash_picker::DropStashItem", - "ctrl-shift-v": "stash_picker::ShowStashItem" - } + "ctrl-shift-v": "stash_picker::ShowStashItem", + }, }, { "context": "Terminal", @@ -1217,8 +1217,8 @@ "ctrl-alt-left": "pane::SplitLeft", "ctrl-alt-right": "pane::SplitRight", "cmd-d": "pane::SplitRight", - "cmd-alt-r": "terminal::RerunTask" - } + "cmd-alt-r": "terminal::RerunTask", + }, }, { "context": "RatePredictionsModal", @@ -1228,8 +1228,8 @@ "cmd-shift-backspace": "zeta::ThumbsDownActivePrediction", "shift-down": "zeta::NextEdit", "shift-up": "zeta::PreviousEdit", - "right": "zeta::PreviewPrediction" - } + "right": "zeta::PreviewPrediction", + }, }, { "context": "RatePredictionsModal > Editor", @@ -1237,15 +1237,15 @@ "bindings": { "escape": "zeta::FocusPredictions", "cmd-shift-enter": "zeta::ThumbsUpActivePrediction", - "cmd-shift-backspace": "zeta::ThumbsDownActivePrediction" - } + "cmd-shift-backspace": "zeta::ThumbsDownActivePrediction", + }, }, { "context": "ZedPredictModal", "use_key_equivalents": true, "bindings": { - "escape": "menu::Cancel" - } + "escape": "menu::Cancel", + }, }, { "context": "ConfigureContextServerModal > Editor", @@ -1253,45 +1253,45 @@ "bindings": { "escape": "menu::Cancel", "enter": "editor::Newline", - "cmd-enter": "menu::Confirm" - } + "cmd-enter": "menu::Confirm", + }, }, { "context": "ContextServerToolsModal", "use_key_equivalents": true, "bindings": { - "escape": "menu::Cancel" - } + "escape": "menu::Cancel", + }, }, { "context": "OnboardingAiConfigurationModal", "use_key_equivalents": true, "bindings": { - "escape": "menu::Cancel" - } + "escape": "menu::Cancel", + }, }, { "context": "Diagnostics", "use_key_equivalents": true, "bindings": { - "ctrl-r": "diagnostics::ToggleDiagnosticsRefresh" - } + "ctrl-r": "diagnostics::ToggleDiagnosticsRefresh", + }, }, { "context": "DebugConsole > Editor", "use_key_equivalents": true, "bindings": { "enter": "menu::Confirm", - "alt-enter": "console::WatchExpression" - } + "alt-enter": "console::WatchExpression", + }, }, { "context": "RunModal", "use_key_equivalents": true, "bindings": { "ctrl-tab": "pane::ActivateNextItem", - "ctrl-shift-tab": "pane::ActivatePreviousItem" - } + "ctrl-shift-tab": "pane::ActivatePreviousItem", + }, }, { "context": "MarkdownPreview", @@ -1301,8 +1301,8 @@ "up": "markdown::ScrollUp", "down": "markdown::ScrollDown", "alt-up": "markdown::ScrollUpByItem", - "alt-down": "markdown::ScrollDownByItem" - } + "alt-down": "markdown::ScrollDownByItem", + }, }, { "context": "KeymapEditor", @@ -1315,8 +1315,8 @@ "alt-enter": "keymap_editor::CreateBinding", "cmd-c": "keymap_editor::CopyAction", "cmd-shift-c": "keymap_editor::CopyContext", - "cmd-t": "keymap_editor::ShowMatchingKeybinds" - } + "cmd-t": "keymap_editor::ShowMatchingKeybinds", + }, }, { "context": "KeystrokeInput", @@ -1324,24 +1324,24 @@ "bindings": { "enter": "keystroke_input::StartRecording", "escape escape escape": "keystroke_input::StopRecording", - "delete": "keystroke_input::ClearKeystrokes" - } + "delete": "keystroke_input::ClearKeystrokes", + }, }, { "context": "KeybindEditorModal", "use_key_equivalents": true, "bindings": { "cmd-enter": "menu::Confirm", - "escape": "menu::Cancel" - } + "escape": "menu::Cancel", + }, }, { "context": "KeybindEditorModal > Editor", "use_key_equivalents": true, "bindings": { "up": "menu::SelectPrevious", - "down": "menu::SelectNext" - } + "down": "menu::SelectNext", + }, }, { "context": "Onboarding", @@ -1353,8 +1353,8 @@ "cmd-0": ["zed::ResetUiFontSize", { "persist": false }], "cmd-enter": "onboarding::Finish", "alt-tab": "onboarding::SignIn", - "alt-shift-a": "onboarding::OpenAccount" - } + "alt-shift-a": "onboarding::OpenAccount", + }, }, { "context": "Welcome", @@ -1363,23 +1363,23 @@ "cmd-=": ["zed::IncreaseUiFontSize", { "persist": false }], "cmd-+": ["zed::IncreaseUiFontSize", { "persist": false }], "cmd--": ["zed::DecreaseUiFontSize", { "persist": false }], - "cmd-0": ["zed::ResetUiFontSize", { "persist": false }] - } + "cmd-0": ["zed::ResetUiFontSize", { "persist": false }], + }, }, { "context": "InvalidBuffer", "use_key_equivalents": true, "bindings": { - "ctrl-shift-enter": "workspace::OpenWithSystem" - } + "ctrl-shift-enter": "workspace::OpenWithSystem", + }, }, { "context": "GitWorktreeSelector || (GitWorktreeSelector > Picker > Editor)", "use_key_equivalents": true, "bindings": { "ctrl-shift-space": "git::WorktreeFromDefaultOnWindow", - "ctrl-space": "git::WorktreeFromDefault" - } + "ctrl-space": "git::WorktreeFromDefault", + }, }, { "context": "SettingsWindow", @@ -1404,8 +1404,8 @@ "ctrl-9": ["settings_editor::FocusFile", 8], "ctrl-0": ["settings_editor::FocusFile", 9], "cmd-{": "settings_editor::FocusPreviousFile", - "cmd-}": "settings_editor::FocusNextFile" - } + "cmd-}": "settings_editor::FocusNextFile", + }, }, { "context": "StashDiff > Editor", @@ -1413,8 +1413,8 @@ "bindings": { "ctrl-space": "git::ApplyCurrentStash", "ctrl-shift-space": "git::PopCurrentStash", - "ctrl-shift-backspace": "git::DropCurrentStash" - } + "ctrl-shift-backspace": "git::DropCurrentStash", + }, }, { "context": "SettingsWindow > NavigationMenu", @@ -1429,22 +1429,22 @@ "pageup": "settings_editor::FocusPreviousRootNavEntry", "pagedown": "settings_editor::FocusNextRootNavEntry", "home": "settings_editor::FocusFirstNavEntry", - "end": "settings_editor::FocusLastNavEntry" - } + "end": "settings_editor::FocusLastNavEntry", + }, }, { "context": "EditPredictionContext > Editor", "bindings": { "alt-left": "dev::EditPredictionContextGoBack", - "alt-right": "dev::EditPredictionContextGoForward" - } + "alt-right": "dev::EditPredictionContextGoForward", + }, }, { "context": "GitBranchSelector || (GitBranchSelector > Picker > Editor)", "use_key_equivalents": true, "bindings": { "cmd-shift-backspace": "branch_picker::DeleteBranch", - "cmd-shift-i": "branch_picker::FilterRemotes" - } - } + "cmd-shift-i": "branch_picker::FilterRemotes", + }, + }, ] diff --git a/assets/keymaps/default-windows.json b/assets/keymaps/default-windows.json index ae051f233e344cc6b961612c690ae1b5107fb2c0..61793d2158d35ed25f71da3606534d64b523de9f 100644 --- a/assets/keymaps/default-windows.json +++ b/assets/keymaps/default-windows.json @@ -42,16 +42,16 @@ "f11": "zed::ToggleFullScreen", "ctrl-shift-i": "edit_prediction::ToggleMenu", "shift-alt-l": "lsp_tool::ToggleMenu", - "ctrl-shift-alt-c": "editor::DisplayCursorNames" - } + "ctrl-shift-alt-c": "editor::DisplayCursorNames", + }, }, { "context": "Picker || menu", "use_key_equivalents": true, "bindings": { "up": "menu::SelectPrevious", - "down": "menu::SelectNext" - } + "down": "menu::SelectNext", + }, }, { "context": "Editor", @@ -119,8 +119,8 @@ "shift-f10": "editor::OpenContextMenu", "ctrl-alt-e": "editor::ToggleEditPrediction", "f9": "editor::ToggleBreakpoint", - "shift-f9": "editor::EditLogBreakpoint" - } + "shift-f9": "editor::EditLogBreakpoint", + }, }, { "context": "Editor && mode == full", @@ -139,23 +139,23 @@ "shift-alt-e": "editor::SelectEnclosingSymbol", "ctrl-shift-backspace": "editor::GoToPreviousChange", "ctrl-shift-alt-backspace": "editor::GoToNextChange", - "alt-enter": "editor::OpenSelectionsInMultibuffer" - } + "alt-enter": "editor::OpenSelectionsInMultibuffer", + }, }, { "context": "Editor && mode == full && edit_prediction", "use_key_equivalents": true, "bindings": { "alt-]": "editor::NextEditPrediction", - "alt-[": "editor::PreviousEditPrediction" - } + "alt-[": "editor::PreviousEditPrediction", + }, }, { "context": "Editor && !edit_prediction", "use_key_equivalents": true, "bindings": { - "alt-\\": "editor::ShowEditPrediction" - } + "alt-\\": "editor::ShowEditPrediction", + }, }, { "context": "Editor && mode == auto_height", @@ -163,23 +163,23 @@ "bindings": { "ctrl-enter": "editor::Newline", "shift-enter": "editor::Newline", - "ctrl-shift-enter": "editor::NewlineBelow" - } + "ctrl-shift-enter": "editor::NewlineBelow", + }, }, { "context": "Markdown", "use_key_equivalents": true, "bindings": { - "ctrl-c": "markdown::Copy" - } + "ctrl-c": "markdown::Copy", + }, }, { "context": "Editor && jupyter && !ContextEditor", "use_key_equivalents": true, "bindings": { "ctrl-shift-enter": "repl::Run", - "ctrl-alt-enter": "repl::RunInPlace" - } + "ctrl-alt-enter": "repl::RunInPlace", + }, }, { "context": "Editor && !agent_diff", @@ -187,8 +187,8 @@ "bindings": { "ctrl-k ctrl-r": "git::Restore", "alt-y": "git::StageAndNext", - "shift-alt-y": "git::UnstageAndNext" - } + "shift-alt-y": "git::UnstageAndNext", + }, }, { "context": "Editor && editor_agent_diff", @@ -198,8 +198,8 @@ "ctrl-n": "agent::Reject", "ctrl-shift-y": "agent::KeepAll", "ctrl-shift-n": "agent::RejectAll", - "ctrl-shift-r": "agent::OpenAgentDiff" - } + "ctrl-shift-r": "agent::OpenAgentDiff", + }, }, { "context": "AgentDiff", @@ -208,8 +208,8 @@ "ctrl-y": "agent::Keep", "ctrl-n": "agent::Reject", "ctrl-shift-y": "agent::KeepAll", - "ctrl-shift-n": "agent::RejectAll" - } + "ctrl-shift-n": "agent::RejectAll", + }, }, { "context": "ContextEditor > Editor", @@ -225,8 +225,8 @@ "ctrl-k c": "assistant::CopyCode", "ctrl-g": "search::SelectNextMatch", "ctrl-shift-g": "search::SelectPreviousMatch", - "ctrl-k l": "agent::OpenRulesLibrary" - } + "ctrl-k l": "agent::OpenRulesLibrary", + }, }, { "context": "AgentPanel", @@ -251,38 +251,38 @@ "alt-enter": "agent::ContinueWithBurnMode", "shift-alt-a": "agent::AllowOnce", "ctrl-alt-y": "agent::AllowAlways", - "shift-alt-z": "agent::RejectOnce" - } + "shift-alt-z": "agent::RejectOnce", + }, }, { "context": "AgentPanel > NavigationMenu", "use_key_equivalents": true, "bindings": { - "shift-backspace": "agent::DeleteRecentlyOpenThread" - } + "shift-backspace": "agent::DeleteRecentlyOpenThread", + }, }, { "context": "AgentPanel > Markdown", "use_key_equivalents": true, "bindings": { - "ctrl-c": "markdown::CopyAsMarkdown" - } + "ctrl-c": "markdown::CopyAsMarkdown", + }, }, { "context": "AgentPanel && text_thread", "use_key_equivalents": true, "bindings": { "ctrl-n": "agent::NewTextThread", - "ctrl-alt-t": "agent::NewThread" - } + "ctrl-alt-t": "agent::NewThread", + }, }, { "context": "AgentPanel && acp_thread", "use_key_equivalents": true, "bindings": { "ctrl-n": "agent::NewExternalAgentThread", - "ctrl-alt-t": "agent::NewThread" - } + "ctrl-alt-t": "agent::NewThread", + }, }, { "context": "MessageEditor && !Picker > Editor && !use_modifier_to_send", @@ -293,8 +293,8 @@ "ctrl-i": "agent::ToggleProfileSelector", "ctrl-shift-r": "agent::OpenAgentDiff", "ctrl-shift-y": "agent::KeepAll", - "ctrl-shift-n": "agent::RejectAll" - } + "ctrl-shift-n": "agent::RejectAll", + }, }, { "context": "MessageEditor && !Picker > Editor && use_modifier_to_send", @@ -305,8 +305,8 @@ "ctrl-i": "agent::ToggleProfileSelector", "ctrl-shift-r": "agent::OpenAgentDiff", "ctrl-shift-y": "agent::KeepAll", - "ctrl-shift-n": "agent::RejectAll" - } + "ctrl-shift-n": "agent::RejectAll", + }, }, { "context": "EditMessageEditor > Editor", @@ -314,8 +314,8 @@ "bindings": { "escape": "menu::Cancel", "enter": "menu::Confirm", - "alt-enter": "editor::Newline" - } + "alt-enter": "editor::Newline", + }, }, { "context": "AgentFeedbackMessageEditor > Editor", @@ -323,14 +323,14 @@ "bindings": { "escape": "menu::Cancel", "enter": "menu::Confirm", - "alt-enter": "editor::Newline" - } + "alt-enter": "editor::Newline", + }, }, { "context": "AcpThread > ModeSelector", "bindings": { - "ctrl-enter": "menu::Confirm" - } + "ctrl-enter": "menu::Confirm", + }, }, { "context": "AcpThread > Editor && !use_modifier_to_send", @@ -340,8 +340,8 @@ "ctrl-shift-r": "agent::OpenAgentDiff", "ctrl-shift-y": "agent::KeepAll", "ctrl-shift-n": "agent::RejectAll", - "shift-tab": "agent::CycleModeSelector" - } + "shift-tab": "agent::CycleModeSelector", + }, }, { "context": "AcpThread > Editor && use_modifier_to_send", @@ -351,15 +351,15 @@ "ctrl-shift-r": "agent::OpenAgentDiff", "ctrl-shift-y": "agent::KeepAll", "ctrl-shift-n": "agent::RejectAll", - "shift-tab": "agent::CycleModeSelector" - } + "shift-tab": "agent::CycleModeSelector", + }, }, { "context": "ThreadHistory", "use_key_equivalents": true, "bindings": { - "backspace": "agent::RemoveSelectedThread" - } + "backspace": "agent::RemoveSelectedThread", + }, }, { "context": "RulesLibrary", @@ -367,8 +367,8 @@ "bindings": { "ctrl-n": "rules_library::NewRule", "ctrl-shift-s": "rules_library::ToggleDefaultRule", - "ctrl-w": "workspace::CloseWindow" - } + "ctrl-w": "workspace::CloseWindow", + }, }, { "context": "BufferSearchBar", @@ -381,24 +381,24 @@ "alt-enter": "search::SelectAllMatches", "ctrl-f": "search::FocusSearch", "ctrl-h": "search::ToggleReplace", - "ctrl-l": "search::ToggleSelection" - } + "ctrl-l": "search::ToggleSelection", + }, }, { "context": "BufferSearchBar && in_replace > Editor", "use_key_equivalents": true, "bindings": { "enter": "search::ReplaceNext", - "ctrl-enter": "search::ReplaceAll" - } + "ctrl-enter": "search::ReplaceAll", + }, }, { "context": "BufferSearchBar && !in_replace > Editor", "use_key_equivalents": true, "bindings": { "up": "search::PreviousHistoryQuery", - "down": "search::NextHistoryQuery" - } + "down": "search::NextHistoryQuery", + }, }, { "context": "ProjectSearchBar", @@ -407,24 +407,24 @@ "escape": "project_search::ToggleFocus", "ctrl-shift-f": "search::FocusSearch", "ctrl-shift-h": "search::ToggleReplace", - "alt-r": "search::ToggleRegex" // vscode - } + "alt-r": "search::ToggleRegex", // vscode + }, }, { "context": "ProjectSearchBar > Editor", "use_key_equivalents": true, "bindings": { "up": "search::PreviousHistoryQuery", - "down": "search::NextHistoryQuery" - } + "down": "search::NextHistoryQuery", + }, }, { "context": "ProjectSearchBar && in_replace > Editor", "use_key_equivalents": true, "bindings": { "enter": "search::ReplaceNext", - "ctrl-alt-enter": "search::ReplaceAll" - } + "ctrl-alt-enter": "search::ReplaceAll", + }, }, { "context": "ProjectSearchView", @@ -432,8 +432,8 @@ "bindings": { "escape": "project_search::ToggleFocus", "ctrl-shift-h": "search::ToggleReplace", - "alt-r": "search::ToggleRegex" // vscode - } + "alt-r": "search::ToggleRegex", // vscode + }, }, { "context": "Pane", @@ -480,8 +480,8 @@ "shift-enter": "project_search::ToggleAllSearchResults", "alt-r": "search::ToggleRegex", // "ctrl-shift-alt-x": "search::ToggleRegex", - "ctrl-k shift-enter": "pane::TogglePinTab" - } + "ctrl-k shift-enter": "pane::TogglePinTab", + }, }, // Bindings from VS Code { @@ -542,31 +542,31 @@ "ctrl-\\": "pane::SplitRight", "alt-.": "editor::GoToHunk", "alt-,": "editor::GoToPreviousHunk", - } + }, }, { "context": "Editor && extension == md", "use_key_equivalents": true, "bindings": { "ctrl-k v": "markdown::OpenPreviewToTheSide", - "ctrl-shift-v": "markdown::OpenPreview" - } + "ctrl-shift-v": "markdown::OpenPreview", + }, }, { "context": "Editor && extension == svg", "use_key_equivalents": true, "bindings": { "ctrl-k v": "svg::OpenPreviewToTheSide", - "ctrl-shift-v": "svg::OpenPreview" - } + "ctrl-shift-v": "svg::OpenPreview", + }, }, { "context": "Editor && mode == full", "use_key_equivalents": true, "bindings": { "ctrl-shift-o": "outline::Toggle", - "ctrl-g": "go_to_line::Toggle" - } + "ctrl-g": "go_to_line::Toggle", + }, }, { "context": "Workspace", @@ -650,22 +650,22 @@ // "foo-bar": ["task::Spawn", { "task_tag": "MyTag" }], "f5": "debugger::Rerun", "ctrl-f4": "workspace::CloseActiveDock", - "ctrl-w": "workspace::CloseActiveDock" - } + "ctrl-w": "workspace::CloseActiveDock", + }, }, { "context": "Workspace && debugger_running", "use_key_equivalents": true, "bindings": { - "f5": "zed::NoAction" - } + "f5": "zed::NoAction", + }, }, { "context": "Workspace && debugger_stopped", "use_key_equivalents": true, "bindings": { - "f5": "debugger::Continue" - } + "f5": "debugger::Continue", + }, }, { "context": "ApplicationMenu", @@ -673,8 +673,8 @@ "bindings": { "f10": "menu::Cancel", "left": "app_menu::ActivateMenuLeft", - "right": "app_menu::ActivateMenuRight" - } + "right": "app_menu::ActivateMenuRight", + }, }, // Bindings from Sublime Text { @@ -691,8 +691,8 @@ "ctrl-alt-left": "editor::MoveToPreviousSubwordStart", "ctrl-alt-right": "editor::MoveToNextSubwordEnd", "ctrl-shift-alt-left": "editor::SelectToPreviousSubwordStart", - "ctrl-shift-alt-right": "editor::SelectToNextSubwordEnd" - } + "ctrl-shift-alt-right": "editor::SelectToNextSubwordEnd", + }, }, // Bindings from Atom { @@ -702,16 +702,16 @@ "ctrl-k up": "pane::SplitUp", "ctrl-k down": "pane::SplitDown", "ctrl-k left": "pane::SplitLeft", - "ctrl-k right": "pane::SplitRight" - } + "ctrl-k right": "pane::SplitRight", + }, }, // Bindings that should be unified with bindings for more general actions { "context": "Editor && renaming", "use_key_equivalents": true, "bindings": { - "enter": "editor::ConfirmRename" - } + "enter": "editor::ConfirmRename", + }, }, { "context": "Editor && showing_completions", @@ -719,22 +719,22 @@ "bindings": { "enter": "editor::ConfirmCompletion", "shift-enter": "editor::ConfirmCompletionReplace", - "tab": "editor::ComposeCompletion" - } + "tab": "editor::ComposeCompletion", + }, }, { "context": "Editor && in_snippet && has_next_tabstop && !showing_completions", "use_key_equivalents": true, "bindings": { - "tab": "editor::NextSnippetTabstop" - } + "tab": "editor::NextSnippetTabstop", + }, }, { "context": "Editor && in_snippet && has_previous_tabstop && !showing_completions", "use_key_equivalents": true, "bindings": { - "shift-tab": "editor::PreviousSnippetTabstop" - } + "shift-tab": "editor::PreviousSnippetTabstop", + }, }, // Bindings for accepting edit predictions // @@ -747,8 +747,8 @@ "alt-tab": "editor::AcceptEditPrediction", "alt-l": "editor::AcceptEditPrediction", "tab": "editor::AcceptEditPrediction", - "alt-right": "editor::AcceptPartialEditPrediction" - } + "alt-right": "editor::AcceptPartialEditPrediction", + }, }, { "context": "Editor && edit_prediction_conflict", @@ -756,15 +756,15 @@ "bindings": { "alt-tab": "editor::AcceptEditPrediction", "alt-l": "editor::AcceptEditPrediction", - "alt-right": "editor::AcceptPartialEditPrediction" - } + "alt-right": "editor::AcceptPartialEditPrediction", + }, }, { "context": "Editor && showing_code_actions", "use_key_equivalents": true, "bindings": { - "enter": "editor::ConfirmCodeAction" - } + "enter": "editor::ConfirmCodeAction", + }, }, { "context": "Editor && (showing_code_actions || showing_completions)", @@ -775,16 +775,16 @@ "ctrl-n": "editor::ContextMenuNext", "down": "editor::ContextMenuNext", "pageup": "editor::ContextMenuFirst", - "pagedown": "editor::ContextMenuLast" - } + "pagedown": "editor::ContextMenuLast", + }, }, { "context": "Editor && showing_signature_help && !showing_completions", "use_key_equivalents": true, "bindings": { "up": "editor::SignatureHelpPrevious", - "down": "editor::SignatureHelpNext" - } + "down": "editor::SignatureHelpNext", + }, }, // Custom bindings { @@ -792,15 +792,15 @@ "bindings": { "ctrl-shift-alt-f": "workspace::FollowNextCollaborator", // Only available in debug builds: opens an element inspector for development. - "shift-alt-i": "dev::ToggleInspector" - } + "shift-alt-i": "dev::ToggleInspector", + }, }, { "context": "!Terminal", "use_key_equivalents": true, "bindings": { - "ctrl-shift-c": "collab_panel::ToggleFocus" - } + "ctrl-shift-c": "collab_panel::ToggleFocus", + }, }, { "context": "!ContextEditor > Editor && mode == full", @@ -813,8 +813,8 @@ "ctrl-f8": "editor::GoToHunk", "ctrl-shift-f8": "editor::GoToPreviousHunk", "ctrl-enter": "assistant::InlineAssist", - "ctrl-shift-;": "editor::ToggleInlayHints" - } + "ctrl-shift-;": "editor::ToggleInlayHints", + }, }, { "context": "PromptEditor", @@ -823,8 +823,8 @@ "ctrl-[": "agent::CyclePreviousInlineAssist", "ctrl-]": "agent::CycleNextInlineAssist", "ctrl-shift-enter": "inline_assistant::ThumbsUpResult", - "ctrl-shift-delete": "inline_assistant::ThumbsDownResult" - } + "ctrl-shift-delete": "inline_assistant::ThumbsDownResult", + }, }, { "context": "Prompt", @@ -833,15 +833,15 @@ "left": "menu::SelectPrevious", "right": "menu::SelectNext", "h": "menu::SelectPrevious", - "l": "menu::SelectNext" - } + "l": "menu::SelectNext", + }, }, { "context": "ProjectSearchBar && !in_replace", "use_key_equivalents": true, "bindings": { - "ctrl-enter": "project_search::SearchInNew" - } + "ctrl-enter": "project_search::SearchInNew", + }, }, { "context": "OutlinePanel && not_editing", @@ -856,8 +856,8 @@ "shift-down": "menu::SelectNext", "shift-up": "menu::SelectPrevious", "alt-enter": "editor::OpenExcerpts", - "ctrl-alt-enter": "editor::OpenExcerptsSplit" - } + "ctrl-alt-enter": "editor::OpenExcerptsSplit", + }, }, { "context": "ProjectPanel", @@ -888,15 +888,15 @@ "ctrl-k ctrl-shift-f": "project_panel::NewSearchInDirectory", "shift-down": "menu::SelectNext", "shift-up": "menu::SelectPrevious", - "escape": "menu::Cancel" - } + "escape": "menu::Cancel", + }, }, { "context": "ProjectPanel && not_editing", "use_key_equivalents": true, "bindings": { - "space": "project_panel::Open" - } + "space": "project_panel::Open", + }, }, { "context": "GitPanel && ChangesList", @@ -917,15 +917,15 @@ "backspace": ["git::RestoreFile", { "skip_prompt": false }], "shift-delete": ["git::RestoreFile", { "skip_prompt": false }], "ctrl-backspace": ["git::RestoreFile", { "skip_prompt": false }], - "ctrl-delete": ["git::RestoreFile", { "skip_prompt": false }] - } + "ctrl-delete": ["git::RestoreFile", { "skip_prompt": false }], + }, }, { "context": "GitPanel && CommitEditor", "use_key_equivalents": true, "bindings": { - "escape": "git::Cancel" - } + "escape": "git::Cancel", + }, }, { "context": "GitCommit > Editor", @@ -935,8 +935,8 @@ "enter": "editor::Newline", "ctrl-enter": "git::Commit", "ctrl-shift-enter": "git::Amend", - "alt-l": "git::GenerateCommitMessage" - } + "alt-l": "git::GenerateCommitMessage", + }, }, { "context": "GitPanel", @@ -953,8 +953,8 @@ "ctrl-space": "git::StageAll", "ctrl-shift-space": "git::UnstageAll", "ctrl-enter": "git::Commit", - "ctrl-shift-enter": "git::Amend" - } + "ctrl-shift-enter": "git::Amend", + }, }, { "context": "GitDiff > Editor", @@ -963,15 +963,15 @@ "ctrl-enter": "git::Commit", "ctrl-shift-enter": "git::Amend", "ctrl-space": "git::StageAll", - "ctrl-shift-space": "git::UnstageAll" - } + "ctrl-shift-space": "git::UnstageAll", + }, }, { "context": "AskPass > Editor", "use_key_equivalents": true, "bindings": { - "enter": "menu::Confirm" - } + "enter": "menu::Confirm", + }, }, { "context": "CommitEditor > Editor", @@ -984,8 +984,8 @@ "ctrl-enter": "git::Commit", "ctrl-shift-enter": "git::Amend", "alt-up": "git_panel::FocusChanges", - "alt-l": "git::GenerateCommitMessage" - } + "alt-l": "git::GenerateCommitMessage", + }, }, { "context": "DebugPanel", @@ -993,8 +993,8 @@ "bindings": { "ctrl-t": "debugger::ToggleThreadPicker", "ctrl-i": "debugger::ToggleSessionPicker", - "shift-alt-escape": "debugger::ToggleExpandItem" - } + "shift-alt-escape": "debugger::ToggleExpandItem", + }, }, { "context": "VariableList", @@ -1007,8 +1007,8 @@ "ctrl-alt-c": "variable_list::CopyVariableName", "delete": "variable_list::RemoveWatch", "backspace": "variable_list::RemoveWatch", - "alt-enter": "variable_list::AddWatch" - } + "alt-enter": "variable_list::AddWatch", + }, }, { "context": "BreakpointList", @@ -1017,16 +1017,16 @@ "space": "debugger::ToggleEnableBreakpoint", "backspace": "debugger::UnsetBreakpoint", "left": "debugger::PreviousBreakpointProperty", - "right": "debugger::NextBreakpointProperty" - } + "right": "debugger::NextBreakpointProperty", + }, }, { "context": "CollabPanel && not_editing", "use_key_equivalents": true, "bindings": { "ctrl-backspace": "collab_panel::Remove", - "space": "menu::Confirm" - } + "space": "menu::Confirm", + }, }, { "context": "CollabPanel", @@ -1034,22 +1034,22 @@ "bindings": { "alt-up": "collab_panel::MoveChannelUp", "alt-down": "collab_panel::MoveChannelDown", - "alt-enter": "collab_panel::OpenSelectedChannelNotes" - } + "alt-enter": "collab_panel::OpenSelectedChannelNotes", + }, }, { "context": "(CollabPanel && editing) > Editor", "use_key_equivalents": true, "bindings": { - "space": "collab_panel::InsertSpace" - } + "space": "collab_panel::InsertSpace", + }, }, { "context": "ChannelModal", "use_key_equivalents": true, "bindings": { - "tab": "channel_modal::ToggleMode" - } + "tab": "channel_modal::ToggleMode", + }, }, { "context": "Picker > Editor", @@ -1059,22 +1059,22 @@ "up": "menu::SelectPrevious", "down": "menu::SelectNext", "tab": "picker::ConfirmCompletion", - "alt-enter": ["picker::ConfirmInput", { "secondary": false }] - } + "alt-enter": ["picker::ConfirmInput", { "secondary": false }], + }, }, { "context": "ChannelModal > Picker > Editor", "use_key_equivalents": true, "bindings": { - "tab": "channel_modal::ToggleMode" - } + "tab": "channel_modal::ToggleMode", + }, }, { "context": "ToolchainSelector", "use_key_equivalents": true, "bindings": { - "ctrl-shift-a": "toolchain::AddToolchain" - } + "ctrl-shift-a": "toolchain::AddToolchain", + }, }, { "context": "FileFinder || (FileFinder > Picker > Editor)", @@ -1082,8 +1082,8 @@ "bindings": { "ctrl-p": "file_finder::Toggle", "ctrl-shift-a": "file_finder::ToggleSplitMenu", - "ctrl-shift-i": "file_finder::ToggleFilterMenu" - } + "ctrl-shift-i": "file_finder::ToggleFilterMenu", + }, }, { "context": "FileFinder || (FileFinder > Picker > Editor) || (FileFinder > Picker > menu)", @@ -1093,8 +1093,8 @@ "ctrl-j": "pane::SplitDown", "ctrl-k": "pane::SplitUp", "ctrl-h": "pane::SplitLeft", - "ctrl-l": "pane::SplitRight" - } + "ctrl-l": "pane::SplitRight", + }, }, { "context": "TabSwitcher", @@ -1103,16 +1103,16 @@ "ctrl-shift-tab": "menu::SelectPrevious", "ctrl-up": "menu::SelectPrevious", "ctrl-down": "menu::SelectNext", - "ctrl-backspace": "tab_switcher::CloseSelectedItem" - } + "ctrl-backspace": "tab_switcher::CloseSelectedItem", + }, }, { "context": "StashList || (StashList > Picker > Editor)", "use_key_equivalents": true, "bindings": { "ctrl-shift-backspace": "stash_picker::DropStashItem", - "ctrl-shift-v": "stash_picker::ShowStashItem" - } + "ctrl-shift-v": "stash_picker::ShowStashItem", + }, }, { "context": "Terminal", @@ -1159,21 +1159,21 @@ "ctrl-shift-r": "terminal::RerunTask", "ctrl-alt-r": "terminal::RerunTask", "alt-t": "terminal::RerunTask", - "ctrl-shift-5": "pane::SplitRight" - } + "ctrl-shift-5": "pane::SplitRight", + }, }, { "context": "Terminal && selection", "bindings": { - "ctrl-c": "terminal::Copy" - } + "ctrl-c": "terminal::Copy", + }, }, { "context": "ZedPredictModal", "use_key_equivalents": true, "bindings": { - "escape": "menu::Cancel" - } + "escape": "menu::Cancel", + }, }, { "context": "ConfigureContextServerModal > Editor", @@ -1181,45 +1181,45 @@ "bindings": { "escape": "menu::Cancel", "enter": "editor::Newline", - "ctrl-enter": "menu::Confirm" - } + "ctrl-enter": "menu::Confirm", + }, }, { "context": "ContextServerToolsModal", "use_key_equivalents": true, "bindings": { - "escape": "menu::Cancel" - } + "escape": "menu::Cancel", + }, }, { "context": "OnboardingAiConfigurationModal", "use_key_equivalents": true, "bindings": { - "escape": "menu::Cancel" - } + "escape": "menu::Cancel", + }, }, { "context": "Diagnostics", "use_key_equivalents": true, "bindings": { - "ctrl-r": "diagnostics::ToggleDiagnosticsRefresh" - } + "ctrl-r": "diagnostics::ToggleDiagnosticsRefresh", + }, }, { "context": "DebugConsole > Editor", "use_key_equivalents": true, "bindings": { "enter": "menu::Confirm", - "alt-enter": "console::WatchExpression" - } + "alt-enter": "console::WatchExpression", + }, }, { "context": "RunModal", "use_key_equivalents": true, "bindings": { "ctrl-tab": "pane::ActivateNextItem", - "ctrl-shift-tab": "pane::ActivatePreviousItem" - } + "ctrl-shift-tab": "pane::ActivatePreviousItem", + }, }, { "context": "MarkdownPreview", @@ -1230,8 +1230,8 @@ "up": "markdown::ScrollUp", "down": "markdown::ScrollDown", "alt-up": "markdown::ScrollUpByItem", - "alt-down": "markdown::ScrollDownByItem" - } + "alt-down": "markdown::ScrollDownByItem", + }, }, { "context": "KeymapEditor", @@ -1244,8 +1244,8 @@ "alt-enter": "keymap_editor::CreateBinding", "ctrl-c": "keymap_editor::CopyAction", "ctrl-shift-c": "keymap_editor::CopyContext", - "ctrl-t": "keymap_editor::ShowMatchingKeybinds" - } + "ctrl-t": "keymap_editor::ShowMatchingKeybinds", + }, }, { "context": "KeystrokeInput", @@ -1253,24 +1253,24 @@ "bindings": { "enter": "keystroke_input::StartRecording", "escape escape escape": "keystroke_input::StopRecording", - "delete": "keystroke_input::ClearKeystrokes" - } + "delete": "keystroke_input::ClearKeystrokes", + }, }, { "context": "KeybindEditorModal", "use_key_equivalents": true, "bindings": { "ctrl-enter": "menu::Confirm", - "escape": "menu::Cancel" - } + "escape": "menu::Cancel", + }, }, { "context": "KeybindEditorModal > Editor", "use_key_equivalents": true, "bindings": { "up": "menu::SelectPrevious", - "down": "menu::SelectNext" - } + "down": "menu::SelectNext", + }, }, { "context": "Onboarding", @@ -1282,8 +1282,8 @@ "ctrl-0": ["zed::ResetUiFontSize", { "persist": false }], "ctrl-enter": "onboarding::Finish", "alt-shift-l": "onboarding::SignIn", - "shift-alt-a": "onboarding::OpenAccount" - } + "shift-alt-a": "onboarding::OpenAccount", + }, }, { "context": "Welcome", @@ -1292,16 +1292,16 @@ "ctrl-=": ["zed::IncreaseUiFontSize", { "persist": false }], "ctrl-+": ["zed::IncreaseUiFontSize", { "persist": false }], "ctrl--": ["zed::DecreaseUiFontSize", { "persist": false }], - "ctrl-0": ["zed::ResetUiFontSize", { "persist": false }] - } + "ctrl-0": ["zed::ResetUiFontSize", { "persist": false }], + }, }, { "context": "GitWorktreeSelector || (GitWorktreeSelector > Picker > Editor)", "use_key_equivalents": true, "bindings": { "ctrl-shift-space": "git::WorktreeFromDefaultOnWindow", - "ctrl-space": "git::WorktreeFromDefault" - } + "ctrl-space": "git::WorktreeFromDefault", + }, }, { "context": "SettingsWindow", @@ -1326,8 +1326,8 @@ "ctrl-9": ["settings_editor::FocusFile", 8], "ctrl-0": ["settings_editor::FocusFile", 9], "ctrl-pageup": "settings_editor::FocusPreviousFile", - "ctrl-pagedown": "settings_editor::FocusNextFile" - } + "ctrl-pagedown": "settings_editor::FocusNextFile", + }, }, { "context": "StashDiff > Editor", @@ -1335,8 +1335,8 @@ "bindings": { "ctrl-space": "git::ApplyCurrentStash", "ctrl-shift-space": "git::PopCurrentStash", - "ctrl-shift-backspace": "git::DropCurrentStash" - } + "ctrl-shift-backspace": "git::DropCurrentStash", + }, }, { "context": "SettingsWindow > NavigationMenu", @@ -1351,22 +1351,22 @@ "pageup": "settings_editor::FocusPreviousRootNavEntry", "pagedown": "settings_editor::FocusNextRootNavEntry", "home": "settings_editor::FocusFirstNavEntry", - "end": "settings_editor::FocusLastNavEntry" - } + "end": "settings_editor::FocusLastNavEntry", + }, }, { "context": "EditPredictionContext > Editor", "bindings": { "alt-left": "dev::EditPredictionContextGoBack", - "alt-right": "dev::EditPredictionContextGoForward" - } + "alt-right": "dev::EditPredictionContextGoForward", + }, }, { "context": "GitBranchSelector || (GitBranchSelector > Picker > Editor)", "use_key_equivalents": true, "bindings": { "ctrl-shift-backspace": "branch_picker::DeleteBranch", - "ctrl-shift-i": "branch_picker::FilterRemotes" - } - } + "ctrl-shift-i": "branch_picker::FilterRemotes", + }, + }, ] diff --git a/assets/keymaps/initial.json b/assets/keymaps/initial.json index 8e4fe59f44ea7346a51e1c064ffa0553315da3b9..3a8d7f382aa57b39efc22845a17a4ef1bfd240ef 100644 --- a/assets/keymaps/initial.json +++ b/assets/keymaps/initial.json @@ -10,12 +10,12 @@ "context": "Workspace", "bindings": { // "shift shift": "file_finder::Toggle" - } + }, }, { "context": "Editor && vim_mode == insert", "bindings": { // "j k": "vim::NormalBefore" - } - } + }, + }, ] diff --git a/assets/keymaps/linux/atom.json b/assets/keymaps/linux/atom.json index 98992b19fac72055807063edae8b7b23652062d3..a15d4877aab79ac2e570697137ba89e3572d074e 100644 --- a/assets/keymaps/linux/atom.json +++ b/assets/keymaps/linux/atom.json @@ -4,15 +4,15 @@ "bindings": { "ctrl-shift-f5": "workspace::Reload", // window:reload "ctrl-k ctrl-n": "workspace::ActivatePreviousPane", // window:focus-next-pane - "ctrl-k ctrl-p": "workspace::ActivateNextPane" // window:focus-previous-pane - } + "ctrl-k ctrl-p": "workspace::ActivateNextPane", // window:focus-previous-pane + }, }, { "context": "Editor", "bindings": { "ctrl-k ctrl-u": "editor::ConvertToUpperCase", // editor:upper-case - "ctrl-k ctrl-l": "editor::ConvertToLowerCase" // editor:lower-case - } + "ctrl-k ctrl-l": "editor::ConvertToLowerCase", // editor:lower-case + }, }, { "context": "Editor && mode == full", @@ -32,8 +32,8 @@ "ctrl-down": "editor::MoveLineDown", // editor:move-line-down "ctrl-\\": "workspace::ToggleLeftDock", // tree-view:toggle "ctrl-shift-m": "markdown::OpenPreviewToTheSide", // markdown-preview:toggle - "ctrl-r": "outline::Toggle" // symbols-view:toggle-project-symbols - } + "ctrl-r": "outline::Toggle", // symbols-view:toggle-project-symbols + }, }, { "context": "BufferSearchBar", @@ -41,8 +41,8 @@ "f3": ["editor::SelectNext", { "replace_newest": true }], // find-and-replace:find-next "shift-f3": ["editor::SelectPrevious", { "replace_newest": true }], //find-and-replace:find-previous "ctrl-f3": "search::SelectNextMatch", // find-and-replace:find-next-selected - "ctrl-shift-f3": "search::SelectPreviousMatch" // find-and-replace:find-previous-selected - } + "ctrl-shift-f3": "search::SelectPreviousMatch", // find-and-replace:find-previous-selected + }, }, { "context": "Workspace", @@ -50,8 +50,8 @@ "ctrl-\\": "workspace::ToggleLeftDock", // tree-view:toggle "ctrl-k ctrl-b": "workspace::ToggleLeftDock", // tree-view:toggle "ctrl-t": "file_finder::Toggle", // fuzzy-finder:toggle-file-finder - "ctrl-r": "project_symbols::Toggle" // symbols-view:toggle-project-symbols - } + "ctrl-r": "project_symbols::Toggle", // symbols-view:toggle-project-symbols + }, }, { "context": "Pane", @@ -65,8 +65,8 @@ "ctrl-6": ["pane::ActivateItem", 5], // tree-view:open-selected-entry-in-pane-6 "ctrl-7": ["pane::ActivateItem", 6], // tree-view:open-selected-entry-in-pane-7 "ctrl-8": ["pane::ActivateItem", 7], // tree-view:open-selected-entry-in-pane-8 - "ctrl-9": ["pane::ActivateItem", 8] // tree-view:open-selected-entry-in-pane-9 - } + "ctrl-9": ["pane::ActivateItem", 8], // tree-view:open-selected-entry-in-pane-9 + }, }, { "context": "ProjectPanel", @@ -75,8 +75,8 @@ "backspace": ["project_panel::Trash", { "skip_prompt": false }], "ctrl-x": "project_panel::Cut", // tree-view:cut "ctrl-c": "project_panel::Copy", // tree-view:copy - "ctrl-v": "project_panel::Paste" // tree-view:paste - } + "ctrl-v": "project_panel::Paste", // tree-view:paste + }, }, { "context": "ProjectPanel && not_editing", @@ -90,7 +90,7 @@ "d": "project_panel::Duplicate", // tree-view:duplicate "home": "menu::SelectFirst", // core:move-to-top "end": "menu::SelectLast", // core:move-to-bottom - "shift-a": "project_panel::NewDirectory" // tree-view:add-folder - } - } + "shift-a": "project_panel::NewDirectory", // tree-view:add-folder + }, + }, ] diff --git a/assets/keymaps/linux/cursor.json b/assets/keymaps/linux/cursor.json index 4d2d13a90d96c31f72b1bb0ccc74608f81004eda..53f38234bb47a0f7c4412bf767e3eedf0465ba2a 100644 --- a/assets/keymaps/linux/cursor.json +++ b/assets/keymaps/linux/cursor.json @@ -8,8 +8,8 @@ "ctrl-shift-i": "agent::ToggleFocus", "ctrl-l": "agent::ToggleFocus", "ctrl-shift-l": "agent::ToggleFocus", - "ctrl-shift-j": "agent::OpenSettings" - } + "ctrl-shift-j": "agent::OpenSettings", + }, }, { "context": "Editor && mode == full", @@ -20,18 +20,18 @@ "ctrl-shift-l": "agent::AddSelectionToThread", // In cursor uses "Ask" mode "ctrl-l": "agent::AddSelectionToThread", // In cursor uses "Agent" mode "ctrl-k": "assistant::InlineAssist", - "ctrl-shift-k": "assistant::InsertIntoEditor" - } + "ctrl-shift-k": "assistant::InsertIntoEditor", + }, }, { "context": "InlineAssistEditor", "use_key_equivalents": true, "bindings": { - "ctrl-shift-backspace": "editor::Cancel" + "ctrl-shift-backspace": "editor::Cancel", // "alt-enter": // Quick Question // "ctrl-shift-enter": // Full File Context // "ctrl-shift-k": // Toggle input focus (editor <> inline assist) - } + }, }, { "context": "AgentPanel || ContextEditor || (MessageEditor > Editor)", @@ -47,7 +47,7 @@ "ctrl-shift-backspace": "editor::Cancel", "ctrl-r": "agent::NewThread", "ctrl-shift-v": "editor::Paste", - "ctrl-shift-k": "assistant::InsertIntoEditor" + "ctrl-shift-k": "assistant::InsertIntoEditor", // "escape": "agent::ToggleFocus" ///// Enable when Zed supports multiple thread tabs // "ctrl-t": // new thread tab @@ -56,28 +56,28 @@ ///// Enable if Zed adds support for keyboard navigation of thread elements // "tab": // cycle to next message // "shift-tab": // cycle to previous message - } + }, }, { "context": "Editor && editor_agent_diff", "use_key_equivalents": true, "bindings": { "ctrl-enter": "agent::KeepAll", - "ctrl-backspace": "agent::RejectAll" - } + "ctrl-backspace": "agent::RejectAll", + }, }, { "context": "Editor && mode == full && edit_prediction", "use_key_equivalents": true, "bindings": { - "ctrl-right": "editor::AcceptPartialEditPrediction" - } + "ctrl-right": "editor::AcceptPartialEditPrediction", + }, }, { "context": "Terminal", "use_key_equivalents": true, "bindings": { - "ctrl-k": "assistant::InlineAssist" - } - } + "ctrl-k": "assistant::InlineAssist", + }, + }, ] diff --git a/assets/keymaps/linux/emacs.json b/assets/keymaps/linux/emacs.json index c5cf22c81220bf286187252394f8fde26bdd6509..5b6f841de07ac2f9bd45c73e032dea0ede409007 100755 --- a/assets/keymaps/linux/emacs.json +++ b/assets/keymaps/linux/emacs.json @@ -5,8 +5,8 @@ [ { "bindings": { - "ctrl-g": "menu::Cancel" - } + "ctrl-g": "menu::Cancel", + }, }, { // Workaround to avoid falling back to default bindings. @@ -18,8 +18,8 @@ "ctrl-g": null, // currently activates `go_to_line::Toggle` when there is nothing to cancel "ctrl-x": null, // currently activates `editor::Cut` if no following key is pressed for 1 second "ctrl-p": null, // currently activates `file_finder::Toggle` when the cursor is on the first character of the buffer - "ctrl-n": null // currently activates `workspace::NewFile` when the cursor is on the last character of the buffer - } + "ctrl-n": null, // currently activates `workspace::NewFile` when the cursor is on the last character of the buffer + }, }, { "context": "Editor", @@ -82,8 +82,8 @@ "ctrl-s": "buffer_search::Deploy", // isearch-forward "ctrl-r": "buffer_search::Deploy", // isearch-backward "alt-^": "editor::JoinLines", // join-line - "alt-q": "editor::Rewrap" // fill-paragraph - } + "alt-q": "editor::Rewrap", // fill-paragraph + }, }, { "context": "Editor && selection_mode", // region selection @@ -119,22 +119,22 @@ "alt->": "editor::SelectToEnd", "ctrl-home": "editor::SelectToBeginning", "ctrl-end": "editor::SelectToEnd", - "ctrl-g": "editor::Cancel" - } + "ctrl-g": "editor::Cancel", + }, }, { "context": "Editor && (showing_code_actions || showing_completions)", "bindings": { "ctrl-p": "editor::ContextMenuPrevious", - "ctrl-n": "editor::ContextMenuNext" - } + "ctrl-n": "editor::ContextMenuNext", + }, }, { "context": "Editor && showing_signature_help && !showing_completions", "bindings": { "ctrl-p": "editor::SignatureHelpPrevious", - "ctrl-n": "editor::SignatureHelpNext" - } + "ctrl-n": "editor::SignatureHelpNext", + }, }, // Example setting for using emacs-style tab // (i.e. indent the current line / selection or perform symbol completion depending on context) @@ -164,8 +164,8 @@ "ctrl-x ctrl-f": "file_finder::Toggle", // find-file "ctrl-x ctrl-s": "workspace::Save", // save-buffer "ctrl-x ctrl-w": "workspace::SaveAs", // write-file - "ctrl-x s": "workspace::SaveAll" // save-some-buffers - } + "ctrl-x s": "workspace::SaveAll", // save-some-buffers + }, }, { // Workaround to enable using native emacs from the Zed terminal. @@ -185,22 +185,22 @@ "ctrl-x ctrl-f": null, // find-file "ctrl-x ctrl-s": null, // save-buffer "ctrl-x ctrl-w": null, // write-file - "ctrl-x s": null // save-some-buffers - } + "ctrl-x s": null, // save-some-buffers + }, }, { "context": "BufferSearchBar > Editor", "bindings": { "ctrl-s": "search::SelectNextMatch", "ctrl-r": "search::SelectPreviousMatch", - "ctrl-g": "buffer_search::Dismiss" - } + "ctrl-g": "buffer_search::Dismiss", + }, }, { "context": "Pane", "bindings": { "ctrl-alt-left": "pane::GoBack", - "ctrl-alt-right": "pane::GoForward" - } - } + "ctrl-alt-right": "pane::GoForward", + }, + }, ] diff --git a/assets/keymaps/linux/jetbrains.json b/assets/keymaps/linux/jetbrains.json index a0314c5bc1dd59c17f3f132db804891ef1df0d4e..3a54c92bf33decd968ee8d711fb1a929534ded21 100644 --- a/assets/keymaps/linux/jetbrains.json +++ b/assets/keymaps/linux/jetbrains.json @@ -13,8 +13,8 @@ "shift-f8": "debugger::StepOut", "f9": "debugger::Continue", "shift-f9": "debugger::Start", - "alt-shift-f9": "debugger::Start" - } + "alt-shift-f9": "debugger::Start", + }, }, { "context": "Editor", @@ -62,8 +62,8 @@ "ctrl-shift-end": "editor::SelectToEnd", "ctrl-f8": "editor::ToggleBreakpoint", "ctrl-shift-f8": "editor::EditLogBreakpoint", - "ctrl-shift-u": "editor::ToggleCase" - } + "ctrl-shift-u": "editor::ToggleCase", + }, }, { "context": "Editor && mode == full", @@ -76,14 +76,14 @@ "ctrl-space": "editor::ShowCompletions", "ctrl-q": "editor::Hover", "ctrl-p": "editor::ShowSignatureHelp", - "ctrl-\\": "assistant::InlineAssist" - } + "ctrl-\\": "assistant::InlineAssist", + }, }, { "context": "BufferSearchBar", "bindings": { - "shift-enter": "search::SelectPreviousMatch" - } + "shift-enter": "search::SelectPreviousMatch", + }, }, { "context": "BufferSearchBar || ProjectSearchBar", @@ -91,8 +91,8 @@ "alt-c": "search::ToggleCaseSensitive", "alt-e": "search::ToggleSelection", "alt-x": "search::ToggleRegex", - "alt-w": "search::ToggleWholeWord" - } + "alt-w": "search::ToggleWholeWord", + }, }, { "context": "Workspace", @@ -114,8 +114,8 @@ "alt-1": "project_panel::ToggleFocus", "alt-5": "debug_panel::ToggleFocus", "alt-6": "diagnostics::Deploy", - "alt-7": "outline_panel::ToggleFocus" - } + "alt-7": "outline_panel::ToggleFocus", + }, }, { "context": "Pane", // this is to override the default Pane mappings to switch tabs @@ -129,15 +129,15 @@ "alt-7": "outline_panel::ToggleFocus", "alt-8": null, // Services (bottom dock) "alt-9": null, // Git History (bottom dock) - "alt-0": "git_panel::ToggleFocus" - } + "alt-0": "git_panel::ToggleFocus", + }, }, { "context": "Workspace || Editor", "bindings": { "alt-f12": "terminal_panel::Toggle", - "ctrl-shift-k": "git::Push" - } + "ctrl-shift-k": "git::Push", + }, }, { "context": "Pane", @@ -145,8 +145,8 @@ "ctrl-alt-left": "pane::GoBack", "ctrl-alt-right": "pane::GoForward", "alt-left": "pane::ActivatePreviousItem", - "alt-right": "pane::ActivateNextItem" - } + "alt-right": "pane::ActivateNextItem", + }, }, { "context": "ProjectPanel", @@ -156,8 +156,8 @@ "backspace": ["project_panel::Trash", { "skip_prompt": false }], "delete": ["project_panel::Trash", { "skip_prompt": false }], "shift-delete": ["project_panel::Delete", { "skip_prompt": false }], - "shift-f6": "project_panel::Rename" - } + "shift-f6": "project_panel::Rename", + }, }, { "context": "Terminal", @@ -167,8 +167,8 @@ "ctrl-up": "terminal::ScrollLineUp", "ctrl-down": "terminal::ScrollLineDown", "shift-pageup": "terminal::ScrollPageUp", - "shift-pagedown": "terminal::ScrollPageDown" - } + "shift-pagedown": "terminal::ScrollPageDown", + }, }, { "context": "GitPanel", "bindings": { "alt-0": "workspace::CloseActiveDock" } }, { "context": "ProjectPanel", "bindings": { "alt-1": "workspace::CloseActiveDock" } }, @@ -179,7 +179,7 @@ "context": "Dock || Workspace || OutlinePanel || ProjectPanel || CollabPanel || (Editor && mode == auto_height)", "bindings": { "escape": "editor::ToggleFocus", - "shift-escape": "workspace::CloseActiveDock" - } - } + "shift-escape": "workspace::CloseActiveDock", + }, + }, ] diff --git a/assets/keymaps/linux/sublime_text.json b/assets/keymaps/linux/sublime_text.json index eefd59e5bd1aa48125d0c6e3d662f3cb4e270be7..1d689a6f5841a011768113257afbed2c447669ed 100644 --- a/assets/keymaps/linux/sublime_text.json +++ b/assets/keymaps/linux/sublime_text.json @@ -22,8 +22,8 @@ "ctrl-^": ["workspace::MoveItemToPane", { "destination": 5 }], "ctrl-&": ["workspace::MoveItemToPane", { "destination": 6 }], "ctrl-*": ["workspace::MoveItemToPane", { "destination": 7 }], - "ctrl-(": ["workspace::MoveItemToPane", { "destination": 8 }] - } + "ctrl-(": ["workspace::MoveItemToPane", { "destination": 8 }], + }, }, { "context": "Editor", @@ -55,20 +55,20 @@ "alt-right": "editor::MoveToNextSubwordEnd", "alt-left": "editor::MoveToPreviousSubwordStart", "alt-shift-right": "editor::SelectToNextSubwordEnd", - "alt-shift-left": "editor::SelectToPreviousSubwordStart" - } + "alt-shift-left": "editor::SelectToPreviousSubwordStart", + }, }, { "context": "Editor && mode == full", "bindings": { - "ctrl-r": "outline::Toggle" - } + "ctrl-r": "outline::Toggle", + }, }, { "context": "Editor && !agent_diff", "bindings": { - "ctrl-k ctrl-z": "git::Restore" - } + "ctrl-k ctrl-z": "git::Restore", + }, }, { "context": "Pane", @@ -83,15 +83,15 @@ "alt-6": ["pane::ActivateItem", 5], "alt-7": ["pane::ActivateItem", 6], "alt-8": ["pane::ActivateItem", 7], - "alt-9": "pane::ActivateLastItem" - } + "alt-9": "pane::ActivateLastItem", + }, }, { "context": "Workspace", "bindings": { "ctrl-k ctrl-b": "workspace::ToggleLeftDock", // "ctrl-0": "project_panel::ToggleFocus", // normally resets zoom - "shift-ctrl-r": "project_symbols::Toggle" - } - } + "shift-ctrl-r": "project_symbols::Toggle", + }, + }, ] diff --git a/assets/keymaps/macos/atom.json b/assets/keymaps/macos/atom.json index ca015b667faa05db53d8fdc3bd82352d9bcc62aa..bf049fd3cb3eca8fe8049fa4e0810f82b10a5bbc 100644 --- a/assets/keymaps/macos/atom.json +++ b/assets/keymaps/macos/atom.json @@ -4,16 +4,16 @@ "bindings": { "ctrl-alt-cmd-l": "workspace::Reload", "cmd-k cmd-p": "workspace::ActivatePreviousPane", - "cmd-k cmd-n": "workspace::ActivateNextPane" - } + "cmd-k cmd-n": "workspace::ActivateNextPane", + }, }, { "context": "Editor", "bindings": { "cmd-shift-backspace": "editor::DeleteToBeginningOfLine", "cmd-k cmd-u": "editor::ConvertToUpperCase", - "cmd-k cmd-l": "editor::ConvertToLowerCase" - } + "cmd-k cmd-l": "editor::ConvertToLowerCase", + }, }, { "context": "Editor && mode == full", @@ -33,8 +33,8 @@ "ctrl-cmd-down": "editor::MoveLineDown", "cmd-\\": "workspace::ToggleLeftDock", "ctrl-shift-m": "markdown::OpenPreviewToTheSide", - "cmd-r": "outline::Toggle" - } + "cmd-r": "outline::Toggle", + }, }, { "context": "BufferSearchBar", @@ -42,8 +42,8 @@ "cmd-g": ["editor::SelectNext", { "replace_newest": true }], "cmd-shift-g": ["editor::SelectPrevious", { "replace_newest": true }], "cmd-f3": "search::SelectNextMatch", - "cmd-shift-f3": "search::SelectPreviousMatch" - } + "cmd-shift-f3": "search::SelectPreviousMatch", + }, }, { "context": "Workspace", @@ -51,8 +51,8 @@ "cmd-\\": "workspace::ToggleLeftDock", "cmd-k cmd-b": "workspace::ToggleLeftDock", "cmd-t": "file_finder::Toggle", - "cmd-shift-r": "project_symbols::Toggle" - } + "cmd-shift-r": "project_symbols::Toggle", + }, }, { "context": "Pane", @@ -67,8 +67,8 @@ "cmd-6": ["pane::ActivateItem", 5], "cmd-7": ["pane::ActivateItem", 6], "cmd-8": ["pane::ActivateItem", 7], - "cmd-9": "pane::ActivateLastItem" - } + "cmd-9": "pane::ActivateLastItem", + }, }, { "context": "ProjectPanel", @@ -77,8 +77,8 @@ "backspace": ["project_panel::Trash", { "skip_prompt": false }], "cmd-x": "project_panel::Cut", "cmd-c": "project_panel::Copy", - "cmd-v": "project_panel::Paste" - } + "cmd-v": "project_panel::Paste", + }, }, { "context": "ProjectPanel && not_editing", @@ -92,7 +92,7 @@ "d": "project_panel::Duplicate", "home": "menu::SelectFirst", "end": "menu::SelectLast", - "shift-a": "project_panel::NewDirectory" - } - } + "shift-a": "project_panel::NewDirectory", + }, + }, ] diff --git a/assets/keymaps/macos/cursor.json b/assets/keymaps/macos/cursor.json index 97abc7dd819485850107eca6762fc1ed60ec0515..6a2f46e0ce6d037de6de2d801d80671c63a3e3cd 100644 --- a/assets/keymaps/macos/cursor.json +++ b/assets/keymaps/macos/cursor.json @@ -8,8 +8,8 @@ "cmd-shift-i": "agent::ToggleFocus", "cmd-l": "agent::ToggleFocus", "cmd-shift-l": "agent::ToggleFocus", - "cmd-shift-j": "agent::OpenSettings" - } + "cmd-shift-j": "agent::OpenSettings", + }, }, { "context": "Editor && mode == full", @@ -20,19 +20,19 @@ "cmd-shift-l": "agent::AddSelectionToThread", // In cursor uses "Ask" mode "cmd-l": "agent::AddSelectionToThread", // In cursor uses "Agent" mode "cmd-k": "assistant::InlineAssist", - "cmd-shift-k": "assistant::InsertIntoEditor" - } + "cmd-shift-k": "assistant::InsertIntoEditor", + }, }, { "context": "InlineAssistEditor", "use_key_equivalents": true, "bindings": { "cmd-shift-backspace": "editor::Cancel", - "cmd-enter": "menu::Confirm" + "cmd-enter": "menu::Confirm", // "alt-enter": // Quick Question // "cmd-shift-enter": // Full File Context // "cmd-shift-k": // Toggle input focus (editor <> inline assist) - } + }, }, { "context": "AgentPanel || ContextEditor || (MessageEditor > Editor)", @@ -48,7 +48,7 @@ "cmd-shift-backspace": "editor::Cancel", "cmd-r": "agent::NewThread", "cmd-shift-v": "editor::Paste", - "cmd-shift-k": "assistant::InsertIntoEditor" + "cmd-shift-k": "assistant::InsertIntoEditor", // "escape": "agent::ToggleFocus" ///// Enable when Zed supports multiple thread tabs // "cmd-t": // new thread tab @@ -57,28 +57,28 @@ ///// Enable if Zed adds support for keyboard navigation of thread elements // "tab": // cycle to next message // "shift-tab": // cycle to previous message - } + }, }, { "context": "Editor && editor_agent_diff", "use_key_equivalents": true, "bindings": { "cmd-enter": "agent::KeepAll", - "cmd-backspace": "agent::RejectAll" - } + "cmd-backspace": "agent::RejectAll", + }, }, { "context": "Editor && mode == full && edit_prediction", "use_key_equivalents": true, "bindings": { - "cmd-right": "editor::AcceptPartialEditPrediction" - } + "cmd-right": "editor::AcceptPartialEditPrediction", + }, }, { "context": "Terminal", "use_key_equivalents": true, "bindings": { - "cmd-k": "assistant::InlineAssist" - } - } + "cmd-k": "assistant::InlineAssist", + }, + }, ] diff --git a/assets/keymaps/macos/emacs.json b/assets/keymaps/macos/emacs.json index ea831c0c059ea082d002f3af01b8d97be9e86616..2f11e2ce00e8b60a0f1c85b5aeb204e866491a45 100755 --- a/assets/keymaps/macos/emacs.json +++ b/assets/keymaps/macos/emacs.json @@ -6,8 +6,8 @@ { "context": "!GitPanel", "bindings": { - "ctrl-g": "menu::Cancel" - } + "ctrl-g": "menu::Cancel", + }, }, { // Workaround to avoid falling back to default bindings. @@ -15,8 +15,8 @@ // NOTE: must be declared before the `Editor` override. "context": "Editor", "bindings": { - "ctrl-g": null // currently activates `go_to_line::Toggle` when there is nothing to cancel - } + "ctrl-g": null, // currently activates `go_to_line::Toggle` when there is nothing to cancel + }, }, { "context": "Editor", @@ -79,8 +79,8 @@ "ctrl-s": "buffer_search::Deploy", // isearch-forward "ctrl-r": "buffer_search::Deploy", // isearch-backward "alt-^": "editor::JoinLines", // join-line - "alt-q": "editor::Rewrap" // fill-paragraph - } + "alt-q": "editor::Rewrap", // fill-paragraph + }, }, { "context": "Editor && selection_mode", // region selection @@ -116,22 +116,22 @@ "alt->": "editor::SelectToEnd", "ctrl-home": "editor::SelectToBeginning", "ctrl-end": "editor::SelectToEnd", - "ctrl-g": "editor::Cancel" - } + "ctrl-g": "editor::Cancel", + }, }, { "context": "Editor && (showing_code_actions || showing_completions)", "bindings": { "ctrl-p": "editor::ContextMenuPrevious", - "ctrl-n": "editor::ContextMenuNext" - } + "ctrl-n": "editor::ContextMenuNext", + }, }, { "context": "Editor && showing_signature_help && !showing_completions", "bindings": { "ctrl-p": "editor::SignatureHelpPrevious", - "ctrl-n": "editor::SignatureHelpNext" - } + "ctrl-n": "editor::SignatureHelpNext", + }, }, // Example setting for using emacs-style tab // (i.e. indent the current line / selection or perform symbol completion depending on context) @@ -161,8 +161,8 @@ "ctrl-x ctrl-f": "file_finder::Toggle", // find-file "ctrl-x ctrl-s": "workspace::Save", // save-buffer "ctrl-x ctrl-w": "workspace::SaveAs", // write-file - "ctrl-x s": "workspace::SaveAll" // save-some-buffers - } + "ctrl-x s": "workspace::SaveAll", // save-some-buffers + }, }, { // Workaround to enable using native emacs from the Zed terminal. @@ -182,22 +182,22 @@ "ctrl-x ctrl-f": null, // find-file "ctrl-x ctrl-s": null, // save-buffer "ctrl-x ctrl-w": null, // write-file - "ctrl-x s": null // save-some-buffers - } + "ctrl-x s": null, // save-some-buffers + }, }, { "context": "BufferSearchBar > Editor", "bindings": { "ctrl-s": "search::SelectNextMatch", "ctrl-r": "search::SelectPreviousMatch", - "ctrl-g": "buffer_search::Dismiss" - } + "ctrl-g": "buffer_search::Dismiss", + }, }, { "context": "Pane", "bindings": { "ctrl-alt-left": "pane::GoBack", - "ctrl-alt-right": "pane::GoForward" - } - } + "ctrl-alt-right": "pane::GoForward", + }, + }, ] diff --git a/assets/keymaps/macos/jetbrains.json b/assets/keymaps/macos/jetbrains.json index 364f489167f5abb9af21d9f005586bde08439850..1721a9d743a67abddbc55a4b505be497920d15aa 100644 --- a/assets/keymaps/macos/jetbrains.json +++ b/assets/keymaps/macos/jetbrains.json @@ -13,8 +13,8 @@ "shift-f8": "debugger::StepOut", "f9": "debugger::Continue", "shift-f9": "debugger::Start", - "alt-shift-f9": "debugger::Start" - } + "alt-shift-f9": "debugger::Start", + }, }, { "context": "Editor", @@ -60,8 +60,8 @@ "cmd-shift-end": "editor::SelectToEnd", "ctrl-f8": "editor::ToggleBreakpoint", "ctrl-shift-f8": "editor::EditLogBreakpoint", - "cmd-shift-u": "editor::ToggleCase" - } + "cmd-shift-u": "editor::ToggleCase", + }, }, { "context": "Editor && mode == full", @@ -74,14 +74,14 @@ "ctrl-space": "editor::ShowCompletions", "cmd-j": "editor::Hover", "cmd-p": "editor::ShowSignatureHelp", - "cmd-\\": "assistant::InlineAssist" - } + "cmd-\\": "assistant::InlineAssist", + }, }, { "context": "BufferSearchBar", "bindings": { - "shift-enter": "search::SelectPreviousMatch" - } + "shift-enter": "search::SelectPreviousMatch", + }, }, { "context": "BufferSearchBar || ProjectSearchBar", @@ -93,8 +93,8 @@ "ctrl-alt-c": "search::ToggleCaseSensitive", "ctrl-alt-e": "search::ToggleSelection", "ctrl-alt-w": "search::ToggleWholeWord", - "ctrl-alt-x": "search::ToggleRegex" - } + "ctrl-alt-x": "search::ToggleRegex", + }, }, { "context": "Workspace", @@ -116,8 +116,8 @@ "cmd-1": "project_panel::ToggleFocus", "cmd-5": "debug_panel::ToggleFocus", "cmd-6": "diagnostics::Deploy", - "cmd-7": "outline_panel::ToggleFocus" - } + "cmd-7": "outline_panel::ToggleFocus", + }, }, { "context": "Pane", // this is to override the default Pane mappings to switch tabs @@ -131,15 +131,15 @@ "cmd-7": "outline_panel::ToggleFocus", "cmd-8": null, // Services (bottom dock) "cmd-9": null, // Git History (bottom dock) - "cmd-0": "git_panel::ToggleFocus" - } + "cmd-0": "git_panel::ToggleFocus", + }, }, { "context": "Workspace || Editor", "bindings": { "alt-f12": "terminal_panel::Toggle", - "cmd-shift-k": "git::Push" - } + "cmd-shift-k": "git::Push", + }, }, { "context": "Pane", @@ -147,8 +147,8 @@ "cmd-alt-left": "pane::GoBack", "cmd-alt-right": "pane::GoForward", "alt-left": "pane::ActivatePreviousItem", - "alt-right": "pane::ActivateNextItem" - } + "alt-right": "pane::ActivateNextItem", + }, }, { "context": "ProjectPanel", @@ -159,8 +159,8 @@ "backspace": ["project_panel::Trash", { "skip_prompt": false }], "delete": ["project_panel::Trash", { "skip_prompt": false }], "shift-delete": ["project_panel::Delete", { "skip_prompt": false }], - "shift-f6": "project_panel::Rename" - } + "shift-f6": "project_panel::Rename", + }, }, { "context": "Terminal", @@ -170,8 +170,8 @@ "cmd-up": "terminal::ScrollLineUp", "cmd-down": "terminal::ScrollLineDown", "shift-pageup": "terminal::ScrollPageUp", - "shift-pagedown": "terminal::ScrollPageDown" - } + "shift-pagedown": "terminal::ScrollPageDown", + }, }, { "context": "GitPanel", "bindings": { "cmd-0": "workspace::CloseActiveDock" } }, { "context": "ProjectPanel", "bindings": { "cmd-1": "workspace::CloseActiveDock" } }, @@ -182,7 +182,7 @@ "context": "Dock || Workspace || OutlinePanel || ProjectPanel || CollabPanel || (Editor && mode == auto_height)", "bindings": { "escape": "editor::ToggleFocus", - "shift-escape": "workspace::CloseActiveDock" - } - } + "shift-escape": "workspace::CloseActiveDock", + }, + }, ] diff --git a/assets/keymaps/macos/sublime_text.json b/assets/keymaps/macos/sublime_text.json index d1bffca755b611d9046d4b7e794d2303835227a2..f4ae1ce5dda4e2c0dd21e97bd3a411dd4a4f3663 100644 --- a/assets/keymaps/macos/sublime_text.json +++ b/assets/keymaps/macos/sublime_text.json @@ -22,8 +22,8 @@ "ctrl-^": ["workspace::MoveItemToPane", { "destination": 5 }], "ctrl-&": ["workspace::MoveItemToPane", { "destination": 6 }], "ctrl-*": ["workspace::MoveItemToPane", { "destination": 7 }], - "ctrl-(": ["workspace::MoveItemToPane", { "destination": 8 }] - } + "ctrl-(": ["workspace::MoveItemToPane", { "destination": 8 }], + }, }, { "context": "Editor", @@ -57,20 +57,20 @@ "ctrl-right": "editor::MoveToNextSubwordEnd", "ctrl-left": "editor::MoveToPreviousSubwordStart", "ctrl-shift-right": "editor::SelectToNextSubwordEnd", - "ctrl-shift-left": "editor::SelectToPreviousSubwordStart" - } + "ctrl-shift-left": "editor::SelectToPreviousSubwordStart", + }, }, { "context": "Editor && mode == full", "bindings": { - "cmd-r": "outline::Toggle" - } + "cmd-r": "outline::Toggle", + }, }, { "context": "Editor && !agent_diff", "bindings": { - "cmd-k cmd-z": "git::Restore" - } + "cmd-k cmd-z": "git::Restore", + }, }, { "context": "Pane", @@ -85,8 +85,8 @@ "cmd-6": ["pane::ActivateItem", 5], "cmd-7": ["pane::ActivateItem", 6], "cmd-8": ["pane::ActivateItem", 7], - "cmd-9": "pane::ActivateLastItem" - } + "cmd-9": "pane::ActivateLastItem", + }, }, { "context": "Workspace", @@ -95,7 +95,7 @@ "cmd-t": "file_finder::Toggle", "shift-cmd-r": "project_symbols::Toggle", // Currently busted: https://github.com/zed-industries/feedback/issues/898 - "ctrl-0": "project_panel::ToggleFocus" - } - } + "ctrl-0": "project_panel::ToggleFocus", + }, + }, ] diff --git a/assets/keymaps/macos/textmate.json b/assets/keymaps/macos/textmate.json index f91f39b7f5c079f81b5fcf8e28e2092a33ff1aa4..90450e60af7147f1394eb6cb4c1efc389edad2d0 100644 --- a/assets/keymaps/macos/textmate.json +++ b/assets/keymaps/macos/textmate.json @@ -2,8 +2,8 @@ { "bindings": { "cmd-shift-o": "projects::OpenRecent", - "cmd-alt-tab": "project_panel::ToggleFocus" - } + "cmd-alt-tab": "project_panel::ToggleFocus", + }, }, { "context": "Editor && mode == full", @@ -15,8 +15,8 @@ "cmd-enter": "editor::NewlineBelow", "cmd-alt-enter": "editor::NewlineAbove", "cmd-shift-l": "editor::SelectLine", - "cmd-shift-t": "outline::Toggle" - } + "cmd-shift-t": "outline::Toggle", + }, }, { "context": "Editor", @@ -41,30 +41,30 @@ "ctrl-u": "editor::ConvertToUpperCase", "ctrl-shift-u": "editor::ConvertToLowerCase", "ctrl-alt-u": "editor::ConvertToUpperCamelCase", - "ctrl-_": "editor::ConvertToSnakeCase" - } + "ctrl-_": "editor::ConvertToSnakeCase", + }, }, { "context": "BufferSearchBar", "bindings": { "ctrl-s": "search::SelectNextMatch", - "ctrl-shift-s": "search::SelectPreviousMatch" - } + "ctrl-shift-s": "search::SelectPreviousMatch", + }, }, { "context": "Workspace", "bindings": { "cmd-alt-ctrl-d": "workspace::ToggleLeftDock", "cmd-t": "file_finder::Toggle", - "cmd-shift-t": "project_symbols::Toggle" - } + "cmd-shift-t": "project_symbols::Toggle", + }, }, { "context": "Pane", "bindings": { "alt-cmd-r": "search::ToggleRegex", - "ctrl-tab": "project_panel::ToggleFocus" - } + "ctrl-tab": "project_panel::ToggleFocus", + }, }, { "context": "ProjectPanel", @@ -75,11 +75,11 @@ "return": "project_panel::Rename", "cmd-c": "project_panel::Copy", "cmd-v": "project_panel::Paste", - "cmd-alt-c": "project_panel::CopyPath" - } + "cmd-alt-c": "project_panel::CopyPath", + }, }, { "context": "Dock", - "bindings": {} - } + "bindings": {}, + }, ] diff --git a/assets/keymaps/storybook.json b/assets/keymaps/storybook.json index 9b92fbe1a3844043e379647d1dd6c57e082fdf77..432bdc7004a4c66b52e20282aba924611b204aa1 100644 --- a/assets/keymaps/storybook.json +++ b/assets/keymaps/storybook.json @@ -27,7 +27,7 @@ "backspace": "editor::Backspace", "delete": "editor::Delete", "left": "editor::MoveLeft", - "right": "editor::MoveRight" - } - } + "right": "editor::MoveRight", + }, + }, ] diff --git a/assets/settings/initial_debug_tasks.json b/assets/settings/initial_debug_tasks.json index af4512bd51aa82d57ce62e605b45ee61e8f98030..851289392a65aecfca17e00d4c123823ac9e21cb 100644 --- a/assets/settings/initial_debug_tasks.json +++ b/assets/settings/initial_debug_tasks.json @@ -8,7 +8,7 @@ "adapter": "Debugpy", "program": "$ZED_FILE", "request": "launch", - "cwd": "$ZED_WORKTREE_ROOT" + "cwd": "$ZED_WORKTREE_ROOT", }, { "label": "Debug active JavaScript file", @@ -16,7 +16,7 @@ "program": "$ZED_FILE", "request": "launch", "cwd": "$ZED_WORKTREE_ROOT", - "type": "pwa-node" + "type": "pwa-node", }, { "label": "JavaScript debug terminal", @@ -24,6 +24,6 @@ "request": "launch", "cwd": "$ZED_WORKTREE_ROOT", "console": "integratedTerminal", - "type": "pwa-node" - } + "type": "pwa-node", + }, ] diff --git a/assets/settings/initial_server_settings.json b/assets/settings/initial_server_settings.json index d6ec33e60128380378610a273a1bbdff1ecdbaa8..29aa569b105157df7ec48164e2066fdac72c7b41 100644 --- a/assets/settings/initial_server_settings.json +++ b/assets/settings/initial_server_settings.json @@ -3,5 +3,5 @@ // For a full list of overridable settings, and general information on settings, // see the documentation: https://zed.dev/docs/configuring-zed#settings-files { - "lsp": {} + "lsp": {}, } diff --git a/assets/settings/initial_tasks.json b/assets/settings/initial_tasks.json index a79e98063237ca297a89b0d151bd48149061b7bb..5bedafbd3a1e75a755598e37cd673742e146fdcc 100644 --- a/assets/settings/initial_tasks.json +++ b/assets/settings/initial_tasks.json @@ -47,8 +47,8 @@ // Whether to show the task line in the output of the spawned task, defaults to `true`. "show_summary": true, // Whether to show the command line in the output of the spawned task, defaults to `true`. - "show_command": true + "show_command": true, // Represents the tags for inline runnable indicators, or spawning multiple tasks at once. // "tags": [] - } + }, ] diff --git a/assets/settings/initial_user_settings.json b/assets/settings/initial_user_settings.json index 5ac2063bdb481e057a2d124c1e72f998390b066b..8b573854895a03243803a71a91a35af647f45ca2 100644 --- a/assets/settings/initial_user_settings.json +++ b/assets/settings/initial_user_settings.json @@ -12,6 +12,6 @@ "theme": { "mode": "system", "light": "One Light", - "dark": "One Dark" - } + "dark": "One Dark", + }, } From 632bd378ba711022953e9960c0fdb1501ef7e2d7 Mon Sep 17 00:00:00 2001 From: Marco Mihai Condrache <52580954+marcocondrache@users.noreply.github.com> Date: Mon, 15 Dec 2025 16:31:15 +0100 Subject: [PATCH 299/621] git_ui: Reset the project diff at the start when it is deployed again (#43579) Closes #26920 Release Notes: - Clicking the 'changes' button now resets the diff at the beginning --------- Signed-off-by: Marco Mihai Condrache <52580954+marcocondrache@users.noreply.github.com> --- crates/git_ui/src/project_diff.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/crates/git_ui/src/project_diff.rs b/crates/git_ui/src/project_diff.rs index 3f689567327e280f7e9911699e10159340ddb8d5..4d7a27354b1b4b6e972579e73c48bcd4c2448a5c 100644 --- a/crates/git_ui/src/project_diff.rs +++ b/crates/git_ui/src/project_diff.rs @@ -156,6 +156,10 @@ impl ProjectDiff { .items_of_type::(cx) .find(|item| matches!(item.read(cx).diff_base(cx), DiffBase::Head)); let project_diff = if let Some(existing) = existing { + existing.update(cx, |project_diff, cx| { + project_diff.move_to_beginning(window, cx); + }); + workspace.activate_item(&existing, true, true, window, cx); existing } else { @@ -365,6 +369,14 @@ impl ProjectDiff { }) } + fn move_to_beginning(&mut self, window: &mut Window, cx: &mut Context) { + self.editor.update(cx, |editor, cx| { + editor.primary_editor().update(cx, |editor, cx| { + editor.move_to_beginning(&Default::default(), window, cx); + }); + }); + } + fn move_to_path(&mut self, path_key: PathKey, window: &mut Window, cx: &mut Context) { if let Some(position) = self.multibuffer.read(cx).location_for_path(&path_key, cx) { self.editor.update(cx, |editor, cx| { From 03216c9800d4155d0642a63641800e36572ae7a2 Mon Sep 17 00:00:00 2001 From: Mayank Verma Date: Mon, 15 Dec 2025 21:02:13 +0530 Subject: [PATCH 300/621] git_ui: Display correct provider for view on remote button (#44738) Closes #44729 Release Notes: - Fixed incorrect provider shown in "view on remote" button --- crates/git_ui/src/commit_view.rs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/crates/git_ui/src/commit_view.rs b/crates/git_ui/src/commit_view.rs index b83ad6d8a6ddab467eb32c31cbc67810b9f74247..8cb9d82826086371950d2c51fd06381dd013251f 100644 --- a/crates/git_ui/src/commit_view.rs +++ b/crates/git_ui/src/commit_view.rs @@ -391,14 +391,16 @@ impl CommitView { time_format::TimestampFormat::MediumAbsolute, ); - let github_url = self.remote.as_ref().map(|remote| { - format!( + let remote_info = self.remote.as_ref().map(|remote| { + let provider = remote.host.name(); + let url = format!( "{}/{}/{}/commit/{}", remote.host.base_url(), remote.owner, remote.repo, commit.sha - ) + ); + (provider, url) }); let (additions, deletions) = self.calculate_changed_lines(cx); @@ -472,9 +474,14 @@ impl CommitView { .children(commit_diff_stat), ), ) - .children(github_url.map(|url| { - Button::new("view_on_github", "View on GitHub") - .icon(IconName::Github) + .children(remote_info.map(|(provider_name, url)| { + let icon = match provider_name.as_str() { + "GitHub" => IconName::Github, + _ => IconName::Link, + }; + + Button::new("view_on_provider", format!("View on {}", provider_name)) + .icon(icon) .icon_color(Color::Muted) .icon_size(IconSize::Small) .icon_position(IconPosition::Start) From 79a8985a8e6ee98f1783a39496adf9f6dbc24701 Mon Sep 17 00:00:00 2001 From: 0x2CA <2478557459@qq.com> Date: Mon, 15 Dec 2025 23:40:37 +0800 Subject: [PATCH 301/621] vim: Add scroll keybindings for the OutlinePanel (#42438) Closes #ISSUE ```json { "context": "OutlinePanel && not_editing", "bindings": { "enter": "editor::ToggleFocus", "/": "menu::Cancel", "ctrl-u": "outline_panel::ScrollUp", "ctrl-d": "outline_panel::ScrollDown", "z t": "outline_panel::ScrollCursorTop", "z z": "outline_panel::ScrollCursorCenter", "z b": "outline_panel::ScrollCursorBottom" } }, { "context": "OutlinePanel && editing", "bindings": { "enter": "menu::Cancel" } }, ``` Release Notes: - Added scroll keybindings for the OutlinePanel --------- Co-authored-by: Ben Kunkle --- Cargo.lock | 1 + assets/keymaps/vim.json | 32 ++++++++- crates/outline_panel/src/outline_panel.rs | 82 +++++++++++++++++++++++ crates/vim/Cargo.toml | 1 + crates/vim/src/test/vim_test_context.rs | 1 + 5 files changed, 115 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1dfcabfb552e128dfa6b0b47ebb5f33bfa2aa4a6..8c1ade1714c9dd7f609582cc8bdf5184678afcd9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -18138,6 +18138,7 @@ dependencies = [ "menu", "multi_buffer", "nvim-rs", + "outline_panel", "parking_lot", "perf", "picker", diff --git a/assets/keymaps/vim.json b/assets/keymaps/vim.json index bbae6e2f4d738ef60b3a1a5ba33a26a9ab68f497..0097480e2775a1048452b2a5e8ec826525da3f2e 100644 --- a/assets/keymaps/vim.json +++ b/assets/keymaps/vim.json @@ -970,10 +970,38 @@ { "context": "OutlinePanel && not_editing", "bindings": { - "j": "menu::SelectNext", - "k": "menu::SelectPrevious", + "h": "outline_panel::CollapseSelectedEntry", + "j": "vim::MenuSelectNext", + "k": "vim::MenuSelectPrevious", + "down": "vim::MenuSelectNext", + "up": "vim::MenuSelectPrevious", + "l": "outline_panel::ExpandSelectedEntry", "shift-g": "menu::SelectLast", "g g": "menu::SelectFirst", + "-": "outline_panel::SelectParent", + "enter": "editor::ToggleFocus", + "/": "menu::Cancel", + "ctrl-u": "outline_panel::ScrollUp", + "ctrl-d": "outline_panel::ScrollDown", + "z t": "outline_panel::ScrollCursorTop", + "z z": "outline_panel::ScrollCursorCenter", + "z b": "outline_panel::ScrollCursorBottom", + "0": ["vim::Number", 0], + "1": ["vim::Number", 1], + "2": ["vim::Number", 2], + "3": ["vim::Number", 3], + "4": ["vim::Number", 4], + "5": ["vim::Number", 5], + "6": ["vim::Number", 6], + "7": ["vim::Number", 7], + "8": ["vim::Number", 8], + "9": ["vim::Number", 9], + }, + }, + { + "context": "OutlinePanel && editing", + "bindings": { + "enter": "menu::Cancel", }, }, { diff --git a/crates/outline_panel/src/outline_panel.rs b/crates/outline_panel/src/outline_panel.rs index 943025b1d0a96692f34f2ebcefff83a0ad2ddaee..8dbf7b681d9be45bda0fd9803cbb8e2cd434e921 100644 --- a/crates/outline_panel/src/outline_panel.rs +++ b/crates/outline_panel/src/outline_panel.rs @@ -75,6 +75,16 @@ actions!( OpenSelectedEntry, /// Reveals the selected item in the system file manager. RevealInFileManager, + /// Scroll half a page upwards + ScrollUp, + /// Scroll half a page downwards + ScrollDown, + /// Scroll until the cursor displays at the center + ScrollCursorCenter, + /// Scroll until the cursor displays at the top + ScrollCursorTop, + /// Scroll until the cursor displays at the bottom + ScrollCursorBottom, /// Selects the parent of the current entry. SelectParent, /// Toggles the pin status of the active editor. @@ -100,6 +110,7 @@ pub struct OutlinePanel { active: bool, pinned: bool, scroll_handle: UniformListScrollHandle, + rendered_entries_len: usize, context_menu: Option<(Entity, Point, Subscription)>, focus_handle: FocusHandle, pending_serialization: Task>, @@ -839,6 +850,7 @@ impl OutlinePanel { fs: workspace.app_state().fs.clone(), max_width_item_index: None, scroll_handle, + rendered_entries_len: 0, focus_handle, filter_editor, fs_entries: Vec::new(), @@ -1149,6 +1161,70 @@ impl OutlinePanel { } } + fn scroll_up(&mut self, _: &ScrollUp, window: &mut Window, cx: &mut Context) { + for _ in 0..self.rendered_entries_len / 2 { + window.dispatch_action(SelectPrevious.boxed_clone(), cx); + } + } + + fn scroll_down(&mut self, _: &ScrollDown, window: &mut Window, cx: &mut Context) { + for _ in 0..self.rendered_entries_len / 2 { + window.dispatch_action(SelectNext.boxed_clone(), cx); + } + } + + fn scroll_cursor_center( + &mut self, + _: &ScrollCursorCenter, + _: &mut Window, + cx: &mut Context, + ) { + if let Some(selected_entry) = self.selected_entry() { + let index = self + .cached_entries + .iter() + .position(|cached_entry| &cached_entry.entry == selected_entry); + if let Some(index) = index { + self.scroll_handle + .scroll_to_item_strict(index, ScrollStrategy::Center); + cx.notify(); + } + } + } + + fn scroll_cursor_top(&mut self, _: &ScrollCursorTop, _: &mut Window, cx: &mut Context) { + if let Some(selected_entry) = self.selected_entry() { + let index = self + .cached_entries + .iter() + .position(|cached_entry| &cached_entry.entry == selected_entry); + if let Some(index) = index { + self.scroll_handle + .scroll_to_item_strict(index, ScrollStrategy::Top); + cx.notify(); + } + } + } + + fn scroll_cursor_bottom( + &mut self, + _: &ScrollCursorBottom, + _: &mut Window, + cx: &mut Context, + ) { + if let Some(selected_entry) = self.selected_entry() { + let index = self + .cached_entries + .iter() + .position(|cached_entry| &cached_entry.entry == selected_entry); + if let Some(index) = index { + self.scroll_handle + .scroll_to_item_strict(index, ScrollStrategy::Bottom); + cx.notify(); + } + } + } + fn select_next(&mut self, _: &SelectNext, window: &mut Window, cx: &mut Context) { if let Some(entry_to_select) = self.selected_entry().and_then(|selected_entry| { self.cached_entries @@ -4578,6 +4654,7 @@ impl OutlinePanel { "entries", items_len, cx.processor(move |outline_panel, range: Range, window, cx| { + outline_panel.rendered_entries_len = range.end - range.start; let entries = outline_panel.cached_entries.get(range); entries .map(|entries| entries.to_vec()) @@ -4970,7 +5047,12 @@ impl Render for OutlinePanel { .key_context(self.dispatch_context(window, cx)) .on_action(cx.listener(Self::open_selected_entry)) .on_action(cx.listener(Self::cancel)) + .on_action(cx.listener(Self::scroll_up)) + .on_action(cx.listener(Self::scroll_down)) .on_action(cx.listener(Self::select_next)) + .on_action(cx.listener(Self::scroll_cursor_center)) + .on_action(cx.listener(Self::scroll_cursor_top)) + .on_action(cx.listener(Self::scroll_cursor_bottom)) .on_action(cx.listener(Self::select_previous)) .on_action(cx.listener(Self::select_first)) .on_action(cx.listener(Self::select_last)) diff --git a/crates/vim/Cargo.toml b/crates/vim/Cargo.toml index 74409a6c255645378b0b2829f4d0045776bfa019..2db1b51e72fcd862ccb1c35ff920fec7dbd47995 100644 --- a/crates/vim/Cargo.toml +++ b/crates/vim/Cargo.toml @@ -66,6 +66,7 @@ lsp = { workspace = true, features = ["test-support"] } markdown_preview.workspace = true parking_lot.workspace = true project_panel.workspace = true +outline_panel.workspace = true release_channel.workspace = true semver.workspace = true settings_ui.workspace = true diff --git a/crates/vim/src/test/vim_test_context.rs b/crates/vim/src/test/vim_test_context.rs index acd77839f2d8cc09ed72993638ff4ec66f79d3fc..2d5ed4227dcc263f56cfa0bcb337f5673df8ef3c 100644 --- a/crates/vim/src/test/vim_test_context.rs +++ b/crates/vim/src/test/vim_test_context.rs @@ -23,6 +23,7 @@ impl VimTestContext { release_channel::init(Version::new(0, 0, 0), cx); command_palette::init(cx); project_panel::init(cx); + outline_panel::init(cx); git_ui::init(cx); crate::init(cx); search::init(cx); From d52defe35a6e5fde07257a67e049383437f538f1 Mon Sep 17 00:00:00 2001 From: Freddy Fallon Date: Mon, 15 Dec 2025 15:55:54 +0000 Subject: [PATCH 302/621] Fix vitest test running and debugging for v4 with backwards compatibility (#43241) ## Summary This PR updates the vitest test runner integration to use the modern `--no-file-parallelism` flag instead of the deprecated `--poolOptions.forks.minForks=0` and `--poolOptions.forks.maxForks=1` flags. ## Changes - Replaced verbose pool options with `--no-file-parallelism` flag in both file-level and symbol-level vitest test tasks - This change works with vitest v4 while maintaining backwards compatibility with earlier versions (or 3 at least!) ## Testing - Added test `test_vitest_uses_no_file_parallelism_flag` that verifies: - The `--no-file-parallelism` flag is present in generated test tasks - The deprecated `poolOptions` flags are not present - Manually tested with both vitest v4 and older versions to confirm backwards compatibility - All existing tests pass ## Impact This allows Zed users to run and debug vitest tests in projects using vitest v4 while maintaining support for earlier versions. Release Notes: - Fixed vitest test running and debugging for projects using vitest v4 --------- Co-authored-by: Cole Miller --- crates/languages/src/typescript.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/crates/languages/src/typescript.rs b/crates/languages/src/typescript.rs index a7aa1bc49c0132b01d0fe45d94a29af4efac6602..7daf178d37229a5b051461e199c3dbf8d830cf22 100644 --- a/crates/languages/src/typescript.rs +++ b/crates/languages/src/typescript.rs @@ -111,8 +111,7 @@ impl PackageJsonData { "--".to_owned(), "vitest".to_owned(), "run".to_owned(), - "--poolOptions.forks.minForks=0".to_owned(), - "--poolOptions.forks.maxForks=1".to_owned(), + "--no-file-parallelism".to_owned(), VariableName::File.template_value(), ], cwd: Some(TYPESCRIPT_VITEST_PACKAGE_PATH_VARIABLE.template_value()), @@ -130,8 +129,7 @@ impl PackageJsonData { "--".to_owned(), "vitest".to_owned(), "run".to_owned(), - "--poolOptions.forks.minForks=0".to_owned(), - "--poolOptions.forks.maxForks=1".to_owned(), + "--no-file-parallelism".to_owned(), "--testNamePattern".to_owned(), format!( "\"{}\"", From b92201922123faf0ac627998229afc3a0437970e Mon Sep 17 00:00:00 2001 From: feeiyu <158308373+feeiyu@users.noreply.github.com> Date: Tue, 16 Dec 2025 00:01:07 +0800 Subject: [PATCH 303/621] git_ui: Make the file history view keyboard navigable (#44328) ![file_history_view_navigation](https://github.com/user-attachments/assets/1435fdae-806e-48d1-a031-2c0fec28725f) Release Notes: - git: Made the file history view keyboard navigable --- crates/git_ui/src/file_history_view.rs | 117 +++++++++++++++++++++---- 1 file changed, 99 insertions(+), 18 deletions(-) diff --git a/crates/git_ui/src/file_history_view.rs b/crates/git_ui/src/file_history_view.rs index 5b3588d29678ec406749ec45be3de154fd71c5f8..4e91fe7e06a5823caac5bf00be8f48cc98dc8da4 100644 --- a/crates/git_ui/src/file_history_view.rs +++ b/crates/git_ui/src/file_history_view.rs @@ -4,7 +4,8 @@ use git::repository::{FileHistory, FileHistoryEntry, RepoPath}; use git::{GitHostingProviderRegistry, GitRemote, parse_git_remote_url}; use gpui::{ AnyElement, AnyEntity, App, Asset, Context, Entity, EventEmitter, FocusHandle, Focusable, - IntoElement, Render, Task, UniformListScrollHandle, WeakEntity, Window, actions, uniform_list, + IntoElement, Render, ScrollStrategy, Task, UniformListScrollHandle, WeakEntity, Window, + actions, uniform_list, }; use project::{ Project, ProjectPath, @@ -191,6 +192,93 @@ impl FileHistoryView { task.detach(); } + fn select_next(&mut self, _: &menu::SelectNext, _: &mut Window, cx: &mut Context) { + let entry_count = self.history.entries.len(); + let ix = match self.selected_entry { + _ if entry_count == 0 => None, + None => Some(0), + Some(ix) => { + if ix == entry_count - 1 { + Some(0) + } else { + Some(ix + 1) + } + } + }; + self.select_ix(ix, cx); + } + + fn select_previous( + &mut self, + _: &menu::SelectPrevious, + _: &mut Window, + cx: &mut Context, + ) { + let entry_count = self.history.entries.len(); + let ix = match self.selected_entry { + _ if entry_count == 0 => None, + None => Some(entry_count - 1), + Some(ix) => { + if ix == 0 { + Some(entry_count - 1) + } else { + Some(ix - 1) + } + } + }; + self.select_ix(ix, cx); + } + + fn select_first(&mut self, _: &menu::SelectFirst, _: &mut Window, cx: &mut Context) { + let entry_count = self.history.entries.len(); + let ix = if entry_count != 0 { Some(0) } else { None }; + self.select_ix(ix, cx); + } + + fn select_last(&mut self, _: &menu::SelectLast, _: &mut Window, cx: &mut Context) { + let entry_count = self.history.entries.len(); + let ix = if entry_count != 0 { + Some(entry_count - 1) + } else { + None + }; + self.select_ix(ix, cx); + } + + fn select_ix(&mut self, ix: Option, cx: &mut Context) { + self.selected_entry = ix; + if let Some(ix) = ix { + self.scroll_handle.scroll_to_item(ix, ScrollStrategy::Top); + } + cx.notify(); + } + + fn confirm(&mut self, _: &menu::Confirm, window: &mut Window, cx: &mut Context) { + self.open_commit_view(window, cx); + } + + fn open_commit_view(&mut self, window: &mut Window, cx: &mut Context) { + let Some(entry) = self + .selected_entry + .and_then(|ix| self.history.entries.get(ix)) + else { + return; + }; + + if let Some(repo) = self.repository.upgrade() { + let sha_str = entry.sha.to_string(); + CommitView::open( + sha_str, + repo.downgrade(), + self.workspace.clone(), + None, + Some(self.history.path.clone()), + window, + cx, + ); + } + } + fn render_commit_avatar( &self, sha: &SharedString, @@ -245,12 +333,8 @@ impl FileHistoryView { time_format::TimestampFormat::Relative, ); - let sha = entry.sha.clone(); - let repo = self.repository.clone(); - let workspace = self.workspace.clone(); - let file_path = self.history.path.clone(); - ListItem::new(("commit", ix)) + .toggle_state(Some(ix) == self.selected_entry) .child( h_flex() .h_8() @@ -301,18 +385,7 @@ impl FileHistoryView { this.selected_entry = Some(ix); cx.notify(); - if let Some(repo) = repo.upgrade() { - let sha_str = sha.to_string(); - CommitView::open( - sha_str, - repo.downgrade(), - workspace.clone(), - None, - Some(file_path.clone()), - window, - cx, - ); - } + this.open_commit_view(window, cx); })) .into_any_element() } @@ -380,6 +453,14 @@ impl Render for FileHistoryView { let entry_count = self.history.entries.len(); v_flex() + .id("file_history_view") + .key_context("FileHistoryView") + .track_focus(&self.focus_handle) + .on_action(cx.listener(Self::select_next)) + .on_action(cx.listener(Self::select_previous)) + .on_action(cx.listener(Self::select_first)) + .on_action(cx.listener(Self::select_last)) + .on_action(cx.listener(Self::confirm)) .size_full() .bg(cx.theme().colors().editor_background) .child( From f2f3d9faf6f22aa4995f2df045286068b693d5c2 Mon Sep 17 00:00:00 2001 From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Date: Mon, 15 Dec 2025 13:02:01 -0300 Subject: [PATCH 304/621] Add adjustments to agent v2 pane changes (#44885) Follow-up to https://github.com/zed-industries/zed/pull/44190. Release Notes: - N/A --- assets/icons/zed_agent_two.svg | 5 ++ crates/agent_ui_v2/src/agent_thread_pane.rs | 99 ++++++++++----------- crates/agent_ui_v2/src/agents_panel.rs | 2 +- crates/icons/src/icons.rs | 1 + crates/ui/src/components/tab_bar.rs | 1 + crates/workspace/src/pane.rs | 74 ++++++++++----- 6 files changed, 107 insertions(+), 75 deletions(-) create mode 100644 assets/icons/zed_agent_two.svg diff --git a/assets/icons/zed_agent_two.svg b/assets/icons/zed_agent_two.svg new file mode 100644 index 0000000000000000000000000000000000000000..c352be84d2f1bea6da1f6a5be70b9420f019b6d6 --- /dev/null +++ b/assets/icons/zed_agent_two.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/crates/agent_ui_v2/src/agent_thread_pane.rs b/crates/agent_ui_v2/src/agent_thread_pane.rs index cfe861ef09c51af511554b3d15a1c810a793ed15..72886f87eca38c630ec29b9b410930f1d3936b50 100644 --- a/crates/agent_ui_v2/src/agent_thread_pane.rs +++ b/crates/agent_ui_v2/src/agent_thread_pane.rs @@ -13,13 +13,12 @@ use settings::DockSide; use settings::Settings as _; use std::rc::Rc; use std::sync::Arc; -use ui::{ - App, Clickable as _, Context, DynamicSpacing, IconButton, IconName, IconSize, IntoElement, - Label, LabelCommon as _, LabelSize, Render, Tab, Window, div, +use ui::{Tab, Tooltip, prelude::*}; +use workspace::{ + Workspace, + dock::{ClosePane, MinimizePane, UtilityPane, UtilityPanePosition}, + utility_pane::UtilityPaneSlot, }; -use workspace::Workspace; -use workspace::dock::{ClosePane, MinimizePane, UtilityPane, UtilityPanePosition}; -use workspace::utility_pane::UtilityPaneSlot; pub const DEFAULT_UTILITY_PANE_WIDTH: Pixels = gpui::px(400.0); @@ -169,58 +168,56 @@ impl AgentThreadPane { let toggle_icon = self.toggle_icon(cx); let title = self.title(cx); - let make_toggle_button = |workspace: WeakEntity, cx: &App| { - div().px(DynamicSpacing::Base06.rems(cx)).child( - IconButton::new("toggle_utility_pane", toggle_icon) - .icon_size(IconSize::Small) - .on_click(move |_, window, cx| { - workspace - .update(cx, |workspace, cx| { - workspace.toggle_utility_pane(slot, window, cx) - }) - .ok(); - }), - ) - }; - - let make_close_button = |id: &'static str, cx: &mut Context| { - let on_click = cx.listener(|this, _: &gpui::ClickEvent, _window, cx| { - cx.emit(ClosePane); - this.thread_view = None; - cx.notify(); - }); - div().px(DynamicSpacing::Base06.rems(cx)).child( - IconButton::new(id, IconName::Close) - .icon_size(IconSize::Small) - .on_click(on_click), - ) - }; - - let make_title_label = |title: SharedString, cx: &App| { - div() - .px(DynamicSpacing::Base06.rems(cx)) - .child(Label::new(title).size(LabelSize::Small)) + let pane_toggle_button = |workspace: WeakEntity| { + IconButton::new("toggle_utility_pane", toggle_icon) + .icon_size(IconSize::Small) + .tooltip(Tooltip::text("Toggle Agent Pane")) + .on_click(move |_, window, cx| { + workspace + .update(cx, |workspace, cx| { + workspace.toggle_utility_pane(slot, window, cx) + }) + .ok(); + }) }; - div() + h_flex() .id("utility-pane-header") - .flex() - .flex_none() - .items_center() .w_full() .h(Tab::container_height(cx)) - .when(slot == UtilityPaneSlot::Left, |this| { - this.child(make_toggle_button(workspace.clone(), cx)) - .child(make_title_label(title.clone(), cx)) - .child(div().flex_grow()) - .child(make_close_button("close_utility_pane_left", cx)) - }) + .px_1p5() + .gap(DynamicSpacing::Base06.rems(cx)) .when(slot == UtilityPaneSlot::Right, |this| { - this.child(make_close_button("close_utility_pane_right", cx)) - .child(make_title_label(title.clone(), cx)) - .child(div().flex_grow()) - .child(make_toggle_button(workspace.clone(), cx)) + this.flex_row_reverse() }) + .flex_none() + .border_b_1() + .border_color(cx.theme().colors().border) + .child(pane_toggle_button(workspace)) + .child( + h_flex() + .size_full() + .min_w_0() + .gap_1() + .map(|this| { + if slot == UtilityPaneSlot::Right { + this.flex_row_reverse().justify_start() + } else { + this.justify_between() + } + }) + .child(Label::new(title).truncate()) + .child( + IconButton::new("close_btn", IconName::Close) + .icon_size(IconSize::Small) + .tooltip(Tooltip::text("Close Agent Pane")) + .on_click(cx.listener(|this, _: &gpui::ClickEvent, _window, cx| { + cx.emit(ClosePane); + this.thread_view = None; + cx.notify() + })), + ), + ) } } diff --git a/crates/agent_ui_v2/src/agents_panel.rs b/crates/agent_ui_v2/src/agents_panel.rs index ace5e73f56b9eff4292f34263bfe08a94e2d6050..a7afdddda43514ade40b7fd9dfd8bcd8ace33dc7 100644 --- a/crates/agent_ui_v2/src/agents_panel.rs +++ b/crates/agent_ui_v2/src/agents_panel.rs @@ -411,7 +411,7 @@ impl Panel for AgentsPanel { } fn icon(&self, _window: &Window, cx: &App) -> Option { - (self.enabled(cx) && AgentSettings::get_global(cx).button).then_some(IconName::ZedAgent) + (self.enabled(cx) && AgentSettings::get_global(cx).button).then_some(IconName::ZedAgentTwo) } fn icon_tooltip(&self, _window: &Window, _cx: &App) -> Option<&'static str> { diff --git a/crates/icons/src/icons.rs b/crates/icons/src/icons.rs index bf4c74f984ff4aa8f06d6408957eddabcf5f94ed..23ae7a6d928d98aafe48d28cfe5626bbf76d29b8 100644 --- a/crates/icons/src/icons.rs +++ b/crates/icons/src/icons.rs @@ -260,6 +260,7 @@ pub enum IconName { XCircle, XCircleFilled, ZedAgent, + ZedAgentTwo, ZedAssistant, ZedBurnMode, ZedBurnModeOn, diff --git a/crates/ui/src/components/tab_bar.rs b/crates/ui/src/components/tab_bar.rs index 681f9a726e0d5f4796325a4533fca909617f1e08..86598b8c6f1ab3a479313c7775405863e9e3b49b 100644 --- a/crates/ui/src/components/tab_bar.rs +++ b/crates/ui/src/components/tab_bar.rs @@ -162,6 +162,7 @@ impl RenderOnce for TabBar { .when(!self.end_children.is_empty(), |div| { div.child( h_flex() + .h_full() .flex_none() .pl(DynamicSpacing::Base04.rems(cx)) .gap(DynamicSpacing::Base04.rems(cx)) diff --git a/crates/workspace/src/pane.rs b/crates/workspace/src/pane.rs index ee57f06937ee2781e8d1b965b5e498f5a31ad80d..50ba58926ece8818ac5a4f44103c3b86eb2b672d 100644 --- a/crates/workspace/src/pane.rs +++ b/crates/workspace/src/pane.rs @@ -3047,6 +3047,8 @@ impl Pane { }; let focus_handle = self.focus_handle.clone(); + let is_pane_focused = self.has_focus(window, cx); + let navigate_backward = IconButton::new("navigate_backward", IconName::ArrowLeft) .icon_size(IconSize::Small) .on_click({ @@ -3076,15 +3078,27 @@ impl Pane { let toggle_icon = pane.toggle_icon(cx); let workspace_handle = self.workspace.clone(); - IconButton::new("open_aside_left", toggle_icon) - .icon_size(IconSize::Small) - .on_click(move |_, window, cx| { - workspace_handle - .update(cx, |workspace, cx| { - workspace.toggle_utility_pane(UtilityPaneSlot::Left, window, cx) - }) - .ok(); - }) + h_flex() + .h_full() + .pr_1p5() + .border_r_1() + .border_color(cx.theme().colors().border) + .child( + IconButton::new("open_aside_left", toggle_icon) + .icon_size(IconSize::Small) + .tooltip(Tooltip::text("Toggle Agent Pane")) // TODO: Probably want to make this generic + .on_click(move |_, window, cx| { + workspace_handle + .update(cx, |workspace, cx| { + workspace.toggle_utility_pane( + UtilityPaneSlot::Left, + window, + cx, + ) + }) + .ok(); + }), + ) .into_any_element() }) }; @@ -3095,15 +3109,29 @@ impl Pane { let toggle_icon = pane.toggle_icon(cx); let workspace_handle = self.workspace.clone(); - IconButton::new("open_aside_right", toggle_icon) - .icon_size(IconSize::Small) - .on_click(move |_, window, cx| { - workspace_handle - .update(cx, |workspace, cx| { - workspace.toggle_utility_pane(UtilityPaneSlot::Right, window, cx) - }) - .ok(); + h_flex() + .h_full() + .when(is_pane_focused, |this| { + this.pl(DynamicSpacing::Base04.rems(cx)) + .border_l_1() + .border_color(cx.theme().colors().border) }) + .child( + IconButton::new("open_aside_right", toggle_icon) + .icon_size(IconSize::Small) + .tooltip(Tooltip::text("Toggle Agent Pane")) // TODO: Probably want to make this generic + .on_click(move |_, window, cx| { + workspace_handle + .update(cx, |workspace, cx| { + workspace.toggle_utility_pane( + UtilityPaneSlot::Right, + window, + cx, + ) + }) + .ok(); + }), + ) .into_any_element() }) }; @@ -3196,8 +3224,8 @@ impl Pane { self.display_nav_history_buttons.unwrap_or_default(), |tab_bar| { tab_bar - .pre_end_child(navigate_backward) - .pre_end_child(navigate_forward) + .start_child(navigate_backward) + .start_child(navigate_forward) }, ) .map(|tab_bar| { @@ -6756,13 +6784,13 @@ mod tests { let tab_bar_scroll_handle = pane.update_in(cx, |pane, _window, _cx| pane.tab_bar_scroll_handle.clone()); assert_eq!(tab_bar_scroll_handle.children_count(), 6); - let tab_bounds = cx.debug_bounds("TAB-3").unwrap(); + let tab_bounds = cx.debug_bounds("TAB-4").unwrap(); let new_tab_button_bounds = cx.debug_bounds("ICON-Plus").unwrap(); let scroll_bounds = tab_bar_scroll_handle.bounds(); let scroll_offset = tab_bar_scroll_handle.offset(); - assert!(tab_bounds.right() <= scroll_bounds.right() + scroll_offset.x); - // -35.0 is the magic number for this setup - assert_eq!(scroll_offset.x, px(-35.0)); + assert!(tab_bounds.right() <= scroll_bounds.right()); + // -43.0 is the magic number for this setup + assert_eq!(scroll_offset.x, px(-43.0)); assert!( !tab_bounds.intersects(&new_tab_button_bounds), "Tab should not overlap with the new tab button, if this is failing check if there's been a redesign!" From c20cbba0ebb1caf3763d55893c4a11dcc06a2cae Mon Sep 17 00:00:00 2001 From: Jeff Brennan <42007840+jeffbrennan@users.noreply.github.com> Date: Mon, 15 Dec 2025 11:11:07 -0500 Subject: [PATCH 305/621] python: Add SQL syntax highlighting (#43756) Release Notes: - Added support for SQL syntax highlighting in Python files ## Summary I am a data engineer who spends a lot of time writing SQL in Python files using Zed. This PR adds support for SQL syntax highlighting with common libraries (like pyspark, polars, pandas) and string variables (prefixed with a `# sql` comment). I referenced [#37605](https://github.com/zed-industries/zed/pull/37605) for this implementation to keep the comment prefix consistent. ## Examples image --------- Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> --- crates/languages/src/python/injections.scm | 31 ++++++++++++++++++++++ docs/src/languages/python.md | 19 +++++++++++++ 2 files changed, 50 insertions(+) diff --git a/crates/languages/src/python/injections.scm b/crates/languages/src/python/injections.scm index 9117c713b98fdd2896b13e4949a77c6489b9ee36..d8470140e999f3dc649c0a498987cfae7df6bf59 100644 --- a/crates/languages/src/python/injections.scm +++ b/crates/languages/src/python/injections.scm @@ -1,3 +1,34 @@ ((comment) @injection.content (#set! injection.language "comment") ) + +; SQL ----------------------------------------------------------------------------- +( + [ + ; function calls + (call + [ + (attribute attribute: (identifier) @function_name) + (identifier) @function_name + ] + arguments: (argument_list + (comment) @comment + (string + (string_content) @injection.content + ) + )) + + ; string variables + ((comment) @comment + . + (expression_statement + (assignment + right: (string + (string_content) @injection.content + ) + ) + )) + ] + (#match? @comment "^(#|#\\s+)(?i:sql)\\s*$") + (#set! injection.language "sql") +) diff --git a/docs/src/languages/python.md b/docs/src/languages/python.md index 5051a72209121176e05d41f57cb8d341db2ca351..2323fe2f9560cf03c586eced0052627705addcc3 100644 --- a/docs/src/languages/python.md +++ b/docs/src/languages/python.md @@ -258,6 +258,25 @@ quote-style = "single" For more details, refer to the Ruff documentation about [configuration files](https://docs.astral.sh/ruff/configuration/) and [language server settings](https://docs.astral.sh/ruff/editors/settings/), and the [list of options](https://docs.astral.sh/ruff/settings/). +### Embedded Language Highlighting + +Zed supports syntax highlighting for code embedded in Python strings by adding a comment with the language name. + +```python +# sql +query = "SELECT * FROM users" + +#sql +query = """ + SELECT * + FROM users +""" + +result = func( #sql + "SELECT * FROM users" +) +``` + ## Debugging Zed supports Python debugging through the `debugpy` adapter. You can start with no configuration or define custom launch profiles in `.zed/debug.json`. From 6401ac072575e399eb62db4d8a16b2e73cc880c2 Mon Sep 17 00:00:00 2001 From: Marco Mihai Condrache <52580954+marcocondrache@users.noreply.github.com> Date: Mon, 15 Dec 2025 17:29:33 +0100 Subject: [PATCH 306/621] remote: Add ssh timeout setting (#44823) Closes #21527 Release Notes: - Added a setting to specify the ssh connection timeout --------- Signed-off-by: Marco Mihai Condrache <52580954+marcocondrache@users.noreply.github.com> --- crates/recent_projects/src/remote_servers.rs | 1 + crates/remote/src/transport/ssh.rs | 18 +++++++++++++++--- crates/settings/src/settings_content.rs | 3 +++ crates/zed/src/zed/open_listener.rs | 1 + 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/crates/recent_projects/src/remote_servers.rs b/crates/recent_projects/src/remote_servers.rs index 1df3abbeaee41532abcf12f5939db050429c73da..c960a2b1a9af9e11730240c24483a673b77e0fb5 100644 --- a/crates/recent_projects/src/remote_servers.rs +++ b/crates/recent_projects/src/remote_servers.rs @@ -1525,6 +1525,7 @@ impl RemoteServerProjects { args: connection_options.args.unwrap_or_default(), upload_binary_over_ssh: None, port_forwards: connection_options.port_forwards, + connection_timeout: connection_options.connection_timeout, }) }); } diff --git a/crates/remote/src/transport/ssh.rs b/crates/remote/src/transport/ssh.rs index 9412549f20d68e999889ed0062397d85abe99d6e..c445c0565837d33dc044087fc53e6573e06ee54c 100644 --- a/crates/remote/src/transport/ssh.rs +++ b/crates/remote/src/transport/ssh.rs @@ -55,6 +55,7 @@ pub struct SshConnectionOptions { pub password: Option, pub args: Option>, pub port_forwards: Option>, + pub connection_timeout: Option, pub nickname: Option, pub upload_binary_over_ssh: bool, @@ -71,6 +72,7 @@ impl From for SshConnectionOptions { nickname: val.nickname, upload_binary_over_ssh: val.upload_binary_over_ssh.unwrap_or_default(), port_forwards: val.port_forwards, + connection_timeout: val.connection_timeout, } } } @@ -670,7 +672,12 @@ impl SshRemoteConnection { delegate.set_status(Some("Downloading remote development server on host"), cx); - const CONNECT_TIMEOUT_SECS: &str = "10"; + let connection_timeout = self + .socket + .connection_options + .connection_timeout + .unwrap_or(10) + .to_string(); match self .socket @@ -681,7 +688,7 @@ impl SshRemoteConnection { "-f", "-L", "--connect-timeout", - CONNECT_TIMEOUT_SECS, + &connection_timeout, url, "-o", &tmp_path_gz.display(self.path_style()), @@ -709,7 +716,7 @@ impl SshRemoteConnection { "wget", &[ "--connect-timeout", - CONNECT_TIMEOUT_SECS, + &connection_timeout, "--tries", "1", url, @@ -1226,6 +1233,7 @@ impl SshConnectionOptions { password: None, nickname: None, upload_binary_over_ssh: false, + connection_timeout: None, }) } @@ -1252,6 +1260,10 @@ impl SshConnectionOptions { pub fn additional_args(&self) -> Vec { let mut args = self.additional_args_for_scp(); + if let Some(timeout) = self.connection_timeout { + args.extend(["-o".to_string(), format!("ConnectTimeout={}", timeout)]); + } + if let Some(forwards) = &self.port_forwards { args.extend(forwards.iter().map(|pf| { let local_host = match &pf.local_host { diff --git a/crates/settings/src/settings_content.rs b/crates/settings/src/settings_content.rs index ba349b865bf2ac4dfd9d19b22c5693307ebae20a..3d7e6b5948b1db4d375814d6969ddabe95fc3e58 100644 --- a/crates/settings/src/settings_content.rs +++ b/crates/settings/src/settings_content.rs @@ -930,6 +930,9 @@ pub struct SshConnection { pub upload_binary_over_ssh: Option, pub port_forwards: Option>, + /// Timeout in seconds for SSH connection and downloading the remote server binary. + /// Defaults to 10 seconds if not specified. + pub connection_timeout: Option, } #[derive(Clone, Default, Serialize, Deserialize, PartialEq, JsonSchema, MergeFrom, Debug)] diff --git a/crates/zed/src/zed/open_listener.rs b/crates/zed/src/zed/open_listener.rs index 5e855aa5a949254ba32658c26a59c48c7413844e..e398ad6df7cde55de529e94b62d4aac173741351 100644 --- a/crates/zed/src/zed/open_listener.rs +++ b/crates/zed/src/zed/open_listener.rs @@ -686,6 +686,7 @@ mod tests { port_forwards: None, nickname: None, upload_binary_over_ssh: false, + connection_timeout: None, }) ); assert_eq!(request.open_paths, vec!["/"]); From 34122aeb21626bfc0502ab7c768ccee2c2dde392 Mon Sep 17 00:00:00 2001 From: Marco Mihai Condrache <52580954+marcocondrache@users.noreply.github.com> Date: Mon, 15 Dec 2025 17:32:54 +0100 Subject: [PATCH 307/621] editor: Don't merge adjacent selections (#44811) Closes #24748 Release Notes: - Adjacent selections are not merged anymore --------- Signed-off-by: Marco Mihai Condrache <52580954+marcocondrache@users.noreply.github.com> Signed-off-by: Marco Mihai Condrache --- crates/editor/src/editor_tests.rs | 20 ++++--- crates/editor/src/selections_collection.rs | 63 ++++++++++++++++++++-- crates/vim/src/helix.rs | 3 +- 3 files changed, 73 insertions(+), 13 deletions(-) diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rs index 89131e8bc39fc03e54e19c9d8b1f79a7f2d66cb9..9b04a6ea2bc7aef4e5a90b7d823e50857cff2172 100644 --- a/crates/editor/src/editor_tests.rs +++ b/crates/editor/src/editor_tests.rs @@ -7750,10 +7750,12 @@ fn test_select_line(cx: &mut TestAppContext) { ]) }); editor.select_line(&SelectLine, window, cx); + // Adjacent line selections should NOT merge (only overlapping ones do) assert_eq!( display_ranges(editor, cx), vec![ - DisplayPoint::new(DisplayRow(0), 0)..DisplayPoint::new(DisplayRow(2), 0), + DisplayPoint::new(DisplayRow(0), 0)..DisplayPoint::new(DisplayRow(1), 0), + DisplayPoint::new(DisplayRow(1), 0)..DisplayPoint::new(DisplayRow(2), 0), DisplayPoint::new(DisplayRow(4), 0)..DisplayPoint::new(DisplayRow(5), 0), ] ); @@ -7772,9 +7774,13 @@ fn test_select_line(cx: &mut TestAppContext) { _ = editor.update(cx, |editor, window, cx| { editor.select_line(&SelectLine, window, cx); + // Adjacent but not overlapping, so they stay separate assert_eq!( display_ranges(editor, cx), - vec![DisplayPoint::new(DisplayRow(0), 0)..DisplayPoint::new(DisplayRow(5), 5)] + vec![ + DisplayPoint::new(DisplayRow(0), 0)..DisplayPoint::new(DisplayRow(4), 0), + DisplayPoint::new(DisplayRow(4), 0)..DisplayPoint::new(DisplayRow(5), 5), + ] ); }); } @@ -16196,7 +16202,7 @@ async fn test_toggle_comment(cx: &mut TestAppContext) { cx.assert_editor_state(indoc! {" fn a() { «b(); - c(); + ˇ»«c(); ˇ» d(); } "}); @@ -16208,8 +16214,8 @@ async fn test_toggle_comment(cx: &mut TestAppContext) { cx.assert_editor_state(indoc! {" fn a() { // «b(); - // c(); - ˇ»// d(); + ˇ»// «c(); + ˇ» // d(); } "}); @@ -16218,7 +16224,7 @@ async fn test_toggle_comment(cx: &mut TestAppContext) { fn a() { // b(); «// c(); - ˇ» // d(); + ˇ» // d(); } "}); @@ -16228,7 +16234,7 @@ async fn test_toggle_comment(cx: &mut TestAppContext) { fn a() { // b(); «c(); - ˇ» // d(); + ˇ» // d(); } "}); diff --git a/crates/editor/src/selections_collection.rs b/crates/editor/src/selections_collection.rs index 6f744e11334fc32e7985ee77e25866ef0c6cfe4c..54bb7ceec1d035fbefb0c229c4e537e8277b67cd 100644 --- a/crates/editor/src/selections_collection.rs +++ b/crates/editor/src/selections_collection.rs @@ -136,7 +136,13 @@ impl SelectionsCollection { iter::from_fn(move || { if let Some(pending) = pending_opt.as_mut() { while let Some(next_selection) = disjoint.peek() { - if pending.start <= next_selection.end && pending.end >= next_selection.start { + if should_merge( + pending.start, + pending.end, + next_selection.start, + next_selection.end, + false, + ) { let next_selection = disjoint.next().unwrap(); if next_selection.start < pending.start { pending.start = next_selection.start; @@ -236,7 +242,13 @@ impl SelectionsCollection { iter::from_fn(move || { if let Some(pending) = pending_opt.as_mut() { while let Some(next_selection) = disjoint.peek() { - if pending.start <= next_selection.end && pending.end >= next_selection.start { + if should_merge( + pending.start, + pending.end, + next_selection.start, + next_selection.end, + false, + ) { let next_selection = disjoint.next().unwrap(); if next_selection.start < pending.start { pending.start = next_selection.start; @@ -666,10 +678,13 @@ impl<'snap, 'a> MutableSelectionsCollection<'snap, 'a> { }) .collect::>(); selections.sort_unstable_by_key(|s| s.start); - // Merge overlapping selections. + let mut i = 1; while i < selections.len() { - if selections[i].start <= selections[i - 1].end { + let prev = &selections[i - 1]; + let current = &selections[i]; + + if should_merge(prev.start, prev.end, current.start, current.end, true) { let removed = selections.remove(i); if removed.start < selections[i - 1].start { selections[i - 1].start = removed.start; @@ -1139,7 +1154,13 @@ fn coalesce_selections( iter::from_fn(move || { let mut selection = selections.next()?; while let Some(next_selection) = selections.peek() { - if selection.end >= next_selection.start { + if should_merge( + selection.start, + selection.end, + next_selection.start, + next_selection.end, + true, + ) { if selection.reversed == next_selection.reversed { selection.end = cmp::max(selection.end, next_selection.end); selections.next(); @@ -1161,3 +1182,35 @@ fn coalesce_selections( Some(selection) }) } + +/// Determines whether two selections should be merged into one. +/// +/// Two selections should be merged when: +/// 1. They overlap: the selections share at least one position +/// 2. They have the same start position: one contains or equals the other +/// 3. A cursor touches a selection boundary: a zero-width selection (cursor) at the +/// start or end of another selection should be absorbed into it +/// +/// Note: two selections that merely touch (one ends exactly where the other begins) +/// but don't share any positions remain separate, see: https://github.com/zed-industries/zed/issues/24748 +fn should_merge(a_start: T, a_end: T, b_start: T, b_end: T, sorted: bool) -> bool { + let is_overlapping = if sorted { + // When sorted, `a` starts before or at `b`, so overlap means `b` starts before `a` ends + b_start < a_end + } else { + a_start < b_end && b_start < a_end + }; + + // Selections starting at the same position should always merge (one contains the other) + let same_start = a_start == b_start; + + // A cursor (zero-width selection) touching another selection's boundary should merge. + // This handles cases like a cursor at position X merging with a selection that + // starts or ends at X. + let is_cursor_a = a_start == a_end; + let is_cursor_b = b_start == b_end; + let cursor_at_boundary = (is_cursor_a && (a_start == b_start || a_end == b_end)) + || (is_cursor_b && (b_start == a_start || b_end == a_end)); + + is_overlapping || same_start || cursor_at_boundary +} diff --git a/crates/vim/src/helix.rs b/crates/vim/src/helix.rs index fae2bda578c6844c33290d059248b895ebde4c3d..f902a8ff6e9f08475fb6ce8323a924730d3621d1 100644 --- a/crates/vim/src/helix.rs +++ b/crates/vim/src/helix.rs @@ -1389,11 +1389,12 @@ mod test { Mode::HelixNormal, ); cx.simulate_keystrokes("x"); + // Adjacent line selections stay separate (not merged) cx.assert_state( indoc! {" «line one line two - line three + ˇ»«line three line four ˇ»line five"}, Mode::HelixNormal, From 0a5955a46458f07005a04c17abe688441dbbc367 Mon Sep 17 00:00:00 2001 From: Ben Kunkle Date: Mon, 15 Dec 2025 08:43:29 -0800 Subject: [PATCH 308/621] Ensure Sweep and Mercury keys are loaded for Edit Prediction button (#44894) Follow up for #44505 Release Notes: - N/A *or* Added/Fixed/Improved ... --- crates/edit_prediction/src/mercury.rs | 6 ++++ crates/edit_prediction/src/sweep_ai.rs | 6 ++++ .../src/edit_prediction_button.rs | 31 +++++++++++++------ 3 files changed, 34 insertions(+), 9 deletions(-) diff --git a/crates/edit_prediction/src/mercury.rs b/crates/edit_prediction/src/mercury.rs index ac9f8f535572dddb56ffcfde9a5f2040a65cf168..b47bd2ad0374eba33e7b8db726c2fa13c0519465 100644 --- a/crates/edit_prediction/src/mercury.rs +++ b/crates/edit_prediction/src/mercury.rs @@ -309,3 +309,9 @@ pub fn mercury_api_token(cx: &mut App) -> Entity { }) .clone() } + +pub fn load_mercury_api_token(cx: &mut App) -> Task> { + mercury_api_token(cx).update(cx, |key_state, cx| { + key_state.load_if_needed(MERCURY_CREDENTIALS_URL, |s| s, cx) + }) +} diff --git a/crates/edit_prediction/src/sweep_ai.rs b/crates/edit_prediction/src/sweep_ai.rs index 7d020c219b47aa8bcf6fb89e516b7f8ff93da497..2ed24cd8ef728383ec800acbb2ab7c7b99f07c06 100644 --- a/crates/edit_prediction/src/sweep_ai.rs +++ b/crates/edit_prediction/src/sweep_ai.rs @@ -282,6 +282,12 @@ pub fn sweep_api_token(cx: &mut App) -> Entity { .clone() } +pub fn load_sweep_api_token(cx: &mut App) -> Task> { + sweep_api_token(cx).update(cx, |key_state, cx| { + key_state.load_if_needed(SWEEP_CREDENTIALS_URL, |s| s, cx) + }) +} + #[derive(Debug, Clone, Serialize)] struct AutocompleteRequest { pub debug_info: Arc, diff --git a/crates/edit_prediction_ui/src/edit_prediction_button.rs b/crates/edit_prediction_ui/src/edit_prediction_button.rs index bbf9f4677df278c014379964e7bdc714e6ce78d8..0dcea477200eef9d1eeb6adeff98f47332d751ca 100644 --- a/crates/edit_prediction_ui/src/edit_prediction_button.rs +++ b/crates/edit_prediction_ui/src/edit_prediction_button.rs @@ -487,6 +487,21 @@ impl EditPredictionButton { cx.observe_global::(move |_, cx| cx.notify()) .detach(); + cx.observe_global::(move |_, cx| cx.notify()) + .detach(); + + let sweep_api_token_task = edit_prediction::sweep_ai::load_sweep_api_token(cx); + let mercury_api_token_task = edit_prediction::mercury::load_mercury_api_token(cx); + + cx.spawn(async move |this, cx| { + _ = futures::join!(sweep_api_token_task, mercury_api_token_task); + this.update(cx, |_, cx| { + cx.notify(); + }) + .ok(); + }) + .detach(); + CodestralEditPredictionDelegate::ensure_api_key_loaded(client.http_client(), cx); Self { @@ -503,7 +518,7 @@ impl EditPredictionButton { } } - fn get_available_providers(&self, cx: &App) -> Vec { + fn get_available_providers(&self, cx: &mut App) -> Vec { let mut providers = Vec::new(); providers.push(EditPredictionProvider::Zed); @@ -532,12 +547,10 @@ impl EditPredictionButton { providers.push(EditPredictionProvider::Codestral); } - let ep_store = EditPredictionStore::try_global(cx); - if cx.has_flag::() - && ep_store - .as_ref() - .is_some_and(|ep_store| ep_store.read(cx).has_sweep_api_token(cx)) + && edit_prediction::sweep_ai::sweep_api_token(cx) + .read(cx) + .has_key() { providers.push(EditPredictionProvider::Experimental( EXPERIMENTAL_SWEEP_EDIT_PREDICTION_PROVIDER_NAME, @@ -545,9 +558,9 @@ impl EditPredictionButton { } if cx.has_flag::() - && ep_store - .as_ref() - .is_some_and(|ep_store| ep_store.read(cx).has_mercury_api_token(cx)) + && edit_prediction::mercury::mercury_api_token(cx) + .read(cx) + .has_key() { providers.push(EditPredictionProvider::Experimental( EXPERIMENTAL_MERCURY_EDIT_PREDICTION_PROVIDER_NAME, From 3cc21a01ef0317e1c098cdb4c55872d9affede6a Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Mon, 15 Dec 2025 19:05:50 +0200 Subject: [PATCH 309/621] Suppress another logged backtrace (#44896) Do not log any error when the binary is not found, do not show any backtrace when logging errors. bad Release Notes: - N/A --- crates/languages/src/rust.rs | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/crates/languages/src/rust.rs b/crates/languages/src/rust.rs index aadf882b8eb038f49b5ad602ba074a91e20ed78d..ee64954196f58fe03f53a9e83fbbbea3f636449a 100644 --- a/crates/languages/src/rust.rs +++ b/crates/languages/src/rust.rs @@ -1126,9 +1126,11 @@ fn package_name_from_pkgid(pkgid: &str) -> Option<&str> { } async fn get_cached_server_binary(container_dir: PathBuf) -> Option { - maybe!(async { + let binary_result = maybe!(async { let mut last = None; - let mut entries = fs::read_dir(&container_dir).await?; + let mut entries = fs::read_dir(&container_dir) + .await + .with_context(|| format!("listing {container_dir:?}"))?; while let Some(entry) = entries.next().await { let path = entry?.path(); if path.extension().is_some_and(|ext| ext == "metadata") { @@ -1137,20 +1139,34 @@ async fn get_cached_server_binary(container_dir: PathBuf) -> Option last, + None => return Ok(None), + }; let path = match RustLspAdapter::GITHUB_ASSET_KIND { AssetKind::TarGz | AssetKind::Gz => path, // Tar and gzip extract in place. AssetKind::Zip => path.join("rust-analyzer.exe"), // zip contains a .exe }; - anyhow::Ok(LanguageServerBinary { + anyhow::Ok(Some(LanguageServerBinary { path, env: None, - arguments: Default::default(), - }) + arguments: Vec::new(), + })) }) - .await - .log_err() + .await; + + match binary_result { + Ok(Some(binary)) => Some(binary), + Ok(None) => { + log::info!("No cached rust-analyzer binary found"); + None + } + Err(e) => { + log::error!("Failed to look up cached rust-analyzer binary: {e:#}"); + None + } + } } fn test_fragment(variables: &TaskVariables, path: &Path, stem: &str) -> String { From e1063743e8314af942e6a017ebfeeb06acddacaf Mon Sep 17 00:00:00 2001 From: AidanV <84053180+AidanV@users.noreply.github.com> Date: Mon, 15 Dec 2025 09:13:18 -0800 Subject: [PATCH 310/621] vim: Fix global mark overwriting inconsistency (#44765) Closes #43963 This issue was caused by the global marks not being deleted. Previously marking the first file `m A` Screenshot From 2025-12-13 01-37-55 followed by marking the second file `m A` Screenshot From 2025-12-13 01-37-42 and navigating back to the first file Screenshot From 2025-12-13 01-37-30 shows that the mark still exists and was not properly deleted. After these changes the global mark in the original file is correctly overwritten. Added regression test for this. Release Notes: - Fixed bug where overwriting global Vim marks was inconsistent --- crates/vim/src/normal/mark.rs | 72 ++++++++++++++++++++++++++++++++++- crates/vim/src/state.rs | 10 ++++- 2 files changed, 79 insertions(+), 3 deletions(-) diff --git a/crates/vim/src/normal/mark.rs b/crates/vim/src/normal/mark.rs index 3bb040511fdd7fa53dd97198ae02b492b0e7359d..a4d85e87b24fa6e2753f0dbcfcbb43be9488f41a 100644 --- a/crates/vim/src/normal/mark.rs +++ b/crates/vim/src/normal/mark.rs @@ -372,9 +372,12 @@ pub fn jump_motion( #[cfg(test)] mod test { + use crate::test::{NeovimBackedTestContext, VimTestContext}; + use editor::Editor; use gpui::TestAppContext; - - use crate::test::NeovimBackedTestContext; + use std::path::Path; + use util::path; + use workspace::{CloseActiveItem, OpenOptions}; #[gpui::test] async fn test_quote_mark(cx: &mut TestAppContext) { @@ -394,4 +397,69 @@ mod test { cx.simulate_shared_keystrokes("^ ` `").await; cx.shared_state().await.assert_eq("Hello, worldˇ!"); } + + #[gpui::test] + async fn test_global_mark_overwrite(cx: &mut TestAppContext) { + let mut cx = VimTestContext::new(cx, true).await; + + let path = Path::new(path!("/first.rs")); + let fs = cx.workspace(|workspace, _, cx| workspace.project().read(cx).fs().clone()); + fs.as_fake().insert_file(path, "one".into()).await; + let path = Path::new(path!("/second.rs")); + fs.as_fake().insert_file(path, "two".into()).await; + + let _ = cx + .workspace(|workspace, window, cx| { + workspace.open_abs_path( + path!("/first.rs").into(), + OpenOptions::default(), + window, + cx, + ) + }) + .await; + + cx.simulate_keystrokes("m A"); + + let _ = cx + .workspace(|workspace, window, cx| { + workspace.open_abs_path( + path!("/second.rs").into(), + OpenOptions::default(), + window, + cx, + ) + }) + .await; + + cx.simulate_keystrokes("m A"); + + let _ = cx + .workspace(|workspace, window, cx| { + workspace.active_pane().update(cx, |pane, cx| { + pane.close_active_item(&CloseActiveItem::default(), window, cx) + }) + }) + .await; + + cx.simulate_keystrokes("m B"); + + cx.simulate_keystrokes("' A"); + + cx.workspace(|workspace, _, cx| { + let active_editor = workspace.active_item_as::(cx).unwrap(); + + let buffer = active_editor + .read(cx) + .buffer() + .read(cx) + .as_singleton() + .unwrap(); + + let file = buffer.read(cx).file().unwrap(); + let file_path = file.as_local().unwrap().abs_path(cx); + + assert_eq!(file_path.to_str().unwrap(), path!("/second.rs")); + }) + } } diff --git a/crates/vim/src/state.rs b/crates/vim/src/state.rs index e96fd3a329e95311eeb73b87b53acbe76939f0cd..2a8aa91063be89ebd616a2f9601f90c912cee8b5 100644 --- a/crates/vim/src/state.rs +++ b/crates/vim/src/state.rs @@ -550,6 +550,10 @@ impl MarksState { let buffer = multibuffer.read(cx).as_singleton(); let abs_path = buffer.as_ref().and_then(|b| self.path_for_buffer(b, cx)); + if self.is_global_mark(&name) && self.global_marks.contains_key(&name) { + self.delete_mark(name.clone(), multibuffer, cx); + } + let Some(abs_path) = abs_path else { self.multibuffer_marks .entry(multibuffer.entity_id()) @@ -573,7 +577,7 @@ impl MarksState { let buffer_id = buffer.read(cx).remote_id(); self.buffer_marks.entry(buffer_id).or_default().insert( - name, + name.clone(), anchors .into_iter() .map(|anchor| anchor.text_anchor) @@ -582,6 +586,10 @@ impl MarksState { if !self.watched_buffers.contains_key(&buffer_id) { self.watch_buffer(MarkLocation::Path(abs_path.clone()), &buffer, cx) } + if self.is_global_mark(&name) { + self.global_marks + .insert(name, MarkLocation::Path(abs_path.clone())); + } self.serialize_buffer_marks(abs_path, &buffer, cx) } From 79dfae24648d5dcb5d5841baa966b798bb554fb5 Mon Sep 17 00:00:00 2001 From: Marco Mihai Condrache <52580954+marcocondrache@users.noreply.github.com> Date: Mon, 15 Dec 2025 18:37:27 +0100 Subject: [PATCH 311/621] gpui: Fix some memory leaks on macOS platform (#44639) While profiling with instruments, I discovered that some of the strings allocated on the mac platform are never released, and the profiler marks them as leaks image Release Notes: - N/A --------- Signed-off-by: Marco Mihai Condrache <52580954+marcocondrache@users.noreply.github.com> Co-authored-by: Anthony Eid --- clippy.toml | 1 + crates/fs/src/fs.rs | 2 ++ crates/gpui/src/platform/mac.rs | 2 ++ .../src/platform/mac/attributed_string.rs | 34 ++++++++++++------- crates/gpui/src/platform/mac/display.rs | 7 ++-- crates/gpui/src/platform/mac/platform.rs | 12 +++---- .../gpui/src/platform/mac/screen_capture.rs | 5 +-- crates/gpui/src/platform/mac/window.rs | 22 ++++++------ 8 files changed, 49 insertions(+), 36 deletions(-) diff --git a/clippy.toml b/clippy.toml index 0ce7a6cd68d4e8210788eb7a67aa06c742cc8274..9dd246074a06c4db7b66eff7a83ef68e3612c378 100644 --- a/clippy.toml +++ b/clippy.toml @@ -14,6 +14,7 @@ disallowed-methods = [ { path = "std::process::Command::stderr", reason = "`smol::process::Command::from()` does not preserve stdio configuration", replacement = "smol::process::Command::stderr" }, { path = "serde_json::from_reader", reason = "Parsing from a buffer is much slower than first reading the buffer into a Vec/String, see https://github.com/serde-rs/json/issues/160#issuecomment-253446892. Use `serde_json::from_slice` instead." }, { path = "serde_json_lenient::from_reader", reason = "Parsing from a buffer is much slower than first reading the buffer into a Vec/String, see https://github.com/serde-rs/json/issues/160#issuecomment-253446892, Use `serde_json_lenient::from_slice` instead." }, + { path = "cocoa::foundation::NSString::alloc", reason = "NSString must be autoreleased to avoid memory leaks. Use `ns_string()` helper instead." }, ] disallowed-types = [ # { path = "std::collections::HashMap", replacement = "collections::HashMap" }, diff --git a/crates/fs/src/fs.rs b/crates/fs/src/fs.rs index e8357e359696bfcfbc7cfd829f84222c1303402a..e6f69a14593a0246ae8ccb4aa4673f4e1f5a1e8e 100644 --- a/crates/fs/src/fs.rs +++ b/crates/fs/src/fs.rs @@ -641,6 +641,8 @@ impl Fs for RealFs { use objc::{class, msg_send, sel, sel_impl}; unsafe { + /// Allow NSString::alloc use here because it sets autorelease + #[allow(clippy::disallowed_methods)] unsafe fn ns_string(string: &str) -> id { unsafe { NSString::alloc(nil).init_str(string).autorelease() } } diff --git a/crates/gpui/src/platform/mac.rs b/crates/gpui/src/platform/mac.rs index 76d636b457517da64cf66988325652ddea56c5d3..aa056846e6bc56e53d95c41a44444dbb89a16237 100644 --- a/crates/gpui/src/platform/mac.rs +++ b/crates/gpui/src/platform/mac.rs @@ -135,6 +135,8 @@ unsafe impl objc::Encode for NSRange { } } +/// Allow NSString::alloc use here because it sets autorelease +#[allow(clippy::disallowed_methods)] unsafe fn ns_string(string: &str) -> id { unsafe { NSString::alloc(nil).init_str(string).autorelease() } } diff --git a/crates/gpui/src/platform/mac/attributed_string.rs b/crates/gpui/src/platform/mac/attributed_string.rs index 5f313ac699d6e1a096c4bcf807fd6c080d0064da..42fe1e5bf7a396a4eaa8ade26977a207d43b49b5 100644 --- a/crates/gpui/src/platform/mac/attributed_string.rs +++ b/crates/gpui/src/platform/mac/attributed_string.rs @@ -50,10 +50,12 @@ impl NSMutableAttributedString for id {} #[cfg(test)] mod tests { + use crate::platform::mac::ns_string; + use super::*; use cocoa::appkit::NSImage; use cocoa::base::nil; - use cocoa::foundation::NSString; + use cocoa::foundation::NSAutoreleasePool; #[test] #[ignore] // This was SIGSEGV-ing on CI but not locally; need to investigate https://github.com/zed-industries/zed/actions/runs/10362363230/job/28684225486?pr=15782#step:4:1348 fn test_nsattributed_string() { @@ -68,26 +70,34 @@ mod tests { impl NSTextAttachment for id {} unsafe { - let image: id = msg_send![class!(NSImage), alloc]; - image.initWithContentsOfFile_(NSString::alloc(nil).init_str("test.jpeg")); + let image: id = { + let img: id = msg_send![class!(NSImage), alloc]; + let img: id = msg_send![img, initWithContentsOfFile: ns_string("test.jpeg")]; + let img: id = msg_send![img, autorelease]; + img + }; let _size = image.size(); - let string = NSString::alloc(nil).init_str("Test String"); - let attr_string = NSMutableAttributedString::alloc(nil).init_attributed_string(string); - let hello_string = NSString::alloc(nil).init_str("Hello World"); - let hello_attr_string = - NSAttributedString::alloc(nil).init_attributed_string(hello_string); + let string = ns_string("Test String"); + let attr_string = NSMutableAttributedString::alloc(nil) + .init_attributed_string(string) + .autorelease(); + let hello_string = ns_string("Hello World"); + let hello_attr_string = NSAttributedString::alloc(nil) + .init_attributed_string(hello_string) + .autorelease(); attr_string.appendAttributedString_(hello_attr_string); - let attachment = NSTextAttachment::alloc(nil); + let attachment: id = msg_send![NSTextAttachment::alloc(nil), autorelease]; let _: () = msg_send![attachment, setImage: image]; let image_attr_string = msg_send![class!(NSAttributedString), attributedStringWithAttachment: attachment]; attr_string.appendAttributedString_(image_attr_string); - let another_string = NSString::alloc(nil).init_str("Another String"); - let another_attr_string = - NSAttributedString::alloc(nil).init_attributed_string(another_string); + let another_string = ns_string("Another String"); + let another_attr_string = NSAttributedString::alloc(nil) + .init_attributed_string(another_string) + .autorelease(); attr_string.appendAttributedString_(another_attr_string); let _len: cocoa::foundation::NSUInteger = msg_send![attr_string, length]; diff --git a/crates/gpui/src/platform/mac/display.rs b/crates/gpui/src/platform/mac/display.rs index fe5aaba8dbb9eab4db8c02f94aea1319c2b7535c..94791620e8a394f67a38c257c95c575398cee0b7 100644 --- a/crates/gpui/src/platform/mac/display.rs +++ b/crates/gpui/src/platform/mac/display.rs @@ -1,9 +1,10 @@ +use super::ns_string; use crate::{Bounds, DisplayId, Pixels, PlatformDisplay, point, px, size}; use anyhow::Result; use cocoa::{ appkit::NSScreen, base::{id, nil}, - foundation::{NSArray, NSDictionary, NSString}, + foundation::{NSArray, NSDictionary}, }; use core_foundation::uuid::{CFUUIDGetUUIDBytes, CFUUIDRef}; use core_graphics::display::{CGDirectDisplayID, CGDisplayBounds, CGGetActiveDisplayList}; @@ -35,7 +36,7 @@ impl MacDisplay { let screens = NSScreen::screens(nil); let screen = cocoa::foundation::NSArray::objectAtIndex(screens, 0); let device_description = NSScreen::deviceDescription(screen); - let screen_number_key: id = NSString::alloc(nil).init_str("NSScreenNumber"); + let screen_number_key: id = ns_string("NSScreenNumber"); let screen_number = device_description.objectForKey_(screen_number_key); let screen_number: CGDirectDisplayID = msg_send![screen_number, unsignedIntegerValue]; Self(screen_number) @@ -150,7 +151,7 @@ impl MacDisplay { unsafe fn get_nsscreen(&self) -> id { let screens = unsafe { NSScreen::screens(nil) }; let count = unsafe { NSArray::count(screens) }; - let screen_number_key: id = unsafe { NSString::alloc(nil).init_str("NSScreenNumber") }; + let screen_number_key: id = unsafe { ns_string("NSScreenNumber") }; for i in 0..count { let screen = unsafe { NSArray::objectAtIndex(screens, i) }; diff --git a/crates/gpui/src/platform/mac/platform.rs b/crates/gpui/src/platform/mac/platform.rs index c2363afe270f973513c8ba696bf5d3f99fb92cad..ee67f465e34bd8109246f68b311e225aa8f9fd0a 100644 --- a/crates/gpui/src/platform/mac/platform.rs +++ b/crates/gpui/src/platform/mac/platform.rs @@ -2,7 +2,7 @@ use super::{ BoolExt, MacKeyboardLayout, MacKeyboardMapper, attributed_string::{NSAttributedString, NSMutableAttributedString}, events::key_to_native, - renderer, + ns_string, renderer, }; use crate::{ Action, AnyWindowHandle, BackgroundExecutor, ClipboardEntry, ClipboardItem, ClipboardString, @@ -1061,13 +1061,15 @@ impl Platform for MacPlatform { let attributed_string = { let mut buf = NSMutableAttributedString::alloc(nil) // TODO can we skip this? Or at least part of it? - .init_attributed_string(NSString::alloc(nil).init_str("")); + .init_attributed_string(ns_string("")) + .autorelease(); for entry in item.entries { if let ClipboardEntry::String(ClipboardString { text, metadata: _ }) = entry { let to_append = NSAttributedString::alloc(nil) - .init_attributed_string(NSString::alloc(nil).init_str(&text)); + .init_attributed_string(ns_string(&text)) + .autorelease(); buf.appendAttributedString_(to_append); } @@ -1543,10 +1545,6 @@ extern "C" fn handle_dock_menu(this: &mut Object, _: Sel, _: id) -> id { } } -unsafe fn ns_string(string: &str) -> id { - unsafe { NSString::alloc(nil).init_str(string).autorelease() } -} - unsafe fn ns_url_to_path(url: id) -> Result { let path: *mut c_char = msg_send![url, fileSystemRepresentation]; anyhow::ensure!(!path.is_null(), "url is not a file path: {}", unsafe { diff --git a/crates/gpui/src/platform/mac/screen_capture.rs b/crates/gpui/src/platform/mac/screen_capture.rs index 4d4ffa6896520e465dfeb7b1ccc06e1149f9e25d..2f2c1eae335c8bcb366879661534c46dacfd47b4 100644 --- a/crates/gpui/src/platform/mac/screen_capture.rs +++ b/crates/gpui/src/platform/mac/screen_capture.rs @@ -1,3 +1,4 @@ +use super::ns_string; use crate::{ DevicePixels, ForegroundExecutor, SharedString, SourceMetadata, platform::{ScreenCaptureFrame, ScreenCaptureSource, ScreenCaptureStream}, @@ -7,7 +8,7 @@ use anyhow::{Result, anyhow}; use block::ConcreteBlock; use cocoa::{ base::{YES, id, nil}, - foundation::{NSArray, NSString}, + foundation::NSArray, }; use collections::HashMap; use core_foundation::base::TCFType; @@ -195,7 +196,7 @@ unsafe fn screen_id_to_human_label() -> HashMap { let screens: id = msg_send![class!(NSScreen), screens]; let count: usize = msg_send![screens, count]; let mut map = HashMap::default(); - let screen_number_key = unsafe { NSString::alloc(nil).init_str("NSScreenNumber") }; + let screen_number_key = unsafe { ns_string("NSScreenNumber") }; for i in 0..count { let screen: id = msg_send![screens, objectAtIndex: i]; let device_desc: id = msg_send![screen, deviceDescription]; diff --git a/crates/gpui/src/platform/mac/window.rs b/crates/gpui/src/platform/mac/window.rs index 53207fb77d16f2e1956f6914889b29ae3ea7bb35..19ad1777570da9494148e01161e156748cd9bcfc 100644 --- a/crates/gpui/src/platform/mac/window.rs +++ b/crates/gpui/src/platform/mac/window.rs @@ -785,7 +785,7 @@ impl MacWindow { native_window.setAcceptsMouseMovedEvents_(YES); if let Some(tabbing_identifier) = tabbing_identifier { - let tabbing_id = NSString::alloc(nil).init_str(tabbing_identifier.as_str()); + let tabbing_id = ns_string(tabbing_identifier.as_str()); let _: () = msg_send![native_window, setTabbingIdentifier: tabbing_id]; } else { let _: () = msg_send![native_window, setTabbingIdentifier:nil]; @@ -908,8 +908,8 @@ impl MacWindow { pub fn get_user_tabbing_preference() -> Option { unsafe { let defaults: id = NSUserDefaults::standardUserDefaults(); - let domain = NSString::alloc(nil).init_str("NSGlobalDomain"); - let key = NSString::alloc(nil).init_str("AppleWindowTabbingMode"); + let domain = ns_string("NSGlobalDomain"); + let key = ns_string("AppleWindowTabbingMode"); let dict: id = msg_send![defaults, persistentDomainForName: domain]; let value: id = if !dict.is_null() { @@ -1037,7 +1037,7 @@ impl PlatformWindow for MacWindow { } if let Some(tabbing_identifier) = tabbing_identifier { - let tabbing_id = NSString::alloc(nil).init_str(tabbing_identifier.as_str()); + let tabbing_id = ns_string(tabbing_identifier.as_str()); let _: () = msg_send![native_window, setTabbingIdentifier: tabbing_id]; } else { let _: () = msg_send![native_window, setTabbingIdentifier:nil]; @@ -1063,10 +1063,8 @@ impl PlatformWindow for MacWindow { return None; } let device_description: id = msg_send![screen, deviceDescription]; - let screen_number: id = NSDictionary::valueForKey_( - device_description, - NSString::alloc(nil).init_str("NSScreenNumber"), - ); + let screen_number: id = + NSDictionary::valueForKey_(device_description, ns_string("NSScreenNumber")); let screen_number: u32 = msg_send![screen_number, unsignedIntValue]; @@ -1509,8 +1507,8 @@ impl PlatformWindow for MacWindow { .spawn(async move { unsafe { let defaults: id = NSUserDefaults::standardUserDefaults(); - let domain = NSString::alloc(nil).init_str("NSGlobalDomain"); - let key = NSString::alloc(nil).init_str("AppleActionOnDoubleClick"); + let domain = ns_string("NSGlobalDomain"); + let key = ns_string("AppleActionOnDoubleClick"); let dict: id = msg_send![defaults, persistentDomainForName: domain]; let action: id = if !dict.is_null() { @@ -2512,7 +2510,7 @@ where unsafe fn display_id_for_screen(screen: id) -> CGDirectDisplayID { unsafe { let device_description = NSScreen::deviceDescription(screen); - let screen_number_key: id = NSString::alloc(nil).init_str("NSScreenNumber"); + let screen_number_key: id = ns_string("NSScreenNumber"); let screen_number = device_description.objectForKey_(screen_number_key); let screen_number: NSUInteger = msg_send![screen_number, unsignedIntegerValue]; screen_number as CGDirectDisplayID @@ -2558,7 +2556,7 @@ unsafe fn remove_layer_background(layer: id) { // `description` reflects its name and some parameters. Currently `NSVisualEffectView` // uses a `CAFilter` named "colorSaturate". If one day they switch to `CIFilter`, the // `description` will still contain "Saturat" ("... inputSaturation = ..."). - let test_string: id = NSString::alloc(nil).init_str("Saturat").autorelease(); + let test_string: id = ns_string("Saturat"); let count = NSArray::count(filters); for i in 0..count { let description: id = msg_send![filters.objectAtIndex(i), description]; From 1b29725a605ce284691fda41acd5692403cc8167 Mon Sep 17 00:00:00 2001 From: Xiaobo Liu Date: Tue, 16 Dec 2025 01:48:04 +0800 Subject: [PATCH 312/621] git_ui: Fix Git panel color for staged new files (#44071) Closes https://github.com/zed-industries/zed/issues/38797 Release Notes: - Fixed Git panel color for staged new files Signed-off-by: Xiaobo Liu Co-authored-by: Cole Miller --- crates/git_ui/src/git_panel.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs index cf588d6b0448c2a7c8e7feb50d34c6e405845116..0cca777e07cf14d7f5e8537b2b8b8779cbc2ef64 100644 --- a/crates/git_ui/src/git_panel.rs +++ b/crates/git_ui/src/git_panel.rs @@ -4700,10 +4700,13 @@ impl GitPanel { let has_conflict = status.is_conflicted(); let is_modified = status.is_modified(); let is_deleted = status.is_deleted(); + let is_created = status.is_created(); let label_color = if status_style == StatusStyle::LabelColor { if has_conflict { Color::VersionControlConflict + } else if is_created { + Color::VersionControlAdded } else if is_modified { Color::VersionControlModified } else if is_deleted { From 0d891bd3e5fef696e920e72f48049383113ca055 Mon Sep 17 00:00:00 2001 From: Dominic Burkart Date: Mon, 15 Dec 2025 18:59:40 +0100 Subject: [PATCH 313/621] Enable Zeta edit predictions with custom URL without authentication (#43236) Enables using Zeta edit predictions with a custom `ZED_PREDICT_EDITS_URL` without requiring authentication to Zed servers. This is useful for: - Development and testing workflows - Self-hosted Zeta instances - Custom AI model endpoints Prior context on this usage of `ZED_PREDICT_EDITS_URL`: https://github.com/zed-industries/zed/pull/30418 Release Notes: - Improved self-hosted zeta UX. Users no longer have to log into Zed to use custom or self-hosted zeta backends. --------- Co-authored-by: Agus Zubiaga --- crates/edit_prediction/src/edit_prediction.rs | 97 ++++++---- .../src/edit_prediction_tests.rs | 168 ++++++++++++++++++ crates/edit_prediction/src/zeta1.rs | 26 +-- 3 files changed, 249 insertions(+), 42 deletions(-) diff --git a/crates/edit_prediction/src/edit_prediction.rs b/crates/edit_prediction/src/edit_prediction.rs index ff15d04cc1c0f8e7bbeb7f2a29b520a8ec32097a..f5ea7590fcba97ee916af985824e21cdf4ea725f 100644 --- a/crates/edit_prediction/src/edit_prediction.rs +++ b/crates/edit_prediction/src/edit_prediction.rs @@ -19,6 +19,7 @@ use futures::{ select_biased, }; use gpui::BackgroundExecutor; +use gpui::http_client::Url; use gpui::{ App, AsyncApp, Entity, EntityId, Global, SharedString, Subscription, Task, WeakEntity, actions, http_client::{self, AsyncBody, Method}, @@ -127,15 +128,6 @@ static EDIT_PREDICTIONS_MODEL_ID: LazyLock = LazyLock::new(|| { } .to_string() }); -static PREDICT_EDITS_URL: LazyLock> = LazyLock::new(|| { - env::var("ZED_PREDICT_EDITS_URL").ok().or_else(|| { - if *USE_OLLAMA { - Some("http://localhost:11434/v1/chat/completions".into()) - } else { - None - } - }) -}); pub struct Zeta2FeatureFlag; @@ -170,6 +162,7 @@ pub struct EditPredictionStore { reject_predictions_tx: mpsc::UnboundedSender, shown_predictions: VecDeque, rated_predictions: HashSet, + custom_predict_edits_url: Option>, } #[derive(Copy, Clone, Default, PartialEq, Eq)] @@ -568,6 +561,20 @@ impl EditPredictionStore { reject_predictions_tx: reject_tx, rated_predictions: Default::default(), shown_predictions: Default::default(), + custom_predict_edits_url: match env::var("ZED_PREDICT_EDITS_URL") { + Ok(custom_url) => Url::parse(&custom_url).log_err().map(Into::into), + Err(_) => { + if *USE_OLLAMA { + Some( + Url::parse("http://localhost:11434/v1/chat/completions") + .unwrap() + .into(), + ) + } else { + None + } + } + }, }; this.configure_context_retrieval(cx); @@ -586,6 +593,11 @@ impl EditPredictionStore { this } + #[cfg(test)] + pub fn set_custom_predict_edits_url(&mut self, url: Url) { + self.custom_predict_edits_url = Some(url.into()); + } + pub fn set_edit_prediction_model(&mut self, model: EditPredictionModel) { self.edit_prediction_model = model; } @@ -1015,8 +1027,13 @@ impl EditPredictionStore { } fn accept_current_prediction(&mut self, project: &Entity, cx: &mut Context) { + let custom_accept_url = env::var("ZED_ACCEPT_PREDICTION_URL").ok(); match self.edit_prediction_model { - EditPredictionModel::Zeta1 | EditPredictionModel::Zeta2 => {} + EditPredictionModel::Zeta1 | EditPredictionModel::Zeta2 => { + if self.custom_predict_edits_url.is_some() && custom_accept_url.is_none() { + return; + } + } EditPredictionModel::Sweep | EditPredictionModel::Mercury => return, } @@ -1036,12 +1053,15 @@ impl EditPredictionStore { let llm_token = self.llm_token.clone(); let app_version = AppVersion::global(cx); cx.spawn(async move |this, cx| { - let url = if let Ok(predict_edits_url) = env::var("ZED_ACCEPT_PREDICTION_URL") { - http_client::Url::parse(&predict_edits_url)? + let (url, require_auth) = if let Some(accept_edits_url) = custom_accept_url { + (http_client::Url::parse(&accept_edits_url)?, false) } else { - client - .http_client() - .build_zed_llm_url("/predict_edits/accept", &[])? + ( + client + .http_client() + .build_zed_llm_url("/predict_edits/accept", &[])?, + true, + ) }; let response = cx @@ -1058,6 +1078,7 @@ impl EditPredictionStore { client, llm_token, app_version, + require_auth, )) .await; @@ -1116,6 +1137,7 @@ impl EditPredictionStore { client.clone(), llm_token.clone(), app_version.clone(), + true, ) .await; @@ -1161,7 +1183,11 @@ impl EditPredictionStore { was_shown: bool, ) { match self.edit_prediction_model { - EditPredictionModel::Zeta1 | EditPredictionModel::Zeta2 => {} + EditPredictionModel::Zeta1 | EditPredictionModel::Zeta2 => { + if self.custom_predict_edits_url.is_some() { + return; + } + } EditPredictionModel::Sweep | EditPredictionModel::Mercury => return, } @@ -1671,13 +1697,9 @@ impl EditPredictionStore { #[cfg(feature = "cli-support")] eval_cache: Option>, #[cfg(feature = "cli-support")] eval_cache_kind: EvalCacheEntryKind, ) -> Result<(open_ai::Response, Option)> { - let url = if let Some(predict_edits_url) = PREDICT_EDITS_URL.as_ref() { - http_client::Url::parse(&predict_edits_url)? - } else { - client - .http_client() - .build_zed_llm_url("/predict_edits/raw", &[])? - }; + let url = client + .http_client() + .build_zed_llm_url("/predict_edits/raw", &[])?; #[cfg(feature = "cli-support")] let cache_key = if let Some(cache) = eval_cache { @@ -1710,6 +1732,7 @@ impl EditPredictionStore { client, llm_token, app_version, + true, ) .await?; @@ -1770,23 +1793,34 @@ impl EditPredictionStore { client: Arc, llm_token: LlmApiToken, app_version: Version, + require_auth: bool, ) -> Result<(Res, Option)> where Res: DeserializeOwned, { let http_client = client.http_client(); - let mut token = llm_token.acquire(&client).await?; + + let mut token = if require_auth { + Some(llm_token.acquire(&client).await?) + } else { + llm_token.acquire(&client).await.ok() + }; let mut did_retry = false; loop { let request_builder = http_client::Request::builder().method(Method::POST); - let request = build( - request_builder - .header("Content-Type", "application/json") - .header("Authorization", format!("Bearer {}", token)) - .header(ZED_VERSION_HEADER_NAME, app_version.to_string()), - )?; + let mut request_builder = request_builder + .header("Content-Type", "application/json") + .header(ZED_VERSION_HEADER_NAME, app_version.to_string()); + + // Only add Authorization header if we have a token + if let Some(ref token_value) = token { + request_builder = + request_builder.header("Authorization", format!("Bearer {}", token_value)); + } + + let request = build(request_builder)?; let mut response = http_client.send(request).await?; @@ -1810,13 +1844,14 @@ impl EditPredictionStore { response.body_mut().read_to_end(&mut body).await?; return Ok((serde_json::from_slice(&body)?, usage)); } else if !did_retry + && token.is_some() && response .headers() .get(EXPIRED_LLM_TOKEN_HEADER_NAME) .is_some() { did_retry = true; - token = llm_token.refresh(&client).await?; + token = Some(llm_token.refresh(&client).await?); } else { let mut body = String::new(); response.body_mut().read_to_string(&mut body).await?; diff --git a/crates/edit_prediction/src/edit_prediction_tests.rs b/crates/edit_prediction/src/edit_prediction_tests.rs index 5067aa0050d7a0831ca7668d17188fa6d41637b9..eee3f1f79e93b60ee3ea7c80bd987af22d613833 100644 --- a/crates/edit_prediction/src/edit_prediction_tests.rs +++ b/crates/edit_prediction/src/edit_prediction_tests.rs @@ -1914,6 +1914,174 @@ fn from_completion_edits( .collect() } +#[gpui::test] +async fn test_unauthenticated_without_custom_url_blocks_prediction_impl(cx: &mut TestAppContext) { + init_test(cx); + + let fs = FakeFs::new(cx.executor()); + fs.insert_tree( + "/project", + serde_json::json!({ + "main.rs": "fn main() {\n \n}\n" + }), + ) + .await; + + let project = Project::test(fs.clone(), [path!("/project").as_ref()], cx).await; + + let http_client = FakeHttpClient::create(|_req| async move { + Ok(gpui::http_client::Response::builder() + .status(401) + .body("Unauthorized".into()) + .unwrap()) + }); + + let client = + cx.update(|cx| client::Client::new(Arc::new(FakeSystemClock::new()), http_client, cx)); + cx.update(|cx| { + language_model::RefreshLlmTokenListener::register(client.clone(), cx); + }); + + let ep_store = cx.new(|cx| EditPredictionStore::new(client, project.read(cx).user_store(), cx)); + + let buffer = project + .update(cx, |project, cx| { + let path = project + .find_project_path(path!("/project/main.rs"), cx) + .unwrap(); + project.open_buffer(path, cx) + }) + .await + .unwrap(); + + let cursor = buffer.read_with(cx, |buffer, _| buffer.anchor_before(Point::new(1, 4))); + ep_store.update(cx, |ep_store, cx| { + ep_store.register_buffer(&buffer, &project, cx) + }); + cx.background_executor.run_until_parked(); + + let completion_task = ep_store.update(cx, |ep_store, cx| { + ep_store.set_edit_prediction_model(EditPredictionModel::Zeta1); + ep_store.request_prediction(&project, &buffer, cursor, Default::default(), cx) + }); + + let result = completion_task.await; + assert!( + result.is_err(), + "Without authentication and without custom URL, prediction should fail" + ); +} + +#[gpui::test] +async fn test_unauthenticated_with_custom_url_allows_prediction_impl(cx: &mut TestAppContext) { + init_test(cx); + + let fs = FakeFs::new(cx.executor()); + fs.insert_tree( + "/project", + serde_json::json!({ + "main.rs": "fn main() {\n \n}\n" + }), + ) + .await; + + let project = Project::test(fs.clone(), [path!("/project").as_ref()], cx).await; + + let predict_called = Arc::new(std::sync::atomic::AtomicBool::new(false)); + let predict_called_clone = predict_called.clone(); + + let http_client = FakeHttpClient::create({ + move |req| { + let uri = req.uri().path().to_string(); + let predict_called = predict_called_clone.clone(); + async move { + if uri.contains("predict") { + predict_called.store(true, std::sync::atomic::Ordering::SeqCst); + Ok(gpui::http_client::Response::builder() + .body( + serde_json::to_string(&open_ai::Response { + id: "test-123".to_string(), + object: "chat.completion".to_string(), + created: 0, + model: "test".to_string(), + usage: open_ai::Usage { + prompt_tokens: 0, + completion_tokens: 0, + total_tokens: 0, + }, + choices: vec![open_ai::Choice { + index: 0, + message: open_ai::RequestMessage::Assistant { + content: Some(open_ai::MessageContent::Plain( + indoc! {" + ```main.rs + <|start_of_file|> + <|editable_region_start|> + fn main() { + println!(\"Hello, world!\"); + } + <|editable_region_end|> + ``` + "} + .to_string(), + )), + tool_calls: vec![], + }, + finish_reason: Some("stop".to_string()), + }], + }) + .unwrap() + .into(), + ) + .unwrap()) + } else { + Ok(gpui::http_client::Response::builder() + .status(401) + .body("Unauthorized".into()) + .unwrap()) + } + } + } + }); + + let client = + cx.update(|cx| client::Client::new(Arc::new(FakeSystemClock::new()), http_client, cx)); + cx.update(|cx| { + language_model::RefreshLlmTokenListener::register(client.clone(), cx); + }); + + let ep_store = cx.new(|cx| EditPredictionStore::new(client, project.read(cx).user_store(), cx)); + + let buffer = project + .update(cx, |project, cx| { + let path = project + .find_project_path(path!("/project/main.rs"), cx) + .unwrap(); + project.open_buffer(path, cx) + }) + .await + .unwrap(); + + let cursor = buffer.read_with(cx, |buffer, _| buffer.anchor_before(Point::new(1, 4))); + ep_store.update(cx, |ep_store, cx| { + ep_store.register_buffer(&buffer, &project, cx) + }); + cx.background_executor.run_until_parked(); + + let completion_task = ep_store.update(cx, |ep_store, cx| { + ep_store.set_custom_predict_edits_url(Url::parse("http://test/predict").unwrap()); + ep_store.set_edit_prediction_model(EditPredictionModel::Zeta1); + ep_store.request_prediction(&project, &buffer, cursor, Default::default(), cx) + }); + + let _ = completion_task.await; + + assert!( + predict_called.load(std::sync::atomic::Ordering::SeqCst), + "With custom URL, predict endpoint should be called even without authentication" + ); +} + #[ctor::ctor] fn init_logger() { zlog::init_test(); diff --git a/crates/edit_prediction/src/zeta1.rs b/crates/edit_prediction/src/zeta1.rs index ed531749cb39d10d71d18947990dd1972f23a986..01c26573307e66cd6ca3bf8ab748ba8d082ea688 100644 --- a/crates/edit_prediction/src/zeta1.rs +++ b/crates/edit_prediction/src/zeta1.rs @@ -78,6 +78,19 @@ pub(crate) fn request_prediction_with_zeta1( cx, ); + let (uri, require_auth) = match &store.custom_predict_edits_url { + Some(custom_url) => (custom_url.clone(), false), + None => { + match client + .http_client() + .build_zed_llm_url("/predict_edits/v2", &[]) + { + Ok(url) => (url.into(), true), + Err(err) => return Task::ready(Err(err)), + } + } + }; + cx.spawn(async move |this, cx| { let GatherContextOutput { mut body, @@ -102,25 +115,16 @@ pub(crate) fn request_prediction_with_zeta1( body.input_excerpt ); - let http_client = client.http_client(); - let response = EditPredictionStore::send_api_request::( |request| { - let uri = if let Ok(predict_edits_url) = std::env::var("ZED_PREDICT_EDITS_URL") { - predict_edits_url - } else { - http_client - .build_zed_llm_url("/predict_edits/v2", &[])? - .as_str() - .into() - }; Ok(request - .uri(uri) + .uri(uri.as_str()) .body(serde_json::to_string(&body)?.into())?) }, client, llm_token, app_version, + require_auth, ) .await; From d4f965724c437aaf2a1a11635838fa9b7224b4ce Mon Sep 17 00:00:00 2001 From: teleoflexuous <116514517+teleoflexuous@users.noreply.github.com> Date: Mon, 15 Dec 2025 19:28:59 +0100 Subject: [PATCH 314/621] editor: Accept next line prediction (#44411) Closes [#20574](https://github.com/zed-industries/zed/issues/20574) Release Notes: - Replaced editor action editor::AcceptPartialEditPrediction with editor::AcceptNextLineEditPrediction and editor::AcceptNextWordEditPrediction Tested manually on windows, attaching screen cap. https://github.com/user-attachments/assets/fea04499-fd16-4b7d-a6aa-3661bb85cf4f Updated existing test for accepting word prediction in copilot - it is already marked as flaky, not sure what to do about it and I'm not really confident creating new one without a working example. Added migration of keymaps and new defaults for windows, linux, macos in defaults and in cursor. This should alleviate [#21645](https://github.com/zed-industries/zed/issues/21645) I used some work done in stale PR https://github.com/zed-industries/zed/pull/25274, hopefully this one makes it through! --------- Co-authored-by: Agus Zubiaga --- assets/keymaps/default-linux.json | 6 +- assets/keymaps/default-macos.json | 6 +- assets/keymaps/default-windows.json | 6 +- assets/keymaps/macos/cursor.json | 3 +- crates/agent_ui/src/agent_ui.rs | 8 +- .../src/copilot_edit_prediction_delegate.rs | 13 +- .../src/edit_prediction_types.rs | 6 + crates/editor/src/actions.rs | 3 +- crates/editor/src/editor.rs | 349 ++++++++++-------- crates/editor/src/element.rs | 11 +- crates/migrator/src/migrations.rs | 6 + .../src/migrations/m_2025_12_08/keymap.rs | 33 ++ crates/migrator/src/migrator.rs | 8 + docs/src/ai/edit-prediction.md | 3 +- 14 files changed, 279 insertions(+), 182 deletions(-) create mode 100644 crates/migrator/src/migrations/m_2025_12_08/keymap.rs diff --git a/assets/keymaps/default-linux.json b/assets/keymaps/default-linux.json index 342c4b0b7cb9608c13bed2899dd67b3ac0378db5..aac9dcf706856703800068e9e4b7ce9e94d73ecb 100644 --- a/assets/keymaps/default-linux.json +++ b/assets/keymaps/default-linux.json @@ -746,7 +746,8 @@ "alt-tab": "editor::AcceptEditPrediction", "alt-l": "editor::AcceptEditPrediction", "tab": "editor::AcceptEditPrediction", - "alt-right": "editor::AcceptPartialEditPrediction", + "alt-right": "editor::AcceptNextWordEditPrediction", + "alt-down": "editor::AcceptNextLineEditPrediction", }, }, { @@ -754,7 +755,8 @@ "bindings": { "alt-tab": "editor::AcceptEditPrediction", "alt-l": "editor::AcceptEditPrediction", - "alt-right": "editor::AcceptPartialEditPrediction", + "alt-right": "editor::AcceptNextWordEditPrediction", + "alt-down": "editor::AcceptNextLineEditPrediction", }, }, { diff --git a/assets/keymaps/default-macos.json b/assets/keymaps/default-macos.json index 50fc0c7222b76c9e5218c47a481442534debe2b0..224f6755465d63df0802e3b3919dbdf2ba82246d 100644 --- a/assets/keymaps/default-macos.json +++ b/assets/keymaps/default-macos.json @@ -810,7 +810,8 @@ "bindings": { "alt-tab": "editor::AcceptEditPrediction", "tab": "editor::AcceptEditPrediction", - "ctrl-cmd-right": "editor::AcceptPartialEditPrediction", + "ctrl-cmd-right": "editor::AcceptNextWordEditPrediction", + "ctrl-cmd-down": "editor::AcceptNextLineEditPrediction", }, }, { @@ -818,7 +819,8 @@ "use_key_equivalents": true, "bindings": { "alt-tab": "editor::AcceptEditPrediction", - "ctrl-cmd-right": "editor::AcceptPartialEditPrediction", + "ctrl-cmd-right": "editor::AcceptNextWordEditPrediction", + "ctrl-cmd-down": "editor::AcceptNextLineEditPrediction", }, }, { diff --git a/assets/keymaps/default-windows.json b/assets/keymaps/default-windows.json index 61793d2158d35ed25f71da3606534d64b523de9f..5626309ecb2e17fbbff53347da6059cd2db3be31 100644 --- a/assets/keymaps/default-windows.json +++ b/assets/keymaps/default-windows.json @@ -747,7 +747,8 @@ "alt-tab": "editor::AcceptEditPrediction", "alt-l": "editor::AcceptEditPrediction", "tab": "editor::AcceptEditPrediction", - "alt-right": "editor::AcceptPartialEditPrediction", + "alt-right": "editor::AcceptNextWordEditPrediction", + "alt-down": "editor::AcceptNextLineEditPrediction", }, }, { @@ -756,7 +757,8 @@ "bindings": { "alt-tab": "editor::AcceptEditPrediction", "alt-l": "editor::AcceptEditPrediction", - "alt-right": "editor::AcceptPartialEditPrediction", + "alt-right": "editor::AcceptNextWordEditPrediction", + "alt-down": "editor::AcceptNextLineEditPrediction", }, }, { diff --git a/assets/keymaps/macos/cursor.json b/assets/keymaps/macos/cursor.json index 6a2f46e0ce6d037de6de2d801d80671c63a3e3cd..93e259db37ac718d2e0258d83e4de436a0a378fd 100644 --- a/assets/keymaps/macos/cursor.json +++ b/assets/keymaps/macos/cursor.json @@ -71,7 +71,8 @@ "context": "Editor && mode == full && edit_prediction", "use_key_equivalents": true, "bindings": { - "cmd-right": "editor::AcceptPartialEditPrediction", + "cmd-right": "editor::AcceptNextWordEditPrediction", + "cmd-down": "editor::AcceptNextLineEditPrediction", }, }, { diff --git a/crates/agent_ui/src/agent_ui.rs b/crates/agent_ui/src/agent_ui.rs index dd8f6912ec9829e7be93ce340d2c8eef8134f897..3a0cc74bef611175b82884bd87e521c5a968d54a 100644 --- a/crates/agent_ui/src/agent_ui.rs +++ b/crates/agent_ui/src/agent_ui.rs @@ -261,12 +261,14 @@ fn update_command_palette_filter(cx: &mut App) { CommandPaletteFilter::update_global(cx, |filter, _| { use editor::actions::{ - AcceptEditPrediction, AcceptPartialEditPrediction, NextEditPrediction, - PreviousEditPrediction, ShowEditPrediction, ToggleEditPrediction, + AcceptEditPrediction, AcceptNextLineEditPrediction, AcceptNextWordEditPrediction, + NextEditPrediction, PreviousEditPrediction, ShowEditPrediction, ToggleEditPrediction, }; let edit_prediction_actions = [ TypeId::of::(), - TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), TypeId::of::(), TypeId::of::(), TypeId::of::(), diff --git a/crates/copilot/src/copilot_edit_prediction_delegate.rs b/crates/copilot/src/copilot_edit_prediction_delegate.rs index 961154dbeecad007f026f25eeac25de95d751d9e..0e0cfe6cdca78d2a8b382269ce1ca9a340d1e69c 100644 --- a/crates/copilot/src/copilot_edit_prediction_delegate.rs +++ b/crates/copilot/src/copilot_edit_prediction_delegate.rs @@ -269,6 +269,7 @@ fn common_prefix, T2: Iterator>(a: T1, b: #[cfg(test)] mod tests { use super::*; + use edit_prediction_types::EditPredictionGranularity; use editor::{ Editor, ExcerptRange, MultiBuffer, MultiBufferOffset, SelectionEffects, test::editor_lsp_test_context::EditorLspTestContext, @@ -581,13 +582,15 @@ mod tests { assert!(editor.has_active_edit_prediction()); // Accepting the first word of the suggestion should only accept the first word and still show the rest. - editor.accept_partial_edit_prediction(&Default::default(), window, cx); + editor.accept_partial_edit_prediction(EditPredictionGranularity::Word, window, cx); + assert!(editor.has_active_edit_prediction()); assert_eq!(editor.text(cx), "one.copilot\ntwo\nthree\n"); assert_eq!(editor.display_text(cx), "one.copilot1\ntwo\nthree\n"); // Accepting next word should accept the non-word and copilot suggestion should be gone - editor.accept_partial_edit_prediction(&Default::default(), window, cx); + editor.accept_partial_edit_prediction(EditPredictionGranularity::Word, window, cx); + assert!(!editor.has_active_edit_prediction()); assert_eq!(editor.text(cx), "one.copilot1\ntwo\nthree\n"); assert_eq!(editor.display_text(cx), "one.copilot1\ntwo\nthree\n"); @@ -623,7 +626,7 @@ mod tests { assert!(editor.has_active_edit_prediction()); // Accepting the first word (non-word) of the suggestion should only accept the first word and still show the rest. - editor.accept_partial_edit_prediction(&Default::default(), window, cx); + editor.accept_partial_edit_prediction(EditPredictionGranularity::Word, window, cx); assert!(editor.has_active_edit_prediction()); assert_eq!(editor.text(cx), "one.123. \ntwo\nthree\n"); assert_eq!( @@ -632,7 +635,7 @@ mod tests { ); // Accepting next word should accept the next word and copilot suggestion should still exist - editor.accept_partial_edit_prediction(&Default::default(), window, cx); + editor.accept_partial_edit_prediction(EditPredictionGranularity::Word, window, cx); assert!(editor.has_active_edit_prediction()); assert_eq!(editor.text(cx), "one.123. copilot\ntwo\nthree\n"); assert_eq!( @@ -641,7 +644,7 @@ mod tests { ); // Accepting the whitespace should accept the non-word/whitespaces with newline and copilot suggestion should be gone - editor.accept_partial_edit_prediction(&Default::default(), window, cx); + editor.accept_partial_edit_prediction(EditPredictionGranularity::Word, window, cx); assert!(!editor.has_active_edit_prediction()); assert_eq!(editor.text(cx), "one.123. copilot\n 456\ntwo\nthree\n"); assert_eq!( diff --git a/crates/edit_prediction_types/src/edit_prediction_types.rs b/crates/edit_prediction_types/src/edit_prediction_types.rs index fbcb3c4c00edbc5fb77f04d1fcaaf4b6129c43db..945cfea4a168af4470d98ca844f311a79de9800a 100644 --- a/crates/edit_prediction_types/src/edit_prediction_types.rs +++ b/crates/edit_prediction_types/src/edit_prediction_types.rs @@ -249,6 +249,12 @@ where } } +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum EditPredictionGranularity { + Word, + Line, + Full, +} /// Returns edits updated based on user edits since the old snapshot. None is returned if any user /// edit is not a prefix of a predicted insertion. pub fn interpolate_edits( diff --git a/crates/editor/src/actions.rs b/crates/editor/src/actions.rs index fb058eb8d7c5ad72a2b2656c3ce943871a623163..ba36f88f6380ade2a0d70f0f7ac3eb221446b781 100644 --- a/crates/editor/src/actions.rs +++ b/crates/editor/src/actions.rs @@ -370,7 +370,8 @@ actions!( AcceptEditPrediction, /// Accepts a partial edit prediction. #[action(deprecated_aliases = ["editor::AcceptPartialCopilotSuggestion"])] - AcceptPartialEditPrediction, + AcceptNextWordEditPrediction, + AcceptNextLineEditPrediction, /// Applies all diff hunks in the editor. ApplyAllDiffHunks, /// Applies the diff hunk at the current position. diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index afa62e5ff31436ef178a94dc0ff8bedfc2691e60..bea7d79779b3a1f8ae0473e26235a2a992f7b030 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -92,7 +92,9 @@ use collections::{BTreeMap, HashMap, HashSet, VecDeque}; use convert_case::{Case, Casing}; use dap::TelemetrySpawnLocation; use display_map::*; -use edit_prediction_types::{EditPredictionDelegate, EditPredictionDelegateHandle}; +use edit_prediction_types::{ + EditPredictionDelegate, EditPredictionDelegateHandle, EditPredictionGranularity, +}; use editor_settings::{GoToDefinitionFallback, Minimap as MinimapSettings}; use element::{AcceptEditPredictionBinding, LineWithInvisibles, PositionMap, layout_line}; use futures::{ @@ -2778,21 +2780,24 @@ impl Editor { pub fn accept_edit_prediction_keybind( &self, - accept_partial: bool, + granularity: EditPredictionGranularity, window: &mut Window, cx: &mut App, ) -> AcceptEditPredictionBinding { let key_context = self.key_context_internal(true, window, cx); let in_conflict = self.edit_prediction_in_conflict(); - let bindings = if accept_partial { - window.bindings_for_action_in_context(&AcceptPartialEditPrediction, key_context) - } else { - window.bindings_for_action_in_context(&AcceptEditPrediction, key_context) - }; + let bindings = + match granularity { + EditPredictionGranularity::Word => window + .bindings_for_action_in_context(&AcceptNextWordEditPrediction, key_context), + EditPredictionGranularity::Line => window + .bindings_for_action_in_context(&AcceptNextLineEditPrediction, key_context), + EditPredictionGranularity::Full => { + window.bindings_for_action_in_context(&AcceptEditPrediction, key_context) + } + }; - // TODO: if the binding contains multiple keystrokes, display all of them, not - // just the first one. AcceptEditPredictionBinding(bindings.into_iter().rev().find(|binding| { !in_conflict || binding @@ -7633,9 +7638,9 @@ impl Editor { } } - pub fn accept_edit_prediction( + pub fn accept_partial_edit_prediction( &mut self, - _: &AcceptEditPrediction, + granularity: EditPredictionGranularity, window: &mut Window, cx: &mut Context, ) { @@ -7647,47 +7652,59 @@ impl Editor { return; }; + if !matches!(granularity, EditPredictionGranularity::Full) && self.selections.count() != 1 { + return; + } + match &active_edit_prediction.completion { EditPrediction::MoveWithin { target, .. } => { let target = *target; - if let Some(position_map) = &self.last_position_map { - if position_map - .visible_row_range - .contains(&target.to_display_point(&position_map.snapshot).row()) - || !self.edit_prediction_requires_modifier() - { - self.unfold_ranges(&[target..target], true, false, cx); - // Note that this is also done in vim's handler of the Tab action. - self.change_selections( - SelectionEffects::scroll(Autoscroll::newest()), - window, - cx, - |selections| { - selections.select_anchor_ranges([target..target]); - }, - ); - self.clear_row_highlights::(); + if matches!(granularity, EditPredictionGranularity::Full) { + if let Some(position_map) = &self.last_position_map { + let target_row = target.to_display_point(&position_map.snapshot).row(); + let is_visible = position_map.visible_row_range.contains(&target_row); - self.edit_prediction_preview - .set_previous_scroll_position(None); - } else { - self.edit_prediction_preview - .set_previous_scroll_position(Some( - position_map.snapshot.scroll_anchor, - )); - - self.highlight_rows::( - target..target, - cx.theme().colors().editor_highlighted_line_background, - RowHighlightOptions { - autoscroll: true, - ..Default::default() - }, - cx, - ); - self.request_autoscroll(Autoscroll::fit(), cx); + if is_visible || !self.edit_prediction_requires_modifier() { + self.unfold_ranges(&[target..target], true, false, cx); + self.change_selections( + SelectionEffects::scroll(Autoscroll::newest()), + window, + cx, + |selections| { + selections.select_anchor_ranges([target..target]); + }, + ); + self.clear_row_highlights::(); + self.edit_prediction_preview + .set_previous_scroll_position(None); + } else { + // Highlight and request scroll + self.edit_prediction_preview + .set_previous_scroll_position(Some( + position_map.snapshot.scroll_anchor, + )); + self.highlight_rows::( + target..target, + cx.theme().colors().editor_highlighted_line_background, + RowHighlightOptions { + autoscroll: true, + ..Default::default() + }, + cx, + ); + self.request_autoscroll(Autoscroll::fit(), cx); + } } + } else { + self.change_selections( + SelectionEffects::scroll(Autoscroll::newest()), + window, + cx, + |selections| { + selections.select_anchor_ranges([target..target]); + }, + ); } } EditPrediction::MoveOutside { snapshot, target } => { @@ -7703,126 +7720,131 @@ impl Editor { cx, ); - if let Some(provider) = self.edit_prediction_provider() { - provider.accept(cx); - } + match granularity { + EditPredictionGranularity::Full => { + if let Some(provider) = self.edit_prediction_provider() { + provider.accept(cx); + } - // Store the transaction ID and selections before applying the edit - let transaction_id_prev = self.buffer.read(cx).last_transaction_id(cx); + let transaction_id_prev = self.buffer.read(cx).last_transaction_id(cx); + let snapshot = self.buffer.read(cx).snapshot(cx); + let last_edit_end = edits.last().unwrap().0.end.bias_right(&snapshot); - let snapshot = self.buffer.read(cx).snapshot(cx); - let last_edit_end = edits.last().unwrap().0.end.bias_right(&snapshot); + self.buffer.update(cx, |buffer, cx| { + buffer.edit(edits.iter().cloned(), None, cx) + }); - self.buffer.update(cx, |buffer, cx| { - buffer.edit(edits.iter().cloned(), None, cx) - }); + self.change_selections(SelectionEffects::no_scroll(), window, cx, |s| { + s.select_anchor_ranges([last_edit_end..last_edit_end]); + }); - self.change_selections(SelectionEffects::no_scroll(), window, cx, |s| { - s.select_anchor_ranges([last_edit_end..last_edit_end]); - }); + let selections = self.selections.disjoint_anchors_arc(); + if let Some(transaction_id_now) = + self.buffer.read(cx).last_transaction_id(cx) + { + if transaction_id_prev != Some(transaction_id_now) { + self.selection_history + .insert_transaction(transaction_id_now, selections); + } + } - let selections = self.selections.disjoint_anchors_arc(); - if let Some(transaction_id_now) = self.buffer.read(cx).last_transaction_id(cx) { - let has_new_transaction = transaction_id_prev != Some(transaction_id_now); - if has_new_transaction { - self.selection_history - .insert_transaction(transaction_id_now, selections); + self.update_visible_edit_prediction(window, cx); + if self.active_edit_prediction.is_none() { + self.refresh_edit_prediction(true, true, window, cx); + } + cx.notify(); } - } + _ => { + let snapshot = self.buffer.read(cx).snapshot(cx); + let cursor_offset = self + .selections + .newest::(&self.display_snapshot(cx)) + .head(); + + let insertion = edits.iter().find_map(|(range, text)| { + let range = range.to_offset(&snapshot); + if range.is_empty() && range.start == cursor_offset { + Some(text) + } else { + None + } + }); - self.update_visible_edit_prediction(window, cx); - if self.active_edit_prediction.is_none() { - self.refresh_edit_prediction(true, true, window, cx); - } + if let Some(text) = insertion { + let text_to_insert = match granularity { + EditPredictionGranularity::Word => { + let mut partial = text + .chars() + .by_ref() + .take_while(|c| c.is_alphabetic()) + .collect::(); + if partial.is_empty() { + partial = text + .chars() + .by_ref() + .take_while(|c| c.is_whitespace() || !c.is_alphabetic()) + .collect::(); + } + partial + } + EditPredictionGranularity::Line => { + if let Some(line) = text.split_inclusive('\n').next() { + line.to_string() + } else { + text.to_string() + } + } + EditPredictionGranularity::Full => unreachable!(), + }; - cx.notify(); + cx.emit(EditorEvent::InputHandled { + utf16_range_to_replace: None, + text: text_to_insert.clone().into(), + }); + + self.insert_with_autoindent_mode(&text_to_insert, None, window, cx); + self.refresh_edit_prediction(true, true, window, cx); + cx.notify(); + } else { + self.accept_partial_edit_prediction( + EditPredictionGranularity::Full, + window, + cx, + ); + } + } + } } } self.edit_prediction_requires_modifier_in_indent_conflict = false; } - pub fn accept_partial_edit_prediction( + pub fn accept_next_word_edit_prediction( &mut self, - _: &AcceptPartialEditPrediction, + _: &AcceptNextWordEditPrediction, window: &mut Window, cx: &mut Context, ) { - let Some(active_edit_prediction) = self.active_edit_prediction.as_ref() else { - return; - }; - if self.selections.count() != 1 { - return; - } - - match &active_edit_prediction.completion { - EditPrediction::MoveWithin { target, .. } => { - let target = *target; - self.change_selections( - SelectionEffects::scroll(Autoscroll::newest()), - window, - cx, - |selections| { - selections.select_anchor_ranges([target..target]); - }, - ); - } - EditPrediction::MoveOutside { snapshot, target } => { - if let Some(workspace) = self.workspace() { - Self::open_editor_at_anchor(snapshot, *target, &workspace, window, cx) - .detach_and_log_err(cx); - } - } - EditPrediction::Edit { edits, .. } => { - self.report_edit_prediction_event( - active_edit_prediction.completion_id.clone(), - true, - cx, - ); - - // Find an insertion that starts at the cursor position. - let snapshot = self.buffer.read(cx).snapshot(cx); - let cursor_offset = self - .selections - .newest::(&self.display_snapshot(cx)) - .head(); - let insertion = edits.iter().find_map(|(range, text)| { - let range = range.to_offset(&snapshot); - if range.is_empty() && range.start == cursor_offset { - Some(text) - } else { - None - } - }); - - if let Some(text) = insertion { - let mut partial_completion = text - .chars() - .by_ref() - .take_while(|c| c.is_alphabetic()) - .collect::(); - if partial_completion.is_empty() { - partial_completion = text - .chars() - .by_ref() - .take_while(|c| c.is_whitespace() || !c.is_alphabetic()) - .collect::(); - } - - cx.emit(EditorEvent::InputHandled { - utf16_range_to_replace: None, - text: partial_completion.clone().into(), - }); + self.accept_partial_edit_prediction(EditPredictionGranularity::Word, window, cx); + } - self.insert_with_autoindent_mode(&partial_completion, None, window, cx); + pub fn accept_next_line_edit_prediction( + &mut self, + _: &AcceptNextLineEditPrediction, + window: &mut Window, + cx: &mut Context, + ) { + self.accept_partial_edit_prediction(EditPredictionGranularity::Line, window, cx); + } - self.refresh_edit_prediction(true, true, window, cx); - cx.notify(); - } else { - self.accept_edit_prediction(&Default::default(), window, cx); - } - } - } + pub fn accept_edit_prediction( + &mut self, + _: &AcceptEditPrediction, + window: &mut Window, + cx: &mut Context, + ) { + self.accept_partial_edit_prediction(EditPredictionGranularity::Full, window, cx); } fn discard_edit_prediction( @@ -8042,21 +8064,23 @@ impl Editor { cx: &mut Context, ) { let mut modifiers_held = false; - if let Some(accept_keystroke) = self - .accept_edit_prediction_keybind(false, window, cx) - .keystroke() - { - modifiers_held = modifiers_held - || (accept_keystroke.modifiers() == modifiers - && accept_keystroke.modifiers().modified()); - }; - if let Some(accept_partial_keystroke) = self - .accept_edit_prediction_keybind(true, window, cx) - .keystroke() - { - modifiers_held = modifiers_held - || (accept_partial_keystroke.modifiers() == modifiers - && accept_partial_keystroke.modifiers().modified()); + + // Check bindings for all granularities. + // If the user holds the key for Word, Line, or Full, we want to show the preview. + let granularities = [ + EditPredictionGranularity::Full, + EditPredictionGranularity::Line, + EditPredictionGranularity::Word, + ]; + + for granularity in granularities { + if let Some(keystroke) = self + .accept_edit_prediction_keybind(granularity, window, cx) + .keystroke() + { + modifiers_held = modifiers_held + || (keystroke.modifiers() == modifiers && keystroke.modifiers().modified()); + } } if modifiers_held { @@ -9476,7 +9500,8 @@ impl Editor { window: &mut Window, cx: &mut App, ) -> Option { - let accept_binding = self.accept_edit_prediction_keybind(false, window, cx); + let accept_binding = + self.accept_edit_prediction_keybind(EditPredictionGranularity::Full, window, cx); let accept_keystroke = accept_binding.keystroke()?; let is_platform_style_mac = PlatformStyle::platform() == PlatformStyle::Mac; diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index 3b16fa1be173ab1a5edbc9bbaad20a3d6b1493e7..8de660275ba9b455aec610568c41347888654495 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -62,6 +62,7 @@ use multi_buffer::{ MultiBufferRow, RowInfo, }; +use edit_prediction_types::EditPredictionGranularity; use project::{ Entry, ProjectPath, debugger::breakpoint_store::{Breakpoint, BreakpointSessionState}, @@ -603,7 +604,8 @@ impl EditorElement { register_action(editor, window, Editor::display_cursor_names); register_action(editor, window, Editor::unique_lines_case_insensitive); register_action(editor, window, Editor::unique_lines_case_sensitive); - register_action(editor, window, Editor::accept_partial_edit_prediction); + register_action(editor, window, Editor::accept_next_word_edit_prediction); + register_action(editor, window, Editor::accept_next_line_edit_prediction); register_action(editor, window, Editor::accept_edit_prediction); register_action(editor, window, Editor::restore_file); register_action(editor, window, Editor::git_restore); @@ -4900,8 +4902,11 @@ impl EditorElement { let edit_prediction = if edit_prediction_popover_visible { self.editor.update(cx, move |editor, cx| { - let accept_binding = - editor.accept_edit_prediction_keybind(false, window, cx); + let accept_binding = editor.accept_edit_prediction_keybind( + EditPredictionGranularity::Full, + window, + cx, + ); let mut element = editor.render_edit_prediction_cursor_popover( min_width, max_width, diff --git a/crates/migrator/src/migrations.rs b/crates/migrator/src/migrations.rs index 398d5aaf9405d34e8d8a4e93d5c9b9045ee49118..a479379a674589c748e22fc18beb8ee7c85df652 100644 --- a/crates/migrator/src/migrations.rs +++ b/crates/migrator/src/migrations.rs @@ -159,3 +159,9 @@ pub(crate) mod m_2025_12_01 { pub(crate) use settings::SETTINGS_PATTERNS; } + +pub(crate) mod m_2025_12_08 { + mod keymap; + + pub(crate) use keymap::KEYMAP_PATTERNS; +} diff --git a/crates/migrator/src/migrations/m_2025_12_08/keymap.rs b/crates/migrator/src/migrations/m_2025_12_08/keymap.rs new file mode 100644 index 0000000000000000000000000000000000000000..70acf4e453486526a30540bf2a15c34d6537411c --- /dev/null +++ b/crates/migrator/src/migrations/m_2025_12_08/keymap.rs @@ -0,0 +1,33 @@ +use collections::HashMap; +use std::{ops::Range, sync::LazyLock}; +use tree_sitter::{Query, QueryMatch}; + +use crate::MigrationPatterns; +use crate::patterns::KEYMAP_ACTION_STRING_PATTERN; + +pub const KEYMAP_PATTERNS: MigrationPatterns = + &[(KEYMAP_ACTION_STRING_PATTERN, replace_string_action)]; + +fn replace_string_action( + contents: &str, + mat: &QueryMatch, + query: &Query, +) -> Option<(Range, String)> { + let action_name_ix = query.capture_index_for_name("action_name")?; + let action_name_node = mat.nodes_for_capture_index(action_name_ix).next()?; + let action_name_range = action_name_node.byte_range(); + let action_name = contents.get(action_name_range.clone())?; + + if let Some(new_action_name) = STRING_REPLACE.get(&action_name) { + return Some((action_name_range, new_action_name.to_string())); + } + + None +} + +static STRING_REPLACE: LazyLock> = LazyLock::new(|| { + HashMap::from_iter([( + "editor::AcceptPartialEditPrediction", + "editor::AcceptNextWordEditPrediction", + )]) +}); diff --git a/crates/migrator/src/migrator.rs b/crates/migrator/src/migrator.rs index 9fb6d8a1151719f350ea7877bfe2492d6b443c23..23a24ae199cd076b76b3df2b0d68712f059fd32e 100644 --- a/crates/migrator/src/migrator.rs +++ b/crates/migrator/src/migrator.rs @@ -139,6 +139,10 @@ pub fn migrate_keymap(text: &str) -> Result> { migrations::m_2025_04_15::KEYMAP_PATTERNS, &KEYMAP_QUERY_2025_04_15, ), + MigrationType::TreeSitter( + migrations::m_2025_12_08::KEYMAP_PATTERNS, + &KEYMAP_QUERY_2025_12_08, + ), ]; run_migrations(text, migrations) } @@ -358,6 +362,10 @@ define_query!( SETTINGS_QUERY_2025_11_20, migrations::m_2025_11_20::SETTINGS_PATTERNS ); +define_query!( + KEYMAP_QUERY_2025_12_08, + migrations::m_2025_12_08::KEYMAP_PATTERNS +); // custom query static EDIT_PREDICTION_SETTINGS_MIGRATION_QUERY: LazyLock = LazyLock::new(|| { diff --git a/docs/src/ai/edit-prediction.md b/docs/src/ai/edit-prediction.md index feef6d36d29eca4157254cc4c209f4a614a927de..65a427842cda461806dc79ecf67f3a180afd9763 100644 --- a/docs/src/ai/edit-prediction.md +++ b/docs/src/ai/edit-prediction.md @@ -58,7 +58,8 @@ In these cases, `alt-tab` is used instead to accept the prediction. When the lan On Linux, `alt-tab` is often used by the window manager for switching windows, so `alt-l` is provided as the default binding for accepting predictions. `tab` and `alt-tab` also work, but aren't displayed by default. -{#action editor::AcceptPartialEditPrediction} ({#kb editor::AcceptPartialEditPrediction}) can be used to accept the current edit prediction up to the next word boundary. +{#action editor::AcceptNextWordEditPrediction} ({#kb editor::AcceptNextWordEditPrediction}) can be used to accept the current edit prediction up to the next word boundary. +{#action editor::AcceptNextLineEditPrediction} ({#kb editor::AcceptNextLineEditPrediction}) can be used to accept the current edit prediction up to the new line boundary. ## Configuring Edit Prediction Keybindings {#edit-predictions-keybinding} From 7cd483321b4f070d5433d31ed3101f97b8d7f866 Mon Sep 17 00:00:00 2001 From: Finn Evers Date: Mon, 15 Dec 2025 19:31:38 +0100 Subject: [PATCH 315/621] agent_ui_v2: Fix `set_position` not updating the position properly (#44902) The panel could not be relocated using the right click menu because both valid positions mapped to `Left` Release Notes: - N/A --- crates/agent_ui_v2/src/agents_panel.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/agent_ui_v2/src/agents_panel.rs b/crates/agent_ui_v2/src/agents_panel.rs index a7afdddda43514ade40b7fd9dfd8bcd8ace33dc7..254b8d2999dd3f9ce99c07a20273cbb1ca9cb929 100644 --- a/crates/agent_ui_v2/src/agents_panel.rs +++ b/crates/agent_ui_v2/src/agents_panel.rs @@ -384,8 +384,7 @@ impl Panel for AgentsPanel { update_settings_file(self.fs.clone(), cx, move |settings, _| { settings.agent.get_or_insert_default().agents_panel_dock = Some(match position { DockPosition::Left => settings::DockSide::Left, - DockPosition::Bottom => settings::DockSide::Right, - DockPosition::Right => settings::DockSide::Left, + DockPosition::Right | DockPosition::Bottom => settings::DockSide::Right, }); }); self.re_register_utility_pane(window, cx); From 7d7ca129db29190fb6a99876d94c753e1db77560 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Mon, 15 Dec 2025 11:36:02 -0700 Subject: [PATCH 316/621] Add timeout support to terminal tool (#44895) Adds an optional `timeout_ms` parameter to the terminal tool that allows bounding the runtime of shell commands. When the timeout expires, the running terminal task is killed and the tool returns with the partial output captured so far. ## Summary This PR adds the ability for the agent to specify a maximum runtime when invoking the terminal tool. This helps prevent indefinite hangs when running commands that might wait for network, user prompts, or long builds/tests. ## Changes - Add `timeout_ms` field to `TerminalToolInput` schema - Extend `TerminalHandle` trait with `kill()` method - Implement `kill()` for `AcpTerminalHandle` and `EvalTerminalHandle` - Race terminal exit against timeout, killing on expiry - Update system prompt to recommend using timeouts for long-running commands - Add test for timeout behavior - Update `.rules` to document GPUI executor timers for tests ## Testing - Added `test_terminal_tool_timeout_kills_handle` which verifies that when a timeout is specified and expires, the terminal handle is killed and the tool returns with partial output. - All existing agent tests pass. Release Notes: - agent: Added optional `timeout_ms` parameter to the terminal tool, allowing the agent to bound command runtime and prevent indefinite hangs --- .rules | 6 + crates/agent/src/agent.rs | 9 + crates/agent/src/templates/system_prompt.hbs | 2 +- crates/agent/src/tests/mod.rs | 219 ++++++++++++++++++- crates/agent/src/thread.rs | 1 + crates/agent/src/tools/terminal_tool.rs | 33 ++- crates/eval/src/instance.rs | 9 + crates/terminal/src/terminal.rs | 5 +- 8 files changed, 275 insertions(+), 9 deletions(-) diff --git a/.rules b/.rules index 82d15eb9e88299ee7c7fe6c717b2da2646e676a7..7c98c65d7e0eaf3ed0d57898dbd8acee28a220ae 100644 --- a/.rules +++ b/.rules @@ -26,6 +26,12 @@ }); ``` +# Timers in tests + +* In GPUI tests, prefer GPUI executor timers over `smol::Timer::after(...)` when you need timeouts, delays, or to drive `run_until_parked()`: + - Use `cx.background_executor().timer(duration).await` (or `cx.background_executor.timer(duration).await` in `TestAppContext`) so the work is scheduled on GPUI's dispatcher. + - Avoid `smol::Timer::after(...)` for test timeouts when you rely on `run_until_parked()`, because it may not be tracked by GPUI's scheduler and can lead to "nothing left to run" when pumping. + # GPUI GPUI is a UI framework which also provides primitives for state and concurrency management. diff --git a/crates/agent/src/agent.rs b/crates/agent/src/agent.rs index cf98a24ac52579fc65bdbcc3444615c89625812a..092f735bb7c3713e70ea137c2bab485315aa8849 100644 --- a/crates/agent/src/agent.rs +++ b/crates/agent/src/agent.rs @@ -1219,6 +1219,15 @@ impl TerminalHandle for AcpTerminalHandle { self.terminal .read_with(cx, |term, cx| term.current_output(cx)) } + + fn kill(&self, cx: &AsyncApp) -> Result<()> { + cx.update(|cx| { + self.terminal.update(cx, |terminal, cx| { + terminal.kill(cx); + }); + })?; + Ok(()) + } } #[cfg(test)] diff --git a/crates/agent/src/templates/system_prompt.hbs b/crates/agent/src/templates/system_prompt.hbs index 4620647135631fdb367b0dc2604e89770a938c07..2477e46a85183813f61bb60d7e3de7f119a4f00c 100644 --- a/crates/agent/src/templates/system_prompt.hbs +++ b/crates/agent/src/templates/system_prompt.hbs @@ -16,7 +16,7 @@ You are a highly skilled software engineer with extensive knowledge in many prog 3. DO NOT use tools to access items that are already available in the context section. 4. Use only the tools that are currently available. 5. DO NOT use a tool that is not available just because it appears in the conversation. This means the user turned it off. -6. NEVER run commands that don't terminate on their own such as web servers (like `npm run start`, `npm run dev`, `python -m http.server`, etc) or file watchers. +6. When running commands that may run indefinitely or for a long time (such as build scripts, tests, servers, or file watchers), specify `timeout_ms` to bound runtime. If the command times out, the user can always ask you to run it again with a longer timeout or no timeout if they're willing to wait or cancel manually. 7. Avoid HTML entity escaping - use plain characters instead. ## Searching and Reading diff --git a/crates/agent/src/tests/mod.rs b/crates/agent/src/tests/mod.rs index 9ff870353279635957cd2b84f418f881c3444aa2..5a581c5db80a4c4f527efc8b1711fbf16c8097f8 100644 --- a/crates/agent/src/tests/mod.rs +++ b/crates/agent/src/tests/mod.rs @@ -9,14 +9,16 @@ use collections::IndexMap; use context_server::{ContextServer, ContextServerCommand, ContextServerId}; use fs::{FakeFs, Fs}; use futures::{ - StreamExt, + FutureExt as _, StreamExt, channel::{ mpsc::{self, UnboundedReceiver}, oneshot, }, + future::{Fuse, Shared}, }; use gpui::{ - App, AppContext, Entity, Task, TestAppContext, UpdateGlobal, http_client::FakeHttpClient, + App, AppContext, AsyncApp, Entity, Task, TestAppContext, UpdateGlobal, + http_client::FakeHttpClient, }; use indoc::indoc; use language_model::{ @@ -35,12 +37,109 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use serde_json::json; use settings::{Settings, SettingsStore}; -use std::{path::Path, rc::Rc, sync::Arc, time::Duration}; +use std::{ + path::Path, + pin::Pin, + rc::Rc, + sync::{ + Arc, + atomic::{AtomicBool, Ordering}, + }, + time::Duration, +}; use util::path; mod test_tools; use test_tools::*; +fn init_test(cx: &mut TestAppContext) { + cx.update(|cx| { + let settings_store = SettingsStore::test(cx); + cx.set_global(settings_store); + }); +} + +struct FakeTerminalHandle { + killed: Arc, + wait_for_exit: Shared>, + output: acp::TerminalOutputResponse, + id: acp::TerminalId, +} + +impl FakeTerminalHandle { + fn new_never_exits(cx: &mut App) -> Self { + let killed = Arc::new(AtomicBool::new(false)); + + let killed_for_task = killed.clone(); + let wait_for_exit = cx + .spawn(async move |cx| { + loop { + if killed_for_task.load(Ordering::SeqCst) { + return acp::TerminalExitStatus::new(); + } + cx.background_executor() + .timer(Duration::from_millis(1)) + .await; + } + }) + .shared(); + + Self { + killed, + wait_for_exit, + output: acp::TerminalOutputResponse::new("partial output".to_string(), false), + id: acp::TerminalId::new("fake_terminal".to_string()), + } + } + + fn was_killed(&self) -> bool { + self.killed.load(Ordering::SeqCst) + } +} + +impl crate::TerminalHandle for FakeTerminalHandle { + fn id(&self, _cx: &AsyncApp) -> Result { + Ok(self.id.clone()) + } + + fn current_output(&self, _cx: &AsyncApp) -> Result { + Ok(self.output.clone()) + } + + fn wait_for_exit(&self, _cx: &AsyncApp) -> Result>> { + Ok(self.wait_for_exit.clone()) + } + + fn kill(&self, _cx: &AsyncApp) -> Result<()> { + self.killed.store(true, Ordering::SeqCst); + Ok(()) + } +} + +struct FakeThreadEnvironment { + handle: Rc, +} + +impl crate::ThreadEnvironment for FakeThreadEnvironment { + fn create_terminal( + &self, + _command: String, + _cwd: Option, + _output_byte_limit: Option, + _cx: &mut AsyncApp, + ) -> Task>> { + Task::ready(Ok(self.handle.clone() as Rc)) + } +} + +fn always_allow_tools(cx: &mut TestAppContext) { + cx.update(|cx| { + let mut settings = agent_settings::AgentSettings::get_global(cx).clone(); + settings.always_allow_tool_actions = true; + agent_settings::AgentSettings::override_global(settings, cx); + }); +} + #[gpui::test] async fn test_echo(cx: &mut TestAppContext) { let ThreadTest { model, thread, .. } = setup(cx, TestModel::Fake).await; @@ -71,6 +170,120 @@ async fn test_echo(cx: &mut TestAppContext) { assert_eq!(stop_events(events), vec![acp::StopReason::EndTurn]); } +#[gpui::test] +async fn test_terminal_tool_timeout_kills_handle(cx: &mut TestAppContext) { + init_test(cx); + always_allow_tools(cx); + + let fs = FakeFs::new(cx.executor()); + let project = Project::test(fs, [], cx).await; + + let handle = Rc::new(cx.update(|cx| FakeTerminalHandle::new_never_exits(cx))); + let environment = Rc::new(FakeThreadEnvironment { + handle: handle.clone(), + }); + + #[allow(clippy::arc_with_non_send_sync)] + let tool = Arc::new(crate::TerminalTool::new(project, environment)); + let (event_stream, mut rx) = crate::ToolCallEventStream::test(); + + let task = cx.update(|cx| { + tool.run( + crate::TerminalToolInput { + command: "sleep 1000".to_string(), + cd: ".".to_string(), + timeout_ms: Some(5), + }, + event_stream, + cx, + ) + }); + + let update = rx.expect_update_fields().await; + assert!( + update.content.iter().any(|blocks| { + blocks + .iter() + .any(|c| matches!(c, acp::ToolCallContent::Terminal(_))) + }), + "expected tool call update to include terminal content" + ); + + let mut task_future: Pin>>>> = Box::pin(task.fuse()); + + let deadline = std::time::Instant::now() + Duration::from_millis(500); + loop { + if let Some(result) = task_future.as_mut().now_or_never() { + let result = result.expect("terminal tool task should complete"); + + assert!( + handle.was_killed(), + "expected terminal handle to be killed on timeout" + ); + assert!( + result.contains("partial output"), + "expected result to include terminal output, got: {result}" + ); + return; + } + + if std::time::Instant::now() >= deadline { + panic!("timed out waiting for terminal tool task to complete"); + } + + cx.run_until_parked(); + cx.background_executor.timer(Duration::from_millis(1)).await; + } +} + +#[gpui::test] +#[ignore] +async fn test_terminal_tool_without_timeout_does_not_kill_handle(cx: &mut TestAppContext) { + init_test(cx); + always_allow_tools(cx); + + let fs = FakeFs::new(cx.executor()); + let project = Project::test(fs, [], cx).await; + + let handle = Rc::new(cx.update(|cx| FakeTerminalHandle::new_never_exits(cx))); + let environment = Rc::new(FakeThreadEnvironment { + handle: handle.clone(), + }); + + #[allow(clippy::arc_with_non_send_sync)] + let tool = Arc::new(crate::TerminalTool::new(project, environment)); + let (event_stream, mut rx) = crate::ToolCallEventStream::test(); + + let _task = cx.update(|cx| { + tool.run( + crate::TerminalToolInput { + command: "sleep 1000".to_string(), + cd: ".".to_string(), + timeout_ms: None, + }, + event_stream, + cx, + ) + }); + + let update = rx.expect_update_fields().await; + assert!( + update.content.iter().any(|blocks| { + blocks + .iter() + .any(|c| matches!(c, acp::ToolCallContent::Terminal(_))) + }), + "expected tool call update to include terminal content" + ); + + smol::Timer::after(Duration::from_millis(25)).await; + + assert!( + !handle.was_killed(), + "did not expect terminal handle to be killed without a timeout" + ); +} + #[gpui::test] async fn test_thinking(cx: &mut TestAppContext) { let ThreadTest { model, thread, .. } = setup(cx, TestModel::Fake).await; diff --git a/crates/agent/src/thread.rs b/crates/agent/src/thread.rs index 4aabf8069bc3380b6908187b28517f99a9548f26..a51dd3bf9fd5213c88a0ab56ef9ec9b563a90756 100644 --- a/crates/agent/src/thread.rs +++ b/crates/agent/src/thread.rs @@ -530,6 +530,7 @@ pub trait TerminalHandle { fn id(&self, cx: &AsyncApp) -> Result; fn current_output(&self, cx: &AsyncApp) -> Result; fn wait_for_exit(&self, cx: &AsyncApp) -> Result>>; + fn kill(&self, cx: &AsyncApp) -> Result<()>; } pub trait ThreadEnvironment { diff --git a/crates/agent/src/tools/terminal_tool.rs b/crates/agent/src/tools/terminal_tool.rs index 2db4a2d86038579fca62224f3a7c567f93fc6922..f3302fb1894612287bf04acfbfa301188bf853fb 100644 --- a/crates/agent/src/tools/terminal_tool.rs +++ b/crates/agent/src/tools/terminal_tool.rs @@ -1,6 +1,7 @@ use agent_client_protocol as acp; use anyhow::Result; -use gpui::{App, Entity, SharedString, Task}; +use futures::FutureExt as _; +use gpui::{App, AppContext, Entity, SharedString, Task}; use project::Project; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -8,6 +9,7 @@ use std::{ path::{Path, PathBuf}, rc::Rc, sync::Arc, + time::Duration, }; use util::markdown::MarkdownInlineCode; @@ -25,13 +27,17 @@ const COMMAND_OUTPUT_LIMIT: u64 = 16 * 1024; /// /// Do not use this tool for commands that run indefinitely, such as servers (like `npm run start`, `npm run dev`, `python -m http.server`, etc) or file watchers that don't terminate on their own. /// +/// For potentially long-running commands, prefer specifying `timeout_ms` to bound runtime and prevent indefinite hangs. +/// /// Remember that each invocation of this tool will spawn a new shell process, so you can't rely on any state from previous invocations. #[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] pub struct TerminalToolInput { /// The one-liner command to execute. - command: String, + pub command: String, /// Working directory for the command. This must be one of the root directories of the project. - cd: String, + pub cd: String, + /// Optional maximum runtime (in milliseconds). If exceeded, the running terminal task is killed. + pub timeout_ms: Option, } pub struct TerminalTool { @@ -116,7 +122,26 @@ impl AgentTool for TerminalTool { acp::ToolCallContent::Terminal(acp::Terminal::new(terminal_id)), ])); - let exit_status = terminal.wait_for_exit(cx)?.await; + let timeout = input.timeout_ms.map(Duration::from_millis); + + let exit_status = match timeout { + Some(timeout) => { + let wait_for_exit = terminal.wait_for_exit(cx)?; + let timeout_task = cx.background_spawn(async move { + smol::Timer::after(timeout).await; + }); + + futures::select! { + status = wait_for_exit.clone().fuse() => status, + _ = timeout_task.fuse() => { + terminal.kill(cx)?; + wait_for_exit.await + } + } + } + None => terminal.wait_for_exit(cx)?.await, + }; + let output = terminal.current_output(cx)?; Ok(process_content(output, &input.command, exit_status)) diff --git a/crates/eval/src/instance.rs b/crates/eval/src/instance.rs index 1af705cd4bfdb4419c767feb41d1428181866c08..4c71a5a82b3946a9cc6e22ced378ebaabeec5256 100644 --- a/crates/eval/src/instance.rs +++ b/crates/eval/src/instance.rs @@ -625,6 +625,15 @@ impl agent::TerminalHandle for EvalTerminalHandle { self.terminal .read_with(cx, |term, cx| term.current_output(cx)) } + + fn kill(&self, cx: &AsyncApp) -> Result<()> { + cx.update(|cx| { + self.terminal.update(cx, |terminal, cx| { + terminal.kill(cx); + }); + })?; + Ok(()) + } } impl agent::ThreadEnvironment for EvalThreadEnvironment { diff --git a/crates/terminal/src/terminal.rs b/crates/terminal/src/terminal.rs index e6bb454fa296b65de60c25f326bba28f484450f0..601fa75044a648e7c40e84b32aabda8096856119 100644 --- a/crates/terminal/src/terminal.rs +++ b/crates/terminal/src/terminal.rs @@ -369,6 +369,7 @@ impl TerminalBuilder { last_content: Default::default(), last_mouse: None, matches: Vec::new(), + selection_head: None, breadcrumb_text: String::new(), scroll_px: px(0.), @@ -595,6 +596,7 @@ impl TerminalBuilder { last_content: Default::default(), last_mouse: None, matches: Vec::new(), + selection_head: None, breadcrumb_text: String::new(), scroll_px: px(0.), @@ -826,6 +828,7 @@ pub struct Terminal { pub matches: Vec>, pub last_content: TerminalContent, pub selection_head: Option, + pub breadcrumb_text: String, title_override: Option, scroll_px: Pixels, @@ -939,7 +942,7 @@ impl Terminal { AlacTermEvent::Bell => { cx.emit(Event::Bell); } - AlacTermEvent::Exit => self.register_task_finished(None, cx), + AlacTermEvent::Exit => self.register_task_finished(Some(9), cx), AlacTermEvent::MouseCursorDirty => { //NOOP, Handled in render } From 0410b2340c62eb2ceb7c844aa7fe6a9d21415d5a Mon Sep 17 00:00:00 2001 From: Dino Date: Mon, 15 Dec 2025 19:18:18 +0000 Subject: [PATCH 317/621] editor: Refactor cursor_offset_on_selection field in favor of VimModeSettings (#44889) In a previous Pull Request, a new field was added to `editor::Editor`, namely `cursor_offset_on_selection`, in order to control whether the cursor representing the head of a selection should be positioned in the last selected character, as we have on Vim mode, or after, like we have when Vim mode is disabled. This field would then be set by the `vim` crate, depending on the current vim mode. However, it was noted that `vim_mode_setting::VimModeSetting` already exsits and allows other crates to determine whether Vim mode is enabled or not. Since we're already checking `!range.is_empty()` in `editor::element::SelectionLayout::new` we can then rely on simply determining whether Vim mode is enabled to decide whether tho shift the cursor one position to the left when making a selection. As such, this commit removes the `cursor_offset_on_selection` field, as well as any related methods in favor of a new `Editor.vim_mode_enabled` method, which can be used to achieve the same behavior. Relates to #42837 Release Notes: - N/A --- crates/editor/src/editor.rs | 31 +++++++++++++------------------ crates/editor/src/element.rs | 27 ++++++++++++++++----------- crates/vim/src/vim.rs | 1 - 3 files changed, 29 insertions(+), 30 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index bea7d79779b3a1f8ae0473e26235a2a992f7b030..3a6fc630e650ecfbd6f95cf0df30ac9f0228f050 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -202,6 +202,7 @@ use ui::{ IconSize, Indicator, Key, Tooltip, h_flex, prelude::*, scrollbars::ScrollbarAutoHide, }; use util::{RangeExt, ResultExt, TryFutureExt, maybe, post_inc}; +use vim_mode_setting::VimModeSetting; use workspace::{ CollaboratorId, Item as WorkspaceItem, ItemId, ItemNavHistory, OpenInTerminal, OpenTerminal, RestoreOnStartupBehavior, SERIALIZATION_THROTTLE_TIME, SplitDirection, TabBarSettings, Toast, @@ -1110,9 +1111,6 @@ pub struct Editor { pending_rename: Option, searchable: bool, cursor_shape: CursorShape, - /// Whether the cursor is offset one character to the left when something is - /// selected (needed for vim visual mode) - cursor_offset_on_selection: bool, current_line_highlight: Option, pub collapse_matches: bool, autoindent_mode: Option, @@ -2288,7 +2286,6 @@ impl Editor { cursor_shape: EditorSettings::get_global(cx) .cursor_shape .unwrap_or_default(), - cursor_offset_on_selection: false, current_line_highlight: None, autoindent_mode: Some(AutoindentMode::EachLine), collapse_matches: false, @@ -2475,10 +2472,7 @@ impl Editor { } } EditorEvent::Edited { .. } => { - let vim_mode = vim_mode_setting::VimModeSetting::try_get(cx) - .map(|vim_mode| vim_mode.0) - .unwrap_or(false); - if !vim_mode { + if !editor.is_vim_mode_enabled(cx) { let display_map = editor.display_snapshot(cx); let selections = editor.selections.all_adjusted_display(&display_map); let pop_state = editor @@ -3107,10 +3101,6 @@ impl Editor { self.cursor_shape } - pub fn set_cursor_offset_on_selection(&mut self, set_cursor_offset_on_selection: bool) { - self.cursor_offset_on_selection = set_cursor_offset_on_selection; - } - pub fn set_current_line_highlight( &mut self, current_line_highlight: Option, @@ -22607,10 +22597,7 @@ impl Editor { .and_then(|e| e.to_str()) .map(|a| a.to_string())); - let vim_mode = vim_mode_setting::VimModeSetting::try_get(cx) - .map(|vim_mode| vim_mode.0) - .unwrap_or(false); - + let vim_mode_enabled = self.is_vim_mode_enabled(cx); let edit_predictions_provider = all_language_settings(file, cx).edit_predictions.provider; let copilot_enabled = edit_predictions_provider == language::language_settings::EditPredictionProvider::Copilot; @@ -22628,7 +22615,7 @@ impl Editor { event_type, type = if auto_saved {"autosave"} else {"manual"}, file_extension, - vim_mode, + vim_mode_enabled, copilot_enabled, copilot_enabled_for_language, edit_predictions_provider, @@ -22638,7 +22625,7 @@ impl Editor { telemetry::event!( event_type, file_extension, - vim_mode, + vim_mode_enabled, copilot_enabled, copilot_enabled_for_language, edit_predictions_provider, @@ -23253,6 +23240,14 @@ impl Editor { show_underlines: self.diagnostics_enabled(), } } + + /// Returns the value of the `vim_mode` setting, defaulting `false` if the + /// setting is not set. + pub(crate) fn is_vim_mode_enabled(&self, cx: &App) -> bool { + VimModeSetting::try_get(cx) + .map(|vim_mode| vim_mode.0) + .unwrap_or(false) + } } fn edit_for_markdown_paste<'a>( diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index 8de660275ba9b455aec610568c41347888654495..efb0459b15b7b7e19a485a81753d39d7dd20b5de 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -133,7 +133,7 @@ impl SelectionLayout { fn new( selection: Selection, line_mode: bool, - cursor_offset: bool, + vim_mode_enabled: bool, cursor_shape: CursorShape, map: &DisplaySnapshot, is_newest: bool, @@ -154,7 +154,7 @@ impl SelectionLayout { } // any vim visual mode (including line mode) - if cursor_offset && !range.is_empty() && !selection.reversed { + if vim_mode_enabled && !range.is_empty() && !selection.reversed { if head.column() > 0 { head = map.clip_point(DisplayPoint::new(head.row(), head.column() - 1), Bias::Left); } else if head.row().0 > 0 && head != map.max_point() { @@ -1463,7 +1463,7 @@ impl EditorElement { let layout = SelectionLayout::new( selection, editor.selections.line_mode(), - editor.cursor_offset_on_selection, + editor.is_vim_mode_enabled(cx), editor.cursor_shape, &snapshot.display_snapshot, is_newest, @@ -1510,7 +1510,7 @@ impl EditorElement { let drag_cursor_layout = SelectionLayout::new( drop_cursor.clone(), false, - editor.cursor_offset_on_selection, + editor.is_vim_mode_enabled(cx), CursorShape::Bar, &snapshot.display_snapshot, false, @@ -1574,7 +1574,7 @@ impl EditorElement { .push(SelectionLayout::new( selection.selection, selection.line_mode, - editor.cursor_offset_on_selection, + editor.is_vim_mode_enabled(cx), selection.cursor_shape, &snapshot.display_snapshot, false, @@ -1585,8 +1585,7 @@ impl EditorElement { selections.extend(remote_selections.into_values()); } else if !editor.is_focused(window) && editor.show_cursor_when_unfocused { - let cursor_offset_on_selection = editor.cursor_offset_on_selection; - + let player = editor.current_user_player_color(cx); let layouts = snapshot .buffer_snapshot() .selections_in_range(&(start_anchor..end_anchor), true) @@ -1594,7 +1593,7 @@ impl EditorElement { SelectionLayout::new( selection, line_mode, - cursor_offset_on_selection, + editor.is_vim_mode_enabled(cx), cursor_shape, &snapshot.display_snapshot, false, @@ -1603,7 +1602,7 @@ impl EditorElement { ) }) .collect::>(); - let player = editor.current_user_player_color(cx); + selections.push((player, layouts)); } }); @@ -3318,7 +3317,7 @@ impl EditorElement { SelectionLayout::new( newest, editor.selections.line_mode(), - editor.cursor_offset_on_selection, + editor.is_vim_mode_enabled(cx), editor.cursor_shape, &snapshot.display_snapshot, true, @@ -11549,6 +11548,7 @@ mod tests { use log::info; use std::num::NonZeroU32; use util::test::sample_text; + use vim_mode_setting::VimModeSetting; #[gpui::test] async fn test_soft_wrap_editor_width_auto_height_editor(cx: &mut TestAppContext) { @@ -11893,6 +11893,12 @@ mod tests { async fn test_vim_visual_selections(cx: &mut TestAppContext) { init_test(cx, |_| {}); + // Enable `vim_mode` setting so the logic that checks whether this is + // enabled can work as expected. + cx.update(|cx| { + VimModeSetting::override_global(VimModeSetting(true), cx); + }); + let window = cx.add_window(|window, cx| { let buffer = MultiBuffer::build_simple(&(sample_text(6, 6, 'a') + "\n"), cx); Editor::new(EditorMode::full(), buffer, None, window, cx) @@ -11903,7 +11909,6 @@ mod tests { window .update(cx, |editor, window, cx| { - editor.cursor_offset_on_selection = true; editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| { s.select_ranges([ Point::new(0, 0)..Point::new(1, 0), diff --git a/crates/vim/src/vim.rs b/crates/vim/src/vim.rs index 26fec968fb261fbb80a9f84211357623147ca0f4..9a9a1a001c32fcf8b22892ce5300d8d2aec3dd37 100644 --- a/crates/vim/src/vim.rs +++ b/crates/vim/src/vim.rs @@ -1943,7 +1943,6 @@ impl Vim { editor.set_collapse_matches(collapse_matches); editor.set_input_enabled(vim.editor_input_enabled()); editor.set_autoindent(vim.should_autoindent()); - editor.set_cursor_offset_on_selection(vim.mode.is_visual()); editor .selections .set_line_mode(matches!(vim.mode, Mode::VisualLine)); From 3076c4ee4eb31427c48ed9478a7c6cce90c8ca3a Mon Sep 17 00:00:00 2001 From: RMcGhee Date: Mon, 15 Dec 2025 13:21:34 -0600 Subject: [PATCH 318/621] Add behavior for multiple click and drag to markdown component (#43813) Closes #43354 Overview: In a diagnostic panel (and all Markdown derived panels, including function hint popovers and the like), the expected behavior is that when a user double clicks a word, the whole word is highlighted. If they double click and hold, then drag, the text selection proceeds word by word. There is similar behavior for triple click which goes line by line, and quadruple click which selects all text. Before this fix, the DiagnosticPopover allowed the user to click and drag, but double click and drag reverts to selecting text character by character. The same wrong behavior is shown for triple click (line). Quadruple click (all text) was not previously implemented in MarkdownElement. Quick example of wrong behavior, showing single click and drag, double click and drag, triple click and drag, then quadruple click (fails). https://github.com/user-attachments/assets/1184e64d-5467-4504-bbb6-404546eab90a Quick example showing the correct behavior fixed in this PR: https://github.com/user-attachments/assets/06bf5398-d6d6-496c-8fe9-705031207f05 Nota bene: I'm not a rust dev, so a lot of this relied on my C/C++ experience, cribbing from elsewhere in the repo, and help from Claude. If that's not ok for this project, I totally understand. Much of this was informed by editor.rs, using a similar pattern to SelectMode in there (see lines 450, and begin_selection and extend_selection). It didn't seem appropriate to import SelectMode from there (also Markdown range and Anchor range seemed different enough), nor did it seem appropriate to move SelectMode to markdown.rs. The tests are non-ui based, instead testing the relevant functions. Not sure if that's what's expected. Release Notes: - Double- and triple-click selection now correctly expands by word and by line within Markdown elements (diagnostics, agent panel, etc.). --- crates/markdown/src/markdown.rs | 270 +++++++++++++++++++++++++++++--- 1 file changed, 251 insertions(+), 19 deletions(-) diff --git a/crates/markdown/src/markdown.rs b/crates/markdown/src/markdown.rs index d6ba3babecf3b6b43155780e569bdc4515762d40..6f4ebe4a91f2cee344c1d82ff70722406251434d 100644 --- a/crates/markdown/src/markdown.rs +++ b/crates/markdown/src/markdown.rs @@ -422,28 +422,72 @@ impl Focusable for Markdown { } } -#[derive(Copy, Clone, Default, Debug)] +#[derive(Debug, Default, Clone)] +enum SelectMode { + #[default] + Character, + Word(Range), + Line(Range), + All, +} + +#[derive(Clone, Default)] struct Selection { start: usize, end: usize, reversed: bool, pending: bool, + mode: SelectMode, } impl Selection { - fn set_head(&mut self, head: usize) { - if head < self.tail() { - if !self.reversed { - self.end = self.start; - self.reversed = true; + fn set_head(&mut self, head: usize, rendered_text: &RenderedText) { + match &self.mode { + SelectMode::Character => { + if head < self.tail() { + if !self.reversed { + self.end = self.start; + self.reversed = true; + } + self.start = head; + } else { + if self.reversed { + self.start = self.end; + self.reversed = false; + } + self.end = head; + } } - self.start = head; - } else { - if self.reversed { - self.start = self.end; + SelectMode::Word(original_range) | SelectMode::Line(original_range) => { + let head_range = if matches!(self.mode, SelectMode::Word(_)) { + rendered_text.surrounding_word_range(head) + } else { + rendered_text.surrounding_line_range(head) + }; + + if head < original_range.start { + self.start = head_range.start; + self.end = original_range.end; + self.reversed = true; + } else if head >= original_range.end { + self.start = original_range.start; + self.end = head_range.end; + self.reversed = false; + } else { + self.start = original_range.start; + self.end = original_range.end; + self.reversed = false; + } + } + SelectMode::All => { + self.start = 0; + self.end = rendered_text + .lines + .last() + .map(|line| line.source_end) + .unwrap_or(0); self.reversed = false; } - self.end = head; } } @@ -532,7 +576,7 @@ impl MarkdownElement { window: &mut Window, cx: &mut App, ) { - let selection = self.markdown.read(cx).selection; + let selection = self.markdown.read(cx).selection.clone(); let selection_start = rendered_text.position_for_source_index(selection.start); let selection_end = rendered_text.position_for_source_index(selection.end); if let Some(((start_position, start_line_height), (end_position, end_line_height))) = @@ -632,18 +676,34 @@ impl MarkdownElement { match rendered_text.source_index_for_position(event.position) { Ok(ix) | Err(ix) => ix, }; - let range = if event.click_count == 2 { - rendered_text.surrounding_word_range(source_index) - } else if event.click_count == 3 { - rendered_text.surrounding_line_range(source_index) - } else { - source_index..source_index + let (range, mode) = match event.click_count { + 1 => { + let range = source_index..source_index; + (range, SelectMode::Character) + } + 2 => { + let range = rendered_text.surrounding_word_range(source_index); + (range.clone(), SelectMode::Word(range)) + } + 3 => { + let range = rendered_text.surrounding_line_range(source_index); + (range.clone(), SelectMode::Line(range)) + } + _ => { + let range = 0..rendered_text + .lines + .last() + .map(|line| line.source_end) + .unwrap_or(0); + (range, SelectMode::All) + } }; markdown.selection = Selection { start: range.start, end: range.end, reversed: false, pending: true, + mode, }; window.focus(&markdown.focus_handle); } @@ -672,7 +732,7 @@ impl MarkdownElement { { Ok(ix) | Err(ix) => ix, }; - markdown.selection.set_head(source_index); + markdown.selection.set_head(source_index, &rendered_text); markdown.autoscroll_request = Some(source_index); cx.notify(); } else { @@ -1941,6 +2001,178 @@ mod tests { rendered.text } + #[gpui::test] + fn test_surrounding_word_range(cx: &mut TestAppContext) { + let rendered = render_markdown("Hello world tesεζ", cx); + + // Test word selection for "Hello" + let word_range = rendered.surrounding_word_range(2); // Simulate click on 'l' in "Hello" + let selected_text = rendered.text_for_range(word_range); + assert_eq!(selected_text, "Hello"); + + // Test word selection for "world" + let word_range = rendered.surrounding_word_range(7); // Simulate click on 'o' in "world" + let selected_text = rendered.text_for_range(word_range); + assert_eq!(selected_text, "world"); + + // Test word selection for "tesεζ" + let word_range = rendered.surrounding_word_range(14); // Simulate click on 's' in "tesεζ" + let selected_text = rendered.text_for_range(word_range); + assert_eq!(selected_text, "tesεζ"); + + // Test word selection at word boundary (space) + let word_range = rendered.surrounding_word_range(5); // Simulate click on space between "Hello" and "world", expect highlighting word to the left + let selected_text = rendered.text_for_range(word_range); + assert_eq!(selected_text, "Hello"); + } + + #[gpui::test] + fn test_surrounding_line_range(cx: &mut TestAppContext) { + let rendered = render_markdown("First line\n\nSecond line\n\nThird lineεζ", cx); + + // Test getting line range for first line + let line_range = rendered.surrounding_line_range(5); // Simulate click somewhere in first line + let selected_text = rendered.text_for_range(line_range); + assert_eq!(selected_text, "First line"); + + // Test getting line range for second line + let line_range = rendered.surrounding_line_range(13); // Simulate click at beginning in second line + let selected_text = rendered.text_for_range(line_range); + assert_eq!(selected_text, "Second line"); + + // Test getting line range for third line + let line_range = rendered.surrounding_line_range(37); // Simulate click at end of third line with multi-byte chars + let selected_text = rendered.text_for_range(line_range); + assert_eq!(selected_text, "Third lineεζ"); + } + + #[gpui::test] + fn test_selection_head_movement(cx: &mut TestAppContext) { + let rendered = render_markdown("Hello world test", cx); + + let mut selection = Selection { + start: 5, + end: 5, + reversed: false, + pending: false, + mode: SelectMode::Character, + }; + + // Test forward selection + selection.set_head(10, &rendered); + assert_eq!(selection.start, 5); + assert_eq!(selection.end, 10); + assert!(!selection.reversed); + assert_eq!(selection.tail(), 5); + + // Test backward selection + selection.set_head(2, &rendered); + assert_eq!(selection.start, 2); + assert_eq!(selection.end, 5); + assert!(selection.reversed); + assert_eq!(selection.tail(), 5); + + // Test forward selection again from reversed state + selection.set_head(15, &rendered); + assert_eq!(selection.start, 5); + assert_eq!(selection.end, 15); + assert!(!selection.reversed); + assert_eq!(selection.tail(), 5); + } + + #[gpui::test] + fn test_word_selection_drag(cx: &mut TestAppContext) { + let rendered = render_markdown("Hello world test", cx); + + // Start with a simulated double-click on "world" (index 6-10) + let word_range = rendered.surrounding_word_range(7); // Click on 'o' in "world" + let mut selection = Selection { + start: word_range.start, + end: word_range.end, + reversed: false, + pending: true, + mode: SelectMode::Word(word_range), + }; + + // Drag forward to "test" - should expand selection to include "test" + selection.set_head(13, &rendered); // Index in "test" + assert_eq!(selection.start, 6); // Start of "world" + assert_eq!(selection.end, 16); // End of "test" + assert!(!selection.reversed); + let selected_text = rendered.text_for_range(selection.start..selection.end); + assert_eq!(selected_text, "world test"); + + // Drag backward to "Hello" - should expand selection to include "Hello" + selection.set_head(2, &rendered); // Index in "Hello" + assert_eq!(selection.start, 0); // Start of "Hello" + assert_eq!(selection.end, 11); // End of "world" (original selection) + assert!(selection.reversed); + let selected_text = rendered.text_for_range(selection.start..selection.end); + assert_eq!(selected_text, "Hello world"); + + // Drag back within original word - should revert to original selection + selection.set_head(8, &rendered); // Back within "world" + assert_eq!(selection.start, 6); // Start of "world" + assert_eq!(selection.end, 11); // End of "world" + assert!(!selection.reversed); + let selected_text = rendered.text_for_range(selection.start..selection.end); + assert_eq!(selected_text, "world"); + } + + #[gpui::test] + fn test_selection_with_markdown_formatting(cx: &mut TestAppContext) { + let rendered = render_markdown( + "This is **bold** text, this is *italic* text, use `code` here", + cx, + ); + let word_range = rendered.surrounding_word_range(10); // Inside "bold" + let selected_text = rendered.text_for_range(word_range); + assert_eq!(selected_text, "bold"); + + let word_range = rendered.surrounding_word_range(32); // Inside "italic" + let selected_text = rendered.text_for_range(word_range); + assert_eq!(selected_text, "italic"); + + let word_range = rendered.surrounding_word_range(51); // Inside "code" + let selected_text = rendered.text_for_range(word_range); + assert_eq!(selected_text, "code"); + } + + #[gpui::test] + fn test_all_selection(cx: &mut TestAppContext) { + let rendered = render_markdown("Hello world\n\nThis is a test\n\nwith multiple lines", cx); + + let total_length = rendered + .lines + .last() + .map(|line| line.source_end) + .unwrap_or(0); + + let mut selection = Selection { + start: 0, + end: total_length, + reversed: false, + pending: true, + mode: SelectMode::All, + }; + + selection.set_head(5, &rendered); // Try to set head in middle + assert_eq!(selection.start, 0); + assert_eq!(selection.end, total_length); + assert!(!selection.reversed); + + selection.set_head(25, &rendered); // Try to set head near end + assert_eq!(selection.start, 0); + assert_eq!(selection.end, total_length); + assert!(!selection.reversed); + + let selected_text = rendered.text_for_range(selection.start..selection.end); + assert_eq!( + selected_text, + "Hello world\nThis is a test\nwith multiple lines" + ); + } + #[test] fn test_escape() { assert_eq!(Markdown::escape("hello `world`"), "hello \\`world\\`"); From c75d88098363cce524efeaf02e032dbb2719a3be Mon Sep 17 00:00:00 2001 From: KyleBarton Date: Mon, 15 Dec 2025 11:27:13 -0800 Subject: [PATCH 319/621] Check for local files from within surrounding parens (#44733) Closes #18228 We parse local clickable links by looking for start/end based on whitespace. However, this means that we don't catch links which are embedded in parenthesis, such as in markdown syntax: `[here's my link text](./path/to/file.txt)` Parsing strictly against parenthesis can be problematic, because strictly-speaking, files can have parenthesis. This is a valid file name in at least MacOS: `thisfilehas)parens.txt` Therefore, this change adds a small regex layer on top of the filename finding logic, which parses out text within parenthesis. If any are found, they are checked for being a valid filepath. The original filename string is also checked in order to preserve behavior. Before: https://github.com/user-attachments/assets/37f60335-e947-4879-9ca2-88a33f5781f5 After: https://github.com/user-attachments/assets/bd10649e-ad74-43da-80f4-3e7fd56abd86 Release Notes: - Improved link parsing for cases when a link is embedded in parenthesis, e.g. markdown --- crates/editor/src/hover_links.rs | 124 +++++++++++++++++++++++++++---- 1 file changed, 108 insertions(+), 16 deletions(-) diff --git a/crates/editor/src/hover_links.rs b/crates/editor/src/hover_links.rs index ba361aa04dee3bfa3a819c8afb7061c238681b77..d7e4169a721765e0f93805bf0c157033bf0cafab 100644 --- a/crates/editor/src/hover_links.rs +++ b/crates/editor/src/hover_links.rs @@ -9,8 +9,10 @@ use language::{Bias, ToOffset}; use linkify::{LinkFinder, LinkKind}; use lsp::LanguageServerId; use project::{InlayId, LocationLink, Project, ResolvedPath}; +use regex::Regex; use settings::Settings; -use std::ops::Range; +use std::{ops::Range, sync::LazyLock}; +use text::OffsetRangeExt; use theme::ActiveTheme as _; use util::{ResultExt, TryFutureExt as _, maybe}; @@ -595,7 +597,8 @@ pub(crate) async fn find_file( let project = project?; let snapshot = buffer.read_with(cx, |buffer, _| buffer.snapshot()).ok()?; let scope = snapshot.language_scope_at(position); - let (range, candidate_file_path) = surrounding_filename(snapshot, position)?; + let (range, candidate_file_path) = surrounding_filename(&snapshot, position)?; + let candidate_len = candidate_file_path.len(); async fn check_path( candidate_file_path: &str, @@ -612,29 +615,66 @@ pub(crate) async fn find_file( .filter(|s| s.is_file()) } - if let Some(existing_path) = check_path(&candidate_file_path, &project, buffer, cx).await { - return Some((range, existing_path)); + let pattern_candidates = link_pattern_file_candidates(&candidate_file_path); + + for (pattern_candidate, pattern_range) in &pattern_candidates { + if let Some(existing_path) = check_path(&pattern_candidate, &project, buffer, cx).await { + let offset_range = range.to_offset(&snapshot); + let actual_start = offset_range.start + pattern_range.start; + let actual_end = offset_range.end - (candidate_len - pattern_range.end); + return Some(( + snapshot.anchor_before(actual_start)..snapshot.anchor_after(actual_end), + existing_path, + )); + } } - if let Some(scope) = scope { - for suffix in scope.path_suffixes() { - if candidate_file_path.ends_with(format!(".{suffix}").as_str()) { - continue; - } + for (pattern_candidate, pattern_range) in pattern_candidates { + for suffix in scope.path_suffixes() { + if pattern_candidate.ends_with(format!(".{suffix}").as_str()) { + continue; + } - let suffixed_candidate = format!("{candidate_file_path}.{suffix}"); - if let Some(existing_path) = check_path(&suffixed_candidate, &project, buffer, cx).await - { - return Some((range, existing_path)); + let suffixed_candidate = format!("{pattern_candidate}.{suffix}"); + if let Some(existing_path) = + check_path(&suffixed_candidate, &project, buffer, cx).await + { + let offset_range = range.to_offset(&snapshot); + let actual_start = offset_range.start + pattern_range.start; + let actual_end = offset_range.end - (candidate_len - pattern_range.end); + return Some(( + snapshot.anchor_before(actual_start)..snapshot.anchor_after(actual_end), + existing_path, + )); + } } } } - None } +// Tries to capture potentially inlined links, like those found in markdown, +// e.g. [LinkTitle](link_file.txt) +// Since files can have parens, we should always return the full string +// (literally, [LinkTitle](link_file.txt)) as a candidate. +fn link_pattern_file_candidates(candidate: &str) -> Vec<(String, Range)> { + static MD_LINK_REGEX: LazyLock = + LazyLock::new(|| Regex::new(r"\(([^)]*)\)").expect("Failed to create REGEX")); + + let candidate_len = candidate.len(); + + let mut candidates = vec![(candidate.to_string(), 0..candidate_len)]; + + if let Some(captures) = MD_LINK_REGEX.captures(candidate) { + if let Some(link) = captures.get(1) { + candidates.push((link.as_str().to_string(), link.range())); + } + } + candidates +} + fn surrounding_filename( - snapshot: language::BufferSnapshot, + snapshot: &language::BufferSnapshot, position: text::Anchor, ) -> Option<(Range, String)> { const LIMIT: usize = 2048; @@ -1316,6 +1356,58 @@ mod tests { assert_eq!(cx.opened_url(), Some("https://zed.dev/releases".into())); } + #[test] + fn test_link_pattern_file_candidates() { + let candidates: Vec = link_pattern_file_candidates("[LinkTitle](link_file.txt)") + .into_iter() + .map(|(c, _)| c) + .collect(); + assert_eq!( + candidates, + vec!["[LinkTitle](link_file.txt)", "link_file.txt",] + ); + // Link title with spaces in it + let candidates: Vec = link_pattern_file_candidates("LinkTitle](link_file.txt)") + .into_iter() + .map(|(c, _)| c) + .collect(); + assert_eq!( + candidates, + vec!["LinkTitle](link_file.txt)", "link_file.txt",] + ); + + // Link with spaces + let candidates: Vec = link_pattern_file_candidates("LinkTitle](link\\ _file.txt)") + .into_iter() + .map(|(c, _)| c) + .collect(); + + assert_eq!( + candidates, + vec!["LinkTitle](link\\ _file.txt)", "link\\ _file.txt",] + ); + // + // Square brackets not strictly necessary + let candidates: Vec = link_pattern_file_candidates("(link_file.txt)") + .into_iter() + .map(|(c, _)| c) + .collect(); + + assert_eq!(candidates, vec!["(link_file.txt)", "link_file.txt",]); + + // No nesting + let candidates: Vec = + link_pattern_file_candidates("LinkTitle](link_(link_file)file.txt)") + .into_iter() + .map(|(c, _)| c) + .collect(); + + assert_eq!( + candidates, + vec!["LinkTitle](link_(link_file)file.txt)", "link_(link_file",] + ) + } + #[gpui::test] async fn test_surrounding_filename(cx: &mut gpui::TestAppContext) { init_test(cx, |_| {}); @@ -1374,7 +1466,7 @@ mod tests { (positions, snapshot) }); - let result = surrounding_filename(snapshot, position); + let result = surrounding_filename(&snapshot, position); if let Some(expected) = expected { assert!(result.is_some(), "Failed to find file path: {}", input); From dbab71e348caaade850dce3106ce4b789380077d Mon Sep 17 00:00:00 2001 From: Agus Zubiaga Date: Mon, 15 Dec 2025 16:32:32 -0300 Subject: [PATCH 320/621] Add `.claude/settings.local.json` to `.gitignore` (#44905) Ignore people's local Claude Code settings Release Notes: - N/A --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index ccf4f471d5a7b70be0dc8d619ac64050dd6681ec..54faaf1374299ee8f97925a95a93b375c349d707 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ .DS_Store .blob_store .build +.claude/settings.local.json .envrc .flatpak-builder .idea @@ -41,4 +42,4 @@ xcuserdata/ .env.secret.toml # `nix build` output -/result +/result From 969e9a6707218c6f705132720810cec1f50c70e7 Mon Sep 17 00:00:00 2001 From: Casper van Elteren Date: Tue, 16 Dec 2025 06:04:50 +1000 Subject: [PATCH 321/621] Fix micromamba not initializing shell (#44646) Closes #44645 This is a continuation of #40577 Release Notes: - initializes micromamba based on the shell --- crates/languages/src/python.rs | 40 ++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/crates/languages/src/python.rs b/crates/languages/src/python.rs index 730470d17958f4db02f1ac8c570ffeb83109112c..fbdeb59b7f15a22d4f4097a3b0e60b4aeb9bf202 100644 --- a/crates/languages/src/python.rs +++ b/crates/languages/src/python.rs @@ -1131,6 +1131,18 @@ fn wr_distance( } } +fn micromamba_shell_name(kind: ShellKind) -> &'static str { + match kind { + ShellKind::Csh => "csh", + ShellKind::Fish => "fish", + ShellKind::Nushell => "nu", + ShellKind::PowerShell => "powershell", + ShellKind::Cmd => "cmd.exe", + // default / catch-all: + _ => "posix", + } +} + #[async_trait] impl ToolchainLister for PythonToolchainProvider { async fn list( @@ -1297,24 +1309,28 @@ impl ToolchainLister for PythonToolchainProvider { .as_option() .map(|venv| venv.conda_manager) .unwrap_or(settings::CondaManager::Auto); - let manager = match conda_manager { settings::CondaManager::Conda => "conda", settings::CondaManager::Mamba => "mamba", settings::CondaManager::Micromamba => "micromamba", - settings::CondaManager::Auto => { - // When auto, prefer the detected manager or fall back to conda - toolchain - .environment - .manager - .as_ref() - .and_then(|m| m.executable.file_name()) - .and_then(|name| name.to_str()) - .filter(|name| matches!(*name, "conda" | "mamba" | "micromamba")) - .unwrap_or("conda") - } + settings::CondaManager::Auto => toolchain + .environment + .manager + .as_ref() + .and_then(|m| m.executable.file_name()) + .and_then(|name| name.to_str()) + .filter(|name| matches!(*name, "conda" | "mamba" | "micromamba")) + .unwrap_or("conda"), }; + // Activate micromamba shell in the child shell + // [required for micromamba] + if manager == "micromamba" { + let shell = micromamba_shell_name(shell); + activation_script + .push(format!(r#"eval "$({manager} shell hook --shell {shell})""#)); + } + if let Some(name) = &toolchain.environment.name { activation_script.push(format!("{manager} activate {name}")); } else { From 2441dc3f6637431a781ae10b2e1aa8c4704b9502 Mon Sep 17 00:00:00 2001 From: Marco Mihai Condrache <52580954+marcocondrache@users.noreply.github.com> Date: Mon, 15 Dec 2025 21:33:15 +0100 Subject: [PATCH 322/621] gpui: Take advantage of unified memory on Apple silicon (#44273) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Metal chooses a buffer’s default storage mode based on the type of GPU in use. On Apple GPUs, the default mode is shared, which allows the CPU and GPU to access the same memory without requiring explicit synchronization. On discrete or external GPUs, Metal instead defaults to managed storage, which does require explicit CPU–GPU memory synchronization. This change aligns our buffer usage with Metal’s default behavior and avoids unnecessary synchronization on Apple-silicon Macs. As a result, memory usage on Apple hardware is reduced and performance improves due to fewer sync operations. Ref: https://developer.apple.com/documentation/metal/setting-resource-storage-modes Ref: https://developer.apple.com/documentation/metal/synchronizing-a-managed-resource-in-macos With the storage mode: image On main branch: image That's a 44% reduction of memory usage. Release Notes: - Reduced memory usage on Apple-silicon Macs by using shared memory where appropriate --------- Signed-off-by: Marco Mihai Condrache <52580954+marcocondrache@users.noreply.github.com> --- crates/gpui/src/platform/mac/metal_atlas.rs | 9 +++ .../gpui/src/platform/mac/metal_renderer.rs | 61 +++++++++++++++---- 2 files changed, 58 insertions(+), 12 deletions(-) diff --git a/crates/gpui/src/platform/mac/metal_atlas.rs b/crates/gpui/src/platform/mac/metal_atlas.rs index 8282530c5efdc13ca95a1f04c0f6ef1a23c8366c..9b43efe361a0816e32e858a44cafec66c42e7f85 100644 --- a/crates/gpui/src/platform/mac/metal_atlas.rs +++ b/crates/gpui/src/platform/mac/metal_atlas.rs @@ -15,6 +15,9 @@ pub(crate) struct MetalAtlas(Mutex); impl MetalAtlas { pub(crate) fn new(device: Device) -> Self { MetalAtlas(Mutex::new(MetalAtlasState { + // Shared memory can be used only if CPU and GPU share the same memory space. + // https://developer.apple.com/documentation/metal/setting-resource-storage-modes + unified_memory: device.has_unified_memory(), device: AssertSend(device), monochrome_textures: Default::default(), polychrome_textures: Default::default(), @@ -29,6 +32,7 @@ impl MetalAtlas { struct MetalAtlasState { device: AssertSend, + unified_memory: bool, monochrome_textures: AtlasTextureList, polychrome_textures: AtlasTextureList, tiles_by_key: FxHashMap, @@ -146,6 +150,11 @@ impl MetalAtlasState { } texture_descriptor.set_pixel_format(pixel_format); texture_descriptor.set_usage(usage); + texture_descriptor.set_storage_mode(if self.unified_memory { + metal::MTLStorageMode::Shared + } else { + metal::MTLStorageMode::Managed + }); let metal_texture = self.device.new_texture(&texture_descriptor); let texture_list = match kind { diff --git a/crates/gpui/src/platform/mac/metal_renderer.rs b/crates/gpui/src/platform/mac/metal_renderer.rs index 550041a0ccb4cd39bc7a86317d9540e806af2a28..6d7b82507fb581ec1f124e153e5bb91d3eaf9d25 100644 --- a/crates/gpui/src/platform/mac/metal_renderer.rs +++ b/crates/gpui/src/platform/mac/metal_renderer.rs @@ -76,12 +76,22 @@ impl InstanceBufferPool { self.buffers.clear(); } - pub(crate) fn acquire(&mut self, device: &metal::Device) -> InstanceBuffer { + pub(crate) fn acquire( + &mut self, + device: &metal::Device, + unified_memory: bool, + ) -> InstanceBuffer { let buffer = self.buffers.pop().unwrap_or_else(|| { - device.new_buffer( - self.buffer_size as u64, - MTLResourceOptions::StorageModeManaged, - ) + let options = if unified_memory { + MTLResourceOptions::StorageModeShared + // Buffers are write only which can benefit from the combined cache + // https://developer.apple.com/documentation/metal/mtlresourceoptions/cpucachemodewritecombined + | MTLResourceOptions::CPUCacheModeWriteCombined + } else { + MTLResourceOptions::StorageModeManaged + }; + + device.new_buffer(self.buffer_size as u64, options) }); InstanceBuffer { metal_buffer: buffer, @@ -99,6 +109,7 @@ impl InstanceBufferPool { pub(crate) struct MetalRenderer { device: metal::Device, layer: metal::MetalLayer, + unified_memory: bool, presents_with_transaction: bool, command_queue: CommandQueue, paths_rasterization_pipeline_state: metal::RenderPipelineState, @@ -179,6 +190,10 @@ impl MetalRenderer { output } + // Shared memory can be used only if CPU and GPU share the same memory space. + // https://developer.apple.com/documentation/metal/setting-resource-storage-modes + let unified_memory = device.has_unified_memory(); + let unit_vertices = [ to_float2_bits(point(0., 0.)), to_float2_bits(point(1., 0.)), @@ -190,7 +205,12 @@ impl MetalRenderer { let unit_vertices = device.new_buffer_with_data( unit_vertices.as_ptr() as *const c_void, mem::size_of_val(&unit_vertices) as u64, - MTLResourceOptions::StorageModeManaged, + if unified_memory { + MTLResourceOptions::StorageModeShared + | MTLResourceOptions::CPUCacheModeWriteCombined + } else { + MTLResourceOptions::StorageModeManaged + }, ); let paths_rasterization_pipeline_state = build_path_rasterization_pipeline_state( @@ -268,6 +288,7 @@ impl MetalRenderer { device, layer, presents_with_transaction: false, + unified_memory, command_queue, paths_rasterization_pipeline_state, path_sprites_pipeline_state, @@ -337,14 +358,23 @@ impl MetalRenderer { texture_descriptor.set_width(size.width.0 as u64); texture_descriptor.set_height(size.height.0 as u64); texture_descriptor.set_pixel_format(metal::MTLPixelFormat::BGRA8Unorm); + texture_descriptor.set_storage_mode(metal::MTLStorageMode::Private); texture_descriptor .set_usage(metal::MTLTextureUsage::RenderTarget | metal::MTLTextureUsage::ShaderRead); self.path_intermediate_texture = Some(self.device.new_texture(&texture_descriptor)); if self.path_sample_count > 1 { + // https://developer.apple.com/documentation/metal/choosing-a-resource-storage-mode-for-apple-gpus + // Rendering MSAA textures are done in a single pass, so we can use memory-less storage on Apple Silicon + let storage_mode = if self.unified_memory { + metal::MTLStorageMode::Memoryless + } else { + metal::MTLStorageMode::Private + }; + let mut msaa_descriptor = texture_descriptor; msaa_descriptor.set_texture_type(metal::MTLTextureType::D2Multisample); - msaa_descriptor.set_storage_mode(metal::MTLStorageMode::Private); + msaa_descriptor.set_storage_mode(storage_mode); msaa_descriptor.set_sample_count(self.path_sample_count as _); self.path_intermediate_msaa_texture = Some(self.device.new_texture(&msaa_descriptor)); } else { @@ -378,7 +408,10 @@ impl MetalRenderer { }; loop { - let mut instance_buffer = self.instance_buffer_pool.lock().acquire(&self.device); + let mut instance_buffer = self + .instance_buffer_pool + .lock() + .acquire(&self.device, self.unified_memory); let command_buffer = self.draw_primitives(scene, &mut instance_buffer, drawable, viewport_size); @@ -550,10 +583,14 @@ impl MetalRenderer { command_encoder.end_encoding(); - instance_buffer.metal_buffer.did_modify_range(NSRange { - location: 0, - length: instance_offset as NSUInteger, - }); + if !self.unified_memory { + // Sync the instance buffer to the GPU + instance_buffer.metal_buffer.did_modify_range(NSRange { + location: 0, + length: instance_offset as NSUInteger, + }); + } + Ok(command_buffer.to_owned()) } From 523f093c8e5685cf4169eefa37072377cf7d7729 Mon Sep 17 00:00:00 2001 From: Mayank Verma Date: Tue, 16 Dec 2025 02:09:07 +0530 Subject: [PATCH 323/621] editor: Use Tree-sitter scopes to calculate quote autoclose (#44281) Closes #44233 Release Notes: - Fixed quote autoclose incorrectly counting quotes inside strings --------- Co-authored-by: Ben Kunkle --- crates/editor/src/editor.rs | 42 +++++++++++- crates/editor/src/editor_tests.rs | 109 ++++++++++++++++++++++++++++++ 2 files changed, 150 insertions(+), 1 deletion(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 3a6fc630e650ecfbd6f95cf0df30ac9f0228f050..797a2c9121d7742b4d3e6948c74eb61731b66856 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -4394,10 +4394,50 @@ impl Editor { && bracket_pair.start.len() == 1 { let target = bracket_pair.start.chars().next().unwrap(); + let mut byte_offset = 0u32; let current_line_count = snapshot .reversed_chars_at(selection.start) .take_while(|&c| c != '\n') - .filter(|&c| c == target) + .filter(|c| { + byte_offset += c.len_utf8() as u32; + if *c != target { + return false; + } + + let point = Point::new( + selection.start.row, + selection.start.column.saturating_sub(byte_offset), + ); + + let is_enabled = snapshot + .language_scope_at(point) + .and_then(|scope| { + scope + .brackets() + .find(|(pair, _)| { + pair.start == bracket_pair.start + }) + .map(|(_, enabled)| enabled) + }) + .unwrap_or(true); + + let is_delimiter = snapshot + .language_scope_at(Point::new( + point.row, + point.column + 1, + )) + .and_then(|scope| { + scope + .brackets() + .find(|(pair, _)| { + pair.start == bracket_pair.start + }) + .map(|(_, enabled)| !enabled) + }) + .unwrap_or(false); + + is_enabled && !is_delimiter + }) .count(); current_line_count % 2 == 1 } else { diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rs index 9b04a6ea2bc7aef4e5a90b7d823e50857cff2172..a020b977c779a9b59a442170f7cc24f87ff54e2b 100644 --- a/crates/editor/src/editor_tests.rs +++ b/crates/editor/src/editor_tests.rs @@ -10869,6 +10869,115 @@ async fn test_autoclose_with_overrides(cx: &mut TestAppContext) { ); } +#[gpui::test] +async fn test_autoclose_quotes_with_scope_awareness(cx: &mut TestAppContext) { + init_test(cx, |_| {}); + + let mut cx = EditorTestContext::new(cx).await; + let language = languages::language("python", tree_sitter_python::LANGUAGE.into()); + + cx.update_buffer(|buffer, cx| buffer.set_language(Some(language), cx)); + + // Double quote inside single-quoted string + cx.set_state(indoc! {r#" + def main(): + items = ['"', ˇ] + "#}); + cx.update_editor(|editor, window, cx| { + editor.handle_input("\"", window, cx); + }); + cx.assert_editor_state(indoc! {r#" + def main(): + items = ['"', "ˇ"] + "#}); + + // Two double quotes inside single-quoted string + cx.set_state(indoc! {r#" + def main(): + items = ['""', ˇ] + "#}); + cx.update_editor(|editor, window, cx| { + editor.handle_input("\"", window, cx); + }); + cx.assert_editor_state(indoc! {r#" + def main(): + items = ['""', "ˇ"] + "#}); + + // Single quote inside double-quoted string + cx.set_state(indoc! {r#" + def main(): + items = ["'", ˇ] + "#}); + cx.update_editor(|editor, window, cx| { + editor.handle_input("'", window, cx); + }); + cx.assert_editor_state(indoc! {r#" + def main(): + items = ["'", 'ˇ'] + "#}); + + // Two single quotes inside double-quoted string + cx.set_state(indoc! {r#" + def main(): + items = ["''", ˇ] + "#}); + cx.update_editor(|editor, window, cx| { + editor.handle_input("'", window, cx); + }); + cx.assert_editor_state(indoc! {r#" + def main(): + items = ["''", 'ˇ'] + "#}); + + // Mixed quotes on same line + cx.set_state(indoc! {r#" + def main(): + items = ['"""', "'''''", ˇ] + "#}); + cx.update_editor(|editor, window, cx| { + editor.handle_input("\"", window, cx); + }); + cx.assert_editor_state(indoc! {r#" + def main(): + items = ['"""', "'''''", "ˇ"] + "#}); + cx.update_editor(|editor, window, cx| { + editor.move_right(&MoveRight, window, cx); + }); + cx.update_editor(|editor, window, cx| { + editor.handle_input(", ", window, cx); + }); + cx.update_editor(|editor, window, cx| { + editor.handle_input("'", window, cx); + }); + cx.assert_editor_state(indoc! {r#" + def main(): + items = ['"""', "'''''", "", 'ˇ'] + "#}); +} + +#[gpui::test] +async fn test_autoclose_quotes_with_multibyte_characters(cx: &mut TestAppContext) { + init_test(cx, |_| {}); + + let mut cx = EditorTestContext::new(cx).await; + let language = languages::language("python", tree_sitter_python::LANGUAGE.into()); + cx.update_buffer(|buffer, cx| buffer.set_language(Some(language), cx)); + + cx.set_state(indoc! {r#" + def main(): + items = ["🎉", ˇ] + "#}); + cx.update_editor(|editor, window, cx| { + editor.handle_input("\"", window, cx); + }); + cx.assert_editor_state(indoc! {r#" + def main(): + items = ["🎉", "ˇ"] + "#}); +} + #[gpui::test] async fn test_surround_with_pair(cx: &mut TestAppContext) { init_test(cx, |_| {}); From fb574d88697afc2d3bd8469df004876402eea0f2 Mon Sep 17 00:00:00 2001 From: Michael Benfield Date: Mon, 15 Dec 2025 12:56:22 -0800 Subject: [PATCH 324/621] Inline assistant: Clear failure text when regenerating (#44911) Release Notes: - N/A --- crates/agent_ui/src/buffer_codegen.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/agent_ui/src/buffer_codegen.rs b/crates/agent_ui/src/buffer_codegen.rs index d8d0efda0fbd70153b02452f6281ee66b90eca92..25395278745a9eb18fbbfa1cd920af3e3b26e24d 100644 --- a/crates/agent_ui/src/buffer_codegen.rs +++ b/crates/agent_ui/src/buffer_codegen.rs @@ -409,6 +409,9 @@ impl CodegenAlternative { model: Arc, cx: &mut Context, ) -> Result<()> { + // Clear the model explanation since the user has started a new generation. + self.description = None; + if let Some(transformation_transaction_id) = self.transformation_transaction_id.take() { self.buffer.update(cx, |buffer, cx| { buffer.undo_transaction(transformation_transaction_id, cx); From 9e11aaec517c8ef51ad0b8a8255be25bce42fa31 Mon Sep 17 00:00:00 2001 From: pedroni <69983330+pedroni@users.noreply.github.com> Date: Mon, 15 Dec 2025 18:04:28 -0300 Subject: [PATCH 325/621] Add ZoomIn and ZoomOut actions for independent zoom control (#44587) Closes #14472 Introduces `workspace::ZoomIn` and `workspace::ZoomOut` actions that complement the existing `workspace::ToggleZoom` action. ZoomIn only zooms if not already zoomed, and ZoomOut only zooms out if currently zoomed. This enables composing zoom actions with `workspace::SendKeystrokes` for workflows like "focus terminal then zoom in".

Example usage

Example keybindings: ```json [ { "bindings": { "ctrl-cmd-,": "terminal_panel::ToggleFocus", "ctrl-cmd-.": "workspace::ZoomIn", } }, { "context": "Terminal", "bindings": { "cmd-.": "terminal_panel::ToggleFocus" } }, { "context": "!Terminal", "bindings": { "cmd-.": ["workspace::SendKeystrokes", "ctrl-cmd-, ctrl-cmd-."] } }, ] ``` Demo: https://github.com/user-attachments/assets/1b1deda9-7775-4d78-a281-dc9622032ead

Release Notes: - Added the actions: `workspace::ZoomIn` and `workspace::ZoomOut` that complement the existing `workspace::ToggleZoom` action --- crates/workspace/src/pane.rs | 23 ++++++- crates/workspace/src/workspace.rs | 103 ++++++++++++++++++++++++++++++ 2 files changed, 125 insertions(+), 1 deletion(-) diff --git a/crates/workspace/src/pane.rs b/crates/workspace/src/pane.rs index 50ba58926ece8818ac5a4f44103c3b86eb2b672d..338a858f3c774deb1cc0750c56afd678f4eadf4a 100644 --- a/crates/workspace/src/pane.rs +++ b/crates/workspace/src/pane.rs @@ -1,7 +1,7 @@ use crate::{ CloseWindow, NewFile, NewTerminal, OpenInTerminal, OpenOptions, OpenTerminal, OpenVisible, SplitDirection, ToggleFileFinder, ToggleProjectSymbols, ToggleZoom, Workspace, - WorkspaceItemBuilder, + WorkspaceItemBuilder, ZoomIn, ZoomOut, invalid_item_view::InvalidItemView, item::{ ActivateOnClose, ClosePosition, Item, ItemBufferKind, ItemHandle, ItemSettings, @@ -1306,6 +1306,25 @@ impl Pane { } } + pub fn zoom_in(&mut self, _: &ZoomIn, window: &mut Window, cx: &mut Context) { + if !self.can_toggle_zoom { + cx.propagate(); + } else if !self.zoomed && !self.items.is_empty() { + if !self.focus_handle.contains_focused(window, cx) { + cx.focus_self(window); + } + cx.emit(Event::ZoomIn); + } + } + + pub fn zoom_out(&mut self, _: &ZoomOut, _window: &mut Window, cx: &mut Context) { + if !self.can_toggle_zoom { + cx.propagate(); + } else if self.zoomed { + cx.emit(Event::ZoomOut); + } + } + pub fn activate_item( &mut self, index: usize, @@ -3900,6 +3919,8 @@ impl Render for Pane { cx.emit(Event::JoinAll); })) .on_action(cx.listener(Pane::toggle_zoom)) + .on_action(cx.listener(Pane::zoom_in)) + .on_action(cx.listener(Pane::zoom_out)) .on_action(cx.listener(Self::navigate_backward)) .on_action(cx.listener(Self::navigate_forward)) .on_action( diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index 0a50faf867c2647874c1c7bb6d7887da6fee1388..7dfa5d634c73ee639be1e24373ca86b548180547 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -272,6 +272,10 @@ actions!( ToggleRightDock, /// Toggles zoom on the active pane. ToggleZoom, + /// Zooms in on the active pane. + ZoomIn, + /// Zooms out of the active pane. + ZoomOut, /// Stops following a collaborator. Unfollow, /// Restores the banner. @@ -9594,6 +9598,105 @@ mod tests { }); } + #[gpui::test] + async fn test_pane_zoom_in_out(cx: &mut TestAppContext) { + init_test(cx); + let fs = FakeFs::new(cx.executor()); + + let project = Project::test(fs, [], cx).await; + let (workspace, cx) = + cx.add_window_view(|window, cx| Workspace::test_new(project, window, cx)); + + let pane = workspace.update_in(cx, |workspace, _window, _cx| { + workspace.active_pane().clone() + }); + + // Add an item to the pane so it can be zoomed + workspace.update_in(cx, |workspace, window, cx| { + let item = cx.new(TestItem::new); + workspace.add_item(pane.clone(), Box::new(item), None, true, true, window, cx); + }); + + // Initially not zoomed + workspace.update_in(cx, |workspace, _window, cx| { + assert!(!pane.read(cx).is_zoomed(), "Pane starts unzoomed"); + assert!( + workspace.zoomed.is_none(), + "Workspace should track no zoomed pane" + ); + assert!(pane.read(cx).items_len() > 0, "Pane should have items"); + }); + + // Zoom In + pane.update_in(cx, |pane, window, cx| { + pane.zoom_in(&crate::ZoomIn, window, cx); + }); + + workspace.update_in(cx, |workspace, window, cx| { + assert!( + pane.read(cx).is_zoomed(), + "Pane should be zoomed after ZoomIn" + ); + assert!( + workspace.zoomed.is_some(), + "Workspace should track the zoomed pane" + ); + assert!( + pane.read(cx).focus_handle(cx).contains_focused(window, cx), + "ZoomIn should focus the pane" + ); + }); + + // Zoom In again is a no-op + pane.update_in(cx, |pane, window, cx| { + pane.zoom_in(&crate::ZoomIn, window, cx); + }); + + workspace.update_in(cx, |workspace, window, cx| { + assert!(pane.read(cx).is_zoomed(), "Second ZoomIn keeps pane zoomed"); + assert!( + workspace.zoomed.is_some(), + "Workspace still tracks zoomed pane" + ); + assert!( + pane.read(cx).focus_handle(cx).contains_focused(window, cx), + "Pane remains focused after repeated ZoomIn" + ); + }); + + // Zoom Out + pane.update_in(cx, |pane, window, cx| { + pane.zoom_out(&crate::ZoomOut, window, cx); + }); + + workspace.update_in(cx, |workspace, _window, cx| { + assert!( + !pane.read(cx).is_zoomed(), + "Pane should unzoom after ZoomOut" + ); + assert!( + workspace.zoomed.is_none(), + "Workspace clears zoom tracking after ZoomOut" + ); + }); + + // Zoom Out again is a no-op + pane.update_in(cx, |pane, window, cx| { + pane.zoom_out(&crate::ZoomOut, window, cx); + }); + + workspace.update_in(cx, |workspace, _window, cx| { + assert!( + !pane.read(cx).is_zoomed(), + "Second ZoomOut keeps pane unzoomed" + ); + assert!( + workspace.zoomed.is_none(), + "Workspace remains without zoomed pane" + ); + }); + } + #[gpui::test] async fn test_toggle_all_docks(cx: &mut gpui::TestAppContext) { init_test(cx); From ee6469d60e4ae1de2e84239db836c767d34958ef Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Mon, 15 Dec 2025 22:13:25 +0100 Subject: [PATCH 326/621] project: Clear worktree settings when worktrees get removed (#44913) Release Notes: - N/A *or* Added/Fixed/Improved ... --- crates/project/src/project_settings.rs | 21 ++++++++++++++------- crates/settings/src/settings_store.rs | 11 +++++++++++ 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/crates/project/src/project_settings.rs b/crates/project/src/project_settings.rs index b7dadc52f74f4800741f5cf537ac9f52c09643e3..8494eac5b33e7e1f231f9c62010c49aec345229f 100644 --- a/crates/project/src/project_settings.rs +++ b/crates/project/src/project_settings.rs @@ -792,13 +792,20 @@ impl SettingsObserver { event: &WorktreeStoreEvent, cx: &mut Context, ) { - if let WorktreeStoreEvent::WorktreeAdded(worktree) = event { - cx.subscribe(worktree, |this, worktree, event, cx| { - if let worktree::Event::UpdatedEntries(changes) = event { - this.update_local_worktree_settings(&worktree, changes, cx) - } - }) - .detach() + match event { + WorktreeStoreEvent::WorktreeAdded(worktree) => cx + .subscribe(worktree, |this, worktree, event, cx| { + if let worktree::Event::UpdatedEntries(changes) = event { + this.update_local_worktree_settings(&worktree, changes, cx) + } + }) + .detach(), + WorktreeStoreEvent::WorktreeRemoved(_, worktree_id) => { + cx.update_global::(|store, cx| { + store.clear_local_settings(*worktree_id, cx).log_err(); + }); + } + _ => {} } } diff --git a/crates/settings/src/settings_store.rs b/crates/settings/src/settings_store.rs index 72e2d3ef099659c5ad27e7f1aaafaee24354d4a9..abd45a141647f6ba13708c549188a22988c78069 100644 --- a/crates/settings/src/settings_store.rs +++ b/crates/settings/src/settings_store.rs @@ -247,6 +247,7 @@ pub trait AnySettingValue: 'static + Send + Sync { fn all_local_values(&self) -> Vec<(WorktreeId, Arc, &dyn Any)>; fn set_global_value(&mut self, value: Box); fn set_local_value(&mut self, root_id: WorktreeId, path: Arc, value: Box); + fn clear_local_values(&mut self, root_id: WorktreeId); } /// Parameters that are used when generating some JSON schemas at runtime. @@ -971,6 +972,11 @@ impl SettingsStore { pub fn clear_local_settings(&mut self, root_id: WorktreeId, cx: &mut App) -> Result<()> { self.local_settings .retain(|(worktree_id, _), _| worktree_id != &root_id); + self.raw_editorconfig_settings + .retain(|(worktree_id, _), _| worktree_id != &root_id); + for setting_value in self.setting_values.values_mut() { + setting_value.clear_local_values(root_id); + } self.recompute_values(Some((root_id, RelPath::empty())), cx); Ok(()) } @@ -1338,6 +1344,11 @@ impl AnySettingValue for SettingValue { Err(ix) => self.local_values.insert(ix, (root_id, path, value)), } } + + fn clear_local_values(&mut self, root_id: WorktreeId) { + self.local_values + .retain(|(worktree_id, _, _)| *worktree_id != root_id); + } } #[cfg(test)] From c7a1852e366dd2df779e652ad86e4df4a2626524 Mon Sep 17 00:00:00 2001 From: Finn Evers Date: Mon, 15 Dec 2025 22:14:04 +0100 Subject: [PATCH 327/621] collab: Add `dependabot[bot]` to the `GET /contributor` endpoint (#44919) This PR adds the `dependabot[bot]` user to the `GET /contributor` endpoint so that it passes the CLA check. Release Notes: - N/A --- crates/collab/src/api/contributors.rs | 40 +++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/crates/collab/src/api/contributors.rs b/crates/collab/src/api/contributors.rs index 574667c723dce62b905e3d2a0b34de1ca4c88c8e..549a9346b57c0a9801fe791826e9346e3f0350df 100644 --- a/crates/collab/src/api/contributors.rs +++ b/crates/collab/src/api/contributors.rs @@ -54,6 +54,16 @@ async fn check_is_contributor( ) -> Result> { let params = params.into_contributor_selector()?; + if Dependabot::is_dependabot(¶ms) { + return Ok(Json(CheckIsContributorResponse { + signed_at: Some( + Dependabot::created_at() + .and_utc() + .to_rfc3339_opts(SecondsFormat::Millis, true), + ), + })); + } + if RenovateBot::is_renovate_bot(¶ms) { return Ok(Json(CheckIsContributorResponse { signed_at: Some( @@ -83,6 +93,36 @@ async fn check_is_contributor( })) } +/// The Dependabot bot GitHub user (`dependabot[bot]`). +/// +/// https://api.github.com/users/dependabot[bot] +struct Dependabot; + +impl Dependabot { + const LOGIN: &'static str = "dependabot[bot]"; + const USER_ID: i32 = 49699333; + + /// Returns the `created_at` timestamp for the Dependabot bot user. + fn created_at() -> &'static NaiveDateTime { + static CREATED_AT: OnceLock = OnceLock::new(); + CREATED_AT.get_or_init(|| { + chrono::DateTime::parse_from_rfc3339("2019-04-16T22:34:25Z") + .expect("failed to parse 'created_at' for 'dependabot[bot]'") + .naive_utc() + }) + } + + /// Returns whether the given contributor selector corresponds to the Dependabot bot user. + fn is_dependabot(contributor: &ContributorSelector) -> bool { + match contributor { + ContributorSelector::GitHubLogin { github_login } => github_login == Self::LOGIN, + ContributorSelector::GitHubUserId { github_user_id } => { + github_user_id == &Self::USER_ID + } + } + } +} + /// The Renovate bot GitHub user (`renovate[bot]`). /// /// https://api.github.com/users/renovate[bot] From 47a6bd22e4335d6ebe4df0e051b672790f2602e2 Mon Sep 17 00:00:00 2001 From: Matt Miller Date: Mon, 15 Dec 2025 15:37:00 -0600 Subject: [PATCH 328/621] Terminal ANSI colors (#44912) Closes #38992 Release Notes: - N/A --------- Co-authored-by: dangooddd --- assets/themes/one/one.json | 104 ++++++++++++++++++------------------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/assets/themes/one/one.json b/assets/themes/one/one.json index c72c92471761c473bea05edc37b1f96f18b2f683..13f94991ad44fc997144a3d44527dcbce5231504 100644 --- a/assets/themes/one/one.json +++ b/assets/themes/one/one.json @@ -68,34 +68,34 @@ "editor.active_wrap_guide": "#c8ccd41a", "editor.document_highlight.read_background": "#74ade81a", "editor.document_highlight.write_background": "#555a6366", - "terminal.background": "#282c33ff", - "terminal.foreground": "#dce0e5ff", + "terminal.background": "#282c34ff", + "terminal.foreground": "#abb2bfff", "terminal.bright_foreground": "#dce0e5ff", - "terminal.dim_foreground": "#282c33ff", - "terminal.ansi.black": "#282c33ff", - "terminal.ansi.bright_black": "#525561ff", - "terminal.ansi.dim_black": "#dce0e5ff", - "terminal.ansi.red": "#d07277ff", - "terminal.ansi.bright_red": "#673a3cff", - "terminal.ansi.dim_red": "#eab7b9ff", - "terminal.ansi.green": "#a1c181ff", - "terminal.ansi.bright_green": "#4d6140ff", - "terminal.ansi.dim_green": "#d1e0bfff", - "terminal.ansi.yellow": "#dec184ff", - "terminal.ansi.bright_yellow": "#e5c07bff", - "terminal.ansi.dim_yellow": "#f1dfc1ff", - "terminal.ansi.blue": "#74ade8ff", - "terminal.ansi.bright_blue": "#385378ff", - "terminal.ansi.dim_blue": "#bed5f4ff", - "terminal.ansi.magenta": "#b477cfff", - "terminal.ansi.bright_magenta": "#d6b4e4ff", - "terminal.ansi.dim_magenta": "#612a79ff", - "terminal.ansi.cyan": "#6eb4bfff", - "terminal.ansi.bright_cyan": "#3a565bff", - "terminal.ansi.dim_cyan": "#b9d9dfff", - "terminal.ansi.white": "#dce0e5ff", + "terminal.dim_foreground": "#636d83ff", + "terminal.ansi.black": "#282c34ff", + "terminal.ansi.bright_black": "#636d83ff", + "terminal.ansi.dim_black": "#3b3f4aff", + "terminal.ansi.red": "#e06c75ff", + "terminal.ansi.bright_red": "#EA858Bff", + "terminal.ansi.dim_red": "#a7545aff", + "terminal.ansi.green": "#98c379ff", + "terminal.ansi.bright_green": "#AAD581ff", + "terminal.ansi.dim_green": "#6d8f59ff", + "terminal.ansi.yellow": "#e5c07bff", + "terminal.ansi.bright_yellow": "#FFD885ff", + "terminal.ansi.dim_yellow": "#b8985bff", + "terminal.ansi.blue": "#61afefff", + "terminal.ansi.bright_blue": "#85C1FFff", + "terminal.ansi.dim_blue": "#457cadff", + "terminal.ansi.magenta": "#c678ddff", + "terminal.ansi.bright_magenta": "#D398EBff", + "terminal.ansi.dim_magenta": "#8d54a0ff", + "terminal.ansi.cyan": "#56b6c2ff", + "terminal.ansi.bright_cyan": "#6ED5DEff", + "terminal.ansi.dim_cyan": "#3c818aff", + "terminal.ansi.white": "#abb2bfff", "terminal.ansi.bright_white": "#fafafaff", - "terminal.ansi.dim_white": "#575d65ff", + "terminal.ansi.dim_white": "#8f969bff", "link_text.hover": "#74ade8ff", "version_control.added": "#27a657ff", "version_control.modified": "#d3b020ff", @@ -473,33 +473,33 @@ "editor.document_highlight.read_background": "#5c78e225", "editor.document_highlight.write_background": "#a3a3a466", "terminal.background": "#fafafaff", - "terminal.foreground": "#242529ff", - "terminal.bright_foreground": "#242529ff", - "terminal.dim_foreground": "#fafafaff", - "terminal.ansi.black": "#242529ff", - "terminal.ansi.bright_black": "#747579ff", - "terminal.ansi.dim_black": "#97979aff", - "terminal.ansi.red": "#d36151ff", - "terminal.ansi.bright_red": "#f0b0a4ff", - "terminal.ansi.dim_red": "#6f312aff", - "terminal.ansi.green": "#669f59ff", - "terminal.ansi.bright_green": "#b2cfa9ff", - "terminal.ansi.dim_green": "#354d2eff", - "terminal.ansi.yellow": "#dec184ff", - "terminal.ansi.bright_yellow": "#826221ff", - "terminal.ansi.dim_yellow": "#786441ff", - "terminal.ansi.blue": "#5c78e2ff", - "terminal.ansi.bright_blue": "#b5baf2ff", - "terminal.ansi.dim_blue": "#2d3d75ff", - "terminal.ansi.magenta": "#984ea5ff", - "terminal.ansi.bright_magenta": "#cea6d3ff", - "terminal.ansi.dim_magenta": "#4b2a50ff", - "terminal.ansi.cyan": "#3a82b7ff", - "terminal.ansi.bright_cyan": "#a3bedaff", - "terminal.ansi.dim_cyan": "#254058ff", - "terminal.ansi.white": "#fafafaff", + "terminal.foreground": "#2a2c33ff", + "terminal.bright_foreground": "#2a2c33ff", + "terminal.dim_foreground": "#bbbbbbff", + "terminal.ansi.black": "#000000ff", + "terminal.ansi.bright_black": "#000000ff", + "terminal.ansi.dim_black": "#555555ff", + "terminal.ansi.red": "#de3e35ff", + "terminal.ansi.bright_red": "#de3e35ff", + "terminal.ansi.dim_red": "#9c2b26ff", + "terminal.ansi.green": "#3f953aff", + "terminal.ansi.bright_green": "#3f953aff", + "terminal.ansi.dim_green": "#2b6927ff", + "terminal.ansi.yellow": "#d2b67cff", + "terminal.ansi.bright_yellow": "#d2b67cff", + "terminal.ansi.dim_yellow": "#a48c5aff", + "terminal.ansi.blue": "#2f5af3ff", + "terminal.ansi.bright_blue": "#2f5af3ff", + "terminal.ansi.dim_blue": "#2140abff", + "terminal.ansi.magenta": "#950095ff", + "terminal.ansi.bright_magenta": "#a00095ff", + "terminal.ansi.dim_magenta": "#6a006aff", + "terminal.ansi.cyan": "#3f953aff", + "terminal.ansi.bright_cyan": "#3f953aff", + "terminal.ansi.dim_cyan": "#2b6927ff", + "terminal.ansi.white": "#bbbbbbff", "terminal.ansi.bright_white": "#ffffffff", - "terminal.ansi.dim_white": "#aaaaaaff", + "terminal.ansi.dim_white": "#888888ff", "link_text.hover": "#5c78e2ff", "version_control.added": "#27a657ff", "version_control.modified": "#d3b020ff", From faef5c9eace02d0e8da87411b1ad4b01ae9e8c12 Mon Sep 17 00:00:00 2001 From: Kunall Banerjee Date: Mon, 15 Dec 2025 17:04:03 -0500 Subject: [PATCH 329/621] docs: Drop deprecated key from settings for Agent Panel (#44923) The `version` key was deprecated a while ago. Release Notes: - N/A --- docs/src/git.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/src/git.md b/docs/src/git.md index d562eb4d0a3b07f4de7df1b0831f6e91a2767c1d..8a94a79973b390f1d4e8075469b610d51b6f2016 100644 --- a/docs/src/git.md +++ b/docs/src/git.md @@ -145,7 +145,6 @@ You can specify your preferred model to use by providing a `commit_message_model ```json [settings] { "agent": { - "version": "2", "commit_message_model": { "provider": "anthropic", "model": "claude-3-5-haiku" From eceece8ce5e98d59ab30be8a0e50677b22c82515 Mon Sep 17 00:00:00 2001 From: Marshall Bowers Date: Mon, 15 Dec 2025 17:11:42 -0500 Subject: [PATCH 330/621] docs: Update links to account page (#44924) This PR updates the links to the account page to point to the Dashboard. Release Notes: - N/A --- docs/src/ai/billing.md | 4 ++-- docs/src/ai/plans-and-usage.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/src/ai/billing.md b/docs/src/ai/billing.md index 64ff871ce1b629fad72d4ddd6f9c8f42f2bf92da..788c0c1cf7cb0bfd64bdd83812e1e62bf51abf88 100644 --- a/docs/src/ai/billing.md +++ b/docs/src/ai/billing.md @@ -5,7 +5,7 @@ For invoice-based billing, a Business plan is required. Contact [sales@zed.dev]( ## Billing Information {#settings} -You can access billing information and settings at [zed.dev/account](https://zed.dev/account). +You can access billing information and settings at [dashboard.zed.dev/account](https://dashboard.zed.dev/account). Most of the page embeds information from our invoicing/metering partner, Orb (we're planning on a more native experience soon!). ## Billing Cycles {#billing-cycles} @@ -28,7 +28,7 @@ If payment of an invoice fails, Zed will block usage of our hosted models until ## Invoice History {#invoice-history} -You can access your invoice history by navigating to [zed.dev/account](https://zed.dev/account) and clicking `Invoice history` within the embedded Orb portal. +You can access your invoice history by navigating to [dashboard.zed.dev/account](https://dashboard.zed.dev/account) and clicking `Invoice history` within the embedded Orb portal. If you require historical Stripe invoices, email [billing-support@zed.dev](mailto:billing-support@zed.dev) diff --git a/docs/src/ai/plans-and-usage.md b/docs/src/ai/plans-and-usage.md index fc59a894aacd524a10e31b65ababd4f8d79e3b8e..63f72211aa70b19b820fb9b368d47a3b008b726d 100644 --- a/docs/src/ai/plans-and-usage.md +++ b/docs/src/ai/plans-and-usage.md @@ -12,11 +12,11 @@ Usage of Zed's hosted models is measured on a token basis, converted to dollars Zed Pro comes with $5 of monthly dollar credit. A trial of Zed Pro includes $20 of credit, usable for 14 days. Monthly included credit resets on your monthly billing date. -To view your current usage, you can visit your account at [zed.dev/account](https://zed.dev/account). Information from our metering and billing provider, Orb, is embedded on that page. +To view your current usage, you can visit your account at [dashboard.zed.dev/account](https://dashboard.zed.dev/account). Information from our metering and billing provider, Orb, is embedded on that page. ## Spend Limits {#usage-spend-limits} -At the top of [the Account page](https://zed.dev/account), you'll find an input for `Maximum Token Spend`. The dollar amount here specifies your _monthly_ limit for spend on tokens, _not counting_ the $5/month included with your Pro subscription. +At the top of [the Account page](https://dashboard.zed.dev/account), you'll find an input for `Maximum Token Spend`. The dollar amount here specifies your _monthly_ limit for spend on tokens, _not counting_ the $5/month included with your Pro subscription. The default value for all Pro users is $10, for a total monthly spend with Zed of $20 ($10 for your Pro subscription, $10 in incremental token spend). This can be set to $0 to limit your spend with Zed to exactly $10/month. If you adjust this limit _higher_ than $10 and consume more than $10 of incremental token spend, you'll be billed via [threshold billing](./billing.md#threshold-billing). From 5987dff7e481f2c3fcc6fc89ffd6ae254bfe638f Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Mon, 15 Dec 2025 15:15:09 -0700 Subject: [PATCH 331/621] Add save_file and restore_file_from_disk agent tools (#44789) Release Notes: - Added `save_file` and `restore_file_from_disk` tools to the agent, allowing it to resolve dirty buffer conflicts when editing files. When the agent encounters a file with unsaved changes, it will now ask whether you want to keep or discard those changes before proceeding. --- crates/agent/src/thread.rs | 5 +- crates/agent/src/tools.rs | 8 +- crates/agent/src/tools/edit_file_tool.rs | 23 +- .../src/tools/restore_file_from_disk_tool.rs | 352 ++++++++++++++++++ crates/agent/src/tools/save_file_tool.rs | 351 +++++++++++++++++ 5 files changed, 732 insertions(+), 7 deletions(-) create mode 100644 crates/agent/src/tools/restore_file_from_disk_tool.rs create mode 100644 crates/agent/src/tools/save_file_tool.rs diff --git a/crates/agent/src/thread.rs b/crates/agent/src/thread.rs index a51dd3bf9fd5213c88a0ab56ef9ec9b563a90756..b61c0ad0840475c3b5f6d4c0a7082a26d4d44a58 100644 --- a/crates/agent/src/thread.rs +++ b/crates/agent/src/thread.rs @@ -2,7 +2,8 @@ use crate::{ ContextServerRegistry, CopyPathTool, CreateDirectoryTool, DbLanguageModel, DbThread, DeletePathTool, DiagnosticsTool, EditFileTool, FetchTool, FindPathTool, GrepTool, ListDirectoryTool, MovePathTool, NowTool, OpenTool, ProjectSnapshot, ReadFileTool, - SystemPromptTemplate, Template, Templates, TerminalTool, ThinkingTool, WebSearchTool, + RestoreFileFromDiskTool, SaveFileTool, SystemPromptTemplate, Template, Templates, TerminalTool, + ThinkingTool, WebSearchTool, }; use acp_thread::{MentionUri, UserMessageId}; use action_log::ActionLog; @@ -1002,6 +1003,8 @@ impl Thread { self.project.clone(), self.action_log.clone(), )); + self.add_tool(SaveFileTool::new(self.project.clone())); + self.add_tool(RestoreFileFromDiskTool::new(self.project.clone())); self.add_tool(TerminalTool::new(self.project.clone(), environment)); self.add_tool(ThinkingTool); self.add_tool(WebSearchTool); diff --git a/crates/agent/src/tools.rs b/crates/agent/src/tools.rs index 62a52998a705e11d1c9e69cbade7f427cc9cfc32..358903a32baa5ead9b073642015e6829501307a2 100644 --- a/crates/agent/src/tools.rs +++ b/crates/agent/src/tools.rs @@ -4,7 +4,6 @@ mod create_directory_tool; mod delete_path_tool; mod diagnostics_tool; mod edit_file_tool; - mod fetch_tool; mod find_path_tool; mod grep_tool; @@ -13,6 +12,8 @@ mod move_path_tool; mod now_tool; mod open_tool; mod read_file_tool; +mod restore_file_from_disk_tool; +mod save_file_tool; mod terminal_tool; mod thinking_tool; @@ -27,7 +28,6 @@ pub use create_directory_tool::*; pub use delete_path_tool::*; pub use diagnostics_tool::*; pub use edit_file_tool::*; - pub use fetch_tool::*; pub use find_path_tool::*; pub use grep_tool::*; @@ -36,6 +36,8 @@ pub use move_path_tool::*; pub use now_tool::*; pub use open_tool::*; pub use read_file_tool::*; +pub use restore_file_from_disk_tool::*; +pub use save_file_tool::*; pub use terminal_tool::*; pub use thinking_tool::*; @@ -92,6 +94,8 @@ tools! { NowTool, OpenTool, ReadFileTool, + RestoreFileFromDiskTool, + SaveFileTool, TerminalTool, ThinkingTool, WebSearchTool, diff --git a/crates/agent/src/tools/edit_file_tool.rs b/crates/agent/src/tools/edit_file_tool.rs index 0ab99426e2e9645adf3f837d21c28dc285ab6ea2..c08300e19541cad49033093f0d2bbe3a5b233683 100644 --- a/crates/agent/src/tools/edit_file_tool.rs +++ b/crates/agent/src/tools/edit_file_tool.rs @@ -316,9 +316,9 @@ impl AgentTool for EditFileTool { // Check for unsaved changes first - these indicate modifications we don't know about if is_dirty { anyhow::bail!( - "This file cannot be written to because it has unsaved changes. \ - Please end the current conversation immediately by telling the user you want to write to this file (mention its path explicitly) but you can't write to it because it has unsaved changes. \ - Ask the user to save that buffer's changes and to inform you when it's ok to proceed." + "This file has unsaved changes. Ask the user whether they want to keep or discard those changes. \ + If they want to keep them, ask for confirmation then use the save_file tool to save the file, then retry this edit. \ + If they want to discard them, ask for confirmation then use the restore_file_from_disk tool to restore the on-disk contents, then retry this edit." ); } @@ -2202,9 +2202,24 @@ mod tests { assert!(result.is_err(), "Edit should fail when buffer is dirty"); let error_msg = result.unwrap_err().to_string(); assert!( - error_msg.contains("cannot be written to because it has unsaved changes"), + error_msg.contains("This file has unsaved changes."), "Error should mention unsaved changes, got: {}", error_msg ); + assert!( + error_msg.contains("keep or discard"), + "Error should ask whether to keep or discard changes, got: {}", + error_msg + ); + assert!( + error_msg.contains("save_file"), + "Error should reference save_file tool, got: {}", + error_msg + ); + assert!( + error_msg.contains("restore_file_from_disk"), + "Error should reference restore_file_from_disk tool, got: {}", + error_msg + ); } } diff --git a/crates/agent/src/tools/restore_file_from_disk_tool.rs b/crates/agent/src/tools/restore_file_from_disk_tool.rs new file mode 100644 index 0000000000000000000000000000000000000000..f5723f6ee3ee46144152dd3ed2939ab2cfaca9c0 --- /dev/null +++ b/crates/agent/src/tools/restore_file_from_disk_tool.rs @@ -0,0 +1,352 @@ +use agent_client_protocol as acp; +use anyhow::Result; +use collections::FxHashSet; +use gpui::{App, Entity, SharedString, Task}; +use language::Buffer; +use project::Project; +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; +use std::path::PathBuf; +use std::sync::Arc; + +use crate::{AgentTool, ToolCallEventStream}; + +/// Discards unsaved changes in open buffers by reloading file contents from disk. +/// +/// Use this tool when: +/// - You attempted to edit files but they have unsaved changes the user does not want to keep. +/// - You want to reset files to the on-disk state before retrying an edit. +/// +/// Only use this tool after asking the user for permission, because it will discard unsaved changes. +#[derive(Debug, Serialize, Deserialize, JsonSchema)] +pub struct RestoreFileFromDiskToolInput { + /// The paths of the files to restore from disk. + pub paths: Vec, +} + +pub struct RestoreFileFromDiskTool { + project: Entity, +} + +impl RestoreFileFromDiskTool { + pub fn new(project: Entity) -> Self { + Self { project } + } +} + +impl AgentTool for RestoreFileFromDiskTool { + type Input = RestoreFileFromDiskToolInput; + type Output = String; + + fn name() -> &'static str { + "restore_file_from_disk" + } + + fn kind() -> acp::ToolKind { + acp::ToolKind::Other + } + + fn initial_title( + &self, + input: Result, + _cx: &mut App, + ) -> SharedString { + match input { + Ok(input) if input.paths.len() == 1 => "Restore file from disk".into(), + Ok(input) => format!("Restore {} files from disk", input.paths.len()).into(), + Err(_) => "Restore files from disk".into(), + } + } + + fn run( + self: Arc, + input: Self::Input, + _event_stream: ToolCallEventStream, + cx: &mut App, + ) -> Task> { + let project = self.project.clone(); + let input_paths = input.paths; + + cx.spawn(async move |cx| { + let mut buffers_to_reload: FxHashSet> = FxHashSet::default(); + + let mut restored_paths: Vec = Vec::new(); + let mut clean_paths: Vec = Vec::new(); + let mut not_found_paths: Vec = Vec::new(); + let mut open_errors: Vec<(PathBuf, String)> = Vec::new(); + let mut dirty_check_errors: Vec<(PathBuf, String)> = Vec::new(); + let mut reload_errors: Vec = Vec::new(); + + for path in input_paths { + let project_path = + project.read_with(cx, |project, cx| project.find_project_path(&path, cx)); + + let project_path = match project_path { + Ok(Some(project_path)) => project_path, + Ok(None) => { + not_found_paths.push(path); + continue; + } + Err(error) => { + open_errors.push((path, error.to_string())); + continue; + } + }; + + let open_buffer_task = + project.update(cx, |project, cx| project.open_buffer(project_path, cx)); + + let buffer = match open_buffer_task { + Ok(task) => match task.await { + Ok(buffer) => buffer, + Err(error) => { + open_errors.push((path, error.to_string())); + continue; + } + }, + Err(error) => { + open_errors.push((path, error.to_string())); + continue; + } + }; + + let is_dirty = match buffer.read_with(cx, |buffer, _| buffer.is_dirty()) { + Ok(is_dirty) => is_dirty, + Err(error) => { + dirty_check_errors.push((path, error.to_string())); + continue; + } + }; + + if is_dirty { + buffers_to_reload.insert(buffer); + restored_paths.push(path); + } else { + clean_paths.push(path); + } + } + + if !buffers_to_reload.is_empty() { + let reload_task = project.update(cx, |project, cx| { + project.reload_buffers(buffers_to_reload, true, cx) + }); + + match reload_task { + Ok(task) => { + if let Err(error) = task.await { + reload_errors.push(error.to_string()); + } + } + Err(error) => { + reload_errors.push(error.to_string()); + } + } + } + + let mut lines: Vec = Vec::new(); + + if !restored_paths.is_empty() { + lines.push(format!("Restored {} file(s).", restored_paths.len())); + } + if !clean_paths.is_empty() { + lines.push(format!("{} clean.", clean_paths.len())); + } + + if !not_found_paths.is_empty() { + lines.push(format!("Not found ({}):", not_found_paths.len())); + for path in ¬_found_paths { + lines.push(format!("- {}", path.display())); + } + } + if !open_errors.is_empty() { + lines.push(format!("Open failed ({}):", open_errors.len())); + for (path, error) in &open_errors { + lines.push(format!("- {}: {}", path.display(), error)); + } + } + if !dirty_check_errors.is_empty() { + lines.push(format!( + "Dirty check failed ({}):", + dirty_check_errors.len() + )); + for (path, error) in &dirty_check_errors { + lines.push(format!("- {}: {}", path.display(), error)); + } + } + if !reload_errors.is_empty() { + lines.push(format!("Reload failed ({}):", reload_errors.len())); + for error in &reload_errors { + lines.push(format!("- {}", error)); + } + } + + if lines.is_empty() { + Ok("No paths provided.".to_string()) + } else { + Ok(lines.join("\n")) + } + }) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use fs::Fs; + use gpui::TestAppContext; + use language::LineEnding; + use project::FakeFs; + use serde_json::json; + use settings::SettingsStore; + use util::path; + + fn init_test(cx: &mut TestAppContext) { + cx.update(|cx| { + let settings_store = SettingsStore::test(cx); + cx.set_global(settings_store); + }); + } + + #[gpui::test] + async fn test_restore_file_from_disk_output_and_effects(cx: &mut TestAppContext) { + init_test(cx); + + let fs = FakeFs::new(cx.executor()); + fs.insert_tree( + "/root", + json!({ + "dirty.txt": "on disk: dirty\n", + "clean.txt": "on disk: clean\n", + }), + ) + .await; + + let project = Project::test(fs.clone(), [path!("/root").as_ref()], cx).await; + let tool = Arc::new(RestoreFileFromDiskTool::new(project.clone())); + + // Make dirty.txt dirty in-memory by saving different content into the buffer without saving to disk. + let dirty_project_path = project.read_with(cx, |project, cx| { + project + .find_project_path("root/dirty.txt", cx) + .expect("dirty.txt should exist in project") + }); + + let dirty_buffer = project + .update(cx, |project, cx| { + project.open_buffer(dirty_project_path, cx) + }) + .await + .unwrap(); + dirty_buffer.update(cx, |buffer, cx| { + buffer.edit([(0..buffer.len(), "in memory: dirty\n")], None, cx); + }); + assert!( + dirty_buffer.read_with(cx, |buffer, _| buffer.is_dirty()), + "dirty.txt buffer should be dirty before restore" + ); + + // Ensure clean.txt is opened but remains clean. + let clean_project_path = project.read_with(cx, |project, cx| { + project + .find_project_path("root/clean.txt", cx) + .expect("clean.txt should exist in project") + }); + + let clean_buffer = project + .update(cx, |project, cx| { + project.open_buffer(clean_project_path, cx) + }) + .await + .unwrap(); + assert!( + !clean_buffer.read_with(cx, |buffer, _| buffer.is_dirty()), + "clean.txt buffer should start clean" + ); + + let output = cx + .update(|cx| { + tool.clone().run( + RestoreFileFromDiskToolInput { + paths: vec![ + PathBuf::from("root/dirty.txt"), + PathBuf::from("root/clean.txt"), + ], + }, + ToolCallEventStream::test().0, + cx, + ) + }) + .await + .unwrap(); + + // Output should mention restored + clean. + assert!( + output.contains("Restored 1 file(s)."), + "expected restored count line, got:\n{output}" + ); + assert!( + output.contains("1 clean."), + "expected clean count line, got:\n{output}" + ); + + // Effect: dirty buffer should be restored back to disk content and become clean. + let dirty_text = dirty_buffer.read_with(cx, |buffer, _| buffer.text()); + assert_eq!( + dirty_text, "on disk: dirty\n", + "dirty.txt buffer should be restored to disk contents" + ); + assert!( + !dirty_buffer.read_with(cx, |buffer, _| buffer.is_dirty()), + "dirty.txt buffer should not be dirty after restore" + ); + + // Disk contents should be unchanged (restore-from-disk should not write). + let disk_dirty = fs.load(path!("/root/dirty.txt").as_ref()).await.unwrap(); + assert_eq!(disk_dirty, "on disk: dirty\n"); + + // Sanity: clean buffer should remain clean and unchanged. + let clean_text = clean_buffer.read_with(cx, |buffer, _| buffer.text()); + assert_eq!(clean_text, "on disk: clean\n"); + assert!( + !clean_buffer.read_with(cx, |buffer, _| buffer.is_dirty()), + "clean.txt buffer should remain clean" + ); + + // Test empty paths case. + let output = cx + .update(|cx| { + tool.clone().run( + RestoreFileFromDiskToolInput { paths: vec![] }, + ToolCallEventStream::test().0, + cx, + ) + }) + .await + .unwrap(); + assert_eq!(output, "No paths provided."); + + // Test not-found path case (path outside the project root). + let output = cx + .update(|cx| { + tool.clone().run( + RestoreFileFromDiskToolInput { + paths: vec![PathBuf::from("nonexistent/path.txt")], + }, + ToolCallEventStream::test().0, + cx, + ) + }) + .await + .unwrap(); + assert!( + output.contains("Not found (1):"), + "expected not-found header line, got:\n{output}" + ); + assert!( + output.contains("- nonexistent/path.txt"), + "expected not-found path bullet, got:\n{output}" + ); + + let _ = LineEnding::Unix; // keep import used if the buffer edit API changes + } +} diff --git a/crates/agent/src/tools/save_file_tool.rs b/crates/agent/src/tools/save_file_tool.rs new file mode 100644 index 0000000000000000000000000000000000000000..429352200109c52303c9f6f94a28a49136af1a61 --- /dev/null +++ b/crates/agent/src/tools/save_file_tool.rs @@ -0,0 +1,351 @@ +use agent_client_protocol as acp; +use anyhow::Result; +use collections::FxHashSet; +use gpui::{App, Entity, SharedString, Task}; +use language::Buffer; +use project::Project; +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; +use std::path::PathBuf; +use std::sync::Arc; + +use crate::{AgentTool, ToolCallEventStream}; + +/// Saves files that have unsaved changes. +/// +/// Use this tool when you need to edit files but they have unsaved changes that must be saved first. +/// Only use this tool after asking the user for permission to save their unsaved changes. +#[derive(Debug, Serialize, Deserialize, JsonSchema)] +pub struct SaveFileToolInput { + /// The paths of the files to save. + pub paths: Vec, +} + +pub struct SaveFileTool { + project: Entity, +} + +impl SaveFileTool { + pub fn new(project: Entity) -> Self { + Self { project } + } +} + +impl AgentTool for SaveFileTool { + type Input = SaveFileToolInput; + type Output = String; + + fn name() -> &'static str { + "save_file" + } + + fn kind() -> acp::ToolKind { + acp::ToolKind::Other + } + + fn initial_title( + &self, + input: Result, + _cx: &mut App, + ) -> SharedString { + match input { + Ok(input) if input.paths.len() == 1 => "Save file".into(), + Ok(input) => format!("Save {} files", input.paths.len()).into(), + Err(_) => "Save files".into(), + } + } + + fn run( + self: Arc, + input: Self::Input, + _event_stream: ToolCallEventStream, + cx: &mut App, + ) -> Task> { + let project = self.project.clone(); + let input_paths = input.paths; + + cx.spawn(async move |cx| { + let mut buffers_to_save: FxHashSet> = FxHashSet::default(); + + let mut saved_paths: Vec = Vec::new(); + let mut clean_paths: Vec = Vec::new(); + let mut not_found_paths: Vec = Vec::new(); + let mut open_errors: Vec<(PathBuf, String)> = Vec::new(); + let mut dirty_check_errors: Vec<(PathBuf, String)> = Vec::new(); + let mut save_errors: Vec<(String, String)> = Vec::new(); + + for path in input_paths { + let project_path = + project.read_with(cx, |project, cx| project.find_project_path(&path, cx)); + + let project_path = match project_path { + Ok(Some(project_path)) => project_path, + Ok(None) => { + not_found_paths.push(path); + continue; + } + Err(error) => { + open_errors.push((path, error.to_string())); + continue; + } + }; + + let open_buffer_task = + project.update(cx, |project, cx| project.open_buffer(project_path, cx)); + + let buffer = match open_buffer_task { + Ok(task) => match task.await { + Ok(buffer) => buffer, + Err(error) => { + open_errors.push((path, error.to_string())); + continue; + } + }, + Err(error) => { + open_errors.push((path, error.to_string())); + continue; + } + }; + + let is_dirty = match buffer.read_with(cx, |buffer, _| buffer.is_dirty()) { + Ok(is_dirty) => is_dirty, + Err(error) => { + dirty_check_errors.push((path, error.to_string())); + continue; + } + }; + + if is_dirty { + buffers_to_save.insert(buffer); + saved_paths.push(path); + } else { + clean_paths.push(path); + } + } + + // Save each buffer individually since there's no batch save API. + for buffer in buffers_to_save { + let path_for_buffer = match buffer.read_with(cx, |buffer, _| { + buffer + .file() + .map(|file| file.path().to_rel_path_buf()) + .map(|path| path.as_rel_path().as_unix_str().to_owned()) + }) { + Ok(path) => path.unwrap_or_else(|| "".to_string()), + Err(error) => { + save_errors.push(("".to_string(), error.to_string())); + continue; + } + }; + + let save_task = project.update(cx, |project, cx| project.save_buffer(buffer, cx)); + + match save_task { + Ok(task) => { + if let Err(error) = task.await { + save_errors.push((path_for_buffer, error.to_string())); + } + } + Err(error) => { + save_errors.push((path_for_buffer, error.to_string())); + } + } + } + + let mut lines: Vec = Vec::new(); + + if !saved_paths.is_empty() { + lines.push(format!("Saved {} file(s).", saved_paths.len())); + } + if !clean_paths.is_empty() { + lines.push(format!("{} clean.", clean_paths.len())); + } + + if !not_found_paths.is_empty() { + lines.push(format!("Not found ({}):", not_found_paths.len())); + for path in ¬_found_paths { + lines.push(format!("- {}", path.display())); + } + } + if !open_errors.is_empty() { + lines.push(format!("Open failed ({}):", open_errors.len())); + for (path, error) in &open_errors { + lines.push(format!("- {}: {}", path.display(), error)); + } + } + if !dirty_check_errors.is_empty() { + lines.push(format!( + "Dirty check failed ({}):", + dirty_check_errors.len() + )); + for (path, error) in &dirty_check_errors { + lines.push(format!("- {}: {}", path.display(), error)); + } + } + if !save_errors.is_empty() { + lines.push(format!("Save failed ({}):", save_errors.len())); + for (path, error) in &save_errors { + lines.push(format!("- {}: {}", path, error)); + } + } + + if lines.is_empty() { + Ok("No paths provided.".to_string()) + } else { + Ok(lines.join("\n")) + } + }) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use fs::Fs; + use gpui::TestAppContext; + use project::FakeFs; + use serde_json::json; + use settings::SettingsStore; + use util::path; + + fn init_test(cx: &mut TestAppContext) { + cx.update(|cx| { + let settings_store = SettingsStore::test(cx); + cx.set_global(settings_store); + }); + } + + #[gpui::test] + async fn test_save_file_output_and_effects(cx: &mut TestAppContext) { + init_test(cx); + + let fs = FakeFs::new(cx.executor()); + fs.insert_tree( + "/root", + json!({ + "dirty.txt": "on disk: dirty\n", + "clean.txt": "on disk: clean\n", + }), + ) + .await; + + let project = Project::test(fs.clone(), [path!("/root").as_ref()], cx).await; + let tool = Arc::new(SaveFileTool::new(project.clone())); + + // Make dirty.txt dirty in-memory. + let dirty_project_path = project.read_with(cx, |project, cx| { + project + .find_project_path("root/dirty.txt", cx) + .expect("dirty.txt should exist in project") + }); + + let dirty_buffer = project + .update(cx, |project, cx| { + project.open_buffer(dirty_project_path, cx) + }) + .await + .unwrap(); + dirty_buffer.update(cx, |buffer, cx| { + buffer.edit([(0..buffer.len(), "in memory: dirty\n")], None, cx); + }); + assert!( + dirty_buffer.read_with(cx, |buffer, _| buffer.is_dirty()), + "dirty.txt buffer should be dirty before save" + ); + + // Ensure clean.txt is opened but remains clean. + let clean_project_path = project.read_with(cx, |project, cx| { + project + .find_project_path("root/clean.txt", cx) + .expect("clean.txt should exist in project") + }); + + let clean_buffer = project + .update(cx, |project, cx| { + project.open_buffer(clean_project_path, cx) + }) + .await + .unwrap(); + assert!( + !clean_buffer.read_with(cx, |buffer, _| buffer.is_dirty()), + "clean.txt buffer should start clean" + ); + + let output = cx + .update(|cx| { + tool.clone().run( + SaveFileToolInput { + paths: vec![ + PathBuf::from("root/dirty.txt"), + PathBuf::from("root/clean.txt"), + ], + }, + ToolCallEventStream::test().0, + cx, + ) + }) + .await + .unwrap(); + + // Output should mention saved + clean. + assert!( + output.contains("Saved 1 file(s)."), + "expected saved count line, got:\n{output}" + ); + assert!( + output.contains("1 clean."), + "expected clean count line, got:\n{output}" + ); + + // Effect: dirty buffer should now be clean and disk should have new content. + assert!( + !dirty_buffer.read_with(cx, |buffer, _| buffer.is_dirty()), + "dirty.txt buffer should not be dirty after save" + ); + + let disk_dirty = fs.load(path!("/root/dirty.txt").as_ref()).await.unwrap(); + assert_eq!( + disk_dirty, "in memory: dirty\n", + "dirty.txt disk content should be updated" + ); + + // Sanity: clean buffer should remain clean and disk unchanged. + let disk_clean = fs.load(path!("/root/clean.txt").as_ref()).await.unwrap(); + assert_eq!(disk_clean, "on disk: clean\n"); + + // Test empty paths case. + let output = cx + .update(|cx| { + tool.clone().run( + SaveFileToolInput { paths: vec![] }, + ToolCallEventStream::test().0, + cx, + ) + }) + .await + .unwrap(); + assert_eq!(output, "No paths provided."); + + // Test not-found path case. + let output = cx + .update(|cx| { + tool.clone().run( + SaveFileToolInput { + paths: vec![PathBuf::from("nonexistent/path.txt")], + }, + ToolCallEventStream::test().0, + cx, + ) + }) + .await + .unwrap(); + assert!( + output.contains("Not found (1):"), + "expected not-found header line, got:\n{output}" + ); + assert!( + output.contains("- nonexistent/path.txt"), + "expected not-found path bullet, got:\n{output}" + ); + } +} From 97f6cdac81ff83476286b18e879e1d1c7a2aad80 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Mon, 15 Dec 2025 15:22:29 -0700 Subject: [PATCH 332/621] Add an autofix workflow (#44922) One of the major annoyances with writing code with claude is that its poorly indented; instead of requiring manual intervention, let's just fix that in CI. Similar to https://autofix.ci, but as we already have a github app, we can do it without relying on a 3rd party. This PR doesn't trigger the workflow (we need a separate change in Zippy to do that) but will let me test it manually. Release Notes: - N/A --- .github/workflows/autofix_pr.yml | 53 +++++++++++++ tooling/xtask/src/tasks/workflows.rs | 2 + .../xtask/src/tasks/workflows/autofix_pr.rs | 77 +++++++++++++++++++ tooling/xtask/src/tasks/workflows/steps.rs | 12 ++- 4 files changed, 143 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/autofix_pr.yml create mode 100644 tooling/xtask/src/tasks/workflows/autofix_pr.rs diff --git a/.github/workflows/autofix_pr.yml b/.github/workflows/autofix_pr.yml new file mode 100644 index 0000000000000000000000000000000000000000..8c7786f6e1b91879a8b5a6f26f685570cd9cb2d3 --- /dev/null +++ b/.github/workflows/autofix_pr.yml @@ -0,0 +1,53 @@ +# Generated from xtask::workflows::autofix_pr +# Rebuild with `cargo xtask workflows`. +name: autofix_pr +run-name: 'autofix PR #${{ inputs.pr_number }}' +on: + workflow_dispatch: + inputs: + pr_number: + description: pr_number + required: true + type: string +jobs: + run_autofix: + runs-on: namespace-profile-2x4-ubuntu-2404 + steps: + - id: get-app-token + name: autofix_pr::run_autofix::authenticate_as_zippy + uses: actions/create-github-app-token@bef1eaf1c0ac2b148ee2a0a74c65fbe6db0631f1 + with: + app-id: ${{ secrets.ZED_ZIPPY_APP_ID }} + private-key: ${{ secrets.ZED_ZIPPY_APP_PRIVATE_KEY }} + - name: steps::checkout_repo_with_token + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 + with: + clean: false + token: ${{ steps.get-app-token.outputs.token }} + - name: autofix_pr::run_autofix::checkout_pr + run: gh pr checkout ${{ inputs.pr_number }} + shell: bash -euxo pipefail {0} + env: + GITHUB_TOKEN: ${{ steps.get-app-token.outputs.token }} + - name: autofix_pr::run_autofix::run_cargo_fmt + run: cargo fmt --all + shell: bash -euxo pipefail {0} + - name: autofix_pr::run_autofix::run_clippy_fix + run: cargo clippy --workspace --release --all-targets --all-features --fix --allow-dirty --allow-staged + shell: bash -euxo pipefail {0} + - name: autofix_pr::run_autofix::commit_and_push + run: | + if git diff --quiet; then + echo "No changes to commit" + else + git add -A + git commit -m "Apply cargo fmt and clippy --fix" + git push + fi + shell: bash -euxo pipefail {0} + env: + GIT_COMMITTER_NAME: Zed Zippy + GIT_COMMITTER_EMAIL: hi@zed.dev + GIT_AUTHOR_NAME: Zed Zippy + GIT_AUTHOR_EMAIL: hi@zed.dev + GITHUB_TOKEN: ${{ steps.get-app-token.outputs.token }} diff --git a/tooling/xtask/src/tasks/workflows.rs b/tooling/xtask/src/tasks/workflows.rs index 717517402d619e54d30a502fcfe26418910aac35..fe476355203a69c962081c36fe350460b9df6f6b 100644 --- a/tooling/xtask/src/tasks/workflows.rs +++ b/tooling/xtask/src/tasks/workflows.rs @@ -5,6 +5,7 @@ use std::fs; use std::path::{Path, PathBuf}; mod after_release; +mod autofix_pr; mod cherry_pick; mod compare_perf; mod danger; @@ -111,6 +112,7 @@ pub fn run_workflows(_: GenerateWorkflowArgs) -> Result<()> { WorkflowFile::zed(run_tests::run_tests), WorkflowFile::zed(release::release), WorkflowFile::zed(cherry_pick::cherry_pick), + WorkflowFile::zed(autofix_pr::autofix_pr), WorkflowFile::zed(compare_perf::compare_perf), WorkflowFile::zed(run_agent_evals::run_unit_evals), WorkflowFile::zed(run_agent_evals::run_cron_unit_evals), diff --git a/tooling/xtask/src/tasks/workflows/autofix_pr.rs b/tooling/xtask/src/tasks/workflows/autofix_pr.rs new file mode 100644 index 0000000000000000000000000000000000000000..7e00a8bcbdbd9cd367221d2d90413fb59428d560 --- /dev/null +++ b/tooling/xtask/src/tasks/workflows/autofix_pr.rs @@ -0,0 +1,77 @@ +use gh_workflow::*; + +use crate::tasks::workflows::{ + runners, + steps::{self, NamedJob, named}, + vars::{self, StepOutput, WorkflowInput}, +}; + +pub fn autofix_pr() -> Workflow { + let pr_number = WorkflowInput::string("pr_number", None); + let autofix = run_autofix(&pr_number); + named::workflow() + .run_name(format!("autofix PR #{pr_number}")) + .on(Event::default().workflow_dispatch( + WorkflowDispatch::default().add_input(pr_number.name, pr_number.input()), + )) + .add_job(autofix.name, autofix.job) +} + +fn run_autofix(pr_number: &WorkflowInput) -> NamedJob { + fn authenticate_as_zippy() -> (Step, StepOutput) { + let step = named::uses( + "actions", + "create-github-app-token", + "bef1eaf1c0ac2b148ee2a0a74c65fbe6db0631f1", + ) + .add_with(("app-id", vars::ZED_ZIPPY_APP_ID)) + .add_with(("private-key", vars::ZED_ZIPPY_APP_PRIVATE_KEY)) + .id("get-app-token"); + let output = StepOutput::new(&step, "token"); + (step, output) + } + + fn checkout_pr(pr_number: &WorkflowInput, token: &StepOutput) -> Step { + named::bash(&format!("gh pr checkout {pr_number}")).add_env(("GITHUB_TOKEN", token)) + } + + fn run_cargo_fmt() -> Step { + named::bash("cargo fmt --all") + } + + fn run_clippy_fix() -> Step { + named::bash( + "cargo clippy --workspace --release --all-targets --all-features --fix --allow-dirty --allow-staged", + ) + } + + fn commit_and_push(token: &StepOutput) -> Step { + named::bash(indoc::indoc! {r#" + if git diff --quiet; then + echo "No changes to commit" + else + git add -A + git commit -m "Apply cargo fmt and clippy --fix" + git push + fi + "#}) + .add_env(("GIT_COMMITTER_NAME", "Zed Zippy")) + .add_env(("GIT_COMMITTER_EMAIL", "hi@zed.dev")) + .add_env(("GIT_AUTHOR_NAME", "Zed Zippy")) + .add_env(("GIT_AUTHOR_EMAIL", "hi@zed.dev")) + .add_env(("GITHUB_TOKEN", token)) + } + + let (authenticate, token) = authenticate_as_zippy(); + + named::job( + Job::default() + .runs_on(runners::LINUX_SMALL) + .add_step(authenticate) + .add_step(steps::checkout_repo_with_token(&token)) + .add_step(checkout_pr(pr_number, &token)) + .add_step(run_cargo_fmt()) + .add_step(run_clippy_fix()) + .add_step(commit_and_push(&token)), + ) +} diff --git a/tooling/xtask/src/tasks/workflows/steps.rs b/tooling/xtask/src/tasks/workflows/steps.rs index 722a5f0704542889703fdbb42c691d01bc50ace6..7d55df2db433d6e6eae96a5ae62a0c033689d904 100644 --- a/tooling/xtask/src/tasks/workflows/steps.rs +++ b/tooling/xtask/src/tasks/workflows/steps.rs @@ -1,6 +1,6 @@ use gh_workflow::*; -use crate::tasks::workflows::{runners::Platform, vars}; +use crate::tasks::workflows::{runners::Platform, vars, vars::StepOutput}; pub const BASH_SHELL: &str = "bash -euxo pipefail {0}"; // https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idstepsshell @@ -17,6 +17,16 @@ pub fn checkout_repo() -> Step { .add_with(("clean", false)) } +pub fn checkout_repo_with_token(token: &StepOutput) -> Step { + named::uses( + "actions", + "checkout", + "11bd71901bbe5b1630ceea73d27597364c9af683", // v4 + ) + .add_with(("clean", false)) + .add_with(("token", token.to_string())) +} + pub fn setup_pnpm() -> Step { named::uses( "pnpm", From 4096bc55bea787b15c9281945aca5b87ce1acdc5 Mon Sep 17 00:00:00 2001 From: Vitaly Slobodin Date: Mon, 15 Dec 2025 23:48:54 +0100 Subject: [PATCH 333/621] languages: Add injections for string and tagged template literals for JS/TS(X) (#44180) Hi! This pull request adds language injections for string and tagged template literals for JS/TS(X). This is similar to what [this extension](https://marketplace.visualstudio.com/items?itemName=bierner.comment-tagged-templates) provides for VSCode. This PR is inspired by this tweet https://x.com/leaverou/status/1996306611208388953?s=46&t=foDQRPR8oIl1buTJ4kZoSQ I've added injections queries for the following languages: HTML, CSS, GraphQL and SQL. This works for: - String literals: `const cssString = /* css */'button { color: hotpink !important; }';` - Template literals: ```const cssString = /* css */`button { color: hotpink !important; }`;``` All injections support the format with whitespaces inside, i.e. `/* html */` and without them `/*html*/`. ## Screenshots |before|after| |---------|-----------| | CleanShot 2025-12-04 at 21 12
00@2x | CleanShot 2025-12-04 at 21 08
35@2x| Release Notes: - Added language injections for string and tagged template literals in JS/TS(X) --- .../languages/src/javascript/injections.scm | 43 +++++++++++++++++++ crates/languages/src/tsx/injections.scm | 43 +++++++++++++++++++ .../languages/src/typescript/injections.scm | 43 +++++++++++++++++++ 3 files changed, 129 insertions(+) diff --git a/crates/languages/src/javascript/injections.scm b/crates/languages/src/javascript/injections.scm index f79cd788d78964f61f611023d0645c95c88aaf17..244e025a6f5d62f1d3500fc35fc480b1baa2471e 100644 --- a/crates/languages/src/javascript/injections.scm +++ b/crates/languages/src/javascript/injections.scm @@ -83,3 +83,46 @@ arguments: (arguments (template_string (string_fragment) @injection.content (#set! injection.language "isograph"))) ) + +; Parse the contents of strings and tagged template +; literals with leading ECMAScript comments: +; '/* html */' or '/*html*/' +( + ((comment) @_ecma_comment [ + (string (string_fragment) @injection.content) + (template_string (string_fragment) @injection.content) + ]) + (#match? @_ecma_comment "^\\/\\*\\s*html\\s*\\*\\/") + (#set! injection.language "html") +) + +; '/* sql */' or '/*sql*/' +( + ((comment) @_ecma_comment [ + (string (string_fragment) @injection.content) + (template_string (string_fragment) @injection.content) + ]) + (#match? @_ecma_comment "^\\/\\*\\s*sql\\s*\\*\\/") + (#set! injection.language "sql") +) + +; '/* gql */' or '/*gql*/' +; '/* graphql */' or '/*graphql*/' +( + ((comment) @_ecma_comment [ + (string (string_fragment) @injection.content) + (template_string (string_fragment) @injection.content) + ]) + (#match? @_ecma_comment "^\\/\\*\\s*(gql|graphql)\\s*\\*\\/") + (#set! injection.language "graphql") +) + +; '/* css */' or '/*css*/' +( + ((comment) @_ecma_comment [ + (string (string_fragment) @injection.content) + (template_string (string_fragment) @injection.content) + ]) + (#match? @_ecma_comment "^\\/\\*\\s*(css)\\s*\\*\\/") + (#set! injection.language "css") +) diff --git a/crates/languages/src/tsx/injections.scm b/crates/languages/src/tsx/injections.scm index 3cca9e8e81c31d3565554595456fa62be89bc81f..2cf3ea69ca2fd95402eba6fadb85f3505c5562b7 100644 --- a/crates/languages/src/tsx/injections.scm +++ b/crates/languages/src/tsx/injections.scm @@ -83,3 +83,46 @@ arguments: (arguments (template_string (string_fragment) @injection.content (#set! injection.language "isograph"))) ) + +; Parse the contents of strings and tagged template +; literals with leading ECMAScript comments: +; '/* html */' or '/*html*/' +( + ((comment) @_ecma_comment [ + (string (string_fragment) @injection.content) + (template_string (string_fragment) @injection.content) + ]) + (#match? @_ecma_comment "^\\/\\*\\s*html\\s*\\*\\/") + (#set! injection.language "html") +) + +; '/* sql */' or '/*sql*/' +( + ((comment) @_ecma_comment [ + (string (string_fragment) @injection.content) + (template_string (string_fragment) @injection.content) + ]) + (#match? @_ecma_comment "^\\/\\*\\s*sql\\s*\\*\\/") + (#set! injection.language "sql") +) + +; '/* gql */' or '/*gql*/' +; '/* graphql */' or '/*graphql*/' +( + ((comment) @_ecma_comment [ + (string (string_fragment) @injection.content) + (template_string (string_fragment) @injection.content) + ]) + (#match? @_ecma_comment "^\\/\\*\\s*(gql|graphql)\\s*\\*\\/") + (#set! injection.language "graphql") +) + +; '/* css */' or '/*css*/' +( + ((comment) @_ecma_comment [ + (string (string_fragment) @injection.content) + (template_string (string_fragment) @injection.content) + ]) + (#match? @_ecma_comment "^\\/\\*\\s*(css)\\s*\\*\\/") + (#set! injection.language "css") +) diff --git a/crates/languages/src/typescript/injections.scm b/crates/languages/src/typescript/injections.scm index 5321e606c118a41df127c8aa37c7c2811dc8bd23..91880407900e7407e46982a54dbeaa3e30277bdd 100644 --- a/crates/languages/src/typescript/injections.scm +++ b/crates/languages/src/typescript/injections.scm @@ -124,3 +124,46 @@ ] ))) (#set! injection.language "css")) + +; Parse the contents of strings and tagged template +; literals with leading ECMAScript comments: +; '/* html */' or '/*html*/' +( + ((comment) @_ecma_comment [ + (string (string_fragment) @injection.content) + (template_string (string_fragment) @injection.content) + ]) + (#match? @_ecma_comment "^\\/\\*\\s*html\\s*\\*\\/") + (#set! injection.language "html") +) + +; '/* sql */' or '/*sql*/' +( + ((comment) @_ecma_comment [ + (string (string_fragment) @injection.content) + (template_string (string_fragment) @injection.content) + ]) + (#match? @_ecma_comment "^\\/\\*\\s*sql\\s*\\*\\/") + (#set! injection.language "sql") +) + +; '/* gql */' or '/*gql*/' +; '/* graphql */' or '/*graphql*/' +( + ((comment) @_ecma_comment [ + (string (string_fragment) @injection.content) + (template_string (string_fragment) @injection.content) + ]) + (#match? @_ecma_comment "^\\/\\*\\s*(gql|graphql)\\s*\\*\\/") + (#set! injection.language "graphql") +) + +; '/* css */' or '/*css*/' +( + ((comment) @_ecma_comment [ + (string (string_fragment) @injection.content) + (template_string (string_fragment) @injection.content) + ]) + (#match? @_ecma_comment "^\\/\\*\\s*(css)\\s*\\*\\/") + (#set! injection.language "css") +) From b52f907a8edb0e4134b6b1bf125c54748fec001e Mon Sep 17 00:00:00 2001 From: Finn Evers Date: Mon, 15 Dec 2025 23:59:04 +0100 Subject: [PATCH 334/621] extension_ci: Auto-assign version bumps to GitHub actor (#44929) Release Notes: - N/A --- .github/workflows/extension_bump.yml | 1 + tooling/xtask/src/tasks/workflows/extension_bump.rs | 5 +++-- .../src/tasks/workflows/{extensions/mod.rs => extensions.rs} | 0 3 files changed, 4 insertions(+), 2 deletions(-) rename tooling/xtask/src/tasks/workflows/{extensions/mod.rs => extensions.rs} (100%) diff --git a/.github/workflows/extension_bump.yml b/.github/workflows/extension_bump.yml index c7582378f1c9e87254e1a0b4e202d9f56b99877b..31676e5c914719a34f8b2e61193475ed107cd2db 100644 --- a/.github/workflows/extension_bump.yml +++ b/.github/workflows/extension_bump.yml @@ -113,6 +113,7 @@ jobs: delete-branch: true token: ${{ steps.generate-token.outputs.token }} sign-commits: true + assignees: ${{ github.actor }} timeout-minutes: 1 create_version_label: needs: diff --git a/tooling/xtask/src/tasks/workflows/extension_bump.rs b/tooling/xtask/src/tasks/workflows/extension_bump.rs index 34fcf8099031ec9d5562c76f45073a9936c285ff..8772011a2d1f48550095a916ab516cc98ac2d1f7 100644 --- a/tooling/xtask/src/tasks/workflows/extension_bump.rs +++ b/tooling/xtask/src/tasks/workflows/extension_bump.rs @@ -1,4 +1,4 @@ -use gh_workflow::*; +use gh_workflow::{ctx::Context, *}; use indoc::indoc; use crate::tasks::workflows::{ @@ -287,7 +287,8 @@ fn create_pull_request(new_version: StepOutput, generated_token: StepOutput) -> .add("base", "main") .add("delete-branch", true) .add("token", generated_token.to_string()) - .add("sign-commits", true), + .add("sign-commits", true) + .add("assignees", Context::github().actor().to_string()), ) } diff --git a/tooling/xtask/src/tasks/workflows/extensions/mod.rs b/tooling/xtask/src/tasks/workflows/extensions.rs similarity index 100% rename from tooling/xtask/src/tasks/workflows/extensions/mod.rs rename to tooling/xtask/src/tasks/workflows/extensions.rs From 0ead4668d2cbd1f0245cb0ffd1ef0de81644d50c Mon Sep 17 00:00:00 2001 From: Artem Molonosov Date: Mon, 15 Dec 2025 23:59:52 +0100 Subject: [PATCH 335/621] project_panel: Fix divider taking too much horizontal space (#44920) Closes: #44917 While setting up the project for contribution, I noticed that the divider in the welcome dialog was rendering incorrectly on the `main` branch compared to the latest release. **Current behaviour (`main` branch):** image **Expected behaviour (Release `0.216.1`):** image --- After some investigation, it looks like the issue was introduced in #44505, specifically in [these changes](https://github.com/zed-industries/zed/pull/44505/changes#diff-4ea61133da5775f0d5d06e67a8dccc84e671c3d04db5f738f6ebfab3a4df0b01R147-R158), which caused the divider to take the full width instead of being properly constrained. **PR result**: image Release Notes: - Fixes -or- divider rendering incorrectly --- crates/project_panel/src/project_panel.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rs index ea667ecbb479ca347914ee11ec789a14f29cf474..a645ae194b19e5770386ed2eb97de11f9350a866 100644 --- a/crates/project_panel/src/project_panel.rs +++ b/crates/project_panel/src/project_panel.rs @@ -6050,9 +6050,9 @@ impl Render for ProjectPanel { h_flex() .w_1_2() .gap_2() - .child(Divider::horizontal()) + .child(div().flex_1().child(Divider::horizontal())) .child(Label::new("or").size(LabelSize::XSmall).color(Color::Muted)) - .child(Divider::horizontal()), + .child(div().flex_1().child(Divider::horizontal())), ) .child( Button::new("clone_repo", "Clone Repository") From 870159e7e8e633db3ff83725ed0c13e99400dde2 Mon Sep 17 00:00:00 2001 From: Cole Miller Date: Mon, 15 Dec 2025 18:40:39 -0500 Subject: [PATCH 336/621] git: Fix partially-staged paths not being accurately rendered (#44837) Updates #44089 - Restores the ability to have a partially staged/`Indeterminate` status for the git panel checkboxes - Removes the `optimistic_staging` logic, since its stated purpose is served by the `PendingOps` system in the `GitStore` (which may have bugs, but we should fix them in the git store rather than adding another layer) Release Notes: - Fixed partially-staged files not being represented accurately in the git panel. --------- Co-authored-by: Anthony Eid --- crates/git_ui/src/git_panel.rs | 315 +++++++++++++-------------------- 1 file changed, 123 insertions(+), 192 deletions(-) diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs index 0cca777e07cf14d7f5e8537b2b8b8779cbc2ef64..d0618508ddbd153f4dcb1b77e974dc42ed2b0b32 100644 --- a/crates/git_ui/src/git_panel.rs +++ b/crates/git_ui/src/git_panel.rs @@ -319,9 +319,7 @@ impl TreeViewState { &mut self, section: Section, mut entries: Vec, - repo: &Repository, seen_directories: &mut HashSet, - optimistic_staging: &HashMap, ) -> Vec<(GitListEntry, bool)> { if entries.is_empty() { return Vec::new(); @@ -365,14 +363,7 @@ impl TreeViewState { } } - let (flattened, _) = self.flatten_tree( - &root, - section, - 0, - repo, - seen_directories, - optimistic_staging, - ); + let (flattened, _) = self.flatten_tree(&root, section, 0, seen_directories); flattened } @@ -381,9 +372,7 @@ impl TreeViewState { node: &TreeNode, section: Section, depth: usize, - repo: &Repository, seen_directories: &mut HashSet, - optimistic_staging: &HashMap, ) -> (Vec<(GitListEntry, bool)>, Vec) { let mut all_statuses = Vec::new(); let mut flattened = Vec::new(); @@ -393,26 +382,13 @@ impl TreeViewState { let Some(path) = terminal.path.clone().or_else(|| child.path.clone()) else { continue; }; - let (child_flattened, mut child_statuses) = self.flatten_tree( - terminal, - section, - depth + 1, - repo, - seen_directories, - optimistic_staging, - ); + let (child_flattened, mut child_statuses) = + self.flatten_tree(terminal, section, depth + 1, seen_directories); let key = TreeKey { section, path }; let expanded = *self.expanded_dirs.get(&key).unwrap_or(&true); self.expanded_dirs.entry(key.clone()).or_insert(true); seen_directories.insert(key.clone()); - let staged_count = child_statuses - .iter() - .filter(|entry| Self::is_entry_staged(entry, repo, optimistic_staging)) - .count(); - let staged_state = - GitPanel::toggle_state_for_counts(staged_count, child_statuses.len()); - self.directory_descendants .insert(key.clone(), child_statuses.clone()); @@ -421,7 +397,6 @@ impl TreeViewState { key, name, depth, - staged_state, expanded, }), true, @@ -465,23 +440,6 @@ impl TreeViewState { let name = parts.join("/"); (node, SharedString::from(name)) } - - fn is_entry_staged( - entry: &GitStatusEntry, - repo: &Repository, - optimistic_staging: &HashMap, - ) -> bool { - if let Some(optimistic) = optimistic_staging.get(&entry.repo_path) { - return *optimistic; - } - repo.pending_ops_for_path(&entry.repo_path) - .map(|ops| ops.staging() || ops.staged()) - .or_else(|| { - repo.status_for_path(&entry.repo_path) - .and_then(|status| status.status.staging().as_bool()) - }) - .unwrap_or(entry.staging.has_staged()) - } } #[derive(Debug, PartialEq, Eq, Clone)] @@ -501,7 +459,7 @@ struct GitTreeDirEntry { key: TreeKey, name: SharedString, depth: usize, - staged_state: ToggleState, + // staged_state: ToggleState, expanded: bool, } @@ -638,7 +596,6 @@ pub struct GitPanel { local_committer_task: Option>, bulk_staging: Option, stash_entries: GitStash, - optimistic_staging: HashMap, _settings_subscription: Subscription, } @@ -808,7 +765,6 @@ impl GitPanel { entry_count: 0, bulk_staging: None, stash_entries: Default::default(), - optimistic_staging: HashMap::default(), _settings_subscription, }; @@ -1555,7 +1511,7 @@ impl GitPanel { .detach(); } - fn is_entry_staged(&self, entry: &GitStatusEntry, repo: &Repository) -> bool { + fn stage_status_for_entry(entry: &GitStatusEntry, repo: &Repository) -> StageStatus { // Checking for current staged/unstaged file status is a chained operation: // 1. first, we check for any pending operation recorded in repository // 2. if there are no pending ops either running or finished, we then ask the repository @@ -1564,25 +1520,59 @@ impl GitPanel { // the checkbox's state (or flickering) which is undesirable. // 3. finally, if there is no info about this `entry` in the repo, we fall back to whatever status is encoded // in `entry` arg. - if let Some(optimistic) = self.optimistic_staging.get(&entry.repo_path) { - return *optimistic; - } repo.pending_ops_for_path(&entry.repo_path) - .map(|ops| ops.staging() || ops.staged()) + .map(|ops| { + if ops.staging() || ops.staged() { + StageStatus::Staged + } else { + StageStatus::Unstaged + } + }) .or_else(|| { repo.status_for_path(&entry.repo_path) - .and_then(|status| status.status.staging().as_bool()) + .map(|status| status.status.staging()) }) - .unwrap_or(entry.staging.has_staged()) + .unwrap_or(entry.staging) } - fn toggle_state_for_counts(staged_count: usize, total: usize) -> ToggleState { - if staged_count == 0 || total == 0 { - ToggleState::Unselected - } else if staged_count == total { - ToggleState::Selected + fn stage_status_for_directory( + &self, + entry: &GitTreeDirEntry, + repo: &Repository, + ) -> StageStatus { + let GitPanelViewMode::Tree(tree_state) = &self.view_mode else { + util::debug_panic!("We should never render a directory entry while in flat view mode"); + return StageStatus::Unstaged; + }; + + let Some(descendants) = tree_state.directory_descendants.get(&entry.key) else { + return StageStatus::Unstaged; + }; + + let mut fully_staged_count = 0usize; + let mut any_staged_or_partially_staged = false; + + for descendant in descendants { + match GitPanel::stage_status_for_entry(descendant, repo) { + StageStatus::Staged => { + fully_staged_count += 1; + any_staged_or_partially_staged = true; + } + StageStatus::PartiallyStaged => { + any_staged_or_partially_staged = true; + } + StageStatus::Unstaged => {} + } + } + + if descendants.is_empty() { + StageStatus::Unstaged + } else if fully_staged_count == descendants.len() { + StageStatus::Staged + } else if any_staged_or_partially_staged { + StageStatus::PartiallyStaged } else { - ToggleState::Indeterminate + StageStatus::Unstaged } } @@ -1611,31 +1601,37 @@ impl GitPanel { match entry { GitListEntry::Status(status_entry) => { let repo_paths = vec![status_entry.clone()]; - let stage = if self.is_entry_staged(status_entry, &repo) { - if let Some(op) = self.bulk_staging.clone() - && op.anchor == status_entry.repo_path - { - clear_anchor = Some(op.anchor); + let stage = match GitPanel::stage_status_for_entry(status_entry, &repo) { + StageStatus::Staged => { + if let Some(op) = self.bulk_staging.clone() + && op.anchor == status_entry.repo_path + { + clear_anchor = Some(op.anchor); + } + false + } + StageStatus::Unstaged | StageStatus::PartiallyStaged => { + set_anchor = Some(status_entry.repo_path.clone()); + true } - false - } else { - set_anchor = Some(status_entry.repo_path.clone()); - true }; (stage, repo_paths) } GitListEntry::TreeStatus(status_entry) => { let repo_paths = vec![status_entry.entry.clone()]; - let stage = if self.is_entry_staged(&status_entry.entry, &repo) { - if let Some(op) = self.bulk_staging.clone() - && op.anchor == status_entry.entry.repo_path - { - clear_anchor = Some(op.anchor); + let stage = match GitPanel::stage_status_for_entry(&status_entry.entry, &repo) { + StageStatus::Staged => { + if let Some(op) = self.bulk_staging.clone() + && op.anchor == status_entry.entry.repo_path + { + clear_anchor = Some(op.anchor); + } + false + } + StageStatus::Unstaged | StageStatus::PartiallyStaged => { + set_anchor = Some(status_entry.entry.repo_path.clone()); + true } - false - } else { - set_anchor = Some(status_entry.entry.repo_path.clone()); - true }; (stage, repo_paths) } @@ -1647,7 +1643,8 @@ impl GitPanel { .filter_map(|entry| entry.status_entry()) .filter(|status_entry| { section.contains(status_entry, &repo) - && status_entry.staging.as_bool() != Some(goal_staged_state) + && GitPanel::stage_status_for_entry(status_entry, &repo).as_bool() + != Some(goal_staged_state) }) .cloned() .collect::>(); @@ -1655,7 +1652,12 @@ impl GitPanel { (goal_staged_state, entries) } GitListEntry::Directory(entry) => { - let goal_staged_state = entry.staged_state != ToggleState::Selected; + let goal_staged_state = match self.stage_status_for_directory(entry, repo) { + StageStatus::Staged => StageStatus::Unstaged, + StageStatus::Unstaged | StageStatus::PartiallyStaged => StageStatus::Staged, + }; + let goal_stage = goal_staged_state == StageStatus::Staged; + let entries = self .view_mode .tree_state() @@ -1664,10 +1666,11 @@ impl GitPanel { .unwrap_or_default() .into_iter() .filter(|status_entry| { - self.is_entry_staged(status_entry, &repo) != goal_staged_state + GitPanel::stage_status_for_entry(status_entry, &repo) + != goal_staged_state }) .collect::>(); - (goal_staged_state, entries) + (goal_stage, entries) } } }; @@ -1682,10 +1685,6 @@ impl GitPanel { self.set_bulk_staging_anchor(anchor, cx); } - let repo = active_repository.read(cx); - self.apply_optimistic_stage(&repo_paths, stage, &repo); - cx.notify(); - self.change_file_stage(stage, repo_paths, cx); } @@ -1730,81 +1729,6 @@ impl GitPanel { .detach(); } - fn apply_optimistic_stage( - &mut self, - entries: &[GitStatusEntry], - stage: bool, - repo: &Repository, - ) { - // This “optimistic” pass keeps all checkboxes—files, folders, and section headers—visually in sync the moment you click, - // even though `change_file_stage` is still talking to the repository in the background. - // Before, the UI would wait for Git, causing checkbox flicker or stale parent states; - // Now, users see instant feedback and accurate parent/child tri-states while the async staging operation completes. - // - // Description: - // It records the desired state in `self.optimistic_staging` (a map from path → bool), - // walks the rendered entries, and swaps their `staging` flags based on that map. - // In tree view it also recomputes every directory’s tri-state checkbox using the updated child data, - // so parent folders flip between selected/indeterminate/empty in the same frame. - let new_stage = if stage { - StageStatus::Staged - } else { - StageStatus::Unstaged - }; - - self.optimistic_staging - .extend(entries.iter().map(|entry| (entry.repo_path.clone(), stage))); - - let staged_states: HashMap = self - .view_mode - .tree_state() - .map(|state| state.directory_descendants.iter()) - .into_iter() - .flatten() - .map(|(key, descendants)| { - let staged_count = descendants - .iter() - .filter(|entry| self.is_entry_staged(entry, repo)) - .count(); - ( - key.clone(), - Self::toggle_state_for_counts(staged_count, descendants.len()), - ) - }) - .collect(); - - for list_entry in &mut self.entries { - match list_entry { - GitListEntry::Status(status) => { - if self - .optimistic_staging - .get(&status.repo_path) - .is_some_and(|s| *s == stage) - { - status.staging = new_stage; - } - } - GitListEntry::TreeStatus(status) => { - if self - .optimistic_staging - .get(&status.entry.repo_path) - .is_some_and(|s| *s == stage) - { - status.entry.staging = new_stage; - } - } - GitListEntry::Directory(dir) => { - if let Some(state) = staged_states.get(&dir.key) { - dir.staged_state = *state; - } - } - _ => {} - } - } - - self.update_counts(repo); - } - pub fn total_staged_count(&self) -> usize { self.tracked_staged_count + self.new_staged_count + self.conflicted_staged_count } @@ -3394,13 +3318,9 @@ impl GitPanel { Some(&mut tree_state.logical_indices), ); - for (entry, is_visible) in tree_state.build_tree_entries( - section, - entries, - &repo, - &mut seen_directories, - &self.optimistic_staging, - ) { + for (entry, is_visible) in + tree_state.build_tree_entries(section, entries, &mut seen_directories) + { push_entry( self, entry, @@ -3440,13 +3360,6 @@ impl GitPanel { self.max_width_item_index = max_width_item_index; self.update_counts(repo); - let visible_paths: HashSet = self - .entries - .iter() - .filter_map(|entry| entry.status_entry().map(|e| e.repo_path.clone())) - .collect(); - self.optimistic_staging - .retain(|path, _| visible_paths.contains(path)); let bulk_staging_anchor_new_index = bulk_staging .as_ref() @@ -3456,7 +3369,9 @@ impl GitPanel { && let Some(index) = bulk_staging_anchor_new_index && let Some(entry) = self.entries.get(index) && let Some(entry) = entry.status_entry() - && self.is_entry_staged(entry, &repo) + && GitPanel::stage_status_for_entry(entry, &repo) + .as_bool() + .unwrap_or(false) { self.bulk_staging = bulk_staging; } @@ -3500,7 +3415,9 @@ impl GitPanel { for status_entry in self.entries.iter().filter_map(|entry| entry.status_entry()) { self.entry_count += 1; - let is_staging_or_staged = self.is_entry_staged(status_entry, repo); + let is_staging_or_staged = GitPanel::stage_status_for_entry(status_entry, repo) + .as_bool() + .unwrap_or(false); if repo.had_conflict_on_last_merge_head_change(&status_entry.repo_path) { self.conflicted_count += 1; @@ -4737,8 +4654,12 @@ impl GitPanel { .active_repository(cx) .expect("active repository must be set"); let repo = active_repo.read(cx); - let is_staging_or_staged = self.is_entry_staged(entry, &repo); - let mut is_staged: ToggleState = is_staging_or_staged.into(); + let stage_status = GitPanel::stage_status_for_entry(entry, &repo); + let mut is_staged: ToggleState = match stage_status { + StageStatus::Staged => ToggleState::Selected, + StageStatus::Unstaged => ToggleState::Unselected, + StageStatus::PartiallyStaged => ToggleState::Indeterminate, + }; if self.show_placeholders && !self.has_staged_changes() && !entry.status.is_created() { is_staged = ToggleState::Selected; } @@ -4895,12 +4816,9 @@ impl GitPanel { } }) .tooltip(move |_window, cx| { - // If is_staging_or_staged is None, this implies the file was partially staged, and so - // we allow the user to stage it in full by displaying `Stage` in the tooltip. - let action = if is_staging_or_staged { - "Unstage" - } else { - "Stage" + let action = match stage_status { + StageStatus::Staged => "Unstage", + StageStatus::Unstaged | StageStatus::PartiallyStaged => "Stage", }; let tooltip_name = action.to_string(); @@ -4960,7 +4878,21 @@ impl GitPanel { } else { IconName::Folder }; - let staged_state = entry.staged_state; + + let stage_status = if let Some(repo) = &self.active_repository { + self.stage_status_for_directory(entry, repo.read(cx)) + } else { + util::debug_panic!( + "Won't have entries to render without an active repository in Git Panel" + ); + StageStatus::PartiallyStaged + }; + + let toggle_state: ToggleState = match stage_status { + StageStatus::Staged => ToggleState::Selected, + StageStatus::Unstaged => ToggleState::Unselected, + StageStatus::PartiallyStaged => ToggleState::Indeterminate, + }; let name_row = h_flex() .items_center() @@ -5006,7 +4938,7 @@ impl GitPanel { .occlude() .cursor_pointer() .child( - Checkbox::new(checkbox_id, staged_state) + Checkbox::new(checkbox_id, toggle_state) .disabled(!has_write_access) .fill() .elevation(ElevationIndex::Surface) @@ -5029,10 +4961,9 @@ impl GitPanel { } }) .tooltip(move |_window, cx| { - let action = if staged_state.selected() { - "Unstage" - } else { - "Stage" + let action = match stage_status { + StageStatus::Staged => "Unstage", + StageStatus::Unstaged | StageStatus::PartiallyStaged => "Stage", }; Tooltip::simple(format!("{action} folder"), cx) }), From b8d0da97fa96025d4139ecfca8605cce72cca723 Mon Sep 17 00:00:00 2001 From: Finn Evers Date: Tue, 16 Dec 2025 00:46:09 +0100 Subject: [PATCH 337/621] collab: Add `copilot-swe-agent[bot]` to the `GET /contributor` endpoint (#44934) This PR adds the `copilot-swe-agent[bot]` user to the `GET /contributor` endpoint so that it passes the CLA check. Release Notes: - N/A --- crates/collab/src/api/contributors.rs | 40 +++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/crates/collab/src/api/contributors.rs b/crates/collab/src/api/contributors.rs index 549a9346b57c0a9801fe791826e9346e3f0350df..e09ac4f8b7355cf143b221308204742139308133 100644 --- a/crates/collab/src/api/contributors.rs +++ b/crates/collab/src/api/contributors.rs @@ -54,6 +54,16 @@ async fn check_is_contributor( ) -> Result> { let params = params.into_contributor_selector()?; + if CopilotSweAgentBot::is_copilot_bot(¶ms) { + return Ok(Json(CheckIsContributorResponse { + signed_at: Some( + CopilotSweAgentBot::created_at() + .and_utc() + .to_rfc3339_opts(SecondsFormat::Millis, true), + ), + })); + } + if Dependabot::is_dependabot(¶ms) { return Ok(Json(CheckIsContributorResponse { signed_at: Some( @@ -93,6 +103,36 @@ async fn check_is_contributor( })) } +/// The Copilot bot GitHub user (`copilot-swe-agent[bot]`). +/// +/// https://api.github.com/users/copilot-swe-agent[bot] +struct CopilotSweAgentBot; + +impl CopilotSweAgentBot { + const LOGIN: &'static str = "copilot-swe-agent[bot]"; + const USER_ID: i32 = 198982749; + + /// Returns the `created_at` timestamp for the Dependabot bot user. + fn created_at() -> &'static NaiveDateTime { + static CREATED_AT: OnceLock = OnceLock::new(); + CREATED_AT.get_or_init(|| { + chrono::DateTime::parse_from_rfc3339("2025-02-12T20:26:08Z") + .expect("failed to parse 'created_at' for 'copilot-swe-agent[bot]'") + .naive_utc() + }) + } + + /// Returns whether the given contributor selector corresponds to the Copilot bot user. + fn is_copilot_bot(contributor: &ContributorSelector) -> bool { + match contributor { + ContributorSelector::GitHubLogin { github_login } => github_login == Self::LOGIN, + ContributorSelector::GitHubUserId { github_user_id } => { + github_user_id == &Self::USER_ID + } + } + } +} + /// The Dependabot bot GitHub user (`dependabot[bot]`). /// /// https://api.github.com/users/dependabot[bot] From 7a4de734c6cccf6d60fd937141305b5fb1a9b55f Mon Sep 17 00:00:00 2001 From: Cole Miller Date: Mon, 15 Dec 2025 18:50:18 -0500 Subject: [PATCH 338/621] git: Ensure no more than 4 blame processes run concurrently for each multibuffer (#44843) Previously we were only awaiting on up to 4 of the blame futures at a time, but we would still call `Project::blame_buffer` eagerly for every buffer in the multibuffer. Since that returns a `Task`, all the blame invocations were still launched concurrently. Release Notes: - N/A --- crates/editor/src/git/blame.rs | 164 ++++++++++++++++++--------------- 1 file changed, 91 insertions(+), 73 deletions(-) diff --git a/crates/editor/src/git/blame.rs b/crates/editor/src/git/blame.rs index 67df69aadab43a45c2941703e10bb81af2b8dd78..031795ff2dbfceb96f950db18101b37fd3cdcf84 100644 --- a/crates/editor/src/git/blame.rs +++ b/crates/editor/src/git/blame.rs @@ -1,7 +1,7 @@ use crate::Editor; -use anyhow::Result; +use anyhow::{Context as _, Result}; use collections::HashMap; -use futures::StreamExt; + use git::{ GitHostingProviderRegistry, GitRemote, Oid, blame::{Blame, BlameEntry, ParsedCommitMessage}, @@ -494,84 +494,102 @@ impl GitBlame { self.changed_while_blurred = true; return; } - let blame = self.project.update(cx, |project, cx| { - let Some(multi_buffer) = self.multi_buffer.upgrade() else { - return Vec::new(); - }; - multi_buffer - .read(cx) - .all_buffer_ids() - .into_iter() - .filter_map(|id| { - let buffer = multi_buffer.read(cx).buffer(id)?; - let snapshot = buffer.read(cx).snapshot(); - let buffer_edits = buffer.update(cx, |buffer, _| buffer.subscribe()); - - let blame_buffer = project.blame_buffer(&buffer, None, cx); - let remote_url = project - .git_store() - .read(cx) - .repository_and_path_for_buffer_id(buffer.read(cx).remote_id(), cx) - .and_then(|(repo, _)| { - repo.read(cx) - .remote_upstream_url - .clone() - .or(repo.read(cx).remote_origin_url.clone()) - }); - Some( - async move { (id, snapshot, buffer_edits, blame_buffer.await, remote_url) }, - ) - }) - .collect::>() - }); - let provider_registry = GitHostingProviderRegistry::default_global(cx); + let buffers_to_blame = self + .multi_buffer + .update(cx, |multi_buffer, _| { + multi_buffer + .all_buffer_ids() + .into_iter() + .filter_map(|id| Some(multi_buffer.buffer(id)?.downgrade())) + .collect::>() + }) + .unwrap_or_default(); + let project = self.project.downgrade(); self.task = cx.spawn(async move |this, cx| { - let (result, errors) = cx - .background_spawn({ - async move { - let blame = futures::stream::iter(blame) - .buffered(4) - .collect::>() - .await; - let mut res = vec![]; - let mut errors = vec![]; - for (id, snapshot, buffer_edits, blame, remote_url) in blame { - match blame { - Ok(Some(Blame { entries, messages })) => { - let entries = build_blame_entry_sum_tree( - entries, - snapshot.max_point().row, - ); - let commit_details = parse_commit_messages( - messages, - remote_url, - provider_registry.clone(), - ) - .await; - - res.push(( + let mut all_results = Vec::new(); + let mut all_errors = Vec::new(); + + for buffers in buffers_to_blame.chunks(4) { + let blame = cx.update(|cx| { + buffers + .iter() + .map(|buffer| { + let buffer = buffer.upgrade().context("buffer was dropped")?; + let project = project.upgrade().context("project was dropped")?; + let id = buffer.read(cx).remote_id(); + let snapshot = buffer.read(cx).snapshot(); + let buffer_edits = buffer.update(cx, |buffer, _| buffer.subscribe()); + let remote_url = project + .read(cx) + .git_store() + .read(cx) + .repository_and_path_for_buffer_id(buffer.read(cx).remote_id(), cx) + .and_then(|(repo, _)| { + repo.read(cx) + .remote_upstream_url + .clone() + .or(repo.read(cx).remote_origin_url.clone()) + }); + let blame_buffer = project + .update(cx, |project, cx| project.blame_buffer(&buffer, None, cx)); + Ok(async move { + (id, snapshot, buffer_edits, blame_buffer.await, remote_url) + }) + }) + .collect::>>() + })??; + let provider_registry = + cx.update(|cx| GitHostingProviderRegistry::default_global(cx))?; + let (results, errors) = cx + .background_spawn({ + async move { + let blame = futures::future::join_all(blame).await; + let mut res = vec![]; + let mut errors = vec![]; + for (id, snapshot, buffer_edits, blame, remote_url) in blame { + match blame { + Ok(Some(Blame { entries, messages })) => { + let entries = build_blame_entry_sum_tree( + entries, + snapshot.max_point().row, + ); + let commit_details = parse_commit_messages( + messages, + remote_url, + provider_registry.clone(), + ) + .await; + + res.push(( + id, + snapshot, + buffer_edits, + Some(entries), + commit_details, + )); + } + Ok(None) => res.push(( id, snapshot, buffer_edits, - Some(entries), - commit_details, - )); - } - Ok(None) => { - res.push((id, snapshot, buffer_edits, None, Default::default())) + None, + Default::default(), + )), + Err(e) => errors.push(e), } - Err(e) => errors.push(e), } + (res, errors) } - (res, errors) - } - }) - .await; + }) + .await; + all_results.extend(results); + all_errors.extend(errors) + } this.update(cx, |this, cx| { this.buffers.clear(); - for (id, snapshot, buffer_edits, entries, commit_details) in result { + for (id, snapshot, buffer_edits, entries, commit_details) in all_results { let Some(entries) = entries else { continue; }; @@ -586,11 +604,11 @@ impl GitBlame { ); } cx.notify(); - if !errors.is_empty() { + if !all_errors.is_empty() { this.project.update(cx, |_, cx| { if this.user_triggered { - log::error!("failed to get git blame data: {errors:?}"); - let notification = errors + log::error!("failed to get git blame data: {all_errors:?}"); + let notification = all_errors .into_iter() .format_with(",", |e, f| f(&format_args!("{:#}", e))) .to_string(); @@ -601,7 +619,7 @@ impl GitBlame { } else { // If we weren't triggered by a user, we just log errors in the background, instead of sending // notifications. - log::debug!("failed to get git blame data: {errors:?}"); + log::debug!("failed to get git blame data: {all_errors:?}"); } }) } From f8561b4cb95165644f9736e0b107e267170105fd Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 15 Dec 2025 15:50:45 -0800 Subject: [PATCH 339/621] Anchor scroll offsets so that entire diff hunks at viewport top become visible (#44932) Fixes https://github.com/zed-industries/zed/issues/39258 Release Notes: - N/A --- crates/editor/src/editor_tests.rs | 34 +++++++++++++++++++++++++++++++ crates/editor/src/scroll.rs | 6 +++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rs index a020b977c779a9b59a442170f7cc24f87ff54e2b..dfc8fd7f901bf1f45352511e3b7e69f7f4d4b367 100644 --- a/crates/editor/src/editor_tests.rs +++ b/crates/editor/src/editor_tests.rs @@ -22233,6 +22233,40 @@ async fn test_toggle_deletion_hunk_at_start_of_file( cx.assert_state_with_diff(hunk_expanded); } +#[gpui::test] +async fn test_expand_first_line_diff_hunk_keeps_deleted_lines_visible( + executor: BackgroundExecutor, + cx: &mut TestAppContext, +) { + init_test(cx, |_| {}); + let mut cx = EditorTestContext::new(cx).await; + + cx.set_state("ˇnew\nsecond\nthird\n"); + cx.set_head_text("old\nsecond\nthird\n"); + cx.update_editor(|editor, window, cx| { + editor.scroll(gpui::Point { x: 0., y: 0. }, None, window, cx); + }); + executor.run_until_parked(); + assert_eq!(cx.update_editor(|e, _, cx| e.scroll_position(cx)).y, 0.0); + + // Expanding a diff hunk at the first line inserts deleted lines above the first buffer line. + cx.update_editor(|editor, window, cx| { + let snapshot = editor.snapshot(window, cx); + let excerpt_id = editor.buffer.read(cx).excerpt_ids()[0]; + let hunks = editor + .diff_hunks_in_ranges(&[Anchor::min()..Anchor::max()], &snapshot.buffer_snapshot()) + .collect::>(); + assert_eq!(hunks.len(), 1); + let hunk_range = Anchor::range_in_buffer(excerpt_id, hunks[0].buffer_range.clone()); + editor.toggle_single_diff_hunk(hunk_range, cx) + }); + executor.run_until_parked(); + cx.assert_state_with_diff("- old\n+ ˇnew\n second\n third\n".to_string()); + + // Keep the editor scrolled to the top so the full hunk remains visible. + assert_eq!(cx.update_editor(|e, _, cx| e.scroll_position(cx)).y, 0.0); +} + #[gpui::test] async fn test_display_diff_hunks(cx: &mut TestAppContext) { init_test(cx, |_| {}); diff --git a/crates/editor/src/scroll.rs b/crates/editor/src/scroll.rs index a92735d18617057ddd10f049e5a22525827e1874..422be9a54e7cfcc40484e4093eeab6c94ce7d8ee 100644 --- a/crates/editor/src/scroll.rs +++ b/crates/editor/src/scroll.rs @@ -251,7 +251,11 @@ impl ScrollManager { Bias::Left, ) .to_point(map); - let top_anchor = map.buffer_snapshot().anchor_after(scroll_top_buffer_point); + // Anchor the scroll position to the *left* of the first visible buffer point. + // + // This prevents the viewport from shifting down when blocks (e.g. expanded diff hunk + // deletions) are inserted *above* the first buffer character in the file. + let top_anchor = map.buffer_snapshot().anchor_before(scroll_top_buffer_point); self.set_anchor( ScrollAnchor { From a60e0a178fb7976700dd9775e6465fcc564b33dc Mon Sep 17 00:00:00 2001 From: Johnny Klucinec <72411904+johnklucinec@users.noreply.github.com> Date: Mon, 15 Dec 2025 20:01:20 -0500 Subject: [PATCH 340/621] Improve keymap error formatting and add settings button icon (#42037) Closes https://github.com/zed-industries/zed/issues/41938 For some error messages relating to the keymap file, the font size was too large. This was due to the error message being a child `MarkdownString` instead of a `SharedString`. A `.text_xs()` method is being applied to this notification, but it appears not to affect the markdown text. I found that the H5 text size in markdown is the same size as other error messages, so I made each element (that had text) that size. There was also a special case for bullet points. I also added a gear icon to the settings button, so it was more in line with other app notifications. Error message (text too large): ![keymap-broke](https://github.com/user-attachments/assets/2c205a3a-ae28-419f-95c4-093340760d03) Expected behavior (notification with correct text sizing and icon): ![keymap-fixed](https://github.com/user-attachments/assets/f8a1396b-177f-4287-b390-c3804b70f1d2) Example behavior: ![settings](https://github.com/user-attachments/assets/09397954-781f-44be-88ad-08035fe66f0c) Release Notes: - Improved UI for keymap error messages. --------- Co-authored-by: Danilo Leal --- crates/settings/src/keymap_file.rs | 8 +++++--- crates/zed/src/zed.rs | 19 +++++++++++-------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/crates/settings/src/keymap_file.rs b/crates/settings/src/keymap_file.rs index 2ef1dfc5385592b9757eff5ec631af818ae1869c..146fc371b14cb5cba428d3a7beec11cc3008e7dd 100644 --- a/crates/settings/src/keymap_file.rs +++ b/crates/settings/src/keymap_file.rs @@ -303,19 +303,21 @@ impl KeymapFile { if errors.is_empty() { KeymapFileLoadResult::Success { key_bindings } } else { - let mut error_message = "Errors in user keymap file.\n".to_owned(); + let mut error_message = "Errors in user keymap file.".to_owned(); + for (context, section_errors) in errors { if context.is_empty() { - let _ = write!(error_message, "\n\nIn section without context predicate:"); + let _ = write!(error_message, "\nIn section without context predicate:"); } else { let _ = write!( error_message, - "\n\nIn section with {}:", + "\nIn section with {}:", MarkdownInlineCode(&format!("context = \"{}\"", context)) ); } let _ = write!(error_message, "{section_errors}"); } + KeymapFileLoadResult::SomeFailedToLoad { key_bindings, error_message: MarkdownString(error_message), diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs index ed22d7ef510e367b71b2a1057513471a4e32306a..a51e38bfe48976c8bf12ae1d546f8a8421288af2 100644 --- a/crates/zed/src/zed.rs +++ b/crates/zed/src/zed.rs @@ -32,8 +32,8 @@ use git_ui::project_diff::ProjectDiffToolbar; use gpui::{ Action, App, AppContext as _, AsyncWindowContext, Context, DismissEvent, Element, Entity, Focusable, KeyBinding, ParentElement, PathPromptOptions, PromptLevel, ReadGlobal, SharedString, - Styled, Task, TitlebarOptions, UpdateGlobal, WeakEntity, Window, WindowKind, WindowOptions, - actions, image_cache, point, px, retain_all, + Task, TitlebarOptions, UpdateGlobal, WeakEntity, Window, WindowKind, WindowOptions, actions, + image_cache, point, px, retain_all, }; use image_viewer::ImageInfo; use language::Capability; @@ -1690,6 +1690,7 @@ fn show_keymap_file_json_error( cx.new(|cx| { MessageNotification::new(message.clone(), cx) .primary_message("Open Keymap File") + .primary_icon(IconName::Settings) .primary_on_click(|window, cx| { window.dispatch_action(zed_actions::OpenKeymapFile.boxed_clone(), cx); cx.emit(DismissEvent); @@ -1748,16 +1749,18 @@ fn show_markdown_app_notification( cx.new(move |cx| { MessageNotification::new_from_builder(cx, move |window, cx| { image_cache(retain_all("notification-cache")) - .text_xs() - .child(markdown_preview::markdown_renderer::render_parsed_markdown( - &parsed_markdown.clone(), - Some(workspace_handle.clone()), - window, - cx, + .child(div().text_ui(cx).child( + markdown_preview::markdown_renderer::render_parsed_markdown( + &parsed_markdown.clone(), + Some(workspace_handle.clone()), + window, + cx, + ), )) .into_any() }) .primary_message(primary_button_message) + .primary_icon(IconName::Settings) .primary_on_click_arc(primary_button_on_click) }) }) From 3b2ccaff6f05a2f6762d41dca48bc63f6cc47c25 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 15 Dec 2025 17:22:41 -0800 Subject: [PATCH 341/621] Make zed --wait work with directories (#44936) Fixes #23347 Release Notes: - Implemented the `zed --wait` flag so that it works when opening a directory. The command will block until the window is closed. --- crates/cli/src/main.rs | 2 + crates/zed/src/zed/open_listener.rs | 233 ++++++++++++++++++---------- 2 files changed, 151 insertions(+), 84 deletions(-) diff --git a/crates/cli/src/main.rs b/crates/cli/src/main.rs index 92c0ce2377b8c200b2367148226f3bd3b81f0008..e1a7a1481b56633364cb011f46cd55e616244f2c 100644 --- a/crates/cli/src/main.rs +++ b/crates/cli/src/main.rs @@ -61,6 +61,8 @@ Examples: )] struct Args { /// Wait for all of the given paths to be opened/closed before exiting. + /// + /// When opening a directory, waits until the created window is closed. #[arg(short, long)] wait: bool, /// Add files to the currently open workspace diff --git a/crates/zed/src/zed/open_listener.rs b/crates/zed/src/zed/open_listener.rs index e398ad6df7cde55de529e94b62d4aac173741351..3bf6bffda6c7cbbb3a6b0d0c8661acc432b71335 100644 --- a/crates/zed/src/zed/open_listener.rs +++ b/crates/zed/src/zed/open_listener.rs @@ -10,6 +10,7 @@ use editor::Editor; use fs::Fs; use futures::channel::mpsc::{UnboundedReceiver, UnboundedSender}; use futures::channel::{mpsc, oneshot}; +use futures::future; use futures::future::join_all; use futures::{FutureExt, SinkExt, StreamExt}; use git_ui::file_diff_view::FileDiffView; @@ -514,33 +515,27 @@ async fn open_local_workspace( app_state: &Arc, cx: &mut AsyncApp, ) -> bool { - let mut errored = false; - let paths_with_position = derive_paths_with_position(app_state.fs.as_ref(), workspace_paths).await; - // Handle reuse flag by finding existing window to replace - let replace_window = if reuse { - cx.update(|cx| workspace::local_workspace_windows(cx).into_iter().next()) - .ok() - .flatten() - } else { - None - }; - - // For reuse, force new workspace creation but with replace_window set - let effective_open_new_workspace = if reuse { - Some(true) + // If reuse flag is passed, open a new workspace in an existing window. + let (open_new_workspace, replace_window) = if reuse { + ( + Some(true), + cx.update(|cx| workspace::local_workspace_windows(cx).into_iter().next()) + .ok() + .flatten(), + ) } else { - open_new_workspace + (open_new_workspace, None) }; - match open_paths_with_positions( + let (workspace, items) = match open_paths_with_positions( &paths_with_position, &diff_paths, app_state.clone(), workspace::OpenOptions { - open_new_workspace: effective_open_new_workspace, + open_new_workspace, replace_window, prefer_focused_window: wait, env: env.cloned(), @@ -550,80 +545,95 @@ async fn open_local_workspace( ) .await { - Ok((workspace, items)) => { - let mut item_release_futures = Vec::new(); + Ok(result) => result, + Err(error) => { + responses + .send(CliResponse::Stderr { + message: format!("error opening {paths_with_position:?}: {error}"), + }) + .log_err(); + return true; + } + }; - for item in items { - match item { - Some(Ok(item)) => { - cx.update(|cx| { - let released = oneshot::channel(); - item.on_release( - cx, - Box::new(move |_| { - let _ = released.0.send(()); - }), - ) - .detach(); - item_release_futures.push(released.1); - }) - .log_err(); - } - Some(Err(err)) => { - responses - .send(CliResponse::Stderr { - message: err.to_string(), - }) - .log_err(); - errored = true; - } - None => {} - } + let mut errored = false; + let mut item_release_futures = Vec::new(); + let mut subscriptions = Vec::new(); + + // If --wait flag is used with no paths, or a directory, then wait until + // the entire workspace is closed. + if wait { + let mut wait_for_window_close = paths_with_position.is_empty() && diff_paths.is_empty(); + for path_with_position in &paths_with_position { + if app_state.fs.is_dir(&path_with_position.path).await { + wait_for_window_close = true; + break; } + } + + if wait_for_window_close { + let (release_tx, release_rx) = oneshot::channel(); + item_release_futures.push(release_rx); + subscriptions.push(workspace.update(cx, |_, _, cx| { + cx.on_release(move |_, _| { + let _ = release_tx.send(()); + }) + })); + } + } - if wait { - let background = cx.background_executor().clone(); - let wait = async move { - if paths_with_position.is_empty() && diff_paths.is_empty() { - let (done_tx, done_rx) = oneshot::channel(); - let _subscription = workspace.update(cx, |_, _, cx| { - cx.on_release(move |_, _| { - let _ = done_tx.send(()); - }) - }); - let _ = done_rx.await; - } else { - let _ = futures::future::try_join_all(item_release_futures).await; - }; + for item in items { + match item { + Some(Ok(item)) => { + if wait { + let (release_tx, release_rx) = oneshot::channel(); + item_release_futures.push(release_rx); + subscriptions.push(cx.update(|cx| { + item.on_release( + cx, + Box::new(move |_| { + release_tx.send(()).ok(); + }), + ) + })); } - .fuse(); - - futures::pin_mut!(wait); - - loop { - // Repeatedly check if CLI is still open to avoid wasting resources - // waiting for files or workspaces to close. - let mut timer = background.timer(Duration::from_secs(1)).fuse(); - futures::select_biased! { - _ = wait => break, - _ = timer => { - if responses.send(CliResponse::Ping).is_err() { - break; - } - } + } + Some(Err(err)) => { + responses + .send(CliResponse::Stderr { + message: err.to_string(), + }) + .log_err(); + errored = true; + } + None => {} + } + } + + if wait { + let wait = async move { + let _subscriptions = subscriptions; + let _ = future::try_join_all(item_release_futures).await; + } + .fuse(); + futures::pin_mut!(wait); + + let background = cx.background_executor().clone(); + loop { + // Repeatedly check if CLI is still open to avoid wasting resources + // waiting for files or workspaces to close. + let mut timer = background.timer(Duration::from_secs(1)).fuse(); + futures::select_biased! { + _ = wait => break, + _ = timer => { + if responses.send(CliResponse::Ping).is_err() { + break; } } } } - Err(error) => { - errored = true; - responses - .send(CliResponse::Stderr { - message: format!("error opening {paths_with_position:?}: {error}"), - }) - .log_err(); - } } + errored } @@ -653,12 +663,13 @@ mod tests { ipc::{self}, }; use editor::Editor; - use gpui::TestAppContext; + use futures::poll; + use gpui::{AppContext as _, TestAppContext}; use language::LineEnding; use remote::SshConnectionOptions; use rope::Rope; use serde_json::json; - use std::sync::Arc; + use std::{sync::Arc, task::Poll}; use util::path; use workspace::{AppState, Workspace}; @@ -754,6 +765,60 @@ mod tests { .unwrap(); } + #[gpui::test] + async fn test_wait_with_directory_waits_for_window_close(cx: &mut TestAppContext) { + let app_state = init_test(cx); + + app_state + .fs + .as_fake() + .insert_tree( + path!("/root"), + json!({ + "dir1": { + "file1.txt": "content1", + }, + }), + ) + .await; + + let (response_tx, _) = ipc::channel::().unwrap(); + let workspace_paths = vec![path!("/root/dir1").to_owned()]; + + let (done_tx, mut done_rx) = futures::channel::oneshot::channel(); + cx.spawn({ + let app_state = app_state.clone(); + move |mut cx| async move { + let errored = open_local_workspace( + workspace_paths, + vec![], + None, + false, + true, + &response_tx, + None, + &app_state, + &mut cx, + ) + .await; + let _ = done_tx.send(errored); + } + }) + .detach(); + + cx.background_executor.run_until_parked(); + assert_eq!(cx.windows().len(), 1); + assert!(matches!(poll!(&mut done_rx), Poll::Pending)); + + let window = cx.windows()[0]; + cx.update_window(window, |_, window, _| window.remove_window()) + .unwrap(); + cx.background_executor.run_until_parked(); + + let errored = done_rx.await.unwrap(); + assert!(!errored); + } + #[gpui::test] async fn test_open_workspace_with_nonexistent_files(cx: &mut TestAppContext) { let app_state = init_test(cx); From dfdad947e150668e7de19ce88173badf0ce27352 Mon Sep 17 00:00:00 2001 From: Ben Kunkle Date: Mon, 15 Dec 2025 18:03:02 -0800 Subject: [PATCH 342/621] settings_ui: Add Edit keybindings button (#44914) Closes #ISSUE Release Notes: - settings_ui: Added an "Open Keymap Editor" item under the Keymap section --- crates/keymap_editor/src/keymap_editor.rs | 95 +++++++++++++---------- crates/settings_ui/src/page_data.rs | 25 +++++- crates/settings_ui/src/settings_ui.rs | 82 +++++++++++++++++++ 3 files changed, 157 insertions(+), 45 deletions(-) diff --git a/crates/keymap_editor/src/keymap_editor.rs b/crates/keymap_editor/src/keymap_editor.rs index e81b1077c70d4eb3828715a6bcd28dfe564ab188..9e243d32151e3caeec2b8c51c7889d2ebe93f29b 100644 --- a/crates/keymap_editor/src/keymap_editor.rs +++ b/crates/keymap_editor/src/keymap_editor.rs @@ -81,50 +81,61 @@ pub fn init(cx: &mut App) { let keymap_event_channel = KeymapEventChannel::new(); cx.set_global(keymap_event_channel); - fn common(filter: Option, cx: &mut App) { - workspace::with_active_or_new_workspace(cx, move |workspace, window, cx| { - workspace - .with_local_workspace(window, cx, move |workspace, window, cx| { - let existing = workspace - .active_pane() - .read(cx) - .items() - .find_map(|item| item.downcast::()); - - let keymap_editor = if let Some(existing) = existing { - workspace.activate_item(&existing, true, true, window, cx); - existing - } else { - let keymap_editor = - cx.new(|cx| KeymapEditor::new(workspace.weak_handle(), window, cx)); - workspace.add_item_to_active_pane( - Box::new(keymap_editor.clone()), - None, - true, - window, - cx, - ); - keymap_editor - }; - - if let Some(filter) = filter { - keymap_editor.update(cx, |editor, cx| { - editor.filter_editor.update(cx, |editor, cx| { - editor.clear(window, cx); - editor.insert(&filter, window, cx); - }); - if !editor.has_binding_for(&filter) { - open_binding_modal_after_loading(cx) - } - }) - } - }) - .detach(); - }) + fn open_keymap_editor( + filter: Option, + workspace: &mut Workspace, + window: &mut Window, + cx: &mut Context, + ) { + workspace + .with_local_workspace(window, cx, |workspace, window, cx| { + let existing = workspace + .active_pane() + .read(cx) + .items() + .find_map(|item| item.downcast::()); + + let keymap_editor = if let Some(existing) = existing { + workspace.activate_item(&existing, true, true, window, cx); + existing + } else { + let keymap_editor = + cx.new(|cx| KeymapEditor::new(workspace.weak_handle(), window, cx)); + workspace.add_item_to_active_pane( + Box::new(keymap_editor.clone()), + None, + true, + window, + cx, + ); + keymap_editor + }; + + if let Some(filter) = filter { + keymap_editor.update(cx, |editor, cx| { + editor.filter_editor.update(cx, |editor, cx| { + editor.clear(window, cx); + editor.insert(&filter, window, cx); + }); + if !editor.has_binding_for(&filter) { + open_binding_modal_after_loading(cx) + } + }) + } + }) + .detach_and_log_err(cx); } - cx.on_action(|_: &OpenKeymap, cx| common(None, cx)) - .on_action(|action: &ChangeKeybinding, cx| common(Some(action.action.clone()), cx)); + cx.observe_new(|workspace: &mut Workspace, _window, _cx| { + workspace + .register_action(|workspace, _: &OpenKeymap, window, cx| { + open_keymap_editor(None, workspace, window, cx); + }) + .register_action(|workspace, action: &ChangeKeybinding, window, cx| { + open_keymap_editor(Some(action.action.clone()), workspace, window, cx); + }); + }) + .detach(); register_serializable_item::(cx); } diff --git a/crates/settings_ui/src/page_data.rs b/crates/settings_ui/src/page_data.rs index 79fc1cc11158399265a184a289fd8d7a71ce8d69..007c41ad59b4e875770beecb089bd4e7fb2078b5 100644 --- a/crates/settings_ui/src/page_data.rs +++ b/crates/settings_ui/src/page_data.rs @@ -1,12 +1,12 @@ -use gpui::App; +use gpui::{Action as _, App}; use settings::{LanguageSettingsContent, SettingsContent}; use std::sync::Arc; use strum::IntoDiscriminant as _; use ui::{IntoElement, SharedString}; use crate::{ - DynamicItem, PROJECT, SettingField, SettingItem, SettingsFieldMetadata, SettingsPage, - SettingsPageItem, SubPageLink, USER, all_language_names, sub_page_stack, + ActionLink, DynamicItem, PROJECT, SettingField, SettingItem, SettingsFieldMetadata, + SettingsPage, SettingsPageItem, SubPageLink, USER, all_language_names, sub_page_stack, }; const DEFAULT_STRING: String = String::new(); @@ -1054,6 +1054,25 @@ pub(crate) fn settings_data(cx: &App) -> Vec { SettingsPage { title: "Keymap", items: vec![ + SettingsPageItem::SectionHeader("Keybindings"), + SettingsPageItem::ActionLink(ActionLink { + title: "Edit Keybindings".into(), + description: Some("Customize keybindings in the keymap editor.".into()), + button_text: "Open Keymap".into(), + on_click: Arc::new(|settings_window, window, cx| { + let Some(original_window) = settings_window.original_window else { + return; + }; + original_window + .update(cx, |_workspace, original_window, cx| { + original_window + .dispatch_action(zed_actions::OpenKeymap.boxed_clone(), cx); + original_window.activate_window(); + }) + .ok(); + window.remove_window(); + }), + }), SettingsPageItem::SectionHeader("Base Keymap"), SettingsPageItem::SettingItem(SettingItem { title: "Base Keymap", diff --git a/crates/settings_ui/src/settings_ui.rs b/crates/settings_ui/src/settings_ui.rs index bfc60cc1ea21525effa5347431d90ee219064d24..40678f6cf8d1c6773ccf1168e065cb318ae9f14f 100644 --- a/crates/settings_ui/src/settings_ui.rs +++ b/crates/settings_ui/src/settings_ui.rs @@ -731,6 +731,7 @@ enum SettingsPageItem { SettingItem(SettingItem), SubPageLink(SubPageLink), DynamicItem(DynamicItem), + ActionLink(ActionLink), } impl std::fmt::Debug for SettingsPageItem { @@ -746,6 +747,9 @@ impl std::fmt::Debug for SettingsPageItem { SettingsPageItem::DynamicItem(dynamic_item) => { write!(f, "DynamicItem({})", dynamic_item.discriminant.title) } + SettingsPageItem::ActionLink(action_link) => { + write!(f, "ActionLink({})", action_link.title) + } } } } @@ -973,6 +977,55 @@ impl SettingsPageItem { return content.into_any_element(); } + SettingsPageItem::ActionLink(action_link) => v_flex() + .group("setting-item") + .px_8() + .child( + h_flex() + .id(action_link.title.clone()) + .w_full() + .min_w_0() + .justify_between() + .map(apply_padding) + .child( + v_flex() + .relative() + .w_full() + .max_w_1_2() + .child(Label::new(action_link.title.clone())) + .when_some( + action_link.description.as_ref(), + |this, description| { + this.child( + Label::new(description.clone()) + .size(LabelSize::Small) + .color(Color::Muted), + ) + }, + ), + ) + .child( + Button::new( + ("action-link".into(), action_link.title.clone()), + action_link.button_text.clone(), + ) + .icon(IconName::ArrowUpRight) + .tab_index(0_isize) + .icon_position(IconPosition::End) + .icon_color(Color::Muted) + .icon_size(IconSize::Small) + .style(ButtonStyle::OutlinedGhost) + .size(ButtonSize::Medium) + .on_click({ + let on_click = action_link.on_click.clone(); + cx.listener(move |this, _, window, cx| { + on_click(this, window, cx); + }) + }), + ), + ) + .when(!is_last, |this| this.child(Divider::horizontal())) + .into_any_element(), } } } @@ -1207,6 +1260,20 @@ impl PartialEq for SubPageLink { } } +#[derive(Clone)] +struct ActionLink { + title: SharedString, + description: Option, + button_text: SharedString, + on_click: Arc, +} + +impl PartialEq for ActionLink { + fn eq(&self, other: &Self) -> bool { + self.title == other.title + } +} + fn all_language_names(cx: &App) -> Vec { workspace::AppState::global(cx) .upgrade() @@ -1626,6 +1693,9 @@ impl SettingsWindow { any_found_since_last_header = true; } } + SettingsPageItem::ActionLink(_) => { + any_found_since_last_header = true; + } } } if let Some(last_header) = page_filter.get_mut(header_index) @@ -1864,6 +1934,18 @@ impl SettingsWindow { sub_page_link.title.as_ref(), ); } + SettingsPageItem::ActionLink(action_link) => { + documents.push(bm25::Document { + id: key_index, + contents: [page.title, header_str, action_link.title.as_ref()] + .join("\n"), + }); + push_candidates( + &mut fuzzy_match_candidates, + key_index, + action_link.title.as_ref(), + ); + } } push_candidates(&mut fuzzy_match_candidates, key_index, page.title); push_candidates(&mut fuzzy_match_candidates, key_index, header_str); From b17b0972048029b3a6a3f05bec4bfbc0bc8ae216 Mon Sep 17 00:00:00 2001 From: Marco Mihai Condrache <52580954+marcocondrache@users.noreply.github.com> Date: Tue, 16 Dec 2025 03:03:16 +0100 Subject: [PATCH 343/621] terminal: Sanitize URLs with characters that cannot be last (#43559) Closes #43345 The list of characters comes from the linkify crate, which is already used for URL detection in the editor: https://github.com/robinst/linkify/blob/5239e12e26c633f42323e51ed81b0ff534528077/src/url.rs#L228 Release Notes: - Improved url links detection in terminals. --------- Signed-off-by: Marco Mihai Condrache <52580954+marcocondrache@users.noreply.github.com> --- crates/terminal/src/terminal_hyperlinks.rs | 80 +++++++++++++--------- 1 file changed, 49 insertions(+), 31 deletions(-) diff --git a/crates/terminal/src/terminal_hyperlinks.rs b/crates/terminal/src/terminal_hyperlinks.rs index cff27c4567cca84b2310723bf73bfda8d58c166d..8ff33895251f707c8bc9a7894bd74b0bb323ae6c 100644 --- a/crates/terminal/src/terminal_hyperlinks.rs +++ b/crates/terminal/src/terminal_hyperlinks.rs @@ -160,8 +160,8 @@ fn sanitize_url_punctuation( let mut sanitized_url = url; let mut chars_trimmed = 0; - // First, handle parentheses balancing using single traversal - let (open_parens, close_parens) = + // Count parentheses in the URL + let (open_parens, mut close_parens) = sanitized_url .chars() .fold((0, 0), |(opens, closes), c| match c { @@ -170,33 +170,27 @@ fn sanitize_url_punctuation( _ => (opens, closes), }); - // Trim unbalanced closing parentheses - if close_parens > open_parens { - let mut remaining_close = close_parens; - while sanitized_url.ends_with(')') && remaining_close > open_parens { - sanitized_url.pop(); - chars_trimmed += 1; - remaining_close -= 1; - } - } + // Remove trailing characters that shouldn't be at the end of URLs + while let Some(last_char) = sanitized_url.chars().last() { + let should_remove = match last_char { + // These may be part of a URL but not at the end. It's not that the spec + // doesn't allow them, but they are frequently used in plain text as delimiters + // where they're not meant to be part of the URL. + '.' | ',' | ':' | ';' => true, + '(' => true, + ')' if close_parens > open_parens => { + close_parens -= 1; + + true + } + _ => false, + }; - // Handle trailing periods - if sanitized_url.ends_with('.') { - let trailing_periods = sanitized_url - .chars() - .rev() - .take_while(|&c| c == '.') - .count(); - - if trailing_periods > 1 { - sanitized_url.truncate(sanitized_url.len() - trailing_periods); - chars_trimmed += trailing_periods; - } else if trailing_periods == 1 - && let Some(second_last_char) = sanitized_url.chars().rev().nth(1) - && (second_last_char.is_alphanumeric() || second_last_char == '/') - { + if should_remove { sanitized_url.pop(); chars_trimmed += 1; + } else { + break; } } @@ -413,6 +407,8 @@ mod tests { ("https://www.google.com/)", "https://www.google.com/"), ("https://example.com/path)", "https://example.com/path"), ("https://test.com/))", "https://test.com/"), + ("https://test.com/(((", "https://test.com/"), + ("https://test.com/(test)(", "https://test.com/(test)"), // Cases that should NOT be sanitized (balanced parentheses) ( "https://en.wikipedia.org/wiki/Example_(disambiguation)", @@ -443,10 +439,10 @@ mod tests { } #[test] - fn test_url_periods_sanitization() { - // Test URLs with trailing periods (sentence punctuation) + fn test_url_punctuation_sanitization() { + // Test URLs with trailing punctuation (sentence/text punctuation) + // The sanitize_url_punctuation function removes ., ,, :, ;, from the end let test_cases = vec![ - // Cases that should be sanitized (trailing periods likely punctuation) ("https://example.com.", "https://example.com"), ( "https://github.com/zed-industries/zed.", @@ -466,13 +462,36 @@ mod tests { "https://en.wikipedia.org/wiki/C.E.O.", "https://en.wikipedia.org/wiki/C.E.O", ), - // Cases that should NOT be sanitized (periods are part of URL structure) + ("https://example.com,", "https://example.com"), + ("https://example.com/path,", "https://example.com/path"), + ("https://example.com,,", "https://example.com"), + ("https://example.com:", "https://example.com"), + ("https://example.com/path:", "https://example.com/path"), + ("https://example.com::", "https://example.com"), + ("https://example.com;", "https://example.com"), + ("https://example.com/path;", "https://example.com/path"), + ("https://example.com;;", "https://example.com"), + ("https://example.com.,", "https://example.com"), + ("https://example.com.:;", "https://example.com"), + ("https://example.com!.", "https://example.com!"), + ("https://example.com/).", "https://example.com/"), + ("https://example.com/);", "https://example.com/"), + ("https://example.com/;)", "https://example.com/"), ( "https://example.com/v1.0/api", "https://example.com/v1.0/api", ), ("https://192.168.1.1", "https://192.168.1.1"), ("https://sub.domain.com", "https://sub.domain.com"), + ( + "https://example.com?query=value", + "https://example.com?query=value", + ), + ("https://example.com?a=1&b=2", "https://example.com?a=1&b=2"), + ( + "https://example.com/path:8080", + "https://example.com/path:8080", + ), ]; for (input, expected) in test_cases { @@ -484,7 +503,6 @@ mod tests { let end_point = AlacPoint::new(Line(0), Column(input.len())); let dummy_match = Match::new(start_point, end_point); - // This test should initially fail since we haven't implemented period sanitization yet let (result, _) = sanitize_url_punctuation(input.to_string(), dummy_match, &term); assert_eq!(result, expected, "Failed for input: {}", input); } From c7d248329bd28fee61e5c5c6915bce72687c066b Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Mon, 15 Dec 2025 21:57:19 -0500 Subject: [PATCH 344/621] Include project rules in commit message generation (#44921) Closes #38027 Release Notes: - AI-generated commit messages now respect rules files (e.g. `AGENTS.md`) if present --------- Co-authored-by: Claude Haiku 4.5 --- Cargo.lock | 1 + crates/agent/src/agent.rs | 15 +----- crates/git_ui/Cargo.toml | 1 + crates/git_ui/src/git_panel.rs | 79 +++++++++++++++++++++++++++--- crates/prompt_store/src/prompts.rs | 12 +++++ 5 files changed, 89 insertions(+), 19 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8c1ade1714c9dd7f609582cc8bdf5184678afcd9..b43be6986b89bcd121416ded247e5bd944628cca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7077,6 +7077,7 @@ dependencies = [ "picker", "pretty_assertions", "project", + "prompt_store", "rand 0.9.2", "recent_projects", "remote", diff --git a/crates/agent/src/agent.rs b/crates/agent/src/agent.rs index 092f735bb7c3713e70ea137c2bab485315aa8849..715c8682ba9b1e6d21c6558271c00180691f59f0 100644 --- a/crates/agent/src/agent.rs +++ b/crates/agent/src/agent.rs @@ -33,7 +33,8 @@ use gpui::{ use language_model::{LanguageModel, LanguageModelProvider, LanguageModelRegistry}; use project::{Project, ProjectItem, ProjectPath, Worktree}; use prompt_store::{ - ProjectContext, PromptStore, RulesFileContext, UserRulesContext, WorktreeContext, + ProjectContext, PromptStore, RULES_FILE_NAMES, RulesFileContext, UserRulesContext, + WorktreeContext, }; use serde::{Deserialize, Serialize}; use settings::{LanguageModelSelection, update_settings_file}; @@ -51,18 +52,6 @@ pub struct ProjectSnapshot { pub timestamp: DateTime, } -const RULES_FILE_NAMES: [&str; 9] = [ - ".rules", - ".cursorrules", - ".windsurfrules", - ".clinerules", - ".github/copilot-instructions.md", - "CLAUDE.md", - "AGENT.md", - "AGENTS.md", - "GEMINI.md", -]; - pub struct RulesLoadingError { pub message: SharedString, } diff --git a/crates/git_ui/Cargo.toml b/crates/git_ui/Cargo.toml index 6747daa09d2801ad8c05c17fb04cb3ab235cdbff..c88244a036767be0ef862e74faa2113d54125443 100644 --- a/crates/git_ui/Cargo.toml +++ b/crates/git_ui/Cargo.toml @@ -43,6 +43,7 @@ notifications.workspace = true panel.workspace = true picker.workspace = true project.workspace = true +prompt_store.workspace = true recent_projects.workspace = true remote.workspace = true schemars.workspace = true diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs index d0618508ddbd153f4dcb1b77e974dc42ed2b0b32..362423b79fed0e8f3428d6784dd6f15b47708247 100644 --- a/crates/git_ui/src/git_panel.rs +++ b/crates/git_ui/src/git_panel.rs @@ -57,6 +57,7 @@ use project::{ git_store::{GitStoreEvent, Repository, RepositoryEvent, RepositoryId, pending_op}, project_settings::{GitPathStyle, ProjectSettings}, }; +use prompt_store::RULES_FILE_NAMES; use serde::{Deserialize, Serialize}; use settings::{Settings, SettingsStore, StatusStyle}; use std::future::Future; @@ -71,7 +72,7 @@ use ui::{ prelude::*, }; use util::paths::PathStyle; -use util::{ResultExt, TryFutureExt, maybe}; +use util::{ResultExt, TryFutureExt, maybe, rel_path::RelPath}; use workspace::SERIALIZATION_THROTTLE_TIME; use workspace::{ Workspace, @@ -2325,6 +2326,56 @@ impl GitPanel { compressed } + async fn load_project_rules( + project: &Entity, + repo_work_dir: &Arc, + cx: &mut AsyncApp, + ) -> Option { + let rules_path = cx + .update(|cx| { + for worktree in project.read(cx).worktrees(cx) { + let worktree_abs_path = worktree.read(cx).abs_path(); + if !worktree_abs_path.starts_with(&repo_work_dir) { + continue; + } + + let worktree_snapshot = worktree.read(cx).snapshot(); + for rules_name in RULES_FILE_NAMES { + if let Ok(rel_path) = RelPath::unix(rules_name) { + if let Some(entry) = worktree_snapshot.entry_for_path(rel_path) { + if entry.is_file() { + return Some(ProjectPath { + worktree_id: worktree.read(cx).id(), + path: entry.path.clone(), + }); + } + } + } + } + } + None + }) + .ok()??; + + let buffer = project + .update(cx, |project, cx| project.open_buffer(rules_path, cx)) + .ok()? + .await + .ok()?; + + let content = buffer + .read_with(cx, |buffer, _| buffer.text()) + .ok()? + .trim() + .to_string(); + + if content.is_empty() { + None + } else { + Some(content) + } + } + /// Generates a commit message using an LLM. pub fn generate_commit_message(&mut self, cx: &mut Context) { if !self.can_commit() || !AgentSettings::get_global(cx).enabled(cx) { @@ -2352,8 +2403,10 @@ impl GitPanel { }); let temperature = AgentSettings::temperature_for_model(&model, cx); + let project = self.project.clone(); + let repo_work_dir = repo.read(cx).work_directory_abs_path.clone(); - self.generate_commit_message_task = Some(cx.spawn(async move |this, cx| { + self.generate_commit_message_task = Some(cx.spawn(async move |this, mut cx| { async move { let _defer = cx.on_drop(&this, |this, _cx| { this.generate_commit_message_task.take(); @@ -2386,19 +2439,33 @@ impl GitPanel { const MAX_DIFF_BYTES: usize = 20_000; diff_text = Self::compress_commit_diff(&diff_text, MAX_DIFF_BYTES); + let rules_content = Self::load_project_rules(&project, &repo_work_dir, &mut cx).await; + let subject = this.update(cx, |this, cx| { this.commit_editor.read(cx).text(cx).lines().next().map(ToOwned::to_owned).unwrap_or_default() })?; let text_empty = subject.trim().is_empty(); - let content = if text_empty { - format!("{PROMPT}\nHere are the changes in this commit:\n{diff_text}") + const PROMPT: &str = include_str!("commit_message_prompt.txt"); + + let rules_section = match &rules_content { + Some(rules) => format!( + "\n\nThe user has provided the following project rules that you should follow when writing the commit message:\n\ + \n{rules}\n\n" + ), + None => String::new(), + }; + + let subject_section = if text_empty { + String::new() } else { - format!("{PROMPT}\nHere is the user's subject line:\n{subject}\nHere are the changes in this commit:\n{diff_text}\n") + format!("\nHere is the user's subject line:\n{subject}") }; - const PROMPT: &str = include_str!("commit_message_prompt.txt"); + let content = format!( + "{PROMPT}{rules_section}{subject_section}\nHere are the changes in this commit:\n{diff_text}" + ); let request = LanguageModelRequest { thread_id: None, diff --git a/crates/prompt_store/src/prompts.rs b/crates/prompt_store/src/prompts.rs index 847e45742db17fe194d002c26a67380390b68f06..674d4869e9825fd700dde3db510fbf68c6b4d5cc 100644 --- a/crates/prompt_store/src/prompts.rs +++ b/crates/prompt_store/src/prompts.rs @@ -20,6 +20,18 @@ use util::{ use crate::UserPromptId; +pub const RULES_FILE_NAMES: &[&str] = &[ + ".rules", + ".cursorrules", + ".windsurfrules", + ".clinerules", + ".github/copilot-instructions.md", + "CLAUDE.md", + "AGENT.md", + "AGENTS.md", + "GEMINI.md", +]; + #[derive(Default, Debug, Clone, Serialize)] pub struct ProjectContext { pub worktrees: Vec, From 829b1b5661dbcf976489c3d8021acdb8f4ed6af9 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Mon, 15 Dec 2025 20:53:50 -0700 Subject: [PATCH 345/621] Fix link opening (#44910) - **Fix editor::OpenUrl on zed links** - **Fix cmd-clicking links too** Closes #44293 Closes #43833 Release Notes: - The `editor::OpenUrl` action now works for links to https://zed.dev - Clicking on a link to a Zed channel or channel-note within the editor no-longer redirects you via the web. --------- Co-authored-by: Zed Zippy <234243425+zed-zippy[bot]@users.noreply.github.com> --- crates/client/src/client.rs | 58 +++++++++++++++++++++++------ crates/editor/src/editor.rs | 9 ++++- crates/zed/src/zed/open_listener.rs | 41 +++++++------------- 3 files changed, 68 insertions(+), 40 deletions(-) diff --git a/crates/client/src/client.rs b/crates/client/src/client.rs index 14311d6bbf52ecb6df8dcc4a2fbc9454836a4834..801c8c3de8d3f02e3d73809df2c651c6973f231a 100644 --- a/crates/client/src/client.rs +++ b/crates/client/src/client.rs @@ -1730,23 +1730,59 @@ impl ProtoClient for Client { /// prefix for the zed:// url scheme pub const ZED_URL_SCHEME: &str = "zed"; +/// A parsed Zed link that can be handled internally by the application. +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum ZedLink { + /// Join a channel: `zed.dev/channel/channel-name-123` or `zed://channel/channel-name-123` + Channel { channel_id: u64 }, + /// Open channel notes: `zed.dev/channel/channel-name-123/notes` or with heading `notes#heading` + ChannelNotes { + channel_id: u64, + heading: Option, + }, +} + /// Parses the given link into a Zed link. /// -/// Returns a [`Some`] containing the unprefixed link if the link is a Zed link. -/// Returns [`None`] otherwise. -pub fn parse_zed_link<'a>(link: &'a str, cx: &App) -> Option<&'a str> { +/// Returns a [`Some`] containing the parsed link if the link is a recognized Zed link +/// that should be handled internally by the application. +/// Returns [`None`] for links that should be opened in the browser. +pub fn parse_zed_link(link: &str, cx: &App) -> Option { let server_url = &ClientSettings::get_global(cx).server_url; - if let Some(stripped) = link + let path = link .strip_prefix(server_url) .and_then(|result| result.strip_prefix('/')) - { - return Some(stripped); + .or_else(|| { + link.strip_prefix(ZED_URL_SCHEME) + .and_then(|result| result.strip_prefix("://")) + })?; + + let mut parts = path.split('/'); + + if parts.next() != Some("channel") { + return None; } - if let Some(stripped) = link - .strip_prefix(ZED_URL_SCHEME) - .and_then(|result| result.strip_prefix("://")) - { - return Some(stripped); + + let slug = parts.next()?; + let id_str = slug.split('-').next_back()?; + let channel_id = id_str.parse::().ok()?; + + let Some(next) = parts.next() else { + return Some(ZedLink::Channel { channel_id }); + }; + + if let Some(heading) = next.strip_prefix("notes#") { + return Some(ZedLink::ChannelNotes { + channel_id, + heading: Some(heading.to_string()), + }); + } + + if next == "notes" { + return Some(ZedLink::ChannelNotes { + channel_id, + heading: None, + }); } None diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 797a2c9121d7742b4d3e6948c74eb61731b66856..7178f7e3e4f31aa9fefd3c080a82c5099a934311 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -17467,7 +17467,14 @@ impl Editor { // If there is one url or file, open it directly match first_url_or_file { Some(Either::Left(url)) => { - cx.update(|_, cx| cx.open_url(&url))?; + cx.update(|window, cx| { + if parse_zed_link(&url, cx).is_some() { + window + .dispatch_action(Box::new(zed_actions::OpenZedUrl { url }), cx); + } else { + cx.open_url(&url); + } + })?; Ok(Navigated::Yes) } Some(Either::Right(path)) => { diff --git a/crates/zed/src/zed/open_listener.rs b/crates/zed/src/zed/open_listener.rs index 3bf6bffda6c7cbbb3a6b0d0c8661acc432b71335..6352c20e5c0dcd0bd25063ca3a7bbcae87e48e3f 100644 --- a/crates/zed/src/zed/open_listener.rs +++ b/crates/zed/src/zed/open_listener.rs @@ -3,7 +3,7 @@ use crate::restorable_workspace_locations; use anyhow::{Context as _, Result, anyhow}; use cli::{CliRequest, CliResponse, ipc::IpcSender}; use cli::{IpcHandshake, ipc}; -use client::parse_zed_link; +use client::{ZedLink, parse_zed_link}; use collections::HashMap; use db::kvp::KEY_VALUE_STORE; use editor::Editor; @@ -112,8 +112,18 @@ impl OpenRequest { }); } else if url.starts_with("ssh://") { this.parse_ssh_file_path(&url, cx)? - } else if let Some(request_path) = parse_zed_link(&url, cx) { - this.parse_request_path(request_path).log_err(); + } else if let Some(zed_link) = parse_zed_link(&url, cx) { + match zed_link { + ZedLink::Channel { channel_id } => { + this.join_channel = Some(channel_id); + } + ZedLink::ChannelNotes { + channel_id, + heading, + } => { + this.open_channel_notes.push((channel_id, heading)); + } + } } else { log::error!("unhandled url: {}", url); } @@ -157,31 +167,6 @@ impl OpenRequest { self.parse_file_path(url.path()); Ok(()) } - - fn parse_request_path(&mut self, request_path: &str) -> Result<()> { - let mut parts = request_path.split('/'); - if parts.next() == Some("channel") - && let Some(slug) = parts.next() - && let Some(id_str) = slug.split('-').next_back() - && let Ok(channel_id) = id_str.parse::() - { - let Some(next) = parts.next() else { - self.join_channel = Some(channel_id); - return Ok(()); - }; - - if let Some(heading) = next.strip_prefix("notes#") { - self.open_channel_notes - .push((channel_id, Some(heading.to_string()))); - return Ok(()); - } - if next == "notes" { - self.open_channel_notes.push((channel_id, None)); - return Ok(()); - } - } - anyhow::bail!("invalid zed url: {request_path}") - } } #[derive(Clone)] From ee2a4a9d37dee1b421f6e44251fc5af2283f44ec Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Mon, 15 Dec 2025 22:10:33 -0700 Subject: [PATCH 346/621] Clean up screenshare (#44945) Release Notes: - Fixed a bug where screen-share tabs would persist after the sender (or receiver) had left the call. --- crates/call/src/call_impl/room.rs | 12 ++++++++++++ crates/workspace/src/shared_screen.rs | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/crates/call/src/call_impl/room.rs b/crates/call/src/call_impl/room.rs index fc15b4e4395ae7aa3100a165d942a6906cf1976d..ccc8c067c25a91aa44c01911be89c21f0ea9367c 100644 --- a/crates/call/src/call_impl/room.rs +++ b/crates/call/src/call_impl/room.rs @@ -305,6 +305,7 @@ impl Room { pub(crate) fn leave(&mut self, cx: &mut Context) -> Task> { cx.notify(); + self.emit_video_track_unsubscribed_events(cx); self.leave_internal(cx) } @@ -352,6 +353,14 @@ impl Room { self.maintain_connection.take(); } + fn emit_video_track_unsubscribed_events(&self, cx: &mut Context) { + for participant in self.remote_participants.values() { + for sid in participant.video_tracks.keys() { + cx.emit(Event::RemoteVideoTrackUnsubscribed { sid: sid.clone() }); + } + } + } + async fn maintain_connection( this: WeakEntity, client: Arc, @@ -882,6 +891,9 @@ impl Room { project_id: project.id, }); } + for sid in participant.video_tracks.keys() { + cx.emit(Event::RemoteVideoTrackUnsubscribed { sid: sid.clone() }); + } false } }); diff --git a/crates/workspace/src/shared_screen.rs b/crates/workspace/src/shared_screen.rs index 3c009f613ea52906649b73bb9fd657bab6906c3b..564560274699ab6685d481340c5efd4b6336ed56 100644 --- a/crates/workspace/src/shared_screen.rs +++ b/crates/workspace/src/shared_screen.rs @@ -42,6 +42,11 @@ impl SharedScreen { }) .detach(); + cx.observe_release(&room, |_, _, cx| { + cx.emit(Event::Close); + }) + .detach(); + let view = cx.new(|cx| RemoteVideoTrackView::new(track.clone(), window, cx)); cx.subscribe(&view, |_, _, ev, cx| match ev { call::RemoteVideoTrackViewEvent::Close => cx.emit(Event::Close), From 6016d0b8c6a22e586158d3b6f810b3cebb136118 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Mon, 15 Dec 2025 22:19:18 -0700 Subject: [PATCH 347/621] Improve autofix (#44930) Release Notes: - N/A --- .github/workflows/autofix_pr.yml | 38 +++++++++++++++++-- script/prettier | 10 ++++- .../xtask/src/tasks/workflows/autofix_pr.rs | 28 +++++++++++--- 3 files changed, 64 insertions(+), 12 deletions(-) diff --git a/.github/workflows/autofix_pr.yml b/.github/workflows/autofix_pr.yml index 8c7786f6e1b91879a8b5a6f26f685570cd9cb2d3..308849ccbeed0be7f9ab5c8f7e5846ed61a8724d 100644 --- a/.github/workflows/autofix_pr.yml +++ b/.github/workflows/autofix_pr.yml @@ -11,7 +11,7 @@ on: type: string jobs: run_autofix: - runs-on: namespace-profile-2x4-ubuntu-2404 + runs-on: namespace-profile-16x32-ubuntu-2204 steps: - id: get-app-token name: autofix_pr::run_autofix::authenticate_as_zippy @@ -29,6 +29,31 @@ jobs: shell: bash -euxo pipefail {0} env: GITHUB_TOKEN: ${{ steps.get-app-token.outputs.token }} + - name: steps::setup_cargo_config + run: | + mkdir -p ./../.cargo + cp ./.cargo/ci-config.toml ./../.cargo/config.toml + shell: bash -euxo pipefail {0} + - name: steps::cache_rust_dependencies_namespace + uses: namespacelabs/nscloud-cache-action@v1 + with: + cache: rust + - name: steps::setup_linux + run: ./script/linux + shell: bash -euxo pipefail {0} + - name: steps::install_mold + run: ./script/install-mold + shell: bash -euxo pipefail {0} + - name: steps::download_wasi_sdk + run: ./script/download-wasi-sdk + shell: bash -euxo pipefail {0} + - name: steps::setup_pnpm + uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 + with: + version: '9' + - name: autofix_pr::run_autofix::run_prettier_fix + run: ./script/prettier --write + shell: bash -euxo pipefail {0} - name: autofix_pr::run_autofix::run_cargo_fmt run: cargo fmt --all shell: bash -euxo pipefail {0} @@ -41,13 +66,18 @@ jobs: echo "No changes to commit" else git add -A - git commit -m "Apply cargo fmt and clippy --fix" + git commit -m "Autofix" git push fi shell: bash -euxo pipefail {0} env: GIT_COMMITTER_NAME: Zed Zippy - GIT_COMMITTER_EMAIL: hi@zed.dev + GIT_COMMITTER_EMAIL: 234243425+zed-zippy[bot]@users.noreply.github.com GIT_AUTHOR_NAME: Zed Zippy - GIT_AUTHOR_EMAIL: hi@zed.dev + GIT_AUTHOR_EMAIL: 234243425+zed-zippy[bot]@users.noreply.github.com GITHUB_TOKEN: ${{ steps.get-app-token.outputs.token }} + - name: steps::cleanup_cargo_config + if: always() + run: | + rm -rf ./../.cargo + shell: bash -euxo pipefail {0} diff --git a/script/prettier b/script/prettier index 5ad5d15cf0353b71a40821f3092ea0e7928abf9d..d7a9ba787fca2343cd705ff0d37e502a7aa9f77c 100755 --- a/script/prettier +++ b/script/prettier @@ -3,14 +3,20 @@ set -euxo pipefail PRETTIER_VERSION=3.5.0 -pnpm dlx "prettier@${PRETTIER_VERSION}" assets/settings/default.json --parser=jsonc --check || { +if [[ "${1:-}" == "--write" ]]; then + MODE="--write" +else + MODE="--check" +fi + +pnpm dlx "prettier@${PRETTIER_VERSION}" assets/settings/default.json --parser=jsonc $MODE || { echo "To fix, run from the root of the Zed repo:" echo " pnpm dlx prettier@${PRETTIER_VERSION} assets/settings/default.json --parser=jsonc --write" false } cd docs -pnpm dlx "prettier@${PRETTIER_VERSION}" . --check || { +pnpm dlx "prettier@${PRETTIER_VERSION}" . $MODE || { echo "To fix, run from the root of the Zed repo:" echo " cd docs && pnpm dlx prettier@${PRETTIER_VERSION} . --write && cd .." false diff --git a/tooling/xtask/src/tasks/workflows/autofix_pr.rs b/tooling/xtask/src/tasks/workflows/autofix_pr.rs index 7e00a8bcbdbd9cd367221d2d90413fb59428d560..835750e282dad39a3455fc0b5eb69bf82cc42201 100644 --- a/tooling/xtask/src/tasks/workflows/autofix_pr.rs +++ b/tooling/xtask/src/tasks/workflows/autofix_pr.rs @@ -2,7 +2,7 @@ use gh_workflow::*; use crate::tasks::workflows::{ runners, - steps::{self, NamedJob, named}, + steps::{self, FluentBuilder, NamedJob, named}, vars::{self, StepOutput, WorkflowInput}, }; @@ -45,20 +45,30 @@ fn run_autofix(pr_number: &WorkflowInput) -> NamedJob { ) } + fn run_prettier_fix() -> Step { + named::bash("./script/prettier --write") + } + fn commit_and_push(token: &StepOutput) -> Step { named::bash(indoc::indoc! {r#" if git diff --quiet; then echo "No changes to commit" else git add -A - git commit -m "Apply cargo fmt and clippy --fix" + git commit -m "Autofix" git push fi "#}) .add_env(("GIT_COMMITTER_NAME", "Zed Zippy")) - .add_env(("GIT_COMMITTER_EMAIL", "hi@zed.dev")) + .add_env(( + "GIT_COMMITTER_EMAIL", + "234243425+zed-zippy[bot]@users.noreply.github.com", + )) .add_env(("GIT_AUTHOR_NAME", "Zed Zippy")) - .add_env(("GIT_AUTHOR_EMAIL", "hi@zed.dev")) + .add_env(( + "GIT_AUTHOR_EMAIL", + "234243425+zed-zippy[bot]@users.noreply.github.com", + )) .add_env(("GITHUB_TOKEN", token)) } @@ -66,12 +76,18 @@ fn run_autofix(pr_number: &WorkflowInput) -> NamedJob { named::job( Job::default() - .runs_on(runners::LINUX_SMALL) + .runs_on(runners::LINUX_DEFAULT) .add_step(authenticate) .add_step(steps::checkout_repo_with_token(&token)) .add_step(checkout_pr(pr_number, &token)) + .add_step(steps::setup_cargo_config(runners::Platform::Linux)) + .add_step(steps::cache_rust_dependencies_namespace()) + .map(steps::install_linux_dependencies) + .add_step(steps::setup_pnpm()) + .add_step(run_prettier_fix()) .add_step(run_cargo_fmt()) .add_step(run_clippy_fix()) - .add_step(commit_and_push(&token)), + .add_step(commit_and_push(&token)) + .add_step(steps::cleanup_cargo_config(runners::Platform::Linux)), ) } From 8ef37e8577c5a3134bc26870caffe466277b27e5 Mon Sep 17 00:00:00 2001 From: Bertie690 <136088738+Bertie690@users.noreply.github.com> Date: Tue, 16 Dec 2025 00:50:15 -0500 Subject: [PATCH 348/621] Remove outdated `Cargo.toml` comment about `declare_interior_mutable_const` (#44950) Since the rule is no longer a `style` lint as of [mid-August](https://github.com/rust-lang/rust-clippy/pull/15454), the comment mentioning it not being one is outdated and should be removed. > [!NOTE] > I kept the severity at `error` for now to avoid rustling feathers. > If `warn` is preferred, feel free to change it yourself or ask me to do it - it's only 1 line of code, after all. Release Notes: - N/A --- Cargo.toml | 2 -- 1 file changed, 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f3a5fefc7168c5296d032ae89ec5817673d9c333..903d17fc3378519d3e632f63c1a1a0e08e6513cb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -857,8 +857,6 @@ unexpected_cfgs = { level = "allow" } dbg_macro = "deny" todo = "deny" -# This is not a style lint, see https://github.com/rust-lang/rust-clippy/pull/15454 -# Remove when the lint gets promoted to `suspicious`. declare_interior_mutable_const = "deny" redundant_clone = "deny" From a1dbfd0d777615cbe83b75dfd5237bb392b20631 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Tue, 16 Dec 2025 08:15:01 +0200 Subject: [PATCH 349/621] Fix the `file_finder::Toggle` binding (#44951) Closes https://github.com/zed-industries/zed/issues/44752 Closes https://github.com/zed-industries/zed/pull/44756 Release Notes: - Fixed "file_finder::Toggle" action sometimes not working in JetBrains keymap --- assets/keymaps/linux/jetbrains.json | 4 +++- assets/keymaps/macos/jetbrains.json | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/assets/keymaps/linux/jetbrains.json b/assets/keymaps/linux/jetbrains.json index 3a54c92bf33decd968ee8d711fb1a929534ded21..d3bf53a0d3694943252e0fccb2ac821cc6c2a6d3 100644 --- a/assets/keymaps/linux/jetbrains.json +++ b/assets/keymaps/linux/jetbrains.json @@ -70,7 +70,9 @@ "bindings": { "ctrl-f12": "outline::Toggle", "ctrl-r": ["buffer_search::Deploy", { "replace_enabled": true }], + "ctrl-e": "file_finder::Toggle", "ctrl-shift-n": "file_finder::Toggle", + "ctrl-alt-n": "file_finder::Toggle", "ctrl-g": "go_to_line::Toggle", "alt-enter": "editor::ToggleCodeActions", "ctrl-space": "editor::ShowCompletions", @@ -105,8 +107,8 @@ "ctrl-e": "file_finder::Toggle", "ctrl-k": "git_panel::ToggleFocus", // bug: This should also focus commit editor "ctrl-shift-n": "file_finder::Toggle", - "ctrl-n": "project_symbols::Toggle", "ctrl-alt-n": "file_finder::Toggle", + "ctrl-n": "project_symbols::Toggle", "ctrl-shift-a": "command_palette::Toggle", "shift shift": "command_palette::Toggle", "ctrl-alt-shift-n": "project_symbols::Toggle", diff --git a/assets/keymaps/macos/jetbrains.json b/assets/keymaps/macos/jetbrains.json index 1721a9d743a67abddbc55a4b505be497920d15aa..9946d8b124957349181db659259174d906d08d3a 100644 --- a/assets/keymaps/macos/jetbrains.json +++ b/assets/keymaps/macos/jetbrains.json @@ -68,8 +68,10 @@ "bindings": { "cmd-f12": "outline::Toggle", "cmd-r": ["buffer_search::Deploy", { "replace_enabled": true }], - "cmd-shift-o": "file_finder::Toggle", "cmd-l": "go_to_line::Toggle", + "cmd-e": "file_finder::Toggle", + "cmd-shift-o": "file_finder::Toggle", + "cmd-shift-n": "file_finder::Toggle", "alt-enter": "editor::ToggleCodeActions", "ctrl-space": "editor::ShowCompletions", "cmd-j": "editor::Hover", From f760233704f927ea778b14bdb8121c085bf8b654 Mon Sep 17 00:00:00 2001 From: Hourann Date: Tue, 16 Dec 2025 15:32:25 +0800 Subject: [PATCH 350/621] workspace: Fix context menu triggering format on save (#44073) Closes #43989 Release Notes: - Fixed editor context menu triggering format on save --- crates/workspace/src/item.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/workspace/src/item.rs b/crates/workspace/src/item.rs index 42eb754c21347e7dced792f3e56cb9901bc70bd1..bb4b10fa63dc884b8cf0ab8eee8e3bc34880b2a5 100644 --- a/crates/workspace/src/item.rs +++ b/crates/workspace/src/item.rs @@ -883,8 +883,14 @@ impl ItemHandle for Entity { if let Some(item) = weak_item.upgrade() && item.workspace_settings(cx).autosave == AutosaveSetting::OnFocusChange { - Pane::autosave_item(&item, workspace.project.clone(), window, cx) - .detach_and_log_err(cx); + // Only trigger autosave if focus has truly left the item. + // If focus is still within the item's hierarchy (e.g., moved to a context menu), + // don't trigger autosave to avoid unwanted formatting and cursor jumps. + let focus_handle = item.item_focus_handle(cx); + if !focus_handle.contains_focused(window, cx) { + Pane::autosave_item(&item, workspace.project.clone(), window, cx) + .detach_and_log_err(cx); + } } }, ) From ebd5a50cce74b1e903a1403a3e5f38ddff93b0c4 Mon Sep 17 00:00:00 2001 From: Patrick Elsen Date: Tue, 16 Dec 2025 09:11:10 +0100 Subject: [PATCH 351/621] language_models: Add `auto_discover` setting for Ollama (#42207) First up: I'm sorry if this is a low quality PR, or if this feature isn't wanted. I implemented this because I'd like to have this behaviour. If you don't think that this is useful, feel free to close the PR without comment. :) My idea is this: I love to pull random models with Ollama to try them. At the same time, not all of them are useful for coding, or some won't work out of the box with the context_length set. So, I'd like to change Zed's behaviour to not show me all models Ollama has, but to limit it to the ones that I configure manually. What I did is add an `auto_discover` field to the settings. The idea is that you can write a config like this: ```json "language_models": { "ollama": { "api_url": "http://localhost:11434", "auto_discover": false, "available_models": [ { "name": "qwen3:4b", "display_name": "Qwen3 4B 32K", "max_tokens": 32768, "supports_tools": true, "supports_thinking": true, "supports_images": true } ] } } ``` The `auto_discover: false` means that Zed won't pick up or show the language models that Ollama knows about, and will only show me the one I manually configured in `available_models`. That way, I can pull random models with Ollama, but in Zed I can only see the ones that I know work (because I've configured them). The default for `auto_discover` (when it is not explicitly set) is `true`, meaning that the existing behaviour is preserved, and this is not a breaking change for configurations. Release Notes: - ollama: Added `auto_discover` setting to optionally limit visible models to only those manually configured in `available_models` --- crates/language_models/src/provider/ollama.rs | 8 ++++-- crates/language_models/src/settings.rs | 1 + .../src/settings_content/language_model.rs | 1 + docs/src/ai/llm-providers.md | 27 +++++++++++++++++++ 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/crates/language_models/src/provider/ollama.rs b/crates/language_models/src/provider/ollama.rs index c961001e65be662e0023b3199f68dfbf4989e604..6f3c49f8669885bfd02e5b11b81a091b1248227c 100644 --- a/crates/language_models/src/provider/ollama.rs +++ b/crates/language_models/src/provider/ollama.rs @@ -43,6 +43,7 @@ static API_KEY_ENV_VAR: LazyLock = env_var!(API_KEY_ENV_VAR_NAME); #[derive(Default, Debug, Clone, PartialEq)] pub struct OllamaSettings { pub api_url: String, + pub auto_discover: bool, pub available_models: Vec, } @@ -238,10 +239,13 @@ impl LanguageModelProvider for OllamaLanguageModelProvider { fn provided_models(&self, cx: &App) -> Vec> { let mut models: HashMap = HashMap::new(); + let settings = OllamaLanguageModelProvider::settings(cx); // Add models from the Ollama API - for model in self.state.read(cx).fetched_models.iter() { - models.insert(model.name.clone(), model.clone()); + if settings.auto_discover { + for model in self.state.read(cx).fetched_models.iter() { + models.insert(model.name.clone(), model.clone()); + } } // Override with available models from settings diff --git a/crates/language_models/src/settings.rs b/crates/language_models/src/settings.rs index 43a8e7334a744c84d6edfae3ffc97115eb8f51b2..62f0025c755e10ea1bdae605d9dcc752298bb5f1 100644 --- a/crates/language_models/src/settings.rs +++ b/crates/language_models/src/settings.rs @@ -78,6 +78,7 @@ impl settings::Settings for AllLanguageModelSettings { }, ollama: OllamaSettings { api_url: ollama.api_url.unwrap(), + auto_discover: ollama.auto_discover.unwrap_or(true), available_models: ollama.available_models.unwrap_or_default(), }, open_router: OpenRouterSettings { diff --git a/crates/settings/src/settings_content/language_model.rs b/crates/settings/src/settings_content/language_model.rs index 48f5a463a4b8d896885d9ba5b7d804d16ecb5b6b..b106f3d9925cb4afe058cff44649f998c8b73d8a 100644 --- a/crates/settings/src/settings_content/language_model.rs +++ b/crates/settings/src/settings_content/language_model.rs @@ -92,6 +92,7 @@ pub enum BedrockAuthMethodContent { #[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema, MergeFrom)] pub struct OllamaSettingsContent { pub api_url: Option, + pub auto_discover: Option, pub available_models: Option>, } diff --git a/docs/src/ai/llm-providers.md b/docs/src/ai/llm-providers.md index f13ece5d3eb6aac3af38a0046abddc474649f503..ee495b1ba7e67a6cc15359453fd7d3ae41b17233 100644 --- a/docs/src/ai/llm-providers.md +++ b/docs/src/ai/llm-providers.md @@ -347,6 +347,33 @@ Download and install Ollama from [ollama.com/download](https://ollama.com/downlo 3. In the Agent Panel, select one of the Ollama models using the model dropdown. +#### Ollama Autodiscovery + +Zed will automatically discover models that Ollama has pulled. You can turn this off by setting +the `auto_discover` field in the Ollama settings. If you do this, you should manually specify which +models are available. + +```json [settings] +{ + "language_models": { + "ollama": { + "api_url": "http://localhost:11434", + "auto_discover": false, + "available_models": [ + { + "name": "qwen2.5-coder", + "display_name": "qwen 2.5 coder", + "max_tokens": 32768, + "supports_tools": true, + "supports_thinking": true, + "supports_images": true + } + ] + } + } +} +``` + #### Ollama Context Length {#ollama-context} Zed has pre-configured maximum context lengths (`max_tokens`) to match the capabilities of common models. From 65e90017914eb2ae41e86435bd203329cc9724c3 Mon Sep 17 00:00:00 2001 From: daomah <129229601+daomah@users.noreply.github.com> Date: Tue, 16 Dec 2025 03:13:48 -0500 Subject: [PATCH 352/621] docs: Add documentation for installing via winget (#44941) Simple documentation PR. Added information for installing on Windows via winget. Added links from the main README to relevant sections for both macOS and Windows Release Notes: - N/A --- README.md | 2 +- docs/src/installation.md | 6 ++++++ docs/src/windows.md | 8 ++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d1e2a75beccc9b115bd3b2e09bcc812aebc98329..d3a5fd20526e5eae6826241dce2bb94e8533ecb3 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Welcome to Zed, a high-performance, multiplayer code editor from the creators of ### Installation -On macOS, Linux, and Windows you can [download Zed directly](https://zed.dev/download) or [install Zed via your local package manager](https://zed.dev/docs/linux#installing-via-a-package-manager). +On macOS, Linux, and Windows you can [download Zed directly](https://zed.dev/download) or install Zed via your local package manager ([macOS](https://zed.dev/docs/installation#macos)/[Linux](https://zed.dev/docs/linux#installing-via-a-package-manager)/[Windows](https://zed.dev/docs/windows#package-managers)). Other platforms are not yet available: diff --git a/docs/src/installation.md b/docs/src/installation.md index 7802ef7776a78deefb196ab005297e1f54314ea6..7d2009e3a0266160ce4e13056287c36ef7660008 100644 --- a/docs/src/installation.md +++ b/docs/src/installation.md @@ -22,6 +22,12 @@ brew install --cask zed@preview Get the latest stable builds via [the download page](https://zed.dev/download). If you want to download our preview build, you can find it on its [releases page](https://zed.dev/releases/preview). After the first manual installation, Zed will periodically check for install updates. +Additionally, you can install Zed using winget: + +```sh +winget install -e --id ZedIndustries.Zed +``` + ### Linux For most Linux users, the easiest way to install Zed is through our installation script: diff --git a/docs/src/windows.md b/docs/src/windows.md index 34a553dd5b032915ed52651f7f02b737995b959b..b7b4b6b7bf153a2cae7cbf2b7168d502cfbdaeb0 100644 --- a/docs/src/windows.md +++ b/docs/src/windows.md @@ -6,6 +6,14 @@ Get the latest stable builds via [the download page](https://zed.dev/download). You can also build zed from source, see [these docs](https://zed.dev/docs/development/windows) for instructions. +### Package managers + +Additionally, you can install Zed using winget: + +```sh +winget install -e --id ZedIndustries.Zed +``` + ## Uninstall - Installed via installer: Use `Settings` → `Apps` → `Installed apps`, search for Zed, and click Uninstall. From 81d8fb930aca1f5e1f0a50d76a8644262538d085 Mon Sep 17 00:00:00 2001 From: Mayank Verma Date: Tue, 16 Dec 2025 13:56:29 +0530 Subject: [PATCH 353/621] tab_switcher: Fix missing preview on initial ctrl-shift-tab press (#44959) Closes #44852 Release Notes: - Fixed tab preview not showing up on initial ctrl-shift-tab press --- crates/tab_switcher/src/tab_switcher.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/tab_switcher/src/tab_switcher.rs b/crates/tab_switcher/src/tab_switcher.rs index 85186ad504eb098264aae64ba3c2354d20d011a4..85bb5fbba6ad49f556ecca9a4863972adb8666ce 100644 --- a/crates/tab_switcher/src/tab_switcher.rs +++ b/crates/tab_switcher/src/tab_switcher.rs @@ -529,7 +529,9 @@ impl TabSwitcherDelegate { } if self.select_last { - return self.matches.len() - 1; + let item_index = self.matches.len() - 1; + self.set_selected_index(item_index, window, cx); + return item_index; } // This only runs when initially opening the picker From 9d4d37a514881af95be3b39809243be2c4ab7a68 Mon Sep 17 00:00:00 2001 From: Ben Brandt Date: Tue, 16 Dec 2025 09:50:27 +0100 Subject: [PATCH 354/621] Revert "editor: Refactor cursor_offset_on_selection field in favor of VimModeSettings" (#44960) Reverts zed-industries/zed#44889 Release Notes: - N/A --- crates/editor/src/editor.rs | 31 ++++++++++++++++++------------- crates/editor/src/element.rs | 27 +++++++++++---------------- crates/vim/src/vim.rs | 1 + 3 files changed, 30 insertions(+), 29 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 7178f7e3e4f31aa9fefd3c080a82c5099a934311..05625d2f4e4e66de5c9fe55f62a02eef5d874df9 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -202,7 +202,6 @@ use ui::{ IconSize, Indicator, Key, Tooltip, h_flex, prelude::*, scrollbars::ScrollbarAutoHide, }; use util::{RangeExt, ResultExt, TryFutureExt, maybe, post_inc}; -use vim_mode_setting::VimModeSetting; use workspace::{ CollaboratorId, Item as WorkspaceItem, ItemId, ItemNavHistory, OpenInTerminal, OpenTerminal, RestoreOnStartupBehavior, SERIALIZATION_THROTTLE_TIME, SplitDirection, TabBarSettings, Toast, @@ -1111,6 +1110,9 @@ pub struct Editor { pending_rename: Option, searchable: bool, cursor_shape: CursorShape, + /// Whether the cursor is offset one character to the left when something is + /// selected (needed for vim visual mode) + cursor_offset_on_selection: bool, current_line_highlight: Option, pub collapse_matches: bool, autoindent_mode: Option, @@ -2286,6 +2288,7 @@ impl Editor { cursor_shape: EditorSettings::get_global(cx) .cursor_shape .unwrap_or_default(), + cursor_offset_on_selection: false, current_line_highlight: None, autoindent_mode: Some(AutoindentMode::EachLine), collapse_matches: false, @@ -2472,7 +2475,10 @@ impl Editor { } } EditorEvent::Edited { .. } => { - if !editor.is_vim_mode_enabled(cx) { + let vim_mode = vim_mode_setting::VimModeSetting::try_get(cx) + .map(|vim_mode| vim_mode.0) + .unwrap_or(false); + if !vim_mode { let display_map = editor.display_snapshot(cx); let selections = editor.selections.all_adjusted_display(&display_map); let pop_state = editor @@ -3101,6 +3107,10 @@ impl Editor { self.cursor_shape } + pub fn set_cursor_offset_on_selection(&mut self, set_cursor_offset_on_selection: bool) { + self.cursor_offset_on_selection = set_cursor_offset_on_selection; + } + pub fn set_current_line_highlight( &mut self, current_line_highlight: Option, @@ -22644,7 +22654,10 @@ impl Editor { .and_then(|e| e.to_str()) .map(|a| a.to_string())); - let vim_mode_enabled = self.is_vim_mode_enabled(cx); + let vim_mode = vim_mode_setting::VimModeSetting::try_get(cx) + .map(|vim_mode| vim_mode.0) + .unwrap_or(false); + let edit_predictions_provider = all_language_settings(file, cx).edit_predictions.provider; let copilot_enabled = edit_predictions_provider == language::language_settings::EditPredictionProvider::Copilot; @@ -22662,7 +22675,7 @@ impl Editor { event_type, type = if auto_saved {"autosave"} else {"manual"}, file_extension, - vim_mode_enabled, + vim_mode, copilot_enabled, copilot_enabled_for_language, edit_predictions_provider, @@ -22672,7 +22685,7 @@ impl Editor { telemetry::event!( event_type, file_extension, - vim_mode_enabled, + vim_mode, copilot_enabled, copilot_enabled_for_language, edit_predictions_provider, @@ -23287,14 +23300,6 @@ impl Editor { show_underlines: self.diagnostics_enabled(), } } - - /// Returns the value of the `vim_mode` setting, defaulting `false` if the - /// setting is not set. - pub(crate) fn is_vim_mode_enabled(&self, cx: &App) -> bool { - VimModeSetting::try_get(cx) - .map(|vim_mode| vim_mode.0) - .unwrap_or(false) - } } fn edit_for_markdown_paste<'a>( diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index efb0459b15b7b7e19a485a81753d39d7dd20b5de..8de660275ba9b455aec610568c41347888654495 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -133,7 +133,7 @@ impl SelectionLayout { fn new( selection: Selection, line_mode: bool, - vim_mode_enabled: bool, + cursor_offset: bool, cursor_shape: CursorShape, map: &DisplaySnapshot, is_newest: bool, @@ -154,7 +154,7 @@ impl SelectionLayout { } // any vim visual mode (including line mode) - if vim_mode_enabled && !range.is_empty() && !selection.reversed { + if cursor_offset && !range.is_empty() && !selection.reversed { if head.column() > 0 { head = map.clip_point(DisplayPoint::new(head.row(), head.column() - 1), Bias::Left); } else if head.row().0 > 0 && head != map.max_point() { @@ -1463,7 +1463,7 @@ impl EditorElement { let layout = SelectionLayout::new( selection, editor.selections.line_mode(), - editor.is_vim_mode_enabled(cx), + editor.cursor_offset_on_selection, editor.cursor_shape, &snapshot.display_snapshot, is_newest, @@ -1510,7 +1510,7 @@ impl EditorElement { let drag_cursor_layout = SelectionLayout::new( drop_cursor.clone(), false, - editor.is_vim_mode_enabled(cx), + editor.cursor_offset_on_selection, CursorShape::Bar, &snapshot.display_snapshot, false, @@ -1574,7 +1574,7 @@ impl EditorElement { .push(SelectionLayout::new( selection.selection, selection.line_mode, - editor.is_vim_mode_enabled(cx), + editor.cursor_offset_on_selection, selection.cursor_shape, &snapshot.display_snapshot, false, @@ -1585,7 +1585,8 @@ impl EditorElement { selections.extend(remote_selections.into_values()); } else if !editor.is_focused(window) && editor.show_cursor_when_unfocused { - let player = editor.current_user_player_color(cx); + let cursor_offset_on_selection = editor.cursor_offset_on_selection; + let layouts = snapshot .buffer_snapshot() .selections_in_range(&(start_anchor..end_anchor), true) @@ -1593,7 +1594,7 @@ impl EditorElement { SelectionLayout::new( selection, line_mode, - editor.is_vim_mode_enabled(cx), + cursor_offset_on_selection, cursor_shape, &snapshot.display_snapshot, false, @@ -1602,7 +1603,7 @@ impl EditorElement { ) }) .collect::>(); - + let player = editor.current_user_player_color(cx); selections.push((player, layouts)); } }); @@ -3317,7 +3318,7 @@ impl EditorElement { SelectionLayout::new( newest, editor.selections.line_mode(), - editor.is_vim_mode_enabled(cx), + editor.cursor_offset_on_selection, editor.cursor_shape, &snapshot.display_snapshot, true, @@ -11548,7 +11549,6 @@ mod tests { use log::info; use std::num::NonZeroU32; use util::test::sample_text; - use vim_mode_setting::VimModeSetting; #[gpui::test] async fn test_soft_wrap_editor_width_auto_height_editor(cx: &mut TestAppContext) { @@ -11893,12 +11893,6 @@ mod tests { async fn test_vim_visual_selections(cx: &mut TestAppContext) { init_test(cx, |_| {}); - // Enable `vim_mode` setting so the logic that checks whether this is - // enabled can work as expected. - cx.update(|cx| { - VimModeSetting::override_global(VimModeSetting(true), cx); - }); - let window = cx.add_window(|window, cx| { let buffer = MultiBuffer::build_simple(&(sample_text(6, 6, 'a') + "\n"), cx); Editor::new(EditorMode::full(), buffer, None, window, cx) @@ -11909,6 +11903,7 @@ mod tests { window .update(cx, |editor, window, cx| { + editor.cursor_offset_on_selection = true; editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| { s.select_ranges([ Point::new(0, 0)..Point::new(1, 0), diff --git a/crates/vim/src/vim.rs b/crates/vim/src/vim.rs index 9a9a1a001c32fcf8b22892ce5300d8d2aec3dd37..26fec968fb261fbb80a9f84211357623147ca0f4 100644 --- a/crates/vim/src/vim.rs +++ b/crates/vim/src/vim.rs @@ -1943,6 +1943,7 @@ impl Vim { editor.set_collapse_matches(collapse_matches); editor.set_input_enabled(vim.editor_input_enabled()); editor.set_autoindent(vim.should_autoindent()); + editor.set_cursor_offset_on_selection(vim.mode.is_visual()); editor .selections .set_line_mode(matches!(vim.mode, Mode::VisualLine)); From a176a8c47efd8312875585349ab4228fa72d7ea4 Mon Sep 17 00:00:00 2001 From: Xiaobo Liu Date: Tue, 16 Dec 2025 16:50:40 +0800 Subject: [PATCH 355/621] agent: Allow LanguageModelImage size to be optional (#44956) Release Notes: - Improved allow LanguageModelImage size to be optional Signed-off-by: Xiaobo Liu --- crates/agent/src/thread.rs | 3 +- crates/language_model/src/request.rs | 36 +++++++++++-------- .../language_models/src/provider/mistral.rs | 2 +- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/crates/agent/src/thread.rs b/crates/agent/src/thread.rs index b61c0ad0840475c3b5f6d4c0a7082a26d4d44a58..837bf454a2431c4a1efa81679adc6ed9ef355908 100644 --- a/crates/agent/src/thread.rs +++ b/crates/agent/src/thread.rs @@ -2662,7 +2662,6 @@ impl From for acp::ContentBlock { fn convert_image(image_content: acp::ImageContent) -> LanguageModelImage { LanguageModelImage { source: image_content.data.into(), - // TODO: make this optional? - size: gpui::Size::new(0.into(), 0.into()), + size: None, } } diff --git a/crates/language_model/src/request.rs b/crates/language_model/src/request.rs index d97d87bdc95c443aeaf3f2b5578bf7f0c1ef322a..5e99cca4f9d6e61672c541cb90a3a1ca7da91203 100644 --- a/crates/language_model/src/request.rs +++ b/crates/language_model/src/request.rs @@ -19,7 +19,8 @@ use crate::{LanguageModelToolUse, LanguageModelToolUseId}; pub struct LanguageModelImage { /// A base64-encoded PNG image. pub source: SharedString, - pub size: Size, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub size: Option>, } impl LanguageModelImage { @@ -61,7 +62,7 @@ impl LanguageModelImage { } Some(Self { - size: size(DevicePixels(width?), DevicePixels(height?)), + size: Some(size(DevicePixels(width?), DevicePixels(height?))), source: SharedString::from(source.to_string()), }) } @@ -83,7 +84,7 @@ impl LanguageModelImage { pub fn empty() -> Self { Self { source: "".into(), - size: size(DevicePixels(0), DevicePixels(0)), + size: None, } } @@ -139,15 +140,18 @@ impl LanguageModelImage { let source = unsafe { String::from_utf8_unchecked(base64_image) }; Some(LanguageModelImage { - size: image_size, + size: Some(image_size), source: source.into(), }) }) } pub fn estimate_tokens(&self) -> usize { - let width = self.size.width.0.unsigned_abs() as usize; - let height = self.size.height.0.unsigned_abs() as usize; + let Some(size) = self.size.as_ref() else { + return 0; + }; + let width = size.width.0.unsigned_abs() as usize; + let height = size.height.0.unsigned_abs() as usize; // From: https://docs.anthropic.com/en/docs/build-with-claude/vision#calculate-image-costs // Note that are a lot of conditions on Anthropic's API, and OpenAI doesn't use this, @@ -463,8 +467,9 @@ mod tests { match result { LanguageModelToolResultContent::Image(image) => { assert_eq!(image.source.as_ref(), "base64encodedimagedata"); - assert_eq!(image.size.width.0, 100); - assert_eq!(image.size.height.0, 200); + let size = image.size.expect("size"); + assert_eq!(size.width.0, 100); + assert_eq!(size.height.0, 200); } _ => panic!("Expected Image variant"), } @@ -483,8 +488,9 @@ mod tests { match result { LanguageModelToolResultContent::Image(image) => { assert_eq!(image.source.as_ref(), "wrappedimagedata"); - assert_eq!(image.size.width.0, 50); - assert_eq!(image.size.height.0, 75); + let size = image.size.expect("size"); + assert_eq!(size.width.0, 50); + assert_eq!(size.height.0, 75); } _ => panic!("Expected Image variant"), } @@ -503,8 +509,9 @@ mod tests { match result { LanguageModelToolResultContent::Image(image) => { assert_eq!(image.source.as_ref(), "caseinsensitive"); - assert_eq!(image.size.width.0, 30); - assert_eq!(image.size.height.0, 40); + let size = image.size.expect("size"); + assert_eq!(size.width.0, 30); + assert_eq!(size.height.0, 40); } _ => panic!("Expected Image variant"), } @@ -541,8 +548,9 @@ mod tests { match result { LanguageModelToolResultContent::Image(image) => { assert_eq!(image.source.as_ref(), "directimage"); - assert_eq!(image.size.width.0, 200); - assert_eq!(image.size.height.0, 300); + let size = image.size.expect("size"); + assert_eq!(size.width.0, 200); + assert_eq!(size.height.0, 300); } _ => panic!("Expected Image variant"), } diff --git a/crates/language_models/src/provider/mistral.rs b/crates/language_models/src/provider/mistral.rs index 3e99f32be8224bb2b9973feccb0ce973b58eaaed..64f3999e3aa96b2611e265a6eaf5df8063332c2a 100644 --- a/crates/language_models/src/provider/mistral.rs +++ b/crates/language_models/src/provider/mistral.rs @@ -927,7 +927,7 @@ mod tests { MessageContent::Text("What's in this image?".into()), MessageContent::Image(LanguageModelImage { source: "base64data".into(), - size: Default::default(), + size: None, }), ], cache: false, From 9c32c29238d2f4b6006e61b979079482bf07f9dd Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Tue, 16 Dec 2025 01:53:08 -0700 Subject: [PATCH 356/621] Revert "Add save_file and restore_file_from_disk agent tools" (#44949) Reverts zed-industries/zed#44789 Need to fix a bug Release Notes: - N/A --- crates/agent/src/thread.rs | 5 +- crates/agent/src/tools.rs | 8 +- crates/agent/src/tools/edit_file_tool.rs | 23 +- .../src/tools/restore_file_from_disk_tool.rs | 352 ------------------ crates/agent/src/tools/save_file_tool.rs | 351 ----------------- 5 files changed, 7 insertions(+), 732 deletions(-) delete mode 100644 crates/agent/src/tools/restore_file_from_disk_tool.rs delete mode 100644 crates/agent/src/tools/save_file_tool.rs diff --git a/crates/agent/src/thread.rs b/crates/agent/src/thread.rs index 837bf454a2431c4a1efa81679adc6ed9ef355908..dbf29c68766cfe28d0bce1d82ed53536446326e2 100644 --- a/crates/agent/src/thread.rs +++ b/crates/agent/src/thread.rs @@ -2,8 +2,7 @@ use crate::{ ContextServerRegistry, CopyPathTool, CreateDirectoryTool, DbLanguageModel, DbThread, DeletePathTool, DiagnosticsTool, EditFileTool, FetchTool, FindPathTool, GrepTool, ListDirectoryTool, MovePathTool, NowTool, OpenTool, ProjectSnapshot, ReadFileTool, - RestoreFileFromDiskTool, SaveFileTool, SystemPromptTemplate, Template, Templates, TerminalTool, - ThinkingTool, WebSearchTool, + SystemPromptTemplate, Template, Templates, TerminalTool, ThinkingTool, WebSearchTool, }; use acp_thread::{MentionUri, UserMessageId}; use action_log::ActionLog; @@ -1003,8 +1002,6 @@ impl Thread { self.project.clone(), self.action_log.clone(), )); - self.add_tool(SaveFileTool::new(self.project.clone())); - self.add_tool(RestoreFileFromDiskTool::new(self.project.clone())); self.add_tool(TerminalTool::new(self.project.clone(), environment)); self.add_tool(ThinkingTool); self.add_tool(WebSearchTool); diff --git a/crates/agent/src/tools.rs b/crates/agent/src/tools.rs index 358903a32baa5ead9b073642015e6829501307a2..62a52998a705e11d1c9e69cbade7f427cc9cfc32 100644 --- a/crates/agent/src/tools.rs +++ b/crates/agent/src/tools.rs @@ -4,6 +4,7 @@ mod create_directory_tool; mod delete_path_tool; mod diagnostics_tool; mod edit_file_tool; + mod fetch_tool; mod find_path_tool; mod grep_tool; @@ -12,8 +13,6 @@ mod move_path_tool; mod now_tool; mod open_tool; mod read_file_tool; -mod restore_file_from_disk_tool; -mod save_file_tool; mod terminal_tool; mod thinking_tool; @@ -28,6 +27,7 @@ pub use create_directory_tool::*; pub use delete_path_tool::*; pub use diagnostics_tool::*; pub use edit_file_tool::*; + pub use fetch_tool::*; pub use find_path_tool::*; pub use grep_tool::*; @@ -36,8 +36,6 @@ pub use move_path_tool::*; pub use now_tool::*; pub use open_tool::*; pub use read_file_tool::*; -pub use restore_file_from_disk_tool::*; -pub use save_file_tool::*; pub use terminal_tool::*; pub use thinking_tool::*; @@ -94,8 +92,6 @@ tools! { NowTool, OpenTool, ReadFileTool, - RestoreFileFromDiskTool, - SaveFileTool, TerminalTool, ThinkingTool, WebSearchTool, diff --git a/crates/agent/src/tools/edit_file_tool.rs b/crates/agent/src/tools/edit_file_tool.rs index c08300e19541cad49033093f0d2bbe3a5b233683..0ab99426e2e9645adf3f837d21c28dc285ab6ea2 100644 --- a/crates/agent/src/tools/edit_file_tool.rs +++ b/crates/agent/src/tools/edit_file_tool.rs @@ -316,9 +316,9 @@ impl AgentTool for EditFileTool { // Check for unsaved changes first - these indicate modifications we don't know about if is_dirty { anyhow::bail!( - "This file has unsaved changes. Ask the user whether they want to keep or discard those changes. \ - If they want to keep them, ask for confirmation then use the save_file tool to save the file, then retry this edit. \ - If they want to discard them, ask for confirmation then use the restore_file_from_disk tool to restore the on-disk contents, then retry this edit." + "This file cannot be written to because it has unsaved changes. \ + Please end the current conversation immediately by telling the user you want to write to this file (mention its path explicitly) but you can't write to it because it has unsaved changes. \ + Ask the user to save that buffer's changes and to inform you when it's ok to proceed." ); } @@ -2202,24 +2202,9 @@ mod tests { assert!(result.is_err(), "Edit should fail when buffer is dirty"); let error_msg = result.unwrap_err().to_string(); assert!( - error_msg.contains("This file has unsaved changes."), + error_msg.contains("cannot be written to because it has unsaved changes"), "Error should mention unsaved changes, got: {}", error_msg ); - assert!( - error_msg.contains("keep or discard"), - "Error should ask whether to keep or discard changes, got: {}", - error_msg - ); - assert!( - error_msg.contains("save_file"), - "Error should reference save_file tool, got: {}", - error_msg - ); - assert!( - error_msg.contains("restore_file_from_disk"), - "Error should reference restore_file_from_disk tool, got: {}", - error_msg - ); } } diff --git a/crates/agent/src/tools/restore_file_from_disk_tool.rs b/crates/agent/src/tools/restore_file_from_disk_tool.rs deleted file mode 100644 index f5723f6ee3ee46144152dd3ed2939ab2cfaca9c0..0000000000000000000000000000000000000000 --- a/crates/agent/src/tools/restore_file_from_disk_tool.rs +++ /dev/null @@ -1,352 +0,0 @@ -use agent_client_protocol as acp; -use anyhow::Result; -use collections::FxHashSet; -use gpui::{App, Entity, SharedString, Task}; -use language::Buffer; -use project::Project; -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; -use std::path::PathBuf; -use std::sync::Arc; - -use crate::{AgentTool, ToolCallEventStream}; - -/// Discards unsaved changes in open buffers by reloading file contents from disk. -/// -/// Use this tool when: -/// - You attempted to edit files but they have unsaved changes the user does not want to keep. -/// - You want to reset files to the on-disk state before retrying an edit. -/// -/// Only use this tool after asking the user for permission, because it will discard unsaved changes. -#[derive(Debug, Serialize, Deserialize, JsonSchema)] -pub struct RestoreFileFromDiskToolInput { - /// The paths of the files to restore from disk. - pub paths: Vec, -} - -pub struct RestoreFileFromDiskTool { - project: Entity, -} - -impl RestoreFileFromDiskTool { - pub fn new(project: Entity) -> Self { - Self { project } - } -} - -impl AgentTool for RestoreFileFromDiskTool { - type Input = RestoreFileFromDiskToolInput; - type Output = String; - - fn name() -> &'static str { - "restore_file_from_disk" - } - - fn kind() -> acp::ToolKind { - acp::ToolKind::Other - } - - fn initial_title( - &self, - input: Result, - _cx: &mut App, - ) -> SharedString { - match input { - Ok(input) if input.paths.len() == 1 => "Restore file from disk".into(), - Ok(input) => format!("Restore {} files from disk", input.paths.len()).into(), - Err(_) => "Restore files from disk".into(), - } - } - - fn run( - self: Arc, - input: Self::Input, - _event_stream: ToolCallEventStream, - cx: &mut App, - ) -> Task> { - let project = self.project.clone(); - let input_paths = input.paths; - - cx.spawn(async move |cx| { - let mut buffers_to_reload: FxHashSet> = FxHashSet::default(); - - let mut restored_paths: Vec = Vec::new(); - let mut clean_paths: Vec = Vec::new(); - let mut not_found_paths: Vec = Vec::new(); - let mut open_errors: Vec<(PathBuf, String)> = Vec::new(); - let mut dirty_check_errors: Vec<(PathBuf, String)> = Vec::new(); - let mut reload_errors: Vec = Vec::new(); - - for path in input_paths { - let project_path = - project.read_with(cx, |project, cx| project.find_project_path(&path, cx)); - - let project_path = match project_path { - Ok(Some(project_path)) => project_path, - Ok(None) => { - not_found_paths.push(path); - continue; - } - Err(error) => { - open_errors.push((path, error.to_string())); - continue; - } - }; - - let open_buffer_task = - project.update(cx, |project, cx| project.open_buffer(project_path, cx)); - - let buffer = match open_buffer_task { - Ok(task) => match task.await { - Ok(buffer) => buffer, - Err(error) => { - open_errors.push((path, error.to_string())); - continue; - } - }, - Err(error) => { - open_errors.push((path, error.to_string())); - continue; - } - }; - - let is_dirty = match buffer.read_with(cx, |buffer, _| buffer.is_dirty()) { - Ok(is_dirty) => is_dirty, - Err(error) => { - dirty_check_errors.push((path, error.to_string())); - continue; - } - }; - - if is_dirty { - buffers_to_reload.insert(buffer); - restored_paths.push(path); - } else { - clean_paths.push(path); - } - } - - if !buffers_to_reload.is_empty() { - let reload_task = project.update(cx, |project, cx| { - project.reload_buffers(buffers_to_reload, true, cx) - }); - - match reload_task { - Ok(task) => { - if let Err(error) = task.await { - reload_errors.push(error.to_string()); - } - } - Err(error) => { - reload_errors.push(error.to_string()); - } - } - } - - let mut lines: Vec = Vec::new(); - - if !restored_paths.is_empty() { - lines.push(format!("Restored {} file(s).", restored_paths.len())); - } - if !clean_paths.is_empty() { - lines.push(format!("{} clean.", clean_paths.len())); - } - - if !not_found_paths.is_empty() { - lines.push(format!("Not found ({}):", not_found_paths.len())); - for path in ¬_found_paths { - lines.push(format!("- {}", path.display())); - } - } - if !open_errors.is_empty() { - lines.push(format!("Open failed ({}):", open_errors.len())); - for (path, error) in &open_errors { - lines.push(format!("- {}: {}", path.display(), error)); - } - } - if !dirty_check_errors.is_empty() { - lines.push(format!( - "Dirty check failed ({}):", - dirty_check_errors.len() - )); - for (path, error) in &dirty_check_errors { - lines.push(format!("- {}: {}", path.display(), error)); - } - } - if !reload_errors.is_empty() { - lines.push(format!("Reload failed ({}):", reload_errors.len())); - for error in &reload_errors { - lines.push(format!("- {}", error)); - } - } - - if lines.is_empty() { - Ok("No paths provided.".to_string()) - } else { - Ok(lines.join("\n")) - } - }) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use fs::Fs; - use gpui::TestAppContext; - use language::LineEnding; - use project::FakeFs; - use serde_json::json; - use settings::SettingsStore; - use util::path; - - fn init_test(cx: &mut TestAppContext) { - cx.update(|cx| { - let settings_store = SettingsStore::test(cx); - cx.set_global(settings_store); - }); - } - - #[gpui::test] - async fn test_restore_file_from_disk_output_and_effects(cx: &mut TestAppContext) { - init_test(cx); - - let fs = FakeFs::new(cx.executor()); - fs.insert_tree( - "/root", - json!({ - "dirty.txt": "on disk: dirty\n", - "clean.txt": "on disk: clean\n", - }), - ) - .await; - - let project = Project::test(fs.clone(), [path!("/root").as_ref()], cx).await; - let tool = Arc::new(RestoreFileFromDiskTool::new(project.clone())); - - // Make dirty.txt dirty in-memory by saving different content into the buffer without saving to disk. - let dirty_project_path = project.read_with(cx, |project, cx| { - project - .find_project_path("root/dirty.txt", cx) - .expect("dirty.txt should exist in project") - }); - - let dirty_buffer = project - .update(cx, |project, cx| { - project.open_buffer(dirty_project_path, cx) - }) - .await - .unwrap(); - dirty_buffer.update(cx, |buffer, cx| { - buffer.edit([(0..buffer.len(), "in memory: dirty\n")], None, cx); - }); - assert!( - dirty_buffer.read_with(cx, |buffer, _| buffer.is_dirty()), - "dirty.txt buffer should be dirty before restore" - ); - - // Ensure clean.txt is opened but remains clean. - let clean_project_path = project.read_with(cx, |project, cx| { - project - .find_project_path("root/clean.txt", cx) - .expect("clean.txt should exist in project") - }); - - let clean_buffer = project - .update(cx, |project, cx| { - project.open_buffer(clean_project_path, cx) - }) - .await - .unwrap(); - assert!( - !clean_buffer.read_with(cx, |buffer, _| buffer.is_dirty()), - "clean.txt buffer should start clean" - ); - - let output = cx - .update(|cx| { - tool.clone().run( - RestoreFileFromDiskToolInput { - paths: vec![ - PathBuf::from("root/dirty.txt"), - PathBuf::from("root/clean.txt"), - ], - }, - ToolCallEventStream::test().0, - cx, - ) - }) - .await - .unwrap(); - - // Output should mention restored + clean. - assert!( - output.contains("Restored 1 file(s)."), - "expected restored count line, got:\n{output}" - ); - assert!( - output.contains("1 clean."), - "expected clean count line, got:\n{output}" - ); - - // Effect: dirty buffer should be restored back to disk content and become clean. - let dirty_text = dirty_buffer.read_with(cx, |buffer, _| buffer.text()); - assert_eq!( - dirty_text, "on disk: dirty\n", - "dirty.txt buffer should be restored to disk contents" - ); - assert!( - !dirty_buffer.read_with(cx, |buffer, _| buffer.is_dirty()), - "dirty.txt buffer should not be dirty after restore" - ); - - // Disk contents should be unchanged (restore-from-disk should not write). - let disk_dirty = fs.load(path!("/root/dirty.txt").as_ref()).await.unwrap(); - assert_eq!(disk_dirty, "on disk: dirty\n"); - - // Sanity: clean buffer should remain clean and unchanged. - let clean_text = clean_buffer.read_with(cx, |buffer, _| buffer.text()); - assert_eq!(clean_text, "on disk: clean\n"); - assert!( - !clean_buffer.read_with(cx, |buffer, _| buffer.is_dirty()), - "clean.txt buffer should remain clean" - ); - - // Test empty paths case. - let output = cx - .update(|cx| { - tool.clone().run( - RestoreFileFromDiskToolInput { paths: vec![] }, - ToolCallEventStream::test().0, - cx, - ) - }) - .await - .unwrap(); - assert_eq!(output, "No paths provided."); - - // Test not-found path case (path outside the project root). - let output = cx - .update(|cx| { - tool.clone().run( - RestoreFileFromDiskToolInput { - paths: vec![PathBuf::from("nonexistent/path.txt")], - }, - ToolCallEventStream::test().0, - cx, - ) - }) - .await - .unwrap(); - assert!( - output.contains("Not found (1):"), - "expected not-found header line, got:\n{output}" - ); - assert!( - output.contains("- nonexistent/path.txt"), - "expected not-found path bullet, got:\n{output}" - ); - - let _ = LineEnding::Unix; // keep import used if the buffer edit API changes - } -} diff --git a/crates/agent/src/tools/save_file_tool.rs b/crates/agent/src/tools/save_file_tool.rs deleted file mode 100644 index 429352200109c52303c9f6f94a28a49136af1a61..0000000000000000000000000000000000000000 --- a/crates/agent/src/tools/save_file_tool.rs +++ /dev/null @@ -1,351 +0,0 @@ -use agent_client_protocol as acp; -use anyhow::Result; -use collections::FxHashSet; -use gpui::{App, Entity, SharedString, Task}; -use language::Buffer; -use project::Project; -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; -use std::path::PathBuf; -use std::sync::Arc; - -use crate::{AgentTool, ToolCallEventStream}; - -/// Saves files that have unsaved changes. -/// -/// Use this tool when you need to edit files but they have unsaved changes that must be saved first. -/// Only use this tool after asking the user for permission to save their unsaved changes. -#[derive(Debug, Serialize, Deserialize, JsonSchema)] -pub struct SaveFileToolInput { - /// The paths of the files to save. - pub paths: Vec, -} - -pub struct SaveFileTool { - project: Entity, -} - -impl SaveFileTool { - pub fn new(project: Entity) -> Self { - Self { project } - } -} - -impl AgentTool for SaveFileTool { - type Input = SaveFileToolInput; - type Output = String; - - fn name() -> &'static str { - "save_file" - } - - fn kind() -> acp::ToolKind { - acp::ToolKind::Other - } - - fn initial_title( - &self, - input: Result, - _cx: &mut App, - ) -> SharedString { - match input { - Ok(input) if input.paths.len() == 1 => "Save file".into(), - Ok(input) => format!("Save {} files", input.paths.len()).into(), - Err(_) => "Save files".into(), - } - } - - fn run( - self: Arc, - input: Self::Input, - _event_stream: ToolCallEventStream, - cx: &mut App, - ) -> Task> { - let project = self.project.clone(); - let input_paths = input.paths; - - cx.spawn(async move |cx| { - let mut buffers_to_save: FxHashSet> = FxHashSet::default(); - - let mut saved_paths: Vec = Vec::new(); - let mut clean_paths: Vec = Vec::new(); - let mut not_found_paths: Vec = Vec::new(); - let mut open_errors: Vec<(PathBuf, String)> = Vec::new(); - let mut dirty_check_errors: Vec<(PathBuf, String)> = Vec::new(); - let mut save_errors: Vec<(String, String)> = Vec::new(); - - for path in input_paths { - let project_path = - project.read_with(cx, |project, cx| project.find_project_path(&path, cx)); - - let project_path = match project_path { - Ok(Some(project_path)) => project_path, - Ok(None) => { - not_found_paths.push(path); - continue; - } - Err(error) => { - open_errors.push((path, error.to_string())); - continue; - } - }; - - let open_buffer_task = - project.update(cx, |project, cx| project.open_buffer(project_path, cx)); - - let buffer = match open_buffer_task { - Ok(task) => match task.await { - Ok(buffer) => buffer, - Err(error) => { - open_errors.push((path, error.to_string())); - continue; - } - }, - Err(error) => { - open_errors.push((path, error.to_string())); - continue; - } - }; - - let is_dirty = match buffer.read_with(cx, |buffer, _| buffer.is_dirty()) { - Ok(is_dirty) => is_dirty, - Err(error) => { - dirty_check_errors.push((path, error.to_string())); - continue; - } - }; - - if is_dirty { - buffers_to_save.insert(buffer); - saved_paths.push(path); - } else { - clean_paths.push(path); - } - } - - // Save each buffer individually since there's no batch save API. - for buffer in buffers_to_save { - let path_for_buffer = match buffer.read_with(cx, |buffer, _| { - buffer - .file() - .map(|file| file.path().to_rel_path_buf()) - .map(|path| path.as_rel_path().as_unix_str().to_owned()) - }) { - Ok(path) => path.unwrap_or_else(|| "".to_string()), - Err(error) => { - save_errors.push(("".to_string(), error.to_string())); - continue; - } - }; - - let save_task = project.update(cx, |project, cx| project.save_buffer(buffer, cx)); - - match save_task { - Ok(task) => { - if let Err(error) = task.await { - save_errors.push((path_for_buffer, error.to_string())); - } - } - Err(error) => { - save_errors.push((path_for_buffer, error.to_string())); - } - } - } - - let mut lines: Vec = Vec::new(); - - if !saved_paths.is_empty() { - lines.push(format!("Saved {} file(s).", saved_paths.len())); - } - if !clean_paths.is_empty() { - lines.push(format!("{} clean.", clean_paths.len())); - } - - if !not_found_paths.is_empty() { - lines.push(format!("Not found ({}):", not_found_paths.len())); - for path in ¬_found_paths { - lines.push(format!("- {}", path.display())); - } - } - if !open_errors.is_empty() { - lines.push(format!("Open failed ({}):", open_errors.len())); - for (path, error) in &open_errors { - lines.push(format!("- {}: {}", path.display(), error)); - } - } - if !dirty_check_errors.is_empty() { - lines.push(format!( - "Dirty check failed ({}):", - dirty_check_errors.len() - )); - for (path, error) in &dirty_check_errors { - lines.push(format!("- {}: {}", path.display(), error)); - } - } - if !save_errors.is_empty() { - lines.push(format!("Save failed ({}):", save_errors.len())); - for (path, error) in &save_errors { - lines.push(format!("- {}: {}", path, error)); - } - } - - if lines.is_empty() { - Ok("No paths provided.".to_string()) - } else { - Ok(lines.join("\n")) - } - }) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use fs::Fs; - use gpui::TestAppContext; - use project::FakeFs; - use serde_json::json; - use settings::SettingsStore; - use util::path; - - fn init_test(cx: &mut TestAppContext) { - cx.update(|cx| { - let settings_store = SettingsStore::test(cx); - cx.set_global(settings_store); - }); - } - - #[gpui::test] - async fn test_save_file_output_and_effects(cx: &mut TestAppContext) { - init_test(cx); - - let fs = FakeFs::new(cx.executor()); - fs.insert_tree( - "/root", - json!({ - "dirty.txt": "on disk: dirty\n", - "clean.txt": "on disk: clean\n", - }), - ) - .await; - - let project = Project::test(fs.clone(), [path!("/root").as_ref()], cx).await; - let tool = Arc::new(SaveFileTool::new(project.clone())); - - // Make dirty.txt dirty in-memory. - let dirty_project_path = project.read_with(cx, |project, cx| { - project - .find_project_path("root/dirty.txt", cx) - .expect("dirty.txt should exist in project") - }); - - let dirty_buffer = project - .update(cx, |project, cx| { - project.open_buffer(dirty_project_path, cx) - }) - .await - .unwrap(); - dirty_buffer.update(cx, |buffer, cx| { - buffer.edit([(0..buffer.len(), "in memory: dirty\n")], None, cx); - }); - assert!( - dirty_buffer.read_with(cx, |buffer, _| buffer.is_dirty()), - "dirty.txt buffer should be dirty before save" - ); - - // Ensure clean.txt is opened but remains clean. - let clean_project_path = project.read_with(cx, |project, cx| { - project - .find_project_path("root/clean.txt", cx) - .expect("clean.txt should exist in project") - }); - - let clean_buffer = project - .update(cx, |project, cx| { - project.open_buffer(clean_project_path, cx) - }) - .await - .unwrap(); - assert!( - !clean_buffer.read_with(cx, |buffer, _| buffer.is_dirty()), - "clean.txt buffer should start clean" - ); - - let output = cx - .update(|cx| { - tool.clone().run( - SaveFileToolInput { - paths: vec![ - PathBuf::from("root/dirty.txt"), - PathBuf::from("root/clean.txt"), - ], - }, - ToolCallEventStream::test().0, - cx, - ) - }) - .await - .unwrap(); - - // Output should mention saved + clean. - assert!( - output.contains("Saved 1 file(s)."), - "expected saved count line, got:\n{output}" - ); - assert!( - output.contains("1 clean."), - "expected clean count line, got:\n{output}" - ); - - // Effect: dirty buffer should now be clean and disk should have new content. - assert!( - !dirty_buffer.read_with(cx, |buffer, _| buffer.is_dirty()), - "dirty.txt buffer should not be dirty after save" - ); - - let disk_dirty = fs.load(path!("/root/dirty.txt").as_ref()).await.unwrap(); - assert_eq!( - disk_dirty, "in memory: dirty\n", - "dirty.txt disk content should be updated" - ); - - // Sanity: clean buffer should remain clean and disk unchanged. - let disk_clean = fs.load(path!("/root/clean.txt").as_ref()).await.unwrap(); - assert_eq!(disk_clean, "on disk: clean\n"); - - // Test empty paths case. - let output = cx - .update(|cx| { - tool.clone().run( - SaveFileToolInput { paths: vec![] }, - ToolCallEventStream::test().0, - cx, - ) - }) - .await - .unwrap(); - assert_eq!(output, "No paths provided."); - - // Test not-found path case. - let output = cx - .update(|cx| { - tool.clone().run( - SaveFileToolInput { - paths: vec![PathBuf::from("nonexistent/path.txt")], - }, - ToolCallEventStream::test().0, - cx, - ) - }) - .await - .unwrap(); - assert!( - output.contains("Not found (1):"), - "expected not-found header line, got:\n{output}" - ); - assert!( - output.contains("- nonexistent/path.txt"), - "expected not-found path bullet, got:\n{output}" - ); - } -} From 9ec147db6751ec60d0a80578f8ef01767fc0db69 Mon Sep 17 00:00:00 2001 From: Moritz Bitsch Date: Tue, 16 Dec 2025 09:48:20 +0000 Subject: [PATCH 357/621] Update Copilot sign-up URL based on verification domain (#44085) Use the url crate to extract the domain from the verification URI and construct the appropriate Copilot sign-up URL for GitHub or GitHub Enterprise. Release Notes: - Improved github enterprise (ghe) copilot sign in --- Cargo.lock | 1 + crates/copilot/Cargo.toml | 1 + crates/copilot/src/sign_in.rs | 44 ++++++++++++++++++++++++++++++++--- 3 files changed, 43 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b43be6986b89bcd121416ded247e5bd944628cca..4858c4ae01c7bdea2eaf46fba87707d3a2e0af24 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3672,6 +3672,7 @@ dependencies = [ "task", "theme", "ui", + "url", "util", "workspace", "zlog", diff --git a/crates/copilot/Cargo.toml b/crates/copilot/Cargo.toml index 459abda17573d66287e2c8ca0b995292acaf163b..3a1706a7a679fbc14eafbeac953d842cda9f65c8 100644 --- a/crates/copilot/Cargo.toml +++ b/crates/copilot/Cargo.toml @@ -52,6 +52,7 @@ ui.workspace = true util.workspace = true workspace.workspace = true itertools.workspace = true +url.workspace = true [target.'cfg(windows)'.dependencies] async-std = { version = "1.12.0", features = ["unstable"] } diff --git a/crates/copilot/src/sign_in.rs b/crates/copilot/src/sign_in.rs index 0bcb11e18be1994ea92703973ad1278c5d5aa4f8..20e31525a8fdb09fce04934d3445d51ba4226a2e 100644 --- a/crates/copilot/src/sign_in.rs +++ b/crates/copilot/src/sign_in.rs @@ -6,6 +6,7 @@ use gpui::{ Subscription, Window, WindowBounds, WindowOptions, div, point, }; use ui::{ButtonLike, CommonAnimationExt, ConfiguredApiCard, Vector, VectorName, prelude::*}; +use url::Url; use util::ResultExt as _; use workspace::{Toast, Workspace, notifications::NotificationId}; @@ -152,6 +153,7 @@ pub struct CopilotCodeVerification { focus_handle: FocusHandle, copilot: Entity, _subscription: Subscription, + sign_up_url: Option, } impl Focusable for CopilotCodeVerification { @@ -183,11 +185,22 @@ impl CopilotCodeVerification { .detach(); let status = copilot.read(cx).status(); + // Determine sign-up URL based on verification_uri domain if available + let sign_up_url = if let Status::SigningIn { + prompt: Some(ref prompt), + } = status + { + // Extract domain from verification_uri to construct sign-up URL + Self::get_sign_up_url_from_verification(&prompt.verification_uri) + } else { + None + }; Self { status, connect_clicked: false, focus_handle: cx.focus_handle(), copilot: copilot.clone(), + sign_up_url, _subscription: cx.observe(copilot, |this, copilot, cx| { let status = copilot.read(cx).status(); match status { @@ -201,10 +214,30 @@ impl CopilotCodeVerification { } pub fn set_status(&mut self, status: Status, cx: &mut Context) { + // Update sign-up URL if we have a new verification URI + if let Status::SigningIn { + prompt: Some(ref prompt), + } = status + { + self.sign_up_url = Self::get_sign_up_url_from_verification(&prompt.verification_uri); + } self.status = status; cx.notify(); } + fn get_sign_up_url_from_verification(verification_uri: &str) -> Option { + // Extract domain from verification URI using url crate + if let Ok(url) = Url::parse(verification_uri) + && let Some(host) = url.host_str() + && !host.contains("github.com") + { + // For GHE, construct URL from domain + Some(format!("https://{}/features/copilot", host)) + } else { + None + } + } + fn render_device_code(data: &PromptUserDeviceFlow, cx: &mut Context) -> impl IntoElement { let copied = cx .read_from_clipboard() @@ -302,7 +335,12 @@ impl CopilotCodeVerification { ) } - fn render_unauthorized_modal(cx: &mut Context) -> impl Element { + fn render_unauthorized_modal(&self, cx: &mut Context) -> impl Element { + let sign_up_url = self + .sign_up_url + .as_deref() + .unwrap_or(COPILOT_SIGN_UP_URL) + .to_owned(); let description = "Enable Copilot by connecting your existing license once you have subscribed or renewed your subscription."; v_flex() @@ -319,7 +357,7 @@ impl CopilotCodeVerification { .full_width() .style(ButtonStyle::Outlined) .size(ButtonSize::Medium) - .on_click(|_, _, cx| cx.open_url(COPILOT_SIGN_UP_URL)), + .on_click(move |_, _, cx| cx.open_url(&sign_up_url)), ) .child( Button::new("copilot-subscribe-cancel-button", "Cancel") @@ -374,7 +412,7 @@ impl Render for CopilotCodeVerification { } => Self::render_prompting_modal(self.connect_clicked, prompt, cx).into_any_element(), Status::Unauthorized => { self.connect_clicked = false; - Self::render_unauthorized_modal(cx).into_any_element() + self.render_unauthorized_modal(cx).into_any_element() } Status::Authorized => { self.connect_clicked = false; From 4109c9dde73ddd24069dc31758e9ca50fb613a89 Mon Sep 17 00:00:00 2001 From: Simon Pham Date: Tue, 16 Dec 2025 17:51:28 +0700 Subject: [PATCH 358/621] workspace: Display a launchpad page when in an empty window & add it as a `restore_on_startup` value (#44048) Hi, This PR fixes nothing. I just miss the option to open recent projects quickly upon opening Zed, so I made this. Hope I can see it soon in Preview channel. If there is any suggestion, just comment. I will take it seriously. Thank you! |ui|before|after| |-|-|-| |empty pane|Screenshot 2025-12-03 at
12 39 25|Screenshot 2025-12-03 at 12 34
03| |new window|Screenshot 2025-12-03 at
12 39 21|Screenshot 2025-12-04 at 10 43
17| --- Release Notes: - Added a new value to the `restore_on_startup` setting called `launchpad`. This value makes Zed open with a variant of the welcome screen ("the launchpad") upon startup. Additionally, this same page variant is now also what is displayed if you close all tabs in an existing window that doesn't contain any folders open. The launchpad page shows you up to 5 recent projects, making it easy to open something you were working recently. --------- Co-authored-by: Danilo Leal --- Cargo.lock | 2 +- assets/keymaps/default-linux.json | 5 + assets/keymaps/default-macos.json | 5 + assets/keymaps/default-windows.json | 5 + crates/editor/src/editor.rs | 9 +- crates/migrator/src/migrations.rs | 6 + .../src/migrations/m_2025_12_15/settings.rs | 52 ++ crates/migrator/src/migrator.rs | 8 + crates/onboarding/Cargo.toml | 1 - crates/onboarding/src/onboarding.rs | 22 +- crates/onboarding/src/welcome.rs | 443 -------------- .../src/settings_content/workspace.rs | 9 +- crates/title_bar/src/title_bar.rs | 2 +- crates/workspace/Cargo.toml | 1 + crates/workspace/src/pane.rs | 26 +- crates/workspace/src/welcome.rs | 568 ++++++++++++++++++ crates/workspace/src/workspace.rs | 1 + crates/zed/src/main.rs | 8 +- crates/zed/src/zed.rs | 1 + crates/zed_actions/src/lib.rs | 2 + docs/src/configuring-zed.md | 10 +- 21 files changed, 711 insertions(+), 475 deletions(-) create mode 100644 crates/migrator/src/migrations/m_2025_12_15/settings.rs delete mode 100644 crates/onboarding/src/welcome.rs create mode 100644 crates/workspace/src/welcome.rs diff --git a/Cargo.lock b/Cargo.lock index 4858c4ae01c7bdea2eaf46fba87707d3a2e0af24..72a65994b9eee32b3b2c84c846e2825ffd0ff723 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10843,7 +10843,6 @@ dependencies = [ "documented", "fs", "fuzzy", - "git", "gpui", "menu", "notifications", @@ -20096,6 +20095,7 @@ dependencies = [ "feature_flags", "fs", "futures 0.3.31", + "git", "gpui", "http_client", "itertools 0.14.0", diff --git a/assets/keymaps/default-linux.json b/assets/keymaps/default-linux.json index aac9dcf706856703800068e9e4b7ce9e94d73ecb..bb49582ce0e939a5c43c24862a4e50f9d82125d2 100644 --- a/assets/keymaps/default-linux.json +++ b/assets/keymaps/default-linux.json @@ -1263,6 +1263,11 @@ "ctrl-+": ["zed::IncreaseUiFontSize", { "persist": false }], "ctrl--": ["zed::DecreaseUiFontSize", { "persist": false }], "ctrl-0": ["zed::ResetUiFontSize", { "persist": false }], + "ctrl-1": ["welcome::OpenRecentProject", 0], + "ctrl-2": ["welcome::OpenRecentProject", 1], + "ctrl-3": ["welcome::OpenRecentProject", 2], + "ctrl-4": ["welcome::OpenRecentProject", 3], + "ctrl-5": ["welcome::OpenRecentProject", 4], }, }, { diff --git a/assets/keymaps/default-macos.json b/assets/keymaps/default-macos.json index 224f6755465d63df0802e3b3919dbdf2ba82246d..3c6ec6e0423e5ea254ddcd9690f92ac11e0fa73a 100644 --- a/assets/keymaps/default-macos.json +++ b/assets/keymaps/default-macos.json @@ -1366,6 +1366,11 @@ "cmd-+": ["zed::IncreaseUiFontSize", { "persist": false }], "cmd--": ["zed::DecreaseUiFontSize", { "persist": false }], "cmd-0": ["zed::ResetUiFontSize", { "persist": false }], + "cmd-1": ["welcome::OpenRecentProject", 0], + "cmd-2": ["welcome::OpenRecentProject", 1], + "cmd-3": ["welcome::OpenRecentProject", 2], + "cmd-4": ["welcome::OpenRecentProject", 3], + "cmd-5": ["welcome::OpenRecentProject", 4], }, }, { diff --git a/assets/keymaps/default-windows.json b/assets/keymaps/default-windows.json index 5626309ecb2e17fbbff53347da6059cd2db3be31..b15313fe75cc1265b5eb0c5560f26e4c148d4336 100644 --- a/assets/keymaps/default-windows.json +++ b/assets/keymaps/default-windows.json @@ -1295,6 +1295,11 @@ "ctrl-+": ["zed::IncreaseUiFontSize", { "persist": false }], "ctrl--": ["zed::DecreaseUiFontSize", { "persist": false }], "ctrl-0": ["zed::ResetUiFontSize", { "persist": false }], + "ctrl-1": ["welcome::OpenRecentProject", 0], + "ctrl-2": ["welcome::OpenRecentProject", 1], + "ctrl-3": ["welcome::OpenRecentProject", 2], + "ctrl-4": ["welcome::OpenRecentProject", 3], + "ctrl-5": ["welcome::OpenRecentProject", 4], }, }, { diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 05625d2f4e4e66de5c9fe55f62a02eef5d874df9..f4a83f900da68d90803b82c0aec1287fcaa71cd3 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -3427,7 +3427,8 @@ impl Editor { data.selections = inmemory_selections; }); - if WorkspaceSettings::get(None, cx).restore_on_startup != RestoreOnStartupBehavior::None + if WorkspaceSettings::get(None, cx).restore_on_startup + != RestoreOnStartupBehavior::EmptyTab && let Some(workspace_id) = self.workspace_serialization_id(cx) { let snapshot = self.buffer().read(cx).snapshot(cx); @@ -3467,7 +3468,8 @@ impl Editor { use text::ToPoint as _; if self.mode.is_minimap() - || WorkspaceSettings::get(None, cx).restore_on_startup == RestoreOnStartupBehavior::None + || WorkspaceSettings::get(None, cx).restore_on_startup + == RestoreOnStartupBehavior::EmptyTab { return; } @@ -23163,7 +23165,8 @@ impl Editor { ) { if self.buffer_kind(cx) == ItemBufferKind::Singleton && !self.mode.is_minimap() - && WorkspaceSettings::get(None, cx).restore_on_startup != RestoreOnStartupBehavior::None + && WorkspaceSettings::get(None, cx).restore_on_startup + != RestoreOnStartupBehavior::EmptyTab { let buffer_snapshot = OnceCell::new(); diff --git a/crates/migrator/src/migrations.rs b/crates/migrator/src/migrations.rs index a479379a674589c748e22fc18beb8ee7c85df652..f3fdb8f36c70d1bfde474f842a7bcbeff2668b50 100644 --- a/crates/migrator/src/migrations.rs +++ b/crates/migrator/src/migrations.rs @@ -165,3 +165,9 @@ pub(crate) mod m_2025_12_08 { pub(crate) use keymap::KEYMAP_PATTERNS; } + +pub(crate) mod m_2025_12_15 { + mod settings; + + pub(crate) use settings::SETTINGS_PATTERNS; +} diff --git a/crates/migrator/src/migrations/m_2025_12_15/settings.rs b/crates/migrator/src/migrations/m_2025_12_15/settings.rs new file mode 100644 index 0000000000000000000000000000000000000000..c875bdfdddffc62a58912bdc53bcf3e496e4eeab --- /dev/null +++ b/crates/migrator/src/migrations/m_2025_12_15/settings.rs @@ -0,0 +1,52 @@ +use std::ops::Range; +use tree_sitter::{Query, QueryMatch}; + +use crate::MigrationPatterns; +use crate::patterns::SETTINGS_NESTED_KEY_VALUE_PATTERN; + +pub const SETTINGS_PATTERNS: MigrationPatterns = &[( + SETTINGS_NESTED_KEY_VALUE_PATTERN, + rename_restore_on_startup_values, +)]; + +fn rename_restore_on_startup_values( + contents: &str, + mat: &QueryMatch, + query: &Query, +) -> Option<(Range, String)> { + if !is_restore_on_startup_setting(contents, mat, query) { + return None; + } + + let setting_value_ix = query.capture_index_for_name("setting_value")?; + let setting_value_range = mat + .nodes_for_capture_index(setting_value_ix) + .next()? + .byte_range(); + let setting_value = contents.get(setting_value_range.clone())?; + + // The value includes quotes, so we check for the quoted string + let new_value = match setting_value.trim() { + "\"none\"" => "\"empty_tab\"", + "\"welcome\"" => "\"launchpad\"", + _ => return None, + }; + + Some((setting_value_range, new_value.to_string())) +} + +fn is_restore_on_startup_setting(contents: &str, mat: &QueryMatch, query: &Query) -> bool { + // Check that the parent key is "workspace" (since restore_on_startup is under workspace settings) + // Actually, restore_on_startup can be at the root level too, so we need to handle both cases + // The SETTINGS_NESTED_KEY_VALUE_PATTERN captures parent_key and setting_name + + let setting_name_ix = match query.capture_index_for_name("setting_name") { + Some(ix) => ix, + None => return false, + }; + let setting_name_range = match mat.nodes_for_capture_index(setting_name_ix).next() { + Some(node) => node.byte_range(), + None => return false, + }; + contents.get(setting_name_range) == Some("restore_on_startup") +} diff --git a/crates/migrator/src/migrator.rs b/crates/migrator/src/migrator.rs index 23a24ae199cd076b76b3df2b0d68712f059fd32e..8329d635ce321c1b6280f06cdabe105879cc03a0 100644 --- a/crates/migrator/src/migrator.rs +++ b/crates/migrator/src/migrator.rs @@ -232,6 +232,10 @@ pub fn migrate_settings(text: &str) -> Result> { &SETTINGS_QUERY_2025_11_20, ), MigrationType::Json(migrations::m_2025_11_25::remove_context_server_source), + MigrationType::TreeSitter( + migrations::m_2025_12_15::SETTINGS_PATTERNS, + &SETTINGS_QUERY_2025_12_15, + ), ]; run_migrations(text, migrations) } @@ -366,6 +370,10 @@ define_query!( KEYMAP_QUERY_2025_12_08, migrations::m_2025_12_08::KEYMAP_PATTERNS ); +define_query!( + SETTINGS_QUERY_2025_12_15, + migrations::m_2025_12_15::SETTINGS_PATTERNS +); // custom query static EDIT_PREDICTION_SETTINGS_MIGRATION_QUERY: LazyLock = LazyLock::new(|| { diff --git a/crates/onboarding/Cargo.toml b/crates/onboarding/Cargo.toml index 2ff3467c4804f7c0a50488a2c4a1e283ea571292..e5e5b5cac93aa4021f8933bd38f8711d53b89902 100644 --- a/crates/onboarding/Cargo.toml +++ b/crates/onboarding/Cargo.toml @@ -22,7 +22,6 @@ db.workspace = true documented.workspace = true fs.workspace = true fuzzy.workspace = true -git.workspace = true gpui.workspace = true menu.workspace = true notifications.workspace = true diff --git a/crates/onboarding/src/onboarding.rs b/crates/onboarding/src/onboarding.rs index 94581e142339cde9d4f1f01a3fb361ae810c1efa..66402f33d31c6e9ce5894c56872c8d92d2c4c36c 100644 --- a/crates/onboarding/src/onboarding.rs +++ b/crates/onboarding/src/onboarding.rs @@ -1,5 +1,4 @@ -pub use crate::welcome::ShowWelcome; -use crate::{multibuffer_hint::MultibufferHint, welcome::WelcomePage}; +use crate::multibuffer_hint::MultibufferHint; use client::{Client, UserStore, zed_urls}; use db::kvp::KEY_VALUE_STORE; use fs::Fs; @@ -17,6 +16,8 @@ use ui::{ Divider, KeyBinding, ParentElement as _, StatefulInteractiveElement, Vector, VectorName, WithScrollbar as _, prelude::*, rems_from_px, }; +pub use workspace::welcome::ShowWelcome; +use workspace::welcome::WelcomePage; use workspace::{ AppState, Workspace, WorkspaceId, dock::DockPosition, @@ -24,12 +25,12 @@ use workspace::{ notifications::NotifyResultExt as _, open_new, register_serializable_item, with_active_or_new_workspace, }; +use zed_actions::OpenOnboarding; mod base_keymap_picker; mod basics_page; pub mod multibuffer_hint; mod theme_preview; -mod welcome; /// Imports settings from Visual Studio Code. #[derive(Copy, Clone, Debug, Default, PartialEq, Deserialize, JsonSchema, Action)] @@ -52,14 +53,6 @@ pub struct ImportCursorSettings { pub const FIRST_OPEN: &str = "first_open"; pub const DOCS_URL: &str = "https://zed.dev/docs/"; -actions!( - zed, - [ - /// Opens the onboarding view. - OpenOnboarding - ] -); - actions!( onboarding, [ @@ -121,7 +114,8 @@ pub fn init(cx: &mut App) { if let Some(existing) = existing { workspace.activate_item(&existing, true, true, window, cx); } else { - let settings_page = WelcomePage::new(window, cx); + let settings_page = cx + .new(|cx| WelcomePage::new(workspace.weak_handle(), false, window, cx)); workspace.add_item_to_active_pane( Box::new(settings_page), None, @@ -427,7 +421,9 @@ fn go_to_welcome_page(cx: &mut App) { if let Some(idx) = idx { pane.activate_item(idx, true, true, window, cx); } else { - let item = Box::new(WelcomePage::new(window, cx)); + let item = Box::new( + cx.new(|cx| WelcomePage::new(workspace.weak_handle(), false, window, cx)), + ); pane.add_item(item, true, true, Some(onboarding_idx), window, cx); } diff --git a/crates/onboarding/src/welcome.rs b/crates/onboarding/src/welcome.rs deleted file mode 100644 index b2711cd52d61a51711bd8ec90581b981d7bcf784..0000000000000000000000000000000000000000 --- a/crates/onboarding/src/welcome.rs +++ /dev/null @@ -1,443 +0,0 @@ -use gpui::{ - Action, App, Context, Entity, EventEmitter, FocusHandle, Focusable, InteractiveElement, - ParentElement, Render, Styled, Task, Window, actions, -}; -use menu::{SelectNext, SelectPrevious}; -use ui::{ButtonLike, Divider, DividerColor, KeyBinding, Vector, VectorName, prelude::*}; -use workspace::{ - NewFile, Open, - item::{Item, ItemEvent}, - with_active_or_new_workspace, -}; -use zed_actions::{Extensions, OpenSettings, agent, command_palette}; - -use crate::{Onboarding, OpenOnboarding}; - -actions!( - zed, - [ - /// Show the Zed welcome screen - ShowWelcome - ] -); - -const CONTENT: (Section<4>, Section<3>) = ( - Section { - title: "Get Started", - entries: [ - SectionEntry { - icon: IconName::Plus, - title: "New File", - action: &NewFile, - }, - SectionEntry { - icon: IconName::FolderOpen, - title: "Open Project", - action: &Open, - }, - SectionEntry { - icon: IconName::CloudDownload, - title: "Clone Repository", - action: &git::Clone, - }, - SectionEntry { - icon: IconName::ListCollapse, - title: "Open Command Palette", - action: &command_palette::Toggle, - }, - ], - }, - Section { - title: "Configure", - entries: [ - SectionEntry { - icon: IconName::Settings, - title: "Open Settings", - action: &OpenSettings, - }, - SectionEntry { - icon: IconName::ZedAssistant, - title: "View AI Settings", - action: &agent::OpenSettings, - }, - SectionEntry { - icon: IconName::Blocks, - title: "Explore Extensions", - action: &Extensions { - category_filter: None, - id: None, - }, - }, - ], - }, -); - -struct Section { - title: &'static str, - entries: [SectionEntry; COLS], -} - -impl Section { - fn render(self, index_offset: usize, focus: &FocusHandle, cx: &mut App) -> impl IntoElement { - v_flex() - .min_w_full() - .child( - h_flex() - .px_1() - .mb_2() - .gap_2() - .child( - Label::new(self.title.to_ascii_uppercase()) - .buffer_font(cx) - .color(Color::Muted) - .size(LabelSize::XSmall), - ) - .child(Divider::horizontal().color(DividerColor::BorderVariant)), - ) - .children( - self.entries - .iter() - .enumerate() - .map(|(index, entry)| entry.render(index_offset + index, focus, cx)), - ) - } -} - -struct SectionEntry { - icon: IconName, - title: &'static str, - action: &'static dyn Action, -} - -impl SectionEntry { - fn render(&self, button_index: usize, focus: &FocusHandle, cx: &App) -> impl IntoElement { - ButtonLike::new(("onboarding-button-id", button_index)) - .tab_index(button_index as isize) - .full_width() - .size(ButtonSize::Medium) - .child( - h_flex() - .w_full() - .justify_between() - .child( - h_flex() - .gap_2() - .child( - Icon::new(self.icon) - .color(Color::Muted) - .size(IconSize::XSmall), - ) - .child(Label::new(self.title)), - ) - .child( - KeyBinding::for_action_in(self.action, focus, cx).size(rems_from_px(12.)), - ), - ) - .on_click(|_, window, cx| window.dispatch_action(self.action.boxed_clone(), cx)) - } -} - -pub struct WelcomePage { - focus_handle: FocusHandle, -} - -impl WelcomePage { - fn select_next(&mut self, _: &SelectNext, window: &mut Window, cx: &mut Context) { - window.focus_next(); - cx.notify(); - } - - fn select_previous(&mut self, _: &SelectPrevious, window: &mut Window, cx: &mut Context) { - window.focus_prev(); - cx.notify(); - } -} - -impl Render for WelcomePage { - fn render(&mut self, _: &mut Window, cx: &mut Context) -> impl IntoElement { - let (first_section, second_section) = CONTENT; - let first_section_entries = first_section.entries.len(); - let last_index = first_section_entries + second_section.entries.len(); - - h_flex() - .size_full() - .justify_center() - .overflow_hidden() - .bg(cx.theme().colors().editor_background) - .key_context("Welcome") - .track_focus(&self.focus_handle(cx)) - .on_action(cx.listener(Self::select_previous)) - .on_action(cx.listener(Self::select_next)) - .child( - h_flex() - .px_12() - .py_40() - .size_full() - .relative() - .max_w(px(1100.)) - .child( - div() - .size_full() - .max_w_128() - .mx_auto() - .child( - h_flex() - .w_full() - .justify_center() - .gap_4() - .child(Vector::square(VectorName::ZedLogo, rems(2.))) - .child( - div().child(Headline::new("Welcome to Zed")).child( - Label::new("The editor for what's next") - .size(LabelSize::Small) - .color(Color::Muted) - .italic(), - ), - ), - ) - .child( - v_flex() - .mt_10() - .gap_6() - .child(first_section.render( - Default::default(), - &self.focus_handle, - cx, - )) - .child(second_section.render( - first_section_entries, - &self.focus_handle, - cx, - )) - .child( - h_flex() - .w_full() - .pt_4() - .justify_center() - // We call this a hack - .rounded_b_xs() - .border_t_1() - .border_color(cx.theme().colors().border.opacity(0.6)) - .border_dashed() - .child( - Button::new("welcome-exit", "Return to Setup") - .tab_index(last_index as isize) - .full_width() - .label_size(LabelSize::XSmall) - .on_click(|_, window, cx| { - window.dispatch_action( - OpenOnboarding.boxed_clone(), - cx, - ); - - with_active_or_new_workspace(cx, |workspace, window, cx| { - let Some((welcome_id, welcome_idx)) = workspace - .active_pane() - .read(cx) - .items() - .enumerate() - .find_map(|(idx, item)| { - let _ = item.downcast::()?; - Some((item.item_id(), idx)) - }) - else { - return; - }; - - workspace.active_pane().update(cx, |pane, cx| { - // Get the index here to get around the borrow checker - let idx = pane.items().enumerate().find_map( - |(idx, item)| { - let _ = - item.downcast::()?; - Some(idx) - }, - ); - - if let Some(idx) = idx { - pane.activate_item( - idx, true, true, window, cx, - ); - } else { - let item = - Box::new(Onboarding::new(workspace, cx)); - pane.add_item( - item, - true, - true, - Some(welcome_idx), - window, - cx, - ); - } - - pane.remove_item( - welcome_id, - false, - false, - window, - cx, - ); - }); - }); - }), - ), - ), - ), - ), - ) - } -} - -impl WelcomePage { - pub fn new(window: &mut Window, cx: &mut App) -> Entity { - cx.new(|cx| { - let focus_handle = cx.focus_handle(); - cx.on_focus(&focus_handle, window, |_, _, cx| cx.notify()) - .detach(); - - WelcomePage { focus_handle } - }) - } -} - -impl EventEmitter for WelcomePage {} - -impl Focusable for WelcomePage { - fn focus_handle(&self, _: &App) -> gpui::FocusHandle { - self.focus_handle.clone() - } -} - -impl Item for WelcomePage { - type Event = ItemEvent; - - fn tab_content_text(&self, _detail: usize, _cx: &App) -> SharedString { - "Welcome".into() - } - - fn telemetry_event_text(&self) -> Option<&'static str> { - Some("New Welcome Page Opened") - } - - fn show_toolbar(&self) -> bool { - false - } - - fn to_item_events(event: &Self::Event, mut f: impl FnMut(workspace::item::ItemEvent)) { - f(*event) - } -} - -impl workspace::SerializableItem for WelcomePage { - fn serialized_item_kind() -> &'static str { - "WelcomePage" - } - - fn cleanup( - workspace_id: workspace::WorkspaceId, - alive_items: Vec, - _window: &mut Window, - cx: &mut App, - ) -> Task> { - workspace::delete_unloaded_items( - alive_items, - workspace_id, - "welcome_pages", - &persistence::WELCOME_PAGES, - cx, - ) - } - - fn deserialize( - _project: Entity, - _workspace: gpui::WeakEntity, - workspace_id: workspace::WorkspaceId, - item_id: workspace::ItemId, - window: &mut Window, - cx: &mut App, - ) -> Task>> { - if persistence::WELCOME_PAGES - .get_welcome_page(item_id, workspace_id) - .ok() - .is_some_and(|is_open| is_open) - { - window.spawn(cx, async move |cx| cx.update(WelcomePage::new)) - } else { - Task::ready(Err(anyhow::anyhow!("No welcome page to deserialize"))) - } - } - - fn serialize( - &mut self, - workspace: &mut workspace::Workspace, - item_id: workspace::ItemId, - _closing: bool, - _window: &mut Window, - cx: &mut Context, - ) -> Option>> { - let workspace_id = workspace.database_id()?; - Some(cx.background_spawn(async move { - persistence::WELCOME_PAGES - .save_welcome_page(item_id, workspace_id, true) - .await - })) - } - - fn should_serialize(&self, event: &Self::Event) -> bool { - event == &ItemEvent::UpdateTab - } -} - -mod persistence { - use db::{ - query, - sqlez::{domain::Domain, thread_safe_connection::ThreadSafeConnection}, - sqlez_macros::sql, - }; - use workspace::WorkspaceDb; - - pub struct WelcomePagesDb(ThreadSafeConnection); - - impl Domain for WelcomePagesDb { - const NAME: &str = stringify!(WelcomePagesDb); - - const MIGRATIONS: &[&str] = (&[sql!( - CREATE TABLE welcome_pages ( - workspace_id INTEGER, - item_id INTEGER UNIQUE, - is_open INTEGER DEFAULT FALSE, - - PRIMARY KEY(workspace_id, item_id), - FOREIGN KEY(workspace_id) REFERENCES workspaces(workspace_id) - ON DELETE CASCADE - ) STRICT; - )]); - } - - db::static_connection!(WELCOME_PAGES, WelcomePagesDb, [WorkspaceDb]); - - impl WelcomePagesDb { - query! { - pub async fn save_welcome_page( - item_id: workspace::ItemId, - workspace_id: workspace::WorkspaceId, - is_open: bool - ) -> Result<()> { - INSERT OR REPLACE INTO welcome_pages(item_id, workspace_id, is_open) - VALUES (?, ?, ?) - } - } - - query! { - pub fn get_welcome_page( - item_id: workspace::ItemId, - workspace_id: workspace::WorkspaceId - ) -> Result { - SELECT is_open - FROM welcome_pages - WHERE item_id = ? AND workspace_id = ? - } - } - } -} diff --git a/crates/settings/src/settings_content/workspace.rs b/crates/settings/src/settings_content/workspace.rs index b809a8fa85a9b27da3f3af5242e99b280466a4bb..832f6ec409c8594c55beab1fd6f327c1215f8bdc 100644 --- a/crates/settings/src/settings_content/workspace.rs +++ b/crates/settings/src/settings_content/workspace.rs @@ -42,7 +42,7 @@ pub struct WorkspaceSettingsContent { /// Default: off pub autosave: Option, /// Controls previous session restoration in freshly launched Zed instance. - /// Values: none, last_workspace, last_session + /// Values: empty_tab, last_workspace, last_session, launchpad /// Default: last_session pub restore_on_startup: Option, /// Whether to attempt to restore previous file's state when opening it again. @@ -382,13 +382,16 @@ impl CloseWindowWhenNoItems { )] #[serde(rename_all = "snake_case")] pub enum RestoreOnStartupBehavior { - /// Always start with an empty editor - None, + /// Always start with an empty editor tab + #[serde(alias = "none")] + EmptyTab, /// Restore the workspace that was closed last. LastWorkspace, /// Restore all workspaces that were open when quitting Zed. #[default] LastSession, + /// Show the launchpad with recent projects (no tabs). + Launchpad, } #[with_fallible_options] diff --git a/crates/title_bar/src/title_bar.rs b/crates/title_bar/src/title_bar.rs index 5bd47d02691c9a5c7fec968b5ea6e97265b956b2..4d7397a0bc82142245b86c11ffdf441a6b781ad8 100644 --- a/crates/title_bar/src/title_bar.rs +++ b/crates/title_bar/src/title_bar.rs @@ -479,7 +479,7 @@ impl TitleBar { let name = if let Some(name) = name { util::truncate_and_trailoff(&name, MAX_PROJECT_NAME_LENGTH) } else { - "Open recent project".to_string() + "Open Recent Project".to_string() }; Button::new("project_name_trigger", name) diff --git a/crates/workspace/Cargo.toml b/crates/workspace/Cargo.toml index acf95df37f5d20da65b6e9fa4460ba09b2ea81e3..c2554c63c4f6a1b9836a8ccc24ce4e567fefe601 100644 --- a/crates/workspace/Cargo.toml +++ b/crates/workspace/Cargo.toml @@ -38,6 +38,7 @@ db.workspace = true feature_flags.workspace = true fs.workspace = true futures.workspace = true +git.workspace = true gpui.workspace = true http_client.workspace = true itertools.workspace = true diff --git a/crates/workspace/src/pane.rs b/crates/workspace/src/pane.rs index 338a858f3c774deb1cc0750c56afd678f4eadf4a..036723c13755ff2a7b2b10e9684d822f239a8e0b 100644 --- a/crates/workspace/src/pane.rs +++ b/crates/workspace/src/pane.rs @@ -47,10 +47,9 @@ use std::{ }; use theme::ThemeSettings; use ui::{ - ButtonSize, Color, ContextMenu, ContextMenuEntry, ContextMenuItem, DecoratedIcon, IconButton, - IconButtonShape, IconDecoration, IconDecorationKind, IconName, IconSize, Indicator, Label, - PopoverMenu, PopoverMenuHandle, Tab, TabBar, TabPosition, Tooltip, prelude::*, - right_click_menu, + ContextMenu, ContextMenuEntry, ContextMenuItem, DecoratedIcon, IconButtonShape, IconDecoration, + IconDecorationKind, Indicator, PopoverMenu, PopoverMenuHandle, Tab, TabBar, TabPosition, + Tooltip, prelude::*, right_click_menu, }; use util::{ResultExt, debug_panic, maybe, paths::PathStyle, truncate_and_remove_front}; @@ -398,6 +397,7 @@ pub struct Pane { diagnostic_summary_update: Task<()>, /// If a certain project item wants to get recreated with specific data, it can persist its data before the recreation here. pub project_item_restoration_data: HashMap>, + welcome_page: Option>, pub in_center_group: bool, pub is_upper_left: bool, @@ -546,6 +546,7 @@ impl Pane { zoom_out_on_close: true, diagnostic_summary_update: Task::ready(()), project_item_restoration_data: HashMap::default(), + welcome_page: None, in_center_group: false, is_upper_left: false, is_upper_right: false, @@ -635,6 +636,10 @@ impl Pane { self.last_focus_handle_by_item .insert(active_item.item_id(), focused.downgrade()); } + } else if let Some(welcome_page) = self.welcome_page.as_ref() { + if self.focus_handle.is_focused(window) { + welcome_page.read(cx).focus_handle(cx).focus(window); + } } } @@ -4061,10 +4066,15 @@ impl Render for Pane { if has_worktrees { placeholder } else { - placeholder.child( - Label::new("Open a file or project to get started.") - .color(Color::Muted), - ) + if self.welcome_page.is_none() { + let workspace = self.workspace.clone(); + self.welcome_page = Some(cx.new(|cx| { + crate::welcome::WelcomePage::new( + workspace, true, window, cx, + ) + })); + } + placeholder.child(self.welcome_page.clone().unwrap()) } } }) diff --git a/crates/workspace/src/welcome.rs b/crates/workspace/src/welcome.rs new file mode 100644 index 0000000000000000000000000000000000000000..93ff1ea266ff9f40b64064ea03d9bd1b91161300 --- /dev/null +++ b/crates/workspace/src/welcome.rs @@ -0,0 +1,568 @@ +use crate::{ + NewFile, Open, PathList, SerializedWorkspaceLocation, WORKSPACE_DB, Workspace, WorkspaceId, + item::{Item, ItemEvent}, +}; +use git::Clone as GitClone; +use gpui::WeakEntity; +use gpui::{ + Action, App, Context, Entity, EventEmitter, FocusHandle, Focusable, InteractiveElement, + ParentElement, Render, Styled, Task, Window, actions, +}; +use menu::{SelectNext, SelectPrevious}; +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; +use ui::{ButtonLike, Divider, DividerColor, KeyBinding, Vector, VectorName, prelude::*}; +use util::ResultExt; +use zed_actions::{Extensions, OpenOnboarding, OpenSettings, agent, command_palette}; + +#[derive(PartialEq, Clone, Debug, Deserialize, Serialize, JsonSchema, Action)] +#[action(namespace = welcome)] +#[serde(transparent)] +pub struct OpenRecentProject { + pub index: usize, +} + +actions!( + zed, + [ + /// Show the Zed welcome screen + ShowWelcome + ] +); + +#[derive(IntoElement)] +struct SectionHeader { + title: SharedString, +} + +impl SectionHeader { + fn new(title: impl Into) -> Self { + Self { + title: title.into(), + } + } +} + +impl RenderOnce for SectionHeader { + fn render(self, _window: &mut Window, cx: &mut App) -> impl IntoElement { + h_flex() + .px_1() + .mb_2() + .gap_2() + .child( + Label::new(self.title.to_ascii_uppercase()) + .buffer_font(cx) + .color(Color::Muted) + .size(LabelSize::XSmall), + ) + .child(Divider::horizontal().color(DividerColor::BorderVariant)) + } +} + +#[derive(IntoElement)] +struct SectionButton { + label: SharedString, + icon: IconName, + action: Box, + tab_index: usize, + focus_handle: FocusHandle, +} + +impl SectionButton { + fn new( + label: impl Into, + icon: IconName, + action: &dyn Action, + tab_index: usize, + focus_handle: FocusHandle, + ) -> Self { + Self { + label: label.into(), + icon, + action: action.boxed_clone(), + tab_index, + focus_handle, + } + } +} + +impl RenderOnce for SectionButton { + fn render(self, _window: &mut Window, cx: &mut App) -> impl IntoElement { + let id = format!("onb-button-{}", self.label); + let action_ref: &dyn Action = &*self.action; + + ButtonLike::new(id) + .tab_index(self.tab_index as isize) + .full_width() + .size(ButtonSize::Medium) + .child( + h_flex() + .w_full() + .justify_between() + .child( + h_flex() + .gap_2() + .child( + Icon::new(self.icon) + .color(Color::Muted) + .size(IconSize::Small), + ) + .child(Label::new(self.label)), + ) + .child( + KeyBinding::for_action_in(action_ref, &self.focus_handle, cx) + .size(rems_from_px(12.)), + ), + ) + .on_click(move |_, window, cx| window.dispatch_action(self.action.boxed_clone(), cx)) + } +} + +struct SectionEntry { + icon: IconName, + title: &'static str, + action: &'static dyn Action, +} + +impl SectionEntry { + fn render(&self, button_index: usize, focus: &FocusHandle, _cx: &App) -> impl IntoElement { + SectionButton::new( + self.title, + self.icon, + self.action, + button_index, + focus.clone(), + ) + } +} + +const CONTENT: (Section<4>, Section<3>) = ( + Section { + title: "Get Started", + entries: [ + SectionEntry { + icon: IconName::Plus, + title: "New File", + action: &NewFile, + }, + SectionEntry { + icon: IconName::FolderOpen, + title: "Open Project", + action: &Open, + }, + SectionEntry { + icon: IconName::CloudDownload, + title: "Clone Repository", + action: &GitClone, + }, + SectionEntry { + icon: IconName::ListCollapse, + title: "Open Command Palette", + action: &command_palette::Toggle, + }, + ], + }, + Section { + title: "Configure", + entries: [ + SectionEntry { + icon: IconName::Settings, + title: "Open Settings", + action: &OpenSettings, + }, + SectionEntry { + icon: IconName::ZedAssistant, + title: "View AI Settings", + action: &agent::OpenSettings, + }, + SectionEntry { + icon: IconName::Blocks, + title: "Explore Extensions", + action: &Extensions { + category_filter: None, + id: None, + }, + }, + ], + }, +); + +struct Section { + title: &'static str, + entries: [SectionEntry; COLS], +} + +impl Section { + fn render(self, index_offset: usize, focus: &FocusHandle, cx: &App) -> impl IntoElement { + v_flex() + .min_w_full() + .child(SectionHeader::new(self.title)) + .children( + self.entries + .iter() + .enumerate() + .map(|(index, entry)| entry.render(index_offset + index, focus, cx)), + ) + } +} + +pub struct WelcomePage { + workspace: WeakEntity, + focus_handle: FocusHandle, + fallback_to_recent_projects: bool, + recent_workspaces: Option>, +} + +impl WelcomePage { + pub fn new( + workspace: WeakEntity, + fallback_to_recent_projects: bool, + window: &mut Window, + cx: &mut Context, + ) -> Self { + let focus_handle = cx.focus_handle(); + cx.on_focus(&focus_handle, window, |_, _, cx| cx.notify()) + .detach(); + + if fallback_to_recent_projects { + cx.spawn_in(window, async move |this: WeakEntity, cx| { + let workspaces = WORKSPACE_DB + .recent_workspaces_on_disk() + .await + .log_err() + .unwrap_or_default(); + + this.update(cx, |this, cx| { + this.recent_workspaces = Some(workspaces); + cx.notify(); + }) + .ok(); + }) + .detach(); + } + + WelcomePage { + workspace, + focus_handle, + fallback_to_recent_projects, + recent_workspaces: None, + } + } + + fn select_next(&mut self, _: &SelectNext, window: &mut Window, cx: &mut Context) { + window.focus_next(); + cx.notify(); + } + + fn select_previous(&mut self, _: &SelectPrevious, window: &mut Window, cx: &mut Context) { + window.focus_prev(); + cx.notify(); + } + + fn open_recent_project( + &mut self, + action: &OpenRecentProject, + window: &mut Window, + cx: &mut Context, + ) { + if let Some(recent_workspaces) = &self.recent_workspaces { + if let Some((_workspace_id, location, paths)) = recent_workspaces.get(action.index) { + let paths = paths.clone(); + let location = location.clone(); + let is_local = matches!(location, SerializedWorkspaceLocation::Local); + let workspace = self.workspace.clone(); + + if is_local { + let paths = paths.paths().to_vec(); + cx.spawn_in(window, async move |_, cx| { + let _ = workspace.update_in(cx, |workspace, window, cx| { + workspace + .open_workspace_for_paths(true, paths, window, cx) + .detach(); + }); + }) + .detach(); + } else { + use zed_actions::OpenRecent; + window.dispatch_action(OpenRecent::default().boxed_clone(), cx); + } + } + } + } + + fn render_recent_project_section( + &self, + recent_projects: Vec, + ) -> impl IntoElement { + v_flex() + .w_full() + .child(SectionHeader::new("Recent Projects")) + .children(recent_projects) + } + + fn render_recent_project( + &self, + index: usize, + location: &SerializedWorkspaceLocation, + paths: &PathList, + ) -> impl IntoElement { + let (icon, title) = match location { + SerializedWorkspaceLocation::Local => { + let path = paths.paths().first().map(|p| p.as_path()); + let name = path + .and_then(|p| p.file_name()) + .map(|n| n.to_string_lossy().to_string()) + .unwrap_or_else(|| "Untitled".to_string()); + (IconName::Folder, name) + } + SerializedWorkspaceLocation::Remote(_) => { + (IconName::Server, "Remote Project".to_string()) + } + }; + + SectionButton::new( + title, + icon, + &OpenRecentProject { index }, + 10, + self.focus_handle.clone(), + ) + } +} + +impl Render for WelcomePage { + fn render(&mut self, _: &mut Window, cx: &mut Context) -> impl IntoElement { + let (first_section, second_section) = CONTENT; + let first_section_entries = first_section.entries.len(); + let last_index = first_section_entries + second_section.entries.len(); + + let recent_projects = self + .recent_workspaces + .as_ref() + .into_iter() + .flatten() + .take(5) + .enumerate() + .map(|(index, (_, loc, paths))| self.render_recent_project(index, loc, paths)) + .collect::>(); + + let second_section = if self.fallback_to_recent_projects && !recent_projects.is_empty() { + self.render_recent_project_section(recent_projects) + .into_any_element() + } else { + second_section + .render(first_section_entries, &self.focus_handle, cx) + .into_any_element() + }; + + let welcome_label = if self.fallback_to_recent_projects { + "Welcome back to Zed" + } else { + "Welcome to Zed" + }; + + h_flex() + .key_context("Welcome") + .track_focus(&self.focus_handle(cx)) + .on_action(cx.listener(Self::select_previous)) + .on_action(cx.listener(Self::select_next)) + .on_action(cx.listener(Self::open_recent_project)) + .size_full() + .justify_center() + .overflow_hidden() + .bg(cx.theme().colors().editor_background) + .child( + h_flex() + .relative() + .size_full() + .px_12() + .py_40() + .max_w(px(1100.)) + .child( + v_flex() + .size_full() + .max_w_128() + .mx_auto() + .gap_6() + .overflow_x_hidden() + .child( + h_flex() + .w_full() + .justify_center() + .mb_4() + .gap_4() + .child(Vector::square(VectorName::ZedLogo, rems_from_px(45.))) + .child( + v_flex().child(Headline::new(welcome_label)).child( + Label::new("The editor for what's next") + .size(LabelSize::Small) + .color(Color::Muted) + .italic(), + ), + ), + ) + .child(first_section.render(Default::default(), &self.focus_handle, cx)) + .child(second_section) + .when(!self.fallback_to_recent_projects, |this| { + this.child( + v_flex().gap_1().child(Divider::horizontal()).child( + Button::new("welcome-exit", "Return to Onboarding") + .tab_index(last_index as isize) + .full_width() + .label_size(LabelSize::XSmall) + .on_click(|_, window, cx| { + window.dispatch_action( + OpenOnboarding.boxed_clone(), + cx, + ); + }), + ), + ) + }), + ), + ) + } +} + +impl EventEmitter for WelcomePage {} + +impl Focusable for WelcomePage { + fn focus_handle(&self, _: &App) -> gpui::FocusHandle { + self.focus_handle.clone() + } +} + +impl Item for WelcomePage { + type Event = ItemEvent; + + fn tab_content_text(&self, _detail: usize, _cx: &App) -> SharedString { + "Welcome".into() + } + + fn telemetry_event_text(&self) -> Option<&'static str> { + Some("New Welcome Page Opened") + } + + fn show_toolbar(&self) -> bool { + false + } + + fn to_item_events(event: &Self::Event, mut f: impl FnMut(crate::item::ItemEvent)) { + f(*event) + } +} + +impl crate::SerializableItem for WelcomePage { + fn serialized_item_kind() -> &'static str { + "WelcomePage" + } + + fn cleanup( + workspace_id: crate::WorkspaceId, + alive_items: Vec, + _window: &mut Window, + cx: &mut App, + ) -> Task> { + crate::delete_unloaded_items( + alive_items, + workspace_id, + "welcome_pages", + &persistence::WELCOME_PAGES, + cx, + ) + } + + fn deserialize( + _project: Entity, + workspace: gpui::WeakEntity, + workspace_id: crate::WorkspaceId, + item_id: crate::ItemId, + window: &mut Window, + cx: &mut App, + ) -> Task>> { + if persistence::WELCOME_PAGES + .get_welcome_page(item_id, workspace_id) + .ok() + .is_some_and(|is_open| is_open) + { + Task::ready(Ok( + cx.new(|cx| WelcomePage::new(workspace, false, window, cx)) + )) + } else { + Task::ready(Err(anyhow::anyhow!("No welcome page to deserialize"))) + } + } + + fn serialize( + &mut self, + workspace: &mut Workspace, + item_id: crate::ItemId, + _closing: bool, + _window: &mut Window, + cx: &mut Context, + ) -> Option>> { + let workspace_id = workspace.database_id()?; + Some(cx.background_spawn(async move { + persistence::WELCOME_PAGES + .save_welcome_page(item_id, workspace_id, true) + .await + })) + } + + fn should_serialize(&self, event: &Self::Event) -> bool { + event == &ItemEvent::UpdateTab + } +} + +mod persistence { + use crate::WorkspaceDb; + use db::{ + query, + sqlez::{domain::Domain, thread_safe_connection::ThreadSafeConnection}, + sqlez_macros::sql, + }; + + pub struct WelcomePagesDb(ThreadSafeConnection); + + impl Domain for WelcomePagesDb { + const NAME: &str = stringify!(WelcomePagesDb); + + const MIGRATIONS: &[&str] = (&[sql!( + CREATE TABLE welcome_pages ( + workspace_id INTEGER, + item_id INTEGER UNIQUE, + is_open INTEGER DEFAULT FALSE, + + PRIMARY KEY(workspace_id, item_id), + FOREIGN KEY(workspace_id) REFERENCES workspaces(workspace_id) + ON DELETE CASCADE + ) STRICT; + )]); + } + + db::static_connection!(WELCOME_PAGES, WelcomePagesDb, [WorkspaceDb]); + + impl WelcomePagesDb { + query! { + pub async fn save_welcome_page( + item_id: crate::ItemId, + workspace_id: crate::WorkspaceId, + is_open: bool + ) -> Result<()> { + INSERT OR REPLACE INTO welcome_pages(item_id, workspace_id, is_open) + VALUES (?, ?, ?) + } + } + + query! { + pub fn get_welcome_page( + item_id: crate::ItemId, + workspace_id: crate::WorkspaceId + ) -> Result { + SELECT is_open + FROM welcome_pages + WHERE item_id = ? AND workspace_id = ? + } + } + } +} diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index 7dfa5d634c73ee639be1e24373ca86b548180547..41304fd77f1eff8d890ff21a3051e57ce3ab295e 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -16,6 +16,7 @@ mod theme_preview; mod toast_layer; mod toolbar; pub mod utility_pane; +pub mod welcome; mod workspace_settings; pub use crate::notifications::NotificationFrame; diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rs index 6d94a15a666c6659f522d4b61962c932347b6304..674cc5f659f7a0d5d97eb7700505eb0ec4c5e5bc 100644 --- a/crates/zed/src/main.rs +++ b/crates/zed/src/main.rs @@ -1157,7 +1157,13 @@ async fn restore_or_create_workspace(app_state: Arc, cx: &mut AsyncApp app_state, cx, |workspace, window, cx| { - Editor::new_file(workspace, &Default::default(), window, cx) + let restore_on_startup = WorkspaceSettings::get_global(cx).restore_on_startup; + match restore_on_startup { + workspace::RestoreOnStartupBehavior::Launchpad => {} + _ => { + Editor::new_file(workspace, &Default::default(), window, cx); + } + } }, ) })? diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs index a51e38bfe48976c8bf12ae1d546f8a8421288af2..c1d98936aa2ad20e6eef7f18bfed2d2c0615395a 100644 --- a/crates/zed/src/zed.rs +++ b/crates/zed/src/zed.rs @@ -4801,6 +4801,7 @@ mod tests { "keymap_editor", "keystroke_input", "language_selector", + "welcome", "line_ending_selector", "lsp_tool", "markdown", diff --git a/crates/zed_actions/src/lib.rs b/crates/zed_actions/src/lib.rs index f69baa03b002fdcac5207f977a23cfc924283e2d..458ca10ecdf8915eef3ee69c6334b1a14cc0c219 100644 --- a/crates/zed_actions/src/lib.rs +++ b/crates/zed_actions/src/lib.rs @@ -70,6 +70,8 @@ actions!( OpenTelemetryLog, /// Opens the performance profiler. OpenPerformanceProfiler, + /// Opens the onboarding view. + OpenOnboarding, ] ); diff --git a/docs/src/configuring-zed.md b/docs/src/configuring-zed.md index 76c0b528fa106ae087297d3c9191ee70620116ba..549dbe6fbb47b03a372ee3ddac87b72dbc4d9c2e 100644 --- a/docs/src/configuring-zed.md +++ b/docs/src/configuring-zed.md @@ -3142,7 +3142,15 @@ List of strings containing any combination of: ```json [settings] { - "restore_on_startup": "none" + "restore_on_startup": "empty_tab" +} +``` + +4. Always start with the welcome launchpad: + +```json [settings] +{ + "restore_on_startup": "launchpad" } ``` From 33b71aea6488b285c98643e7bee9a90ea1067ded Mon Sep 17 00:00:00 2001 From: Mayank Verma Date: Tue, 16 Dec 2025 16:46:27 +0530 Subject: [PATCH 359/621] workspace: Use markdown to render LSP notification content (#44215) Closes #43657 Release Notes: - Improved LSP notification messages by adding markdown rendering with clickable URLs, inline code, etc.
Before After
screenshot-notification-before screenshot-notification-after
--------- Co-authored-by: Danilo Leal --- Cargo.lock | 1 + crates/workspace/Cargo.toml | 1 + crates/workspace/src/notifications.rs | 77 ++++++++++++++++++++++----- 3 files changed, 67 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 72a65994b9eee32b3b2c84c846e2825ffd0ff723..6d5d68fa9293a391ecfa1308c1c347a7cd48cb8b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -20101,6 +20101,7 @@ dependencies = [ "itertools 0.14.0", "language", "log", + "markdown", "menu", "node_runtime", "parking_lot", diff --git a/crates/workspace/Cargo.toml b/crates/workspace/Cargo.toml index c2554c63c4f6a1b9836a8ccc24ce4e567fefe601..956d63580404da351d34af3b5cf5fd531d5a0011 100644 --- a/crates/workspace/Cargo.toml +++ b/crates/workspace/Cargo.toml @@ -45,6 +45,7 @@ itertools.workspace = true language.workspace = true log.workspace = true menu.workspace = true +markdown.workspace = true node_runtime.workspace = true parking_lot.workspace = true postage.workspace = true diff --git a/crates/workspace/src/notifications.rs b/crates/workspace/src/notifications.rs index 6d37ea4d2a50637ae7c2e0287ae8f371e3b47aba..3b126d329e7fafefa4043661c5039f1e17b09b54 100644 --- a/crates/workspace/src/notifications.rs +++ b/crates/workspace/src/notifications.rs @@ -3,9 +3,12 @@ use anyhow::Context as _; use gpui::{ AnyView, App, AppContext as _, AsyncWindowContext, ClickEvent, ClipboardItem, Context, DismissEvent, Entity, EventEmitter, FocusHandle, Focusable, PromptLevel, Render, ScrollHandle, - Task, svg, + Task, TextStyleRefinement, UnderlineStyle, svg, }; +use markdown::{Markdown, MarkdownElement, MarkdownStyle}; use parking_lot::Mutex; +use settings::Settings; +use theme::ThemeSettings; use std::ops::Deref; use std::sync::{Arc, LazyLock}; @@ -216,6 +219,7 @@ pub struct LanguageServerPrompt { focus_handle: FocusHandle, request: Option, scroll_handle: ScrollHandle, + markdown: Entity, } impl Focusable for LanguageServerPrompt { @@ -228,10 +232,13 @@ impl Notification for LanguageServerPrompt {} impl LanguageServerPrompt { pub fn new(request: project::LanguageServerPromptRequest, cx: &mut App) -> Self { + let markdown = cx.new(|cx| Markdown::new(request.message.clone().into(), None, None, cx)); + Self { focus_handle: cx.focus_handle(), request: Some(request), scroll_handle: ScrollHandle::new(), + markdown, } } @@ -262,7 +269,7 @@ impl Render for LanguageServerPrompt { }; let (icon, color) = match request.level { - PromptLevel::Info => (IconName::Info, Color::Accent), + PromptLevel::Info => (IconName::Info, Color::Muted), PromptLevel::Warning => (IconName::Warning, Color::Warning), PromptLevel::Critical => (IconName::XCircle, Color::Error), }; @@ -291,16 +298,15 @@ impl Render for LanguageServerPrompt { .child( h_flex() .justify_between() - .items_start() .child( h_flex() .gap_2() - .child(Icon::new(icon).color(color)) + .child(Icon::new(icon).color(color).size(IconSize::Small)) .child(Label::new(request.lsp_name.clone())), ) .child( h_flex() - .gap_2() + .gap_1() .child( IconButton::new("copy", IconName::Copy) .on_click({ @@ -317,15 +323,17 @@ impl Render for LanguageServerPrompt { IconButton::new(close_id, close_icon) .tooltip(move |_window, cx| { if suppress { - Tooltip::for_action( - "Suppress.\nClose with click.", - &SuppressNotification, + Tooltip::with_meta( + "Suppress", + Some(&SuppressNotification), + "Click to close", cx, ) } else { - Tooltip::for_action( - "Close.\nSuppress with shift-click.", - &menu::Cancel, + Tooltip::with_meta( + "Close", + Some(&menu::Cancel), + "Suppress with shift-click", cx, ) } @@ -342,7 +350,16 @@ impl Render for LanguageServerPrompt { ), ), ) - .child(Label::new(request.message.to_string()).size(LabelSize::Small)) + .child( + MarkdownElement::new(self.markdown.clone(), markdown_style(window, cx)) + .text_size(TextSize::Small.rems(cx)) + .code_block_renderer(markdown::CodeBlockRenderer::Default { + copy_button: false, + copy_button_on_hover: false, + border: false, + }) + .on_url_click(|link, _, cx| cx.open_url(&link)), + ) .children(request.actions.iter().enumerate().map(|(ix, action)| { let this_handle = cx.entity(); Button::new(ix, action.title.clone()) @@ -369,6 +386,42 @@ fn workspace_error_notification_id() -> NotificationId { NotificationId::unique::() } +fn markdown_style(window: &Window, cx: &App) -> MarkdownStyle { + let settings = ThemeSettings::get_global(cx); + let ui_font_family = settings.ui_font.family.clone(); + let ui_font_fallbacks = settings.ui_font.fallbacks.clone(); + let buffer_font_family = settings.buffer_font.family.clone(); + let buffer_font_fallbacks = settings.buffer_font.fallbacks.clone(); + + let mut base_text_style = window.text_style(); + base_text_style.refine(&TextStyleRefinement { + font_family: Some(ui_font_family), + font_fallbacks: ui_font_fallbacks, + color: Some(cx.theme().colors().text), + ..Default::default() + }); + + MarkdownStyle { + base_text_style, + selection_background_color: cx.theme().colors().element_selection_background, + inline_code: TextStyleRefinement { + background_color: Some(cx.theme().colors().editor_background.opacity(0.5)), + font_family: Some(buffer_font_family), + font_fallbacks: buffer_font_fallbacks, + ..Default::default() + }, + link: TextStyleRefinement { + underline: Some(UnderlineStyle { + thickness: px(1.), + color: Some(cx.theme().colors().text_accent), + wavy: false, + }), + ..Default::default() + }, + ..Default::default() + } +} + #[derive(Debug, Clone)] pub struct ErrorMessagePrompt { message: SharedString, From c3b08609094a4442d7b7a85a4de89553e4f16c3e Mon Sep 17 00:00:00 2001 From: Michael Benfield Date: Tue, 16 Dec 2025 03:25:59 -0800 Subject: [PATCH 360/621] Remove CopyAsMarkdown (#44933) Copying rendered markdown doesn't reliably do anything sensible. If we copy text from the middle of a bold section, no formatting is copied. If we copy text at the end, the trailing bold delimiters are copied, resulting in gibberish markdown. Thus even fixing the associated issue (so that leading delimeters are reliably copied) won't consistently produce good results. Also, as the user messages in the agent panel don't render markdown anyway, it seems the most likely use case for copying markdown is inapplicable. Closes #42958 Release Notes: - N/A --- assets/keymaps/default-linux.json | 6 +++--- assets/keymaps/default-macos.json | 2 +- assets/keymaps/default-windows.json | 2 +- crates/markdown/src/markdown.rs | 18 ------------------ 4 files changed, 5 insertions(+), 23 deletions(-) diff --git a/assets/keymaps/default-linux.json b/assets/keymaps/default-linux.json index bb49582ce0e939a5c43c24862a4e50f9d82125d2..38ef7d092d534163ead569c522227b089f84af99 100644 --- a/assets/keymaps/default-linux.json +++ b/assets/keymaps/default-linux.json @@ -262,9 +262,9 @@ { "context": "AgentPanel > Markdown", "bindings": { - "copy": "markdown::CopyAsMarkdown", - "ctrl-insert": "markdown::CopyAsMarkdown", - "ctrl-c": "markdown::CopyAsMarkdown", + "copy": "markdown::Copy", + "ctrl-insert": "markdown::Copy", + "ctrl-c": "markdown::Copy", }, }, { diff --git a/assets/keymaps/default-macos.json b/assets/keymaps/default-macos.json index 3c6ec6e0423e5ea254ddcd9690f92ac11e0fa73a..8a0e3dfdcddbd448e6a6b9bf66f3731153208120 100644 --- a/assets/keymaps/default-macos.json +++ b/assets/keymaps/default-macos.json @@ -303,7 +303,7 @@ "context": "AgentPanel > Markdown", "use_key_equivalents": true, "bindings": { - "cmd-c": "markdown::CopyAsMarkdown", + "cmd-c": "markdown::Copy", }, }, { diff --git a/assets/keymaps/default-windows.json b/assets/keymaps/default-windows.json index b15313fe75cc1265b5eb0c5560f26e4c148d4336..e344ea356fb171fb07474f498056df73c73d8307 100644 --- a/assets/keymaps/default-windows.json +++ b/assets/keymaps/default-windows.json @@ -265,7 +265,7 @@ "context": "AgentPanel > Markdown", "use_key_equivalents": true, "bindings": { - "ctrl-c": "markdown::CopyAsMarkdown", + "ctrl-c": "markdown::Copy", }, }, { diff --git a/crates/markdown/src/markdown.rs b/crates/markdown/src/markdown.rs index 6f4ebe4a91f2cee344c1d82ff70722406251434d..270192107c13e8ddfc5eba1b3e6e8e298b93125a 100644 --- a/crates/markdown/src/markdown.rs +++ b/crates/markdown/src/markdown.rs @@ -149,8 +149,6 @@ actions!( [ /// Copies the selected text to the clipboard. Copy, - /// Copies the selected text as markdown to the clipboard. - CopyAsMarkdown ] ); @@ -295,14 +293,6 @@ impl Markdown { cx.write_to_clipboard(ClipboardItem::new_string(text)); } - fn copy_as_markdown(&self, _: &mut Window, cx: &mut Context) { - if self.selection.end <= self.selection.start { - return; - } - let text = self.source[self.selection.start..self.selection.end].to_string(); - cx.write_to_clipboard(ClipboardItem::new_string(text)); - } - fn parse(&mut self, cx: &mut Context) { if self.source.is_empty() { return; @@ -1360,14 +1350,6 @@ impl Element for MarkdownElement { } } }); - window.on_action(std::any::TypeId::of::(), { - let entity = self.markdown.clone(); - move |_, phase, window, cx| { - if phase == DispatchPhase::Bubble { - entity.update(cx, move |this, cx| this.copy_as_markdown(window, cx)) - } - } - }); self.paint_mouse_listeners(hitbox, &rendered_markdown.text, window, cx); rendered_markdown.element.paint(window, cx); From 2178ad6b9146b30cd2915b1c4d886640e0671164 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Tue, 16 Dec 2025 13:33:22 +0200 Subject: [PATCH 361/621] Remove unneccessary snapshot storing in the buffer chunks (#44972) Release Notes: - N/A Co-authored-by: Lukas Wirth --- crates/language/src/buffer.rs | 6 +- crates/language/src/buffer/row_chunk.rs | 62 +++++++++---------- crates/project/src/lsp_store.rs | 21 +++++-- .../project/src/lsp_store/inlay_hint_cache.rs | 11 +--- 4 files changed, 50 insertions(+), 50 deletions(-) diff --git a/crates/language/src/buffer.rs b/crates/language/src/buffer.rs index 22fcbf5ee85c0f42de8097526df4a5fdc383ac35..59795c375ab9b663339dbbebccc60062058c6ef9 100644 --- a/crates/language/src/buffer.rs +++ b/crates/language/src/buffer.rs @@ -4317,14 +4317,12 @@ impl BufferSnapshot { for chunk in self .tree_sitter_data .chunks - .applicable_chunks(&[self.anchor_before(range.start)..self.anchor_after(range.end)]) + .applicable_chunks(&[range.to_point(self)]) { if known_chunks.is_some_and(|chunks| chunks.contains(&chunk.row_range())) { continue; } - let Some(chunk_range) = self.tree_sitter_data.chunks.chunk_range(chunk) else { - continue; - }; + let chunk_range = chunk.anchor_range(); let chunk_range = chunk_range.to_offset(&self); if let Some(cached_brackets) = diff --git a/crates/language/src/buffer/row_chunk.rs b/crates/language/src/buffer/row_chunk.rs index e4ef5227e690a9912257ea00edc2b5f722326ae3..0f3c0b5afb1cc1a2d60a2a568fe00403733ef5c6 100644 --- a/crates/language/src/buffer/row_chunk.rs +++ b/crates/language/src/buffer/row_chunk.rs @@ -3,7 +3,6 @@ use std::{ops::Range, sync::Arc}; -use clock::Global; use text::{Anchor, OffsetRangeExt as _, Point}; use util::RangeExt; @@ -19,14 +18,13 @@ use crate::BufferRow; /// #[derive(Clone)] pub struct RowChunks { - snapshot: text::BufferSnapshot, chunks: Arc<[RowChunk]>, + version: clock::Global, } impl std::fmt::Debug for RowChunks { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_struct("RowChunks") - .field("version", self.snapshot.version()) .field("chunks", &self.chunks) .finish() } @@ -38,34 +36,45 @@ impl RowChunks { let last_row = buffer_point_range.end.row; let chunks = (buffer_point_range.start.row..=last_row) .step_by(max_rows_per_chunk as usize) + .collect::>(); + let last_chunk_id = chunks.len() - 1; + let chunks = chunks + .into_iter() .enumerate() - .map(|(id, chunk_start)| RowChunk { - id, - start: chunk_start, - end_exclusive: (chunk_start + max_rows_per_chunk).min(last_row), + .map(|(id, chunk_start)| { + let start = Point::new(chunk_start, 0); + let end_exclusive = (chunk_start + max_rows_per_chunk).min(last_row); + let end = if id == last_chunk_id { + Point::new(end_exclusive, snapshot.line_len(end_exclusive)) + } else { + Point::new(end_exclusive, 0) + }; + RowChunk { + id, + start: chunk_start, + end_exclusive, + start_anchor: snapshot.anchor_before(start), + end_anchor: snapshot.anchor_after(end), + } }) .collect::>(); Self { - snapshot, chunks: Arc::from(chunks), + version: snapshot.version().clone(), } } - pub fn version(&self) -> &Global { - self.snapshot.version() + pub fn version(&self) -> &clock::Global { + &self.version } pub fn len(&self) -> usize { self.chunks.len() } - pub fn applicable_chunks( - &self, - ranges: &[Range], - ) -> impl Iterator { + pub fn applicable_chunks(&self, ranges: &[Range]) -> impl Iterator { let row_ranges = ranges .iter() - .map(|range| range.to_point(&self.snapshot)) // Be lenient and yield multiple chunks if they "touch" the exclusive part of the range. // This will result in LSP hints [re-]queried for more ranges, but also more hints already visible when scrolling around. .map(|point_range| point_range.start.row..point_range.end.row + 1) @@ -81,23 +90,6 @@ impl RowChunks { .copied() } - pub fn chunk_range(&self, chunk: RowChunk) -> Option> { - if !self.chunks.contains(&chunk) { - return None; - } - - let start = Point::new(chunk.start, 0); - let end = if self.chunks.last() == Some(&chunk) { - Point::new( - chunk.end_exclusive, - self.snapshot.line_len(chunk.end_exclusive), - ) - } else { - Point::new(chunk.end_exclusive, 0) - }; - Some(self.snapshot.anchor_before(start)..self.snapshot.anchor_after(end)) - } - pub fn previous_chunk(&self, chunk: RowChunk) -> Option { if chunk.id == 0 { None @@ -112,10 +104,16 @@ pub struct RowChunk { pub id: usize, pub start: BufferRow, pub end_exclusive: BufferRow, + pub start_anchor: Anchor, + pub end_anchor: Anchor, } impl RowChunk { pub fn row_range(&self) -> Range { self.start..self.end_exclusive } + + pub fn anchor_range(&self) -> Range { + self.start_anchor..self.end_anchor + } } diff --git a/crates/project/src/lsp_store.rs b/crates/project/src/lsp_store.rs index a8c639fe5930bf8c71d8bca5f2455364826c3514..b107be8b9ff32ef078d92700b46210a3c35c2845 100644 --- a/crates/project/src/lsp_store.rs +++ b/crates/project/src/lsp_store.rs @@ -6849,9 +6849,15 @@ impl LspStore { ranges: &[Range], cx: &mut Context, ) -> Vec> { + let buffer_snapshot = buffer.read(cx).snapshot(); + let ranges = ranges + .iter() + .map(|range| range.to_point(&buffer_snapshot)) + .collect::>(); + self.latest_lsp_data(buffer, cx) .inlay_hints - .applicable_chunks(ranges) + .applicable_chunks(ranges.as_slice()) .map(|chunk| chunk.row_range()) .collect() } @@ -6898,6 +6904,12 @@ impl LspStore { .map(|(_, known_chunks)| known_chunks) .unwrap_or_default(); + let buffer_snapshot = buffer.read(cx).snapshot(); + let ranges = ranges + .iter() + .map(|range| range.to_point(&buffer_snapshot)) + .collect::>(); + let mut hint_fetch_tasks = Vec::new(); let mut cached_inlay_hints = None; let mut ranges_to_query = None; @@ -6922,9 +6934,7 @@ impl LspStore { .cloned(), ) { (None, None) => { - let Some(chunk_range) = existing_inlay_hints.chunk_range(row_chunk) else { - continue; - }; + let chunk_range = row_chunk.anchor_range(); ranges_to_query .get_or_insert_with(Vec::new) .push((row_chunk, chunk_range)); @@ -12726,10 +12736,11 @@ impl LspStore { .update(cx, |buffer, _| buffer.wait_for_version(version))? .await?; lsp_store.update(cx, |lsp_store, cx| { + let buffer_snapshot = buffer.read(cx).snapshot(); let lsp_data = lsp_store.latest_lsp_data(&buffer, cx); let chunks_queried_for = lsp_data .inlay_hints - .applicable_chunks(&[range]) + .applicable_chunks(&[range.to_point(&buffer_snapshot)]) .collect::>(); match chunks_queried_for.as_slice() { &[chunk] => { diff --git a/crates/project/src/lsp_store/inlay_hint_cache.rs b/crates/project/src/lsp_store/inlay_hint_cache.rs index 804552b52cee9f31799e12f3c42e0614291eeab9..0cd9698e74bbfa4c53ad58569ebf59db99b5decd 100644 --- a/crates/project/src/lsp_store/inlay_hint_cache.rs +++ b/crates/project/src/lsp_store/inlay_hint_cache.rs @@ -8,7 +8,7 @@ use language::{ row_chunk::{RowChunk, RowChunks}, }; use lsp::LanguageServerId; -use text::Anchor; +use text::Point; use crate::{InlayHint, InlayId}; @@ -90,10 +90,7 @@ impl BufferInlayHints { } } - pub fn applicable_chunks( - &self, - ranges: &[Range], - ) -> impl Iterator { + pub fn applicable_chunks(&self, ranges: &[Range]) -> impl Iterator { self.chunks.applicable_chunks(ranges) } @@ -226,8 +223,4 @@ impl BufferInlayHints { } } } - - pub fn chunk_range(&self, chunk: RowChunk) -> Option> { - self.chunks.chunk_range(chunk) - } } From ba24ac7aae456dc3862fcd569a5041388d05f96c Mon Sep 17 00:00:00 2001 From: Luca <45566784+LuggaPugga@users.noreply.github.com> Date: Tue, 16 Dec 2025 12:35:45 +0100 Subject: [PATCH 362/621] fix: updated cursor linux keymap to use new AcceptNextWordEditPrediction (#44971) ### Problem PR #44411 replaced the `editor::AcceptPartialEditPrediction` action with `editor::AcceptNextLineEditPrediction` and `editor::AcceptNextWordEditPrediction`. However, the Linux cursor keymap wasn't updated to reflect this change, causing a panic on startup for Linux users. ### Solution Updated the Linux keymap configuration to reference the new actions Release Notes: - N/A --- assets/keymaps/linux/cursor.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/assets/keymaps/linux/cursor.json b/assets/keymaps/linux/cursor.json index 53f38234bb47a0f7c4412bf767e3eedf0465ba2a..58a7309cf902a3f69f949830cace2200f41fb0fe 100644 --- a/assets/keymaps/linux/cursor.json +++ b/assets/keymaps/linux/cursor.json @@ -70,7 +70,8 @@ "context": "Editor && mode == full && edit_prediction", "use_key_equivalents": true, "bindings": { - "ctrl-right": "editor::AcceptPartialEditPrediction", + "ctrl-right": "editor::AcceptNextWordEditPrediction", + "ctrl-down": "editor::AcceptNextLineEditPrediction", }, }, { From f358b9531a3311b449c3fde41a04f7bfc0c574f2 Mon Sep 17 00:00:00 2001 From: Smit Barmase Date: Tue, 16 Dec 2025 17:09:11 +0530 Subject: [PATCH 363/621] gpui: Add grid repeat min content API (#44973) Required for https://github.com/zed-industries/zed/pull/44712 We started using `grid` for Markdown tables instead of flex. This resulted in tables having a width of 0 inside popovers, since popovers are laid out using `AvailableSpace::MinContent`. One way to fix this is to lay out popovers using `MaxContent` instead. But that would affect all Markdown rendered in popovers and could change how popovers look, or regress things. The other option is to fix it where the problem actually is: `repeat(count, vec![minmax(length(0.0), fr(1.0))])`. Since the minimum width here is `0`, laying things out with `MinContent` causes the Markdown table to shrink completely. What we want instead is for the minimum width to be the min-content size, but only for Markdown rendered inside popovers. This PR does exactly that, without interfering with the `grid_cols` API, which intentionally follows a TailwindCSS-like convention. See https://github.com/zed-industries/zed/pull/44368 for context. Release Notes: - N/A --- crates/gpui/src/style.rs | 5 +++++ crates/gpui/src/styled.rs | 7 +++++++ crates/gpui/src/taffy.rs | 15 ++++++++++++++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/crates/gpui/src/style.rs b/crates/gpui/src/style.rs index 446c3ad2a325681a39689577a261ed1ffdde6d5b..4d6e6f490d81d967692a3e9d8316af75a7a4d306 100644 --- a/crates/gpui/src/style.rs +++ b/crates/gpui/src/style.rs @@ -265,6 +265,10 @@ pub struct Style { /// Equivalent to the Tailwind `grid-cols-` pub grid_cols: Option, + /// The grid columns with min-content minimum sizing. + /// Unlike grid_cols, it won't shrink to width 0 in AvailableSpace::MinContent constraints. + pub grid_cols_min_content: Option, + /// The row span of this element /// Equivalent to the Tailwind `grid-rows-` pub grid_rows: Option, @@ -772,6 +776,7 @@ impl Default for Style { opacity: None, grid_rows: None, grid_cols: None, + grid_cols_min_content: None, grid_location: None, #[cfg(debug_assertions)] diff --git a/crates/gpui/src/styled.rs b/crates/gpui/src/styled.rs index e01649be481e27f89643db2ffb3a9ccd294b9b73..e8088a84d7fc141d0a320988c6399afe2b93ce07 100644 --- a/crates/gpui/src/styled.rs +++ b/crates/gpui/src/styled.rs @@ -637,6 +637,13 @@ pub trait Styled: Sized { self } + /// Sets the grid columns with min-content minimum sizing. + /// Unlike grid_cols, it won't shrink to width 0 in AvailableSpace::MinContent constraints. + fn grid_cols_min_content(mut self, cols: u16) -> Self { + self.style().grid_cols_min_content = Some(cols); + self + } + /// Sets the grid rows of this element. fn grid_rows(mut self, rows: u16) -> Self { self.style().grid_rows = Some(rows); diff --git a/crates/gpui/src/taffy.rs b/crates/gpui/src/taffy.rs index 11cb0872861321c3c06c3f8a5bf79fdd30eb2275..99a50b87c8aa9f40a7694f1c2084b10f6d0a9315 100644 --- a/crates/gpui/src/taffy.rs +++ b/crates/gpui/src/taffy.rs @@ -8,6 +8,7 @@ use std::{fmt::Debug, ops::Range}; use taffy::{ TaffyTree, TraversePartialTree as _, geometry::{Point as TaffyPoint, Rect as TaffyRect, Size as TaffySize}, + prelude::min_content, style::AvailableSpace as TaffyAvailableSpace, tree::NodeId, }; @@ -314,6 +315,14 @@ impl ToTaffy for Style { .unwrap_or_default() } + fn to_grid_repeat_min_content( + unit: &Option, + ) -> Vec> { + // grid-template-columns: repeat(, minmax(min-content, 1fr)); + unit.map(|count| vec![repeat(count, vec![minmax(min_content(), fr(1.0))])]) + .unwrap_or_default() + } + taffy::style::Style { display: self.display.into(), overflow: self.overflow.into(), @@ -338,7 +347,11 @@ impl ToTaffy for Style { flex_grow: self.flex_grow, flex_shrink: self.flex_shrink, grid_template_rows: to_grid_repeat(&self.grid_rows), - grid_template_columns: to_grid_repeat(&self.grid_cols), + grid_template_columns: if self.grid_cols_min_content.is_some() { + to_grid_repeat_min_content(&self.grid_cols_min_content) + } else { + to_grid_repeat(&self.grid_cols) + }, grid_row: self .grid_location .as_ref() From 30deb22ab7f0ae7d8c2df879176789cfaa948b44 Mon Sep 17 00:00:00 2001 From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Date: Tue, 16 Dec 2025 09:04:07 -0300 Subject: [PATCH 364/621] agent_ui: Add the ability to delete a profile through the UI (#44977) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It was only possible to delete profiles through the `settings.json`, but now you can do it through the UI: Screenshot 2025-12-16 at 8  42@2x Release Notes: - agent: Added the ability to delete a profile through the "Manage Profiles" modal. --- .../manage_profiles_modal.rs | 86 +++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/crates/agent_ui/src/agent_configuration/manage_profiles_modal.rs b/crates/agent_ui/src/agent_configuration/manage_profiles_modal.rs index 2f17349c3d1da1cf68a3ab513ccad434a115087b..ed00b2b5c716fdf27abc1c9d7c5850b36fce830f 100644 --- a/crates/agent_ui/src/agent_configuration/manage_profiles_modal.rs +++ b/crates/agent_ui/src/agent_configuration/manage_profiles_modal.rs @@ -8,6 +8,7 @@ use editor::Editor; use fs::Fs; use gpui::{DismissEvent, Entity, EventEmitter, FocusHandle, Focusable, Subscription, prelude::*}; use language_model::{LanguageModel, LanguageModelRegistry}; +use settings::SettingsStore; use settings::{ LanguageModelProviderSetting, LanguageModelSelection, Settings as _, update_settings_file, }; @@ -94,6 +95,7 @@ pub struct ViewProfileMode { configure_default_model: NavigableEntry, configure_tools: NavigableEntry, configure_mcps: NavigableEntry, + delete_profile: NavigableEntry, cancel_item: NavigableEntry, } @@ -109,6 +111,7 @@ pub struct ManageProfilesModal { active_model: Option>, focus_handle: FocusHandle, mode: Mode, + _settings_subscription: Subscription, } impl ManageProfilesModal { @@ -148,12 +151,23 @@ impl ManageProfilesModal { ) -> Self { let focus_handle = cx.focus_handle(); + // Keep this modal in sync with settings changes (including profile deletion). + let settings_subscription = + cx.observe_global_in::(window, |this, window, cx| { + if matches!(this.mode, Mode::ChooseProfile(_)) { + this.mode = Mode::choose_profile(window, cx); + this.focus_handle(cx).focus(window); + cx.notify(); + } + }); + Self { fs, active_model, context_server_registry, focus_handle, mode: Mode::choose_profile(window, cx), + _settings_subscription: settings_subscription, } } @@ -192,6 +206,7 @@ impl ManageProfilesModal { configure_default_model: NavigableEntry::focusable(cx), configure_tools: NavigableEntry::focusable(cx), configure_mcps: NavigableEntry::focusable(cx), + delete_profile: NavigableEntry::focusable(cx), cancel_item: NavigableEntry::focusable(cx), }); self.focus_handle(cx).focus(window); @@ -369,6 +384,42 @@ impl ManageProfilesModal { } } + fn delete_profile( + &mut self, + profile_id: AgentProfileId, + window: &mut Window, + cx: &mut Context, + ) { + if builtin_profiles::is_builtin(&profile_id) { + self.view_profile(profile_id, window, cx); + return; + } + + let fs = self.fs.clone(); + + update_settings_file(fs, cx, move |settings, _cx| { + let Some(agent_settings) = settings.agent.as_mut() else { + return; + }; + + let Some(profiles) = agent_settings.profiles.as_mut() else { + return; + }; + + profiles.shift_remove(profile_id.0.as_ref()); + + if agent_settings + .default_profile + .as_deref() + .is_some_and(|default_profile| default_profile == profile_id.0.as_ref()) + { + agent_settings.default_profile = Some(AgentProfileId::default().0); + } + }); + + self.choose_profile(window, cx); + } + fn cancel(&mut self, window: &mut Window, cx: &mut Context) { match &self.mode { Mode::ChooseProfile { .. } => { @@ -756,6 +807,40 @@ impl ManageProfilesModal { }), ), ) + .child( + div() + .id("delete-profile") + .track_focus(&mode.delete_profile.focus_handle) + .on_action({ + let profile_id = mode.profile_id.clone(); + cx.listener(move |this, _: &menu::Confirm, window, cx| { + this.delete_profile(profile_id.clone(), window, cx); + }) + }) + .child( + ListItem::new("delete-profile") + .toggle_state( + mode.delete_profile + .focus_handle + .contains_focused(window, cx), + ) + .inset(true) + .spacing(ListItemSpacing::Sparse) + .start_slot( + Icon::new(IconName::Trash) + .size(IconSize::Small) + .color(Color::Error), + ) + .child(Label::new("Delete Profile").color(Color::Error)) + .disabled(builtin_profiles::is_builtin(&mode.profile_id)) + .on_click({ + let profile_id = mode.profile_id.clone(); + cx.listener(move |this, _, window, cx| { + this.delete_profile(profile_id.clone(), window, cx); + }) + }), + ), + ) .child(ListSeparator) .child( div() @@ -805,6 +890,7 @@ impl ManageProfilesModal { .entry(mode.configure_default_model) .entry(mode.configure_tools) .entry(mode.configure_mcps) + .entry(mode.delete_profile) .entry(mode.cancel_item) } } From 4e482288cb42fc998e6af18b87d643940c5fa3bf Mon Sep 17 00:00:00 2001 From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Date: Tue, 16 Dec 2025 09:15:08 -0300 Subject: [PATCH 365/621] agent_ui: Add keybinding to cycle through profiles (#44979) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Similar to the mode selector in external agents, it will now be possible to use `shift-tab` to cycle through profiles. Screenshot 2025-12-16 at 9  04@2x Release Notes: - Added the ability to use `shift-tab` to cycle through profiles for the built-in Zed agent. --- crates/agent_ui/src/acp/thread_view.rs | 6 ++- crates/agent_ui/src/profile_selector.rs | 56 +++++++++++++++++++++---- 2 files changed, 52 insertions(+), 10 deletions(-) diff --git a/crates/agent_ui/src/acp/thread_view.rs b/crates/agent_ui/src/acp/thread_view.rs index 6cd2ec2fa3442bbf4961dffb0c4538ac9615d982..bc449c3c3a0238a5989c52abec029a708bf9f0ba 100644 --- a/crates/agent_ui/src/acp/thread_view.rs +++ b/crates/agent_ui/src/acp/thread_view.rs @@ -4208,7 +4208,11 @@ impl AcpThreadView { } })) .on_action(cx.listener(|this, _: &CycleModeSelector, window, cx| { - if let Some(mode_selector) = this.mode_selector() { + if let Some(profile_selector) = this.profile_selector.as_ref() { + profile_selector.update(cx, |profile_selector, cx| { + profile_selector.cycle_profile(cx); + }); + } else if let Some(mode_selector) = this.mode_selector() { mode_selector.update(cx, |mode_selector, cx| { mode_selector.cycle_mode(window, cx); }); diff --git a/crates/agent_ui/src/profile_selector.rs b/crates/agent_ui/src/profile_selector.rs index 0182be0912d3b8a8a046371ce725e7d21a0ddb58..ac08070fcefa92854b51bc8a66d4d388d08e087d 100644 --- a/crates/agent_ui/src/profile_selector.rs +++ b/crates/agent_ui/src/profile_selector.rs @@ -1,4 +1,4 @@ -use crate::{ManageProfiles, ToggleProfileSelector}; +use crate::{CycleModeSelector, ManageProfiles, ToggleProfileSelector}; use agent_settings::{ AgentProfile, AgentProfileId, AgentSettings, AvailableProfiles, builtin_profiles, }; @@ -70,6 +70,29 @@ impl ProfileSelector { self.picker_handle.clone() } + pub fn cycle_profile(&mut self, cx: &mut Context) { + if !self.provider.profiles_supported(cx) { + return; + } + + let profiles = AgentProfile::available_profiles(cx); + if profiles.is_empty() { + return; + } + + let current_profile_id = self.provider.profile_id(cx); + let current_index = profiles + .keys() + .position(|id| id == ¤t_profile_id) + .unwrap_or(0); + + let next_index = (current_index + 1) % profiles.len(); + + if let Some((next_profile_id, _)) = profiles.get_index(next_index) { + self.provider.set_profile(next_profile_id.clone(), cx); + } + } + fn ensure_picker( &mut self, window: &mut Window, @@ -163,14 +186,29 @@ impl Render for ProfileSelector { PickerPopoverMenu::new( picker, trigger_button, - move |_window, cx| { - Tooltip::for_action_in( - "Toggle Profile Menu", - &ToggleProfileSelector, - &focus_handle, - cx, - ) - }, + Tooltip::element({ + move |_window, cx| { + let container = || h_flex().gap_1().justify_between(); + v_flex() + .gap_1() + .child( + container() + .pb_1() + .border_b_1() + .border_color(cx.theme().colors().border_variant) + .child(Label::new("Cycle Through Profiles")) + .child(KeyBinding::for_action_in( + &CycleModeSelector, + &focus_handle, + cx, + )), + ) + .child(container().child(Label::new("Toggle Profile Menu")).child( + KeyBinding::for_action_in(&ToggleProfileSelector, &focus_handle, cx), + )) + .into_any() + } + }), gpui::Corner::BottomRight, cx, ) From 5152fd898ef941d607abf07317dbf9edc27e998c Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Tue, 16 Dec 2025 13:35:47 +0100 Subject: [PATCH 366/621] agent_ui: Add scroll to most recent user prompt button (#44961) Release Notes: - Added a button to the agent thread view that scrolls to the most recent prompt --- crates/agent_ui/src/acp/thread_view.rs | 103 ++++++++++++++++++++++++- 1 file changed, 102 insertions(+), 1 deletion(-) diff --git a/crates/agent_ui/src/acp/thread_view.rs b/crates/agent_ui/src/acp/thread_view.rs index bc449c3c3a0238a5989c52abec029a708bf9f0ba..f5e5b6c3b261d5c82bf8d3fc3fc13d482e69ca7d 100644 --- a/crates/agent_ui/src/acp/thread_view.rs +++ b/crates/agent_ui/src/acp/thread_view.rs @@ -693,7 +693,7 @@ impl AcpThreadView { this.new_server_version_available = Some(new_version.into()); cx.notify(); }) - .log_err(); + .ok(); } } }) @@ -4863,6 +4863,32 @@ impl AcpThreadView { cx.notify(); } + fn scroll_to_most_recent_user_prompt(&mut self, cx: &mut Context) { + let Some(thread) = self.thread() else { + return; + }; + + let entries = thread.read(cx).entries(); + if entries.is_empty() { + return; + } + + // Find the most recent user message and scroll it to the top of the viewport. + // (Fallback: if no user message exists, scroll to the bottom.) + if let Some(ix) = entries + .iter() + .rposition(|entry| matches!(entry, AgentThreadEntry::UserMessage(_))) + { + self.list_state.scroll_to(ListOffset { + item_ix: ix, + offset_in_item: px(0.0), + }); + cx.notify(); + } else { + self.scroll_to_bottom(cx); + } + } + pub fn scroll_to_bottom(&mut self, cx: &mut Context) { if let Some(thread) = self.thread() { let entry_count = thread.read(cx).entries().len(); @@ -5081,6 +5107,16 @@ impl AcpThreadView { } })); + let scroll_to_recent_user_prompt = + IconButton::new("scroll_to_recent_user_prompt", IconName::ForwardArrow) + .shape(ui::IconButtonShape::Square) + .icon_size(IconSize::Small) + .icon_color(Color::Ignored) + .tooltip(Tooltip::text("Scroll To Most Recent User Prompt")) + .on_click(cx.listener(move |this, _, _, cx| { + this.scroll_to_most_recent_user_prompt(cx); + })); + let scroll_to_top = IconButton::new("scroll_to_top", IconName::ArrowUp) .shape(ui::IconButtonShape::Square) .icon_size(IconSize::Small) @@ -5157,6 +5193,7 @@ impl AcpThreadView { container .child(open_as_markdown) + .child(scroll_to_recent_user_prompt) .child(scroll_to_top) .into_any_element() } @@ -6789,6 +6826,70 @@ pub(crate) mod tests { }); } + #[gpui::test] + async fn test_scroll_to_most_recent_user_prompt(cx: &mut TestAppContext) { + init_test(cx); + + let connection = StubAgentConnection::new(); + + // Each user prompt will result in a user message entry plus an agent message entry. + connection.set_next_prompt_updates(vec![acp::SessionUpdate::AgentMessageChunk( + acp::ContentChunk::new("Response 1".into()), + )]); + + let (thread_view, cx) = + setup_thread_view(StubAgentServer::new(connection.clone()), cx).await; + + let thread = thread_view + .read_with(cx, |view, _| view.thread().cloned()) + .unwrap(); + + thread + .update(cx, |thread, cx| thread.send_raw("Prompt 1", cx)) + .await + .unwrap(); + cx.run_until_parked(); + + connection.set_next_prompt_updates(vec![acp::SessionUpdate::AgentMessageChunk( + acp::ContentChunk::new("Response 2".into()), + )]); + + thread + .update(cx, |thread, cx| thread.send_raw("Prompt 2", cx)) + .await + .unwrap(); + cx.run_until_parked(); + + // Move somewhere else first so we're not trivially already on the last user prompt. + thread_view.update(cx, |view, cx| { + view.scroll_to_top(cx); + }); + cx.run_until_parked(); + + thread_view.update(cx, |view, cx| { + view.scroll_to_most_recent_user_prompt(cx); + let scroll_top = view.list_state.logical_scroll_top(); + // Entries layout is: [User1, Assistant1, User2, Assistant2] + assert_eq!(scroll_top.item_ix, 2); + }); + } + + #[gpui::test] + async fn test_scroll_to_most_recent_user_prompt_falls_back_to_bottom_without_user_messages( + cx: &mut TestAppContext, + ) { + init_test(cx); + + let (thread_view, cx) = setup_thread_view(StubAgentServer::default_response(), cx).await; + + // With no entries, scrolling should be a no-op and must not panic. + thread_view.update(cx, |view, cx| { + view.scroll_to_most_recent_user_prompt(cx); + let scroll_top = view.list_state.logical_scroll_top(); + assert_eq!(scroll_top.item_ix, 0); + }); + } + #[gpui::test] async fn test_message_editing_cancel(cx: &mut TestAppContext) { init_test(cx); From 68295ba3713b00ddebaa8de81f166085d4fe5fc6 Mon Sep 17 00:00:00 2001 From: Smit Barmase Date: Tue, 16 Dec 2025 18:11:06 +0530 Subject: [PATCH 367/621] markdown: Fix Markdown table not rendering in hover popover (#44712) Closes #44306 This PR makes two changes: - Uses the new `grid_cols_min_content` API. See more here: https://github.com/zed-industries/zed/pull/44973. - Changes Markdown table rendering to use a single grid instead of creating a new grid per row, so column widths stay consistent across rows. Release Notes: - Fixed an issue where Markdown tables wouldn't render in the hover popover. --- crates/editor/src/hover_popover.rs | 2 ++ crates/markdown/src/markdown.rs | 56 ++++++++++++++++++------------ 2 files changed, 35 insertions(+), 23 deletions(-) diff --git a/crates/editor/src/hover_popover.rs b/crates/editor/src/hover_popover.rs index 7c3e41e8c2edf721fbcae729069eecb640e2246c..64415005ec61b1ce942e4fbedaabc70919f5e61d 100644 --- a/crates/editor/src/hover_popover.rs +++ b/crates/editor/src/hover_popover.rs @@ -656,6 +656,7 @@ pub fn hover_markdown_style(window: &Window, cx: &App) -> MarkdownStyle { .text_base() .mt(rems(1.)) .mb_0(), + table_columns_min_size: true, ..Default::default() } } @@ -709,6 +710,7 @@ pub fn diagnostics_markdown_style(window: &Window, cx: &App) -> MarkdownStyle { .font_weight(FontWeight::BOLD) .text_base() .mb_0(), + table_columns_min_size: true, ..Default::default() } } diff --git a/crates/markdown/src/markdown.rs b/crates/markdown/src/markdown.rs index 270192107c13e8ddfc5eba1b3e6e8e298b93125a..50de82fb5f24bd0328123ada86d80d073b675801 100644 --- a/crates/markdown/src/markdown.rs +++ b/crates/markdown/src/markdown.rs @@ -70,6 +70,7 @@ pub struct MarkdownStyle { pub heading_level_styles: Option, pub height_is_multiple_of_line_height: bool, pub prevent_mouse_interaction: bool, + pub table_columns_min_size: bool, } impl Default for MarkdownStyle { @@ -91,6 +92,7 @@ impl Default for MarkdownStyle { heading_level_styles: None, height_is_multiple_of_line_height: false, prevent_mouse_interaction: false, + table_columns_min_size: false, } } } @@ -1062,11 +1064,21 @@ impl Element for MarkdownElement { MarkdownTag::MetadataBlock(_) => {} MarkdownTag::Table(alignments) => { builder.table_alignments = alignments.clone(); + builder.table_row_index = 0; + builder.in_table_head = false; + let column_count = alignments.len(); builder.push_div( div() .id(("table", range.start)) - .min_w_0() + .grid() + .grid_cols(column_count as u16) + .when(self.style.table_columns_min_size, |this| { + this.grid_cols_min_content(column_count as u16) + }) + .when(!self.style.table_columns_min_size, |this| { + this.grid_cols(column_count as u16) + }) .size_full() .mb_2() .border_1() @@ -1078,38 +1090,30 @@ impl Element for MarkdownElement { ); } MarkdownTag::TableHead => { - let column_count = builder.table_alignments.len(); - - builder.push_div( - div() - .grid() - .grid_cols(column_count as u16) - .bg(cx.theme().colors().title_bar_background), - range, - markdown_end, - ); + builder.in_table_head = true; builder.push_text_style(TextStyleRefinement { font_weight: Some(FontWeight::SEMIBOLD), ..Default::default() }); } - MarkdownTag::TableRow => { - let column_count = builder.table_alignments.len(); - - builder.push_div( - div().grid().grid_cols(column_count as u16), - range, - markdown_end, - ); - } + MarkdownTag::TableRow => {} MarkdownTag::TableCell => { + let is_header = builder.in_table_head; + let row_index = builder.table_row_index; + builder.push_div( div() .min_w_0() .border(px(0.5)) .border_color(cx.theme().colors().border) .px_1() - .py_0p5(), + .py_0p5() + .when(is_header, |this| { + this.bg(cx.theme().colors().title_bar_background) + }) + .when(!is_header && row_index % 2 == 1, |this| { + this.bg(cx.theme().colors().panel_background) + }), range, markdown_end, ); @@ -1224,13 +1228,15 @@ impl Element for MarkdownElement { MarkdownTagEnd::Table => { builder.pop_div(); builder.table_alignments.clear(); + builder.in_table_head = false; + builder.table_row_index = 0; } MarkdownTagEnd::TableHead => { - builder.pop_div(); builder.pop_text_style(); + builder.in_table_head = false; } MarkdownTagEnd::TableRow => { - builder.pop_div(); + builder.table_row_index += 1; } MarkdownTagEnd::TableCell => { builder.pop_div(); @@ -1500,6 +1506,8 @@ struct MarkdownElementBuilder { code_block_stack: Vec>>, list_stack: Vec, table_alignments: Vec, + in_table_head: bool, + table_row_index: usize, syntax_theme: Arc, } @@ -1536,6 +1544,8 @@ impl MarkdownElementBuilder { code_block_stack: Vec::new(), list_stack: Vec::new(), table_alignments: Vec::new(), + in_table_head: false, + table_row_index: 0, syntax_theme, } } From 90d7ccfd5d0db23b04e4cf48d1f049b211654f12 Mon Sep 17 00:00:00 2001 From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Date: Tue, 16 Dec 2025 09:46:08 -0300 Subject: [PATCH 368/621] agent_ui: Search models only by name (#44984) We were previously matching the search on both model name and provider ID. In most cases, this would yield an okay result, but if you search for "Opus", for example, you'd see the Sonnet models in the search result, which was very confusing. This was because we were matching to both provider ID and model name. "Sonnet" and "Opus" share the same provider ID, so they both contain "Anthropic" as a prefix. Then, "Opus" contains the letter P, as well as Anthropic, thus the match. Now, we're only matching by model name, which I think most of the time will yield more accurate results. Release Notes: - agent: Improved the model search quality in the model picker. --- crates/agent_ui/src/acp/model_selector.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/crates/agent_ui/src/acp/model_selector.rs b/crates/agent_ui/src/acp/model_selector.rs index f9710ad9b3aac29546dbe66a518a198d9b113385..959e0e72f38feadb39da38b7bbc3eed58dcd775e 100644 --- a/crates/agent_ui/src/acp/model_selector.rs +++ b/crates/agent_ui/src/acp/model_selector.rs @@ -403,9 +403,7 @@ async fn fuzzy_search( let candidates = model_list .iter() .enumerate() - .map(|(ix, model)| { - StringMatchCandidate::new(ix, &format!("{}/{}", model.id, model.name)) - }) + .map(|(ix, model)| StringMatchCandidate::new(ix, model.name.as_ref())) .collect::>(); let mut matches = match_strings( &candidates, From 775548e93c2fe1f56351acc92ae95b379b5cc4d6 Mon Sep 17 00:00:00 2001 From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Date: Tue, 16 Dec 2025 09:55:26 -0300 Subject: [PATCH 369/621] ui: Fix Divider component growing unnecessarily (#44986) I had previously added `flex_none` to the Divider and that caused it to grow beyond the container's width in some cases (project panel, agent panel's restore to check point button, etc.). Release Notes: - N/A --- crates/project_panel/src/project_panel.rs | 4 ++-- crates/ui/src/components/divider.rs | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rs index a645ae194b19e5770386ed2eb97de11f9350a866..ea667ecbb479ca347914ee11ec789a14f29cf474 100644 --- a/crates/project_panel/src/project_panel.rs +++ b/crates/project_panel/src/project_panel.rs @@ -6050,9 +6050,9 @@ impl Render for ProjectPanel { h_flex() .w_1_2() .gap_2() - .child(div().flex_1().child(Divider::horizontal())) + .child(Divider::horizontal()) .child(Label::new("or").size(LabelSize::XSmall).color(Color::Muted)) - .child(div().flex_1().child(Divider::horizontal())), + .child(Divider::horizontal()), ) .child( Button::new("clone_repo", "Clone Repository") diff --git a/crates/ui/src/components/divider.rs b/crates/ui/src/components/divider.rs index cc7ad19875d2817d98076812bb7b9ea101341107..5ad2187cfae36f3cc45cbecb42f115f0742abed4 100644 --- a/crates/ui/src/components/divider.rs +++ b/crates/ui/src/components/divider.rs @@ -146,13 +146,11 @@ impl RenderOnce for Divider { let base = match self.direction { DividerDirection::Horizontal => div() .min_w_0() - .flex_none() .h_px() .w_full() .when(self.inset, |this| this.mx_1p5()), DividerDirection::Vertical => div() .min_w_0() - .flex_none() .w_px() .h_full() .when(self.inset, |this| this.my_1p5()), From 37bd27b2a8b2f26e70c3a279bad1fbb70d0e3f47 Mon Sep 17 00:00:00 2001 From: lif <1835304752@qq.com> Date: Tue, 16 Dec 2025 21:05:31 +0800 Subject: [PATCH 370/621] diagnostics: Respect toolbar breadcrumbs setting in diagnostics panel (#44974) ## Summary The diagnostics panel was ignoring the user's `toolbar.breadcrumbs` setting and always showing breadcrumbs. This makes both `BufferDiagnosticsEditor` and `ProjectDiagnosticsEditor` check the `EditorSettings` to determine whether to display breadcrumbs. ## Changes - `buffer_diagnostics.rs`: Updated `breadcrumb_location` to check `EditorSettings::get_global(cx).toolbar.breadcrumbs` - `diagnostics.rs`: Updated `breadcrumb_location` to check `EditorSettings::get_global(cx).toolbar.breadcrumbs` This follows the same pattern used by the regular `Editor` in `items.rs`. ## Test plan 1. Set `toolbar.breadcrumbs` to `false` in settings.json 2. Open a file with diagnostics 3. Run `diagnostics: deploy current file` 4. Verify that breadcrumbs are hidden in the diagnostics panel Fixes #43020 --- crates/diagnostics/src/buffer_diagnostics.rs | 10 +++++++--- crates/diagnostics/src/diagnostics.rs | 10 +++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/crates/diagnostics/src/buffer_diagnostics.rs b/crates/diagnostics/src/buffer_diagnostics.rs index 0fd8783dd514f8da3c53d41dcb6f8e9004ae501c..ca28f2805adca78846a66e7b1f4d9f3fc57bb557 100644 --- a/crates/diagnostics/src/buffer_diagnostics.rs +++ b/crates/diagnostics/src/buffer_diagnostics.rs @@ -6,7 +6,7 @@ use crate::{ use anyhow::Result; use collections::HashMap; use editor::{ - Editor, EditorEvent, ExcerptRange, MultiBuffer, PathKey, + Editor, EditorEvent, EditorSettings, ExcerptRange, MultiBuffer, PathKey, display_map::{BlockPlacement, BlockProperties, BlockStyle, CustomBlockId}, multibuffer_context_lines, }; @@ -701,8 +701,12 @@ impl Item for BufferDiagnosticsEditor { }); } - fn breadcrumb_location(&self, _: &App) -> ToolbarItemLocation { - ToolbarItemLocation::PrimaryLeft + fn breadcrumb_location(&self, cx: &App) -> ToolbarItemLocation { + if EditorSettings::get_global(cx).toolbar.breadcrumbs { + ToolbarItemLocation::PrimaryLeft + } else { + ToolbarItemLocation::Hidden + } } fn breadcrumbs(&self, theme: &theme::Theme, cx: &App) -> Option> { diff --git a/crates/diagnostics/src/diagnostics.rs b/crates/diagnostics/src/diagnostics.rs index 76edf4f9b438aca1c47393c9c14c6321d0013eb8..0999bebdb6aa9ca744e3a5121670a1b7357411a9 100644 --- a/crates/diagnostics/src/diagnostics.rs +++ b/crates/diagnostics/src/diagnostics.rs @@ -12,7 +12,7 @@ use buffer_diagnostics::BufferDiagnosticsEditor; use collections::{BTreeSet, HashMap, HashSet}; use diagnostic_renderer::DiagnosticBlock; use editor::{ - Editor, EditorEvent, ExcerptRange, MultiBuffer, PathKey, + Editor, EditorEvent, EditorSettings, ExcerptRange, MultiBuffer, PathKey, display_map::{BlockPlacement, BlockProperties, BlockStyle, CustomBlockId}, multibuffer_context_lines, }; @@ -894,8 +894,12 @@ impl Item for ProjectDiagnosticsEditor { Some(Box::new(self.editor.clone())) } - fn breadcrumb_location(&self, _: &App) -> ToolbarItemLocation { - ToolbarItemLocation::PrimaryLeft + fn breadcrumb_location(&self, cx: &App) -> ToolbarItemLocation { + if EditorSettings::get_global(cx).toolbar.breadcrumbs { + ToolbarItemLocation::PrimaryLeft + } else { + ToolbarItemLocation::Hidden + } } fn breadcrumbs(&self, theme: &theme::Theme, cx: &App) -> Option> { From 0362e301f72c4bcec766e8d309c2c2cdc3ba32eb Mon Sep 17 00:00:00 2001 From: Daiki Takagi <90747075+Suzushiro-radish@users.noreply.github.com> Date: Tue, 16 Dec 2025 22:43:23 +0900 Subject: [PATCH 371/621] acp_thread: Decode file:// mention paths so non-ASCII names render correctly (#44983) ## Summary This fixes a minor bug I found #44981 - Fix percent-encoded filenames appearing in agent mentions after message submission. - Decode file:// paths in MentionUri::parse using the existing urlencoding crate (already used elsewhere in the codebase). - Add tests for non-ASCII file URIs. ## Screenshots image --- Cargo.lock | 1 + crates/acp_thread/Cargo.toml | 1 + crates/acp_thread/src/mention.rs | 19 ++++++++++++++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 6d5d68fa9293a391ecfa1308c1c347a7cd48cb8b..5b35991dfde30b4b976ae96a552862876a245486 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -37,6 +37,7 @@ dependencies = [ "terminal", "ui", "url", + "urlencoding", "util", "uuid", "watch", diff --git a/crates/acp_thread/Cargo.toml b/crates/acp_thread/Cargo.toml index 8ef6f1a52c8b207658d59a1e6b877964df9e42ce..70f2e4d259f1611fb42ebc0b064d278c8b3b9c4d 100644 --- a/crates/acp_thread/Cargo.toml +++ b/crates/acp_thread/Cargo.toml @@ -46,6 +46,7 @@ url.workspace = true util.workspace = true uuid.workspace = true watch.workspace = true +urlencoding.workspace = true [dev-dependencies] env_logger.workspace = true diff --git a/crates/acp_thread/src/mention.rs b/crates/acp_thread/src/mention.rs index c1b7032cfaa904764055bb79a3cac7e7ac74b0c1..3e2e53fb7fbdf581b45566bd747cfcbfc1c0a004 100644 --- a/crates/acp_thread/src/mention.rs +++ b/crates/acp_thread/src/mention.rs @@ -4,12 +4,14 @@ use file_icons::FileIcons; use prompt_store::{PromptId, UserPromptId}; use serde::{Deserialize, Serialize}; use std::{ + borrow::Cow, fmt, ops::RangeInclusive, path::{Path, PathBuf}, }; use ui::{App, IconName, SharedString}; use url::Url; +use urlencoding::decode; use util::paths::PathStyle; #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Hash)] @@ -74,11 +76,13 @@ impl MentionUri { let path = url.path(); match url.scheme() { "file" => { - let path = if path_style.is_windows() { + let normalized = if path_style.is_windows() { path.trim_start_matches("/") } else { path }; + let decoded = decode(normalized).unwrap_or(Cow::Borrowed(normalized)); + let path = decoded.as_ref(); if let Some(fragment) = url.fragment() { let line_range = parse_line_range(fragment)?; @@ -406,6 +410,19 @@ mod tests { assert_eq!(parsed.to_uri().to_string(), selection_uri); } + #[test] + fn test_parse_file_uri_with_non_ascii() { + let file_uri = uri!("file:///path/to/%E6%97%A5%E6%9C%AC%E8%AA%9E.txt"); + let parsed = MentionUri::parse(file_uri, PathStyle::local()).unwrap(); + match &parsed { + MentionUri::File { abs_path } => { + assert_eq!(abs_path, Path::new(path!("/path/to/日本語.txt"))); + } + _ => panic!("Expected File variant"), + } + assert_eq!(parsed.to_uri().to_string(), file_uri); + } + #[test] fn test_parse_untitled_selection_uri() { let selection_uri = uri!("zed:///agent/untitled-buffer#L1:10"); From 5f451c89e07edffa443fcc8293f4055213ce0fcf Mon Sep 17 00:00:00 2001 From: Smit Barmase Date: Tue, 16 Dec 2025 19:18:52 +0530 Subject: [PATCH 372/621] markdown: Fix double borders in Markdown and Markdown Preview tables (#44991) Improves upon https://github.com/zed-industries/zed/pull/42674 Before: image image After: image image Release Notes: - Fixed an issue where Markdown tables would sometimes show double borders. --- crates/markdown/src/markdown.rs | 82 ++++++++++++++----- .../markdown_preview/src/markdown_renderer.rs | 12 ++- 2 files changed, 69 insertions(+), 25 deletions(-) diff --git a/crates/markdown/src/markdown.rs b/crates/markdown/src/markdown.rs index 50de82fb5f24bd0328123ada86d80d073b675801..536d9fd6a2439e9b23b9f99d20a4aff425eda956 100644 --- a/crates/markdown/src/markdown.rs +++ b/crates/markdown/src/markdown.rs @@ -1063,9 +1063,7 @@ impl Element for MarkdownElement { } MarkdownTag::MetadataBlock(_) => {} MarkdownTag::Table(alignments) => { - builder.table_alignments = alignments.clone(); - builder.table_row_index = 0; - builder.in_table_head = false; + builder.table.start(alignments.clone()); let column_count = alignments.len(); builder.push_div( @@ -1081,7 +1079,7 @@ impl Element for MarkdownElement { }) .size_full() .mb_2() - .border_1() + .border(px(1.5)) .border_color(cx.theme().colors().border) .rounded_sm() .overflow_hidden(), @@ -1090,21 +1088,24 @@ impl Element for MarkdownElement { ); } MarkdownTag::TableHead => { - builder.in_table_head = true; + builder.table.start_head(); builder.push_text_style(TextStyleRefinement { font_weight: Some(FontWeight::SEMIBOLD), ..Default::default() }); } - MarkdownTag::TableRow => {} + MarkdownTag::TableRow => { + builder.table.start_row(); + } MarkdownTag::TableCell => { - let is_header = builder.in_table_head; - let row_index = builder.table_row_index; + let is_header = builder.table.in_head; + let row_index = builder.table.row_index; + let col_index = builder.table.col_index; builder.push_div( div() - .min_w_0() - .border(px(0.5)) + .when(col_index > 0, |this| this.border_l_1()) + .when(row_index > 0, |this| this.border_t_1()) .border_color(cx.theme().colors().border) .px_1() .py_0p5() @@ -1227,19 +1228,18 @@ impl Element for MarkdownElement { } MarkdownTagEnd::Table => { builder.pop_div(); - builder.table_alignments.clear(); - builder.in_table_head = false; - builder.table_row_index = 0; + builder.table.end(); } MarkdownTagEnd::TableHead => { builder.pop_text_style(); - builder.in_table_head = false; + builder.table.end_head(); } MarkdownTagEnd::TableRow => { - builder.table_row_index += 1; + builder.table.end_row(); } MarkdownTagEnd::TableCell => { builder.pop_div(); + builder.table.end_cell(); } _ => log::debug!("unsupported markdown tag end: {:?}", tag), }, @@ -1494,6 +1494,50 @@ impl ParentElement for AnyDiv { } } +#[derive(Default)] +struct TableState { + alignments: Vec, + in_head: bool, + row_index: usize, + col_index: usize, +} + +impl TableState { + fn start(&mut self, alignments: Vec) { + self.alignments = alignments; + self.in_head = false; + self.row_index = 0; + self.col_index = 0; + } + + fn end(&mut self) { + self.alignments.clear(); + self.in_head = false; + self.row_index = 0; + self.col_index = 0; + } + + fn start_head(&mut self) { + self.in_head = true; + } + + fn end_head(&mut self) { + self.in_head = false; + } + + fn start_row(&mut self) { + self.col_index = 0; + } + + fn end_row(&mut self) { + self.row_index += 1; + } + + fn end_cell(&mut self) { + self.col_index += 1; + } +} + struct MarkdownElementBuilder { div_stack: Vec, rendered_lines: Vec, @@ -1505,9 +1549,7 @@ struct MarkdownElementBuilder { text_style_stack: Vec, code_block_stack: Vec>>, list_stack: Vec, - table_alignments: Vec, - in_table_head: bool, - table_row_index: usize, + table: TableState, syntax_theme: Arc, } @@ -1543,9 +1585,7 @@ impl MarkdownElementBuilder { text_style_stack: Vec::new(), code_block_stack: Vec::new(), list_stack: Vec::new(), - table_alignments: Vec::new(), - in_table_head: false, - table_row_index: 0, + table: TableState::default(), syntax_theme, } } diff --git a/crates/markdown_preview/src/markdown_renderer.rs b/crates/markdown_preview/src/markdown_renderer.rs index 336f1cacfd2e3d7c25e19aeaf328b1c10db10b30..d4c810245c0fcf874160957cff1b029c4c4c1702 100644 --- a/crates/markdown_preview/src/markdown_renderer.rs +++ b/crates/markdown_preview/src/markdown_renderer.rs @@ -9,7 +9,7 @@ use gpui::{ AbsoluteLength, AnyElement, App, AppContext as _, ClipboardItem, Context, Div, Element, ElementId, Entity, HighlightStyle, Hsla, ImageSource, InteractiveText, IntoElement, Keystroke, Modifiers, ParentElement, Render, Resource, SharedString, Styled, StyledText, TextStyle, - WeakEntity, Window, div, img, rems, + WeakEntity, Window, div, img, px, rems, }; use settings::Settings; use std::{ @@ -521,7 +521,8 @@ fn render_markdown_table(parsed: &ParsedMarkdownTable, cx: &mut RenderContext) - .children(render_markdown_text(&cell.children, cx)) .px_2() .py_1() - .border_1() + .when(col_idx > 0, |this| this.border_l_1()) + .when(row_idx > 0, |this| this.border_t_1()) .border_color(cx.border_color) .when(cell.is_header, |this| { this.bg(cx.title_bar_background_color) @@ -551,7 +552,8 @@ fn render_markdown_table(parsed: &ParsedMarkdownTable, cx: &mut RenderContext) - } let empty_cell = div() - .border_1() + .when(col_idx > 0, |this| this.border_l_1()) + .when(row_idx > 0, |this| this.border_t_1()) .border_color(cx.border_color) .when(row_idx % 2 == 1, |this| this.bg(cx.panel_background_color)); @@ -568,8 +570,10 @@ fn render_markdown_table(parsed: &ParsedMarkdownTable, cx: &mut RenderContext) - div() .grid() .grid_cols(max_column_count as u16) - .border_1() + .border(px(1.5)) .border_color(cx.border_color) + .rounded_sm() + .overflow_hidden() .children(cells), ) .into_any() From 37e4f7e9b54e1cc830ec45d7fb4d019edf9f47cd Mon Sep 17 00:00:00 2001 From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Date: Tue, 16 Dec 2025 10:50:52 -0300 Subject: [PATCH 373/621] agent_ui: Remove custom "unavailable editing" tooltip (#44992) Now that we can use `Tooltip::element`, we don't need a separate file/component just for this. Release Notes: - N/A --- crates/agent_ui/src/acp/thread_view.rs | 26 ++++++++++++----- crates/agent_ui/src/ui.rs | 4 +-- .../src/ui/unavailable_editing_tooltip.rs | 29 ------------------- 3 files changed, 20 insertions(+), 39 deletions(-) delete mode 100644 crates/agent_ui/src/ui/unavailable_editing_tooltip.rs diff --git a/crates/agent_ui/src/acp/thread_view.rs b/crates/agent_ui/src/acp/thread_view.rs index f5e5b6c3b261d5c82bf8d3fc3fc13d482e69ca7d..aa02e22635c1585003fbfc540b50687ae0930ecd 100644 --- a/crates/agent_ui/src/acp/thread_view.rs +++ b/crates/agent_ui/src/acp/thread_view.rs @@ -63,10 +63,7 @@ use crate::acp::message_editor::{MessageEditor, MessageEditorEvent}; use crate::agent_diff::AgentDiff; use crate::profile_selector::{ProfileProvider, ProfileSelector}; -use crate::ui::{ - AgentNotification, AgentNotificationEvent, BurnModeTooltip, UnavailableEditingTooltip, - UsageCallout, -}; +use crate::ui::{AgentNotification, AgentNotificationEvent, BurnModeTooltip, UsageCallout}; use crate::{ AgentDiffPane, AgentPanel, AllowAlways, AllowOnce, ContinueThread, ContinueWithBurnMode, CycleModeSelector, ExpandMessageEditor, Follow, KeepAll, NewThread, OpenAgentDiff, OpenHistory, @@ -2091,10 +2088,23 @@ impl AcpThreadView { .icon_size(IconSize::Small) .icon_color(Color::Muted) .style(ButtonStyle::Transparent) - .tooltip(move |_window, cx| { - cx.new(|_| UnavailableEditingTooltip::new(agent_name.clone())) - .into() - }) + .tooltip(Tooltip::element({ + move |_, _| { + v_flex() + .gap_1() + .child(Label::new("Unavailable Editing")).child( + div().max_w_64().child( + Label::new(format!( + "Editing previous messages is not available for {} yet.", + agent_name.clone() + )) + .size(LabelSize::Small) + .color(Color::Muted), + ), + ) + .into_any_element() + } + })) ) ) } diff --git a/crates/agent_ui/src/ui.rs b/crates/agent_ui/src/ui.rs index e604df416e2725a6f1b7bff8eed883a8cc36e184..6c3d8bc1427092b0d0380cf286da1706337932fe 100644 --- a/crates/agent_ui/src/ui.rs +++ b/crates/agent_ui/src/ui.rs @@ -5,7 +5,7 @@ mod claude_code_onboarding_modal; mod end_trial_upsell; mod hold_for_default; mod onboarding_modal; -mod unavailable_editing_tooltip; + mod usage_callout; pub use acp_onboarding_modal::*; @@ -15,5 +15,5 @@ pub use claude_code_onboarding_modal::*; pub use end_trial_upsell::*; pub use hold_for_default::*; pub use onboarding_modal::*; -pub use unavailable_editing_tooltip::*; + pub use usage_callout::*; diff --git a/crates/agent_ui/src/ui/unavailable_editing_tooltip.rs b/crates/agent_ui/src/ui/unavailable_editing_tooltip.rs deleted file mode 100644 index 2993fb89a989619ecfe3d79b06d82a2a6f71fc31..0000000000000000000000000000000000000000 --- a/crates/agent_ui/src/ui/unavailable_editing_tooltip.rs +++ /dev/null @@ -1,29 +0,0 @@ -use gpui::{Context, IntoElement, Render, Window}; -use ui::{prelude::*, tooltip_container}; - -pub struct UnavailableEditingTooltip { - agent_name: SharedString, -} - -impl UnavailableEditingTooltip { - pub fn new(agent_name: SharedString) -> Self { - Self { agent_name } - } -} - -impl Render for UnavailableEditingTooltip { - fn render(&mut self, _: &mut Window, cx: &mut Context) -> impl IntoElement { - tooltip_container(cx, |this, _| { - this.child(Label::new("Unavailable Editing")).child( - div().max_w_64().child( - Label::new(format!( - "Editing previous messages is not available for {} yet.", - self.agent_name - )) - .size(LabelSize::Small) - .color(Color::Muted), - ), - ) - }) - } -} From 5f054e8d9c227e206e7dd3379c81911aa8e652c2 Mon Sep 17 00:00:00 2001 From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Date: Tue, 16 Dec 2025 11:34:20 -0300 Subject: [PATCH 374/621] agent_ui: Create components for the model selector (#44993) This PR introduces a few components for the model selector pickers. Given we're still maintaining two flavors of it due to one of them being wired through ACP and the other through the language model registry, having one source of truth for the UI should help with maintenance moving forward, considering that despite the internal differences, they look and behave the same from the standpoint of the UI. Release Notes: - N/A --- crates/agent_ui/src/acp/model_selector.rs | 86 ++-------- .../agent_ui/src/language_model_selector.rs | 85 ++-------- crates/agent_ui/src/ui.rs | 4 +- .../src/ui/model_selector_components.rs | 147 ++++++++++++++++++ 4 files changed, 176 insertions(+), 146 deletions(-) create mode 100644 crates/agent_ui/src/ui/model_selector_components.rs diff --git a/crates/agent_ui/src/acp/model_selector.rs b/crates/agent_ui/src/acp/model_selector.rs index 959e0e72f38feadb39da38b7bbc3eed58dcd775e..658b88e0c2a4f0b4203c5f1191c0a49cb4ad6fd5 100644 --- a/crates/agent_ui/src/acp/model_selector.rs +++ b/crates/agent_ui/src/acp/model_selector.rs @@ -12,14 +12,11 @@ use gpui::{ }; use ordered_float::OrderedFloat; use picker::{Picker, PickerDelegate}; -use ui::{ - DocumentationAside, DocumentationEdge, DocumentationSide, IntoElement, KeyBinding, ListItem, - ListItemSpacing, prelude::*, -}; +use ui::{DocumentationAside, DocumentationEdge, DocumentationSide, prelude::*}; use util::ResultExt; use zed_actions::agent::OpenSettings; -use crate::ui::HoldForDefault; +use crate::ui::{HoldForDefault, ModelSelectorFooter, ModelSelectorHeader, ModelSelectorListItem}; pub type AcpModelSelector = Picker; @@ -236,39 +233,19 @@ impl PickerDelegate for AcpModelPickerDelegate { fn render_match( &self, ix: usize, - selected: bool, + is_focused: bool, _: &mut Window, cx: &mut Context>, ) -> Option { match self.filtered_entries.get(ix)? { - AcpModelPickerEntry::Separator(title) => Some( - div() - .px_2() - .pb_1() - .when(ix > 1, |this| { - this.mt_1() - .pt_2() - .border_t_1() - .border_color(cx.theme().colors().border_variant) - }) - .child( - Label::new(title) - .size(LabelSize::XSmall) - .color(Color::Muted), - ) - .into_any_element(), - ), + AcpModelPickerEntry::Separator(title) => { + Some(ModelSelectorHeader::new(title, ix > 1).into_any_element()) + } AcpModelPickerEntry::Model(model_info) => { let is_selected = Some(model_info) == self.selected_model.as_ref(); let default_model = self.agent_server.default_model(cx); let is_default = default_model.as_ref() == Some(&model_info.id); - let model_icon_color = if is_selected { - Color::Accent - } else { - Color::Muted - }; - Some( div() .id(("model-picker-menu-child", ix)) @@ -284,30 +261,10 @@ impl PickerDelegate for AcpModelPickerDelegate { })) }) .child( - ListItem::new(ix) - .inset(true) - .spacing(ListItemSpacing::Sparse) - .toggle_state(selected) - .child( - h_flex() - .w_full() - .gap_1p5() - .when_some(model_info.icon, |this, icon| { - this.child( - Icon::new(icon) - .color(model_icon_color) - .size(IconSize::Small) - ) - }) - .child(Label::new(model_info.name.clone()).truncate()), - ) - .end_slot(div().pr_3().when(is_selected, |this| { - this.child( - Icon::new(IconName::Check) - .color(Color::Accent) - .size(IconSize::Small), - ) - })), + ModelSelectorListItem::new(ix, model_info.name.clone()) + .is_focused(is_focused) + .is_selected(is_selected) + .when_some(model_info.icon, |this, icon| this.icon(icon)), ) .into_any_element() ) @@ -343,7 +300,7 @@ impl PickerDelegate for AcpModelPickerDelegate { fn render_footer( &self, _window: &mut Window, - cx: &mut Context>, + _cx: &mut Context>, ) -> Option { let focus_handle = self.focus_handle.clone(); @@ -351,26 +308,7 @@ impl PickerDelegate for AcpModelPickerDelegate { return None; } - Some( - h_flex() - .w_full() - .p_1p5() - .border_t_1() - .border_color(cx.theme().colors().border_variant) - .child( - Button::new("configure", "Configure") - .full_width() - .style(ButtonStyle::Outlined) - .key_binding( - KeyBinding::for_action_in(&OpenSettings, &focus_handle, cx) - .map(|kb| kb.size(rems_from_px(12.))), - ) - .on_click(|_, window, cx| { - window.dispatch_action(OpenSettings.boxed_clone(), cx); - }), - ) - .into_any(), - ) + Some(ModelSelectorFooter::new(OpenSettings.boxed_clone(), focus_handle).into_any_element()) } } diff --git a/crates/agent_ui/src/language_model_selector.rs b/crates/agent_ui/src/language_model_selector.rs index 5b5a4513c6dca32e985c966e07ad84e84fc9a872..7e1c35eba45bf9a79d42b59374c8cdb2aa0cac21 100644 --- a/crates/agent_ui/src/language_model_selector.rs +++ b/crates/agent_ui/src/language_model_selector.rs @@ -11,9 +11,11 @@ use language_model::{ }; use ordered_float::OrderedFloat; use picker::{Picker, PickerDelegate}; -use ui::{KeyBinding, ListItem, ListItemSpacing, prelude::*}; +use ui::prelude::*; use zed_actions::agent::OpenSettings; +use crate::ui::{ModelSelectorFooter, ModelSelectorHeader, ModelSelectorListItem}; + type OnModelChanged = Arc, &mut App) + 'static>; type GetActiveModel = Arc Option + 'static>; @@ -459,28 +461,14 @@ impl PickerDelegate for LanguageModelPickerDelegate { fn render_match( &self, ix: usize, - selected: bool, + is_focused: bool, _: &mut Window, cx: &mut Context>, ) -> Option { match self.filtered_entries.get(ix)? { - LanguageModelPickerEntry::Separator(title) => Some( - div() - .px_2() - .pb_1() - .when(ix > 1, |this| { - this.mt_1() - .pt_2() - .border_t_1() - .border_color(cx.theme().colors().border_variant) - }) - .child( - Label::new(title) - .size(LabelSize::XSmall) - .color(Color::Muted), - ) - .into_any_element(), - ), + LanguageModelPickerEntry::Separator(title) => { + Some(ModelSelectorHeader::new(title, ix > 1).into_any_element()) + } LanguageModelPickerEntry::Model(model_info) => { let active_model = (self.get_active_model)(cx); let active_provider_id = active_model.as_ref().map(|m| m.provider.id()); @@ -489,35 +477,11 @@ impl PickerDelegate for LanguageModelPickerDelegate { let is_selected = Some(model_info.model.provider_id()) == active_provider_id && Some(model_info.model.id()) == active_model_id; - let model_icon_color = if is_selected { - Color::Accent - } else { - Color::Muted - }; - Some( - ListItem::new(ix) - .inset(true) - .spacing(ListItemSpacing::Sparse) - .toggle_state(selected) - .child( - h_flex() - .w_full() - .gap_1p5() - .child( - Icon::new(model_info.icon) - .color(model_icon_color) - .size(IconSize::Small), - ) - .child(Label::new(model_info.model.name().0).truncate()), - ) - .end_slot(div().pr_3().when(is_selected, |this| { - this.child( - Icon::new(IconName::Check) - .color(Color::Accent) - .size(IconSize::Small), - ) - })) + ModelSelectorListItem::new(ix, model_info.model.name().0) + .is_focused(is_focused) + .is_selected(is_selected) + .icon(model_info.icon) .into_any_element(), ) } @@ -527,34 +491,15 @@ impl PickerDelegate for LanguageModelPickerDelegate { fn render_footer( &self, _window: &mut Window, - cx: &mut Context>, + _cx: &mut Context>, ) -> Option { - let focus_handle = self.focus_handle.clone(); - if !self.popover_styles { return None; } - Some( - h_flex() - .w_full() - .p_1p5() - .border_t_1() - .border_color(cx.theme().colors().border_variant) - .child( - Button::new("configure", "Configure") - .full_width() - .style(ButtonStyle::Outlined) - .key_binding( - KeyBinding::for_action_in(&OpenSettings, &focus_handle, cx) - .map(|kb| kb.size(rems_from_px(12.))), - ) - .on_click(|_, window, cx| { - window.dispatch_action(OpenSettings.boxed_clone(), cx); - }), - ) - .into_any(), - ) + let focus_handle = self.focus_handle.clone(); + + Some(ModelSelectorFooter::new(OpenSettings.boxed_clone(), focus_handle).into_any_element()) } } diff --git a/crates/agent_ui/src/ui.rs b/crates/agent_ui/src/ui.rs index 6c3d8bc1427092b0d0380cf286da1706337932fe..b484fdb6c6c480f1cffe78eea7a51f635d3906a1 100644 --- a/crates/agent_ui/src/ui.rs +++ b/crates/agent_ui/src/ui.rs @@ -4,8 +4,8 @@ mod burn_mode_tooltip; mod claude_code_onboarding_modal; mod end_trial_upsell; mod hold_for_default; +mod model_selector_components; mod onboarding_modal; - mod usage_callout; pub use acp_onboarding_modal::*; @@ -14,6 +14,6 @@ pub use burn_mode_tooltip::*; pub use claude_code_onboarding_modal::*; pub use end_trial_upsell::*; pub use hold_for_default::*; +pub use model_selector_components::*; pub use onboarding_modal::*; - pub use usage_callout::*; diff --git a/crates/agent_ui/src/ui/model_selector_components.rs b/crates/agent_ui/src/ui/model_selector_components.rs new file mode 100644 index 0000000000000000000000000000000000000000..3218daef7c9aadae5cd45b2fc65807d8a32254bd --- /dev/null +++ b/crates/agent_ui/src/ui/model_selector_components.rs @@ -0,0 +1,147 @@ +use gpui::{Action, FocusHandle, prelude::*}; +use ui::{KeyBinding, ListItem, ListItemSpacing, prelude::*}; + +#[derive(IntoElement)] +pub struct ModelSelectorHeader { + title: SharedString, + has_border: bool, +} + +impl ModelSelectorHeader { + pub fn new(title: impl Into, has_border: bool) -> Self { + Self { + title: title.into(), + has_border, + } + } +} + +impl RenderOnce for ModelSelectorHeader { + fn render(self, _window: &mut Window, cx: &mut App) -> impl IntoElement { + div() + .px_2() + .pb_1() + .when(self.has_border, |this| { + this.mt_1() + .pt_2() + .border_t_1() + .border_color(cx.theme().colors().border_variant) + }) + .child( + Label::new(self.title) + .size(LabelSize::XSmall) + .color(Color::Muted), + ) + } +} + +#[derive(IntoElement)] +pub struct ModelSelectorListItem { + index: usize, + title: SharedString, + icon: Option, + is_selected: bool, + is_focused: bool, +} + +impl ModelSelectorListItem { + pub fn new(index: usize, title: impl Into) -> Self { + Self { + index, + title: title.into(), + icon: None, + is_selected: false, + is_focused: false, + } + } + + pub fn icon(mut self, icon: IconName) -> Self { + self.icon = Some(icon); + self + } + + pub fn is_selected(mut self, is_selected: bool) -> Self { + self.is_selected = is_selected; + self + } + + pub fn is_focused(mut self, is_focused: bool) -> Self { + self.is_focused = is_focused; + self + } +} + +impl RenderOnce for ModelSelectorListItem { + fn render(self, _window: &mut Window, _cx: &mut App) -> impl IntoElement { + let model_icon_color = if self.is_selected { + Color::Accent + } else { + Color::Muted + }; + + ListItem::new(self.index) + .inset(true) + .spacing(ListItemSpacing::Sparse) + .toggle_state(self.is_focused) + .child( + h_flex() + .w_full() + .gap_1p5() + .when_some(self.icon, |this, icon| { + this.child( + Icon::new(icon) + .color(model_icon_color) + .size(IconSize::Small), + ) + }) + .child(Label::new(self.title).truncate()), + ) + .end_slot(div().pr_2().when(self.is_selected, |this| { + this.child( + Icon::new(IconName::Check) + .color(Color::Accent) + .size(IconSize::Small), + ) + })) + } +} + +#[derive(IntoElement)] +pub struct ModelSelectorFooter { + action: Box, + focus_handle: FocusHandle, +} + +impl ModelSelectorFooter { + pub fn new(action: Box, focus_handle: FocusHandle) -> Self { + Self { + action, + focus_handle, + } + } +} + +impl RenderOnce for ModelSelectorFooter { + fn render(self, _window: &mut Window, cx: &mut App) -> impl IntoElement { + let action = self.action; + let focus_handle = self.focus_handle; + + h_flex() + .w_full() + .p_1p5() + .border_t_1() + .border_color(cx.theme().colors().border_variant) + .child( + Button::new("configure", "Configure") + .full_width() + .style(ButtonStyle::Outlined) + .key_binding( + KeyBinding::for_action_in(action.as_ref(), &focus_handle, cx) + .map(|kb| kb.size(rems_from_px(12.))), + ) + .on_click(move |_, window, cx| { + window.dispatch_action(action.boxed_clone(), cx); + }), + ) + } +} From 81519ae9233924007d37171db96f8bc99eeb00d2 Mon Sep 17 00:00:00 2001 From: Finn Evers Date: Tue, 16 Dec 2025 15:44:30 +0100 Subject: [PATCH 375/621] collab: Add `copilot` name alias to the `GET /contributor` endpoint (#44958) Although the copilot bot integration is referred to by `copilot-swe-agent[bot]` (https://api.github.com/users/copilot-swe-agent[bot]), GitHub parses the copilot identity as @\copilot in some cases, e.g. https://github.com/zed-industries/zed/pull/44915#issuecomment-3657567754. This causes the CLA check to still fail despite Copilot being added to the CLA endpoint (and https://api.github.com/users/copilot returning a 404 for that very name..). This PR fixes this by also considering the name alias of Copilot for the `contributor` endpoint. Release Notes: - N/A --- crates/collab/src/api/contributors.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/collab/src/api/contributors.rs b/crates/collab/src/api/contributors.rs index e09ac4f8b7355cf143b221308204742139308133..ce318b15295ebe5c777597a6d3c6106e57af8e05 100644 --- a/crates/collab/src/api/contributors.rs +++ b/crates/collab/src/api/contributors.rs @@ -111,6 +111,9 @@ struct CopilotSweAgentBot; impl CopilotSweAgentBot { const LOGIN: &'static str = "copilot-swe-agent[bot]"; const USER_ID: i32 = 198982749; + /// The alias of the GitHub copilot user. Although https://api.github.com/users/copilot + /// yields a 404, GitHub still refers to the copilot bot user as @Copilot in some cases. + const NAME_ALIAS: &'static str = "copilot"; /// Returns the `created_at` timestamp for the Dependabot bot user. fn created_at() -> &'static NaiveDateTime { @@ -125,7 +128,9 @@ impl CopilotSweAgentBot { /// Returns whether the given contributor selector corresponds to the Copilot bot user. fn is_copilot_bot(contributor: &ContributorSelector) -> bool { match contributor { - ContributorSelector::GitHubLogin { github_login } => github_login == Self::LOGIN, + ContributorSelector::GitHubLogin { github_login } => { + github_login == Self::LOGIN || github_login == Self::NAME_ALIAS + } ContributorSelector::GitHubUserId { github_user_id } => { github_user_id == &Self::USER_ID } From da0960bab680d8a626e91124edcd3667cabbe23d Mon Sep 17 00:00:00 2001 From: Nereuxofficial <37740907+Nereuxofficial@users.noreply.github.com> Date: Tue, 16 Dec 2025 15:51:33 +0100 Subject: [PATCH 376/621] languages: Correctly calculate ranges in `label_for_completion` (#44925) Closes #44825 Release Notes: - Fixed a case where an incorrect match could be generated in label_for_completion --------- Co-authored-by: Kirill Bulatov --- crates/language/src/language.rs | 5 +++- crates/languages/src/rust.rs | 48 ++++++++++++++++++++++++++++++--- 2 files changed, 49 insertions(+), 4 deletions(-) diff --git a/crates/language/src/language.rs b/crates/language/src/language.rs index a17c93f11a8705bf477d2eceb4f7bec9315cf6d1..b0805c4ddd9d1203a1f1a3071e8640fd016c1fb1 100644 --- a/crates/language/src/language.rs +++ b/crates/language/src/language.rs @@ -2425,7 +2425,10 @@ impl CodeLabel { "invalid filter range" ); runs.iter().for_each(|(range, _)| { - assert!(text.get(range.clone()).is_some(), "invalid run range"); + assert!( + text.get(range.clone()).is_some(), + "invalid run range with inputs. Requested range {range:?} in text '{text}'", + ); }); Self { runs, diff --git a/crates/languages/src/rust.rs b/crates/languages/src/rust.rs index ee64954196f58fe03f53a9e83fbbbea3f636449a..c10f76b079bf093e71b5444934196940e7b26d6c 100644 --- a/crates/languages/src/rust.rs +++ b/crates/languages/src/rust.rs @@ -375,16 +375,20 @@ impl LspAdapter for RustLspAdapter { let start_pos = range.start as usize; let end_pos = range.end as usize; - label.push_str(&snippet.text[text_pos..end_pos]); - text_pos = end_pos; + label.push_str(&snippet.text[text_pos..start_pos]); if start_pos == end_pos { let caret_start = label.len(); label.push('…'); runs.push((caret_start..label.len(), HighlightId::TABSTOP_INSERT_ID)); } else { - runs.push((start_pos..end_pos, HighlightId::TABSTOP_REPLACE_ID)); + let label_start = label.len(); + label.push_str(&snippet.text[start_pos..end_pos]); + let label_end = label.len(); + runs.push((label_start..label_end, HighlightId::TABSTOP_REPLACE_ID)); } + + text_pos = end_pos; } label.push_str(&snippet.text[text_pos..]); @@ -1592,6 +1596,44 @@ mod tests { ], )) ); + + // Test for correct range calculation with mixed empty and non-empty tabstops.(See https://github.com/zed-industries/zed/issues/44825) + let res = adapter + .label_for_completion( + &lsp::CompletionItem { + kind: Some(lsp::CompletionItemKind::STRUCT), + label: "Particles".to_string(), + insert_text_format: Some(lsp::InsertTextFormat::SNIPPET), + text_edit: Some(lsp::CompletionTextEdit::Edit(lsp::TextEdit { + range: lsp::Range::default(), + new_text: "Particles { pos_x: $1, pos_y: $2, vel_x: $3, vel_y: $4, acc_x: ${5:()}, acc_y: ${6:()}, mass: $7 }$0".to_string(), + })), + ..Default::default() + }, + &language, + ) + .await + .unwrap(); + + assert_eq!( + res, + CodeLabel::new( + "Particles { pos_x: …, pos_y: …, vel_x: …, vel_y: …, acc_x: (), acc_y: (), mass: … }".to_string(), + 0..9, + vec![ + (19..22, HighlightId::TABSTOP_INSERT_ID), + (31..34, HighlightId::TABSTOP_INSERT_ID), + (43..46, HighlightId::TABSTOP_INSERT_ID), + (55..58, HighlightId::TABSTOP_INSERT_ID), + (67..69, HighlightId::TABSTOP_REPLACE_ID), + (78..80, HighlightId::TABSTOP_REPLACE_ID), + (88..91, HighlightId::TABSTOP_INSERT_ID), + (0..9, highlight_type), + (60..65, highlight_field), + (71..76, highlight_field), + ], + ) + ); } #[gpui::test] From 1104ac7f7c61a33d5a32161c19cecd5aefbad5e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yara=20=F0=9F=8F=B3=EF=B8=8F=E2=80=8D=E2=9A=A7=EF=B8=8F?= Date: Tue, 16 Dec 2025 16:07:33 +0100 Subject: [PATCH 377/621] Revert windows implementation of "Multiple priority scheduler (#44701)" (#44990) This reverts the windows part of commit 636d11ebec8e74f0f0c173e858597fb57ccfa0b9. Release Notes: - N/A --- crates/gpui/src/executor.rs | 10 ++ crates/gpui/src/gpui.rs | 4 +- .../gpui/src/platform/windows/dispatcher.rs | 91 ++++++++----------- crates/gpui/src/platform/windows/events.rs | 3 +- crates/gpui/src/platform/windows/platform.rs | 24 +++-- crates/gpui/src/platform/windows/window.rs | 4 +- 6 files changed, 65 insertions(+), 71 deletions(-) diff --git a/crates/gpui/src/executor.rs b/crates/gpui/src/executor.rs index a219a20e92819f7d510ff9e93bce493f7ca723c9..6c2ecb341ff2fe446efd7823c107fd32a557feb5 100644 --- a/crates/gpui/src/executor.rs +++ b/crates/gpui/src/executor.rs @@ -290,9 +290,19 @@ impl BackgroundExecutor { &self, future: AnyFuture, label: Option, + #[cfg_attr( + target_os = "windows", + expect( + unused_variables, + reason = "Multi priority scheduler is broken on windows" + ) + )] priority: Priority, ) -> Task { let dispatcher = self.dispatcher.clone(); + #[cfg(target_os = "windows")] + let priority = Priority::Medium; // multi-prio scheduler is broken on windows + let (runnable, task) = if let Priority::Realtime(realtime) = priority { let location = core::panic::Location::caller(); let (mut tx, rx) = flume::bounded::>(1); diff --git a/crates/gpui/src/gpui.rs b/crates/gpui/src/gpui.rs index e5c726f58e117b76e2dbb2976089d5788baa848e..76a61e286d3fe6c1acae8e4e628d4c9130f1305f 100644 --- a/crates/gpui/src/gpui.rs +++ b/crates/gpui/src/gpui.rs @@ -31,7 +31,7 @@ mod path_builder; mod platform; pub mod prelude; mod profiler; -#[cfg(any(target_os = "windows", target_os = "linux"))] +#[cfg(target_os = "linux")] mod queue; mod scene; mod shared_string; @@ -91,7 +91,7 @@ pub use keymap::*; pub use path_builder::*; pub use platform::*; pub use profiler::*; -#[cfg(any(target_os = "windows", target_os = "linux"))] +#[cfg(target_os = "linux")] pub(crate) use queue::{PriorityQueueReceiver, PriorityQueueSender}; pub use refineable::*; pub use scene::*; diff --git a/crates/gpui/src/platform/windows/dispatcher.rs b/crates/gpui/src/platform/windows/dispatcher.rs index 0720d414c9b44dec4a3bab5b50fd7dde47991989..14486ccee9843ef9c0792d62f22fa825f0db43ee 100644 --- a/crates/gpui/src/platform/windows/dispatcher.rs +++ b/crates/gpui/src/platform/windows/dispatcher.rs @@ -4,31 +4,24 @@ use std::{ time::{Duration, Instant}, }; -use anyhow::Context; +use flume::Sender; use util::ResultExt; use windows::{ - System::Threading::{ - ThreadPool, ThreadPoolTimer, TimerElapsedHandler, WorkItemHandler, WorkItemPriority, - }, + System::Threading::{ThreadPool, ThreadPoolTimer, TimerElapsedHandler, WorkItemHandler}, Win32::{ Foundation::{LPARAM, WPARAM}, - System::Threading::{ - GetCurrentThread, HIGH_PRIORITY_CLASS, SetPriorityClass, SetThreadPriority, - THREAD_PRIORITY_HIGHEST, THREAD_PRIORITY_TIME_CRITICAL, - }, UI::WindowsAndMessaging::PostMessageW, }, }; use crate::{ - GLOBAL_THREAD_TIMINGS, HWND, PlatformDispatcher, Priority, PriorityQueueSender, - RealtimePriority, RunnableVariant, SafeHwnd, THREAD_TIMINGS, TaskLabel, TaskTiming, - ThreadTaskTimings, WM_GPUI_TASK_DISPATCHED_ON_MAIN_THREAD, profiler, + GLOBAL_THREAD_TIMINGS, HWND, PlatformDispatcher, RunnableVariant, SafeHwnd, THREAD_TIMINGS, + TaskLabel, TaskTiming, ThreadTaskTimings, WM_GPUI_TASK_DISPATCHED_ON_MAIN_THREAD, }; pub(crate) struct WindowsDispatcher { pub(crate) wake_posted: AtomicBool, - main_sender: PriorityQueueSender, + main_sender: Sender, main_thread_id: ThreadId, pub(crate) platform_window_handle: SafeHwnd, validation_number: usize, @@ -36,7 +29,7 @@ pub(crate) struct WindowsDispatcher { impl WindowsDispatcher { pub(crate) fn new( - main_sender: PriorityQueueSender, + main_sender: Sender, platform_window_handle: HWND, validation_number: usize, ) -> Self { @@ -52,7 +45,7 @@ impl WindowsDispatcher { } } - fn dispatch_on_threadpool(&self, priority: WorkItemPriority, runnable: RunnableVariant) { + fn dispatch_on_threadpool(&self, runnable: RunnableVariant) { let handler = { let mut task_wrapper = Some(runnable); WorkItemHandler::new(move |_| { @@ -60,8 +53,7 @@ impl WindowsDispatcher { Ok(()) }) }; - - ThreadPool::RunWithPriorityAsync(&handler, priority).log_err(); + ThreadPool::RunAsync(&handler).log_err(); } fn dispatch_on_threadpool_after(&self, runnable: RunnableVariant, duration: Duration) { @@ -87,7 +79,7 @@ impl WindowsDispatcher { start, end: None, }; - profiler::add_task_timing(timing); + Self::add_task_timing(timing); runnable.run(); @@ -99,7 +91,7 @@ impl WindowsDispatcher { start, end: None, }; - profiler::add_task_timing(timing); + Self::add_task_timing(timing); runnable.run(); @@ -110,7 +102,23 @@ impl WindowsDispatcher { let end = Instant::now(); timing.end = Some(end); - profiler::add_task_timing(timing); + Self::add_task_timing(timing); + } + + pub(crate) fn add_task_timing(timing: TaskTiming) { + THREAD_TIMINGS.with(|timings| { + let mut timings = timings.lock(); + let timings = &mut timings.timings; + + if let Some(last_timing) = timings.iter_mut().rev().next() { + if last_timing.location == timing.location { + last_timing.end = timing.end; + return; + } + } + + timings.push_back(timing); + }); } } @@ -138,22 +146,20 @@ impl PlatformDispatcher for WindowsDispatcher { current().id() == self.main_thread_id } - fn dispatch(&self, runnable: RunnableVariant, label: Option, priority: Priority) { - let priority = match priority { - Priority::Realtime(_) => unreachable!(), - Priority::High => WorkItemPriority::High, - Priority::Medium => WorkItemPriority::Normal, - Priority::Low => WorkItemPriority::Low, - }; - self.dispatch_on_threadpool(priority, runnable); - + fn dispatch( + &self, + runnable: RunnableVariant, + label: Option, + _priority: gpui::Priority, + ) { + self.dispatch_on_threadpool(runnable); if let Some(label) = label { log::debug!("TaskLabel: {label:?}"); } } - fn dispatch_on_main_thread(&self, runnable: RunnableVariant, priority: Priority) { - match self.main_sender.send(priority, runnable) { + fn dispatch_on_main_thread(&self, runnable: RunnableVariant, _priority: gpui::Priority) { + match self.main_sender.send(runnable) { Ok(_) => { if !self.wake_posted.swap(true, Ordering::AcqRel) { unsafe { @@ -185,27 +191,8 @@ impl PlatformDispatcher for WindowsDispatcher { self.dispatch_on_threadpool_after(runnable, duration); } - fn spawn_realtime(&self, priority: RealtimePriority, f: Box) { - std::thread::spawn(move || { - // SAFETY: always safe to call - let thread_handle = unsafe { GetCurrentThread() }; - - let thread_priority = match priority { - RealtimePriority::Audio => THREAD_PRIORITY_TIME_CRITICAL, - RealtimePriority::Other => THREAD_PRIORITY_HIGHEST, - }; - - // SAFETY: thread_handle is a valid handle to a thread - unsafe { SetPriorityClass(thread_handle, HIGH_PRIORITY_CLASS) } - .context("thread priority class") - .log_err(); - - // SAFETY: thread_handle is a valid handle to a thread - unsafe { SetThreadPriority(thread_handle, thread_priority) } - .context("thread priority") - .log_err(); - - f(); - }); + fn spawn_realtime(&self, _priority: crate::RealtimePriority, _f: Box) { + // disabled on windows for now. + unimplemented!(); } } diff --git a/crates/gpui/src/platform/windows/events.rs b/crates/gpui/src/platform/windows/events.rs index f648f45cf4bf632ae07784de8bdc1503f88d6177..e6fa6006eb95ec45f1634cb72ef63e2f622455a7 100644 --- a/crates/gpui/src/platform/windows/events.rs +++ b/crates/gpui/src/platform/windows/events.rs @@ -243,8 +243,7 @@ impl WindowsWindowInner { fn handle_timer_msg(&self, handle: HWND, wparam: WPARAM) -> Option { if wparam.0 == SIZE_MOVE_LOOP_TIMER_ID { - let mut runnables = self.main_receiver.clone().try_iter(); - while let Some(Ok(runnable)) = runnables.next() { + for runnable in self.main_receiver.drain() { WindowsDispatcher::execute_runnable(runnable); } self.handle_paint_msg(handle) diff --git a/crates/gpui/src/platform/windows/platform.rs b/crates/gpui/src/platform/windows/platform.rs index fa847bca6b404538a9f75b757bf53a2e4e2a1418..af0cb89ecc94da70cc42c8d4c397aeb2a811d6fb 100644 --- a/crates/gpui/src/platform/windows/platform.rs +++ b/crates/gpui/src/platform/windows/platform.rs @@ -51,7 +51,7 @@ struct WindowsPlatformInner { raw_window_handles: std::sync::Weak>>, // The below members will never change throughout the entire lifecycle of the app. validation_number: usize, - main_receiver: PriorityQueueReceiver, + main_receiver: flume::Receiver, dispatcher: Arc, } @@ -98,7 +98,7 @@ impl WindowsPlatform { OleInitialize(None).context("unable to initialize Windows OLE")?; } let directx_devices = DirectXDevices::new().context("Creating DirectX devices")?; - let (main_sender, main_receiver) = PriorityQueueReceiver::new(); + let (main_sender, main_receiver) = flume::unbounded::(); let validation_number = if usize::BITS == 64 { rand::random::() as usize } else { @@ -857,24 +857,22 @@ impl WindowsPlatformInner { } break 'tasks; } - let mut main_receiver = self.main_receiver.clone(); - match main_receiver.try_pop() { - Ok(Some(runnable)) => WindowsDispatcher::execute_runnable(runnable), - _ => break 'timeout_loop, + match self.main_receiver.try_recv() { + Err(_) => break 'timeout_loop, + Ok(runnable) => WindowsDispatcher::execute_runnable(runnable), } } // Someone could enqueue a Runnable here. The flag is still true, so they will not PostMessage. // We need to check for those Runnables after we clear the flag. self.dispatcher.wake_posted.store(false, Ordering::Release); - let mut main_receiver = self.main_receiver.clone(); - match main_receiver.try_pop() { - Ok(Some(runnable)) => { + match self.main_receiver.try_recv() { + Err(_) => break 'tasks, + Ok(runnable) => { self.dispatcher.wake_posted.store(true, Ordering::Release); WindowsDispatcher::execute_runnable(runnable); } - _ => break 'tasks, } } @@ -936,7 +934,7 @@ pub(crate) struct WindowCreationInfo { pub(crate) windows_version: WindowsVersion, pub(crate) drop_target_helper: IDropTargetHelper, pub(crate) validation_number: usize, - pub(crate) main_receiver: PriorityQueueReceiver, + pub(crate) main_receiver: flume::Receiver, pub(crate) platform_window_handle: HWND, pub(crate) disable_direct_composition: bool, pub(crate) directx_devices: DirectXDevices, @@ -949,8 +947,8 @@ struct PlatformWindowCreateContext { inner: Option>>, raw_window_handles: std::sync::Weak>>, validation_number: usize, - main_sender: Option>, - main_receiver: Option>, + main_sender: Option>, + main_receiver: Option>, directx_devices: Option, dispatcher: Option>, } diff --git a/crates/gpui/src/platform/windows/window.rs b/crates/gpui/src/platform/windows/window.rs index 0cfa812b288406c5b4afcea37949eed3918f5c91..7ef92b4150e69424b68e9417dda377aa7f2e9cc0 100644 --- a/crates/gpui/src/platform/windows/window.rs +++ b/crates/gpui/src/platform/windows/window.rs @@ -81,7 +81,7 @@ pub(crate) struct WindowsWindowInner { pub(crate) executor: ForegroundExecutor, pub(crate) windows_version: WindowsVersion, pub(crate) validation_number: usize, - pub(crate) main_receiver: PriorityQueueReceiver, + pub(crate) main_receiver: flume::Receiver, pub(crate) platform_window_handle: HWND, } @@ -362,7 +362,7 @@ struct WindowCreateContext { windows_version: WindowsVersion, drop_target_helper: IDropTargetHelper, validation_number: usize, - main_receiver: PriorityQueueReceiver, + main_receiver: flume::Receiver, platform_window_handle: HWND, appearance: WindowAppearance, disable_direct_composition: bool, From 73b37e9774399780fb49901a4a2d0b025db4a2a8 Mon Sep 17 00:00:00 2001 From: Dave Waggoner Date: Tue, 16 Dec 2025 07:08:28 -0800 Subject: [PATCH 378/621] terminal: Improve scroll performance (#44714) Related to: - #44510 - #44407 Previously we were searching for hyperlinks on every scroll, even if Cmd was not held. With this PR, - We only search for hyperlinks on scroll if Cmd is held - We now clear `last_hovered_word` in all cases where Cmd is not held - Renamed `word_from_position` -> `schedule_find_hyperlink` - Simplified logic in `schedule_find_hyperlink` Performance measurements The test scrolls up and down 20,000x in a loop. However, since this PR is just removing a code path that was very dependent on the length of the line in terminal, it's not super meaningful as a comparison. The test uses a line length of "long line ".repeat(1000), and in main the performance is directly proportional to the line length, so for benchmarking it in main it only scrolls up and down 20x. I think all that is really useful to say is that currently scrolling is slow, and proportional to the line length, and with this PR it is buttery-smooth and unaffected by line length. I've included a few data points below anyway. At least the test can help catch future regressions. | Branch | Command | Scrolls | Iter/sec | Mean [ms] | SD [ms] | Iterations | Importance (weight) | |:---|:---|---:|---:|---:|---:|---:|---:| | main | tests::perf::scroll_long_line_benchmark | 40 | 16.85 | 712.00 | 2.80 | 12 | average (50) | | this PR | tests::perf::scroll_long_line_benchmark | 40 | 116.22 | 413.60 | 0.50 | 48 | average (50) | | this PR | tests::perf::scroll_long_line_benchmark | 40,000 | 9.19 | 1306.40 | 7.00 | 12 | average (50) | | only overhead | tests::perf::scroll_long_line_benchmark | 0 | 114.29 | 420.90 | 2.00 | 48 | average (50) | Release Notes: - terminal: Improved scroll performance --- crates/terminal/src/terminal.rs | 152 ++++++++++++++++++++++++++------ 1 file changed, 127 insertions(+), 25 deletions(-) diff --git a/crates/terminal/src/terminal.rs b/crates/terminal/src/terminal.rs index 601fa75044a648e7c40e84b32aabda8096856119..c7ac75af0c810c55d470b1de8175c11c65855b58 100644 --- a/crates/terminal/src/terminal.rs +++ b/crates/terminal/src/terminal.rs @@ -892,6 +892,8 @@ impl TaskStatus { } } +const FIND_HYPERLINK_THROTTLE_PX: Pixels = px(5.0); + impl Terminal { fn process_event(&mut self, event: AlacTermEvent, cx: &mut Context) { match event { @@ -1718,38 +1720,40 @@ impl Terminal { { self.write_to_pty(bytes); } - } else if e.modifiers.secondary() { - self.word_from_position(e.position); + } else { + self.schedule_find_hyperlink(e.modifiers, e.position); } cx.notify(); } - fn word_from_position(&mut self, position: Point) { - if self.selection_phase == SelectionPhase::Selecting { + fn schedule_find_hyperlink(&mut self, modifiers: Modifiers, position: Point) { + if self.selection_phase == SelectionPhase::Selecting + || !modifiers.secondary() + || !self.last_content.terminal_bounds.bounds.contains(&position) + { self.last_content.last_hovered_word = None; - } else if self.last_content.terminal_bounds.bounds.contains(&position) { - // Throttle hyperlink searches to avoid excessive processing - let now = Instant::now(); - let should_search = if let Some(last_pos) = self.last_hyperlink_search_position { + return; + } + + // Throttle hyperlink searches to avoid excessive processing + let now = Instant::now(); + if self + .last_hyperlink_search_position + .map_or(true, |last_pos| { // Only search if mouse moved significantly or enough time passed - let distance_moved = - ((position.x - last_pos.x).abs() + (position.y - last_pos.y).abs()) > px(5.0); + let distance_moved = ((position.x - last_pos.x).abs() + + (position.y - last_pos.y).abs()) + > FIND_HYPERLINK_THROTTLE_PX; let time_elapsed = now.duration_since(self.last_mouse_move_time).as_millis() > 100; distance_moved || time_elapsed - } else { - true - }; - - if should_search { - self.last_mouse_move_time = now; - self.last_hyperlink_search_position = Some(position); - self.events.push_back(InternalEvent::FindHyperlink( - position - self.last_content.terminal_bounds.bounds.origin, - false, - )); - } - } else { - self.last_content.last_hovered_word = None; + }) + { + self.last_mouse_move_time = now; + self.last_hyperlink_search_position = Some(position); + self.events.push_back(InternalEvent::FindHyperlink( + position - self.last_content.terminal_bounds.bounds.origin, + false, + )); } } @@ -1941,7 +1945,7 @@ impl Terminal { } fn refresh_hovered_word(&mut self, window: &Window) { - self.word_from_position(window.mouse_position()); + self.schedule_find_hyperlink(window.modifiers(), window.mouse_position()); } fn determine_scroll_lines( @@ -2858,4 +2862,102 @@ mod tests { text ); } + + mod perf { + use super::super::*; + use gpui::{ + Entity, Point, ScrollDelta, ScrollWheelEvent, TestAppContext, VisualContext, + VisualTestContext, point, + }; + use util::default; + use util_macros::perf; + + async fn init_scroll_perf_test( + cx: &mut TestAppContext, + ) -> (Entity, &mut VisualTestContext) { + cx.update(|cx| { + let settings_store = settings::SettingsStore::test(cx); + cx.set_global(settings_store); + }); + + cx.executor().allow_parking(); + + let window = cx.add_empty_window(); + let builder = window + .update(|window, cx| { + let settings = TerminalSettings::get_global(cx); + let test_path_hyperlink_timeout_ms = 100; + TerminalBuilder::new( + None, + None, + task::Shell::System, + HashMap::default(), + CursorShape::default(), + AlternateScroll::On, + None, + settings.path_hyperlink_regexes.clone(), + test_path_hyperlink_timeout_ms, + false, + window.window_handle().window_id().as_u64(), + None, + cx, + vec![], + ) + }) + .await + .unwrap(); + let terminal = window.new(|cx| builder.subscribe(cx)); + + terminal.update(window, |term, cx| { + term.write_output("long line ".repeat(1000).as_bytes(), cx); + }); + + (terminal, window) + } + + #[perf] + #[gpui::test] + async fn scroll_long_line_benchmark(cx: &mut TestAppContext) { + let (terminal, window) = init_scroll_perf_test(cx).await; + let wobble = point(FIND_HYPERLINK_THROTTLE_PX, px(0.0)); + let mut scroll_by = |lines: i32| { + window.update_window_entity(&terminal, |terminal, window, cx| { + let bounds = terminal.last_content.terminal_bounds.bounds; + let center = bounds.origin + bounds.center(); + let position = center + wobble * lines as f32; + + terminal.mouse_move( + &MouseMoveEvent { + position, + ..default() + }, + cx, + ); + + terminal.scroll_wheel( + &ScrollWheelEvent { + position, + delta: ScrollDelta::Lines(Point::new(0.0, lines as f32)), + ..default() + }, + 1.0, + ); + + assert!( + terminal + .events + .iter() + .any(|event| matches!(event, InternalEvent::Scroll(_))), + "Should have Scroll event when scrolling within terminal bounds" + ); + terminal.sync(window, cx); + }); + }; + + for _ in 0..20000 { + scroll_by(1); + scroll_by(-1); + } + } + } } From 7ba6f39e8284cb7b3522f137b0d724ad59740ddd Mon Sep 17 00:00:00 2001 From: Andre Roelofs Date: Tue, 16 Dec 2025 16:36:45 +0100 Subject: [PATCH 379/621] Fix macros on x11 sometimes resulting in incorrect input (#44234) Closes #40678 The python file below simulates the macros at various timings and can be run by running: 1. `sudo python3 -m pip install evdev --break-system-packages` 2. `sudo python3 zed_shift_brace_replayer.py` Checked timings for hold=0.1, =0.01 and =0.001 with the latter two no longer causing incorrect inputs. [zed_shift_brace_replayer.py](https://github.com/user-attachments/files/23560570/zed_shift_brace_replayer.py) Release Notes: - linux: fixed a race condition where the macros containing modifier + key would sometimes be processed without the modifier --- crates/gpui/src/platform/linux/x11/client.rs | 29 +++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/crates/gpui/src/platform/linux/x11/client.rs b/crates/gpui/src/platform/linux/x11/client.rs index 60400dada57775a295fdb36c7f1ddd9dd8b83a67..5e9089b09809a7ec1b8b257427b0a670adc0f123 100644 --- a/crates/gpui/src/platform/linux/x11/client.rs +++ b/crates/gpui/src/platform/linux/x11/client.rs @@ -29,7 +29,7 @@ use x11rb::{ protocol::xkb::ConnectionExt as _, protocol::xproto::{ AtomEnum, ChangeWindowAttributesAux, ClientMessageData, ClientMessageEvent, - ConnectionExt as _, EventMask, Visibility, + ConnectionExt as _, EventMask, ModMask, Visibility, }, protocol::{Event, randr, render, xinput, xkb, xproto}, resource_manager::Database, @@ -1018,6 +1018,12 @@ impl X11Client { let modifiers = modifiers_from_state(event.state); state.modifiers = modifiers; state.pre_key_char_down.take(); + + // Macros containing modifiers might result in + // the modifiers missing from the event. + // We therefore update the mask from the global state. + update_xkb_mask_from_event_state(&mut state.xkb, event.state); + let keystroke = { let code = event.detail.into(); let mut keystroke = crate::Keystroke::from_xkb(&state.xkb, modifiers, code); @@ -1083,6 +1089,11 @@ impl X11Client { let modifiers = modifiers_from_state(event.state); state.modifiers = modifiers; + // Macros containing modifiers might result in + // the modifiers missing from the event. + // We therefore update the mask from the global state. + update_xkb_mask_from_event_state(&mut state.xkb, event.state); + let keystroke = { let code = event.detail.into(); let keystroke = crate::Keystroke::from_xkb(&state.xkb, modifiers, code); @@ -2516,3 +2527,19 @@ fn get_dpi_factor((width_px, height_px): (u32, u32), (width_mm, height_mm): (u64 fn valid_scale_factor(scale_factor: f32) -> bool { scale_factor.is_sign_positive() && scale_factor.is_normal() } + +#[inline] +fn update_xkb_mask_from_event_state(xkb: &mut xkbc::State, event_state: xproto::KeyButMask) { + let depressed_mods = event_state.remove((ModMask::LOCK | ModMask::M2).bits()); + let latched_mods = xkb.serialize_mods(xkbc::STATE_MODS_LATCHED); + let locked_mods = xkb.serialize_mods(xkbc::STATE_MODS_LOCKED); + let locked_layout = xkb.serialize_layout(xkbc::STATE_LAYOUT_LOCKED); + xkb.update_mask( + depressed_mods.into(), + latched_mods, + locked_mods, + 0, + 0, + locked_layout, + ); +} From 4573a59777a905204c50e8f746bf9319febce9b1 Mon Sep 17 00:00:00 2001 From: Xiaobo Liu Date: Tue, 16 Dec 2025 23:37:03 +0800 Subject: [PATCH 380/621] git_ui: Fix double slash in commit URLs (#44996) Release Notes: - Fixed double slash in commit URLs The github_url variable was generating URLs with an extra slash like "https://github.com//user/repo/commit/xxxx" due to manual string formatting of the base_url() result. Fixed by replacing manual URL construction with the proper build_commit_permalink() method that uses Url::join() for correct path handling, consistent with how other Git hosting providers construct URLs. Signed-off-by: Xiaobo Liu --- crates/git_ui/src/commit_view.rs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/crates/git_ui/src/commit_view.rs b/crates/git_ui/src/commit_view.rs index 8cb9d82826086371950d2c51fd06381dd013251f..0f5420fec4169f8e3d945dd8bd0987ebbaba8d19 100644 --- a/crates/git_ui/src/commit_view.rs +++ b/crates/git_ui/src/commit_view.rs @@ -3,7 +3,10 @@ use buffer_diff::{BufferDiff, BufferDiffSnapshot}; use editor::display_map::{BlockPlacement, BlockProperties, BlockStyle}; use editor::{Editor, EditorEvent, ExcerptRange, MultiBuffer, multibuffer_context_lines}; use git::repository::{CommitDetails, CommitDiff, RepoPath}; -use git::{GitHostingProviderRegistry, GitRemote, parse_git_remote_url}; +use git::{ + BuildCommitPermalinkParams, GitHostingProviderRegistry, GitRemote, ParsedGitRemote, + parse_git_remote_url, +}; use gpui::{ AnyElement, App, AppContext as _, AsyncApp, AsyncWindowContext, Context, Element, Entity, EventEmitter, FocusHandle, Focusable, InteractiveElement, IntoElement, ParentElement, @@ -393,13 +396,15 @@ impl CommitView { let remote_info = self.remote.as_ref().map(|remote| { let provider = remote.host.name(); - let url = format!( - "{}/{}/{}/commit/{}", - remote.host.base_url(), - remote.owner, - remote.repo, - commit.sha - ); + let parsed_remote = ParsedGitRemote { + owner: remote.owner.as_ref().into(), + repo: remote.repo.as_ref().into(), + }; + let params = BuildCommitPermalinkParams { sha: &commit.sha }; + let url = remote + .host + .build_commit_permalink(&parsed_remote, params) + .to_string(); (provider, url) }); From 935a7cc310db486b1e08483f24f26e7935e53679 Mon Sep 17 00:00:00 2001 From: Nihal Kumar <121309701+nihalxkumar@users.noreply.github.com> Date: Tue, 16 Dec 2025 21:16:14 +0530 Subject: [PATCH 381/621] terminal: Add ctrl+click link detection with mouse movement (#42526) Closes #41994 This PR introduces Element-bounded drag tolerance for Ctrl/Cmd+click in terminal. Previously, Ctrl/Cmd+click on terminal links required pixel-perfect accuracy. Any mouse movement during the click would cancel the navigation, making it frustrating to click on links, especially on high-DPI displays or with sensitive mice. Users can now click anywhere within a clickable element (file path, URL, hyperlink), drag the cursor anywhere within that same element's boundaries and release to trigger navigation Implementation: - Stores detected element metadata (`text` and `grid_range`) on Ctrl/Cmd+mouse-down - Tracks cursor position during drag, preserving click state while within element bounds - Verifies element match on mouse-up before triggering navigation - Uses existing `find_from_grid_point()` for element detection Before: [before.webm](https://github.com/user-attachments/assets/ee80de66-998e-4d8e-94d0-f5e65eb06d22) After: [after.webm](https://github.com/user-attachments/assets/7c9ddd9e-cfc1-4c79-b62c-78e9d909e6f4) Release Notes: - terminal: Fixed an issue where `ctrl|cmd+click` on links was very sensitive to mouse movement. Clicking links now tolerates mouse movement within the same clickable element, making link navigation more reliable --------- Co-authored-by: Ben Kunkle --- crates/terminal/src/terminal.rs | 287 +++++++++++++++++++++++++++----- 1 file changed, 249 insertions(+), 38 deletions(-) diff --git a/crates/terminal/src/terminal.rs b/crates/terminal/src/terminal.rs index c7ac75af0c810c55d470b1de8175c11c65855b58..e64780e2945363e71b357b79aee57024484d417c 100644 --- a/crates/terminal/src/terminal.rs +++ b/crates/terminal/src/terminal.rs @@ -155,8 +155,8 @@ enum InternalEvent { ScrollToAlacPoint(AlacPoint), SetSelection(Option<(Selection, AlacPoint)>), UpdateSelection(Point), - // Adjusted mouse position, should open FindHyperlink(Point, bool), + ProcessHyperlink((String, bool, Match), bool), // Whether keep selection when copy Copy(Option), // Vi mode events @@ -380,6 +380,7 @@ impl TerminalBuilder { is_remote_terminal: false, last_mouse_move_time: Instant::now(), last_hyperlink_search_position: None, + mouse_down_hyperlink: None, #[cfg(windows)] shell_program: None, activation_script: Vec::new(), @@ -610,6 +611,7 @@ impl TerminalBuilder { is_remote_terminal, last_mouse_move_time: Instant::now(), last_hyperlink_search_position: None, + mouse_down_hyperlink: None, #[cfg(windows)] shell_program, activation_script: activation_script.clone(), @@ -840,6 +842,7 @@ pub struct Terminal { is_remote_terminal: bool, last_mouse_move_time: Instant, last_hyperlink_search_position: Option>, + mouse_down_hyperlink: Option<(String, bool, Match)>, #[cfg(windows)] shell_program: Option, template: CopyTemplate, @@ -1152,7 +1155,6 @@ impl Terminal { } InternalEvent::FindHyperlink(position, open) => { trace!("Finding hyperlink at position: position={position:?}, open={open:?}"); - let prev_hovered_word = self.last_content.last_hovered_word.take(); let point = grid_point( *position, @@ -1166,47 +1168,53 @@ impl Terminal { point, &mut self.hyperlink_regex_searches, ) { - Some((maybe_url_or_path, is_url, url_match)) => { - let target = if is_url { - // Treat "file://" URLs like file paths to ensure - // that line numbers at the end of the path are - // handled correctly. - // file://{path} should be urldecoded, returning a urldecoded {path} - if let Some(path) = maybe_url_or_path.strip_prefix("file://") { - let decoded_path = urlencoding::decode(path) - .map(|decoded| decoded.into_owned()) - .unwrap_or(path.to_owned()); - - MaybeNavigationTarget::PathLike(PathLikeTarget { - maybe_path: decoded_path, - terminal_dir: self.working_directory(), - }) - } else { - MaybeNavigationTarget::Url(maybe_url_or_path.clone()) - } - } else { - MaybeNavigationTarget::PathLike(PathLikeTarget { - maybe_path: maybe_url_or_path.clone(), - terminal_dir: self.working_directory(), - }) - }; - if *open { - cx.emit(Event::Open(target)); - } else { - self.update_selected_word( - prev_hovered_word, - url_match, - maybe_url_or_path, - target, - cx, - ); - } + Some(hyperlink) => { + self.process_hyperlink(hyperlink, *open, cx); } None => { cx.emit(Event::NewNavigationTarget(None)); } } } + InternalEvent::ProcessHyperlink(hyperlink, open) => { + self.process_hyperlink(hyperlink.clone(), *open, cx); + } + } + } + + fn process_hyperlink( + &mut self, + hyperlink: (String, bool, Match), + open: bool, + cx: &mut Context, + ) { + let (maybe_url_or_path, is_url, url_match) = hyperlink; + let prev_hovered_word = self.last_content.last_hovered_word.take(); + + let target = if is_url { + if let Some(path) = maybe_url_or_path.strip_prefix("file://") { + let decoded_path = urlencoding::decode(path) + .map(|decoded| decoded.into_owned()) + .unwrap_or(path.to_owned()); + + MaybeNavigationTarget::PathLike(PathLikeTarget { + maybe_path: decoded_path, + terminal_dir: self.working_directory(), + }) + } else { + MaybeNavigationTarget::Url(maybe_url_or_path.clone()) + } + } else { + MaybeNavigationTarget::PathLike(PathLikeTarget { + maybe_path: maybe_url_or_path.clone(), + terminal_dir: self.working_directory(), + }) + }; + + if open { + cx.emit(Event::Open(target)); + } else { + self.update_selected_word(prev_hovered_word, url_match, maybe_url_or_path, target, cx); } } @@ -1777,6 +1785,20 @@ impl Terminal { ) { let position = e.position - self.last_content.terminal_bounds.bounds.origin; if !self.mouse_mode(e.modifiers.shift) { + if let Some((.., hyperlink_range)) = &self.mouse_down_hyperlink { + let point = grid_point( + position, + self.last_content.terminal_bounds, + self.last_content.display_offset, + ); + + if !hyperlink_range.contains(&point) { + self.mouse_down_hyperlink = None; + } else { + return; + } + } + self.selection_phase = SelectionPhase::Selecting; // Alacritty has the same ordering, of first updating the selection // then scrolling 15ms later @@ -1823,6 +1845,23 @@ impl Terminal { self.last_content.display_offset, ); + if e.button == MouseButton::Left + && e.modifiers.secondary() + && !self.mouse_mode(e.modifiers.shift) + { + let term_lock = self.term.lock(); + self.mouse_down_hyperlink = terminal_hyperlinks::find_from_grid_point( + &term_lock, + point, + &mut self.hyperlink_regex_searches, + ); + drop(term_lock); + + if self.mouse_down_hyperlink.is_some() { + return; + } + } + if self.mouse_mode(e.modifiers.shift) { if let Some(bytes) = mouse_button_report(point, e.button, e.modifiers, true, self.last_content.mode) @@ -1893,6 +1932,31 @@ impl Terminal { self.copy(Some(true)); } + if let Some(mouse_down_hyperlink) = self.mouse_down_hyperlink.take() { + let point = grid_point( + position, + self.last_content.terminal_bounds, + self.last_content.display_offset, + ); + + if let Some(mouse_up_hyperlink) = { + let term_lock = self.term.lock(); + terminal_hyperlinks::find_from_grid_point( + &term_lock, + point, + &mut self.hyperlink_regex_searches, + ) + } { + if mouse_down_hyperlink == mouse_up_hyperlink { + self.events + .push_back(InternalEvent::ProcessHyperlink(mouse_up_hyperlink, true)); + self.selection_phase = SelectionPhase::Ended; + self.last_mouse = None; + return; + } + } + } + //Hyperlinks if self.selection_phase == SelectionPhase::Ended { let mouse_cell_index = @@ -2409,10 +2473,91 @@ mod tests { term::cell::Cell, }; use collections::HashMap; - use gpui::{Pixels, Point, TestAppContext, bounds, point, size, smol_timeout}; + use gpui::{ + Entity, Modifiers, MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent, Pixels, + Point, TestAppContext, bounds, point, size, smol_timeout, + }; use rand::{Rng, distr, rngs::ThreadRng}; use task::ShellBuilder; + fn init_ctrl_click_hyperlink_test(cx: &mut TestAppContext, output: &[u8]) -> Entity { + cx.update(|cx| { + let settings_store = settings::SettingsStore::test(cx); + cx.set_global(settings_store); + }); + + let terminal = cx.new(|cx| { + TerminalBuilder::new_display_only(CursorShape::default(), AlternateScroll::On, None, 0) + .unwrap() + .subscribe(cx) + }); + + terminal.update(cx, |terminal, cx| { + terminal.write_output(output, cx); + }); + + cx.run_until_parked(); + + terminal.update(cx, |terminal, _cx| { + let term_lock = terminal.term.lock(); + terminal.last_content = Terminal::make_content(&term_lock, &terminal.last_content); + drop(term_lock); + + let terminal_bounds = TerminalBounds::new( + px(20.0), + px(10.0), + bounds(point(px(0.0), px(0.0)), size(px(400.0), px(400.0))), + ); + terminal.last_content.terminal_bounds = terminal_bounds; + terminal.events.clear(); + }); + + terminal + } + + fn ctrl_mouse_down_at( + terminal: &mut Terminal, + position: Point, + cx: &mut Context, + ) { + let mouse_down = MouseDownEvent { + button: MouseButton::Left, + position, + modifiers: Modifiers::secondary_key(), + click_count: 1, + first_mouse: true, + }; + terminal.mouse_down(&mouse_down, cx); + } + + fn ctrl_mouse_move_to( + terminal: &mut Terminal, + position: Point, + cx: &mut Context, + ) { + let terminal_bounds = terminal.last_content.terminal_bounds.bounds; + let drag_event = MouseMoveEvent { + position, + pressed_button: Some(MouseButton::Left), + modifiers: Modifiers::secondary_key(), + }; + terminal.mouse_drag(&drag_event, terminal_bounds, cx); + } + + fn ctrl_mouse_up_at( + terminal: &mut Terminal, + position: Point, + cx: &mut Context, + ) { + let mouse_up = MouseUpEvent { + button: MouseButton::Left, + position, + modifiers: Modifiers::secondary_key(), + click_count: 1, + }; + terminal.mouse_up(&mouse_up, cx); + } + #[gpui::test] async fn test_basic_terminal(cx: &mut TestAppContext) { cx.executor().allow_parking(); @@ -2863,6 +3008,72 @@ mod tests { ); } + #[gpui::test] + async fn test_hyperlink_ctrl_click_same_position(cx: &mut TestAppContext) { + let terminal = init_ctrl_click_hyperlink_test(cx, b"Visit https://zed.dev/ for more\r\n"); + + terminal.update(cx, |terminal, cx| { + let click_position = point(px(80.0), px(10.0)); + ctrl_mouse_down_at(terminal, click_position, cx); + ctrl_mouse_up_at(terminal, click_position, cx); + + assert!( + terminal + .events + .iter() + .any(|event| matches!(event, InternalEvent::ProcessHyperlink(_, true))), + "Should have ProcessHyperlink event when ctrl+clicking on same hyperlink position" + ); + }); + } + + #[gpui::test] + async fn test_hyperlink_ctrl_click_drag_outside_bounds(cx: &mut TestAppContext) { + let terminal = init_ctrl_click_hyperlink_test( + cx, + b"Visit https://zed.dev/ for more\r\nThis is another line\r\n", + ); + + terminal.update(cx, |terminal, cx| { + let down_position = point(px(80.0), px(10.0)); + let up_position = point(px(10.0), px(50.0)); + + ctrl_mouse_down_at(terminal, down_position, cx); + ctrl_mouse_move_to(terminal, up_position, cx); + ctrl_mouse_up_at(terminal, up_position, cx); + + assert!( + !terminal + .events + .iter() + .any(|event| matches!(event, InternalEvent::ProcessHyperlink(_, _))), + "Should NOT have ProcessHyperlink event when dragging outside the hyperlink" + ); + }); + } + + #[gpui::test] + async fn test_hyperlink_ctrl_click_drag_within_bounds(cx: &mut TestAppContext) { + let terminal = init_ctrl_click_hyperlink_test(cx, b"Visit https://zed.dev/ for more\r\n"); + + terminal.update(cx, |terminal, cx| { + let down_position = point(px(70.0), px(10.0)); + let up_position = point(px(130.0), px(10.0)); + + ctrl_mouse_down_at(terminal, down_position, cx); + ctrl_mouse_move_to(terminal, up_position, cx); + ctrl_mouse_up_at(terminal, up_position, cx); + + assert!( + terminal + .events + .iter() + .any(|event| matches!(event, InternalEvent::ProcessHyperlink(_, true))), + "Should have ProcessHyperlink event when dragging within hyperlink bounds" + ); + }); + } + mod perf { use super::super::*; use gpui::{ From 005a85e57b14aed31e7a55dca9efe2b28f158d36 Mon Sep 17 00:00:00 2001 From: Dan Greco Date: Tue, 16 Dec 2025 10:48:14 -0500 Subject: [PATCH 382/621] Add project settings schema to schema_generator CLI (#44321) Release Notes: - Added project settings schema to the schema_generator CLI. This allows for exporting the project settings schema as JSON for use in other tools. --- Cargo.lock | 1 + crates/schema_generator/Cargo.toml | 1 + crates/schema_generator/src/main.rs | 6 ++++++ 3 files changed, 8 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 5b35991dfde30b4b976ae96a552862876a245486..b9a9dee415d76123cf3c9c86686f94e704b5a4db 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14249,6 +14249,7 @@ dependencies = [ "schemars", "serde", "serde_json", + "settings", "theme", ] diff --git a/crates/schema_generator/Cargo.toml b/crates/schema_generator/Cargo.toml index 865f76f4af917606af5d61d173950493fdde07c7..b92298a3b41d62b861c19a1f22ceaee0d63828b5 100644 --- a/crates/schema_generator/Cargo.toml +++ b/crates/schema_generator/Cargo.toml @@ -15,4 +15,5 @@ env_logger.workspace = true schemars = { workspace = true, features = ["indexmap2"] } serde.workspace = true serde_json.workspace = true +settings.workspace = true theme.workspace = true diff --git a/crates/schema_generator/src/main.rs b/crates/schema_generator/src/main.rs index a7e406a1a9c0426ac8294c05bd475931c3e62fb4..a77060c54d1361dc96204238a282f8e75946a37b 100644 --- a/crates/schema_generator/src/main.rs +++ b/crates/schema_generator/src/main.rs @@ -1,6 +1,7 @@ use anyhow::Result; use clap::{Parser, ValueEnum}; use schemars::schema_for; +use settings::ProjectSettingsContent; use theme::{IconThemeFamilyContent, ThemeFamilyContent}; #[derive(Parser, Debug)] @@ -14,6 +15,7 @@ pub struct Args { pub enum SchemaType { Theme, IconTheme, + Project, } fn main() -> Result<()> { @@ -30,6 +32,10 @@ fn main() -> Result<()> { let schema = schema_for!(IconThemeFamilyContent); println!("{}", serde_json::to_string_pretty(&schema)?); } + SchemaType::Project => { + let schema = schema_for!(ProjectSettingsContent); + println!("{}", serde_json::to_string_pretty(&schema)?); + } } Ok(()) From 914b0117fb5a23469af85e567d5723eca6b53635 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Tue, 16 Dec 2025 16:59:26 +0100 Subject: [PATCH 383/621] Optimize editor rendering when clipped by parent containers (#44995) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #44997 ## Summary Optimizes editor rendering when an editor is partially clipped by a parent container (e.g., a `List`). The editor now only lays out and renders lines that are actually visible within the viewport, rather than all lines in the document. ## Problem When an `AutoHeight` editor with thousands of lines is placed inside a scrollable `List` (such as in the Agent Panel thread view), the editor would lay out **all** lines during prepaint, even though only a small portion was visible. Profiling showed that ~50% of frame time was spent in `EditorElement::prepaint` → `LineWithInvisibles::from_chunks`, processing thousands of invisible lines. ## Solution Calculate the intersection of the editor's bounds with the current content mask (which represents the visible viewport after all parent clipping). Use this to determine: 1. `clipped_top_in_lines` - how many lines are clipped above the viewport 2. `visible_height_in_lines` - how many lines are actually visible Then adjust `start_row` and `end_row` to only include visible lines. The parent container handles positioning, so `scroll_position` remains unchanged for paint calculations. ## Example For a 3000-line editor where only 50 lines are visible: - **Before**: Lay out and render 3000 lines - **After**: Lay out and render ~50 lines ## Testing Verified the following scenarios work correctly: - Editor fully visible (no clipping) - Editor clipped from top - Editor clipped from bottom - Editor completely outside viewport (renders nothing) - Fractional line clipping at boundaries - Scrollable editors with internal scroll state inside a clipped container Release Notes: - Improved agent panel performance when rendering large diffs. --- crates/editor/src/element.rs | 17 +++++++++++++++-- crates/editor/src/test.rs | 8 +++----- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index 8de660275ba9b455aec610568c41347888654495..95047569c31c2e306b0f984832b568f052e4179a 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -9164,6 +9164,15 @@ impl Element for EditorElement { let height_in_lines = f64::from(bounds.size.height / line_height); let max_row = snapshot.max_point().row().as_f64(); + // Calculate how much of the editor is clipped by parent containers (e.g., List). + // This allows us to only render lines that are actually visible, which is + // critical for performance when large AutoHeight editors are inside Lists. + let visible_bounds = window.content_mask().bounds; + let clipped_top = (visible_bounds.origin.y - bounds.origin.y).max(px(0.)); + let clipped_top_in_lines = f64::from(clipped_top / line_height); + let visible_height_in_lines = + f64::from(visible_bounds.size.height / line_height); + // The max scroll position for the top of the window let max_scroll_top = if matches!( snapshot.mode, @@ -9220,10 +9229,14 @@ impl Element for EditorElement { let mut scroll_position = snapshot.scroll_position(); // The scroll position is a fractional point, the whole number of which represents // the top of the window in terms of display rows. - let start_row = DisplayRow(scroll_position.y as u32); + // We add clipped_top_in_lines to skip rows that are clipped by parent containers, + // but we don't modify scroll_position itself since the parent handles positioning. + let start_row = + DisplayRow((scroll_position.y + clipped_top_in_lines).floor() as u32); let max_row = snapshot.max_point().row(); let end_row = cmp::min( - (scroll_position.y + height_in_lines).ceil() as u32, + (scroll_position.y + clipped_top_in_lines + visible_height_in_lines).ceil() + as u32, max_row.next_row().0, ); let end_row = DisplayRow(end_row); diff --git a/crates/editor/src/test.rs b/crates/editor/src/test.rs index 5a0652bdd199a638f92234b1d50232071db18e07..1cc619385446502db6a3a0dceb6e70fa4b4e8416 100644 --- a/crates/editor/src/test.rs +++ b/crates/editor/src/test.rs @@ -176,11 +176,9 @@ pub fn block_content_for_tests( } pub fn editor_content_with_blocks(editor: &Entity, cx: &mut VisualTestContext) -> String { - cx.draw( - gpui::Point::default(), - size(px(3000.0), px(3000.0)), - |_, _| editor.clone(), - ); + let draw_size = size(px(3000.0), px(3000.0)); + cx.simulate_resize(draw_size); + cx.draw(gpui::Point::default(), draw_size, |_, _| editor.clone()); let (snapshot, mut lines, blocks) = editor.update_in(cx, |editor, window, cx| { let snapshot = editor.snapshot(window, cx); let text = editor.display_text(cx); From 8b9fa1581c038abf64bd2a4d39f1a1f367c07595 Mon Sep 17 00:00:00 2001 From: Lena <241371603+zelenenka@users.noreply.github.com> Date: Tue, 16 Dec 2025 17:01:28 +0100 Subject: [PATCH 384/621] Update contribution ideas and guidelines (#45001) Release Notes: - N/A --- CONTRIBUTING.md | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9cbac4af2b57f0350fa9f5665e110e0d6e7f6341..f7aceadce18788ae2b8bb9d0fe4b5f16225e70d2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -15,15 +15,17 @@ with the community to improve the product in ways we haven't thought of (or had In particular we love PRs that are: -- Fixes to existing bugs and issues. -- Small enhancements to existing features, particularly to make them work for more people. +- Fixing or extending the docs. +- Fixing bugs. +- Small enhancements to existing features to make them work for more people (making things work on more platforms/modes/whatever). - Small extra features, like keybindings or actions you miss from other editors or extensions. -- Work towards shipping larger features on our roadmap. +- Part of a Community Program like [Let's Git Together](https://github.com/zed-industries/zed/issues/41541). If you're looking for concrete ideas: -- Our [top-ranking issues](https://github.com/zed-industries/zed/issues/5393) based on votes by the community. -- Our [public roadmap](https://zed.dev/roadmap) contains a rough outline of our near-term priorities for Zed. +- [Curated board of issues](https://github.com/orgs/zed-industries/projects/69) suitable for everyone from first-time contributors to seasoned community champions. +- [Triaged bugs with confirmed steps to reproduce](https://github.com/zed-industries/zed/issues?q=is%3Aissue%20state%3Aopen%20type%3ABug%20label%3Astate%3Areproducible). +- [Area labels](https://github.com/zed-industries/zed/labels?q=area%3A*) to browse bugs in a specific part of the product you care about (after clicking on an area label, add type:Bug to the search). ## Sending changes @@ -37,9 +39,17 @@ like, sorry). Although we will take a look, we tend to only merge about half the PRs that are submitted. If you'd like your PR to have the best chance of being merged: -- Include a clear description of what you're solving, and why it's important to you. -- Include tests. -- If it changes the UI, attach screenshots or screen recordings. +- Make sure the change is **desired**: we're always happy to accept bugfixes, + but features should be confirmed with us first if you aim to avoid wasted + effort. If there isn't already a GitHub issue for your feature with staff + confirmation that we want it, start with a GitHub discussion rather than a PR. +- Include a clear description of **what you're solving**, and why it's important. +- Include **tests**. +- If it changes the UI, attach **screenshots** or screen recordings. +- Make the PR about **one thing only**, e.g. if it's a bugfix, don't add two + features and a refactoring on top of that. +- Keep AI assistance under your judgement and responsibility: it's unlikely + we'll merge a vibe-coded PR that the author doesn't understand. The internal advice for reviewers is as follows: @@ -50,10 +60,9 @@ The internal advice for reviewers is as follows: If you need more feedback from us: the best way is to be responsive to Github comments, or to offer up time to pair with us. -If you are making a larger change, or need advice on how to finish the change -you're making, please open the PR early. We would love to help you get -things right, and it's often easier to see how to solve a problem before the -diff gets too big. +If you need help deciding how to fix a bug, or finish implementing a feature +that we've agreed we want, please open a PR early so we can discuss how to make +the change with code in hand. ## Things we will (probably) not merge @@ -61,11 +70,11 @@ Although there are few hard and fast rules, typically we don't merge: - Anything that can be provided by an extension. For example a new language, or theme. For adding themes or support for a new language to Zed, check out our [docs on developing extensions](https://zed.dev/docs/extensions/developing-extensions). - New file icons. Zed's default icon theme consists of icons that are hand-designed to fit together in a cohesive manner, please don't submit PRs with off-the-shelf SVGs. +- Features where (in our subjective opinion) the extra complexity isn't worth it for the number of people who will benefit. - Giant refactorings. - Non-trivial changes with no tests. - Stylistic code changes that do not alter any app logic. Reducing allocations, removing `.unwrap()`s, fixing typos is great; making code "more readable" — maybe not so much. -- Features where (in our subjective opinion) the extra complexity isn't worth it for the number of people who will benefit. -- Anything that seems completely AI generated. +- Anything that seems AI-generated without understanding the output. ## Bird's-eye view of Zed From 420254cff1498bc141f89edca345b3603d535984 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Tue, 16 Dec 2025 09:18:51 -0700 Subject: [PATCH 385/621] Re-add save_file and restore_file_from_disk agent tools (#45005) This re-introduces the `save_file` and `restore_file_from_disk` agent tools that were reverted in #44949. I pushed that original PR without trying it just to get the build off my machine, but I had missed a step: the tools weren't added to the default profile settings in `default.json`, so they were never enabled even though the code was present. ## Changes - Add `save_file` and `restore_file_from_disk` to the "write" profile in `default.json` - Add `Thread::has_tool()` method to check tool availability at runtime - Make `edit_file_tool`'s dirty buffer error message conditional on whether `save_file`/`restore_file_from_disk` tools are available (so the agent gets appropriate guidance based on what tools it actually has) - Update test to match new conditional error message behavior Release Notes: - Added `save_file` and `restore_file_from_disk` agent tools to handle dirty buffers when editing files --- assets/settings/default.json | 2 + crates/agent/src/thread.rs | 11 +- crates/agent/src/tools.rs | 8 +- crates/agent/src/tools/edit_file_tool.rs | 47 ++- .../src/tools/restore_file_from_disk_tool.rs | 352 ++++++++++++++++++ crates/agent/src/tools/save_file_tool.rs | 351 +++++++++++++++++ 6 files changed, 760 insertions(+), 11 deletions(-) create mode 100644 crates/agent/src/tools/restore_file_from_disk_tool.rs create mode 100644 crates/agent/src/tools/save_file_tool.rs diff --git a/assets/settings/default.json b/assets/settings/default.json index 146915dd1a242e2a8b70ba1010bb5fbe09dbbbbc..0ef3bb70c71bb96828bc1b1c2594376b15bada90 100644 --- a/assets/settings/default.json +++ b/assets/settings/default.json @@ -972,6 +972,8 @@ "now": true, "find_path": true, "read_file": true, + "restore_file_from_disk": true, + "save_file": true, "open": true, "grep": true, "terminal": true, diff --git a/crates/agent/src/thread.rs b/crates/agent/src/thread.rs index dbf29c68766cfe28d0bce1d82ed53536446326e2..bed3db853a3106ca4df9676d799b4a2bfa0106a0 100644 --- a/crates/agent/src/thread.rs +++ b/crates/agent/src/thread.rs @@ -2,7 +2,8 @@ use crate::{ ContextServerRegistry, CopyPathTool, CreateDirectoryTool, DbLanguageModel, DbThread, DeletePathTool, DiagnosticsTool, EditFileTool, FetchTool, FindPathTool, GrepTool, ListDirectoryTool, MovePathTool, NowTool, OpenTool, ProjectSnapshot, ReadFileTool, - SystemPromptTemplate, Template, Templates, TerminalTool, ThinkingTool, WebSearchTool, + RestoreFileFromDiskTool, SaveFileTool, SystemPromptTemplate, Template, Templates, TerminalTool, + ThinkingTool, WebSearchTool, }; use acp_thread::{MentionUri, UserMessageId}; use action_log::ActionLog; @@ -1002,6 +1003,8 @@ impl Thread { self.project.clone(), self.action_log.clone(), )); + self.add_tool(SaveFileTool::new(self.project.clone())); + self.add_tool(RestoreFileFromDiskTool::new(self.project.clone())); self.add_tool(TerminalTool::new(self.project.clone(), environment)); self.add_tool(ThinkingTool); self.add_tool(WebSearchTool); @@ -1966,6 +1969,12 @@ impl Thread { self.running_turn.as_ref()?.tools.get(name).cloned() } + pub fn has_tool(&self, name: &str) -> bool { + self.running_turn + .as_ref() + .is_some_and(|turn| turn.tools.contains_key(name)) + } + fn build_request_messages( &self, available_tools: Vec, diff --git a/crates/agent/src/tools.rs b/crates/agent/src/tools.rs index 62a52998a705e11d1c9e69cbade7f427cc9cfc32..358903a32baa5ead9b073642015e6829501307a2 100644 --- a/crates/agent/src/tools.rs +++ b/crates/agent/src/tools.rs @@ -4,7 +4,6 @@ mod create_directory_tool; mod delete_path_tool; mod diagnostics_tool; mod edit_file_tool; - mod fetch_tool; mod find_path_tool; mod grep_tool; @@ -13,6 +12,8 @@ mod move_path_tool; mod now_tool; mod open_tool; mod read_file_tool; +mod restore_file_from_disk_tool; +mod save_file_tool; mod terminal_tool; mod thinking_tool; @@ -27,7 +28,6 @@ pub use create_directory_tool::*; pub use delete_path_tool::*; pub use diagnostics_tool::*; pub use edit_file_tool::*; - pub use fetch_tool::*; pub use find_path_tool::*; pub use grep_tool::*; @@ -36,6 +36,8 @@ pub use move_path_tool::*; pub use now_tool::*; pub use open_tool::*; pub use read_file_tool::*; +pub use restore_file_from_disk_tool::*; +pub use save_file_tool::*; pub use terminal_tool::*; pub use thinking_tool::*; @@ -92,6 +94,8 @@ tools! { NowTool, OpenTool, ReadFileTool, + RestoreFileFromDiskTool, + SaveFileTool, TerminalTool, ThinkingTool, WebSearchTool, diff --git a/crates/agent/src/tools/edit_file_tool.rs b/crates/agent/src/tools/edit_file_tool.rs index 0ab99426e2e9645adf3f837d21c28dc285ab6ea2..3acb7f5951f3ca4b682dcabc62a0d54c35ab08d6 100644 --- a/crates/agent/src/tools/edit_file_tool.rs +++ b/crates/agent/src/tools/edit_file_tool.rs @@ -306,20 +306,39 @@ impl AgentTool for EditFileTool { // Check if the file has been modified since the agent last read it if let Some(abs_path) = abs_path.as_ref() { - let (last_read_mtime, current_mtime, is_dirty) = self.thread.update(cx, |thread, cx| { + let (last_read_mtime, current_mtime, is_dirty, has_save_tool, has_restore_tool) = self.thread.update(cx, |thread, cx| { let last_read = thread.file_read_times.get(abs_path).copied(); let current = buffer.read(cx).file().and_then(|file| file.disk_state().mtime()); let dirty = buffer.read(cx).is_dirty(); - (last_read, current, dirty) + let has_save = thread.has_tool("save_file"); + let has_restore = thread.has_tool("restore_file_from_disk"); + (last_read, current, dirty, has_save, has_restore) })?; // Check for unsaved changes first - these indicate modifications we don't know about if is_dirty { - anyhow::bail!( - "This file cannot be written to because it has unsaved changes. \ - Please end the current conversation immediately by telling the user you want to write to this file (mention its path explicitly) but you can't write to it because it has unsaved changes. \ - Ask the user to save that buffer's changes and to inform you when it's ok to proceed." - ); + let message = match (has_save_tool, has_restore_tool) { + (true, true) => { + "This file has unsaved changes. Ask the user whether they want to keep or discard those changes. \ + If they want to keep them, ask for confirmation then use the save_file tool to save the file, then retry this edit. \ + If they want to discard them, ask for confirmation then use the restore_file_from_disk tool to restore the on-disk contents, then retry this edit." + } + (true, false) => { + "This file has unsaved changes. Ask the user whether they want to keep or discard those changes. \ + If they want to keep them, ask for confirmation then use the save_file tool to save the file, then retry this edit. \ + If they want to discard them, ask the user to manually revert the file, then inform you when it's ok to proceed." + } + (false, true) => { + "This file has unsaved changes. Ask the user whether they want to keep or discard those changes. \ + If they want to keep them, ask the user to manually save the file, then inform you when it's ok to proceed. \ + If they want to discard them, ask for confirmation then use the restore_file_from_disk tool to restore the on-disk contents, then retry this edit." + } + (false, false) => { + "This file has unsaved changes. Ask the user whether they want to keep or discard those changes, \ + then ask them to save or revert the file manually and inform you when it's ok to proceed." + } + }; + anyhow::bail!("{}", message); } // Check if the file was modified on disk since we last read it @@ -2202,9 +2221,21 @@ mod tests { assert!(result.is_err(), "Edit should fail when buffer is dirty"); let error_msg = result.unwrap_err().to_string(); assert!( - error_msg.contains("cannot be written to because it has unsaved changes"), + error_msg.contains("This file has unsaved changes."), "Error should mention unsaved changes, got: {}", error_msg ); + assert!( + error_msg.contains("keep or discard"), + "Error should ask whether to keep or discard changes, got: {}", + error_msg + ); + // Since save_file and restore_file_from_disk tools aren't added to the thread, + // the error message should ask the user to manually save or revert + assert!( + error_msg.contains("save or revert the file manually"), + "Error should ask user to manually save or revert when tools aren't available, got: {}", + error_msg + ); } } diff --git a/crates/agent/src/tools/restore_file_from_disk_tool.rs b/crates/agent/src/tools/restore_file_from_disk_tool.rs new file mode 100644 index 0000000000000000000000000000000000000000..f5723f6ee3ee46144152dd3ed2939ab2cfaca9c0 --- /dev/null +++ b/crates/agent/src/tools/restore_file_from_disk_tool.rs @@ -0,0 +1,352 @@ +use agent_client_protocol as acp; +use anyhow::Result; +use collections::FxHashSet; +use gpui::{App, Entity, SharedString, Task}; +use language::Buffer; +use project::Project; +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; +use std::path::PathBuf; +use std::sync::Arc; + +use crate::{AgentTool, ToolCallEventStream}; + +/// Discards unsaved changes in open buffers by reloading file contents from disk. +/// +/// Use this tool when: +/// - You attempted to edit files but they have unsaved changes the user does not want to keep. +/// - You want to reset files to the on-disk state before retrying an edit. +/// +/// Only use this tool after asking the user for permission, because it will discard unsaved changes. +#[derive(Debug, Serialize, Deserialize, JsonSchema)] +pub struct RestoreFileFromDiskToolInput { + /// The paths of the files to restore from disk. + pub paths: Vec, +} + +pub struct RestoreFileFromDiskTool { + project: Entity, +} + +impl RestoreFileFromDiskTool { + pub fn new(project: Entity) -> Self { + Self { project } + } +} + +impl AgentTool for RestoreFileFromDiskTool { + type Input = RestoreFileFromDiskToolInput; + type Output = String; + + fn name() -> &'static str { + "restore_file_from_disk" + } + + fn kind() -> acp::ToolKind { + acp::ToolKind::Other + } + + fn initial_title( + &self, + input: Result, + _cx: &mut App, + ) -> SharedString { + match input { + Ok(input) if input.paths.len() == 1 => "Restore file from disk".into(), + Ok(input) => format!("Restore {} files from disk", input.paths.len()).into(), + Err(_) => "Restore files from disk".into(), + } + } + + fn run( + self: Arc, + input: Self::Input, + _event_stream: ToolCallEventStream, + cx: &mut App, + ) -> Task> { + let project = self.project.clone(); + let input_paths = input.paths; + + cx.spawn(async move |cx| { + let mut buffers_to_reload: FxHashSet> = FxHashSet::default(); + + let mut restored_paths: Vec = Vec::new(); + let mut clean_paths: Vec = Vec::new(); + let mut not_found_paths: Vec = Vec::new(); + let mut open_errors: Vec<(PathBuf, String)> = Vec::new(); + let mut dirty_check_errors: Vec<(PathBuf, String)> = Vec::new(); + let mut reload_errors: Vec = Vec::new(); + + for path in input_paths { + let project_path = + project.read_with(cx, |project, cx| project.find_project_path(&path, cx)); + + let project_path = match project_path { + Ok(Some(project_path)) => project_path, + Ok(None) => { + not_found_paths.push(path); + continue; + } + Err(error) => { + open_errors.push((path, error.to_string())); + continue; + } + }; + + let open_buffer_task = + project.update(cx, |project, cx| project.open_buffer(project_path, cx)); + + let buffer = match open_buffer_task { + Ok(task) => match task.await { + Ok(buffer) => buffer, + Err(error) => { + open_errors.push((path, error.to_string())); + continue; + } + }, + Err(error) => { + open_errors.push((path, error.to_string())); + continue; + } + }; + + let is_dirty = match buffer.read_with(cx, |buffer, _| buffer.is_dirty()) { + Ok(is_dirty) => is_dirty, + Err(error) => { + dirty_check_errors.push((path, error.to_string())); + continue; + } + }; + + if is_dirty { + buffers_to_reload.insert(buffer); + restored_paths.push(path); + } else { + clean_paths.push(path); + } + } + + if !buffers_to_reload.is_empty() { + let reload_task = project.update(cx, |project, cx| { + project.reload_buffers(buffers_to_reload, true, cx) + }); + + match reload_task { + Ok(task) => { + if let Err(error) = task.await { + reload_errors.push(error.to_string()); + } + } + Err(error) => { + reload_errors.push(error.to_string()); + } + } + } + + let mut lines: Vec = Vec::new(); + + if !restored_paths.is_empty() { + lines.push(format!("Restored {} file(s).", restored_paths.len())); + } + if !clean_paths.is_empty() { + lines.push(format!("{} clean.", clean_paths.len())); + } + + if !not_found_paths.is_empty() { + lines.push(format!("Not found ({}):", not_found_paths.len())); + for path in ¬_found_paths { + lines.push(format!("- {}", path.display())); + } + } + if !open_errors.is_empty() { + lines.push(format!("Open failed ({}):", open_errors.len())); + for (path, error) in &open_errors { + lines.push(format!("- {}: {}", path.display(), error)); + } + } + if !dirty_check_errors.is_empty() { + lines.push(format!( + "Dirty check failed ({}):", + dirty_check_errors.len() + )); + for (path, error) in &dirty_check_errors { + lines.push(format!("- {}: {}", path.display(), error)); + } + } + if !reload_errors.is_empty() { + lines.push(format!("Reload failed ({}):", reload_errors.len())); + for error in &reload_errors { + lines.push(format!("- {}", error)); + } + } + + if lines.is_empty() { + Ok("No paths provided.".to_string()) + } else { + Ok(lines.join("\n")) + } + }) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use fs::Fs; + use gpui::TestAppContext; + use language::LineEnding; + use project::FakeFs; + use serde_json::json; + use settings::SettingsStore; + use util::path; + + fn init_test(cx: &mut TestAppContext) { + cx.update(|cx| { + let settings_store = SettingsStore::test(cx); + cx.set_global(settings_store); + }); + } + + #[gpui::test] + async fn test_restore_file_from_disk_output_and_effects(cx: &mut TestAppContext) { + init_test(cx); + + let fs = FakeFs::new(cx.executor()); + fs.insert_tree( + "/root", + json!({ + "dirty.txt": "on disk: dirty\n", + "clean.txt": "on disk: clean\n", + }), + ) + .await; + + let project = Project::test(fs.clone(), [path!("/root").as_ref()], cx).await; + let tool = Arc::new(RestoreFileFromDiskTool::new(project.clone())); + + // Make dirty.txt dirty in-memory by saving different content into the buffer without saving to disk. + let dirty_project_path = project.read_with(cx, |project, cx| { + project + .find_project_path("root/dirty.txt", cx) + .expect("dirty.txt should exist in project") + }); + + let dirty_buffer = project + .update(cx, |project, cx| { + project.open_buffer(dirty_project_path, cx) + }) + .await + .unwrap(); + dirty_buffer.update(cx, |buffer, cx| { + buffer.edit([(0..buffer.len(), "in memory: dirty\n")], None, cx); + }); + assert!( + dirty_buffer.read_with(cx, |buffer, _| buffer.is_dirty()), + "dirty.txt buffer should be dirty before restore" + ); + + // Ensure clean.txt is opened but remains clean. + let clean_project_path = project.read_with(cx, |project, cx| { + project + .find_project_path("root/clean.txt", cx) + .expect("clean.txt should exist in project") + }); + + let clean_buffer = project + .update(cx, |project, cx| { + project.open_buffer(clean_project_path, cx) + }) + .await + .unwrap(); + assert!( + !clean_buffer.read_with(cx, |buffer, _| buffer.is_dirty()), + "clean.txt buffer should start clean" + ); + + let output = cx + .update(|cx| { + tool.clone().run( + RestoreFileFromDiskToolInput { + paths: vec![ + PathBuf::from("root/dirty.txt"), + PathBuf::from("root/clean.txt"), + ], + }, + ToolCallEventStream::test().0, + cx, + ) + }) + .await + .unwrap(); + + // Output should mention restored + clean. + assert!( + output.contains("Restored 1 file(s)."), + "expected restored count line, got:\n{output}" + ); + assert!( + output.contains("1 clean."), + "expected clean count line, got:\n{output}" + ); + + // Effect: dirty buffer should be restored back to disk content and become clean. + let dirty_text = dirty_buffer.read_with(cx, |buffer, _| buffer.text()); + assert_eq!( + dirty_text, "on disk: dirty\n", + "dirty.txt buffer should be restored to disk contents" + ); + assert!( + !dirty_buffer.read_with(cx, |buffer, _| buffer.is_dirty()), + "dirty.txt buffer should not be dirty after restore" + ); + + // Disk contents should be unchanged (restore-from-disk should not write). + let disk_dirty = fs.load(path!("/root/dirty.txt").as_ref()).await.unwrap(); + assert_eq!(disk_dirty, "on disk: dirty\n"); + + // Sanity: clean buffer should remain clean and unchanged. + let clean_text = clean_buffer.read_with(cx, |buffer, _| buffer.text()); + assert_eq!(clean_text, "on disk: clean\n"); + assert!( + !clean_buffer.read_with(cx, |buffer, _| buffer.is_dirty()), + "clean.txt buffer should remain clean" + ); + + // Test empty paths case. + let output = cx + .update(|cx| { + tool.clone().run( + RestoreFileFromDiskToolInput { paths: vec![] }, + ToolCallEventStream::test().0, + cx, + ) + }) + .await + .unwrap(); + assert_eq!(output, "No paths provided."); + + // Test not-found path case (path outside the project root). + let output = cx + .update(|cx| { + tool.clone().run( + RestoreFileFromDiskToolInput { + paths: vec![PathBuf::from("nonexistent/path.txt")], + }, + ToolCallEventStream::test().0, + cx, + ) + }) + .await + .unwrap(); + assert!( + output.contains("Not found (1):"), + "expected not-found header line, got:\n{output}" + ); + assert!( + output.contains("- nonexistent/path.txt"), + "expected not-found path bullet, got:\n{output}" + ); + + let _ = LineEnding::Unix; // keep import used if the buffer edit API changes + } +} diff --git a/crates/agent/src/tools/save_file_tool.rs b/crates/agent/src/tools/save_file_tool.rs new file mode 100644 index 0000000000000000000000000000000000000000..429352200109c52303c9f6f94a28a49136af1a61 --- /dev/null +++ b/crates/agent/src/tools/save_file_tool.rs @@ -0,0 +1,351 @@ +use agent_client_protocol as acp; +use anyhow::Result; +use collections::FxHashSet; +use gpui::{App, Entity, SharedString, Task}; +use language::Buffer; +use project::Project; +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; +use std::path::PathBuf; +use std::sync::Arc; + +use crate::{AgentTool, ToolCallEventStream}; + +/// Saves files that have unsaved changes. +/// +/// Use this tool when you need to edit files but they have unsaved changes that must be saved first. +/// Only use this tool after asking the user for permission to save their unsaved changes. +#[derive(Debug, Serialize, Deserialize, JsonSchema)] +pub struct SaveFileToolInput { + /// The paths of the files to save. + pub paths: Vec, +} + +pub struct SaveFileTool { + project: Entity, +} + +impl SaveFileTool { + pub fn new(project: Entity) -> Self { + Self { project } + } +} + +impl AgentTool for SaveFileTool { + type Input = SaveFileToolInput; + type Output = String; + + fn name() -> &'static str { + "save_file" + } + + fn kind() -> acp::ToolKind { + acp::ToolKind::Other + } + + fn initial_title( + &self, + input: Result, + _cx: &mut App, + ) -> SharedString { + match input { + Ok(input) if input.paths.len() == 1 => "Save file".into(), + Ok(input) => format!("Save {} files", input.paths.len()).into(), + Err(_) => "Save files".into(), + } + } + + fn run( + self: Arc, + input: Self::Input, + _event_stream: ToolCallEventStream, + cx: &mut App, + ) -> Task> { + let project = self.project.clone(); + let input_paths = input.paths; + + cx.spawn(async move |cx| { + let mut buffers_to_save: FxHashSet> = FxHashSet::default(); + + let mut saved_paths: Vec = Vec::new(); + let mut clean_paths: Vec = Vec::new(); + let mut not_found_paths: Vec = Vec::new(); + let mut open_errors: Vec<(PathBuf, String)> = Vec::new(); + let mut dirty_check_errors: Vec<(PathBuf, String)> = Vec::new(); + let mut save_errors: Vec<(String, String)> = Vec::new(); + + for path in input_paths { + let project_path = + project.read_with(cx, |project, cx| project.find_project_path(&path, cx)); + + let project_path = match project_path { + Ok(Some(project_path)) => project_path, + Ok(None) => { + not_found_paths.push(path); + continue; + } + Err(error) => { + open_errors.push((path, error.to_string())); + continue; + } + }; + + let open_buffer_task = + project.update(cx, |project, cx| project.open_buffer(project_path, cx)); + + let buffer = match open_buffer_task { + Ok(task) => match task.await { + Ok(buffer) => buffer, + Err(error) => { + open_errors.push((path, error.to_string())); + continue; + } + }, + Err(error) => { + open_errors.push((path, error.to_string())); + continue; + } + }; + + let is_dirty = match buffer.read_with(cx, |buffer, _| buffer.is_dirty()) { + Ok(is_dirty) => is_dirty, + Err(error) => { + dirty_check_errors.push((path, error.to_string())); + continue; + } + }; + + if is_dirty { + buffers_to_save.insert(buffer); + saved_paths.push(path); + } else { + clean_paths.push(path); + } + } + + // Save each buffer individually since there's no batch save API. + for buffer in buffers_to_save { + let path_for_buffer = match buffer.read_with(cx, |buffer, _| { + buffer + .file() + .map(|file| file.path().to_rel_path_buf()) + .map(|path| path.as_rel_path().as_unix_str().to_owned()) + }) { + Ok(path) => path.unwrap_or_else(|| "".to_string()), + Err(error) => { + save_errors.push(("".to_string(), error.to_string())); + continue; + } + }; + + let save_task = project.update(cx, |project, cx| project.save_buffer(buffer, cx)); + + match save_task { + Ok(task) => { + if let Err(error) = task.await { + save_errors.push((path_for_buffer, error.to_string())); + } + } + Err(error) => { + save_errors.push((path_for_buffer, error.to_string())); + } + } + } + + let mut lines: Vec = Vec::new(); + + if !saved_paths.is_empty() { + lines.push(format!("Saved {} file(s).", saved_paths.len())); + } + if !clean_paths.is_empty() { + lines.push(format!("{} clean.", clean_paths.len())); + } + + if !not_found_paths.is_empty() { + lines.push(format!("Not found ({}):", not_found_paths.len())); + for path in ¬_found_paths { + lines.push(format!("- {}", path.display())); + } + } + if !open_errors.is_empty() { + lines.push(format!("Open failed ({}):", open_errors.len())); + for (path, error) in &open_errors { + lines.push(format!("- {}: {}", path.display(), error)); + } + } + if !dirty_check_errors.is_empty() { + lines.push(format!( + "Dirty check failed ({}):", + dirty_check_errors.len() + )); + for (path, error) in &dirty_check_errors { + lines.push(format!("- {}: {}", path.display(), error)); + } + } + if !save_errors.is_empty() { + lines.push(format!("Save failed ({}):", save_errors.len())); + for (path, error) in &save_errors { + lines.push(format!("- {}: {}", path, error)); + } + } + + if lines.is_empty() { + Ok("No paths provided.".to_string()) + } else { + Ok(lines.join("\n")) + } + }) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use fs::Fs; + use gpui::TestAppContext; + use project::FakeFs; + use serde_json::json; + use settings::SettingsStore; + use util::path; + + fn init_test(cx: &mut TestAppContext) { + cx.update(|cx| { + let settings_store = SettingsStore::test(cx); + cx.set_global(settings_store); + }); + } + + #[gpui::test] + async fn test_save_file_output_and_effects(cx: &mut TestAppContext) { + init_test(cx); + + let fs = FakeFs::new(cx.executor()); + fs.insert_tree( + "/root", + json!({ + "dirty.txt": "on disk: dirty\n", + "clean.txt": "on disk: clean\n", + }), + ) + .await; + + let project = Project::test(fs.clone(), [path!("/root").as_ref()], cx).await; + let tool = Arc::new(SaveFileTool::new(project.clone())); + + // Make dirty.txt dirty in-memory. + let dirty_project_path = project.read_with(cx, |project, cx| { + project + .find_project_path("root/dirty.txt", cx) + .expect("dirty.txt should exist in project") + }); + + let dirty_buffer = project + .update(cx, |project, cx| { + project.open_buffer(dirty_project_path, cx) + }) + .await + .unwrap(); + dirty_buffer.update(cx, |buffer, cx| { + buffer.edit([(0..buffer.len(), "in memory: dirty\n")], None, cx); + }); + assert!( + dirty_buffer.read_with(cx, |buffer, _| buffer.is_dirty()), + "dirty.txt buffer should be dirty before save" + ); + + // Ensure clean.txt is opened but remains clean. + let clean_project_path = project.read_with(cx, |project, cx| { + project + .find_project_path("root/clean.txt", cx) + .expect("clean.txt should exist in project") + }); + + let clean_buffer = project + .update(cx, |project, cx| { + project.open_buffer(clean_project_path, cx) + }) + .await + .unwrap(); + assert!( + !clean_buffer.read_with(cx, |buffer, _| buffer.is_dirty()), + "clean.txt buffer should start clean" + ); + + let output = cx + .update(|cx| { + tool.clone().run( + SaveFileToolInput { + paths: vec![ + PathBuf::from("root/dirty.txt"), + PathBuf::from("root/clean.txt"), + ], + }, + ToolCallEventStream::test().0, + cx, + ) + }) + .await + .unwrap(); + + // Output should mention saved + clean. + assert!( + output.contains("Saved 1 file(s)."), + "expected saved count line, got:\n{output}" + ); + assert!( + output.contains("1 clean."), + "expected clean count line, got:\n{output}" + ); + + // Effect: dirty buffer should now be clean and disk should have new content. + assert!( + !dirty_buffer.read_with(cx, |buffer, _| buffer.is_dirty()), + "dirty.txt buffer should not be dirty after save" + ); + + let disk_dirty = fs.load(path!("/root/dirty.txt").as_ref()).await.unwrap(); + assert_eq!( + disk_dirty, "in memory: dirty\n", + "dirty.txt disk content should be updated" + ); + + // Sanity: clean buffer should remain clean and disk unchanged. + let disk_clean = fs.load(path!("/root/clean.txt").as_ref()).await.unwrap(); + assert_eq!(disk_clean, "on disk: clean\n"); + + // Test empty paths case. + let output = cx + .update(|cx| { + tool.clone().run( + SaveFileToolInput { paths: vec![] }, + ToolCallEventStream::test().0, + cx, + ) + }) + .await + .unwrap(); + assert_eq!(output, "No paths provided."); + + // Test not-found path case. + let output = cx + .update(|cx| { + tool.clone().run( + SaveFileToolInput { + paths: vec![PathBuf::from("nonexistent/path.txt")], + }, + ToolCallEventStream::test().0, + cx, + ) + }) + .await + .unwrap(); + assert!( + output.contains("Not found (1):"), + "expected not-found header line, got:\n{output}" + ); + assert!( + output.contains("- nonexistent/path.txt"), + "expected not-found path bullet, got:\n{output}" + ); + } +} From 0466db66cde85d79c8b3ec4bbe418bc68130f5c2 Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Tue, 16 Dec 2025 17:41:27 +0100 Subject: [PATCH 386/621] helix: Map Zed's specific diff and git-related to goto mode (#45006) Until now, Helix-mode users would have to rely on Vim's `d *` behaviour which cannot be reliably replicated with Helix's default delete behaviour and so I believe that remapping this functionality to Helix's goto mode is a better fit. Release Notes: - Added custom mappings for Zed specific diff and git-related actions to Helix's goto mode: * `g o` - toggle selected diff hunks * `g O` - toggle staged * `g R` - restore change * `g u` - stage and goto next diff hunk * `g U` - unstage and goto next diff hunk --- assets/keymaps/vim.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/assets/keymaps/vim.json b/assets/keymaps/vim.json index 0097480e2775a1048452b2a5e8ec826525da3f2e..6e5d3423872a7dd83234b28e67c5082b36bd858f 100644 --- a/assets/keymaps/vim.json +++ b/assets/keymaps/vim.json @@ -502,6 +502,11 @@ "g p": "pane::ActivatePreviousItem", "shift-h": "pane::ActivatePreviousItem", // not a helix default "g .": "vim::HelixGotoLastModification", + "g o": "editor::ToggleSelectedDiffHunks", // Zed specific + "g shift-o": "git::ToggleStaged", // Zed specific + "g shift-r": "git::Restore", // Zed specific + "g u": "git::StageAndNext", // Zed specific + "g shift-u": "git::UnstageAndNext", // Zed specific // Window mode "space w v": "pane::SplitDown", From bcebe76e536c980a03ce618343a76a511f543881 Mon Sep 17 00:00:00 2001 From: "Joseph T. Lyons" Date: Tue, 16 Dec 2025 12:14:57 -0500 Subject: [PATCH 387/621] Bump Zed to v0.219 (#45009) Release Notes: - N/A --- Cargo.lock | 2 +- crates/zed/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b9a9dee415d76123cf3c9c86686f94e704b5a4db..f8ff534719080a144ee0541d7b63f8b631017452 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -20507,7 +20507,7 @@ dependencies = [ [[package]] name = "zed" -version = "0.218.0" +version = "0.219.0" dependencies = [ "acp_tools", "activity_indicator", diff --git a/crates/zed/Cargo.toml b/crates/zed/Cargo.toml index 141de1139fb571020377ef9b115ed8204bad100b..955540843489ac21d79042854eb6fcebf5f64318 100644 --- a/crates/zed/Cargo.toml +++ b/crates/zed/Cargo.toml @@ -2,7 +2,7 @@ description = "The fast, collaborative code editor." edition.workspace = true name = "zed" -version = "0.218.0" +version = "0.219.0" publish.workspace = true license = "GPL-3.0-or-later" authors = ["Zed Team "] From 3f11cbd62c203857f83252f7e2aa1b073a4b73fb Mon Sep 17 00:00:00 2001 From: Remco Smits Date: Tue, 16 Dec 2025 18:51:58 +0100 Subject: [PATCH 388/621] git_ui: Add support for collapsing/expanding entries with your keyboard (#45002) This PR adds support for collapsing/expanding Git entries with your keyboard like you can inside the project panel and variable list. I noticed there is a bug that selecting the next entry when you are on the directory level will select a non-visible entry. Will fix that in another PR, as it is not related to this feature implementation. **Result**: https://github.com/user-attachments/assets/912cc146-1e1c-485f-9b60-5ddc0a124696 Release Notes: - Git panel: Add support for collapsing/expanding entries with your keyboard. --- assets/keymaps/default-linux.json | 2 ++ assets/keymaps/default-macos.json | 2 ++ assets/keymaps/default-windows.json | 2 ++ crates/git_ui/src/git_panel.rs | 48 +++++++++++++++++++++++++++++ 4 files changed, 54 insertions(+) diff --git a/assets/keymaps/default-linux.json b/assets/keymaps/default-linux.json index 38ef7d092d534163ead569c522227b089f84af99..185a2249a7a7f3cd33213a736d38df2f8565b885 100644 --- a/assets/keymaps/default-linux.json +++ b/assets/keymaps/default-linux.json @@ -900,6 +900,8 @@ { "context": "GitPanel && ChangesList", "bindings": { + "left": "git_panel::CollapseSelectedEntry", + "right": "git_panel::ExpandSelectedEntry", "up": "menu::SelectPrevious", "down": "menu::SelectNext", "enter": "menu::Confirm", diff --git a/assets/keymaps/default-macos.json b/assets/keymaps/default-macos.json index 8a0e3dfdcddbd448e6a6b9bf66f3731153208120..c711615041931a064680c5afce32c4ec06c749b3 100644 --- a/assets/keymaps/default-macos.json +++ b/assets/keymaps/default-macos.json @@ -975,6 +975,8 @@ "context": "GitPanel && ChangesList", "use_key_equivalents": true, "bindings": { + "left": "git_panel::CollapseSelectedEntry", + "right": "git_panel::ExpandSelectedEntry", "up": "menu::SelectPrevious", "down": "menu::SelectNext", "cmd-up": "menu::SelectFirst", diff --git a/assets/keymaps/default-windows.json b/assets/keymaps/default-windows.json index e344ea356fb171fb07474f498056df73c73d8307..1498f1deb98b6258bd92ac2dd0dbf1199c7db64f 100644 --- a/assets/keymaps/default-windows.json +++ b/assets/keymaps/default-windows.json @@ -904,6 +904,8 @@ "context": "GitPanel && ChangesList", "use_key_equivalents": true, "bindings": { + "left": "git_panel::CollapseSelectedEntry", + "right": "git_panel::ExpandSelectedEntry", "up": "menu::SelectPrevious", "down": "menu::SelectNext", "enter": "menu::Confirm", diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs index 362423b79fed0e8f3428d6784dd6f15b47708247..9bdcb0858a4547b3312ed5d48c85a6e8a7015d8d 100644 --- a/crates/git_ui/src/git_panel.rs +++ b/crates/git_ui/src/git_panel.rs @@ -98,6 +98,10 @@ actions!( ToggleSortByPath, /// Toggles showing entries in tree vs flat view. ToggleTreeView, + /// Expands the selected entry to show its children. + ExpandSelectedEntry, + /// Collapses the selected entry to hide its children. + CollapseSelectedEntry, ] ); @@ -896,6 +900,48 @@ impl GitPanel { .position(|entry| entry.status_entry().is_some()) } + fn expand_selected_entry( + &mut self, + _: &ExpandSelectedEntry, + window: &mut Window, + cx: &mut Context, + ) { + let Some(entry) = self.get_selected_entry().cloned() else { + return; + }; + + if let GitListEntry::Directory(dir_entry) = entry { + if dir_entry.expanded { + self.select_next(&SelectNext, window, cx); + } else { + self.toggle_directory(&dir_entry.key, window, cx); + } + } else { + self.select_next(&SelectNext, window, cx); + } + } + + fn collapse_selected_entry( + &mut self, + _: &CollapseSelectedEntry, + window: &mut Window, + cx: &mut Context, + ) { + let Some(entry) = self.get_selected_entry().cloned() else { + return; + }; + + if let GitListEntry::Directory(dir_entry) = entry { + if dir_entry.expanded { + self.toggle_directory(&dir_entry.key, window, cx); + } else { + self.select_previous(&SelectPrevious, window, cx); + } + } else { + self.select_previous(&SelectPrevious, window, cx); + } + } + fn select_first(&mut self, _: &SelectFirst, _window: &mut Window, cx: &mut Context) { if let Some(first_entry) = self.first_status_entry_index() { self.selected_entry = Some(first_entry); @@ -5264,6 +5310,8 @@ impl Render for GitPanel { .on_action(cx.listener(Self::stash_all)) .on_action(cx.listener(Self::stash_pop)) }) + .on_action(cx.listener(Self::collapse_selected_entry)) + .on_action(cx.listener(Self::expand_selected_entry)) .on_action(cx.listener(Self::select_first)) .on_action(cx.listener(Self::select_next)) .on_action(cx.listener(Self::select_previous)) From c1317baebebf955c589ef19d8c209b2ef526f75f Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Tue, 16 Dec 2025 10:58:10 -0700 Subject: [PATCH 389/621] Revert "Optimize editor rendering when clipped by parent containers" (#45011) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 914b0117fb5a23469af85e567d5723eca6b53635 (#44995). The optimization introduced a regression that causes the main thread to hang for **100+ seconds** in certain scenarios, requiring a force quit to recover. ## Analysis from spindump When a large `AutoHeight` editor is displayed inside a `List` (e.g., Agent Panel thread view), the clipping calculation can produce invalid row ranges: 1. `visible_bounds` from `window.content_mask().bounds` represents the window's content mask, not the intersection with the editor 2. When the editor is partially scrolled out of view, `clipped_top_in_lines` becomes extremely large 3. This causes `start_row` to be computed as an astronomically high value 4. `blocks_in_range(start_row..end_row)` then spends excessive time in `Cursor::search_forward` iterating through the block tree The spindump showed **~46% of samples** (459/1001 over 10+ seconds) stuck in `BlockSnapshot::blocks_in_range()`, specifically in cursor iteration. ### Heaviest stack trace ``` EditorElement::prepaint └─ blocks_in_range + 236 └─ Cursor::search_forward (459 samples) ``` ## Symptoms - Main thread unresponsive for 33-113 seconds before sampling even began - UI completely frozen - High CPU usage on main thread (10+ seconds of CPU time in the sample) - Force quit required to recover ## Path forward The original optimization goal (reducing line layout work for clipped editors) is valid, but the implementation needs to: 1. Correctly calculate the **intersection** of editor bounds with the visible viewport 2. Ensure row calculations stay within valid ranges (clamped to `max_row`) 3. Handle edge cases where the editor is completely outside the visible bounds Release Notes: - Fixed a hang that could occur when viewing large diffs in the Agent Panel --- crates/editor/src/element.rs | 17 ++--------------- crates/editor/src/test.rs | 8 +++++--- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index 95047569c31c2e306b0f984832b568f052e4179a..8de660275ba9b455aec610568c41347888654495 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -9164,15 +9164,6 @@ impl Element for EditorElement { let height_in_lines = f64::from(bounds.size.height / line_height); let max_row = snapshot.max_point().row().as_f64(); - // Calculate how much of the editor is clipped by parent containers (e.g., List). - // This allows us to only render lines that are actually visible, which is - // critical for performance when large AutoHeight editors are inside Lists. - let visible_bounds = window.content_mask().bounds; - let clipped_top = (visible_bounds.origin.y - bounds.origin.y).max(px(0.)); - let clipped_top_in_lines = f64::from(clipped_top / line_height); - let visible_height_in_lines = - f64::from(visible_bounds.size.height / line_height); - // The max scroll position for the top of the window let max_scroll_top = if matches!( snapshot.mode, @@ -9229,14 +9220,10 @@ impl Element for EditorElement { let mut scroll_position = snapshot.scroll_position(); // The scroll position is a fractional point, the whole number of which represents // the top of the window in terms of display rows. - // We add clipped_top_in_lines to skip rows that are clipped by parent containers, - // but we don't modify scroll_position itself since the parent handles positioning. - let start_row = - DisplayRow((scroll_position.y + clipped_top_in_lines).floor() as u32); + let start_row = DisplayRow(scroll_position.y as u32); let max_row = snapshot.max_point().row(); let end_row = cmp::min( - (scroll_position.y + clipped_top_in_lines + visible_height_in_lines).ceil() - as u32, + (scroll_position.y + height_in_lines).ceil() as u32, max_row.next_row().0, ); let end_row = DisplayRow(end_row); diff --git a/crates/editor/src/test.rs b/crates/editor/src/test.rs index 1cc619385446502db6a3a0dceb6e70fa4b4e8416..5a0652bdd199a638f92234b1d50232071db18e07 100644 --- a/crates/editor/src/test.rs +++ b/crates/editor/src/test.rs @@ -176,9 +176,11 @@ pub fn block_content_for_tests( } pub fn editor_content_with_blocks(editor: &Entity, cx: &mut VisualTestContext) -> String { - let draw_size = size(px(3000.0), px(3000.0)); - cx.simulate_resize(draw_size); - cx.draw(gpui::Point::default(), draw_size, |_, _| editor.clone()); + cx.draw( + gpui::Point::default(), + size(px(3000.0), px(3000.0)), + |_, _| editor.clone(), + ); let (snapshot, mut lines, blocks) = editor.update_in(cx, |editor, window, cx| { let snapshot = editor.snapshot(window, cx); let text = editor.display_text(cx); From d07818b20fa9fbc24c906d0c81ffbe89cd4cd471 Mon Sep 17 00:00:00 2001 From: Bennet Bo Fenner Date: Tue, 16 Dec 2025 19:02:13 +0100 Subject: [PATCH 390/621] git: Allow customising commit message prompt from rules library (#45004) Closes #26823 Release Notes: - Added support for customising the prompt used for generating commit message in the rules library --------- Co-authored-by: Danilo Leal --- crates/agent/src/agent.rs | 5 +- crates/agent_ui/src/completion_provider.rs | 13 +- crates/git_ui/src/git_panel.rs | 22 +- crates/prompt_store/src/prompt_store.rs | 53 ++- crates/rules_library/src/rules_library.rs | 394 +++++++++++---------- 5 files changed, 285 insertions(+), 202 deletions(-) diff --git a/crates/agent/src/agent.rs b/crates/agent/src/agent.rs index 715c8682ba9b1e6d21c6558271c00180691f59f0..f29b9f405c121b54fd9a4a250e977c593ffc3d4b 100644 --- a/crates/agent/src/agent.rs +++ b/crates/agent/src/agent.rs @@ -414,10 +414,7 @@ impl NativeAgent { .into_iter() .flat_map(|(contents, prompt_metadata)| match contents { Ok(contents) => Some(UserRulesContext { - uuid: match prompt_metadata.id { - prompt_store::PromptId::User { uuid } => uuid, - prompt_store::PromptId::EditWorkflow => return None, - }, + uuid: prompt_metadata.id.user_id()?, title: prompt_metadata.title.map(|title| title.to_string()), contents, }), diff --git a/crates/agent_ui/src/completion_provider.rs b/crates/agent_ui/src/completion_provider.rs index a2b6e0510e25c12cfbfb98d3e72cb0d2c830887a..206a2b3282b5471e8d5e8d18788519c3853dca55 100644 --- a/crates/agent_ui/src/completion_provider.rs +++ b/crates/agent_ui/src/completion_provider.rs @@ -20,7 +20,7 @@ use project::{ Completion, CompletionDisplayOptions, CompletionIntent, CompletionResponse, PathMatchCandidateSet, Project, ProjectPath, Symbol, WorktreeId, }; -use prompt_store::{PromptId, PromptStore, UserPromptId}; +use prompt_store::{PromptStore, UserPromptId}; use rope::Point; use text::{Anchor, ToPoint as _}; use ui::prelude::*; @@ -1585,13 +1585,10 @@ pub(crate) fn search_rules( if metadata.default { None } else { - match metadata.id { - PromptId::EditWorkflow => None, - PromptId::User { uuid } => Some(RulesContextEntry { - prompt_id: uuid, - title: metadata.title?, - }), - } + Some(RulesContextEntry { + prompt_id: metadata.id.user_id()?, + title: metadata.title?, + }) } }) .collect::>() diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs index 9bdcb0858a4547b3312ed5d48c85a6e8a7015d8d..d7be4dfe723e9cbe312420e920e4b4e90f080585 100644 --- a/crates/git_ui/src/git_panel.rs +++ b/crates/git_ui/src/git_panel.rs @@ -57,7 +57,7 @@ use project::{ git_store::{GitStoreEvent, Repository, RepositoryEvent, RepositoryId, pending_op}, project_settings::{GitPathStyle, ProjectSettings}, }; -use prompt_store::RULES_FILE_NAMES; +use prompt_store::{PromptId, PromptStore, RULES_FILE_NAMES}; use serde::{Deserialize, Serialize}; use settings::{Settings, SettingsStore, StatusStyle}; use std::future::Future; @@ -2422,6 +2422,20 @@ impl GitPanel { } } + async fn load_commit_message_prompt(cx: &mut AsyncApp) -> String { + const DEFAULT_PROMPT: &str = include_str!("commit_message_prompt.txt"); + + let load = async { + let store = cx.update(|cx| PromptStore::global(cx)).ok()?.await.ok()?; + store + .update(cx, |s, cx| s.load(PromptId::CommitMessage, cx)) + .ok()? + .await + .ok() + }; + load.await.unwrap_or_else(|| DEFAULT_PROMPT.to_string()) + } + /// Generates a commit message using an LLM. pub fn generate_commit_message(&mut self, cx: &mut Context) { if !self.can_commit() || !AgentSettings::get_global(cx).enabled(cx) { @@ -2487,14 +2501,14 @@ impl GitPanel { let rules_content = Self::load_project_rules(&project, &repo_work_dir, &mut cx).await; + let prompt = Self::load_commit_message_prompt(&mut cx).await; + let subject = this.update(cx, |this, cx| { this.commit_editor.read(cx).text(cx).lines().next().map(ToOwned::to_owned).unwrap_or_default() })?; let text_empty = subject.trim().is_empty(); - const PROMPT: &str = include_str!("commit_message_prompt.txt"); - let rules_section = match &rules_content { Some(rules) => format!( "\n\nThe user has provided the following project rules that you should follow when writing the commit message:\n\ @@ -2510,7 +2524,7 @@ impl GitPanel { }; let content = format!( - "{PROMPT}{rules_section}{subject_section}\nHere are the changes in this commit:\n{diff_text}" + "{prompt}{rules_section}{subject_section}\nHere are the changes in this commit:\n{diff_text}" ); let request = LanguageModelRequest { diff --git a/crates/prompt_store/src/prompt_store.rs b/crates/prompt_store/src/prompt_store.rs index fb087ce34d6d67fe4ea11a33f554307ed558c18a..b69051b067c95674d8d09be76c5b4c607fd03f67 100644 --- a/crates/prompt_store/src/prompt_store.rs +++ b/crates/prompt_store/src/prompt_store.rs @@ -56,6 +56,7 @@ pub struct PromptMetadata { pub enum PromptId { User { uuid: UserPromptId }, EditWorkflow, + CommitMessage, } impl PromptId { @@ -63,8 +64,32 @@ impl PromptId { UserPromptId::new().into() } + pub fn user_id(&self) -> Option { + match self { + Self::User { uuid } => Some(*uuid), + _ => None, + } + } + pub fn is_built_in(&self) -> bool { - !matches!(self, PromptId::User { .. }) + match self { + Self::User { .. } => false, + Self::EditWorkflow | Self::CommitMessage => true, + } + } + + pub fn can_edit(&self) -> bool { + match self { + Self::User { .. } | Self::CommitMessage => true, + Self::EditWorkflow => false, + } + } + + pub fn default_content(&self) -> Option<&'static str> { + match self { + Self::User { .. } | Self::EditWorkflow => None, + Self::CommitMessage => Some(include_str!("../../git_ui/src/commit_message_prompt.txt")), + } } } @@ -95,6 +120,7 @@ impl std::fmt::Display for PromptId { match self { PromptId::User { uuid } => write!(f, "{}", uuid.0), PromptId::EditWorkflow => write!(f, "Edit workflow"), + PromptId::CommitMessage => write!(f, "Commit message"), } } } @@ -181,6 +207,25 @@ impl PromptStore { metadata.delete(&mut txn, &PromptId::EditWorkflow).ok(); bodies.delete(&mut txn, &PromptId::EditWorkflow).ok(); + // Insert default commit message prompt if not present + if metadata.get(&txn, &PromptId::CommitMessage)?.is_none() { + metadata.put( + &mut txn, + &PromptId::CommitMessage, + &PromptMetadata { + id: PromptId::CommitMessage, + title: Some("Git Commit Message".into()), + default: false, + saved_at: Utc::now(), + }, + )?; + } + if bodies.get(&txn, &PromptId::CommitMessage)?.is_none() { + let commit_message_prompt = + include_str!("../../git_ui/src/commit_message_prompt.txt"); + bodies.put(&mut txn, &PromptId::CommitMessage, commit_message_prompt)?; + } + txn.commit()?; Self::upgrade_dbs(&db_env, metadata, bodies).log_err(); @@ -387,8 +432,8 @@ impl PromptStore { body: Rope, cx: &Context, ) -> Task> { - if id.is_built_in() { - return Task::ready(Err(anyhow!("built-in prompts cannot be saved"))); + if !id.can_edit() { + return Task::ready(Err(anyhow!("this prompt cannot be edited"))); } let prompt_metadata = PromptMetadata { @@ -430,7 +475,7 @@ impl PromptStore { ) -> Task> { let mut cache = self.metadata_cache.write(); - if id.is_built_in() { + if !id.can_edit() { title = cache .metadata_by_id .get(&id) diff --git a/crates/rules_library/src/rules_library.rs b/crates/rules_library/src/rules_library.rs index 09b7e0b539cde7371b97ef092fbd8f904b241c13..00cf939f7af45f7701cd9d3599a103ece4a6f393 100644 --- a/crates/rules_library/src/rules_library.rs +++ b/crates/rules_library/src/rules_library.rs @@ -21,9 +21,7 @@ use std::sync::atomic::AtomicBool; use std::time::Duration; use theme::ThemeSettings; use title_bar::platform_title_bar::PlatformTitleBar; -use ui::{ - Divider, KeyBinding, ListItem, ListItemSpacing, ListSubHeader, Render, Tooltip, prelude::*, -}; +use ui::{Divider, KeyBinding, ListItem, ListItemSpacing, ListSubHeader, Tooltip, prelude::*}; use util::{ResultExt, TryFutureExt}; use workspace::{Workspace, WorkspaceSettings, client_side_decorations}; use zed_actions::assistant::InlineAssist; @@ -44,15 +42,12 @@ actions!( /// Duplicates the selected rule. DuplicateRule, /// Toggles whether the selected rule is a default rule. - ToggleDefaultRule + ToggleDefaultRule, + /// Restores a built-in rule to its default content. + RestoreDefaultContent ] ); -const BUILT_IN_TOOLTIP_TEXT: &str = concat!( - "This rule supports special functionality.\n", - "It's read-only, but you can remove it from your default rules." -); - pub trait InlineAssistDelegate { fn assist( &self, @@ -270,23 +265,35 @@ impl PickerDelegate for RulePickerDelegate { .background_spawn(async move { let matches = search.await; - let (default_rules, non_default_rules): (Vec<_>, Vec<_>) = - matches.iter().partition(|rule| rule.default); + let (built_in_rules, user_rules): (Vec<_>, Vec<_>) = + matches.into_iter().partition(|rule| rule.id.is_built_in()); + let (default_rules, other_rules): (Vec<_>, Vec<_>) = + user_rules.into_iter().partition(|rule| rule.default); let mut filtered_entries = Vec::new(); + if !built_in_rules.is_empty() { + filtered_entries.push(RulePickerEntry::Header("Built-in Rules".into())); + + for rule in built_in_rules { + filtered_entries.push(RulePickerEntry::Rule(rule)); + } + + filtered_entries.push(RulePickerEntry::Separator); + } + if !default_rules.is_empty() { filtered_entries.push(RulePickerEntry::Header("Default Rules".into())); for rule in default_rules { - filtered_entries.push(RulePickerEntry::Rule(rule.clone())); + filtered_entries.push(RulePickerEntry::Rule(rule)); } filtered_entries.push(RulePickerEntry::Separator); } - for rule in non_default_rules { - filtered_entries.push(RulePickerEntry::Rule(rule.clone())); + for rule in other_rules { + filtered_entries.push(RulePickerEntry::Rule(rule)); } let selected_index = prev_prompt_id @@ -341,21 +348,27 @@ impl PickerDelegate for RulePickerDelegate { cx: &mut Context>, ) -> Option { match self.filtered_entries.get(ix)? { - RulePickerEntry::Header(title) => Some( - ListSubHeader::new(title.clone()) - .end_slot( - IconButton::new("info", IconName::Info) - .style(ButtonStyle::Transparent) - .icon_size(IconSize::Small) - .icon_color(Color::Muted) - .tooltip(Tooltip::text( - "Default Rules are attached by default with every new thread.", - )) - .into_any_element(), - ) - .inset(true) - .into_any_element(), - ), + RulePickerEntry::Header(title) => { + let tooltip_text = if title.as_ref() == "Built-in Rules" { + "Built-in rules are those included out of the box with Zed." + } else { + "Default Rules are attached by default with every new thread." + }; + + Some( + ListSubHeader::new(title.clone()) + .end_slot( + IconButton::new("info", IconName::Info) + .style(ButtonStyle::Transparent) + .icon_size(IconSize::Small) + .icon_color(Color::Muted) + .tooltip(Tooltip::text(tooltip_text)) + .into_any_element(), + ) + .inset(true) + .into_any_element(), + ) + } RulePickerEntry::Separator => Some( h_flex() .py_1() @@ -376,7 +389,7 @@ impl PickerDelegate for RulePickerDelegate { .truncate() .mr_10(), ) - .end_slot::(default.then(|| { + .end_slot::((default && !prompt_id.is_built_in()).then(|| { IconButton::new("toggle-default-rule", IconName::Paperclip) .toggle_state(true) .icon_color(Color::Accent) @@ -386,62 +399,52 @@ impl PickerDelegate for RulePickerDelegate { cx.emit(RulePickerEvent::ToggledDefault { prompt_id }) })) })) - .end_hover_slot( - h_flex() - .child(if prompt_id.is_built_in() { - div() - .id("built-in-rule") - .child(Icon::new(IconName::FileLock).color(Color::Muted)) - .tooltip(move |_window, cx| { - Tooltip::with_meta( - "Built-in rule", - None, - BUILT_IN_TOOLTIP_TEXT, - cx, - ) - }) - .into_any() - } else { - IconButton::new("delete-rule", IconName::Trash) - .icon_color(Color::Muted) - .icon_size(IconSize::Small) - .tooltip(Tooltip::text("Delete Rule")) - .on_click(cx.listener(move |_, _, _, cx| { - cx.emit(RulePickerEvent::Deleted { prompt_id }) - })) - .into_any_element() - }) - .child( - IconButton::new("toggle-default-rule", IconName::Plus) - .selected_icon(IconName::Dash) - .toggle_state(default) - .icon_size(IconSize::Small) - .icon_color(if default { - Color::Accent - } else { - Color::Muted - }) - .map(|this| { - if default { - this.tooltip(Tooltip::text( - "Remove from Default Rules", - )) + .when(!prompt_id.is_built_in(), |this| { + this.end_hover_slot( + h_flex() + .child( + IconButton::new("delete-rule", IconName::Trash) + .icon_color(Color::Muted) + .icon_size(IconSize::Small) + .tooltip(Tooltip::text("Delete Rule")) + .on_click(cx.listener(move |_, _, _, cx| { + cx.emit(RulePickerEvent::Deleted { prompt_id }) + })), + ) + .child( + IconButton::new("toggle-default-rule", IconName::Plus) + .selected_icon(IconName::Dash) + .toggle_state(default) + .icon_size(IconSize::Small) + .icon_color(if default { + Color::Accent } else { - this.tooltip(move |_window, cx| { - Tooltip::with_meta( - "Add to Default Rules", - None, - "Always included in every thread.", - cx, - ) + Color::Muted + }) + .map(|this| { + if default { + this.tooltip(Tooltip::text( + "Remove from Default Rules", + )) + } else { + this.tooltip(move |_window, cx| { + Tooltip::with_meta( + "Add to Default Rules", + None, + "Always included in every thread.", + cx, + ) + }) + } + }) + .on_click(cx.listener(move |_, _, _, cx| { + cx.emit(RulePickerEvent::ToggledDefault { + prompt_id, }) - } - }) - .on_click(cx.listener(move |_, _, _, cx| { - cx.emit(RulePickerEvent::ToggledDefault { prompt_id }) - })), - ), - ) + })), + ), + ) + }) .into_any_element(), ) } @@ -573,7 +576,7 @@ impl RulesLibrary { pub fn save_rule(&mut self, prompt_id: PromptId, window: &mut Window, cx: &mut Context) { const SAVE_THROTTLE: Duration = Duration::from_millis(500); - if prompt_id.is_built_in() { + if !prompt_id.can_edit() { return; } @@ -661,6 +664,33 @@ impl RulesLibrary { } } + pub fn restore_default_content_for_active_rule( + &mut self, + window: &mut Window, + cx: &mut Context, + ) { + if let Some(active_rule_id) = self.active_rule_id { + self.restore_default_content(active_rule_id, window, cx); + } + } + + pub fn restore_default_content( + &mut self, + prompt_id: PromptId, + window: &mut Window, + cx: &mut Context, + ) { + let Some(default_content) = prompt_id.default_content() else { + return; + }; + + if let Some(rule_editor) = self.rule_editors.get(&prompt_id) { + rule_editor.body_editor.update(cx, |editor, cx| { + editor.set_text(default_content, window, cx); + }); + } + } + pub fn toggle_default_for_rule( &mut self, prompt_id: PromptId, @@ -721,7 +751,7 @@ impl RulesLibrary { }); let mut editor = Editor::for_buffer(buffer, None, window, cx); - if prompt_id.is_built_in() { + if !prompt_id.can_edit() { editor.set_read_only(true); editor.set_show_edit_predictions(Some(false), window, cx); } @@ -1148,30 +1178,38 @@ impl RulesLibrary { fn render_active_rule_editor( &self, editor: &Entity, + read_only: bool, cx: &mut Context, ) -> impl IntoElement { let settings = ThemeSettings::get_global(cx); + let text_color = if read_only { + cx.theme().colors().text_muted + } else { + cx.theme().colors().text + }; div() .w_full() - .on_action(cx.listener(Self::move_down_from_title)) .pl_1() .border_1() .border_color(transparent_black()) .rounded_sm() - .group_hover("active-editor-header", |this| { - this.border_color(cx.theme().colors().border_variant) + .when(!read_only, |this| { + this.group_hover("active-editor-header", |this| { + this.border_color(cx.theme().colors().border_variant) + }) }) + .on_action(cx.listener(Self::move_down_from_title)) .child(EditorElement::new( &editor, EditorStyle { background: cx.theme().system().transparent, local_player: cx.theme().players().local(), text: TextStyle { - color: cx.theme().colors().editor_foreground, + color: text_color, font_family: settings.ui_font.family.clone(), font_features: settings.ui_font.features.clone(), - font_size: HeadlineSize::Large.rems().into(), + font_size: HeadlineSize::Medium.rems().into(), font_weight: settings.ui_font.weight, line_height: relative(settings.buffer_line_height.value()), ..Default::default() @@ -1186,6 +1224,68 @@ impl RulesLibrary { )) } + fn render_duplicate_rule_button(&self) -> impl IntoElement { + IconButton::new("duplicate-rule", IconName::BookCopy) + .tooltip(move |_window, cx| Tooltip::for_action("Duplicate Rule", &DuplicateRule, cx)) + .on_click(|_, window, cx| { + window.dispatch_action(Box::new(DuplicateRule), cx); + }) + } + + fn render_built_in_rule_controls(&self) -> impl IntoElement { + h_flex() + .gap_1() + .child(self.render_duplicate_rule_button()) + .child( + IconButton::new("restore-default", IconName::RotateCcw) + .tooltip(move |_window, cx| { + Tooltip::for_action( + "Restore to Default Content", + &RestoreDefaultContent, + cx, + ) + }) + .on_click(|_, window, cx| { + window.dispatch_action(Box::new(RestoreDefaultContent), cx); + }), + ) + } + + fn render_regular_rule_controls(&self, default: bool) -> impl IntoElement { + h_flex() + .gap_1() + .child( + IconButton::new("toggle-default-rule", IconName::Paperclip) + .toggle_state(default) + .when(default, |this| this.icon_color(Color::Accent)) + .map(|this| { + if default { + this.tooltip(Tooltip::text("Remove from Default Rules")) + } else { + this.tooltip(move |_window, cx| { + Tooltip::with_meta( + "Add to Default Rules", + None, + "Always included in every thread.", + cx, + ) + }) + } + }) + .on_click(|_, window, cx| { + window.dispatch_action(Box::new(ToggleDefaultRule), cx); + }), + ) + .child(self.render_duplicate_rule_button()) + .child( + IconButton::new("delete-rule", IconName::Trash) + .tooltip(move |_window, cx| Tooltip::for_action("Delete Rule", &DeleteRule, cx)) + .on_click(|_, window, cx| { + window.dispatch_action(Box::new(DeleteRule), cx); + }), + ) + } + fn render_active_rule(&mut self, cx: &mut Context) -> gpui::Stateful
{ div() .id("rule-editor") @@ -1198,9 +1298,9 @@ impl RulesLibrary { let rule_metadata = self.store.read(cx).metadata(prompt_id)?; let rule_editor = &self.rule_editors[&prompt_id]; let focus_handle = rule_editor.body_editor.focus_handle(cx); - let model = LanguageModelRegistry::read_global(cx) - .default_model() - .map(|default| default.model); + let registry = LanguageModelRegistry::read_global(cx); + let model = registry.default_model().map(|default| default.model); + let built_in = prompt_id.is_built_in(); Some( v_flex() @@ -1214,14 +1314,15 @@ impl RulesLibrary { .child( h_flex() .group("active-editor-header") - .pt_2() - .pl_1p5() - .pr_2p5() + .h_12() + .px_2() .gap_2() .justify_between() - .child( - self.render_active_rule_editor(&rule_editor.title_editor, cx), - ) + .child(self.render_active_rule_editor( + &rule_editor.title_editor, + built_in, + cx, + )) .child( h_flex() .h_full() @@ -1258,89 +1359,15 @@ impl RulesLibrary { .color(Color::Muted), ) })) - .child(if prompt_id.is_built_in() { - div() - .id("built-in-rule") - .child( - Icon::new(IconName::FileLock) - .color(Color::Muted), - ) - .tooltip(move |_window, cx| { - Tooltip::with_meta( - "Built-in rule", - None, - BUILT_IN_TOOLTIP_TEXT, - cx, - ) - }) - .into_any() - } else { - IconButton::new("delete-rule", IconName::Trash) - .tooltip(move |_window, cx| { - Tooltip::for_action( - "Delete Rule", - &DeleteRule, - cx, - ) - }) - .on_click(|_, window, cx| { - window - .dispatch_action(Box::new(DeleteRule), cx); - }) - .into_any_element() - }) - .child( - IconButton::new("duplicate-rule", IconName::BookCopy) - .tooltip(move |_window, cx| { - Tooltip::for_action( - "Duplicate Rule", - &DuplicateRule, - cx, - ) - }) - .on_click(|_, window, cx| { - window.dispatch_action( - Box::new(DuplicateRule), - cx, - ); - }), - ) - .child( - IconButton::new( - "toggle-default-rule", - IconName::Paperclip, - ) - .toggle_state(rule_metadata.default) - .icon_color(if rule_metadata.default { - Color::Accent + .map(|this| { + if built_in { + this.child(self.render_built_in_rule_controls()) } else { - Color::Muted - }) - .map(|this| { - if rule_metadata.default { - this.tooltip(Tooltip::text( - "Remove from Default Rules", - )) - } else { - this.tooltip(move |_window, cx| { - Tooltip::with_meta( - "Add to Default Rules", - None, - "Always included in every thread.", - cx, - ) - }) - } - }) - .on_click( - |_, window, cx| { - window.dispatch_action( - Box::new(ToggleDefaultRule), - cx, - ); - }, - ), - ), + this.child(self.render_regular_rule_controls( + rule_metadata.default, + )) + } + }), ), ) .child( @@ -1385,6 +1412,9 @@ impl Render for RulesLibrary { .on_action(cx.listener(|this, &ToggleDefaultRule, window, cx| { this.toggle_default_for_active_rule(window, cx) })) + .on_action(cx.listener(|this, &RestoreDefaultContent, window, cx| { + this.restore_default_content_for_active_rule(window, cx) + })) .size_full() .overflow_hidden() .font(ui_font) From 4896f477e2353fa5f6eaf01642533e7f7bd56384 Mon Sep 17 00:00:00 2001 From: max <144637754+mdliss@users.noreply.github.com> Date: Tue, 16 Dec 2025 12:03:34 -0600 Subject: [PATCH 391/621] Add MCP prompt support to agent threads (#43523) Fixes #43165 ## Problem MCP prompts were only available in text threads, not agent threads. Users with MCP servers that expose prompts couldn't use them in the main agent panel. ## Solution Added MCP prompt support to agent threads by: - Creating `ContextServerPromptRegistry` to track MCP prompts from context servers - Subscribing to context server events to reload prompts when MCP servers start/stop - Converting MCP prompts to available commands that appear in the slash command menu - Integrating prompt expansion into the agent message flow ## Testing Tested with a custom MCP server exposing `explain-code` and `write-tests` prompts. Prompts now appear in the `/` slash command menu in agent threads. Release Notes: - Added MCP prompt support to agent threads. Prompts from MCP servers now appear in the slash command menu when typing `/` in agent threads. --------- Co-authored-by: Agus Zubiaga --- crates/acp_thread/src/acp_thread.rs | 41 ++- crates/agent/src/agent.rs | 327 +++++++++++++++++- crates/agent/src/thread.rs | 60 +++- .../src/tools/context_server_registry.rs | 160 ++++++++- crates/agent_ui/src/acp/thread_view.rs | 78 ++++- crates/context_server/src/types.rs | 2 +- 6 files changed, 627 insertions(+), 41 deletions(-) diff --git a/crates/acp_thread/src/acp_thread.rs b/crates/acp_thread/src/acp_thread.rs index 53294a963d9d230c9b06372c26591ede0434ab28..2ec6347fd4aa088d7ae2cc8f5a7b6cef37d3b202 100644 --- a/crates/acp_thread/src/acp_thread.rs +++ b/crates/acp_thread/src/acp_thread.rs @@ -43,6 +43,7 @@ pub struct UserMessage { pub content: ContentBlock, pub chunks: Vec, pub checkpoint: Option, + pub indented: bool, } #[derive(Debug)] @@ -73,6 +74,7 @@ impl UserMessage { #[derive(Debug, PartialEq)] pub struct AssistantMessage { pub chunks: Vec, + pub indented: bool, } impl AssistantMessage { @@ -123,6 +125,14 @@ pub enum AgentThreadEntry { } impl AgentThreadEntry { + pub fn is_indented(&self) -> bool { + match self { + Self::UserMessage(message) => message.indented, + Self::AssistantMessage(message) => message.indented, + Self::ToolCall(_) => false, + } + } + pub fn to_markdown(&self, cx: &App) -> String { match self { Self::UserMessage(message) => message.to_markdown(cx), @@ -1184,6 +1194,16 @@ impl AcpThread { message_id: Option, chunk: acp::ContentBlock, cx: &mut Context, + ) { + self.push_user_content_block_with_indent(message_id, chunk, false, cx) + } + + pub fn push_user_content_block_with_indent( + &mut self, + message_id: Option, + chunk: acp::ContentBlock, + indented: bool, + cx: &mut Context, ) { let language_registry = self.project.read(cx).languages().clone(); let path_style = self.project.read(cx).path_style(cx); @@ -1194,8 +1214,10 @@ impl AcpThread { id, content, chunks, + indented: existing_indented, .. }) = last_entry + && *existing_indented == indented { *id = message_id.or(id.take()); content.append(chunk.clone(), &language_registry, path_style, cx); @@ -1210,6 +1232,7 @@ impl AcpThread { content, chunks: vec![chunk], checkpoint: None, + indented, }), cx, ); @@ -1221,12 +1244,26 @@ impl AcpThread { chunk: acp::ContentBlock, is_thought: bool, cx: &mut Context, + ) { + self.push_assistant_content_block_with_indent(chunk, is_thought, false, cx) + } + + pub fn push_assistant_content_block_with_indent( + &mut self, + chunk: acp::ContentBlock, + is_thought: bool, + indented: bool, + cx: &mut Context, ) { let language_registry = self.project.read(cx).languages().clone(); let path_style = self.project.read(cx).path_style(cx); let entries_len = self.entries.len(); if let Some(last_entry) = self.entries.last_mut() - && let AgentThreadEntry::AssistantMessage(AssistantMessage { chunks }) = last_entry + && let AgentThreadEntry::AssistantMessage(AssistantMessage { + chunks, + indented: existing_indented, + }) = last_entry + && *existing_indented == indented { let idx = entries_len - 1; cx.emit(AcpThreadEvent::EntryUpdated(idx)); @@ -1255,6 +1292,7 @@ impl AcpThread { self.push_entry( AgentThreadEntry::AssistantMessage(AssistantMessage { chunks: vec![chunk], + indented, }), cx, ); @@ -1704,6 +1742,7 @@ impl AcpThread { content: block, chunks: message, checkpoint: None, + indented: false, }), cx, ); diff --git a/crates/agent/src/agent.rs b/crates/agent/src/agent.rs index f29b9f405c121b54fd9a4a250e977c593ffc3d4b..693d3abd4497c057a75b4f01c07bd51f311f1fdb 100644 --- a/crates/agent/src/agent.rs +++ b/crates/agent/src/agent.rs @@ -5,12 +5,12 @@ mod legacy_thread; mod native_agent_server; pub mod outline; mod templates; -mod thread; -mod tools; - #[cfg(test)] mod tests; +mod thread; +mod tools; +use context_server::ContextServerId; pub use db::*; pub use history_store::*; pub use native_agent_server::NativeAgentServer; @@ -18,11 +18,11 @@ pub use templates::*; pub use thread::*; pub use tools::*; -use acp_thread::{AcpThread, AgentModelSelector}; +use acp_thread::{AcpThread, AgentModelSelector, UserMessageId}; use agent_client_protocol as acp; use anyhow::{Context as _, Result, anyhow}; use chrono::{DateTime, Utc}; -use collections::{HashSet, IndexMap}; +use collections::{HashMap, HashSet, IndexMap}; use fs::Fs; use futures::channel::{mpsc, oneshot}; use futures::future::Shared; @@ -39,7 +39,6 @@ use prompt_store::{ use serde::{Deserialize, Serialize}; use settings::{LanguageModelSelection, update_settings_file}; use std::any::Any; -use std::collections::HashMap; use std::path::{Path, PathBuf}; use std::rc::Rc; use std::sync::Arc; @@ -252,12 +251,24 @@ impl NativeAgent { .await; cx.new(|cx| { + let context_server_store = project.read(cx).context_server_store(); + let context_server_registry = + cx.new(|cx| ContextServerRegistry::new(context_server_store.clone(), cx)); + let mut subscriptions = vec![ cx.subscribe(&project, Self::handle_project_event), cx.subscribe( &LanguageModelRegistry::global(cx), Self::handle_models_updated_event, ), + cx.subscribe( + &context_server_store, + Self::handle_context_server_store_updated, + ), + cx.subscribe( + &context_server_registry, + Self::handle_context_server_registry_event, + ), ]; if let Some(prompt_store) = prompt_store.as_ref() { subscriptions.push(cx.subscribe(prompt_store, Self::handle_prompts_updated_event)) @@ -266,16 +277,14 @@ impl NativeAgent { let (project_context_needs_refresh_tx, project_context_needs_refresh_rx) = watch::channel(()); Self { - sessions: HashMap::new(), + sessions: HashMap::default(), history, project_context: cx.new(|_| project_context), project_context_needs_refresh: project_context_needs_refresh_tx, _maintain_project_context: cx.spawn(async move |this, cx| { Self::maintain_project_context(this, project_context_needs_refresh_rx, cx).await }), - context_server_registry: cx.new(|cx| { - ContextServerRegistry::new(project.read(cx).context_server_store(), cx) - }), + context_server_registry, templates, models: LanguageModels::new(cx), project, @@ -344,6 +353,9 @@ impl NativeAgent { pending_save: Task::ready(()), }, ); + + self.update_available_commands(cx); + acp_thread } @@ -608,6 +620,99 @@ impl NativeAgent { } } + fn handle_context_server_store_updated( + &mut self, + _store: Entity, + _event: &project::context_server_store::Event, + cx: &mut Context, + ) { + self.update_available_commands(cx); + } + + fn handle_context_server_registry_event( + &mut self, + _registry: Entity, + event: &ContextServerRegistryEvent, + cx: &mut Context, + ) { + match event { + ContextServerRegistryEvent::ToolsChanged => {} + ContextServerRegistryEvent::PromptsChanged => { + self.update_available_commands(cx); + } + } + } + + fn update_available_commands(&self, cx: &mut Context) { + let available_commands = self.build_available_commands(cx); + for session in self.sessions.values() { + if let Some(acp_thread) = session.acp_thread.upgrade() { + acp_thread.update(cx, |thread, cx| { + thread + .handle_session_update( + acp::SessionUpdate::AvailableCommandsUpdate( + acp::AvailableCommandsUpdate::new(available_commands.clone()), + ), + cx, + ) + .log_err(); + }); + } + } + } + + fn build_available_commands(&self, cx: &App) -> Vec { + let registry = self.context_server_registry.read(cx); + + let mut prompt_name_counts: HashMap<&str, usize> = HashMap::default(); + for context_server_prompt in registry.prompts() { + *prompt_name_counts + .entry(context_server_prompt.prompt.name.as_str()) + .or_insert(0) += 1; + } + + registry + .prompts() + .flat_map(|context_server_prompt| { + let prompt = &context_server_prompt.prompt; + + let should_prefix = prompt_name_counts + .get(prompt.name.as_str()) + .copied() + .unwrap_or(0) + > 1; + + let name = if should_prefix { + format!("{}.{}", context_server_prompt.server_id, prompt.name) + } else { + prompt.name.clone() + }; + + let mut command = acp::AvailableCommand::new( + name, + prompt.description.clone().unwrap_or_default(), + ); + + match prompt.arguments.as_deref() { + Some([arg]) => { + let hint = format!("<{}>", arg.name); + + command = command.input(acp::AvailableCommandInput::Unstructured( + acp::UnstructuredCommandInput::new(hint), + )); + } + Some([]) | None => {} + Some(_) => { + // skip >1 argument commands since we don't support them yet + return None; + } + } + + Some(command) + }) + .collect() + } + pub fn load_thread( &mut self, id: acp::SessionId, @@ -706,6 +811,102 @@ impl NativeAgent { history.update(cx, |history, cx| history.reload(cx)).ok(); }); } + + fn send_mcp_prompt( + &self, + message_id: UserMessageId, + session_id: agent_client_protocol::SessionId, + prompt_name: String, + server_id: ContextServerId, + arguments: HashMap, + original_content: Vec, + cx: &mut Context, + ) -> Task> { + let server_store = self.context_server_registry.read(cx).server_store().clone(); + let path_style = self.project.read(cx).path_style(cx); + + cx.spawn(async move |this, cx| { + let prompt = + crate::get_prompt(&server_store, &server_id, &prompt_name, arguments, cx).await?; + + let (acp_thread, thread) = this.update(cx, |this, _cx| { + let session = this + .sessions + .get(&session_id) + .context("Failed to get session")?; + anyhow::Ok((session.acp_thread.clone(), session.thread.clone())) + })??; + + let mut last_is_user = true; + + thread.update(cx, |thread, cx| { + thread.push_acp_user_block( + message_id, + original_content.into_iter().skip(1), + path_style, + cx, + ); + })?; + + for message in prompt.messages { + let context_server::types::PromptMessage { role, content } = message; + let block = mcp_message_content_to_acp_content_block(content); + + match role { + context_server::types::Role::User => { + let id = acp_thread::UserMessageId::new(); + + acp_thread.update(cx, |acp_thread, cx| { + acp_thread.push_user_content_block_with_indent( + Some(id.clone()), + block.clone(), + true, + cx, + ); + anyhow::Ok(()) + })??; + + thread.update(cx, |thread, cx| { + thread.push_acp_user_block(id, [block], path_style, cx); + anyhow::Ok(()) + })??; + } + context_server::types::Role::Assistant => { + acp_thread.update(cx, |acp_thread, cx| { + acp_thread.push_assistant_content_block_with_indent( + block.clone(), + false, + true, + cx, + ); + anyhow::Ok(()) + })??; + + thread.update(cx, |thread, cx| { + thread.push_acp_agent_block(block, cx); + anyhow::Ok(()) + })??; + } + } + + last_is_user = role == context_server::types::Role::User; + } + + let response_stream = thread.update(cx, |thread, cx| { + if last_is_user { + thread.send_existing(cx) + } else { + // Resume if MCP prompt did not end with a user message + thread.resume(cx) + } + })??; + + cx.update(|cx| { + NativeAgentConnection::handle_thread_events(response_stream, acp_thread, cx) + })? + .await + }) + } } /// Wrapper struct that implements the AgentConnection trait @@ -840,6 +1041,39 @@ impl NativeAgentConnection { } } +struct Command<'a> { + prompt_name: &'a str, + arg_value: &'a str, + explicit_server_id: Option<&'a str>, +} + +impl<'a> Command<'a> { + fn parse(prompt: &'a [acp::ContentBlock]) -> Option { + let acp::ContentBlock::Text(text_content) = prompt.first()? else { + return None; + }; + let text = text_content.text.trim(); + let command = text.strip_prefix('/')?; + let (command, arg_value) = command + .split_once(char::is_whitespace) + .unwrap_or((command, "")); + + if let Some((server_id, prompt_name)) = command.split_once('.') { + Some(Self { + prompt_name, + arg_value, + explicit_server_id: Some(server_id), + }) + } else { + Some(Self { + prompt_name: command, + arg_value, + explicit_server_id: None, + }) + } + } +} + struct NativeAgentModelSelector { session_id: acp::SessionId, connection: NativeAgentConnection, @@ -1005,6 +1239,47 @@ impl acp_thread::AgentConnection for NativeAgentConnection { let session_id = params.session_id.clone(); log::info!("Received prompt request for session: {}", session_id); log::debug!("Prompt blocks count: {}", params.prompt.len()); + + if let Some(parsed_command) = Command::parse(¶ms.prompt) { + let registry = self.0.read(cx).context_server_registry.read(cx); + + let explicit_server_id = parsed_command + .explicit_server_id + .map(|server_id| ContextServerId(server_id.into())); + + if let Some(prompt) = + registry.find_prompt(explicit_server_id.as_ref(), parsed_command.prompt_name) + { + let arguments = if !parsed_command.arg_value.is_empty() + && let Some(arg_name) = prompt + .prompt + .arguments + .as_ref() + .and_then(|args| args.first()) + .map(|arg| arg.name.clone()) + { + HashMap::from_iter([(arg_name, parsed_command.arg_value.to_string())]) + } else { + Default::default() + }; + + let prompt_name = prompt.prompt.name.clone(); + let server_id = prompt.server_id.clone(); + + return self.0.update(cx, |agent, cx| { + agent.send_mcp_prompt( + id, + session_id.clone(), + prompt_name, + server_id, + arguments, + params.prompt, + cx, + ) + }); + }; + }; + let path_style = self.0.read(cx).project.read(cx).path_style(cx); self.run_turn(session_id, cx, move |thread, cx| { @@ -1601,3 +1876,35 @@ mod internal_tests { }); } } + +fn mcp_message_content_to_acp_content_block( + content: context_server::types::MessageContent, +) -> acp::ContentBlock { + match content { + context_server::types::MessageContent::Text { + text, + annotations: _, + } => text.into(), + context_server::types::MessageContent::Image { + data, + mime_type, + annotations: _, + } => acp::ContentBlock::Image(acp::ImageContent::new(data, mime_type)), + context_server::types::MessageContent::Audio { + data, + mime_type, + annotations: _, + } => acp::ContentBlock::Audio(acp::AudioContent::new(data, mime_type)), + context_server::types::MessageContent::Resource { + resource, + annotations: _, + } => { + let mut link = + acp::ResourceLink::new(resource.uri.to_string(), resource.uri.to_string()); + if let Some(mime_type) = resource.mime_type { + link = link.mime_type(mime_type); + } + acp::ContentBlock::ResourceLink(link) + } + } +} diff --git a/crates/agent/src/thread.rs b/crates/agent/src/thread.rs index bed3db853a3106ca4df9676d799b4a2bfa0106a0..bb22470b9e7db934f949a13b86fd13f9dc58beed 100644 --- a/crates/agent/src/thread.rs +++ b/crates/agent/src/thread.rs @@ -108,7 +108,13 @@ impl Message { pub fn to_request(&self) -> Vec { match self { - Message::User(message) => vec![message.to_request()], + Message::User(message) => { + if message.content.is_empty() { + vec![] + } else { + vec![message.to_request()] + } + } Message::Agent(message) => message.to_request(), Message::Resume => vec![LanguageModelRequestMessage { role: Role::User, @@ -1141,20 +1147,64 @@ impl Thread { where T: Into, { + let content = content.into_iter().map(Into::into).collect::>(); + log::debug!("Thread::send content: {:?}", content); + + self.messages + .push(Message::User(UserMessage { id, content })); + cx.notify(); + + self.send_existing(cx) + } + + pub fn send_existing( + &mut self, + cx: &mut Context, + ) -> Result>> { let model = self.model().context("No language model configured")?; log::info!("Thread::send called with model: {}", model.name().0); self.advance_prompt_id(); - let content = content.into_iter().map(Into::into).collect::>(); - log::debug!("Thread::send content: {:?}", content); + log::debug!("Total messages in thread: {}", self.messages.len()); + self.run_turn(cx) + } + pub fn push_acp_user_block( + &mut self, + id: UserMessageId, + blocks: impl IntoIterator, + path_style: PathStyle, + cx: &mut Context, + ) { + let content = blocks + .into_iter() + .map(|block| UserMessageContent::from_content_block(block, path_style)) + .collect::>(); self.messages .push(Message::User(UserMessage { id, content })); cx.notify(); + } - log::debug!("Total messages in thread: {}", self.messages.len()); - self.run_turn(cx) + pub fn push_acp_agent_block(&mut self, block: acp::ContentBlock, cx: &mut Context) { + let text = match block { + acp::ContentBlock::Text(text_content) => text_content.text, + acp::ContentBlock::Image(_) => "[image]".to_string(), + acp::ContentBlock::Audio(_) => "[audio]".to_string(), + acp::ContentBlock::ResourceLink(resource_link) => resource_link.uri, + acp::ContentBlock::Resource(resource) => match resource.resource { + acp::EmbeddedResourceResource::TextResourceContents(resource) => resource.uri, + acp::EmbeddedResourceResource::BlobResourceContents(resource) => resource.uri, + _ => "[resource]".to_string(), + }, + _ => "[unknown]".to_string(), + }; + + self.messages.push(Message::Agent(AgentMessage { + content: vec![AgentMessageContent::Text(text)], + ..Default::default() + })); + cx.notify(); } #[cfg(feature = "eval")] diff --git a/crates/agent/src/tools/context_server_registry.rs b/crates/agent/src/tools/context_server_registry.rs index 03a0ef84e73d4cbca83d61077d568ec58cd7ae2b..735a47ae9fb99decbf97beb74a590f13f8f74878 100644 --- a/crates/agent/src/tools/context_server_registry.rs +++ b/crates/agent/src/tools/context_server_registry.rs @@ -3,11 +3,23 @@ use agent_client_protocol::ToolKind; use anyhow::{Result, anyhow, bail}; use collections::{BTreeMap, HashMap}; use context_server::ContextServerId; -use gpui::{App, Context, Entity, SharedString, Task}; +use gpui::{App, AppContext, AsyncApp, Context, Entity, EventEmitter, SharedString, Task}; use project::context_server_store::{ContextServerStatus, ContextServerStore}; use std::sync::Arc; use util::ResultExt; +pub struct ContextServerPrompt { + pub server_id: ContextServerId, + pub prompt: context_server::types::Prompt, +} + +pub enum ContextServerRegistryEvent { + ToolsChanged, + PromptsChanged, +} + +impl EventEmitter for ContextServerRegistry {} + pub struct ContextServerRegistry { server_store: Entity, registered_servers: HashMap, @@ -16,7 +28,20 @@ pub struct ContextServerRegistry { struct RegisteredContextServer { tools: BTreeMap>, + prompts: BTreeMap, load_tools: Task>, + load_prompts: Task>, +} + +impl RegisteredContextServer { + fn new() -> Self { + Self { + tools: BTreeMap::default(), + prompts: BTreeMap::default(), + load_tools: Task::ready(Ok(())), + load_prompts: Task::ready(Ok(())), + } + } } impl ContextServerRegistry { @@ -28,6 +53,7 @@ impl ContextServerRegistry { }; for server in server_store.read(cx).running_servers() { this.reload_tools_for_server(server.id(), cx); + this.reload_prompts_for_server(server.id(), cx); } this } @@ -56,6 +82,41 @@ impl ContextServerRegistry { .map(|(id, server)| (id, &server.tools)) } + pub fn prompts(&self) -> impl Iterator { + self.registered_servers + .values() + .flat_map(|server| server.prompts.values()) + } + + pub fn find_prompt( + &self, + server_id: Option<&ContextServerId>, + name: &str, + ) -> Option<&ContextServerPrompt> { + if let Some(server_id) = server_id { + self.registered_servers + .get(server_id) + .and_then(|server| server.prompts.get(name)) + } else { + self.registered_servers + .values() + .find_map(|server| server.prompts.get(name)) + } + } + + pub fn server_store(&self) -> &Entity { + &self.server_store + } + + fn get_or_register_server( + &mut self, + server_id: &ContextServerId, + ) -> &mut RegisteredContextServer { + self.registered_servers + .entry(server_id.clone()) + .or_insert_with(RegisteredContextServer::new) + } + fn reload_tools_for_server(&mut self, server_id: ContextServerId, cx: &mut Context) { let Some(server) = self.server_store.read(cx).get_running_server(&server_id) else { return; @@ -67,13 +128,7 @@ impl ContextServerRegistry { return; } - let registered_server = - self.registered_servers - .entry(server_id.clone()) - .or_insert(RegisteredContextServer { - tools: BTreeMap::default(), - load_tools: Task::ready(Ok(())), - }); + let registered_server = self.get_or_register_server(&server_id); registered_server.load_tools = cx.spawn(async move |this, cx| { let response = client .request::(()) @@ -94,6 +149,49 @@ impl ContextServerRegistry { )); registered_server.tools.insert(tool.name(), tool); } + cx.emit(ContextServerRegistryEvent::ToolsChanged); + cx.notify(); + } + }) + }); + } + + fn reload_prompts_for_server(&mut self, server_id: ContextServerId, cx: &mut Context) { + let Some(server) = self.server_store.read(cx).get_running_server(&server_id) else { + return; + }; + let Some(client) = server.client() else { + return; + }; + if !client.capable(context_server::protocol::ServerCapability::Prompts) { + return; + } + + let registered_server = self.get_or_register_server(&server_id); + + registered_server.load_prompts = cx.spawn(async move |this, cx| { + let response = client + .request::(()) + .await; + + this.update(cx, |this, cx| { + let Some(registered_server) = this.registered_servers.get_mut(&server_id) else { + return; + }; + + registered_server.prompts.clear(); + if let Some(response) = response.log_err() { + for prompt in response.prompts { + let name: SharedString = prompt.name.clone().into(); + registered_server.prompts.insert( + name, + ContextServerPrompt { + server_id: server_id.clone(), + prompt, + }, + ); + } + cx.emit(ContextServerRegistryEvent::PromptsChanged); cx.notify(); } }) @@ -112,9 +210,17 @@ impl ContextServerRegistry { ContextServerStatus::Starting => {} ContextServerStatus::Running => { self.reload_tools_for_server(server_id.clone(), cx); + self.reload_prompts_for_server(server_id.clone(), cx); } ContextServerStatus::Stopped | ContextServerStatus::Error(_) => { - self.registered_servers.remove(server_id); + if let Some(registered_server) = self.registered_servers.remove(server_id) { + if !registered_server.tools.is_empty() { + cx.emit(ContextServerRegistryEvent::ToolsChanged); + } + if !registered_server.prompts.is_empty() { + cx.emit(ContextServerRegistryEvent::PromptsChanged); + } + } cx.notify(); } } @@ -251,3 +357,39 @@ impl AnyAgentTool for ContextServerTool { Ok(()) } } + +pub fn get_prompt( + server_store: &Entity, + server_id: &ContextServerId, + prompt_name: &str, + arguments: HashMap, + cx: &mut AsyncApp, +) -> Task> { + let server = match cx.update(|cx| server_store.read(cx).get_running_server(server_id)) { + Ok(server) => server, + Err(error) => return Task::ready(Err(error)), + }; + let Some(server) = server else { + return Task::ready(Err(anyhow::anyhow!("Context server not found"))); + }; + + let Some(protocol) = server.client() else { + return Task::ready(Err(anyhow::anyhow!("Context server not initialized"))); + }; + + let prompt_name = prompt_name.to_string(); + + cx.background_spawn(async move { + let response = protocol + .request::( + context_server::types::PromptsGetParams { + name: prompt_name, + arguments: (!arguments.is_empty()).then(|| arguments), + meta: None, + }, + ) + .await?; + + Ok(response) + }) +} diff --git a/crates/agent_ui/src/acp/thread_view.rs b/crates/agent_ui/src/acp/thread_view.rs index aa02e22635c1585003fbfc540b50687ae0930ecd..cabdaf920c9597e85176f11f4f3a466c4ab96fe8 100644 --- a/crates/agent_ui/src/acp/thread_view.rs +++ b/crates/agent_ui/src/acp/thread_view.rs @@ -1315,7 +1315,7 @@ impl AcpThreadView { })?; anyhow::Ok(()) }) - .detach(); + .detach_and_log_err(cx); } fn open_edited_buffer( @@ -1940,6 +1940,16 @@ impl AcpThreadView { window: &mut Window, cx: &Context, ) -> AnyElement { + let is_indented = entry.is_indented(); + let is_first_indented = is_indented + && self.thread().is_some_and(|thread| { + thread + .read(cx) + .entries() + .get(entry_ix.saturating_sub(1)) + .is_none_or(|entry| !entry.is_indented()) + }); + let primary = match &entry { AgentThreadEntry::UserMessage(message) => { let Some(editor) = self @@ -1972,7 +1982,9 @@ impl AcpThreadView { v_flex() .id(("user_message", entry_ix)) .map(|this| { - if entry_ix == 0 && !has_checkpoint_button && rules_item.is_none() { + if is_first_indented { + this.pt_0p5() + } else if entry_ix == 0 && !has_checkpoint_button && rules_item.is_none() { this.pt(rems_from_px(18.)) } else if rules_item.is_some() { this.pt_3() @@ -2018,6 +2030,9 @@ impl AcpThreadView { .shadow_md() .bg(cx.theme().colors().editor_background) .border_1() + .when(is_indented, |this| { + this.py_2().px_2().shadow_sm() + }) .when(editing && !editor_focus, |this| this.border_dashed()) .border_color(cx.theme().colors().border) .map(|this|{ @@ -2112,7 +2127,10 @@ impl AcpThreadView { ) .into_any() } - AgentThreadEntry::AssistantMessage(AssistantMessage { chunks }) => { + AgentThreadEntry::AssistantMessage(AssistantMessage { + chunks, + indented: _, + }) => { let is_last = entry_ix + 1 == total_entries; let style = default_markdown_style(false, false, window, cx); @@ -2146,6 +2164,7 @@ impl AcpThreadView { v_flex() .px_5() .py_1p5() + .when(is_first_indented, |this| this.pt_0p5()) .when(is_last, |this| this.pb_4()) .w_full() .text_ui(cx) @@ -2155,19 +2174,48 @@ impl AcpThreadView { AgentThreadEntry::ToolCall(tool_call) => { let has_terminals = tool_call.terminals().next().is_some(); - div().w_full().map(|this| { - if has_terminals { - this.children(tool_call.terminals().map(|terminal| { - self.render_terminal_tool_call( - entry_ix, terminal, tool_call, window, cx, - ) - })) - } else { - this.child(self.render_tool_call(entry_ix, tool_call, window, cx)) - } - }) + div() + .w_full() + .map(|this| { + if has_terminals { + this.children(tool_call.terminals().map(|terminal| { + self.render_terminal_tool_call( + entry_ix, terminal, tool_call, window, cx, + ) + })) + } else { + this.child(self.render_tool_call(entry_ix, tool_call, window, cx)) + } + }) + .into_any() } - .into_any(), + }; + + let primary = if is_indented { + let line_top = if is_first_indented { + rems_from_px(-12.0) + } else { + rems_from_px(0.0) + }; + + div() + .relative() + .w_full() + .pl(rems_from_px(20.0)) + .bg(cx.theme().colors().panel_background.opacity(0.2)) + .child( + div() + .absolute() + .left(rems_from_px(18.0)) + .top(line_top) + .bottom_0() + .w_px() + .bg(cx.theme().colors().border.opacity(0.6)), + ) + .child(primary) + .into_any_element() + } else { + primary }; let needs_confirmation = if let AgentThreadEntry::ToolCall(tool_call) = entry { diff --git a/crates/context_server/src/types.rs b/crates/context_server/src/types.rs index 03aca4f3caf7995091bbc8e049494b324674a9d3..81a427a289347ad50bf6a11674c4c5867073a274 100644 --- a/crates/context_server/src/types.rs +++ b/crates/context_server/src/types.rs @@ -330,7 +330,7 @@ pub struct PromptMessage { pub content: MessageContent, } -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)] #[serde(rename_all = "lowercase")] pub enum Role { User, From 93d79f3862ea56b5c445b534285f843ce6868ea2 Mon Sep 17 00:00:00 2001 From: Mayank Verma Date: Tue, 16 Dec 2025 23:39:09 +0530 Subject: [PATCH 392/621] git: Add support for repository excludes file (#42082) Closes #4824 Release Notes: - Added support for Git repository excludes file `.git/info/exclude` --------- Co-authored-by: Cole Miller Co-authored-by: Cole Miller --- crates/editor/src/editor_tests.rs | 47 +++++-- crates/editor/src/test/editor_test_context.rs | 6 + crates/git/src/git.rs | 1 + crates/worktree/src/ignore.rs | 37 +++++- crates/worktree/src/worktree.rs | 121 +++++++++++++++++- crates/worktree/src/worktree_tests.rs | 90 ++++++++++++- 6 files changed, 280 insertions(+), 22 deletions(-) diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rs index dfc8fd7f901bf1f45352511e3b7e69f7f4d4b367..0fc91832dcaab8ed709739c74be01e51bb491e83 100644 --- a/crates/editor/src/editor_tests.rs +++ b/crates/editor/src/editor_tests.rs @@ -25578,6 +25578,7 @@ async fn test_tab_in_leading_whitespace_auto_indents_for_python(cx: &mut TestApp ˇ log('for else') "}); cx.update_editor(|e, window, cx| e.tab(&Tab, window, cx)); + cx.wait_for_autoindent_applied().await; cx.assert_editor_state(indoc! {" def main(): ˇfor item in items: @@ -25597,6 +25598,7 @@ async fn test_tab_in_leading_whitespace_auto_indents_for_python(cx: &mut TestApp // test relative indent is preserved when tab // for `if`, `elif`, `else`, `while`, `with` and `for` cx.update_editor(|e, window, cx| e.tab(&Tab, window, cx)); + cx.wait_for_autoindent_applied().await; cx.assert_editor_state(indoc! {" def main(): ˇfor item in items: @@ -25630,6 +25632,7 @@ async fn test_tab_in_leading_whitespace_auto_indents_for_python(cx: &mut TestApp ˇ return 0 "}); cx.update_editor(|e, window, cx| e.tab(&Tab, window, cx)); + cx.wait_for_autoindent_applied().await; cx.assert_editor_state(indoc! {" def main(): ˇtry: @@ -25646,6 +25649,7 @@ async fn test_tab_in_leading_whitespace_auto_indents_for_python(cx: &mut TestApp // test relative indent is preserved when tab // for `try`, `except`, `else`, `finally`, `match` and `def` cx.update_editor(|e, window, cx| e.tab(&Tab, window, cx)); + cx.wait_for_autoindent_applied().await; cx.assert_editor_state(indoc! {" def main(): ˇtry: @@ -25679,6 +25683,7 @@ async fn test_outdent_after_input_for_python(cx: &mut TestAppContext) { cx.update_editor(|editor, window, cx| { editor.handle_input("else:", window, cx); }); + cx.wait_for_autoindent_applied().await; cx.assert_editor_state(indoc! {" def main(): if i == 2: @@ -25696,6 +25701,7 @@ async fn test_outdent_after_input_for_python(cx: &mut TestAppContext) { cx.update_editor(|editor, window, cx| { editor.handle_input("except:", window, cx); }); + cx.wait_for_autoindent_applied().await; cx.assert_editor_state(indoc! {" def main(): try: @@ -25715,6 +25721,7 @@ async fn test_outdent_after_input_for_python(cx: &mut TestAppContext) { cx.update_editor(|editor, window, cx| { editor.handle_input("else:", window, cx); }); + cx.wait_for_autoindent_applied().await; cx.assert_editor_state(indoc! {" def main(): try: @@ -25738,6 +25745,7 @@ async fn test_outdent_after_input_for_python(cx: &mut TestAppContext) { cx.update_editor(|editor, window, cx| { editor.handle_input("finally:", window, cx); }); + cx.wait_for_autoindent_applied().await; cx.assert_editor_state(indoc! {" def main(): try: @@ -25762,6 +25770,7 @@ async fn test_outdent_after_input_for_python(cx: &mut TestAppContext) { cx.update_editor(|editor, window, cx| { editor.handle_input("else:", window, cx); }); + cx.wait_for_autoindent_applied().await; cx.assert_editor_state(indoc! {" def main(): try: @@ -25787,6 +25796,7 @@ async fn test_outdent_after_input_for_python(cx: &mut TestAppContext) { cx.update_editor(|editor, window, cx| { editor.handle_input("finally:", window, cx); }); + cx.wait_for_autoindent_applied().await; cx.assert_editor_state(indoc! {" def main(): try: @@ -25812,6 +25822,7 @@ async fn test_outdent_after_input_for_python(cx: &mut TestAppContext) { cx.update_editor(|editor, window, cx| { editor.handle_input("except:", window, cx); }); + cx.wait_for_autoindent_applied().await; cx.assert_editor_state(indoc! {" def main(): try: @@ -25835,6 +25846,7 @@ async fn test_outdent_after_input_for_python(cx: &mut TestAppContext) { cx.update_editor(|editor, window, cx| { editor.handle_input("except:", window, cx); }); + cx.wait_for_autoindent_applied().await; cx.assert_editor_state(indoc! {" def main(): try: @@ -25856,6 +25868,7 @@ async fn test_outdent_after_input_for_python(cx: &mut TestAppContext) { cx.update_editor(|editor, window, cx| { editor.handle_input("else:", window, cx); }); + cx.wait_for_autoindent_applied().await; cx.assert_editor_state(indoc! {" def main(): for i in range(10): @@ -25872,6 +25885,7 @@ async fn test_outdent_after_input_for_python(cx: &mut TestAppContext) { cx.update_editor(|editor, window, cx| { editor.handle_input("a", window, cx); }); + cx.wait_for_autoindent_applied().await; cx.assert_editor_state(indoc! {" def f() -> list[str]: aˇ @@ -25885,6 +25899,7 @@ async fn test_outdent_after_input_for_python(cx: &mut TestAppContext) { cx.update_editor(|editor, window, cx| { editor.handle_input(":", window, cx); }); + cx.wait_for_autoindent_applied().await; cx.assert_editor_state(indoc! {" match 1: case:ˇ @@ -25908,6 +25923,7 @@ async fn test_indent_on_newline_for_python(cx: &mut TestAppContext) { cx.update_editor(|editor, window, cx| { editor.newline(&Newline, window, cx); }); + cx.wait_for_autoindent_applied().await; cx.assert_editor_state(indoc! {" # COMMENT: ˇ @@ -25920,7 +25936,7 @@ async fn test_indent_on_newline_for_python(cx: &mut TestAppContext) { cx.update_editor(|editor, window, cx| { editor.newline(&Newline, window, cx); }); - cx.run_until_parked(); + cx.wait_for_autoindent_applied().await; cx.assert_editor_state(indoc! {" { ˇ @@ -25980,6 +25996,7 @@ async fn test_tab_in_leading_whitespace_auto_indents_for_bash(cx: &mut TestAppCo ˇ} "}); cx.update_editor(|e, window, cx| e.tab(&Tab, window, cx)); + cx.wait_for_autoindent_applied().await; cx.assert_editor_state(indoc! {" function main() { ˇfor item in $items; do @@ -25997,6 +26014,7 @@ async fn test_tab_in_leading_whitespace_auto_indents_for_bash(cx: &mut TestAppCo "}); // test relative indent is preserved when tab cx.update_editor(|e, window, cx| e.tab(&Tab, window, cx)); + cx.wait_for_autoindent_applied().await; cx.assert_editor_state(indoc! {" function main() { ˇfor item in $items; do @@ -26031,6 +26049,7 @@ async fn test_tab_in_leading_whitespace_auto_indents_for_bash(cx: &mut TestAppCo ˇ} "}); cx.update_editor(|e, window, cx| e.tab(&Tab, window, cx)); + cx.wait_for_autoindent_applied().await; cx.assert_editor_state(indoc! {" function handle() { ˇcase \"$1\" in @@ -26073,6 +26092,7 @@ async fn test_indent_after_input_for_bash(cx: &mut TestAppContext) { ˇ} "}); cx.update_editor(|e, window, cx| e.handle_input("#", window, cx)); + cx.wait_for_autoindent_applied().await; cx.assert_editor_state(indoc! {" function main() { #ˇ for item in $items; do @@ -26107,6 +26127,7 @@ async fn test_outdent_after_input_for_bash(cx: &mut TestAppContext) { cx.update_editor(|editor, window, cx| { editor.handle_input("else", window, cx); }); + cx.wait_for_autoindent_applied().await; cx.assert_editor_state(indoc! {" if [ \"$1\" = \"test\" ]; then echo \"foo bar\" @@ -26122,6 +26143,7 @@ async fn test_outdent_after_input_for_bash(cx: &mut TestAppContext) { cx.update_editor(|editor, window, cx| { editor.handle_input("elif", window, cx); }); + cx.wait_for_autoindent_applied().await; cx.assert_editor_state(indoc! {" if [ \"$1\" = \"test\" ]; then echo \"foo bar\" @@ -26139,6 +26161,7 @@ async fn test_outdent_after_input_for_bash(cx: &mut TestAppContext) { cx.update_editor(|editor, window, cx| { editor.handle_input("fi", window, cx); }); + cx.wait_for_autoindent_applied().await; cx.assert_editor_state(indoc! {" if [ \"$1\" = \"test\" ]; then echo \"foo bar\" @@ -26156,6 +26179,7 @@ async fn test_outdent_after_input_for_bash(cx: &mut TestAppContext) { cx.update_editor(|editor, window, cx| { editor.handle_input("done", window, cx); }); + cx.wait_for_autoindent_applied().await; cx.assert_editor_state(indoc! {" while read line; do echo \"$line\" @@ -26171,6 +26195,7 @@ async fn test_outdent_after_input_for_bash(cx: &mut TestAppContext) { cx.update_editor(|editor, window, cx| { editor.handle_input("done", window, cx); }); + cx.wait_for_autoindent_applied().await; cx.assert_editor_state(indoc! {" for file in *.txt; do cat \"$file\" @@ -26191,6 +26216,7 @@ async fn test_outdent_after_input_for_bash(cx: &mut TestAppContext) { cx.update_editor(|editor, window, cx| { editor.handle_input("esac", window, cx); }); + cx.wait_for_autoindent_applied().await; cx.assert_editor_state(indoc! {" case \"$1\" in start) @@ -26213,6 +26239,7 @@ async fn test_outdent_after_input_for_bash(cx: &mut TestAppContext) { cx.update_editor(|editor, window, cx| { editor.handle_input("*)", window, cx); }); + cx.wait_for_autoindent_applied().await; cx.assert_editor_state(indoc! {" case \"$1\" in start) @@ -26232,6 +26259,7 @@ async fn test_outdent_after_input_for_bash(cx: &mut TestAppContext) { cx.update_editor(|editor, window, cx| { editor.handle_input("fi", window, cx); }); + cx.wait_for_autoindent_applied().await; cx.assert_editor_state(indoc! {" if [ \"$1\" = \"test\" ]; then echo \"outer if\" @@ -26258,6 +26286,7 @@ async fn test_indent_on_newline_for_bash(cx: &mut TestAppContext) { cx.update_editor(|editor, window, cx| { editor.newline(&Newline, window, cx); }); + cx.wait_for_autoindent_applied().await; cx.assert_editor_state(indoc! {" # COMMENT: ˇ @@ -26271,7 +26300,7 @@ async fn test_indent_on_newline_for_bash(cx: &mut TestAppContext) { cx.update_editor(|editor, window, cx| { editor.newline(&Newline, window, cx); }); - cx.run_until_parked(); + cx.wait_for_autoindent_applied().await; cx.assert_editor_state(indoc! {" if [ \"$1\" = \"test\" ]; then @@ -26286,7 +26315,7 @@ async fn test_indent_on_newline_for_bash(cx: &mut TestAppContext) { cx.update_editor(|editor, window, cx| { editor.newline(&Newline, window, cx); }); - cx.run_until_parked(); + cx.wait_for_autoindent_applied().await; cx.assert_editor_state(indoc! {" if [ \"$1\" = \"test\" ]; then else @@ -26301,7 +26330,7 @@ async fn test_indent_on_newline_for_bash(cx: &mut TestAppContext) { cx.update_editor(|editor, window, cx| { editor.newline(&Newline, window, cx); }); - cx.run_until_parked(); + cx.wait_for_autoindent_applied().await; cx.assert_editor_state(indoc! {" if [ \"$1\" = \"test\" ]; then elif @@ -26315,7 +26344,7 @@ async fn test_indent_on_newline_for_bash(cx: &mut TestAppContext) { cx.update_editor(|editor, window, cx| { editor.newline(&Newline, window, cx); }); - cx.run_until_parked(); + cx.wait_for_autoindent_applied().await; cx.assert_editor_state(indoc! {" for file in *.txt; do ˇ @@ -26329,7 +26358,7 @@ async fn test_indent_on_newline_for_bash(cx: &mut TestAppContext) { cx.update_editor(|editor, window, cx| { editor.newline(&Newline, window, cx); }); - cx.run_until_parked(); + cx.wait_for_autoindent_applied().await; cx.assert_editor_state(indoc! {" case \"$1\" in start) @@ -26346,7 +26375,7 @@ async fn test_indent_on_newline_for_bash(cx: &mut TestAppContext) { cx.update_editor(|editor, window, cx| { editor.newline(&Newline, window, cx); }); - cx.run_until_parked(); + cx.wait_for_autoindent_applied().await; cx.assert_editor_state(indoc! {" case \"$1\" in start) @@ -26362,7 +26391,7 @@ async fn test_indent_on_newline_for_bash(cx: &mut TestAppContext) { cx.update_editor(|editor, window, cx| { editor.newline(&Newline, window, cx); }); - cx.run_until_parked(); + cx.wait_for_autoindent_applied().await; cx.assert_editor_state(indoc! {" function test() { ˇ @@ -26376,7 +26405,7 @@ async fn test_indent_on_newline_for_bash(cx: &mut TestAppContext) { cx.update_editor(|editor, window, cx| { editor.newline(&Newline, window, cx); }); - cx.run_until_parked(); + cx.wait_for_autoindent_applied().await; cx.assert_editor_state(indoc! {" echo \"test\"; ˇ diff --git a/crates/editor/src/test/editor_test_context.rs b/crates/editor/src/test/editor_test_context.rs index 511629c59d8f61f1c53f5deaa406f113b9dfc3d9..bcfaeea3a7330539b2f2790e7dbe9a4969c76981 100644 --- a/crates/editor/src/test/editor_test_context.rs +++ b/crates/editor/src/test/editor_test_context.rs @@ -305,6 +305,12 @@ impl EditorTestContext { snapshot.anchor_before(ranges[0].start)..snapshot.anchor_after(ranges[0].end) } + pub async fn wait_for_autoindent_applied(&mut self) { + if let Some(fut) = self.update_buffer(|buffer, _| buffer.wait_for_autoindent_applied()) { + fut.await.ok(); + } + } + pub fn set_head_text(&mut self, diff_base: &str) { self.cx.run_until_parked(); let fs = diff --git a/crates/git/src/git.rs b/crates/git/src/git.rs index 8b8f88ef65b86ea9157e1c3217fa01bb0d6355cb..805d8d181ab7a434b565d38bdb2f802a8a3cda1a 100644 --- a/crates/git/src/git.rs +++ b/crates/git/src/git.rs @@ -23,6 +23,7 @@ pub const FSMONITOR_DAEMON: &str = "fsmonitor--daemon"; pub const LFS_DIR: &str = "lfs"; pub const COMMIT_MESSAGE: &str = "COMMIT_EDITMSG"; pub const INDEX_LOCK: &str = "index.lock"; +pub const REPO_EXCLUDE: &str = "info/exclude"; actions!( git, diff --git a/crates/worktree/src/ignore.rs b/crates/worktree/src/ignore.rs index 17c362e2d7f78384fe3b9b444353d302c4dac4c5..87487c36df6dc4eca3da43eaab95f83847ba5d1f 100644 --- a/crates/worktree/src/ignore.rs +++ b/crates/worktree/src/ignore.rs @@ -13,6 +13,10 @@ pub enum IgnoreStackEntry { Global { ignore: Arc, }, + RepoExclude { + ignore: Arc, + parent: Arc, + }, Some { abs_base_path: Arc, ignore: Arc, @@ -21,6 +25,12 @@ pub enum IgnoreStackEntry { All, } +#[derive(Debug)] +pub enum IgnoreKind { + Gitignore(Arc), + RepoExclude, +} + impl IgnoreStack { pub fn none() -> Self { Self { @@ -43,13 +53,19 @@ impl IgnoreStack { } } - pub fn append(self, abs_base_path: Arc, ignore: Arc) -> Self { + pub fn append(self, kind: IgnoreKind, ignore: Arc) -> Self { let top = match self.top.as_ref() { IgnoreStackEntry::All => self.top.clone(), - _ => Arc::new(IgnoreStackEntry::Some { - abs_base_path, - ignore, - parent: self.top.clone(), + _ => Arc::new(match kind { + IgnoreKind::Gitignore(abs_base_path) => IgnoreStackEntry::Some { + abs_base_path, + ignore, + parent: self.top.clone(), + }, + IgnoreKind::RepoExclude => IgnoreStackEntry::RepoExclude { + ignore, + parent: self.top.clone(), + }, }), }; Self { @@ -84,6 +100,17 @@ impl IgnoreStack { ignore::Match::Whitelist(_) => false, } } + IgnoreStackEntry::RepoExclude { ignore, parent } => { + match ignore.matched(abs_path, is_dir) { + ignore::Match::None => IgnoreStack { + repo_root: self.repo_root.clone(), + top: parent.clone(), + } + .is_abs_path_ignored(abs_path, is_dir), + ignore::Match::Ignore(_) => true, + ignore::Match::Whitelist(_) => false, + } + } IgnoreStackEntry::Some { abs_base_path, ignore, diff --git a/crates/worktree/src/worktree.rs b/crates/worktree/src/worktree.rs index e1ce31c038de9136109c3c8566e5e497dfa4f239..6ec19493840da0b9de3eb55ac483488339ec5e8d 100644 --- a/crates/worktree/src/worktree.rs +++ b/crates/worktree/src/worktree.rs @@ -19,7 +19,8 @@ use futures::{ }; use fuzzy::CharBag; use git::{ - COMMIT_MESSAGE, DOT_GIT, FSMONITOR_DAEMON, GITIGNORE, INDEX_LOCK, LFS_DIR, status::GitSummary, + COMMIT_MESSAGE, DOT_GIT, FSMONITOR_DAEMON, GITIGNORE, INDEX_LOCK, LFS_DIR, REPO_EXCLUDE, + status::GitSummary, }; use gpui::{ App, AppContext as _, AsyncApp, BackgroundExecutor, Context, Entity, EventEmitter, Priority, @@ -71,6 +72,8 @@ use util::{ }; pub use worktree_settings::WorktreeSettings; +use crate::ignore::IgnoreKind; + pub const FS_WATCH_LATENCY: Duration = Duration::from_millis(100); /// A set of local or remote files that are being opened as part of a project. @@ -233,6 +236,9 @@ impl Default for WorkDirectory { pub struct LocalSnapshot { snapshot: Snapshot, global_gitignore: Option>, + /// Exclude files for all git repositories in the worktree, indexed by their absolute path. + /// The boolean indicates whether the gitignore needs to be updated. + repo_exclude_by_work_dir_abs_path: HashMap, (Arc, bool)>, /// All of the gitignore files in the worktree, indexed by their absolute path. /// The boolean indicates whether the gitignore needs to be updated. ignores_by_parent_abs_path: HashMap, (Arc, bool)>, @@ -393,6 +399,7 @@ impl Worktree { let mut snapshot = LocalSnapshot { ignores_by_parent_abs_path: Default::default(), global_gitignore: Default::default(), + repo_exclude_by_work_dir_abs_path: Default::default(), git_repositories: Default::default(), snapshot: Snapshot::new( cx.entity_id().as_u64(), @@ -2565,13 +2572,21 @@ impl LocalSnapshot { } else { IgnoreStack::none() }; + + if let Some((repo_exclude, _)) = repo_root + .as_ref() + .and_then(|abs_path| self.repo_exclude_by_work_dir_abs_path.get(abs_path)) + { + ignore_stack = ignore_stack.append(IgnoreKind::RepoExclude, repo_exclude.clone()); + } ignore_stack.repo_root = repo_root; for (parent_abs_path, ignore) in new_ignores.into_iter().rev() { if ignore_stack.is_abs_path_ignored(parent_abs_path, true) { ignore_stack = IgnoreStack::all(); break; } else if let Some(ignore) = ignore { - ignore_stack = ignore_stack.append(parent_abs_path.into(), ignore); + ignore_stack = + ignore_stack.append(IgnoreKind::Gitignore(parent_abs_path.into()), ignore); } } @@ -3646,13 +3661,23 @@ impl BackgroundScanner { let root_abs_path = self.state.lock().await.snapshot.abs_path.clone(); let repo = if self.scanning_enabled { - let (ignores, repo) = discover_ancestor_git_repo(self.fs.clone(), &root_abs_path).await; + let (ignores, exclude, repo) = + discover_ancestor_git_repo(self.fs.clone(), &root_abs_path).await; self.state .lock() .await .snapshot .ignores_by_parent_abs_path .extend(ignores); + if let Some(exclude) = exclude { + self.state + .lock() + .await + .snapshot + .repo_exclude_by_work_dir_abs_path + .insert(root_abs_path.as_path().into(), (exclude, false)); + } + repo } else { None @@ -3914,6 +3939,7 @@ impl BackgroundScanner { let mut relative_paths = Vec::with_capacity(abs_paths.len()); let mut dot_git_abs_paths = Vec::new(); + let mut work_dirs_needing_exclude_update = Vec::new(); abs_paths.sort_unstable(); abs_paths.dedup_by(|a, b| a.starts_with(b)); { @@ -3987,6 +4013,18 @@ impl BackgroundScanner { continue; }; + let absolute_path = abs_path.to_path_buf(); + if absolute_path.ends_with(Path::new(DOT_GIT).join(REPO_EXCLUDE)) { + if let Some(repository) = snapshot + .git_repositories + .values() + .find(|repo| repo.common_dir_abs_path.join(REPO_EXCLUDE) == absolute_path) + { + work_dirs_needing_exclude_update + .push(repository.work_directory_abs_path.clone()); + } + } + if abs_path.file_name() == Some(OsStr::new(GITIGNORE)) { for (_, repo) in snapshot .git_repositories @@ -4032,6 +4070,19 @@ impl BackgroundScanner { return; } + if !work_dirs_needing_exclude_update.is_empty() { + let mut state = self.state.lock().await; + for work_dir_abs_path in work_dirs_needing_exclude_update { + if let Some((_, needs_update)) = state + .snapshot + .repo_exclude_by_work_dir_abs_path + .get_mut(&work_dir_abs_path) + { + *needs_update = true; + } + } + } + self.state.lock().await.snapshot.scan_id += 1; let (scan_job_tx, scan_job_rx) = channel::unbounded(); @@ -4299,7 +4350,8 @@ impl BackgroundScanner { match build_gitignore(&child_abs_path, self.fs.as_ref()).await { Ok(ignore) => { let ignore = Arc::new(ignore); - ignore_stack = ignore_stack.append(job.abs_path.clone(), ignore.clone()); + ignore_stack = ignore_stack + .append(IgnoreKind::Gitignore(job.abs_path.clone()), ignore.clone()); new_ignore = Some(ignore); } Err(error) => { @@ -4561,11 +4613,24 @@ impl BackgroundScanner { .await; if path.is_empty() - && let Some((ignores, repo)) = new_ancestor_repo.take() + && let Some((ignores, exclude, repo)) = new_ancestor_repo.take() { log::trace!("updating ancestor git repository"); state.snapshot.ignores_by_parent_abs_path.extend(ignores); if let Some((ancestor_dot_git, work_directory)) = repo { + if let Some(exclude) = exclude { + let work_directory_abs_path = self + .state + .lock() + .await + .snapshot + .work_directory_abs_path(&work_directory); + + state + .snapshot + .repo_exclude_by_work_dir_abs_path + .insert(work_directory_abs_path.into(), (exclude, false)); + } state .insert_git_repository_for_path( work_directory, @@ -4663,6 +4728,36 @@ impl BackgroundScanner { { let snapshot = &mut self.state.lock().await.snapshot; let abs_path = snapshot.abs_path.clone(); + + snapshot.repo_exclude_by_work_dir_abs_path.retain( + |work_dir_abs_path, (exclude, needs_update)| { + if *needs_update { + *needs_update = false; + ignores_to_update.push(work_dir_abs_path.clone()); + + if let Some((_, repository)) = snapshot + .git_repositories + .iter() + .find(|(_, repo)| &repo.work_directory_abs_path == work_dir_abs_path) + { + let exclude_abs_path = + repository.common_dir_abs_path.join(REPO_EXCLUDE); + if let Ok(current_exclude) = self + .executor + .block(build_gitignore(&exclude_abs_path, self.fs.as_ref())) + { + *exclude = Arc::new(current_exclude); + } + } + } + + snapshot + .git_repositories + .iter() + .any(|(_, repo)| &repo.work_directory_abs_path == work_dir_abs_path) + }, + ); + snapshot .ignores_by_parent_abs_path .retain(|parent_abs_path, (_, needs_update)| { @@ -4717,7 +4812,8 @@ impl BackgroundScanner { let mut ignore_stack = job.ignore_stack; if let Some((ignore, _)) = snapshot.ignores_by_parent_abs_path.get(&job.abs_path) { - ignore_stack = ignore_stack.append(job.abs_path.clone(), ignore.clone()); + ignore_stack = + ignore_stack.append(IgnoreKind::Gitignore(job.abs_path.clone()), ignore.clone()); } let mut entries_by_id_edits = Vec::new(); @@ -4892,6 +4988,9 @@ impl BackgroundScanner { let preserve = ids_to_preserve.contains(work_directory_id); if !preserve { affected_repo_roots.push(entry.dot_git_abs_path.parent().unwrap().into()); + snapshot + .repo_exclude_by_work_dir_abs_path + .remove(&entry.work_directory_abs_path); } preserve }); @@ -4931,8 +5030,10 @@ async fn discover_ancestor_git_repo( root_abs_path: &SanitizedPath, ) -> ( HashMap, (Arc, bool)>, + Option>, Option<(PathBuf, WorkDirectory)>, ) { + let mut exclude = None; let mut ignores = HashMap::default(); for (index, ancestor) in root_abs_path.as_path().ancestors().enumerate() { if index != 0 { @@ -4968,6 +5069,7 @@ async fn discover_ancestor_git_repo( // also mark where in the git repo the root folder is located. return ( ignores, + exclude, Some(( ancestor_dot_git, WorkDirectory::AboveProject { @@ -4979,12 +5081,17 @@ async fn discover_ancestor_git_repo( }; } + let repo_exclude_abs_path = ancestor_dot_git.join(REPO_EXCLUDE); + if let Ok(repo_exclude) = build_gitignore(&repo_exclude_abs_path, fs.as_ref()).await { + exclude = Some(Arc::new(repo_exclude)); + } + // Reached root of git repository. break; } } - (ignores, None) + (ignores, exclude, None) } fn build_diff( diff --git a/crates/worktree/src/worktree_tests.rs b/crates/worktree/src/worktree_tests.rs index e58e99ea68ebde51a6c12abfd859296b3cd883c4..12f2863aab6c4b4376157f3499fa332051a4822f 100644 --- a/crates/worktree/src/worktree_tests.rs +++ b/crates/worktree/src/worktree_tests.rs @@ -1,7 +1,7 @@ use crate::{Entry, EntryKind, Event, PathChange, Worktree, WorktreeModelHandle}; use anyhow::Result; use fs::{FakeFs, Fs, RealFs, RemoveOptions}; -use git::GITIGNORE; +use git::{DOT_GIT, GITIGNORE, REPO_EXCLUDE}; use gpui::{AppContext as _, BackgroundExecutor, BorrowAppContext, Context, Task, TestAppContext}; use parking_lot::Mutex; use postage::stream::Stream; @@ -2412,6 +2412,94 @@ async fn test_global_gitignore(executor: BackgroundExecutor, cx: &mut TestAppCon }); } +#[gpui::test] +async fn test_repo_exclude(executor: BackgroundExecutor, cx: &mut TestAppContext) { + init_test(cx); + + let fs = FakeFs::new(executor); + let project_dir = Path::new(path!("/project")); + fs.insert_tree( + project_dir, + json!({ + ".git": { + "info": { + "exclude": ".env.*" + } + }, + ".env.example": "secret=xxxx", + ".env.local": "secret=1234", + ".gitignore": "!.env.example", + "README.md": "# Repo Exclude", + "src": { + "main.rs": "fn main() {}", + }, + }), + ) + .await; + + let worktree = Worktree::local( + project_dir, + true, + fs.clone(), + Default::default(), + true, + &mut cx.to_async(), + ) + .await + .unwrap(); + worktree + .update(cx, |worktree, _| { + worktree.as_local().unwrap().scan_complete() + }) + .await; + cx.run_until_parked(); + + // .gitignore overrides .git/info/exclude + worktree.update(cx, |worktree, _cx| { + let expected_excluded_paths = []; + let expected_ignored_paths = [".env.local"]; + let expected_tracked_paths = [".env.example", "README.md", "src/main.rs"]; + let expected_included_paths = []; + + check_worktree_entries( + worktree, + &expected_excluded_paths, + &expected_ignored_paths, + &expected_tracked_paths, + &expected_included_paths, + ); + }); + + // Ignore statuses are updated when .git/info/exclude file changes + fs.write( + &project_dir.join(DOT_GIT).join(REPO_EXCLUDE), + ".env.example".as_bytes(), + ) + .await + .unwrap(); + worktree + .update(cx, |worktree, _| { + worktree.as_local().unwrap().scan_complete() + }) + .await; + cx.run_until_parked(); + + worktree.update(cx, |worktree, _cx| { + let expected_excluded_paths = []; + let expected_ignored_paths = []; + let expected_tracked_paths = [".env.example", ".env.local", "README.md", "src/main.rs"]; + let expected_included_paths = []; + + check_worktree_entries( + worktree, + &expected_excluded_paths, + &expected_ignored_paths, + &expected_tracked_paths, + &expected_included_paths, + ); + }); +} + #[track_caller] fn check_worktree_entries( tree: &Worktree, From f21cec7cb1d961a0956b97046001117da3bc17f2 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Tue, 16 Dec 2025 20:34:00 +0200 Subject: [PATCH 393/621] Introduce worktree trust mechanism (#44887) Closes https://github.com/zed-industries/zed/issues/12589 Forces Zed to require user permissions before running any basic potentially dangerous actions: parsing and synchronizing `.zed/settings.json`, downloading and spawning any language and MCP servers (includes `prettier` and `copilot` instances) and all `NodeRuntime` interactions. There are more we can add later, among the ideas: DAP downloads on debugger start, Python virtual environment, etc. By default, Zed starts in restricted mode and shows a `! Restricted Mode` in the title bar, no aforementioned actions are executed. Clicking it or calling `workspace::ToggleWorktreeSecurity` command will bring a modal to trust worktrees or dismiss the modal: 1 Agent Panel shows a message too: 2 This works on local, SSH and WSL remote projects, trusted worktrees are persisted between Zed restarts. There's a way to clear all persisted trust with `workspace::ClearTrustedWorktrees`, this will restart Zed. This mechanism can be turned off with settings: ```jsonc "session": { "trust_all_worktrees": true } ``` in this mode, all worktrees will be trusted by default, allowing all actions, but no auto trust will be persisted: hence, when the setting is changed back, auto trusted worktrees will require another trust confirmation. This settings switch was added to the onboarding view also. Release Notes: - Introduced worktree trust mechanism, can be turned off with `"session": { "trust_all_worktrees": true }` --------- Co-authored-by: Matt Miller Co-authored-by: Danilo Leal Co-authored-by: John D. Swanson --- Cargo.lock | 1 + assets/keymaps/default-linux.json | 1 + assets/keymaps/default-macos.json | 1 + assets/keymaps/default-windows.json | 1 + assets/settings/default.json | 6 + crates/agent_ui/src/agent_panel.rs | 245 ++- crates/agent_ui/src/agent_ui.rs | 10 + .../remote_editing_collaboration_tests.rs | 286 ++- crates/collab/src/tests/test_server.rs | 3 + crates/edit_prediction_cli/src/headless.rs | 5 +- .../edit_prediction_cli/src/load_project.rs | 1 + crates/editor/src/editor_tests.rs | 169 +- crates/eval/src/eval.rs | 2 +- crates/eval/src/instance.rs | 1 + crates/git_ui/src/worktree_picker.rs | 1 + crates/inspector_ui/src/inspector.rs | 1 + crates/node_runtime/src/node_runtime.rs | 9 + crates/onboarding/src/basics_page.rs | 48 +- crates/project/Cargo.toml | 2 + crates/project/src/context_server_store.rs | 19 + crates/project/src/lsp_store.rs | 85 +- crates/project/src/persistence.rs | 411 ++++ crates/project/src/project.rs | 127 +- crates/project/src/project_settings.rs | 168 +- crates/project/src/trusted_worktrees.rs | 1933 +++++++++++++++++ crates/project_benchmarks/src/main.rs | 3 +- crates/proto/proto/worktree.proto | 19 + crates/proto/proto/zed.proto | 5 +- crates/proto/src/proto.rs | 10 +- .../recent_projects/src/remote_connections.rs | 21 +- crates/recent_projects/src/remote_servers.rs | 1 + crates/remote_server/Cargo.toml | 2 +- crates/remote_server/src/headless_project.rs | 62 + .../remote_server/src/remote_editing_tests.rs | 3 +- crates/remote_server/src/unix.rs | 7 + .../settings/src/settings_content/project.rs | 6 + crates/settings_ui/src/page_data.rs | 22 + crates/title_bar/src/title_bar.rs | 62 +- .../components/notification/alert_modal.rs | 231 +- crates/workspace/src/modal_layer.rs | 17 +- crates/workspace/src/security_modal.rs | 373 ++++ crates/workspace/src/workspace.rs | 83 +- crates/zed/src/main.rs | 14 +- docs/src/SUMMARY.md | 5 +- docs/src/ai/privacy-and-security.md | 4 +- docs/src/configuring-zed.md | 41 + docs/src/worktree-trust.md | 66 + 47 files changed, 4415 insertions(+), 178 deletions(-) create mode 100644 crates/project/src/persistence.rs create mode 100644 crates/project/src/trusted_worktrees.rs create mode 100644 crates/workspace/src/security_modal.rs create mode 100644 docs/src/worktree-trust.md diff --git a/Cargo.lock b/Cargo.lock index f8ff534719080a144ee0541d7b63f8b631017452..b89c0803c7ed9a1b90fc3e8fc55eab10cee7b905 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -12421,6 +12421,7 @@ dependencies = [ "context_server", "dap", "dap_adapters", + "db", "extension", "fancy-regex", "fs", diff --git a/assets/keymaps/default-linux.json b/assets/keymaps/default-linux.json index 185a2249a7a7f3cd33213a736d38df2f8565b885..5a37614180d46b4a79b97f9a23665cbf5372cc0a 100644 --- a/assets/keymaps/default-linux.json +++ b/assets/keymaps/default-linux.json @@ -45,6 +45,7 @@ "ctrl-alt-z": "edit_prediction::RatePredictions", "ctrl-alt-shift-i": "edit_prediction::ToggleMenu", "ctrl-alt-l": "lsp_tool::ToggleMenu", + "ctrl-alt-shift-s": "workspace::ToggleWorktreeSecurity", }, }, { diff --git a/assets/keymaps/default-macos.json b/assets/keymaps/default-macos.json index c711615041931a064680c5afce32c4ec06c749b3..8c8094495e16a9f26adaa380f584abe5e3bc2947 100644 --- a/assets/keymaps/default-macos.json +++ b/assets/keymaps/default-macos.json @@ -51,6 +51,7 @@ "ctrl-cmd-i": "edit_prediction::ToggleMenu", "ctrl-cmd-l": "lsp_tool::ToggleMenu", "ctrl-cmd-c": "editor::DisplayCursorNames", + "ctrl-cmd-s": "workspace::ToggleWorktreeSecurity", }, }, { diff --git a/assets/keymaps/default-windows.json b/assets/keymaps/default-windows.json index 1498f1deb98b6258bd92ac2dd0dbf1199c7db64f..74320ae637080da92108f195eabca537e3a71406 100644 --- a/assets/keymaps/default-windows.json +++ b/assets/keymaps/default-windows.json @@ -43,6 +43,7 @@ "ctrl-shift-i": "edit_prediction::ToggleMenu", "shift-alt-l": "lsp_tool::ToggleMenu", "ctrl-shift-alt-c": "editor::DisplayCursorNames", + "ctrl-shift-alt-s": "workspace::ToggleWorktreeSecurity", }, }, { diff --git a/assets/settings/default.json b/assets/settings/default.json index 0ef3bb70c71bb96828bc1b1c2594376b15bada90..a0e499934428b4bafcbe12b97b2e8fc4747a5f31 100644 --- a/assets/settings/default.json +++ b/assets/settings/default.json @@ -2062,6 +2062,12 @@ // // Default: true "restore_unsaved_buffers": true, + // Whether or not to skip worktree trust checks. + // When trusted, project settings are synchronized automatically, + // language and MCP servers are downloaded and started automatically. + // + // Default: false + "trust_all_worktrees": false, }, // Zed's Prettier integration settings. // Allows to enable/disable formatting with Prettier diff --git a/crates/agent_ui/src/agent_panel.rs b/crates/agent_ui/src/agent_panel.rs index 97c7aecb8e34563db0adfa6bdbeda31140fd6cdd..ff8cf8db969e9ef2d1d86b306c0f38fb66a67fde 100644 --- a/crates/agent_ui/src/agent_panel.rs +++ b/crates/agent_ui/src/agent_panel.rs @@ -2,10 +2,12 @@ use std::{ops::Range, path::Path, rc::Rc, sync::Arc, time::Duration}; use acp_thread::AcpThread; use agent::{ContextServerRegistry, DbThreadMetadata, HistoryEntry, HistoryStore}; +use agent_servers::AgentServer; use db::kvp::{Dismissable, KEY_VALUE_STORE}; use project::{ ExternalAgentServerName, agent_server_store::{CLAUDE_CODE_NAME, CODEX_NAME, GEMINI_NAME}, + trusted_worktrees::{RemoteHostLocation, TrustedWorktrees, wait_for_workspace_trust}, }; use serde::{Deserialize, Serialize}; use settings::{ @@ -262,6 +264,17 @@ impl AgentType { Self::Custom { .. } => Some(IconName::Sparkle), } } + + fn is_mcp(&self) -> bool { + match self { + Self::NativeAgent => false, + Self::TextThread => false, + Self::Custom { .. } => false, + Self::Gemini => true, + Self::ClaudeCode => true, + Self::Codex => true, + } + } } impl From for AgentType { @@ -287,7 +300,7 @@ impl ActiveView { } } - pub fn native_agent( + fn native_agent( fs: Arc, prompt_store: Option>, history_store: Entity, @@ -442,6 +455,9 @@ pub struct AgentPanel { pending_serialization: Option>>, onboarding: Entity, selected_agent: AgentType, + new_agent_thread_task: Task<()>, + show_trust_workspace_message: bool, + _worktree_trust_subscription: Option, } impl AgentPanel { @@ -665,6 +681,48 @@ impl AgentPanel { None }; + let mut show_trust_workspace_message = false; + let worktree_trust_subscription = + TrustedWorktrees::try_get_global(cx).and_then(|trusted_worktrees| { + let has_global_trust = trusted_worktrees.update(cx, |trusted_worktrees, cx| { + trusted_worktrees.can_trust_workspace( + project + .read(cx) + .remote_connection_options(cx) + .map(RemoteHostLocation::from), + cx, + ) + }); + if has_global_trust { + None + } else { + show_trust_workspace_message = true; + let project = project.clone(); + Some(cx.subscribe( + &trusted_worktrees, + move |agent_panel, trusted_worktrees, _, cx| { + let new_show_trust_workspace_message = + !trusted_worktrees.update(cx, |trusted_worktrees, cx| { + trusted_worktrees.can_trust_workspace( + project + .read(cx) + .remote_connection_options(cx) + .map(RemoteHostLocation::from), + cx, + ) + }); + if new_show_trust_workspace_message + != agent_panel.show_trust_workspace_message + { + agent_panel.show_trust_workspace_message = + new_show_trust_workspace_message; + cx.notify(); + }; + }, + )) + } + }); + let mut panel = Self { active_view, workspace, @@ -687,11 +745,14 @@ impl AgentPanel { height: None, zoomed: false, pending_serialization: None, + new_agent_thread_task: Task::ready(()), onboarding, acp_history, history_store, selected_agent: AgentType::default(), loading: false, + show_trust_workspace_message, + _worktree_trust_subscription: worktree_trust_subscription, }; // Initial sync of agent servers from extensions @@ -884,37 +945,63 @@ impl AgentPanel { } }; - let server = ext_agent.server(fs, history); - - this.update_in(cx, |this, window, cx| { - let selected_agent = ext_agent.into(); - if this.selected_agent != selected_agent { - this.selected_agent = selected_agent; - this.serialize(cx); + if ext_agent.is_mcp() { + let wait_task = this.update(cx, |agent_panel, cx| { + agent_panel.project.update(cx, |project, cx| { + wait_for_workspace_trust( + project.remote_connection_options(cx), + "context servers", + cx, + ) + }) + })?; + if let Some(wait_task) = wait_task { + this.update_in(cx, |agent_panel, window, cx| { + agent_panel.show_trust_workspace_message = true; + cx.notify(); + agent_panel.new_agent_thread_task = + cx.spawn_in(window, async move |agent_panel, cx| { + wait_task.await; + let server = ext_agent.server(fs, history); + agent_panel + .update_in(cx, |agent_panel, window, cx| { + agent_panel.show_trust_workspace_message = false; + cx.notify(); + agent_panel._external_thread( + server, + resume_thread, + summarize_thread, + workspace, + project, + loading, + ext_agent, + window, + cx, + ); + }) + .ok(); + }); + })?; + return Ok(()); } + } - let thread_view = cx.new(|cx| { - crate::acp::AcpThreadView::new( - server, - resume_thread, - summarize_thread, - workspace.clone(), - project, - this.history_store.clone(), - this.prompt_store.clone(), - !loading, - window, - cx, - ) - }); - - this.set_active_view( - ActiveView::ExternalAgentThread { thread_view }, - !loading, + let server = ext_agent.server(fs, history); + this.update_in(cx, |agent_panel, window, cx| { + agent_panel._external_thread( + server, + resume_thread, + summarize_thread, + workspace, + project, + loading, + ext_agent, window, cx, ); - }) + })?; + + anyhow::Ok(()) }) .detach_and_log_err(cx); } @@ -1423,6 +1510,36 @@ impl AgentPanel { window: &mut Window, cx: &mut Context, ) { + let wait_task = if agent.is_mcp() { + self.project.update(cx, |project, cx| { + wait_for_workspace_trust( + project.remote_connection_options(cx), + "context servers", + cx, + ) + }) + } else { + None + }; + if let Some(wait_task) = wait_task { + self.show_trust_workspace_message = true; + cx.notify(); + self.new_agent_thread_task = cx.spawn_in(window, async move |agent_panel, cx| { + wait_task.await; + agent_panel + .update_in(cx, |agent_panel, window, cx| { + agent_panel.show_trust_workspace_message = false; + cx.notify(); + agent_panel._new_agent_thread(agent, window, cx); + }) + .ok(); + }); + } else { + self._new_agent_thread(agent, window, cx); + } + } + + fn _new_agent_thread(&mut self, agent: AgentType, window: &mut Window, cx: &mut Context) { match agent { AgentType::TextThread => { window.dispatch_action(NewTextThread.boxed_clone(), cx); @@ -1477,6 +1594,47 @@ impl AgentPanel { cx, ); } + + fn _external_thread( + &mut self, + server: Rc, + resume_thread: Option, + summarize_thread: Option, + workspace: WeakEntity, + project: Entity, + loading: bool, + ext_agent: ExternalAgent, + window: &mut Window, + cx: &mut Context, + ) { + let selected_agent = AgentType::from(ext_agent); + if self.selected_agent != selected_agent { + self.selected_agent = selected_agent; + self.serialize(cx); + } + + let thread_view = cx.new(|cx| { + crate::acp::AcpThreadView::new( + server, + resume_thread, + summarize_thread, + workspace.clone(), + project, + self.history_store.clone(), + self.prompt_store.clone(), + !loading, + window, + cx, + ) + }); + + self.set_active_view( + ActiveView::ExternalAgentThread { thread_view }, + !loading, + window, + cx, + ); + } } impl Focusable for AgentPanel { @@ -2557,6 +2715,38 @@ impl AgentPanel { } } + fn render_workspace_trust_message(&self, cx: &Context) -> Option { + if !self.show_trust_workspace_message { + return None; + } + + let description = "To protect your system, third-party code—like MCP servers—won't run until you mark this workspace as safe."; + + Some( + Callout::new() + .icon(IconName::Warning) + .severity(Severity::Warning) + .border_position(ui::BorderPosition::Bottom) + .title("You're in Restricted Mode") + .description(description) + .actions_slot( + Button::new("open-trust-modal", "Configure Project Trust") + .label_size(LabelSize::Small) + .style(ButtonStyle::Outlined) + .on_click({ + cx.listener(move |this, _, window, cx| { + this.workspace + .update(cx, |workspace, cx| { + workspace + .show_worktree_trust_security_modal(true, window, cx) + }) + .log_err(); + }) + }), + ), + ) + } + fn key_context(&self) -> KeyContext { let mut key_context = KeyContext::new_with_defaults(); key_context.add("AgentPanel"); @@ -2609,6 +2799,7 @@ impl Render for AgentPanel { } })) .child(self.render_toolbar(window, cx)) + .children(self.render_workspace_trust_message(cx)) .children(self.render_onboarding(window, cx)) .map(|parent| match &self.active_view { ActiveView::ExternalAgentThread { thread_view, .. } => parent diff --git a/crates/agent_ui/src/agent_ui.rs b/crates/agent_ui/src/agent_ui.rs index 3a0cc74bef611175b82884bd87e521c5a968d54a..4f759d6a9c7687d2cdf29752c489db2fcb1ffe68 100644 --- a/crates/agent_ui/src/agent_ui.rs +++ b/crates/agent_ui/src/agent_ui.rs @@ -171,6 +171,16 @@ impl ExternalAgent { Self::Custom { name } => Rc::new(agent_servers::CustomAgentServer::new(name.clone())), } } + + pub fn is_mcp(&self) -> bool { + match self { + Self::Gemini => true, + Self::ClaudeCode => true, + Self::Codex => true, + Self::NativeAgent => false, + Self::Custom { .. } => false, + } + } } /// Opens the profile management interface for configuring agent tools and settings. diff --git a/crates/collab/src/tests/remote_editing_collaboration_tests.rs b/crates/collab/src/tests/remote_editing_collaboration_tests.rs index 04403de9fa0883e9d738f3d96b9b2acdf1d66967..a66d7a1856c195a41a495123b468dc2b6ac8a1ca 100644 --- a/crates/collab/src/tests/remote_editing_collaboration_tests.rs +++ b/crates/collab/src/tests/remote_editing_collaboration_tests.rs @@ -4,6 +4,7 @@ use collections::{HashMap, HashSet}; use dap::{Capabilities, adapters::DebugTaskDefinition, transport::RequestHandling}; use debugger_ui::debugger_panel::DebugPanel; +use editor::{Editor, EditorMode, MultiBuffer}; use extension::ExtensionHostProxy; use fs::{FakeFs, Fs as _, RemoveOptions}; use futures::StreamExt as _; @@ -12,22 +13,30 @@ use http_client::BlockedHttpClient; use language::{ FakeLspAdapter, Language, LanguageConfig, LanguageMatcher, LanguageRegistry, language_settings::{Formatter, FormatterList, language_settings}, - tree_sitter_typescript, + rust_lang, tree_sitter_typescript, }; use node_runtime::NodeRuntime; use project::{ ProjectPath, debugger::session::ThreadId, lsp_store::{FormatTrigger, LspFormatTarget}, + trusted_worktrees::{PathTrust, TrustedWorktrees}, }; use remote::RemoteClient; use remote_server::{HeadlessAppState, HeadlessProject}; use rpc::proto; use serde_json::json; -use settings::{LanguageServerFormatterSpecifier, PrettierSettingsContent, SettingsStore}; +use settings::{ + InlayHintSettingsContent, LanguageServerFormatterSpecifier, PrettierSettingsContent, + SettingsStore, +}; use std::{ path::Path, - sync::{Arc, atomic::AtomicUsize}, + sync::{ + Arc, + atomic::{AtomicUsize, Ordering}, + }, + time::Duration, }; use task::TcpArgumentsTemplate; use util::{path, rel_path::rel_path}; @@ -90,13 +99,14 @@ async fn test_sharing_an_ssh_remote_project( languages, extension_host_proxy: Arc::new(ExtensionHostProxy::new()), }, + false, cx, ) }); let client_ssh = RemoteClient::fake_client(opts, cx_a).await; let (project_a, worktree_id) = client_a - .build_ssh_project(path!("/code/project1"), client_ssh, cx_a) + .build_ssh_project(path!("/code/project1"), client_ssh, false, cx_a) .await; // While the SSH worktree is being scanned, user A shares the remote project. @@ -250,13 +260,14 @@ async fn test_ssh_collaboration_git_branches( languages, extension_host_proxy: Arc::new(ExtensionHostProxy::new()), }, + false, cx, ) }); let client_ssh = RemoteClient::fake_client(opts, cx_a).await; let (project_a, _) = client_a - .build_ssh_project("/project", client_ssh, cx_a) + .build_ssh_project("/project", client_ssh, false, cx_a) .await; // While the SSH worktree is being scanned, user A shares the remote project. @@ -454,13 +465,14 @@ async fn test_ssh_collaboration_formatting_with_prettier( languages, extension_host_proxy: Arc::new(ExtensionHostProxy::new()), }, + false, cx, ) }); let client_ssh = RemoteClient::fake_client(opts, cx_a).await; let (project_a, worktree_id) = client_a - .build_ssh_project(path!("/project"), client_ssh, cx_a) + .build_ssh_project(path!("/project"), client_ssh, false, cx_a) .await; // While the SSH worktree is being scanned, user A shares the remote project. @@ -615,6 +627,7 @@ async fn test_remote_server_debugger( languages, extension_host_proxy: Arc::new(ExtensionHostProxy::new()), }, + false, cx, ) }); @@ -627,7 +640,7 @@ async fn test_remote_server_debugger( command_palette_hooks::init(cx); }); let (project_a, _) = client_a - .build_ssh_project(path!("/code"), client_ssh.clone(), cx_a) + .build_ssh_project(path!("/code"), client_ssh.clone(), false, cx_a) .await; let (workspace, cx_a) = client_a.build_workspace(&project_a, cx_a); @@ -723,6 +736,7 @@ async fn test_slow_adapter_startup_retries( languages, extension_host_proxy: Arc::new(ExtensionHostProxy::new()), }, + false, cx, ) }); @@ -735,7 +749,7 @@ async fn test_slow_adapter_startup_retries( command_palette_hooks::init(cx); }); let (project_a, _) = client_a - .build_ssh_project(path!("/code"), client_ssh.clone(), cx_a) + .build_ssh_project(path!("/code"), client_ssh.clone(), false, cx_a) .await; let (workspace, cx_a) = client_a.build_workspace(&project_a, cx_a); @@ -838,3 +852,259 @@ async fn test_slow_adapter_startup_retries( shutdown_session.await.unwrap(); } + +#[gpui::test] +async fn test_ssh_remote_worktree_trust(cx_a: &mut TestAppContext, server_cx: &mut TestAppContext) { + use project::trusted_worktrees::RemoteHostLocation; + + cx_a.update(|cx| { + release_channel::init(semver::Version::new(0, 0, 0), cx); + }); + server_cx.update(|cx| { + release_channel::init(semver::Version::new(0, 0, 0), cx); + }); + + let mut server = TestServer::start(cx_a.executor().clone()).await; + let client_a = server.create_client(cx_a, "user_a").await; + + let server_name = "override-rust-analyzer"; + let lsp_inlay_hint_request_count = Arc::new(AtomicUsize::new(0)); + + let (opts, server_ssh) = RemoteClient::fake_server(cx_a, server_cx); + let remote_fs = FakeFs::new(server_cx.executor()); + remote_fs + .insert_tree( + path!("/projects"), + json!({ + "project_a": { + ".zed": { + "settings.json": r#"{"languages":{"Rust":{"language_servers":["override-rust-analyzer"]}}}"# + }, + "main.rs": "fn main() {}" + }, + "project_b": { "lib.rs": "pub fn lib() {}" } + }), + ) + .await; + + server_cx.update(HeadlessProject::init); + let remote_http_client = Arc::new(BlockedHttpClient); + let node = NodeRuntime::unavailable(); + let languages = Arc::new(LanguageRegistry::new(server_cx.executor())); + languages.add(rust_lang()); + + let capabilities = lsp::ServerCapabilities { + inlay_hint_provider: Some(lsp::OneOf::Left(true)), + ..lsp::ServerCapabilities::default() + }; + let mut fake_language_servers = languages.register_fake_lsp( + "Rust", + FakeLspAdapter { + name: server_name, + capabilities: capabilities.clone(), + initializer: Some(Box::new({ + let lsp_inlay_hint_request_count = lsp_inlay_hint_request_count.clone(); + move |fake_server| { + let lsp_inlay_hint_request_count = lsp_inlay_hint_request_count.clone(); + fake_server.set_request_handler::( + move |_params, _| { + lsp_inlay_hint_request_count.fetch_add(1, Ordering::Release); + async move { + Ok(Some(vec![lsp::InlayHint { + position: lsp::Position::new(0, 0), + label: lsp::InlayHintLabel::String("hint".to_string()), + kind: None, + text_edits: None, + tooltip: None, + padding_left: None, + padding_right: None, + data: None, + }])) + } + }, + ); + } + })), + ..FakeLspAdapter::default() + }, + ); + + let _headless_project = server_cx.new(|cx| { + HeadlessProject::new( + HeadlessAppState { + session: server_ssh, + fs: remote_fs.clone(), + http_client: remote_http_client, + node_runtime: node, + languages, + extension_host_proxy: Arc::new(ExtensionHostProxy::new()), + }, + true, + cx, + ) + }); + + let client_ssh = RemoteClient::fake_client(opts, cx_a).await; + let (project_a, worktree_id_a) = client_a + .build_ssh_project(path!("/projects/project_a"), client_ssh.clone(), true, cx_a) + .await; + + cx_a.update(|cx| { + release_channel::init(semver::Version::new(0, 0, 0), cx); + + SettingsStore::update_global(cx, |store, cx| { + store.update_user_settings(cx, |settings| { + let language_settings = &mut settings.project.all_languages.defaults; + language_settings.inlay_hints = Some(InlayHintSettingsContent { + enabled: Some(true), + ..InlayHintSettingsContent::default() + }) + }); + }); + }); + + project_a + .update(cx_a, |project, cx| { + project.languages().add(rust_lang()); + project.languages().register_fake_lsp_adapter( + "Rust", + FakeLspAdapter { + name: server_name, + capabilities, + ..FakeLspAdapter::default() + }, + ); + project.find_or_create_worktree(path!("/projects/project_b"), true, cx) + }) + .await + .unwrap(); + + cx_a.run_until_parked(); + + let worktree_ids = project_a.read_with(cx_a, |project, cx| { + project + .worktrees(cx) + .map(|wt| wt.read(cx).id()) + .collect::>() + }); + assert_eq!(worktree_ids.len(), 2); + + let remote_host = project_a.read_with(cx_a, |project, cx| { + project + .remote_connection_options(cx) + .map(RemoteHostLocation::from) + }); + + let trusted_worktrees = + cx_a.update(|cx| TrustedWorktrees::try_get_global(cx).expect("trust global should exist")); + + let can_trust_a = + trusted_worktrees.update(cx_a, |store, cx| store.can_trust(worktree_ids[0], cx)); + let can_trust_b = + trusted_worktrees.update(cx_a, |store, cx| store.can_trust(worktree_ids[1], cx)); + assert!(!can_trust_a, "project_a should be restricted initially"); + assert!(!can_trust_b, "project_b should be restricted initially"); + + let worktree_store = project_a.read_with(cx_a, |project, _| project.worktree_store()); + let has_restricted = trusted_worktrees.read_with(cx_a, |store, cx| { + store.has_restricted_worktrees(&worktree_store, cx) + }); + assert!(has_restricted, "should have restricted worktrees"); + + let buffer_before_approval = project_a + .update(cx_a, |project, cx| { + project.open_buffer((worktree_id_a, rel_path("main.rs")), cx) + }) + .await + .unwrap(); + + let (editor, cx_a) = cx_a.add_window_view(|window, cx| { + Editor::new( + EditorMode::full(), + cx.new(|cx| MultiBuffer::singleton(buffer_before_approval.clone(), cx)), + Some(project_a.clone()), + window, + cx, + ) + }); + cx_a.run_until_parked(); + let fake_language_server = fake_language_servers.next(); + + cx_a.read(|cx| { + let file = buffer_before_approval.read(cx).file(); + assert_eq!( + language_settings(Some("Rust".into()), file, cx).language_servers, + ["...".to_string()], + "remote .zed/settings.json must not sync before trust approval" + ) + }); + + editor.update_in(cx_a, |editor, window, cx| { + editor.handle_input("1", window, cx); + }); + cx_a.run_until_parked(); + cx_a.executor().advance_clock(Duration::from_secs(1)); + assert_eq!( + lsp_inlay_hint_request_count.load(Ordering::Acquire), + 0, + "inlay hints must not be queried before trust approval" + ); + + trusted_worktrees.update(cx_a, |store, cx| { + store.trust( + HashSet::from_iter([PathTrust::Worktree(worktree_ids[0])]), + remote_host.clone(), + cx, + ); + }); + cx_a.run_until_parked(); + + cx_a.read(|cx| { + let file = buffer_before_approval.read(cx).file(); + assert_eq!( + language_settings(Some("Rust".into()), file, cx).language_servers, + ["override-rust-analyzer".to_string()], + "remote .zed/settings.json should sync after trust approval" + ) + }); + let _fake_language_server = fake_language_server.await.unwrap(); + editor.update_in(cx_a, |editor, window, cx| { + editor.handle_input("1", window, cx); + }); + cx_a.run_until_parked(); + cx_a.executor().advance_clock(Duration::from_secs(1)); + assert!( + lsp_inlay_hint_request_count.load(Ordering::Acquire) > 0, + "inlay hints should be queried after trust approval" + ); + + let can_trust_a = + trusted_worktrees.update(cx_a, |store, cx| store.can_trust(worktree_ids[0], cx)); + let can_trust_b = + trusted_worktrees.update(cx_a, |store, cx| store.can_trust(worktree_ids[1], cx)); + assert!(can_trust_a, "project_a should be trusted after trust()"); + assert!(!can_trust_b, "project_b should still be restricted"); + + trusted_worktrees.update(cx_a, |store, cx| { + store.trust( + HashSet::from_iter([PathTrust::Worktree(worktree_ids[1])]), + remote_host.clone(), + cx, + ); + }); + + let can_trust_a = + trusted_worktrees.update(cx_a, |store, cx| store.can_trust(worktree_ids[0], cx)); + let can_trust_b = + trusted_worktrees.update(cx_a, |store, cx| store.can_trust(worktree_ids[1], cx)); + assert!(can_trust_a, "project_a should remain trusted"); + assert!(can_trust_b, "project_b should now be trusted"); + + let has_restricted_after = trusted_worktrees.read_with(cx_a, |store, cx| { + store.has_restricted_worktrees(&worktree_store, cx) + }); + assert!( + !has_restricted_after, + "should have no restricted worktrees after trusting both" + ); +} diff --git a/crates/collab/src/tests/test_server.rs b/crates/collab/src/tests/test_server.rs index 959d54cf0864ccddf7273cca0276d18d4f59308b..3abbd1a014b556db02e70b42c239729100f17eb8 100644 --- a/crates/collab/src/tests/test_server.rs +++ b/crates/collab/src/tests/test_server.rs @@ -761,6 +761,7 @@ impl TestClient { &self, root_path: impl AsRef, ssh: Entity, + init_worktree_trust: bool, cx: &mut TestAppContext, ) -> (Entity, WorktreeId) { let project = cx.update(|cx| { @@ -771,6 +772,7 @@ impl TestClient { self.app_state.user_store.clone(), self.app_state.languages.clone(), self.app_state.fs.clone(), + init_worktree_trust, cx, ) }); @@ -839,6 +841,7 @@ impl TestClient { self.app_state.languages.clone(), self.app_state.fs.clone(), None, + false, cx, ) }) diff --git a/crates/edit_prediction_cli/src/headless.rs b/crates/edit_prediction_cli/src/headless.rs index 2deb96fdbf19a94c5649d87a7bf2f5fea0b601c2..489e78d364d0fdbb08b93eab89fd5f91f345f68e 100644 --- a/crates/edit_prediction_cli/src/headless.rs +++ b/crates/edit_prediction_cli/src/headless.rs @@ -8,8 +8,7 @@ use gpui_tokio::Tokio; use language::LanguageRegistry; use language_extension::LspAccess; use node_runtime::{NodeBinaryOptions, NodeRuntime}; -use project::Project; -use project::project_settings::ProjectSettings; +use project::{Project, project_settings::ProjectSettings}; use release_channel::{AppCommitSha, AppVersion}; use reqwest_client::ReqwestClient; use settings::{Settings, SettingsStore}; @@ -115,7 +114,7 @@ pub fn init(cx: &mut App) -> EpAppState { tx.send(Some(options)).log_err(); }) .detach(); - let node_runtime = NodeRuntime::new(client.http_client(), None, rx); + let node_runtime = NodeRuntime::new(client.http_client(), None, rx, None); let extension_host_proxy = ExtensionHostProxy::global(cx); diff --git a/crates/edit_prediction_cli/src/load_project.rs b/crates/edit_prediction_cli/src/load_project.rs index 38f114d726d3626fac89982b7f3a98c55e92ac07..70daf00b79486fd917556cffaa26b1fd01ed4d28 100644 --- a/crates/edit_prediction_cli/src/load_project.rs +++ b/crates/edit_prediction_cli/src/load_project.rs @@ -179,6 +179,7 @@ async fn setup_project( app_state.languages.clone(), app_state.fs.clone(), None, + false, cx, ) })?; diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rs index 0fc91832dcaab8ed709739c74be01e51bb491e83..f379b2b4e014ae7f51b5d8ffd842112dba54279b 100644 --- a/crates/editor/src/editor_tests.rs +++ b/crates/editor/src/editor_tests.rs @@ -41,14 +41,16 @@ use multi_buffer::{ use parking_lot::Mutex; use pretty_assertions::{assert_eq, assert_ne}; use project::{ - FakeFs, + FakeFs, Project, debugger::breakpoint_store::{BreakpointState, SourceBreakpoint}, project_settings::LspSettings, + trusted_worktrees::{PathTrust, TrustedWorktrees}, }; use serde_json::{self, json}; use settings::{ AllLanguageSettingsContent, EditorSettingsContent, IndentGuideBackgroundColoring, - IndentGuideColoring, ProjectSettingsContent, SearchSettingsContent, + IndentGuideColoring, InlayHintSettingsContent, ProjectSettingsContent, SearchSettingsContent, + SettingsStore, }; use std::{cell::RefCell, future::Future, rc::Rc, sync::atomic::AtomicBool, time::Instant}; use std::{ @@ -29364,3 +29366,166 @@ async fn test_find_references_single_case(cx: &mut TestAppContext) { cx.assert_editor_state(after); } + +#[gpui::test] +async fn test_local_worktree_trust(cx: &mut TestAppContext) { + init_test(cx, |_| {}); + + cx.update(|cx| { + SettingsStore::update_global(cx, |store, cx| { + store.update_user_settings(cx, |settings| { + settings.project.all_languages.defaults.inlay_hints = + Some(InlayHintSettingsContent { + enabled: Some(true), + ..InlayHintSettingsContent::default() + }); + }); + }); + }); + + let fs = FakeFs::new(cx.executor()); + fs.insert_tree( + path!("/project"), + json!({ + ".zed": { + "settings.json": r#"{"languages":{"Rust":{"language_servers":["override-rust-analyzer"]}}}"# + }, + "main.rs": "fn main() {}" + }), + ) + .await; + + let lsp_inlay_hint_request_count = Arc::new(AtomicUsize::new(0)); + let server_name = "override-rust-analyzer"; + let project = Project::test_with_worktree_trust(fs, [path!("/project").as_ref()], cx).await; + + let language_registry = project.read_with(cx, |project, _| project.languages().clone()); + language_registry.add(rust_lang()); + + let capabilities = lsp::ServerCapabilities { + inlay_hint_provider: Some(lsp::OneOf::Left(true)), + ..lsp::ServerCapabilities::default() + }; + let mut fake_language_servers = language_registry.register_fake_lsp( + "Rust", + FakeLspAdapter { + name: server_name, + capabilities, + initializer: Some(Box::new({ + let lsp_inlay_hint_request_count = lsp_inlay_hint_request_count.clone(); + move |fake_server| { + let lsp_inlay_hint_request_count = lsp_inlay_hint_request_count.clone(); + fake_server.set_request_handler::( + move |_params, _| { + lsp_inlay_hint_request_count.fetch_add(1, atomic::Ordering::Release); + async move { + Ok(Some(vec![lsp::InlayHint { + position: lsp::Position::new(0, 0), + label: lsp::InlayHintLabel::String("hint".to_string()), + kind: None, + text_edits: None, + tooltip: None, + padding_left: None, + padding_right: None, + data: None, + }])) + } + }, + ); + } + })), + ..FakeLspAdapter::default() + }, + ); + + cx.run_until_parked(); + + let worktree_id = project.read_with(cx, |project, cx| { + project + .worktrees(cx) + .next() + .map(|wt| wt.read(cx).id()) + .expect("should have a worktree") + }); + + let trusted_worktrees = + cx.update(|cx| TrustedWorktrees::try_get_global(cx).expect("trust global should exist")); + + let can_trust = trusted_worktrees.update(cx, |store, cx| store.can_trust(worktree_id, cx)); + assert!(!can_trust, "worktree should be restricted initially"); + + let buffer_before_approval = project + .update(cx, |project, cx| { + project.open_buffer((worktree_id, rel_path("main.rs")), cx) + }) + .await + .unwrap(); + + let (editor, cx) = cx.add_window_view(|window, cx| { + Editor::new( + EditorMode::full(), + cx.new(|cx| MultiBuffer::singleton(buffer_before_approval.clone(), cx)), + Some(project.clone()), + window, + cx, + ) + }); + cx.run_until_parked(); + let fake_language_server = fake_language_servers.next(); + + cx.read(|cx| { + let file = buffer_before_approval.read(cx).file(); + assert_eq!( + language::language_settings::language_settings(Some("Rust".into()), file, cx) + .language_servers, + ["...".to_string()], + "local .zed/settings.json must not apply before trust approval" + ) + }); + + editor.update_in(cx, |editor, window, cx| { + editor.handle_input("1", window, cx); + }); + cx.run_until_parked(); + cx.executor() + .advance_clock(std::time::Duration::from_secs(1)); + assert_eq!( + lsp_inlay_hint_request_count.load(atomic::Ordering::Acquire), + 0, + "inlay hints must not be queried before trust approval" + ); + + trusted_worktrees.update(cx, |store, cx| { + store.trust( + std::collections::HashSet::from_iter([PathTrust::Worktree(worktree_id)]), + None, + cx, + ); + }); + cx.run_until_parked(); + + cx.read(|cx| { + let file = buffer_before_approval.read(cx).file(); + assert_eq!( + language::language_settings::language_settings(Some("Rust".into()), file, cx) + .language_servers, + ["override-rust-analyzer".to_string()], + "local .zed/settings.json should apply after trust approval" + ) + }); + let _fake_language_server = fake_language_server.await.unwrap(); + editor.update_in(cx, |editor, window, cx| { + editor.handle_input("1", window, cx); + }); + cx.run_until_parked(); + cx.executor() + .advance_clock(std::time::Duration::from_secs(1)); + assert!( + lsp_inlay_hint_request_count.load(atomic::Ordering::Acquire) > 0, + "inlay hints should be queried after trust approval" + ); + + let can_trust_after = + trusted_worktrees.update(cx, |store, cx| store.can_trust(worktree_id, cx)); + assert!(can_trust_after, "worktree should be trusted after trust()"); +} diff --git a/crates/eval/src/eval.rs b/crates/eval/src/eval.rs index 80633696b7d5e655bb7db3627568b881642cf62c..3a2891922c80b95c85f0daed25603bea14b41842 100644 --- a/crates/eval/src/eval.rs +++ b/crates/eval/src/eval.rs @@ -422,7 +422,7 @@ pub fn init(cx: &mut App) -> Arc { tx.send(Some(options)).log_err(); }) .detach(); - let node_runtime = NodeRuntime::new(client.http_client(), None, rx); + let node_runtime = NodeRuntime::new(client.http_client(), None, rx, None); let extension_host_proxy = ExtensionHostProxy::global(cx); debug_adapter_extension::init(extension_host_proxy.clone(), cx); diff --git a/crates/eval/src/instance.rs b/crates/eval/src/instance.rs index 4c71a5a82b3946a9cc6e22ced378ebaabeec5256..8c9da3eefab61e4fa5897f9d76123c3fe1d5fa8b 100644 --- a/crates/eval/src/instance.rs +++ b/crates/eval/src/instance.rs @@ -202,6 +202,7 @@ impl ExampleInstance { app_state.languages.clone(), app_state.fs.clone(), None, + false, cx, ); diff --git a/crates/git_ui/src/worktree_picker.rs b/crates/git_ui/src/worktree_picker.rs index f6b3e47dec386d906e55e555600a93059d0766d0..875ae55eefae19e24aa26fe75f80d70f8316c82b 100644 --- a/crates/git_ui/src/worktree_picker.rs +++ b/crates/git_ui/src/worktree_picker.rs @@ -421,6 +421,7 @@ async fn open_remote_worktree( app_state.user_store.clone(), app_state.languages.clone(), app_state.fs.clone(), + true, cx, ) })?; diff --git a/crates/inspector_ui/src/inspector.rs b/crates/inspector_ui/src/inspector.rs index 7f7985df9b98ee286c79e18a665802b1f73fbc1e..a82d27b6d015bef97b50983e05f3e2096a1ef8c7 100644 --- a/crates/inspector_ui/src/inspector.rs +++ b/crates/inspector_ui/src/inspector.rs @@ -33,6 +33,7 @@ pub fn init(app_state: Arc, cx: &mut App) { app_state.languages.clone(), app_state.fs.clone(), None, + false, cx, ); diff --git a/crates/node_runtime/src/node_runtime.rs b/crates/node_runtime/src/node_runtime.rs index 1eb6714500446dbfd2967ed4aa2f514a5f427aba..322117cd717cac5c604ba215a2a1c7e0f7d87f06 100644 --- a/crates/node_runtime/src/node_runtime.rs +++ b/crates/node_runtime/src/node_runtime.rs @@ -9,6 +9,8 @@ use serde::Deserialize; use smol::io::BufReader; use smol::{fs, lock::Mutex}; use std::fmt::Display; +use std::future::Future; +use std::pin::Pin; use std::{ env::{self, consts}, ffi::OsString, @@ -46,6 +48,7 @@ struct NodeRuntimeState { last_options: Option, options: watch::Receiver>, shell_env_loaded: Shared>, + trust_task: Option + Send>>>, } impl NodeRuntime { @@ -53,9 +56,11 @@ impl NodeRuntime { http: Arc, shell_env_loaded: Option>, options: watch::Receiver>, + trust_task: Option + Send>>>, ) -> Self { NodeRuntime(Arc::new(Mutex::new(NodeRuntimeState { http, + trust_task, instance: None, last_options: None, options, @@ -70,11 +75,15 @@ impl NodeRuntime { last_options: None, options: watch::channel(Some(NodeBinaryOptions::default())).1, shell_env_loaded: oneshot::channel().1.shared(), + trust_task: None, }))) } async fn instance(&self) -> Box { let mut state = self.0.lock().await; + if let Some(trust_task) = state.trust_task.take() { + trust_task.await; + } let options = loop { if let Some(options) = state.options.borrow().as_ref() { diff --git a/crates/onboarding/src/basics_page.rs b/crates/onboarding/src/basics_page.rs index ab5d578f7de731aff6be355b4d7ddb2c6cf95d57..b5a2f5de365b581b95cb60269918068345474880 100644 --- a/crates/onboarding/src/basics_page.rs +++ b/crates/onboarding/src/basics_page.rs @@ -3,6 +3,7 @@ use std::sync::Arc; use client::TelemetrySettings; use fs::Fs; use gpui::{Action, App, IntoElement}; +use project::project_settings::ProjectSettings; use settings::{BaseKeymap, Settings, update_settings_file}; use theme::{ Appearance, SystemAppearance, ThemeAppearanceMode, ThemeName, ThemeRegistry, ThemeSelection, @@ -10,8 +11,8 @@ use theme::{ }; use ui::{ Divider, ParentElement as _, StatefulInteractiveElement, SwitchField, TintColor, - ToggleButtonGroup, ToggleButtonGroupSize, ToggleButtonSimple, ToggleButtonWithIcon, prelude::*, - rems_from_px, + ToggleButtonGroup, ToggleButtonGroupSize, ToggleButtonSimple, ToggleButtonWithIcon, Tooltip, + prelude::*, rems_from_px, }; use vim_mode_setting::VimModeSetting; @@ -409,6 +410,48 @@ fn render_vim_mode_switch(tab_index: &mut isize, cx: &mut App) -> impl IntoEleme }) } +fn render_worktree_auto_trust_switch(tab_index: &mut isize, cx: &mut App) -> impl IntoElement { + let toggle_state = if ProjectSettings::get_global(cx).session.trust_all_worktrees { + ui::ToggleState::Selected + } else { + ui::ToggleState::Unselected + }; + + let tooltip_description = "Zed can only allow services like language servers, project settings, and MCP servers to run after you mark a new project as trusted."; + + SwitchField::new( + "onboarding-auto-trust-worktrees", + Some("Trust All Projects By Default"), + Some("Automatically mark all new projects as trusted to unlock all Zed's features".into()), + toggle_state, + { + let fs = ::global(cx); + move |&selection, _, cx| { + let trust = match selection { + ToggleState::Selected => true, + ToggleState::Unselected => false, + ToggleState::Indeterminate => { + return; + } + }; + update_settings_file(fs.clone(), cx, move |setting, _| { + setting.session.get_or_insert_default().trust_all_worktrees = Some(trust); + }); + + telemetry::event!( + "Welcome Page Worktree Auto Trust Toggled", + options = if trust { "on" } else { "off" } + ); + } + }, + ) + .tab_index({ + *tab_index += 1; + *tab_index - 1 + }) + .tooltip(Tooltip::text(tooltip_description)) +} + fn render_setting_import_button( tab_index: isize, label: SharedString, @@ -481,6 +524,7 @@ pub(crate) fn render_basics_page(cx: &mut App) -> impl IntoElement { .child(render_base_keymap_section(&mut tab_index, cx)) .child(render_import_settings_section(&mut tab_index, cx)) .child(render_vim_mode_switch(&mut tab_index, cx)) + .child(render_worktree_auto_trust_switch(&mut tab_index, cx)) .child(Divider::horizontal().color(ui::DividerColor::BorderVariant)) .child(render_telemetry_section(&mut tab_index, cx)) } diff --git a/crates/project/Cargo.toml b/crates/project/Cargo.toml index 9e2789fc109b8217f0f1033cc6d4832105c0ad48..b589af2d50c77b68da6d94334904505f104b37e8 100644 --- a/crates/project/Cargo.toml +++ b/crates/project/Cargo.toml @@ -40,6 +40,7 @@ clock.workspace = true collections.workspace = true context_server.workspace = true dap.workspace = true +db.workspace = true extension.workspace = true fancy-regex.workspace = true fs.workspace = true @@ -96,6 +97,7 @@ tracing.workspace = true [dev-dependencies] client = { workspace = true, features = ["test-support"] } +db = { workspace = true, features = ["test-support"] } collections = { workspace = true, features = ["test-support"] } context_server = { workspace = true, features = ["test-support"] } buffer_diff = { workspace = true, features = ["test-support"] } diff --git a/crates/project/src/context_server_store.rs b/crates/project/src/context_server_store.rs index 7ba46a46872ba57c758baccf9f67b0039818ee75..7d060db887b1b5d07dd4d6de9ca85297adfd0c6f 100644 --- a/crates/project/src/context_server_store.rs +++ b/crates/project/src/context_server_store.rs @@ -15,6 +15,7 @@ use util::{ResultExt as _, rel_path::RelPath}; use crate::{ Project, project_settings::{ContextServerSettings, ProjectSettings}, + trusted_worktrees::wait_for_workspace_trust, worktree_store::WorktreeStore, }; @@ -332,6 +333,15 @@ impl ContextServerStore { pub fn start_server(&mut self, server: Arc, cx: &mut Context) { cx.spawn(async move |this, cx| { + let wait_task = this.update(cx, |context_server_store, cx| { + context_server_store.project.update(cx, |project, cx| { + let remote_host = project.remote_connection_options(cx); + wait_for_workspace_trust(remote_host, "context servers", cx) + }) + })??; + if let Some(wait_task) = wait_task { + wait_task.await; + } let this = this.upgrade().context("Context server store dropped")?; let settings = this .update(cx, |this, _| { @@ -572,6 +582,15 @@ impl ContextServerStore { } async fn maintain_servers(this: WeakEntity, cx: &mut AsyncApp) -> Result<()> { + let wait_task = this.update(cx, |context_server_store, cx| { + context_server_store.project.update(cx, |project, cx| { + let remote_host = project.remote_connection_options(cx); + wait_for_workspace_trust(remote_host, "context servers", cx) + }) + })??; + if let Some(wait_task) = wait_task { + wait_task.await; + } let (mut configured_servers, registry, worktree_store) = this.update(cx, |this, _| { ( this.context_server_settings.clone(), diff --git a/crates/project/src/lsp_store.rs b/crates/project/src/lsp_store.rs index b107be8b9ff32ef078d92700b46210a3c35c2845..2ea3dbf70fcb4359f3f5985cc6cd3bb4db7df009 100644 --- a/crates/project/src/lsp_store.rs +++ b/crates/project/src/lsp_store.rs @@ -38,6 +38,7 @@ use crate::{ prettier_store::{self, PrettierStore, PrettierStoreEvent}, project_settings::{LspSettings, ProjectSettings}, toolchain_store::{LocalToolchainStore, ToolchainStoreEvent}, + trusted_worktrees::{PathTrust, TrustedWorktrees, TrustedWorktreesEvent}, worktree_store::{WorktreeStore, WorktreeStoreEvent}, yarn::YarnPathStore, }; @@ -54,8 +55,8 @@ use futures::{ }; use globset::{Glob, GlobBuilder, GlobMatcher, GlobSet, GlobSetBuilder}; use gpui::{ - App, AppContext, AsyncApp, Context, Entity, EventEmitter, PromptLevel, SharedString, Task, - WeakEntity, + App, AppContext, AsyncApp, Context, Entity, EventEmitter, PromptLevel, SharedString, + Subscription, Task, WeakEntity, }; use http_client::HttpClient; use itertools::Itertools as _; @@ -96,13 +97,14 @@ use serde::Serialize; use serde_json::Value; use settings::{Settings, SettingsLocation, SettingsStore}; use sha2::{Digest, Sha256}; -use smol::channel::Sender; +use smol::channel::{Receiver, Sender}; use snippet::Snippet; use std::{ any::TypeId, borrow::Cow, cell::RefCell, cmp::{Ordering, Reverse}, + collections::hash_map, convert::TryInto, ffi::OsStr, future::ready, @@ -296,6 +298,7 @@ pub struct LocalLspStore { LanguageServerId, HashMap, HashMap>>, >, + restricted_worktrees_tasks: HashMap)>, } impl LocalLspStore { @@ -367,7 +370,8 @@ impl LocalLspStore { ) -> LanguageServerId { let worktree = worktree_handle.read(cx); - let root_path = worktree.abs_path(); + let worktree_id = worktree.id(); + let worktree_abs_path = worktree.abs_path(); let toolchain = key.toolchain.clone(); let override_options = settings.initialization_options.clone(); @@ -375,19 +379,49 @@ impl LocalLspStore { let server_id = self.languages.next_language_server_id(); log::trace!( - "attempting to start language server {:?}, path: {root_path:?}, id: {server_id}", + "attempting to start language server {:?}, path: {worktree_abs_path:?}, id: {server_id}", adapter.name.0 ); + let untrusted_worktree_task = + TrustedWorktrees::try_get_global(cx).and_then(|trusted_worktrees| { + let can_trust = trusted_worktrees.update(cx, |trusted_worktrees, cx| { + trusted_worktrees.can_trust(worktree_id, cx) + }); + if can_trust { + self.restricted_worktrees_tasks.remove(&worktree_id); + None + } else { + match self.restricted_worktrees_tasks.entry(worktree_id) { + hash_map::Entry::Occupied(o) => Some(o.get().1.clone()), + hash_map::Entry::Vacant(v) => { + let (tx, rx) = smol::channel::bounded::<()>(1); + let subscription = cx.subscribe(&trusted_worktrees, move |_, e, _| { + if let TrustedWorktreesEvent::Trusted(_, trusted_paths) = e { + if trusted_paths.contains(&PathTrust::Worktree(worktree_id)) { + tx.send_blocking(()).ok(); + } + } + }); + v.insert((subscription, rx.clone())); + Some(rx) + } + } + } + }); + let update_binary_status = untrusted_worktree_task.is_none(); + let binary = self.get_language_server_binary( + worktree_abs_path.clone(), adapter.clone(), settings, toolchain.clone(), delegate.clone(), true, + untrusted_worktree_task, cx, ); - let pending_workspace_folders: Arc>> = Default::default(); + let pending_workspace_folders = Arc::>>::default(); let pending_server = cx.spawn({ let adapter = adapter.clone(); @@ -420,7 +454,7 @@ impl LocalLspStore { server_id, server_name, binary, - &root_path, + &worktree_abs_path, code_action_kinds, Some(pending_workspace_folders), cx, @@ -556,8 +590,10 @@ impl LocalLspStore { pending_workspace_folders, }; - self.languages - .update_lsp_binary_status(adapter.name(), BinaryStatus::Starting); + if update_binary_status { + self.languages + .update_lsp_binary_status(adapter.name(), BinaryStatus::Starting); + } self.language_servers.insert(server_id, state); self.language_server_ids @@ -571,19 +607,34 @@ impl LocalLspStore { fn get_language_server_binary( &self, + worktree_abs_path: Arc, adapter: Arc, settings: Arc, toolchain: Option, delegate: Arc, allow_binary_download: bool, + untrusted_worktree_task: Option>, cx: &mut App, ) -> Task> { if let Some(settings) = &settings.binary && let Some(path) = settings.path.as_ref().map(PathBuf::from) { let settings = settings.clone(); - + let languages = self.languages.clone(); return cx.background_spawn(async move { + if let Some(untrusted_worktree_task) = untrusted_worktree_task { + log::info!( + "Waiting for worktree {worktree_abs_path:?} to be trusted, before starting language server {}", + adapter.name(), + ); + untrusted_worktree_task.recv().await.ok(); + log::info!( + "Worktree {worktree_abs_path:?} is trusted, starting language server {}", + adapter.name(), + ); + languages + .update_lsp_binary_status(adapter.name(), BinaryStatus::Starting); + } let mut env = delegate.shell_env().await; env.extend(settings.env.unwrap_or_default()); @@ -614,6 +665,18 @@ impl LocalLspStore { }; cx.spawn(async move |cx| { + if let Some(untrusted_worktree_task) = untrusted_worktree_task { + log::info!( + "Waiting for worktree {worktree_abs_path:?} to be trusted, before starting language server {}", + adapter.name(), + ); + untrusted_worktree_task.recv().await.ok(); + log::info!( + "Worktree {worktree_abs_path:?} is trusted, starting language server {}", + adapter.name(), + ); + } + let (existing_binary, maybe_download_binary) = adapter .clone() .get_language_server_command(delegate.clone(), toolchain, lsp_binary_options, cx) @@ -3258,6 +3321,7 @@ impl LocalLspStore { id_to_remove: WorktreeId, cx: &mut Context, ) -> Vec { + self.restricted_worktrees_tasks.remove(&id_to_remove); self.diagnostics.remove(&id_to_remove); self.prettier_store.update(cx, |prettier_store, cx| { prettier_store.remove_worktree(id_to_remove, cx); @@ -3974,6 +4038,7 @@ impl LspStore { buffers_opened_in_servers: HashMap::default(), buffer_pull_diagnostics_result_ids: HashMap::default(), workspace_pull_diagnostics_result_ids: HashMap::default(), + restricted_worktrees_tasks: HashMap::default(), watched_manifest_filenames: ManifestProvidersStore::global(cx) .manifest_file_names(), }), diff --git a/crates/project/src/persistence.rs b/crates/project/src/persistence.rs new file mode 100644 index 0000000000000000000000000000000000000000..be844c58384aa001fdbffa5fbac5dc513e98c535 --- /dev/null +++ b/crates/project/src/persistence.rs @@ -0,0 +1,411 @@ +use collections::{HashMap, HashSet}; +use gpui::{App, Entity, SharedString}; +use std::path::PathBuf; + +use db::{ + query, + sqlez::{domain::Domain, thread_safe_connection::ThreadSafeConnection}, + sqlez_macros::sql, +}; + +use crate::{ + trusted_worktrees::{PathTrust, RemoteHostLocation, find_worktree_in_store}, + worktree_store::WorktreeStore, +}; + +// https://www.sqlite.org/limits.html +// > <..> the maximum value of a host parameter number is SQLITE_MAX_VARIABLE_NUMBER, +// > which defaults to <..> 32766 for SQLite versions after 3.32.0. +#[allow(unused)] +const MAX_QUERY_PLACEHOLDERS: usize = 32000; + +#[allow(unused)] +pub struct ProjectDb(ThreadSafeConnection); + +impl Domain for ProjectDb { + const NAME: &str = stringify!(ProjectDb); + + const MIGRATIONS: &[&str] = &[sql!( + CREATE TABLE IF NOT EXISTS trusted_worktrees ( + trust_id INTEGER PRIMARY KEY AUTOINCREMENT, + absolute_path TEXT, + user_name TEXT, + host_name TEXT + ) STRICT; + )]; +} + +db::static_connection!(PROJECT_DB, ProjectDb, []); + +impl ProjectDb { + pub(crate) async fn save_trusted_worktrees( + &self, + trusted_worktrees: HashMap, HashSet>, + trusted_workspaces: HashSet>, + ) -> anyhow::Result<()> { + use anyhow::Context as _; + use db::sqlez::statement::Statement; + use itertools::Itertools as _; + + PROJECT_DB + .clear_trusted_worktrees() + .await + .context("clearing previous trust state")?; + + let trusted_worktrees = trusted_worktrees + .into_iter() + .flat_map(|(host, abs_paths)| { + abs_paths + .into_iter() + .map(move |abs_path| (Some(abs_path), host.clone())) + }) + .chain(trusted_workspaces.into_iter().map(|host| (None, host))) + .collect::>(); + let mut first_worktree; + let mut last_worktree = 0_usize; + for (count, placeholders) in std::iter::once("(?, ?, ?)") + .cycle() + .take(trusted_worktrees.len()) + .chunks(MAX_QUERY_PLACEHOLDERS / 3) + .into_iter() + .map(|chunk| { + let mut count = 0; + let placeholders = chunk + .inspect(|_| { + count += 1; + }) + .join(", "); + (count, placeholders) + }) + .collect::>() + { + first_worktree = last_worktree; + last_worktree = last_worktree + count; + let query = format!( + r#"INSERT INTO trusted_worktrees(absolute_path, user_name, host_name) +VALUES {placeholders};"# + ); + + let trusted_worktrees = trusted_worktrees[first_worktree..last_worktree].to_vec(); + self.write(move |conn| { + let mut statement = Statement::prepare(conn, query)?; + let mut next_index = 1; + for (abs_path, host) in trusted_worktrees { + let abs_path = abs_path.as_ref().map(|abs_path| abs_path.to_string_lossy()); + next_index = statement.bind( + &abs_path.as_ref().map(|abs_path| abs_path.as_ref()), + next_index, + )?; + next_index = statement.bind( + &host + .as_ref() + .and_then(|host| Some(host.user_name.as_ref()?.as_str())), + next_index, + )?; + next_index = statement.bind( + &host.as_ref().map(|host| host.host_identifier.as_str()), + next_index, + )?; + } + statement.exec() + }) + .await + .context("inserting new trusted state")?; + } + Ok(()) + } + + pub(crate) fn fetch_trusted_worktrees( + &self, + worktree_store: Option>, + host: Option, + cx: &App, + ) -> anyhow::Result, HashSet>> { + let trusted_worktrees = PROJECT_DB.trusted_worktrees()?; + Ok(trusted_worktrees + .into_iter() + .map(|(abs_path, user_name, host_name)| { + let db_host = match (user_name, host_name) { + (_, None) => None, + (None, Some(host_name)) => Some(RemoteHostLocation { + user_name: None, + host_identifier: SharedString::new(host_name), + }), + (Some(user_name), Some(host_name)) => Some(RemoteHostLocation { + user_name: Some(SharedString::new(user_name)), + host_identifier: SharedString::new(host_name), + }), + }; + + match abs_path { + Some(abs_path) => { + if db_host != host { + (db_host, PathTrust::AbsPath(abs_path)) + } else if let Some(worktree_store) = &worktree_store { + find_worktree_in_store(worktree_store.read(cx), &abs_path, cx) + .map(PathTrust::Worktree) + .map(|trusted_worktree| (host.clone(), trusted_worktree)) + .unwrap_or_else(|| (db_host.clone(), PathTrust::AbsPath(abs_path))) + } else { + (db_host, PathTrust::AbsPath(abs_path)) + } + } + None => (db_host, PathTrust::Workspace), + } + }) + .fold(HashMap::default(), |mut acc, (remote_host, path_trust)| { + acc.entry(remote_host) + .or_insert_with(HashSet::default) + .insert(path_trust); + acc + })) + } + + query! { + fn trusted_worktrees() -> Result, Option, Option)>> { + SELECT absolute_path, user_name, host_name + FROM trusted_worktrees + } + } + + query! { + pub async fn clear_trusted_worktrees() -> Result<()> { + DELETE FROM trusted_worktrees + } + } +} + +#[cfg(test)] +mod tests { + use std::path::PathBuf; + + use collections::{HashMap, HashSet}; + use gpui::{SharedString, TestAppContext}; + use serde_json::json; + use settings::SettingsStore; + use smol::lock::Mutex; + use util::path; + + use crate::{ + FakeFs, Project, + persistence::PROJECT_DB, + trusted_worktrees::{PathTrust, RemoteHostLocation}, + }; + + static TEST_LOCK: Mutex<()> = Mutex::new(()); + + #[gpui::test] + async fn test_save_and_fetch_trusted_worktrees(cx: &mut TestAppContext) { + cx.executor().allow_parking(); + let _guard = TEST_LOCK.lock().await; + PROJECT_DB.clear_trusted_worktrees().await.unwrap(); + cx.update(|cx| { + if cx.try_global::().is_none() { + let settings = SettingsStore::test(cx); + cx.set_global(settings); + } + }); + + let fs = FakeFs::new(cx.executor()); + fs.insert_tree( + path!("/"), + json!({ + "project_a": { "main.rs": "" }, + "project_b": { "lib.rs": "" } + }), + ) + .await; + + let project = Project::test( + fs, + [path!("/project_a").as_ref(), path!("/project_b").as_ref()], + cx, + ) + .await; + let worktree_store = project.read_with(cx, |p, _| p.worktree_store()); + + let mut trusted_paths: HashMap, HashSet> = + HashMap::default(); + trusted_paths.insert( + None, + HashSet::from_iter([ + PathBuf::from(path!("/project_a")), + PathBuf::from(path!("/project_b")), + ]), + ); + + PROJECT_DB + .save_trusted_worktrees(trusted_paths, HashSet::default()) + .await + .unwrap(); + + let fetched = cx.update(|cx| { + PROJECT_DB.fetch_trusted_worktrees(Some(worktree_store.clone()), None, cx) + }); + let fetched = fetched.unwrap(); + + let local_trust = fetched.get(&None).expect("should have local host entry"); + assert_eq!(local_trust.len(), 2); + assert!( + local_trust + .iter() + .all(|p| matches!(p, PathTrust::Worktree(_))) + ); + + let fetched_no_store = cx + .update(|cx| PROJECT_DB.fetch_trusted_worktrees(None, None, cx)) + .unwrap(); + let local_trust_no_store = fetched_no_store + .get(&None) + .expect("should have local host entry"); + assert_eq!(local_trust_no_store.len(), 2); + assert!( + local_trust_no_store + .iter() + .all(|p| matches!(p, PathTrust::AbsPath(_))) + ); + } + + #[gpui::test] + async fn test_save_and_fetch_workspace_trust(cx: &mut TestAppContext) { + cx.executor().allow_parking(); + let _guard = TEST_LOCK.lock().await; + PROJECT_DB.clear_trusted_worktrees().await.unwrap(); + cx.update(|cx| { + if cx.try_global::().is_none() { + let settings = SettingsStore::test(cx); + cx.set_global(settings); + } + }); + + let fs = FakeFs::new(cx.executor()); + fs.insert_tree(path!("/root"), json!({ "main.rs": "" })) + .await; + + let project = Project::test(fs, [path!("/root").as_ref()], cx).await; + let worktree_store = project.read_with(cx, |p, _| p.worktree_store()); + + let trusted_workspaces = HashSet::from_iter([None]); + PROJECT_DB + .save_trusted_worktrees(HashMap::default(), trusted_workspaces) + .await + .unwrap(); + + let fetched = cx.update(|cx| { + PROJECT_DB.fetch_trusted_worktrees(Some(worktree_store.clone()), None, cx) + }); + let fetched = fetched.unwrap(); + + let local_trust = fetched.get(&None).expect("should have local host entry"); + assert!(local_trust.contains(&PathTrust::Workspace)); + + let fetched_no_store = cx + .update(|cx| PROJECT_DB.fetch_trusted_worktrees(None, None, cx)) + .unwrap(); + let local_trust_no_store = fetched_no_store + .get(&None) + .expect("should have local host entry"); + assert!(local_trust_no_store.contains(&PathTrust::Workspace)); + } + + #[gpui::test] + async fn test_save_and_fetch_remote_host_trust(cx: &mut TestAppContext) { + cx.executor().allow_parking(); + let _guard = TEST_LOCK.lock().await; + PROJECT_DB.clear_trusted_worktrees().await.unwrap(); + cx.update(|cx| { + if cx.try_global::().is_none() { + let settings = SettingsStore::test(cx); + cx.set_global(settings); + } + }); + + let fs = FakeFs::new(cx.executor()); + fs.insert_tree(path!("/root"), json!({ "main.rs": "" })) + .await; + + let project = Project::test(fs, [path!("/root").as_ref()], cx).await; + let worktree_store = project.read_with(cx, |p, _| p.worktree_store()); + + let remote_host = Some(RemoteHostLocation { + user_name: Some(SharedString::from("testuser")), + host_identifier: SharedString::from("remote.example.com"), + }); + + let mut trusted_paths: HashMap, HashSet> = + HashMap::default(); + trusted_paths.insert( + remote_host.clone(), + HashSet::from_iter([PathBuf::from("/home/testuser/project")]), + ); + + PROJECT_DB + .save_trusted_worktrees(trusted_paths, HashSet::default()) + .await + .unwrap(); + + let fetched = cx.update(|cx| { + PROJECT_DB.fetch_trusted_worktrees(Some(worktree_store.clone()), None, cx) + }); + let fetched = fetched.unwrap(); + + let remote_trust = fetched + .get(&remote_host) + .expect("should have remote host entry"); + assert_eq!(remote_trust.len(), 1); + assert!(remote_trust + .iter() + .any(|p| matches!(p, PathTrust::AbsPath(path) if path == &PathBuf::from("/home/testuser/project")))); + + let fetched_no_store = cx + .update(|cx| PROJECT_DB.fetch_trusted_worktrees(None, None, cx)) + .unwrap(); + let remote_trust_no_store = fetched_no_store + .get(&remote_host) + .expect("should have remote host entry"); + assert_eq!(remote_trust_no_store.len(), 1); + assert!(remote_trust_no_store + .iter() + .any(|p| matches!(p, PathTrust::AbsPath(path) if path == &PathBuf::from("/home/testuser/project")))); + } + + #[gpui::test] + async fn test_clear_trusted_worktrees(cx: &mut TestAppContext) { + cx.executor().allow_parking(); + let _guard = TEST_LOCK.lock().await; + PROJECT_DB.clear_trusted_worktrees().await.unwrap(); + cx.update(|cx| { + if cx.try_global::().is_none() { + let settings = SettingsStore::test(cx); + cx.set_global(settings); + } + }); + + let fs = FakeFs::new(cx.executor()); + fs.insert_tree(path!("/root"), json!({ "main.rs": "" })) + .await; + + let project = Project::test(fs, [path!("/root").as_ref()], cx).await; + let worktree_store = project.read_with(cx, |p, _| p.worktree_store()); + + let trusted_workspaces = HashSet::from_iter([None]); + PROJECT_DB + .save_trusted_worktrees(HashMap::default(), trusted_workspaces) + .await + .unwrap(); + + PROJECT_DB.clear_trusted_worktrees().await.unwrap(); + + let fetched = cx.update(|cx| { + PROJECT_DB.fetch_trusted_worktrees(Some(worktree_store.clone()), None, cx) + }); + let fetched = fetched.unwrap(); + + assert!(fetched.is_empty(), "should be empty after clear"); + + let fetched_no_store = cx + .update(|cx| PROJECT_DB.fetch_trusted_worktrees(None, None, cx)) + .unwrap(); + assert!(fetched_no_store.is_empty(), "should be empty after clear"); + } +} diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index 7e7c1ecb67d2f463cb5b728cbb2a7f1ea2b072e0..79d37f0e99f35f5c059a98017f5036e95e18bf01 100644 --- a/crates/project/src/project.rs +++ b/crates/project/src/project.rs @@ -10,6 +10,7 @@ pub mod image_store; pub mod lsp_command; pub mod lsp_store; mod manifest_tree; +mod persistence; pub mod prettier_store; mod project_search; pub mod project_settings; @@ -19,6 +20,7 @@ pub mod task_store; pub mod telemetry_snapshot; pub mod terminals; pub mod toolchain_store; +pub mod trusted_worktrees; pub mod worktree_store; #[cfg(test)] @@ -39,6 +41,7 @@ use crate::{ git_store::GitStore, lsp_store::{SymbolLocation, log_store::LogKind}, project_search::SearchResultsHandle, + trusted_worktrees::{PathTrust, RemoteHostLocation, TrustedWorktrees}, }; pub use agent_server_store::{AgentServerStore, AgentServersUpdated, ExternalAgentServerName}; pub use git_store::{ @@ -1069,6 +1072,7 @@ impl Project { languages: Arc, fs: Arc, env: Option>, + init_worktree_trust: bool, cx: &mut App, ) -> Entity { cx.new(|cx: &mut Context| { @@ -1077,6 +1081,15 @@ impl Project { .detach(); let snippets = SnippetProvider::new(fs.clone(), BTreeSet::from_iter([]), cx); let worktree_store = cx.new(|_| WorktreeStore::local(false, fs.clone())); + if init_worktree_trust { + trusted_worktrees::track_worktree_trust( + worktree_store.clone(), + None, + None, + None, + cx, + ); + } cx.subscribe(&worktree_store, Self::on_worktree_store_event) .detach(); @@ -1250,6 +1263,7 @@ impl Project { user_store: Entity, languages: Arc, fs: Arc, + init_worktree_trust: bool, cx: &mut App, ) -> Entity { cx.new(|cx: &mut Context| { @@ -1258,8 +1272,14 @@ impl Project { .detach(); let snippets = SnippetProvider::new(fs.clone(), BTreeSet::from_iter([]), cx); - let (remote_proto, path_style) = - remote.read_with(cx, |remote, _| (remote.proto_client(), remote.path_style())); + let (remote_proto, path_style, connection_options) = + remote.read_with(cx, |remote, _| { + ( + remote.proto_client(), + remote.path_style(), + remote.connection_options(), + ) + }); let worktree_store = cx.new(|_| { WorktreeStore::remote( false, @@ -1268,8 +1288,23 @@ impl Project { path_style, ) }); + cx.subscribe(&worktree_store, Self::on_worktree_store_event) .detach(); + if init_worktree_trust { + match &connection_options { + RemoteConnectionOptions::Wsl(..) | RemoteConnectionOptions::Ssh(..) => { + trusted_worktrees::track_worktree_trust( + worktree_store.clone(), + Some(RemoteHostLocation::from(connection_options)), + None, + Some((remote_proto.clone(), REMOTE_SERVER_PROJECT_ID)), + cx, + ); + } + RemoteConnectionOptions::Docker(..) => {} + } + } let weak_self = cx.weak_entity(); let context_server_store = @@ -1450,6 +1485,9 @@ impl Project { remote_proto.add_entity_request_handler(Self::handle_language_server_prompt_request); remote_proto.add_entity_message_handler(Self::handle_hide_toast); remote_proto.add_entity_request_handler(Self::handle_update_buffer_from_remote_server); + remote_proto.add_entity_request_handler(Self::handle_trust_worktrees); + remote_proto.add_entity_request_handler(Self::handle_restrict_worktrees); + BufferStore::init(&remote_proto); LspStore::init(&remote_proto); SettingsObserver::init(&remote_proto); @@ -1810,6 +1848,7 @@ impl Project { Arc::new(languages), fs, None, + false, cx, ) }) @@ -1834,6 +1873,25 @@ impl Project { fs: Arc, root_paths: impl IntoIterator, cx: &mut gpui::TestAppContext, + ) -> Entity { + Self::test_project(fs, root_paths, false, cx).await + } + + #[cfg(any(test, feature = "test-support"))] + pub async fn test_with_worktree_trust( + fs: Arc, + root_paths: impl IntoIterator, + cx: &mut gpui::TestAppContext, + ) -> Entity { + Self::test_project(fs, root_paths, true, cx).await + } + + #[cfg(any(test, feature = "test-support"))] + async fn test_project( + fs: Arc, + root_paths: impl IntoIterator, + init_worktree_trust: bool, + cx: &mut gpui::TestAppContext, ) -> Entity { use clock::FakeSystemClock; @@ -1850,6 +1908,7 @@ impl Project { Arc::new(languages), fs, None, + init_worktree_trust, cx, ) }); @@ -4757,9 +4816,14 @@ impl Project { envelope: TypedEnvelope, mut cx: AsyncApp, ) -> Result<()> { - this.update(&mut cx, |this, cx| { + this.update(&mut cx, |project, cx| { let worktree_id = WorktreeId::from_proto(envelope.payload.worktree_id); - if let Some(worktree) = this.worktree_for_id(worktree_id, cx) { + if let Some(trusted_worktrees) = TrustedWorktrees::try_get_global(cx) { + trusted_worktrees.update(cx, |trusted_worktrees, cx| { + trusted_worktrees.can_trust(worktree_id, cx) + }); + } + if let Some(worktree) = project.worktree_for_id(worktree_id, cx) { worktree.update(cx, |worktree, _| { let worktree = worktree.as_remote_mut().unwrap(); worktree.update_from_remote(envelope.payload); @@ -4786,6 +4850,61 @@ impl Project { BufferStore::handle_update_buffer(buffer_store, envelope, cx).await } + async fn handle_trust_worktrees( + this: Entity, + envelope: TypedEnvelope, + mut cx: AsyncApp, + ) -> Result { + let trusted_worktrees = cx + .update(|cx| TrustedWorktrees::try_get_global(cx))? + .context("missing trusted worktrees")?; + trusted_worktrees.update(&mut cx, |trusted_worktrees, cx| { + let remote_host = this + .read(cx) + .remote_connection_options(cx) + .map(RemoteHostLocation::from); + trusted_worktrees.trust( + envelope + .payload + .trusted_paths + .into_iter() + .filter_map(|proto_path| PathTrust::from_proto(proto_path)) + .collect(), + remote_host, + cx, + ); + })?; + Ok(proto::Ack {}) + } + + async fn handle_restrict_worktrees( + this: Entity, + envelope: TypedEnvelope, + mut cx: AsyncApp, + ) -> Result { + let trusted_worktrees = cx + .update(|cx| TrustedWorktrees::try_get_global(cx))? + .context("missing trusted worktrees")?; + trusted_worktrees.update(&mut cx, |trusted_worktrees, cx| { + let mut restricted_paths = envelope + .payload + .worktree_ids + .into_iter() + .map(WorktreeId::from_proto) + .map(PathTrust::Worktree) + .collect::>(); + if envelope.payload.restrict_workspace { + restricted_paths.insert(PathTrust::Workspace); + } + let remote_host = this + .read(cx) + .remote_connection_options(cx) + .map(RemoteHostLocation::from); + trusted_worktrees.restrict(restricted_paths, remote_host, cx); + })?; + Ok(proto::Ack {}) + } + async fn handle_update_buffer( this: Entity, envelope: TypedEnvelope, diff --git a/crates/project/src/project_settings.rs b/crates/project/src/project_settings.rs index 8494eac5b33e7e1f231f9c62010c49aec345229f..6d95411681d5d350271e7071b752f27d0807f60d 100644 --- a/crates/project/src/project_settings.rs +++ b/crates/project/src/project_settings.rs @@ -23,13 +23,14 @@ use settings::{ DapSettingsContent, InvalidSettingsError, LocalSettingsKind, RegisterSetting, Settings, SettingsLocation, SettingsStore, parse_json_with_comments, watch_config_file, }; -use std::{path::PathBuf, sync::Arc, time::Duration}; +use std::{cell::OnceCell, collections::BTreeMap, path::PathBuf, sync::Arc, time::Duration}; use task::{DebugTaskFile, TaskTemplates, VsCodeDebugTaskFile, VsCodeTaskFile}; use util::{ResultExt, rel_path::RelPath, serde::default_true}; use worktree::{PathChange, UpdatedEntriesSet, Worktree, WorktreeId}; use crate::{ task_store::{TaskSettingsLocation, TaskStore}, + trusted_worktrees::{PathTrust, TrustedWorktrees, TrustedWorktreesEvent}, worktree_store::{WorktreeStore, WorktreeStoreEvent}, }; @@ -83,6 +84,12 @@ pub struct SessionSettings { /// /// Default: true pub restore_unsaved_buffers: bool, + /// Whether or not to skip worktree trust checks. + /// When trusted, project settings are synchronized automatically, + /// language and MCP servers are downloaded and started automatically. + /// + /// Default: false + pub trust_all_worktrees: bool, } #[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize, JsonSchema)] @@ -570,6 +577,7 @@ impl Settings for ProjectSettings { load_direnv: project.load_direnv.clone().unwrap(), session: SessionSettings { restore_unsaved_buffers: content.session.unwrap().restore_unsaved_buffers.unwrap(), + trust_all_worktrees: content.session.unwrap().trust_all_worktrees.unwrap(), }, } } @@ -595,6 +603,9 @@ pub struct SettingsObserver { worktree_store: Entity, project_id: u64, task_store: Entity, + pending_local_settings: + HashMap), Option>>, + _trusted_worktrees_watcher: Option, _user_settings_watcher: Option, _global_task_config_watcher: Task<()>, _global_debug_config_watcher: Task<()>, @@ -620,11 +631,61 @@ impl SettingsObserver { cx.subscribe(&worktree_store, Self::on_worktree_store_event) .detach(); + let _trusted_worktrees_watcher = + TrustedWorktrees::try_get_global(cx).map(|trusted_worktrees| { + cx.subscribe( + &trusted_worktrees, + move |settings_observer, _, e, cx| match e { + TrustedWorktreesEvent::Trusted(_, trusted_paths) => { + for trusted_path in trusted_paths { + if let Some(pending_local_settings) = settings_observer + .pending_local_settings + .remove(trusted_path) + { + for ((worktree_id, directory_path), settings_contents) in + pending_local_settings + { + apply_local_settings( + worktree_id, + &directory_path, + LocalSettingsKind::Settings, + &settings_contents, + cx, + ); + if let Some(downstream_client) = + &settings_observer.downstream_client + { + downstream_client + .send(proto::UpdateWorktreeSettings { + project_id: settings_observer.project_id, + worktree_id: worktree_id.to_proto(), + path: directory_path.to_proto(), + content: settings_contents, + kind: Some( + local_settings_kind_to_proto( + LocalSettingsKind::Settings, + ) + .into(), + ), + }) + .log_err(); + } + } + } + } + } + TrustedWorktreesEvent::Restricted(..) => {} + }, + ) + }); + Self { worktree_store, task_store, mode: SettingsObserverMode::Local(fs.clone()), downstream_client: None, + _trusted_worktrees_watcher, + pending_local_settings: HashMap::default(), _user_settings_watcher: None, project_id: REMOTE_SERVER_PROJECT_ID, _global_task_config_watcher: Self::subscribe_to_global_task_file_changes( @@ -677,6 +738,8 @@ impl SettingsObserver { mode: SettingsObserverMode::Remote, downstream_client: None, project_id: REMOTE_SERVER_PROJECT_ID, + _trusted_worktrees_watcher: None, + pending_local_settings: HashMap::default(), _user_settings_watcher: user_settings_watcher, _global_task_config_watcher: Self::subscribe_to_global_task_file_changes( fs.clone(), @@ -975,36 +1038,32 @@ impl SettingsObserver { let worktree_id = worktree.read(cx).id(); let remote_worktree_id = worktree.read(cx).id(); let task_store = self.task_store.clone(); - + let can_trust_worktree = OnceCell::new(); for (directory, kind, file_content) in settings_contents { + let mut applied = true; match kind { - LocalSettingsKind::Settings | LocalSettingsKind::Editorconfig => cx - .update_global::(|store, cx| { - let result = store.set_local_settings( - worktree_id, - directory.clone(), - kind, - file_content.as_deref(), - cx, - ); - - match result { - Err(InvalidSettingsError::LocalSettings { path, message }) => { - log::error!("Failed to set local settings in {path:?}: {message}"); - cx.emit(SettingsObserverEvent::LocalSettingsUpdated(Err( - InvalidSettingsError::LocalSettings { path, message }, - ))); - } - Err(e) => { - log::error!("Failed to set local settings: {e}"); - } - Ok(()) => { - cx.emit(SettingsObserverEvent::LocalSettingsUpdated(Ok(directory - .as_std_path() - .join(local_settings_file_relative_path().as_std_path())))); - } + LocalSettingsKind::Settings => { + if *can_trust_worktree.get_or_init(|| { + if let Some(trusted_worktrees) = TrustedWorktrees::try_get_global(cx) { + trusted_worktrees.update(cx, |trusted_worktrees, cx| { + trusted_worktrees.can_trust(worktree_id, cx) + }) + } else { + true } - }), + }) { + apply_local_settings(worktree_id, &directory, kind, &file_content, cx) + } else { + applied = false; + self.pending_local_settings + .entry(PathTrust::Worktree(worktree_id)) + .or_default() + .insert((worktree_id, directory.clone()), file_content.clone()); + } + } + LocalSettingsKind::Editorconfig => { + apply_local_settings(worktree_id, &directory, kind, &file_content, cx) + } LocalSettingsKind::Tasks => { let result = task_store.update(cx, |task_store, cx| { task_store.update_user_tasks( @@ -1067,16 +1126,18 @@ impl SettingsObserver { } }; - if let Some(downstream_client) = &self.downstream_client { - downstream_client - .send(proto::UpdateWorktreeSettings { - project_id: self.project_id, - worktree_id: remote_worktree_id.to_proto(), - path: directory.to_proto(), - content: file_content.clone(), - kind: Some(local_settings_kind_to_proto(kind).into()), - }) - .log_err(); + if applied { + if let Some(downstream_client) = &self.downstream_client { + downstream_client + .send(proto::UpdateWorktreeSettings { + project_id: self.project_id, + worktree_id: remote_worktree_id.to_proto(), + path: directory.to_proto(), + content: file_content.clone(), + kind: Some(local_settings_kind_to_proto(kind).into()), + }) + .log_err(); + } } } } @@ -1193,6 +1254,37 @@ impl SettingsObserver { } } +fn apply_local_settings( + worktree_id: WorktreeId, + directory: &Arc, + kind: LocalSettingsKind, + file_content: &Option, + cx: &mut Context<'_, SettingsObserver>, +) { + cx.update_global::(|store, cx| { + let result = store.set_local_settings( + worktree_id, + directory.clone(), + kind, + file_content.as_deref(), + cx, + ); + + match result { + Err(InvalidSettingsError::LocalSettings { path, message }) => { + log::error!("Failed to set local settings in {path:?}: {message}"); + cx.emit(SettingsObserverEvent::LocalSettingsUpdated(Err( + InvalidSettingsError::LocalSettings { path, message }, + ))); + } + Err(e) => log::error!("Failed to set local settings: {e}"), + Ok(()) => cx.emit(SettingsObserverEvent::LocalSettingsUpdated(Ok(directory + .as_std_path() + .join(local_settings_file_relative_path().as_std_path())))), + } + }) +} + pub fn local_settings_kind_from_proto(kind: proto::LocalSettingsKind) -> LocalSettingsKind { match kind { proto::LocalSettingsKind::Settings => LocalSettingsKind::Settings, diff --git a/crates/project/src/trusted_worktrees.rs b/crates/project/src/trusted_worktrees.rs new file mode 100644 index 0000000000000000000000000000000000000000..733e8d48294b863f8bf35cdb1ea458acd59dcadb --- /dev/null +++ b/crates/project/src/trusted_worktrees.rs @@ -0,0 +1,1933 @@ +//! A module, responsible for managing the trust logic in Zed. +//! +//! It deals with multiple hosts, distinguished by [`RemoteHostLocation`]. +//! Each [`crate::Project`] and `HeadlessProject` should call [`init_global`], if wants to establish the trust mechanism. +//! This will set up a [`gpui::Global`] with [`TrustedWorktrees`] entity that will persist, restore and allow querying for worktree trust. +//! It's also possible to subscribe on [`TrustedWorktreesEvent`] events of this entity to track trust changes dynamically. +//! +//! The implementation can synchronize trust information with the remote hosts: currently, WSL and SSH. +//! Docker and Collab remotes do not employ trust mechanism, as manage that themselves. +//! +//! Unless `trust_all_worktrees` auto trust is enabled, does not trust anything that was not persisted before. +//! When dealing with "restricted" and other related concepts in the API, it means all explicitly restricted, after any of the [`TrustedWorktreesStore::can_trust`] and [`TrustedWorktreesStore::can_trust_global`] calls. +//! +//! +//! +//! +//! Path rust hierarchy. +//! +//! Zed has multiple layers of trust, based on the requests and [`PathTrust`] enum variants. +//! From the least to the most trusted level: +//! +//! * "single file worktree" +//! +//! After opening an empty Zed it's possible to open just a file, same as after opening a directory in Zed it's possible to open a file outside of this directory. +//! Usual scenario for both cases is opening Zed's settings.json file via `zed: open settings file` command: that starts a language server for a new file open, which originates from a newly created, single file worktree. +//! +//! Spawning a language server is potentially dangerous, and Zed needs to restrict that by default. +//! Each single file worktree requires a separate trust permission, unless a more global level is trusted. +//! +//! * "workspace" +//! +//! Even an empty Zed instance with no files or directories open is potentially dangerous: opening an Assistant Panel and creating new external agent thread might require installing and running MCP servers. +//! +//! Disabling the entire panel is possible with ai-related settings. +//! Yet when it's enabled, it's still reasonably safe to use remote AI agents and control their permissions in the Assistant Panel. +//! +//! Unlike that, MCP servers are similar to language servers and may require fetching, installing and running packages or binaries. +//! Given that those servers are not tied to any particular worktree, this level of trust is required to operate any MCP server. +//! +//! Workspace level of trust assumes all single file worktrees are trusted too, for the same host: if we allow global MCP server-related functionality, we can already allow spawning language servers for single file worktrees as well. +//! +//! * "directory worktree" +//! +//! If a directory is open in Zed, it's a full worktree which may spawn multiple language servers associated with it. +//! Each such worktree requires a separate trust permission, so each separate directory worktree has to be trusted separately, unless a more global level is trusted. +//! +//! When a directory worktree is trusted and language servers are allowed to be downloaded and started, hence we also allow workspace level of trust (hence, "single file worktree" level of trust also). +//! +//! * "path override" +//! +//! To ease trusting multiple directory worktrees at once, it's possible to trust a parent directory of a certain directory worktree opened in Zed. +//! Trusting a directory means trusting all its subdirectories as well, including all current and potential directory worktrees. +//! +//! If we trust multiple projects to install and spawn various language server processes, we can also allow workspace trust requests for MCP servers installation and spawning. + +use collections::{HashMap, HashSet}; +use gpui::{ + App, AppContext as _, Context, Entity, EventEmitter, Global, SharedString, Task, WeakEntity, +}; +use remote::RemoteConnectionOptions; +use rpc::{AnyProtoClient, proto}; +use settings::{Settings as _, WorktreeId}; +use std::{ + path::{Path, PathBuf}, + sync::Arc, +}; +use util::debug_panic; + +use crate::{project_settings::ProjectSettings, worktree_store::WorktreeStore}; + +#[cfg(not(any(test, feature = "test-support")))] +use crate::persistence::PROJECT_DB; +#[cfg(not(any(test, feature = "test-support")))] +use util::ResultExt as _; + +pub fn init( + downstream_client: Option<(AnyProtoClient, u64)>, + upstream_client: Option<(AnyProtoClient, u64)>, + cx: &mut App, +) { + if TrustedWorktrees::try_get_global(cx).is_none() { + let trusted_worktrees = cx.new(|cx| { + TrustedWorktreesStore::new(None, None, downstream_client, upstream_client, cx) + }); + cx.set_global(TrustedWorktrees(trusted_worktrees)) + } +} + +/// An initialization call to set up trust global for a particular project (remote or local). +pub fn track_worktree_trust( + worktree_store: Entity, + remote_host: Option, + downstream_client: Option<(AnyProtoClient, u64)>, + upstream_client: Option<(AnyProtoClient, u64)>, + cx: &mut App, +) { + match TrustedWorktrees::try_get_global(cx) { + Some(trusted_worktrees) => { + trusted_worktrees.update(cx, |trusted_worktrees, cx| { + let sync_upstream = trusted_worktrees.upstream_client.as_ref().map(|(_, id)| id) + != upstream_client.as_ref().map(|(_, id)| id); + trusted_worktrees.downstream_client = downstream_client; + trusted_worktrees.upstream_client = upstream_client; + trusted_worktrees.add_worktree_store(worktree_store, remote_host, cx); + + if sync_upstream { + if let Some((upstream_client, upstream_project_id)) = + &trusted_worktrees.upstream_client + { + let trusted_paths = trusted_worktrees + .trusted_paths + .iter() + .flat_map(|(_, paths)| { + paths.iter().map(|trusted_path| trusted_path.to_proto()) + }) + .collect::>(); + if !trusted_paths.is_empty() { + upstream_client + .send(proto::TrustWorktrees { + project_id: *upstream_project_id, + trusted_paths, + }) + .ok(); + } + } + } + }); + } + None => { + let trusted_worktrees = cx.new(|cx| { + TrustedWorktreesStore::new( + Some(worktree_store.clone()), + remote_host, + downstream_client, + upstream_client, + cx, + ) + }); + cx.set_global(TrustedWorktrees(trusted_worktrees)) + } + } +} + +/// Waits until at least [`PathTrust::Workspace`] level of trust is granted for the host the [`TrustedWorktrees`] was initialized with. +pub fn wait_for_default_workspace_trust( + what_waits: &'static str, + cx: &mut App, +) -> Option> { + let trusted_worktrees = TrustedWorktrees::try_get_global(cx)?; + wait_for_workspace_trust( + trusted_worktrees.read(cx).remote_host.clone(), + what_waits, + cx, + ) +} + +/// Waits until at least [`PathTrust::Workspace`] level of trust is granted for a particular host. +pub fn wait_for_workspace_trust( + remote_host: Option>, + what_waits: &'static str, + cx: &mut App, +) -> Option> { + let trusted_worktrees = TrustedWorktrees::try_get_global(cx)?; + let remote_host = remote_host.map(|host| host.into()); + + let remote_host = if trusted_worktrees.update(cx, |trusted_worktrees, cx| { + trusted_worktrees.can_trust_workspace(remote_host.clone(), cx) + }) { + None + } else { + Some(remote_host) + }?; + + Some(cx.spawn(async move |cx| { + log::info!("Waiting for workspace to be trusted before starting {what_waits}"); + let (tx, restricted_worktrees_task) = smol::channel::bounded::<()>(1); + let Ok(_subscription) = cx.update(|cx| { + cx.subscribe(&trusted_worktrees, move |_, e, _| { + if let TrustedWorktreesEvent::Trusted(trusted_host, trusted_paths) = e { + if trusted_host == &remote_host && trusted_paths.contains(&PathTrust::Workspace) + { + log::info!("Workspace is trusted for {what_waits}"); + tx.send_blocking(()).ok(); + } + } + }) + }) else { + return; + }; + + restricted_worktrees_task.recv().await.ok(); + })) +} + +/// A collection of worktree trust metadata, can be accessed globally (if initialized) and subscribed to. +pub struct TrustedWorktrees(Entity); + +impl Global for TrustedWorktrees {} + +impl TrustedWorktrees { + pub fn try_get_global(cx: &App) -> Option> { + cx.try_global::().map(|this| this.0.clone()) + } +} + +/// A collection of worktrees that are considered trusted and not trusted. +/// This can be used when checking for this criteria before enabling certain features. +/// +/// Emits an event each time the worktree was checked and found not trusted, +/// or a certain worktree had been trusted. +pub struct TrustedWorktreesStore { + downstream_client: Option<(AnyProtoClient, u64)>, + upstream_client: Option<(AnyProtoClient, u64)>, + worktree_stores: HashMap, Option>, + trusted_paths: HashMap, HashSet>, + #[cfg(not(any(test, feature = "test-support")))] + serialization_task: Task<()>, + restricted: HashSet, + remote_host: Option, + restricted_workspaces: HashSet>, +} + +/// An identifier of a host to split the trust questions by. +/// Each trusted data change and event is done for a particular host. +/// A host may contain more than one worktree or even project open concurrently. +#[derive(Debug, PartialEq, Eq, Clone, Hash)] +pub struct RemoteHostLocation { + pub user_name: Option, + pub host_identifier: SharedString, +} + +impl From for RemoteHostLocation { + fn from(options: RemoteConnectionOptions) -> Self { + let (user_name, host_name) = match options { + RemoteConnectionOptions::Ssh(ssh) => ( + ssh.username.map(SharedString::new), + SharedString::new(ssh.host), + ), + RemoteConnectionOptions::Wsl(wsl) => ( + wsl.user.map(SharedString::new), + SharedString::new(wsl.distro_name), + ), + RemoteConnectionOptions::Docker(docker_connection_options) => ( + Some(SharedString::new(docker_connection_options.name)), + SharedString::new(docker_connection_options.container_id), + ), + }; + RemoteHostLocation { + user_name, + host_identifier: host_name, + } + } +} + +/// A unit of trust consideration inside a particular host: +/// either a familiar worktree, or a path that may influence other worktrees' trust. +/// See module-level documentation on the trust model. +#[derive(Debug, PartialEq, Eq, Clone, Hash)] +pub enum PathTrust { + /// General, no worktrees or files open case. + /// E.g. MCP servers can be spawned from a blank Zed instance, but will do `npm i` and other potentially malicious actions. + Workspace, + /// A worktree that is familiar to this workspace. + /// Either a single file or a directory worktree. + Worktree(WorktreeId), + /// A path that may be another worktree yet not loaded into any workspace (hence, without any `WorktreeId`), + /// or a parent path coming out of the security modal. + AbsPath(PathBuf), +} + +impl PathTrust { + fn to_proto(&self) -> proto::PathTrust { + match self { + Self::Workspace => proto::PathTrust { + content: Some(proto::path_trust::Content::Workspace(0)), + }, + Self::Worktree(worktree_id) => proto::PathTrust { + content: Some(proto::path_trust::Content::WorktreeId( + worktree_id.to_proto(), + )), + }, + Self::AbsPath(path_buf) => proto::PathTrust { + content: Some(proto::path_trust::Content::AbsPath( + path_buf.to_string_lossy().to_string(), + )), + }, + } + } + + pub fn from_proto(proto: proto::PathTrust) -> Option { + Some(match proto.content? { + proto::path_trust::Content::WorktreeId(id) => { + Self::Worktree(WorktreeId::from_proto(id)) + } + proto::path_trust::Content::AbsPath(path) => Self::AbsPath(PathBuf::from(path)), + proto::path_trust::Content::Workspace(_) => Self::Workspace, + }) + } +} + +/// A change of trust on a certain host. +#[derive(Debug)] +pub enum TrustedWorktreesEvent { + Trusted(Option, HashSet), + Restricted(Option, HashSet), +} + +impl EventEmitter for TrustedWorktreesStore {} + +impl TrustedWorktreesStore { + fn new( + worktree_store: Option>, + remote_host: Option, + downstream_client: Option<(AnyProtoClient, u64)>, + upstream_client: Option<(AnyProtoClient, u64)>, + cx: &App, + ) -> Self { + #[cfg(any(test, feature = "test-support"))] + let _ = cx; + + #[cfg(not(any(test, feature = "test-support")))] + let trusted_paths = if downstream_client.is_none() { + match PROJECT_DB.fetch_trusted_worktrees( + worktree_store.clone(), + remote_host.clone(), + cx, + ) { + Ok(trusted_paths) => trusted_paths, + Err(e) => { + log::error!("Failed to do initial trusted worktrees fetch: {e:#}"); + HashMap::default() + } + } + } else { + HashMap::default() + }; + #[cfg(any(test, feature = "test-support"))] + let trusted_paths = HashMap::, HashSet>::default(); + + if let Some((upstream_client, upstream_project_id)) = &upstream_client { + let trusted_paths = trusted_paths + .iter() + .flat_map(|(_, paths)| paths.iter().map(|trusted_path| trusted_path.to_proto())) + .collect::>(); + if !trusted_paths.is_empty() { + upstream_client + .send(proto::TrustWorktrees { + project_id: *upstream_project_id, + trusted_paths, + }) + .ok(); + } + } + + let worktree_stores = match worktree_store { + Some(worktree_store) => { + HashMap::from_iter([(worktree_store.downgrade(), remote_host.clone())]) + } + None => HashMap::default(), + }; + + Self { + trusted_paths, + downstream_client, + upstream_client, + remote_host, + restricted_workspaces: HashSet::default(), + restricted: HashSet::default(), + #[cfg(not(any(test, feature = "test-support")))] + serialization_task: Task::ready(()), + worktree_stores, + } + } + + /// Whether a particular worktree store has associated worktrees that are restricted, or an associated host is restricted. + pub fn has_restricted_worktrees( + &self, + worktree_store: &Entity, + cx: &App, + ) -> bool { + let Some(remote_host) = self.worktree_stores.get(&worktree_store.downgrade()) else { + return false; + }; + self.restricted_workspaces.contains(remote_host) + || self.restricted.iter().any(|restricted_worktree| { + worktree_store + .read(cx) + .worktree_for_id(*restricted_worktree, cx) + .is_some() + }) + } + + /// Adds certain entities on this host to the trusted list. + /// This will emit [`TrustedWorktreesEvent::Trusted`] event for all passed entries + /// and the ones that got auto trusted based on trust hierarchy (see module-level docs). + pub fn trust( + &mut self, + mut trusted_paths: HashSet, + remote_host: Option, + cx: &mut Context, + ) { + let mut new_workspace_trusted = false; + let mut new_trusted_single_file_worktrees = HashSet::default(); + let mut new_trusted_other_worktrees = HashSet::default(); + let mut new_trusted_abs_paths = HashSet::default(); + for trusted_path in trusted_paths.iter().chain( + self.trusted_paths + .remove(&remote_host) + .iter() + .flat_map(|current_trusted| current_trusted.iter()), + ) { + match trusted_path { + PathTrust::Workspace => new_workspace_trusted = true, + PathTrust::Worktree(worktree_id) => { + self.restricted.remove(worktree_id); + if let Some((abs_path, is_file, host)) = + self.find_worktree_data(*worktree_id, cx) + { + if host == remote_host { + if is_file { + new_trusted_single_file_worktrees.insert(*worktree_id); + } else { + new_trusted_other_worktrees.insert((abs_path, *worktree_id)); + new_workspace_trusted = true; + } + } + } + } + PathTrust::AbsPath(path) => { + new_workspace_trusted = true; + debug_assert!( + path.is_absolute(), + "Cannot trust non-absolute path {path:?}" + ); + new_trusted_abs_paths.insert(path.clone()); + } + } + } + + if new_workspace_trusted { + new_trusted_single_file_worktrees.clear(); + self.restricted_workspaces.remove(&remote_host); + trusted_paths.insert(PathTrust::Workspace); + } + new_trusted_other_worktrees.retain(|(worktree_abs_path, _)| { + new_trusted_abs_paths + .iter() + .all(|new_trusted_path| !worktree_abs_path.starts_with(new_trusted_path)) + }); + if !new_trusted_other_worktrees.is_empty() { + new_trusted_single_file_worktrees.clear(); + } + self.restricted = std::mem::take(&mut self.restricted) + .into_iter() + .filter(|restricted_worktree| { + let Some((restricted_worktree_path, is_file, restricted_host)) = + self.find_worktree_data(*restricted_worktree, cx) + else { + return false; + }; + if restricted_host != remote_host { + return true; + } + let retain = (!is_file + || (!new_workspace_trusted && new_trusted_other_worktrees.is_empty())) + && new_trusted_abs_paths.iter().all(|new_trusted_path| { + !restricted_worktree_path.starts_with(new_trusted_path) + }); + if !retain { + trusted_paths.insert(PathTrust::Worktree(*restricted_worktree)); + } + retain + }) + .collect(); + + { + let trusted_paths = self.trusted_paths.entry(remote_host.clone()).or_default(); + trusted_paths.extend(new_trusted_abs_paths.into_iter().map(PathTrust::AbsPath)); + trusted_paths.extend( + new_trusted_other_worktrees + .into_iter() + .map(|(_, worktree_id)| PathTrust::Worktree(worktree_id)), + ); + trusted_paths.extend( + new_trusted_single_file_worktrees + .into_iter() + .map(PathTrust::Worktree), + ); + if trusted_paths.is_empty() && new_workspace_trusted { + trusted_paths.insert(PathTrust::Workspace); + } + } + + cx.emit(TrustedWorktreesEvent::Trusted( + remote_host, + trusted_paths.clone(), + )); + + #[cfg(not(any(test, feature = "test-support")))] + if self.downstream_client.is_none() { + let mut new_trusted_workspaces = HashSet::default(); + let new_trusted_worktrees = self + .trusted_paths + .clone() + .into_iter() + .map(|(host, paths)| { + let abs_paths = paths + .into_iter() + .flat_map(|path| match path { + PathTrust::Worktree(worktree_id) => self + .find_worktree_data(worktree_id, cx) + .map(|(abs_path, ..)| abs_path.to_path_buf()), + PathTrust::AbsPath(abs_path) => Some(abs_path), + PathTrust::Workspace => { + new_trusted_workspaces.insert(host.clone()); + None + } + }) + .collect(); + (host, abs_paths) + }) + .collect(); + // Do not persist auto trusted worktrees + if !ProjectSettings::get_global(cx).session.trust_all_worktrees { + self.serialization_task = cx.background_spawn(async move { + PROJECT_DB + .save_trusted_worktrees(new_trusted_worktrees, new_trusted_workspaces) + .await + .log_err(); + }); + } + } + + if let Some((upstream_client, upstream_project_id)) = &self.upstream_client { + let trusted_paths = trusted_paths + .iter() + .map(|trusted_path| trusted_path.to_proto()) + .collect::>(); + if !trusted_paths.is_empty() { + upstream_client + .send(proto::TrustWorktrees { + project_id: *upstream_project_id, + trusted_paths, + }) + .ok(); + } + } + } + + /// Restricts certain entities on this host. + /// This will emit [`TrustedWorktreesEvent::Restricted`] event for all passed entries. + pub fn restrict( + &mut self, + restricted_paths: HashSet, + remote_host: Option, + cx: &mut Context, + ) { + for restricted_path in restricted_paths { + match restricted_path { + PathTrust::Workspace => { + self.restricted_workspaces.insert(remote_host.clone()); + cx.emit(TrustedWorktreesEvent::Restricted( + remote_host.clone(), + HashSet::from_iter([PathTrust::Workspace]), + )); + } + PathTrust::Worktree(worktree_id) => { + self.restricted.insert(worktree_id); + cx.emit(TrustedWorktreesEvent::Restricted( + remote_host.clone(), + HashSet::from_iter([PathTrust::Worktree(worktree_id)]), + )); + } + PathTrust::AbsPath(..) => debug_panic!("Unexpected: cannot restrict an abs path"), + } + } + } + + /// Erases all trust information. + /// Requires Zed's restart to take proper effect. + pub fn clear_trusted_paths(&mut self, cx: &App) -> Task<()> { + if self.downstream_client.is_none() { + self.trusted_paths.clear(); + + #[cfg(not(any(test, feature = "test-support")))] + { + let (tx, rx) = smol::channel::bounded(1); + self.serialization_task = cx.background_spawn(async move { + PROJECT_DB.clear_trusted_worktrees().await.log_err(); + tx.send(()).await.ok(); + }); + + return cx.background_spawn(async move { + rx.recv().await.ok(); + }); + } + + #[cfg(any(test, feature = "test-support"))] + { + let _ = cx; + Task::ready(()) + } + } else { + Task::ready(()) + } + } + + /// Checks whether a certain worktree is trusted (or on a larger trust level). + /// If not, emits [`TrustedWorktreesEvent::Restricted`] event if for the first time and not trusted, or no corresponding worktree store was found. + /// + /// No events or data adjustment happens when `trust_all_worktrees` auto trust is enabled. + pub fn can_trust(&mut self, worktree_id: WorktreeId, cx: &mut Context) -> bool { + if ProjectSettings::get_global(cx).session.trust_all_worktrees { + return true; + } + if self.restricted.contains(&worktree_id) { + return false; + } + + let Some((worktree_path, is_file, remote_host)) = self.find_worktree_data(worktree_id, cx) + else { + return false; + }; + + if self + .trusted_paths + .get(&remote_host) + .is_some_and(|trusted_paths| trusted_paths.contains(&PathTrust::Worktree(worktree_id))) + { + return true; + } + + // See module documentation for details on trust level. + if is_file && self.trusted_paths.contains_key(&remote_host) { + return true; + } + + let parent_path_trusted = + self.trusted_paths + .get(&remote_host) + .is_some_and(|trusted_paths| { + trusted_paths.iter().any(|trusted_path| { + let PathTrust::AbsPath(trusted_path) = trusted_path else { + return false; + }; + worktree_path.starts_with(trusted_path) + }) + }); + if parent_path_trusted { + return true; + } + + self.restricted.insert(worktree_id); + cx.emit(TrustedWorktreesEvent::Restricted( + remote_host, + HashSet::from_iter([PathTrust::Worktree(worktree_id)]), + )); + if let Some((downstream_client, downstream_project_id)) = &self.downstream_client { + downstream_client + .send(proto::RestrictWorktrees { + project_id: *downstream_project_id, + restrict_workspace: false, + worktree_ids: vec![worktree_id.to_proto()], + }) + .ok(); + } + if let Some((upstream_client, upstream_project_id)) = &self.upstream_client { + upstream_client + .send(proto::RestrictWorktrees { + project_id: *upstream_project_id, + restrict_workspace: false, + worktree_ids: vec![worktree_id.to_proto()], + }) + .ok(); + } + false + } + + /// Checks whether a certain worktree is trusted globally (or on a larger trust level). + /// If not, emits [`TrustedWorktreesEvent::Restricted`] event if checked for the first time and not trusted. + /// + /// No events or data adjustment happens when `trust_all_worktrees` auto trust is enabled. + pub fn can_trust_workspace( + &mut self, + remote_host: Option, + cx: &mut Context, + ) -> bool { + if ProjectSettings::get_global(cx).session.trust_all_worktrees { + return true; + } + if self.restricted_workspaces.contains(&remote_host) { + return false; + } + if self.trusted_paths.contains_key(&remote_host) { + return true; + } + + self.restricted_workspaces.insert(remote_host.clone()); + cx.emit(TrustedWorktreesEvent::Restricted( + remote_host.clone(), + HashSet::from_iter([PathTrust::Workspace]), + )); + + if remote_host == self.remote_host { + if let Some((downstream_client, downstream_project_id)) = &self.downstream_client { + downstream_client + .send(proto::RestrictWorktrees { + project_id: *downstream_project_id, + restrict_workspace: true, + worktree_ids: Vec::new(), + }) + .ok(); + } + if let Some((upstream_client, upstream_project_id)) = &self.upstream_client { + upstream_client + .send(proto::RestrictWorktrees { + project_id: *upstream_project_id, + restrict_workspace: true, + worktree_ids: Vec::new(), + }) + .ok(); + } + } + false + } + + /// Lists all explicitly restricted worktrees (via [`TrustedWorktreesStore::can_trust`] and [`TrustedWorktreesStore::can_trust_workspace`] method calls) for a particular worktree store on a particular host. + pub fn restricted_worktrees( + &self, + worktree_store: &WorktreeStore, + remote_host: Option, + cx: &App, + ) -> HashSet)>> { + let mut single_file_paths = HashSet::default(); + let other_paths = self + .restricted + .iter() + .filter_map(|&restricted_worktree_id| { + let worktree = worktree_store.worktree_for_id(restricted_worktree_id, cx)?; + let worktree = worktree.read(cx); + let abs_path = worktree.abs_path(); + if worktree.is_single_file() { + single_file_paths.insert(Some((restricted_worktree_id, abs_path))); + None + } else { + Some((restricted_worktree_id, abs_path)) + } + }) + .map(Some) + .collect::>(); + + if !other_paths.is_empty() { + return other_paths; + } else if self.restricted_workspaces.contains(&remote_host) { + return HashSet::from_iter([None]); + } else { + single_file_paths + } + } + + /// Switches the "trust nothing" mode to "automatically trust everything". + /// This does not influence already persisted data, but stops adding new worktrees there. + pub fn auto_trust_all(&mut self, cx: &mut Context) { + for (remote_host, mut worktrees) in std::mem::take(&mut self.restricted) + .into_iter() + .flat_map(|restricted_worktree| { + let (_, _, host) = self.find_worktree_data(restricted_worktree, cx)?; + Some((restricted_worktree, host)) + }) + .fold(HashMap::default(), |mut acc, (worktree_id, remote_host)| { + acc.entry(remote_host) + .or_insert_with(HashSet::default) + .insert(PathTrust::Worktree(worktree_id)); + acc + }) + { + if self.restricted_workspaces.remove(&remote_host) { + worktrees.insert(PathTrust::Workspace); + } + self.trust(worktrees, remote_host, cx); + } + + for remote_host in std::mem::take(&mut self.restricted_workspaces) { + self.trust(HashSet::from_iter([PathTrust::Workspace]), remote_host, cx); + } + } + + fn find_worktree_data( + &mut self, + worktree_id: WorktreeId, + cx: &mut Context, + ) -> Option<(Arc, bool, Option)> { + let mut worktree_data = None; + self.worktree_stores.retain( + |worktree_store, remote_host| match worktree_store.upgrade() { + Some(worktree_store) => { + if worktree_data.is_none() { + if let Some(worktree) = + worktree_store.read(cx).worktree_for_id(worktree_id, cx) + { + worktree_data = Some(( + worktree.read(cx).abs_path(), + worktree.read(cx).is_single_file(), + remote_host.clone(), + )); + } + } + true + } + None => false, + }, + ); + worktree_data + } + + fn add_worktree_store( + &mut self, + worktree_store: Entity, + remote_host: Option, + cx: &mut Context, + ) { + self.worktree_stores + .insert(worktree_store.downgrade(), remote_host.clone()); + + if let Some(trusted_paths) = self.trusted_paths.remove(&remote_host) { + self.trusted_paths.insert( + remote_host.clone(), + trusted_paths + .into_iter() + .map(|path_trust| match path_trust { + PathTrust::AbsPath(abs_path) => { + find_worktree_in_store(worktree_store.read(cx), &abs_path, cx) + .map(PathTrust::Worktree) + .unwrap_or_else(|| PathTrust::AbsPath(abs_path)) + } + other => other, + }) + .collect(), + ); + } + } +} + +pub(crate) fn find_worktree_in_store( + worktree_store: &WorktreeStore, + abs_path: &Path, + cx: &App, +) -> Option { + let (worktree, path_in_worktree) = worktree_store.find_worktree(&abs_path, cx)?; + if path_in_worktree.is_empty() { + Some(worktree.read(cx).id()) + } else { + None + } +} + +#[cfg(test)] +mod tests { + use std::{cell::RefCell, path::PathBuf, rc::Rc}; + + use collections::HashSet; + use gpui::TestAppContext; + use serde_json::json; + use settings::SettingsStore; + use util::path; + + use crate::{FakeFs, Project}; + + use super::*; + + fn init_test(cx: &mut TestAppContext) { + cx.update(|cx| { + if cx.try_global::().is_none() { + let settings_store = SettingsStore::test(cx); + cx.set_global(settings_store); + } + if cx.try_global::().is_some() { + cx.remove_global::(); + } + }); + } + + fn init_trust_global( + worktree_store: Entity, + cx: &mut TestAppContext, + ) -> Entity { + cx.update(|cx| { + track_worktree_trust(worktree_store, None, None, None, cx); + TrustedWorktrees::try_get_global(cx).expect("global should be set") + }) + } + + #[gpui::test] + async fn test_single_worktree_trust(cx: &mut TestAppContext) { + init_test(cx); + + let fs = FakeFs::new(cx.executor()); + fs.insert_tree(path!("/root"), json!({ "main.rs": "fn main() {}" })) + .await; + + let project = Project::test(fs, [path!("/root").as_ref()], cx).await; + let worktree_store = project.read_with(cx, |project, _| project.worktree_store()); + let worktree_id = worktree_store.read_with(cx, |store, cx| { + store.worktrees().next().unwrap().read(cx).id() + }); + + let trusted_worktrees = init_trust_global(worktree_store.clone(), cx); + + let events: Rc>> = Rc::default(); + cx.update({ + let events = events.clone(); + |cx| { + cx.subscribe(&trusted_worktrees, move |_, event, _| { + events.borrow_mut().push(match event { + TrustedWorktreesEvent::Trusted(host, paths) => { + TrustedWorktreesEvent::Trusted(host.clone(), paths.clone()) + } + TrustedWorktreesEvent::Restricted(host, paths) => { + TrustedWorktreesEvent::Restricted(host.clone(), paths.clone()) + } + }); + }) + } + }) + .detach(); + + let can_trust = trusted_worktrees.update(cx, |store, cx| store.can_trust(worktree_id, cx)); + assert!(!can_trust, "worktree should be restricted by default"); + + { + let events = events.borrow(); + assert_eq!(events.len(), 1); + match &events[0] { + TrustedWorktreesEvent::Restricted(host, paths) => { + assert!(host.is_none()); + assert!(paths.contains(&PathTrust::Worktree(worktree_id))); + } + _ => panic!("expected Restricted event"), + } + } + + let has_restricted = trusted_worktrees.read_with(cx, |store, cx| { + store.has_restricted_worktrees(&worktree_store, cx) + }); + assert!(has_restricted, "should have restricted worktrees"); + + let restricted = worktree_store.read_with(cx, |ws, cx| { + trusted_worktrees + .read(cx) + .restricted_worktrees(ws, None, cx) + }); + assert!( + restricted + .iter() + .any(|r| r.as_ref().map(|(id, _)| *id) == Some(worktree_id)) + ); + + events.borrow_mut().clear(); + + let can_trust_again = + trusted_worktrees.update(cx, |store, cx| store.can_trust(worktree_id, cx)); + assert!(!can_trust_again, "worktree should still be restricted"); + assert!( + events.borrow().is_empty(), + "no duplicate Restricted event on repeated can_trust" + ); + + trusted_worktrees.update(cx, |store, cx| { + store.trust( + HashSet::from_iter([PathTrust::Worktree(worktree_id)]), + None, + cx, + ); + }); + + { + let events = events.borrow(); + assert_eq!(events.len(), 1); + match &events[0] { + TrustedWorktreesEvent::Trusted(host, paths) => { + assert!(host.is_none()); + assert!(paths.contains(&PathTrust::Worktree(worktree_id))); + } + _ => panic!("expected Trusted event"), + } + } + + let can_trust_after = + trusted_worktrees.update(cx, |store, cx| store.can_trust(worktree_id, cx)); + assert!(can_trust_after, "worktree should be trusted after trust()"); + + let has_restricted_after = trusted_worktrees.read_with(cx, |store, cx| { + store.has_restricted_worktrees(&worktree_store, cx) + }); + assert!( + !has_restricted_after, + "should have no restricted worktrees after trust" + ); + + let restricted_after = worktree_store.read_with(cx, |ws, cx| { + trusted_worktrees + .read(cx) + .restricted_worktrees(ws, None, cx) + }); + assert!( + restricted_after.is_empty(), + "restricted set should be empty" + ); + } + + #[gpui::test] + async fn test_workspace_trust_no_worktrees(cx: &mut TestAppContext) { + init_test(cx); + + let fs = FakeFs::new(cx.executor()); + fs.insert_tree(path!("/root"), json!({})).await; + + let project = Project::test(fs, Vec::<&Path>::new(), cx).await; + let worktree_store = project.read_with(cx, |project, _| project.worktree_store()); + + let trusted_worktrees = init_trust_global(worktree_store, cx); + + let events: Rc>> = Rc::default(); + cx.update({ + let events = events.clone(); + |cx| { + cx.subscribe(&trusted_worktrees, move |_, event, _| { + events.borrow_mut().push(match event { + TrustedWorktreesEvent::Trusted(host, paths) => { + TrustedWorktreesEvent::Trusted(host.clone(), paths.clone()) + } + TrustedWorktreesEvent::Restricted(host, paths) => { + TrustedWorktreesEvent::Restricted(host.clone(), paths.clone()) + } + }); + }) + } + }) + .detach(); + + let can_trust_workspace = + trusted_worktrees.update(cx, |store, cx| store.can_trust_workspace(None, cx)); + assert!( + !can_trust_workspace, + "workspace should be restricted by default" + ); + + { + let events = events.borrow(); + assert_eq!(events.len(), 1); + match &events[0] { + TrustedWorktreesEvent::Restricted(host, paths) => { + assert!(host.is_none()); + assert!(paths.contains(&PathTrust::Workspace)); + } + _ => panic!("expected Restricted event"), + } + } + + events.borrow_mut().clear(); + + let can_trust_workspace_again = + trusted_worktrees.update(cx, |store, cx| store.can_trust_workspace(None, cx)); + assert!( + !can_trust_workspace_again, + "workspace should still be restricted" + ); + assert!( + events.borrow().is_empty(), + "no duplicate Restricted event on repeated can_trust_workspace" + ); + + trusted_worktrees.update(cx, |store, cx| { + store.trust(HashSet::from_iter([PathTrust::Workspace]), None, cx); + }); + + { + let events = events.borrow(); + assert_eq!(events.len(), 1); + match &events[0] { + TrustedWorktreesEvent::Trusted(host, paths) => { + assert!(host.is_none()); + assert!(paths.contains(&PathTrust::Workspace)); + } + _ => panic!("expected Trusted event"), + } + } + + let can_trust_workspace_after = + trusted_worktrees.update(cx, |store, cx| store.can_trust_workspace(None, cx)); + assert!( + can_trust_workspace_after, + "workspace should be trusted after trust()" + ); + } + + #[gpui::test] + async fn test_single_file_worktree_trust(cx: &mut TestAppContext) { + init_test(cx); + + let fs = FakeFs::new(cx.executor()); + fs.insert_tree(path!("/root"), json!({ "foo.rs": "fn foo() {}" })) + .await; + + let project = Project::test(fs, [path!("/root/foo.rs").as_ref()], cx).await; + let worktree_store = project.read_with(cx, |project, _| project.worktree_store()); + let worktree_id = worktree_store.read_with(cx, |store, cx| { + let worktree = store.worktrees().next().unwrap(); + let worktree = worktree.read(cx); + assert!(worktree.is_single_file(), "expected single-file worktree"); + worktree.id() + }); + + let trusted_worktrees = init_trust_global(worktree_store, cx); + + let events: Rc>> = Rc::default(); + cx.update({ + let events = events.clone(); + |cx| { + cx.subscribe(&trusted_worktrees, move |_, event, _| { + events.borrow_mut().push(match event { + TrustedWorktreesEvent::Trusted(host, paths) => { + TrustedWorktreesEvent::Trusted(host.clone(), paths.clone()) + } + TrustedWorktreesEvent::Restricted(host, paths) => { + TrustedWorktreesEvent::Restricted(host.clone(), paths.clone()) + } + }); + }) + } + }) + .detach(); + + let can_trust = trusted_worktrees.update(cx, |store, cx| store.can_trust(worktree_id, cx)); + assert!( + !can_trust, + "single-file worktree should be restricted by default" + ); + + { + let events = events.borrow(); + assert_eq!(events.len(), 1); + match &events[0] { + TrustedWorktreesEvent::Restricted(host, paths) => { + assert!(host.is_none()); + assert!(paths.contains(&PathTrust::Worktree(worktree_id))); + } + _ => panic!("expected Restricted event"), + } + } + + events.borrow_mut().clear(); + + trusted_worktrees.update(cx, |store, cx| { + store.trust( + HashSet::from_iter([PathTrust::Worktree(worktree_id)]), + None, + cx, + ); + }); + + { + let events = events.borrow(); + assert_eq!(events.len(), 1); + match &events[0] { + TrustedWorktreesEvent::Trusted(host, paths) => { + assert!(host.is_none()); + assert!(paths.contains(&PathTrust::Worktree(worktree_id))); + } + _ => panic!("expected Trusted event"), + } + } + + let can_trust_after = + trusted_worktrees.update(cx, |store, cx| store.can_trust(worktree_id, cx)); + assert!( + can_trust_after, + "single-file worktree should be trusted after trust()" + ); + } + + #[gpui::test] + async fn test_workspace_trust_unlocks_single_file_worktree(cx: &mut TestAppContext) { + init_test(cx); + + let fs = FakeFs::new(cx.executor()); + fs.insert_tree(path!("/root"), json!({ "foo.rs": "fn foo() {}" })) + .await; + + let project = Project::test(fs, [path!("/root/foo.rs").as_ref()], cx).await; + let worktree_store = project.read_with(cx, |project, _| project.worktree_store()); + let worktree_id = worktree_store.read_with(cx, |store, cx| { + let worktree = store.worktrees().next().unwrap(); + let worktree = worktree.read(cx); + assert!(worktree.is_single_file(), "expected single-file worktree"); + worktree.id() + }); + + let trusted_worktrees = init_trust_global(worktree_store, cx); + + let can_trust_workspace = + trusted_worktrees.update(cx, |store, cx| store.can_trust_workspace(None, cx)); + assert!( + !can_trust_workspace, + "workspace should be restricted by default" + ); + + let can_trust_file = + trusted_worktrees.update(cx, |store, cx| store.can_trust(worktree_id, cx)); + assert!( + !can_trust_file, + "single-file worktree should be restricted by default" + ); + + trusted_worktrees.update(cx, |store, cx| { + store.trust(HashSet::from_iter([PathTrust::Workspace]), None, cx); + }); + + let can_trust_workspace_after = + trusted_worktrees.update(cx, |store, cx| store.can_trust_workspace(None, cx)); + assert!( + can_trust_workspace_after, + "workspace should be trusted after trust(Workspace)" + ); + + let can_trust_file_after = + trusted_worktrees.update(cx, |store, cx| store.can_trust(worktree_id, cx)); + assert!( + can_trust_file_after, + "single-file worktree should be trusted after workspace trust" + ); + } + + #[gpui::test] + async fn test_multiple_single_file_worktrees_trust_one(cx: &mut TestAppContext) { + init_test(cx); + + let fs = FakeFs::new(cx.executor()); + fs.insert_tree( + path!("/root"), + json!({ + "a.rs": "fn a() {}", + "b.rs": "fn b() {}", + "c.rs": "fn c() {}" + }), + ) + .await; + + let project = Project::test( + fs, + [ + path!("/root/a.rs").as_ref(), + path!("/root/b.rs").as_ref(), + path!("/root/c.rs").as_ref(), + ], + cx, + ) + .await; + let worktree_store = project.read_with(cx, |project, _| project.worktree_store()); + let worktree_ids: Vec<_> = worktree_store.read_with(cx, |store, cx| { + store + .worktrees() + .map(|worktree| { + let worktree = worktree.read(cx); + assert!(worktree.is_single_file()); + worktree.id() + }) + .collect() + }); + assert_eq!(worktree_ids.len(), 3); + + let trusted_worktrees = init_trust_global(worktree_store, cx); + + for &worktree_id in &worktree_ids { + let can_trust = + trusted_worktrees.update(cx, |store, cx| store.can_trust(worktree_id, cx)); + assert!( + !can_trust, + "worktree {worktree_id:?} should be restricted initially" + ); + } + + trusted_worktrees.update(cx, |store, cx| { + store.trust( + HashSet::from_iter([PathTrust::Worktree(worktree_ids[1])]), + None, + cx, + ); + }); + + let can_trust_0 = + trusted_worktrees.update(cx, |store, cx| store.can_trust(worktree_ids[0], cx)); + let can_trust_1 = + trusted_worktrees.update(cx, |store, cx| store.can_trust(worktree_ids[1], cx)); + let can_trust_2 = + trusted_worktrees.update(cx, |store, cx| store.can_trust(worktree_ids[2], cx)); + + assert!(!can_trust_0, "worktree 0 should still be restricted"); + assert!(can_trust_1, "worktree 1 should be trusted"); + assert!(!can_trust_2, "worktree 2 should still be restricted"); + } + + #[gpui::test] + async fn test_two_directory_worktrees_separate_trust(cx: &mut TestAppContext) { + init_test(cx); + + let fs = FakeFs::new(cx.executor()); + fs.insert_tree( + path!("/projects"), + json!({ + "project_a": { "main.rs": "fn main() {}" }, + "project_b": { "lib.rs": "pub fn lib() {}" } + }), + ) + .await; + + let project = Project::test( + fs, + [ + path!("/projects/project_a").as_ref(), + path!("/projects/project_b").as_ref(), + ], + cx, + ) + .await; + let worktree_store = project.read_with(cx, |project, _| project.worktree_store()); + let worktree_ids: Vec<_> = worktree_store.read_with(cx, |store, cx| { + store + .worktrees() + .map(|worktree| { + let worktree = worktree.read(cx); + assert!(!worktree.is_single_file()); + worktree.id() + }) + .collect() + }); + assert_eq!(worktree_ids.len(), 2); + + let trusted_worktrees = init_trust_global(worktree_store, cx); + + let can_trust_a = + trusted_worktrees.update(cx, |store, cx| store.can_trust(worktree_ids[0], cx)); + let can_trust_b = + trusted_worktrees.update(cx, |store, cx| store.can_trust(worktree_ids[1], cx)); + assert!(!can_trust_a, "project_a should be restricted initially"); + assert!(!can_trust_b, "project_b should be restricted initially"); + + trusted_worktrees.update(cx, |store, cx| { + store.trust( + HashSet::from_iter([PathTrust::Worktree(worktree_ids[0])]), + None, + cx, + ); + }); + + let can_trust_a = + trusted_worktrees.update(cx, |store, cx| store.can_trust(worktree_ids[0], cx)); + let can_trust_b = + trusted_worktrees.update(cx, |store, cx| store.can_trust(worktree_ids[1], cx)); + assert!(can_trust_a, "project_a should be trusted after trust()"); + assert!(!can_trust_b, "project_b should still be restricted"); + + trusted_worktrees.update(cx, |store, cx| { + store.trust( + HashSet::from_iter([PathTrust::Worktree(worktree_ids[1])]), + None, + cx, + ); + }); + + let can_trust_a = + trusted_worktrees.update(cx, |store, cx| store.can_trust(worktree_ids[0], cx)); + let can_trust_b = + trusted_worktrees.update(cx, |store, cx| store.can_trust(worktree_ids[1], cx)); + assert!(can_trust_a, "project_a should remain trusted"); + assert!(can_trust_b, "project_b should now be trusted"); + } + + #[gpui::test] + async fn test_directory_worktree_trust_enables_workspace(cx: &mut TestAppContext) { + init_test(cx); + + let fs = FakeFs::new(cx.executor()); + fs.insert_tree(path!("/root"), json!({ "main.rs": "fn main() {}" })) + .await; + + let project = Project::test(fs, [path!("/root").as_ref()], cx).await; + let worktree_store = project.read_with(cx, |project, _| project.worktree_store()); + let worktree_id = worktree_store.read_with(cx, |store, cx| { + let worktree = store.worktrees().next().unwrap(); + assert!(!worktree.read(cx).is_single_file()); + worktree.read(cx).id() + }); + + let trusted_worktrees = init_trust_global(worktree_store, cx); + + let can_trust_workspace = + trusted_worktrees.update(cx, |store, cx| store.can_trust_workspace(None, cx)); + assert!( + !can_trust_workspace, + "workspace should be restricted initially" + ); + + trusted_worktrees.update(cx, |store, cx| { + store.trust( + HashSet::from_iter([PathTrust::Worktree(worktree_id)]), + None, + cx, + ); + }); + + let can_trust_workspace_after = + trusted_worktrees.update(cx, |store, cx| store.can_trust_workspace(None, cx)); + assert!( + can_trust_workspace_after, + "workspace should be trusted after trusting directory worktree" + ); + } + + #[gpui::test] + async fn test_directory_worktree_trust_enables_single_file(cx: &mut TestAppContext) { + init_test(cx); + + let fs = FakeFs::new(cx.executor()); + fs.insert_tree( + path!("/"), + json!({ + "project": { "main.rs": "fn main() {}" }, + "standalone.rs": "fn standalone() {}" + }), + ) + .await; + + let project = Project::test( + fs, + [path!("/project").as_ref(), path!("/standalone.rs").as_ref()], + cx, + ) + .await; + let worktree_store = project.read_with(cx, |project, _| project.worktree_store()); + let (dir_worktree_id, file_worktree_id) = worktree_store.read_with(cx, |store, cx| { + let worktrees: Vec<_> = store.worktrees().collect(); + assert_eq!(worktrees.len(), 2); + let (dir_worktree, file_worktree) = if worktrees[0].read(cx).is_single_file() { + (&worktrees[1], &worktrees[0]) + } else { + (&worktrees[0], &worktrees[1]) + }; + assert!(!dir_worktree.read(cx).is_single_file()); + assert!(file_worktree.read(cx).is_single_file()); + (dir_worktree.read(cx).id(), file_worktree.read(cx).id()) + }); + + let trusted_worktrees = init_trust_global(worktree_store, cx); + + let can_trust_file = + trusted_worktrees.update(cx, |store, cx| store.can_trust(file_worktree_id, cx)); + assert!( + !can_trust_file, + "single-file worktree should be restricted initially" + ); + + trusted_worktrees.update(cx, |store, cx| { + store.trust( + HashSet::from_iter([PathTrust::Worktree(dir_worktree_id)]), + None, + cx, + ); + }); + + let can_trust_dir = + trusted_worktrees.update(cx, |store, cx| store.can_trust(dir_worktree_id, cx)); + let can_trust_file_after = + trusted_worktrees.update(cx, |store, cx| store.can_trust(file_worktree_id, cx)); + assert!(can_trust_dir, "directory worktree should be trusted"); + assert!( + can_trust_file_after, + "single-file worktree should be trusted after directory worktree trust" + ); + } + + #[gpui::test] + async fn test_abs_path_trust_covers_multiple_worktrees(cx: &mut TestAppContext) { + init_test(cx); + + let fs = FakeFs::new(cx.executor()); + fs.insert_tree( + path!("/workspace"), + json!({ + "project_a": { "main.rs": "fn main() {}" }, + "project_b": { "lib.rs": "pub fn lib() {}" } + }), + ) + .await; + + let project = Project::test( + fs, + [ + path!("/workspace/project_a").as_ref(), + path!("/workspace/project_b").as_ref(), + ], + cx, + ) + .await; + let worktree_store = project.read_with(cx, |project, _| project.worktree_store()); + let worktree_ids: Vec<_> = worktree_store.read_with(cx, |store, cx| { + store + .worktrees() + .map(|worktree| worktree.read(cx).id()) + .collect() + }); + assert_eq!(worktree_ids.len(), 2); + + let trusted_worktrees = init_trust_global(worktree_store, cx); + + for &worktree_id in &worktree_ids { + let can_trust = + trusted_worktrees.update(cx, |store, cx| store.can_trust(worktree_id, cx)); + assert!(!can_trust, "worktree should be restricted initially"); + } + + trusted_worktrees.update(cx, |store, cx| { + store.trust( + HashSet::from_iter([PathTrust::AbsPath(PathBuf::from(path!("/workspace")))]), + None, + cx, + ); + }); + + for &worktree_id in &worktree_ids { + let can_trust = + trusted_worktrees.update(cx, |store, cx| store.can_trust(worktree_id, cx)); + assert!( + can_trust, + "worktree should be trusted after parent path trust" + ); + } + } + + #[gpui::test] + async fn test_auto_trust_all(cx: &mut TestAppContext) { + init_test(cx); + + let fs = FakeFs::new(cx.executor()); + fs.insert_tree( + path!("/"), + json!({ + "project_a": { "main.rs": "fn main() {}" }, + "project_b": { "lib.rs": "pub fn lib() {}" }, + "single.rs": "fn single() {}" + }), + ) + .await; + + let project = Project::test( + fs, + [ + path!("/project_a").as_ref(), + path!("/project_b").as_ref(), + path!("/single.rs").as_ref(), + ], + cx, + ) + .await; + let worktree_store = project.read_with(cx, |project, _| project.worktree_store()); + let worktree_ids: Vec<_> = worktree_store.read_with(cx, |store, cx| { + store + .worktrees() + .map(|worktree| worktree.read(cx).id()) + .collect() + }); + assert_eq!(worktree_ids.len(), 3); + + let trusted_worktrees = init_trust_global(worktree_store.clone(), cx); + + let events: Rc>> = Rc::default(); + cx.update({ + let events = events.clone(); + |cx| { + cx.subscribe(&trusted_worktrees, move |_, event, _| { + events.borrow_mut().push(match event { + TrustedWorktreesEvent::Trusted(host, paths) => { + TrustedWorktreesEvent::Trusted(host.clone(), paths.clone()) + } + TrustedWorktreesEvent::Restricted(host, paths) => { + TrustedWorktreesEvent::Restricted(host.clone(), paths.clone()) + } + }); + }) + } + }) + .detach(); + + for &worktree_id in &worktree_ids { + let can_trust = + trusted_worktrees.update(cx, |store, cx| store.can_trust(worktree_id, cx)); + assert!(!can_trust, "worktree should be restricted initially"); + } + let can_trust_workspace = + trusted_worktrees.update(cx, |store, cx| store.can_trust_workspace(None, cx)); + assert!( + !can_trust_workspace, + "workspace should be restricted initially" + ); + + let has_restricted = trusted_worktrees.read_with(cx, |store, cx| { + store.has_restricted_worktrees(&worktree_store, cx) + }); + assert!(has_restricted, "should have restricted worktrees"); + + events.borrow_mut().clear(); + + trusted_worktrees.update(cx, |store, cx| { + store.auto_trust_all(cx); + }); + + for &worktree_id in &worktree_ids { + let can_trust = + trusted_worktrees.update(cx, |store, cx| store.can_trust(worktree_id, cx)); + assert!( + can_trust, + "worktree {worktree_id:?} should be trusted after auto_trust_all" + ); + } + + let can_trust_workspace = + trusted_worktrees.update(cx, |store, cx| store.can_trust_workspace(None, cx)); + assert!( + can_trust_workspace, + "workspace should be trusted after auto_trust_all" + ); + + let has_restricted_after = trusted_worktrees.read_with(cx, |store, cx| { + store.has_restricted_worktrees(&worktree_store, cx) + }); + assert!( + !has_restricted_after, + "should have no restricted worktrees after auto_trust_all" + ); + + let trusted_event_count = events + .borrow() + .iter() + .filter(|e| matches!(e, TrustedWorktreesEvent::Trusted(..))) + .count(); + assert!( + trusted_event_count > 0, + "should have emitted Trusted events" + ); + } + + #[gpui::test] + async fn test_wait_for_global_trust_already_trusted(cx: &mut TestAppContext) { + init_test(cx); + + let fs = FakeFs::new(cx.executor()); + fs.insert_tree(path!("/root"), json!({ "main.rs": "fn main() {}" })) + .await; + + let project = Project::test(fs, [path!("/root").as_ref()], cx).await; + let worktree_store = project.read_with(cx, |project, _| project.worktree_store()); + + let trusted_worktrees = init_trust_global(worktree_store, cx); + + trusted_worktrees.update(cx, |store, cx| { + store.trust(HashSet::from_iter([PathTrust::Workspace]), None, cx); + }); + + let task = cx.update(|cx| wait_for_workspace_trust(None::, "test", cx)); + assert!(task.is_none(), "should return None when already trusted"); + } + + #[gpui::test] + async fn test_wait_for_workspace_trust_resolves_on_trust(cx: &mut TestAppContext) { + init_test(cx); + + let fs = FakeFs::new(cx.executor()); + fs.insert_tree(path!("/root"), json!({ "main.rs": "fn main() {}" })) + .await; + + let project = Project::test(fs, [path!("/root").as_ref()], cx).await; + let worktree_store = project.read_with(cx, |project, _| project.worktree_store()); + + let trusted_worktrees = init_trust_global(worktree_store, cx); + + let task = cx.update(|cx| wait_for_workspace_trust(None::, "test", cx)); + assert!( + task.is_some(), + "should return Some(Task) when not yet trusted" + ); + + let task = task.unwrap(); + + cx.executor().run_until_parked(); + + trusted_worktrees.update(cx, |store, cx| { + store.trust(HashSet::from_iter([PathTrust::Workspace]), None, cx); + }); + + cx.executor().run_until_parked(); + task.await; + } + + #[gpui::test] + async fn test_wait_for_default_workspace_trust_resolves_on_directory_worktree_trust( + cx: &mut TestAppContext, + ) { + init_test(cx); + + let fs = FakeFs::new(cx.executor()); + fs.insert_tree(path!("/root"), json!({ "main.rs": "fn main() {}" })) + .await; + + let project = Project::test(fs, [path!("/root").as_ref()], cx).await; + let worktree_store = project.read_with(cx, |project, _| project.worktree_store()); + let worktree_id = worktree_store.read_with(cx, |store, cx| { + let worktree = store.worktrees().next().unwrap(); + assert!(!worktree.read(cx).is_single_file()); + worktree.read(cx).id() + }); + + let trusted_worktrees = init_trust_global(worktree_store, cx); + + let task = cx.update(|cx| wait_for_default_workspace_trust("test", cx)); + assert!( + task.is_some(), + "should return Some(Task) when not yet trusted" + ); + + let task = task.unwrap(); + + cx.executor().run_until_parked(); + + trusted_worktrees.update(cx, |store, cx| { + store.trust( + HashSet::from_iter([PathTrust::Worktree(worktree_id)]), + None, + cx, + ); + }); + + cx.executor().run_until_parked(); + task.await; + } + + #[gpui::test] + async fn test_trust_restrict_trust_cycle(cx: &mut TestAppContext) { + init_test(cx); + + let fs = FakeFs::new(cx.executor()); + fs.insert_tree(path!("/root"), json!({ "main.rs": "fn main() {}" })) + .await; + + let project = Project::test(fs, [path!("/root").as_ref()], cx).await; + let worktree_store = project.read_with(cx, |project, _| project.worktree_store()); + let worktree_id = worktree_store.read_with(cx, |store, cx| { + store.worktrees().next().unwrap().read(cx).id() + }); + + let trusted_worktrees = init_trust_global(worktree_store.clone(), cx); + + let events: Rc>> = Rc::default(); + cx.update({ + let events = events.clone(); + |cx| { + cx.subscribe(&trusted_worktrees, move |_, event, _| { + events.borrow_mut().push(match event { + TrustedWorktreesEvent::Trusted(host, paths) => { + TrustedWorktreesEvent::Trusted(host.clone(), paths.clone()) + } + TrustedWorktreesEvent::Restricted(host, paths) => { + TrustedWorktreesEvent::Restricted(host.clone(), paths.clone()) + } + }); + }) + } + }) + .detach(); + + let can_trust = trusted_worktrees.update(cx, |store, cx| store.can_trust(worktree_id, cx)); + assert!(!can_trust, "should be restricted initially"); + assert_eq!(events.borrow().len(), 1); + events.borrow_mut().clear(); + + trusted_worktrees.update(cx, |store, cx| { + store.trust( + HashSet::from_iter([PathTrust::Worktree(worktree_id)]), + None, + cx, + ); + }); + let can_trust = trusted_worktrees.update(cx, |store, cx| store.can_trust(worktree_id, cx)); + assert!(can_trust, "should be trusted after trust()"); + assert_eq!(events.borrow().len(), 1); + assert!(matches!( + &events.borrow()[0], + TrustedWorktreesEvent::Trusted(..) + )); + events.borrow_mut().clear(); + + trusted_worktrees.update(cx, |store, cx| { + store.restrict( + HashSet::from_iter([PathTrust::Worktree(worktree_id)]), + None, + cx, + ); + }); + let can_trust = trusted_worktrees.update(cx, |store, cx| store.can_trust(worktree_id, cx)); + assert!(!can_trust, "should be restricted after restrict()"); + assert_eq!(events.borrow().len(), 1); + assert!(matches!( + &events.borrow()[0], + TrustedWorktreesEvent::Restricted(..) + )); + + let has_restricted = trusted_worktrees.read_with(cx, |store, cx| { + store.has_restricted_worktrees(&worktree_store, cx) + }); + assert!(has_restricted); + events.borrow_mut().clear(); + + trusted_worktrees.update(cx, |store, cx| { + store.trust( + HashSet::from_iter([PathTrust::Worktree(worktree_id)]), + None, + cx, + ); + }); + let can_trust = trusted_worktrees.update(cx, |store, cx| store.can_trust(worktree_id, cx)); + assert!(can_trust, "should be trusted again after second trust()"); + assert_eq!(events.borrow().len(), 1); + assert!(matches!( + &events.borrow()[0], + TrustedWorktreesEvent::Trusted(..) + )); + + let has_restricted = trusted_worktrees.read_with(cx, |store, cx| { + store.has_restricted_worktrees(&worktree_store, cx) + }); + assert!(!has_restricted); + } + + #[gpui::test] + async fn test_multi_host_trust_isolation(cx: &mut TestAppContext) { + init_test(cx); + + let fs = FakeFs::new(cx.executor()); + fs.insert_tree( + path!("/"), + json!({ + "local_project": { "main.rs": "fn main() {}" }, + "remote_project": { "lib.rs": "pub fn lib() {}" } + }), + ) + .await; + + let project = Project::test( + fs, + [ + path!("/local_project").as_ref(), + path!("/remote_project").as_ref(), + ], + cx, + ) + .await; + let worktree_store = project.read_with(cx, |project, _| project.worktree_store()); + let worktree_ids: Vec<_> = worktree_store.read_with(cx, |store, cx| { + store + .worktrees() + .map(|worktree| worktree.read(cx).id()) + .collect() + }); + assert_eq!(worktree_ids.len(), 2); + let local_worktree = worktree_ids[0]; + let _remote_worktree = worktree_ids[1]; + + let trusted_worktrees = init_trust_global(worktree_store, cx); + + let host_a: Option = None; + let host_b = Some(RemoteHostLocation { + user_name: Some("user".into()), + host_identifier: "remote-host".into(), + }); + + let can_trust_local = + trusted_worktrees.update(cx, |store, cx| store.can_trust(local_worktree, cx)); + assert!(!can_trust_local, "local worktree restricted on host_a"); + + trusted_worktrees.update(cx, |store, cx| { + store.trust( + HashSet::from_iter([PathTrust::Workspace]), + host_b.clone(), + cx, + ); + }); + + let can_trust_workspace_a = trusted_worktrees.update(cx, |store, cx| { + store.can_trust_workspace(host_a.clone(), cx) + }); + assert!( + !can_trust_workspace_a, + "host_a workspace should still be restricted" + ); + + let can_trust_workspace_b = trusted_worktrees.update(cx, |store, cx| { + store.can_trust_workspace(host_b.clone(), cx) + }); + assert!(can_trust_workspace_b, "host_b workspace should be trusted"); + + trusted_worktrees.update(cx, |store, cx| { + store.trust( + HashSet::from_iter([PathTrust::Worktree(local_worktree)]), + host_a.clone(), + cx, + ); + }); + + let can_trust_local_after = + trusted_worktrees.update(cx, |store, cx| store.can_trust(local_worktree, cx)); + assert!( + can_trust_local_after, + "local worktree should be trusted on host_a" + ); + + let can_trust_workspace_a_after = trusted_worktrees.update(cx, |store, cx| { + store.can_trust_workspace(host_a.clone(), cx) + }); + assert!( + can_trust_workspace_a_after, + "host_a workspace should be trusted after directory trust" + ); + } +} diff --git a/crates/project_benchmarks/src/main.rs b/crates/project_benchmarks/src/main.rs index 738d0d0f2240f566f77f98a07df4a9ac587e10b4..03c25bc464af06793e351f27588b023ec8eb3eb9 100644 --- a/crates/project_benchmarks/src/main.rs +++ b/crates/project_benchmarks/src/main.rs @@ -62,7 +62,7 @@ fn main() -> Result<(), anyhow::Error> { let client = Client::production(cx); let http_client = FakeHttpClient::with_200_response(); let (_, rx) = watch::channel(None); - let node = NodeRuntime::new(http_client, None, rx); + let node = NodeRuntime::new(http_client, None, rx, None); let user_store = cx.new(|cx| UserStore::new(client.clone(), cx)); let registry = Arc::new(LanguageRegistry::new(cx.background_executor().clone())); let fs = Arc::new(RealFs::new(None, cx.background_executor().clone())); @@ -73,6 +73,7 @@ fn main() -> Result<(), anyhow::Error> { registry, fs, Some(Default::default()), + false, cx, ); diff --git a/crates/proto/proto/worktree.proto b/crates/proto/proto/worktree.proto index 9ab9e95438d220834351308ea83ffe9a18dec999..315aeb311e1e4284970dffa17bee4b0142373e92 100644 --- a/crates/proto/proto/worktree.proto +++ b/crates/proto/proto/worktree.proto @@ -158,3 +158,22 @@ message UpdateUserSettings { uint64 project_id = 1; string contents = 2; } + +message TrustWorktrees { + uint64 project_id = 1; + repeated PathTrust trusted_paths = 2; +} + +message PathTrust { + oneof content { + uint64 workspace = 1; + uint64 worktree_id = 2; + string abs_path = 3; + } +} + +message RestrictWorktrees { + uint64 project_id = 1; + bool restrict_workspace = 2; + repeated uint64 worktree_ids = 3; +} diff --git a/crates/proto/proto/zed.proto b/crates/proto/proto/zed.proto index 8e26a26a43ff8af5c1b676f5dc7f8fe49e67e19f..b781a06155698505eaeb0a1d19eaaba3e7d3c08d 100644 --- a/crates/proto/proto/zed.proto +++ b/crates/proto/proto/zed.proto @@ -448,7 +448,10 @@ message Envelope { ExternalExtensionAgentsUpdated external_extension_agents_updated = 401; GitCreateRemote git_create_remote = 402; - GitRemoveRemote git_remove_remote = 403;// current max + GitRemoveRemote git_remove_remote = 403; + + TrustWorktrees trust_worktrees = 404; + RestrictWorktrees restrict_worktrees = 405; // current max } reserved 87 to 88, 396; diff --git a/crates/proto/src/proto.rs b/crates/proto/src/proto.rs index 455f94704663dcd96e37487b1a4243850634c18e..840118b0c9d17e3c1889b8138ae70a639930f28e 100644 --- a/crates/proto/src/proto.rs +++ b/crates/proto/src/proto.rs @@ -310,6 +310,8 @@ messages!( (GitCreateBranch, Background), (GitChangeBranch, Background), (GitRenameBranch, Background), + (TrustWorktrees, Background), + (RestrictWorktrees, Background), (CheckForPushedCommits, Background), (CheckForPushedCommitsResponse, Background), (GitDiff, Background), @@ -529,7 +531,9 @@ request_messages!( (GetAgentServerCommand, AgentServerCommand), (RemoteStarted, Ack), (GitGetWorktrees, GitWorktreesResponse), - (GitCreateWorktree, Ack) + (GitCreateWorktree, Ack), + (TrustWorktrees, Ack), + (RestrictWorktrees, Ack), ); lsp_messages!( @@ -702,7 +706,9 @@ entity_messages!( ExternalAgentLoadingStatusUpdated, NewExternalAgentVersionAvailable, GitGetWorktrees, - GitCreateWorktree + GitCreateWorktree, + TrustWorktrees, + RestrictWorktrees, ); entity_messages!( diff --git a/crates/recent_projects/src/remote_connections.rs b/crates/recent_projects/src/remote_connections.rs index c0a655d19e513c838275d3e4f3beadaabcc8fef6..be40df4d1c80c3a1dda7c3f8fdfa370bc231bbfb 100644 --- a/crates/recent_projects/src/remote_connections.rs +++ b/crates/recent_projects/src/remote_connections.rs @@ -16,6 +16,7 @@ use gpui::{ use language::{CursorShape, Point}; use markdown::{Markdown, MarkdownElement, MarkdownStyle}; +use project::trusted_worktrees; use release_channel::ReleaseChannel; use remote::{ ConnectionIdentifier, DockerConnectionOptions, RemoteClient, RemoteConnection, @@ -646,6 +647,7 @@ pub async fn open_remote_project( app_state.languages.clone(), app_state.fs.clone(), None, + false, cx, ); cx.new(|cx| { @@ -788,11 +790,20 @@ pub async fn open_remote_project( continue; } - if created_new_window { - window - .update(cx, |_, window, _| window.remove_window()) - .ok(); - } + window + .update(cx, |workspace, window, cx| { + if created_new_window { + window.remove_window(); + } + trusted_worktrees::track_worktree_trust( + workspace.project().read(cx).worktree_store(), + None, + None, + None, + cx, + ); + }) + .ok(); } Ok(items) => { diff --git a/crates/recent_projects/src/remote_servers.rs b/crates/recent_projects/src/remote_servers.rs index c960a2b1a9af9e11730240c24483a673b77e0fb5..84cc216805897d81ee8d7cbba3b0f6d8a66cbdf9 100644 --- a/crates/recent_projects/src/remote_servers.rs +++ b/crates/recent_projects/src/remote_servers.rs @@ -1000,6 +1000,7 @@ impl RemoteServerProjects { app_state.user_store.clone(), app_state.languages.clone(), app_state.fs.clone(), + true, cx, ), ) diff --git a/crates/remote_server/Cargo.toml b/crates/remote_server/Cargo.toml index 114dc777c1d518fc2bcbc6aaff5a4b9aa7b68a1d..ce4af656a60267cde5453f27cad129109ff660f1 100644 --- a/crates/remote_server/Cargo.toml +++ b/crates/remote_server/Cargo.toml @@ -26,6 +26,7 @@ anyhow.workspace = true askpass.workspace = true clap.workspace = true client.workspace = true +collections.workspace = true dap_adapters.workspace = true debug_adapter_extension.workspace = true env_logger.workspace = true @@ -81,7 +82,6 @@ action_log.workspace = true agent = { workspace = true, features = ["test-support"] } client = { workspace = true, features = ["test-support"] } clock = { workspace = true, features = ["test-support"] } -collections.workspace = true dap = { workspace = true, features = ["test-support"] } editor = { workspace = true, features = ["test-support"] } workspace = { workspace = true, features = ["test-support"] } diff --git a/crates/remote_server/src/headless_project.rs b/crates/remote_server/src/headless_project.rs index 361e74579cc157e6e40a968a29ef4e6eed026335..89d26d35c77e076e1e618669acb5e54dc8afdcca 100644 --- a/crates/remote_server/src/headless_project.rs +++ b/crates/remote_server/src/headless_project.rs @@ -1,4 +1,5 @@ use anyhow::{Context as _, Result, anyhow}; +use collections::HashSet; use language::File; use lsp::LanguageServerId; @@ -21,6 +22,7 @@ use project::{ project_settings::SettingsObserver, search::SearchQuery, task_store::TaskStore, + trusted_worktrees::{PathTrust, RemoteHostLocation, TrustedWorktrees}, worktree_store::WorktreeStore, }; use rpc::{ @@ -86,6 +88,7 @@ impl HeadlessProject { languages, extension_host_proxy: proxy, }: HeadlessAppState, + init_worktree_trust: bool, cx: &mut Context, ) -> Self { debug_adapter_extension::init(proxy.clone(), cx); @@ -97,6 +100,16 @@ impl HeadlessProject { store }); + if init_worktree_trust { + project::trusted_worktrees::track_worktree_trust( + worktree_store.clone(), + None::, + Some((session.clone(), REMOTE_SERVER_PROJECT_ID)), + None, + cx, + ); + } + let environment = cx.new(|cx| ProjectEnvironment::new(None, worktree_store.downgrade(), None, true, cx)); let manifest_tree = ManifestTree::new(worktree_store.clone(), cx); @@ -264,6 +277,8 @@ impl HeadlessProject { session.add_entity_request_handler(Self::handle_get_directory_environment); session.add_entity_message_handler(Self::handle_toggle_lsp_logs); session.add_entity_request_handler(Self::handle_open_image_by_path); + session.add_entity_request_handler(Self::handle_trust_worktrees); + session.add_entity_request_handler(Self::handle_restrict_worktrees); session.add_entity_request_handler(BufferStore::handle_update_buffer); session.add_entity_message_handler(BufferStore::handle_close_buffer); @@ -595,6 +610,53 @@ impl HeadlessProject { }) } + pub async fn handle_trust_worktrees( + _: Entity, + envelope: TypedEnvelope, + mut cx: AsyncApp, + ) -> Result { + let trusted_worktrees = cx + .update(|cx| TrustedWorktrees::try_get_global(cx))? + .context("missing trusted worktrees")?; + trusted_worktrees.update(&mut cx, |trusted_worktrees, cx| { + trusted_worktrees.trust( + envelope + .payload + .trusted_paths + .into_iter() + .filter_map(PathTrust::from_proto) + .collect(), + None, + cx, + ); + })?; + Ok(proto::Ack {}) + } + + pub async fn handle_restrict_worktrees( + _: Entity, + envelope: TypedEnvelope, + mut cx: AsyncApp, + ) -> Result { + let trusted_worktrees = cx + .update(|cx| TrustedWorktrees::try_get_global(cx))? + .context("missing trusted worktrees")?; + trusted_worktrees.update(&mut cx, |trusted_worktrees, cx| { + let mut restricted_paths = envelope + .payload + .worktree_ids + .into_iter() + .map(WorktreeId::from_proto) + .map(PathTrust::Worktree) + .collect::>(); + if envelope.payload.restrict_workspace { + restricted_paths.insert(PathTrust::Workspace); + } + trusted_worktrees.restrict(restricted_paths, None, cx); + })?; + Ok(proto::Ack {}) + } + pub async fn handle_open_new_buffer( this: Entity, _message: TypedEnvelope, diff --git a/crates/remote_server/src/remote_editing_tests.rs b/crates/remote_server/src/remote_editing_tests.rs index a91d1d055d582eb2f2de4883314ad5984238103a..a7a870b0513694abe8b126fd0badea05534749ea 100644 --- a/crates/remote_server/src/remote_editing_tests.rs +++ b/crates/remote_server/src/remote_editing_tests.rs @@ -1933,6 +1933,7 @@ pub async fn init_test( languages, extension_host_proxy: proxy, }, + false, cx, ) }); @@ -1977,5 +1978,5 @@ fn build_project(ssh: Entity, cx: &mut TestAppContext) -> Entity

>); let node_runtime = NodeRuntime::new( http_client.clone(), Some(shell_env_loaded_rx), node_settings_rx, + trust_task, ); let mut languages = LanguageRegistry::new(cx.background_executor().clone()); @@ -468,6 +474,7 @@ pub fn execute_run( languages, extension_host_proxy, }, + true, cx, ) }); diff --git a/crates/settings/src/settings_content/project.rs b/crates/settings/src/settings_content/project.rs index 5cd708694d0cfd3699fdc822509d0209f9a96fd1..a5e15153832c425134e129cba1984b3b5886aa56 100644 --- a/crates/settings/src/settings_content/project.rs +++ b/crates/settings/src/settings_content/project.rs @@ -187,6 +187,12 @@ pub struct SessionSettingsContent { /// /// Default: true pub restore_unsaved_buffers: Option, + /// Whether or not to skip worktree trust checks. + /// When trusted, project settings are synchronized automatically, + /// language and MCP servers are downloaded and started automatically. + /// + /// Default: false + pub trust_all_worktrees: Option, } #[derive(Deserialize, Serialize, Clone, PartialEq, Eq, JsonSchema, MergeFrom, Debug)] diff --git a/crates/settings_ui/src/page_data.rs b/crates/settings_ui/src/page_data.rs index 007c41ad59b4e875770beecb089bd4e7fb2078b5..1d0603de3184ad9da874b428a94af37d8966e6a2 100644 --- a/crates/settings_ui/src/page_data.rs +++ b/crates/settings_ui/src/page_data.rs @@ -138,6 +138,28 @@ pub(crate) fn settings_data(cx: &App) -> Vec { metadata: None, files: USER, }), + SettingsPageItem::SectionHeader("Security"), + SettingsPageItem::SettingItem(SettingItem { + title: "Trust All Projects By Default", + description: "When opening Zed, avoid Restricted Mode by auto-trusting all projects, enabling use of all features without having to give permission to each new project.", + field: Box::new(SettingField { + json_path: Some("session.trust_all_projects"), + pick: |settings_content| { + settings_content + .session + .as_ref() + .and_then(|session| session.trust_all_worktrees.as_ref()) + }, + write: |settings_content, value| { + settings_content + .session + .get_or_insert_default() + .trust_all_worktrees = value; + }, + }), + metadata: None, + files: USER, + }), SettingsPageItem::SectionHeader("Workspace Restoration"), SettingsPageItem::SettingItem(SettingItem { title: "Restore Unsaved Buffers", diff --git a/crates/title_bar/src/title_bar.rs b/crates/title_bar/src/title_bar.rs index 4d7397a0bc82142245b86c11ffdf441a6b781ad8..608fea7383176460cb4b7519824cd2dc118dbb69 100644 --- a/crates/title_bar/src/title_bar.rs +++ b/crates/title_bar/src/title_bar.rs @@ -30,18 +30,20 @@ use gpui::{ Subscription, WeakEntity, Window, actions, div, }; use onboarding_banner::OnboardingBanner; -use project::{Project, WorktreeSettings, git_store::GitStoreEvent}; +use project::{ + Project, WorktreeSettings, git_store::GitStoreEvent, trusted_worktrees::TrustedWorktrees, +}; use remote::RemoteConnectionOptions; use settings::{Settings, SettingsLocation}; use std::sync::Arc; use theme::ActiveTheme; use title_bar_settings::TitleBarSettings; use ui::{ - Avatar, Button, ButtonLike, ButtonStyle, Chip, ContextMenu, Icon, IconName, IconSize, - IconWithIndicator, Indicator, PopoverMenu, PopoverMenuHandle, Tooltip, h_flex, prelude::*, + Avatar, ButtonLike, Chip, ContextMenu, IconWithIndicator, Indicator, PopoverMenu, + PopoverMenuHandle, TintColor, Tooltip, prelude::*, }; use util::{ResultExt, rel_path::RelPath}; -use workspace::{Workspace, notifications::NotifyResultExt}; +use workspace::{ToggleWorktreeSecurity, Workspace, notifications::NotifyResultExt}; use zed_actions::{OpenRecent, OpenRemote}; pub use onboarding_banner::restore_banner; @@ -163,6 +165,7 @@ impl Render for TitleBar { title_bar .when(title_bar_settings.show_project_items, |title_bar| { title_bar + .children(self.render_restricted_mode(cx)) .children(self.render_project_host(cx)) .child(self.render_project_name(cx)) }) @@ -291,7 +294,12 @@ impl TitleBar { _ => {} }), ); - subscriptions.push(cx.observe(&user_store, |_, _, cx| cx.notify())); + subscriptions.push(cx.observe(&user_store, |_a, _, cx| cx.notify())); + if let Some(trusted_worktrees) = TrustedWorktrees::try_get_global(cx) { + subscriptions.push(cx.subscribe(&trusted_worktrees, |_, _, _, cx| { + cx.notify(); + })); + } let banner = cx.new(|cx| { OnboardingBanner::new( @@ -317,7 +325,7 @@ impl TitleBar { client, _subscriptions: subscriptions, banner, - screen_share_popover_handle: Default::default(), + screen_share_popover_handle: PopoverMenuHandle::default(), } } @@ -427,6 +435,48 @@ impl TitleBar { ) } + pub fn render_restricted_mode(&self, cx: &mut Context) -> Option { + let has_restricted_worktrees = TrustedWorktrees::try_get_global(cx) + .map(|trusted_worktrees| { + trusted_worktrees + .read(cx) + .has_restricted_worktrees(&self.project.read(cx).worktree_store(), cx) + }) + .unwrap_or(false); + if !has_restricted_worktrees { + return None; + } + + Some( + Button::new("restricted_mode_trigger", "Restricted Mode") + .style(ButtonStyle::Tinted(TintColor::Warning)) + .label_size(LabelSize::Small) + .color(Color::Warning) + .icon(IconName::Warning) + .icon_color(Color::Warning) + .icon_size(IconSize::Small) + .icon_position(IconPosition::Start) + .tooltip(|_, cx| { + Tooltip::with_meta( + "You're in Restricted Mode", + Some(&ToggleWorktreeSecurity), + "Mark this project as trusted and unlock all features", + cx, + ) + }) + .on_click({ + cx.listener(move |this, _, window, cx| { + this.workspace + .update(cx, |workspace, cx| { + workspace.show_worktree_trust_security_modal(true, window, cx) + }) + .log_err(); + }) + }) + .into_any_element(), + ) + } + pub fn render_project_host(&self, cx: &mut Context) -> Option { if self.project.read(cx).is_via_remote_server() { return self.render_remote_project_connection(cx); diff --git a/crates/ui/src/components/notification/alert_modal.rs b/crates/ui/src/components/notification/alert_modal.rs index 9990dc1ce5f13e6834a009c4b8d7c14b594ccf36..52a084c847887a4dea7fd8b9a3fbad8390f68863 100644 --- a/crates/ui/src/components/notification/alert_modal.rs +++ b/crates/ui/src/components/notification/alert_modal.rs @@ -1,73 +1,161 @@ use crate::component_prelude::*; use crate::prelude::*; +use crate::{Checkbox, ListBulletItem, ToggleState}; +use gpui::Action; +use gpui::FocusHandle; use gpui::IntoElement; +use gpui::Stateful; use smallvec::{SmallVec, smallvec}; +use theme::ActiveTheme; + +type ActionHandler = Box) -> Stateful

>; #[derive(IntoElement, RegisterComponent)] pub struct AlertModal { id: ElementId, + header: Option, children: SmallVec<[AnyElement; 2]>, - title: SharedString, - primary_action: SharedString, - dismiss_label: SharedString, + footer: Option, + title: Option, + primary_action: Option, + dismiss_label: Option, + width: Option, + key_context: Option, + action_handlers: Vec, + focus_handle: Option, } impl AlertModal { - pub fn new(id: impl Into, title: impl Into) -> Self { + pub fn new(id: impl Into) -> Self { Self { id: id.into(), + header: None, children: smallvec![], - title: title.into(), - primary_action: "Ok".into(), - dismiss_label: "Cancel".into(), + footer: None, + title: None, + primary_action: None, + dismiss_label: None, + width: None, + key_context: None, + action_handlers: Vec::new(), + focus_handle: None, } } + pub fn title(mut self, title: impl Into) -> Self { + self.title = Some(title.into()); + self + } + + pub fn header(mut self, header: impl IntoElement) -> Self { + self.header = Some(header.into_any_element()); + self + } + + pub fn footer(mut self, footer: impl IntoElement) -> Self { + self.footer = Some(footer.into_any_element()); + self + } + pub fn primary_action(mut self, primary_action: impl Into) -> Self { - self.primary_action = primary_action.into(); + self.primary_action = Some(primary_action.into()); self } pub fn dismiss_label(mut self, dismiss_label: impl Into) -> Self { - self.dismiss_label = dismiss_label.into(); + self.dismiss_label = Some(dismiss_label.into()); + self + } + + pub fn width(mut self, width: impl Into) -> Self { + self.width = Some(width.into()); + self + } + + pub fn key_context(mut self, key_context: impl Into) -> Self { + self.key_context = Some(key_context.into()); + self + } + + pub fn on_action( + mut self, + listener: impl Fn(&A, &mut Window, &mut App) + 'static, + ) -> Self { + self.action_handlers + .push(Box::new(move |div| div.on_action(listener))); + self + } + + pub fn track_focus(mut self, focus_handle: &gpui::FocusHandle) -> Self { + self.focus_handle = Some(focus_handle.clone()); self } } impl RenderOnce for AlertModal { fn render(self, _window: &mut Window, cx: &mut App) -> impl IntoElement { - v_flex() + let width = self.width.unwrap_or_else(|| px(440.).into()); + let has_default_footer = self.primary_action.is_some() || self.dismiss_label.is_some(); + + let mut modal = v_flex() + .when_some(self.key_context, |this, key_context| { + this.key_context(key_context.as_str()) + }) + .when_some(self.focus_handle, |this, focus_handle| { + this.track_focus(&focus_handle) + }) .id(self.id) .elevation_3(cx) - .w(px(440.)) - .p_5() - .child( + .w(width) + .bg(cx.theme().colors().elevated_surface_background) + .overflow_hidden(); + + for handler in self.action_handlers { + modal = handler(modal); + } + + if let Some(header) = self.header { + modal = modal.child(header); + } else if let Some(title) = self.title { + modal = modal.child( + v_flex() + .pt_3() + .pr_3() + .pl_3() + .pb_1() + .child(Headline::new(title).size(HeadlineSize::Small)), + ); + } + + if !self.children.is_empty() { + modal = modal.child( v_flex() + .p_3() .text_ui(cx) .text_color(Color::Muted.color(cx)) .gap_1() - .child(Headline::new(self.title).size(HeadlineSize::Small)) .children(self.children), - ) - .child( + ); + } + + if let Some(footer) = self.footer { + modal = modal.child(footer); + } else if has_default_footer { + let primary_action = self.primary_action.unwrap_or_else(|| "Ok".into()); + let dismiss_label = self.dismiss_label.unwrap_or_else(|| "Cancel".into()); + + modal = modal.child( h_flex() - .h(rems(1.75)) + .p_3() .items_center() - .child(div().flex_1()) - .child( - h_flex() - .items_center() - .gap_1() - .child( - Button::new(self.dismiss_label.clone(), self.dismiss_label.clone()) - .color(Color::Muted), - ) - .child(Button::new( - self.primary_action.clone(), - self.primary_action, - )), - ), - ) + .justify_end() + .gap_1() + .child(Button::new(dismiss_label.clone(), dismiss_label).color(Color::Muted)) + .child(Button::new(primary_action.clone(), primary_action)), + ); + } + + modal } } @@ -90,24 +178,75 @@ impl Component for AlertModal { Some("A modal dialog that presents an alert message with primary and dismiss actions.") } - fn preview(_window: &mut Window, _cx: &mut App) -> Option { + fn preview(_window: &mut Window, cx: &mut App) -> Option { Some( v_flex() .gap_6() .p_4() - .children(vec![example_group( - vec![ - single_example( - "Basic Alert", - AlertModal::new("simple-modal", "Do you want to leave the current call?") - .child("The current window will be closed, and connections to any shared projects will be terminated." - ) - .primary_action("Leave Call") - .into_any_element(), - ) - ], - )]) - .into_any_element() + .children(vec![ + example_group(vec![single_example( + "Basic Alert", + AlertModal::new("simple-modal") + .title("Do you want to leave the current call?") + .child( + "The current window will be closed, and connections to any shared projects will be terminated." + ) + .primary_action("Leave Call") + .dismiss_label("Cancel") + .into_any_element(), + )]), + example_group(vec![single_example( + "Custom Header", + AlertModal::new("custom-header-modal") + .header( + v_flex() + .p_3() + .bg(cx.theme().colors().background) + .gap_1() + .child( + h_flex() + .gap_1() + .child(Icon::new(IconName::Warning).color(Color::Warning)) + .child(Headline::new("Unrecognized Workspace").size(HeadlineSize::Small)) + ) + .child( + h_flex() + .pl(IconSize::default().rems() + rems(0.5)) + .child(Label::new("~/projects/my-project").color(Color::Muted)) + ) + ) + .child( + "Untrusted workspaces are opened in Restricted Mode to protect your system. +Review .zed/settings.json for any extensions or commands configured by this project.", + ) + .child( + v_flex() + .mt_1() + .child(Label::new("Restricted mode prevents:").color(Color::Muted)) + .child(ListBulletItem::new("Project settings from being applied")) + .child(ListBulletItem::new("Language servers from running")) + .child(ListBulletItem::new("MCP integrations from installing")) + ) + .footer( + h_flex() + .p_3() + .justify_between() + .child( + Checkbox::new("trust-parent", ToggleState::Unselected) + .label("Trust all projects in parent directory") + ) + .child( + h_flex() + .gap_1() + .child(Button::new("restricted", "Stay in Restricted Mode").color(Color::Muted)) + .child(Button::new("trust", "Trust and Continue").style(ButtonStyle::Filled)) + ) + ) + .width(rems(40.)) + .into_any_element(), + )]), + ]) + .into_any_element(), ) } } diff --git a/crates/workspace/src/modal_layer.rs b/crates/workspace/src/modal_layer.rs index bcd7db3a82aec46405927e118af86cf4a0d4912b..d6f10f703100d89bef5babd4baa590df5fa0c8fd 100644 --- a/crates/workspace/src/modal_layer.rs +++ b/crates/workspace/src/modal_layer.rs @@ -171,28 +171,19 @@ impl Render for ModalLayer { }; div() - .occlude() .absolute() .size_full() - .top_0() - .left_0() - .when(active_modal.modal.fade_out_background(cx), |el| { + .inset_0() + .occlude() + .when(active_modal.modal.fade_out_background(cx), |this| { let mut background = cx.theme().colors().elevated_surface_background; background.fade_out(0.2); - el.bg(background) + this.bg(background) }) - .on_mouse_down( - MouseButton::Left, - cx.listener(|this, _, window, cx| { - this.hide_modal(window, cx); - }), - ) .child( v_flex() .h(px(0.0)) .top_20() - .flex() - .flex_col() .items_center() .track_focus(&active_modal.focus_handle) .child( diff --git a/crates/workspace/src/security_modal.rs b/crates/workspace/src/security_modal.rs new file mode 100644 index 0000000000000000000000000000000000000000..f2a94ad81661a2572f35d1d746b04b31fa24f00c --- /dev/null +++ b/crates/workspace/src/security_modal.rs @@ -0,0 +1,373 @@ +//! A UI interface for managing the [`TrustedWorktrees`] data. + +use std::{ + borrow::Cow, + path::{Path, PathBuf}, + sync::Arc, +}; + +use collections::{HashMap, HashSet}; +use gpui::{DismissEvent, EventEmitter, FocusHandle, Focusable, WeakEntity}; + +use project::{ + WorktreeId, + trusted_worktrees::{PathTrust, RemoteHostLocation, TrustedWorktrees}, + worktree_store::WorktreeStore, +}; +use smallvec::SmallVec; +use theme::ActiveTheme; +use ui::{ + AlertModal, Checkbox, FluentBuilder, KeyBinding, ListBulletItem, ToggleState, prelude::*, +}; + +use crate::{DismissDecision, ModalView, ToggleWorktreeSecurity}; + +pub struct SecurityModal { + restricted_paths: HashMap, RestrictedPath>, + home_dir: Option, + trust_parents: bool, + worktree_store: WeakEntity, + remote_host: Option, + focus_handle: FocusHandle, + trusted: Option, +} + +#[derive(Debug, PartialEq, Eq)] +struct RestrictedPath { + abs_path: Option>, + is_file: bool, + host: Option, +} + +impl Focusable for SecurityModal { + fn focus_handle(&self, _: &ui::App) -> FocusHandle { + self.focus_handle.clone() + } +} + +impl EventEmitter for SecurityModal {} + +impl ModalView for SecurityModal { + fn fade_out_background(&self) -> bool { + true + } + + fn on_before_dismiss(&mut self, _: &mut Window, _: &mut Context) -> DismissDecision { + match self.trusted { + Some(false) => telemetry::event!("Open in Restricted", source = "Worktree Trust Modal"), + Some(true) => telemetry::event!("Trust and Continue", source = "Worktree Trust Modal"), + None => telemetry::event!("Dismissed", source = "Worktree Trust Modal"), + } + DismissDecision::Dismiss(true) + } +} + +impl Render for SecurityModal { + fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { + if self.restricted_paths.is_empty() { + self.dismiss(cx); + return v_flex().into_any_element(); + } + + let header_label = if self.restricted_paths.len() == 1 { + "Unrecognized Project" + } else { + "Unrecognized Projects" + }; + + let trust_label = self.build_trust_label(); + + AlertModal::new("security-modal") + .width(rems(40.)) + .key_context("SecurityModal") + .track_focus(&self.focus_handle(cx)) + .on_action(cx.listener(|this, _: &menu::Confirm, _window, cx| { + this.trust_and_dismiss(cx); + })) + .on_action(cx.listener(|security_modal, _: &ToggleWorktreeSecurity, _window, cx| { + security_modal.trusted = Some(false); + security_modal.dismiss(cx); + })) + .header( + v_flex() + .p_3() + .gap_1() + .rounded_t_md() + .bg(cx.theme().colors().editor_background.opacity(0.5)) + .border_b_1() + .border_color(cx.theme().colors().border_variant) + .child( + h_flex() + .gap_2() + .child(Icon::new(IconName::Warning).color(Color::Warning)) + .child(Label::new(header_label)), + ) + .children(self.restricted_paths.values().map(|restricted_path| { + let abs_path = restricted_path.abs_path.as_ref().and_then(|abs_path| { + if restricted_path.is_file { + abs_path.parent() + } else { + Some(abs_path.as_ref()) + } + }); + + let label = match abs_path { + Some(abs_path) => match &restricted_path.host { + Some(remote_host) => match &remote_host.user_name { + Some(user_name) => format!( + "{} ({}@{})", + self.shorten_path(abs_path).display(), + user_name, + remote_host.host_identifier + ), + None => format!( + "{} ({})", + self.shorten_path(abs_path).display(), + remote_host.host_identifier + ), + }, + None => self.shorten_path(abs_path).display().to_string(), + }, + None => match &restricted_path.host { + Some(remote_host) => match &remote_host.user_name { + Some(user_name) => format!( + "Empty project ({}@{})", + user_name, remote_host.host_identifier + ), + None => { + format!("Empty project ({})", remote_host.host_identifier) + } + }, + None => "Empty project".to_string(), + }, + }; + h_flex() + .pl(IconSize::default().rems() + rems(0.5)) + .child(Label::new(label).color(Color::Muted)) + })), + ) + .child( + v_flex() + .gap_2() + .child( + v_flex() + .child( + Label::new( + "Untrusted projects are opened in Restricted Mode to protect your system.", + ) + .color(Color::Muted), + ) + .child( + Label::new( + "Review .zed/settings.json for any extensions or commands configured by this project.", + ) + .color(Color::Muted), + ), + ) + .child( + v_flex() + .child(Label::new("Restricted Mode prevents:").color(Color::Muted)) + .child(ListBulletItem::new("Project settings from being applied")) + .child(ListBulletItem::new("Language servers from running")) + .child(ListBulletItem::new("MCP Server integrations from installing")), + ) + .map(|this| match trust_label { + Some(trust_label) => this.child( + Checkbox::new("trust-parents", ToggleState::from(self.trust_parents)) + .label(trust_label) + .on_click(cx.listener( + |security_modal, state: &ToggleState, _, cx| { + security_modal.trust_parents = state.selected(); + cx.notify(); + cx.stop_propagation(); + }, + )), + ), + None => this, + }), + ) + .footer( + h_flex() + .px_3() + .pb_3() + .gap_1() + .justify_end() + .child( + Button::new("rm", "Stay in Restricted Mode") + .key_binding( + KeyBinding::for_action( + &ToggleWorktreeSecurity, + cx, + ) + .map(|kb| kb.size(rems_from_px(12.))), + ) + .on_click(cx.listener(move |security_modal, _, _, cx| { + security_modal.trusted = Some(false); + security_modal.dismiss(cx); + cx.stop_propagation(); + })), + ) + .child( + Button::new("tc", "Trust and Continue") + .style(ButtonStyle::Filled) + .layer(ui::ElevationIndex::ModalSurface) + .key_binding( + KeyBinding::for_action(&menu::Confirm, cx) + .map(|kb| kb.size(rems_from_px(12.))), + ) + .on_click(cx.listener(move |security_modal, _, _, cx| { + security_modal.trust_and_dismiss(cx); + cx.stop_propagation(); + })), + ), + ) + .into_any_element() + } +} + +impl SecurityModal { + pub fn new( + worktree_store: WeakEntity, + remote_host: Option>, + cx: &mut Context, + ) -> Self { + let mut this = Self { + worktree_store, + remote_host: remote_host.map(|host| host.into()), + restricted_paths: HashMap::default(), + focus_handle: cx.focus_handle(), + trust_parents: false, + home_dir: std::env::home_dir(), + trusted: None, + }; + this.refresh_restricted_paths(cx); + + this + } + + fn build_trust_label(&self) -> Option> { + let mut has_restricted_files = false; + let available_parents = self + .restricted_paths + .values() + .filter(|restricted_path| { + has_restricted_files |= restricted_path.is_file; + !restricted_path.is_file + }) + .filter_map(|restricted_path| restricted_path.abs_path.as_ref()?.parent()) + .collect::>(); + match available_parents.len() { + 0 => { + if has_restricted_files { + Some(Cow::Borrowed("Trust all single files")) + } else { + None + } + } + 1 => Some(Cow::Owned(format!( + "Trust all projects in the {:?} folder", + self.shorten_path(available_parents[0]) + ))), + _ => Some(Cow::Borrowed("Trust all projects in the parent folders")), + } + } + + fn shorten_path<'a>(&self, path: &'a Path) -> Cow<'a, Path> { + match &self.home_dir { + Some(home_dir) => path + .strip_prefix(home_dir) + .map(|stripped| Path::new("~").join(stripped)) + .map(Cow::Owned) + .unwrap_or(Cow::Borrowed(path)), + None => Cow::Borrowed(path), + } + } + + fn trust_and_dismiss(&mut self, cx: &mut Context) { + if let Some(trusted_worktrees) = TrustedWorktrees::try_get_global(cx) { + trusted_worktrees.update(cx, |trusted_worktrees, cx| { + let mut paths_to_trust = self + .restricted_paths + .keys() + .map(|worktree_id| match worktree_id { + Some(worktree_id) => PathTrust::Worktree(*worktree_id), + None => PathTrust::Workspace, + }) + .collect::>(); + if self.trust_parents { + paths_to_trust.extend(self.restricted_paths.values().filter_map( + |restricted_paths| { + if restricted_paths.is_file { + Some(PathTrust::Workspace) + } else { + let parent_abs_path = + restricted_paths.abs_path.as_ref()?.parent()?.to_owned(); + Some(PathTrust::AbsPath(parent_abs_path)) + } + }, + )); + } + trusted_worktrees.trust(paths_to_trust, self.remote_host.clone(), cx); + }); + } + + self.trusted = Some(true); + self.dismiss(cx); + } + + pub fn dismiss(&mut self, cx: &mut Context) { + cx.emit(DismissEvent); + } + + pub fn refresh_restricted_paths(&mut self, cx: &mut Context) { + if let Some(trusted_worktrees) = TrustedWorktrees::try_get_global(cx) { + if let Some(worktree_store) = self.worktree_store.upgrade() { + let mut new_restricted_worktrees = trusted_worktrees + .read(cx) + .restricted_worktrees(worktree_store.read(cx), self.remote_host.clone(), cx) + .into_iter() + .filter_map(|restricted_path| { + let restricted_path = match restricted_path { + Some((worktree_id, abs_path)) => { + let worktree = + worktree_store.read(cx).worktree_for_id(worktree_id, cx)?; + ( + Some(worktree_id), + RestrictedPath { + abs_path: Some(abs_path), + is_file: worktree.read(cx).is_single_file(), + host: self.remote_host.clone(), + }, + ) + } + None => ( + None, + RestrictedPath { + abs_path: None, + is_file: false, + host: self.remote_host.clone(), + }, + ), + }; + Some(restricted_path) + }) + .collect::>(); + // Do not clutter the UI: + // * trusting regular local worktrees assumes the workspace is trusted either, on the same host. + // * trusting a workspace trusts all single-file worktrees on the same host. + if new_restricted_worktrees.len() > 1 { + new_restricted_worktrees.remove(&None); + } + + if self.restricted_paths != new_restricted_worktrees { + self.trust_parents = false; + self.restricted_paths = new_restricted_worktrees; + cx.notify(); + } + } + } else if !self.restricted_paths.is_empty() { + self.restricted_paths.clear(); + cx.notify(); + } + } +} diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index 41304fd77f1eff8d890ff21a3051e57ce3ab295e..34593f5bc8f6af3b9cbac87e8fbff50d3f954a95 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -9,6 +9,7 @@ pub mod pane_group; mod path_list; mod persistence; pub mod searchable; +mod security_modal; pub mod shared_screen; mod status_bar; pub mod tasks; @@ -77,7 +78,9 @@ use project::{ DirectoryLister, Project, ProjectEntryId, ProjectPath, ResolvedPath, Worktree, WorktreeId, WorktreeSettings, debugger::{breakpoint_store::BreakpointStoreEvent, session::ThreadStatus}, + project_settings::ProjectSettings, toolchain_store::ToolchainStoreEvent, + trusted_worktrees::TrustedWorktrees, }; use remote::{ RemoteClientDelegate, RemoteConnection, RemoteConnectionOptions, @@ -86,7 +89,9 @@ use remote::{ use schemars::JsonSchema; use serde::Deserialize; use session::AppSession; -use settings::{CenteredPaddingSettings, Settings, SettingsLocation, update_settings_file}; +use settings::{ + CenteredPaddingSettings, Settings, SettingsLocation, SettingsStore, update_settings_file, +}; use shared_screen::SharedScreen; use sqlez::{ bindable::{Bind, Column, StaticColumnCount}, @@ -137,6 +142,7 @@ use crate::{ SerializedAxis, model::{DockData, DockStructure, SerializedItem, SerializedPane, SerializedPaneGroup}, }, + security_modal::SecurityModal, utility_pane::{DraggedUtilityPane, UtilityPaneFrame, UtilityPaneSlot, UtilityPaneState}, }; @@ -277,6 +283,12 @@ actions!( ZoomIn, /// Zooms out of the active pane. ZoomOut, + /// If any worktrees are in restricted mode, shows a modal with possible actions. + /// If the modal is shown already, closes it without trusting any worktree. + ToggleWorktreeSecurity, + /// Clears all trusted worktrees, placing them in restricted mode on next open. + /// Requires restart to take effect on already opened projects. + ClearTrustedWorktrees, /// Stops following a collaborator. Unfollow, /// Restores the banner. @@ -1217,6 +1229,17 @@ impl Workspace { window: &mut Window, cx: &mut Context, ) -> Self { + cx.observe_global::(|_, cx| { + if ProjectSettings::get_global(cx).session.trust_all_worktrees { + if let Some(trusted_worktrees) = TrustedWorktrees::try_get_global(cx) { + trusted_worktrees.update(cx, |trusted_worktrees, cx| { + trusted_worktrees.auto_trust_all(cx); + }) + } + } + }) + .detach(); + cx.subscribe_in(&project, window, move |this, _, event, window, cx| { match event { project::Event::RemoteIdChanged(_) => { @@ -1474,7 +1497,7 @@ impl Workspace { }), ]; - cx.defer_in(window, |this, window, cx| { + cx.defer_in(window, move |this, window, cx| { this.update_window_title(window, cx); this.show_initial_notifications(cx); }); @@ -1559,6 +1582,7 @@ impl Workspace { app_state.languages.clone(), app_state.fs.clone(), env, + true, cx, ); @@ -5938,6 +5962,25 @@ impl Workspace { } }, )) + .on_action(cx.listener( + |workspace: &mut Workspace, _: &ToggleWorktreeSecurity, window, cx| { + workspace.show_worktree_trust_security_modal(true, window, cx); + }, + )) + .on_action( + cx.listener(|_: &mut Workspace, _: &ClearTrustedWorktrees, _, cx| { + if let Some(trusted_worktrees) = TrustedWorktrees::try_get_global(cx) { + let clear_task = trusted_worktrees.update(cx, |trusted_worktrees, cx| { + trusted_worktrees.clear_trusted_paths(cx) + }); + cx.spawn(async move |_, cx| { + clear_task.await; + cx.update(|cx| reload(cx)).ok(); + }) + .detach(); + } + }), + ) .on_action(cx.listener( |workspace: &mut Workspace, _: &ReopenClosedItem, window, cx| { workspace.reopen_closed_item(window, cx).detach(); @@ -6418,6 +6461,41 @@ impl Workspace { file.project.all_languages.defaults.show_edit_predictions = Some(!show_edit_predictions) }); } + + pub fn show_worktree_trust_security_modal( + &mut self, + toggle: bool, + window: &mut Window, + cx: &mut Context, + ) { + if let Some(security_modal) = self.active_modal::(cx) { + if toggle { + security_modal.update(cx, |security_modal, cx| { + security_modal.dismiss(cx); + }) + } else { + security_modal.update(cx, |security_modal, cx| { + security_modal.refresh_restricted_paths(cx); + }); + } + } else { + let has_restricted_worktrees = TrustedWorktrees::try_get_global(cx) + .map(|trusted_worktrees| { + trusted_worktrees + .read(cx) + .has_restricted_worktrees(&self.project().read(cx).worktree_store(), cx) + }) + .unwrap_or(false); + if has_restricted_worktrees { + let project = self.project().read(cx); + let remote_host = project.remote_connection_options(cx); + let worktree_store = project.worktree_store().downgrade(); + self.toggle_modal(window, cx, |_, cx| { + SecurityModal::new(worktree_store, remote_host, cx) + }); + } + } + } } fn leader_border_for_pane( @@ -7968,6 +8046,7 @@ pub fn open_remote_project_with_new_connection( app_state.user_store.clone(), app_state.languages.clone(), app_state.fs.clone(), + true, cx, ) })?; diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rs index 674cc5f659f7a0d5d97eb7700505eb0ec4c5e5bc..353baba02cca9b0060a647f438fa8be4e81e9142 100644 --- a/crates/zed/src/main.rs +++ b/crates/zed/src/main.rs @@ -27,7 +27,7 @@ use reqwest_client::ReqwestClient; use assets::Assets; use node_runtime::{NodeBinaryOptions, NodeRuntime}; use parking_lot::Mutex; -use project::project_settings::ProjectSettings; +use project::{project_settings::ProjectSettings, trusted_worktrees}; use recent_projects::{SshSettings, open_remote_project}; use release_channel::{AppCommitSha, AppVersion, ReleaseChannel}; use session::{AppSession, Session}; @@ -36,6 +36,7 @@ use std::{ env, io::{self, IsTerminal}, path::{Path, PathBuf}, + pin::Pin, process, sync::{Arc, OnceLock}, time::Instant, @@ -406,6 +407,7 @@ pub fn main() { }); app.run(move |cx| { + trusted_worktrees::init(None, None, cx); menu::init(); zed_actions::init(); @@ -474,7 +476,15 @@ pub fn main() { tx.send(Some(options)).log_err(); }) .detach(); - let node_runtime = NodeRuntime::new(client.http_client(), Some(shell_env_loaded_rx), rx); + + let trust_task = trusted_worktrees::wait_for_default_workspace_trust("Node runtime", cx) + .map(|trust_task| Box::pin(trust_task) as Pin>); + let node_runtime = NodeRuntime::new( + client.http_client(), + Some(shell_env_loaded_rx), + rx, + trust_task, + ); debug_adapter_extension::init(extension_host_proxy.clone(), cx); languages::init(languages.clone(), fs.clone(), node_runtime.clone(), cx); diff --git a/docs/src/SUMMARY.md b/docs/src/SUMMARY.md index 9d1f6f61d446b67256c00bf6322aed73af922c5e..6514bd6455d85fe390bebce10096fc4edc5a9f0a 100644 --- a/docs/src/SUMMARY.md +++ b/docs/src/SUMMARY.md @@ -23,6 +23,9 @@ - [Visual Customization](./visual-customization.md) - [Vim Mode](./vim.md) - [Helix Mode](./helix.md) +- [Privacy and Security](./ai/privacy-and-security.md) + - [Worktree Trust](./worktree-trust.md) + - [AI Improvement](./ai/ai-improvement.md) @@ -69,8 +72,6 @@ - [Models](./ai/models.md) - [Plans and Usage](./ai/plans-and-usage.md) - [Billing](./ai/billing.md) -- [Privacy and Security](./ai/privacy-and-security.md) - - [AI Improvement](./ai/ai-improvement.md) # Extensions diff --git a/docs/src/ai/privacy-and-security.md b/docs/src/ai/privacy-and-security.md index 6921567b9165e863cd4303752a669e641e6fcdca..d72cc8c476a83f60d8342962fcdd410e541e7356 100644 --- a/docs/src/ai/privacy-and-security.md +++ b/docs/src/ai/privacy-and-security.md @@ -2,7 +2,7 @@ ## Philosophy -Zed aims to collect on the minimum data necessary to serve and improve our product. +Zed aims to collect only the minimum data necessary to serve and improve our product. We believe in opt-in data sharing as the default in building AI products, rather than opt-out, like most of our competitors. Privacy Mode is not a setting to be toggled, it's a default stance. @@ -12,6 +12,8 @@ It is entirely possible to use Zed, including Zed's AI capabilities, without sha ## Documentation +- [Worktree trust](../worktree-trust.md): How Zed opens files and directories in restricted mode. + - [Telemetry](../telemetry.md): How Zed collects general telemetry data. - [AI Improvement](./ai-improvement.md): Zed's opt-in-only approach to data collection for AI improvement, whether our Agentic offering or Edit Predictions. diff --git a/docs/src/configuring-zed.md b/docs/src/configuring-zed.md index 549dbe6fbb47b03a372ee3ddac87b72dbc4d9c2e..8a638d9f7857e1a55aaa5589a77110a7b803bbfe 100644 --- a/docs/src/configuring-zed.md +++ b/docs/src/configuring-zed.md @@ -1451,6 +1451,47 @@ or `boolean` values +### Session + +- Description: Controls Zed lifecycle-related behavior. +- Setting: `session` +- Default: + +```json +{ + "session": { + "restore_unsaved_buffers": true, + "trust_all_worktrees": false + } +} +``` + +**Options** + +1. Whether or not to restore unsaved buffers on restart: + +```json [settings] +{ + "session": { + "restore_unsaved_buffers": true + } +} +``` + +If this is true, user won't be prompted whether to save/discard dirty files when closing the application. + +2. Whether or not to skip worktree and workspace trust checks: + +```json [settings] +{ + "session": { + "trust_all_worktrees": false + } +} +``` + +When trusted, project settings are synchronized automatically, language and MCP servers are downloaded and started automatically. + ### Drag And Drop Selection - Description: Whether to allow drag and drop text selection in buffer. `delay` is the milliseconds that must elapse before drag and drop is allowed. Otherwise, a new text selection is created. diff --git a/docs/src/worktree-trust.md b/docs/src/worktree-trust.md new file mode 100644 index 0000000000000000000000000000000000000000..158851117bfdc4d00746594d74e1e6dae0bb84dc --- /dev/null +++ b/docs/src/worktree-trust.md @@ -0,0 +1,66 @@ +# Zed and trusted worktrees + +A worktree in Zed is either a directory or a single file that Zed opens as a standalone "project". +Zed opens a worktree every time `zed some/path` is invoked, on drag and dropping a file or directory into Zed, on opening user settings.json, etc. + +Every worktree opened may contain a `.zed/settings.json` file with extra configuration options that may require installing and spawning language servers or MCP servers. +Note that the Zed workspace itself may also perform user-configured MCP server installation and spawning, even if no worktrees are open. + +In order to provide users the opportunity to make their own choices according to their unique threat model and risk tolerance, the workspace and all worktrees will be started in Restricted mode, which prevents download and execution of any related items. Until configured to trust the workspace and/or worktrees, Zed will not perform any untrusted actions and will wait for user confirmation. This gives users a chance to review and understand any pre-configured settings, MCP servers, or language servers associated with a project. + +If a worktree is not trusted, Zed will indicate this with an exclamation mark icon in the title bar and a message in the Agent panel. Clicking this icon or using `workspace::ToggleWorktreeSecurity` action will bring up the security modal that allows the user to trust the worktree. + +Trusting any worktree will persist this information between restarts. It's possible to clear all trusted worktrees with `workspace::ClearTrustedWorktrees` command. +This command will restart Zed, to ensure no untrusted settings, language servers or MCP servers persist. + +This feature works locally and on SSH and WSL remote hosts. Zed tracks trust information per host in these cases. + +## What is restricted + +Restricted Mode prevents: + +- Project settings (`.zed/settings.json`) from being parsed and applied +- Language servers from being installed and spawned +- MCP servers from being installed and spawned + +## Configuring broad worktree trust + +By default, Zed won't trust any new worktrees and users will be required to trust each new worktree. Though not recommended, users may elect to trust all worktrees and the current workspace for a given session by configuring the following setting: + +```json [settings] +"session": { + "trust_all_worktrees": true +} +``` + +Note that auto trusted worktrees are not persisted between restarts, only manually trusted worktrees are. This ensures that new trust decisions must be made if a users elects to disable the `trust_all_worktrees` setting. + +## Trust hierarchy + +These are mostly internal details and may change in the future, but are helpful to understand how multiple different trust requests can be approved at once. +Zed has multiple layers of trust, based on the requests, from the least to most trusted level: + +- "single file worktree" + +After opening an empty Zed it's possible to open just a file, same as after opening a directory in Zed it's possible to open a file outside of this directory. +A typical scenario where a directory might be open and a single file is subsequently opened is opening Zed's settings.json file via `zed: open settings file` command: that starts a language server for a new file open, which originates from a newly created, single file worktree. + +Spawning a language server presents a risk should the language server experience a supply-chain attack; therefore, Zed restricts that by default. Each single file worktree requires a separate trust grant, unless the directory containing it is trusted or all worktrees are trusted. + +- "workspace" + +Even an empty Zed workspace with no files or directories open presents a risk if new MCP servers are locally configured by the user without review. For instance, opening an Assistant Panel and creating a new external agent thread might require installing and running new user-configured [Model Context Protocol servers](./ai/mcp.md). By default, zed will restrict a new MCP server until the user elects to trust the local workspace. Users may also disable the entire Agent panel if preferred; see [AI Configuration](./ai/configuration.md) for more details. + +Workspace trust, permitted by trusting Zed with no worktrees open, allows locally configured resources to be downloaded and executed. Workspace trust is per host and also trusts all single file worktrees from the same host in order to permit all local user-configured MCP and language servers to start. + +- "directory worktree" + +If a directory is open in Zed, it's a full worktree which may spawn multiple language servers associated with it or spawn MCP servers if contained in a project settings file.Therefore, each directory worktree requires a separate trust grant unless a parent directory worktree trust is granted (see below). + +When a directory worktree is trusted, language and MCP servers are permitted to be downloaded and started, hence we also enable workspace trust for the host in question automatically when this occurs. + +- "parent directory worktree" + +To permit trust decisions for multiple directory worktrees at once, it's possible to trust all subdirectories of a given parent directory worktree opened in Zed by checking the appropriate checkbox. This will grant trust to all its subdirectories, including all current and potential directory worktrees. + +This also automatically enables workspace trust to permit the newly trusted resources to download and start. From be1f824a35f414effa888a3959371a289cb84876 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Tue, 16 Dec 2025 11:38:46 -0700 Subject: [PATCH 394/621] Fix agent notification getting stuck when thread view is dropped (#44939) Closes #32951 ## Summary When an agent notification was shown and the `AcpThreadView` was dropped (e.g., by closing the project window or navigating to a new thread), the notification would become orphaned and undismissable because the subscriptions handling dismiss events were dropped along with the thread view. ## Fix Added an `on_release` callback that closes all notification windows when the thread view is dropped. This ensures notifications are always cleaned up properly. ## Testing Added `test_notification_closed_when_thread_view_dropped` to verify notifications are closed when the thread view is dropped. Release Notes: - Fixed agent notification getting stuck and becoming undismissable when the project window is closed or when navigating to a new thread --- crates/agent_ui/src/acp/thread_view.rs | 66 +++++++++++++++++++++++++- 1 file changed, 64 insertions(+), 2 deletions(-) diff --git a/crates/agent_ui/src/acp/thread_view.rs b/crates/agent_ui/src/acp/thread_view.rs index cabdaf920c9597e85176f11f4f3a466c4ab96fe8..90134ebfb458a37f01ed99fe7345238c763e5418 100644 --- a/crates/agent_ui/src/acp/thread_view.rs +++ b/crates/agent_ui/src/acp/thread_view.rs @@ -389,6 +389,17 @@ impl AcpThreadView { ), ]; + cx.on_release(|this, cx| { + for window in this.notifications.drain(..) { + window + .update(cx, |_, window, _| { + window.remove_window(); + }) + .ok(); + } + }) + .detach(); + let show_codex_windows_warning = cfg!(windows) && project.read(cx).is_local() && agent.clone().downcast::().is_some(); @@ -5042,8 +5053,8 @@ impl AcpThreadView { }); if let Some(screen_window) = cx - .open_window(options, |_, cx| { - cx.new(|_| { + .open_window(options, |_window, cx| { + cx.new(|_cx| { AgentNotification::new(title.clone(), caption.clone(), icon, project_name) }) }) @@ -6469,6 +6480,57 @@ pub(crate) mod tests { ); } + #[gpui::test] + async fn test_notification_closed_when_thread_view_dropped(cx: &mut TestAppContext) { + init_test(cx); + + let (thread_view, cx) = setup_thread_view(StubAgentServer::default_response(), cx).await; + + let weak_view = thread_view.downgrade(); + + let message_editor = cx.read(|cx| thread_view.read(cx).message_editor.clone()); + message_editor.update_in(cx, |editor, window, cx| { + editor.set_text("Hello", window, cx); + }); + + cx.deactivate_window(); + + thread_view.update_in(cx, |thread_view, window, cx| { + thread_view.send(window, cx); + }); + + cx.run_until_parked(); + + // Verify notification is shown + assert!( + cx.windows() + .iter() + .any(|window| window.downcast::().is_some()), + "Expected notification to be shown" + ); + + // Drop the thread view (simulating navigation to a new thread) + drop(thread_view); + drop(message_editor); + // Trigger an update to flush effects, which will call release_dropped_entities + cx.update(|_window, _cx| {}); + cx.run_until_parked(); + + // Verify the entity was actually released + assert!( + !weak_view.is_upgradable(), + "Thread view entity should be released after dropping" + ); + + // The notification should be automatically closed via on_release + assert!( + !cx.windows() + .iter() + .any(|window| window.downcast::().is_some()), + "Notification should be closed when thread view is dropped" + ); + } + async fn setup_thread_view( agent: impl AgentServer + 'static, cx: &mut TestAppContext, From bd5569b338234c66d4fd850e0c3d0f0446ba1371 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Tue, 16 Dec 2025 20:41:38 +0200 Subject: [PATCH 395/621] Bump tree-sitter to the latest (#44963) Release Notes: - N/A Co-authored-by: Lukas Wirth --- Cargo.lock | 294 +++++++++++------- Cargo.toml | 6 +- crates/editor/src/jsx_tag_auto_close.rs | 2 +- crates/extension_host/src/wasm_host.rs | 10 +- crates/extension_host/src/wasm_host/wit.rs | 2 +- .../src/wasm_host/wit/since_v0_8_0.rs | 4 +- .../src/syntax_map/syntax_map_tests.rs | 4 +- crates/vim/src/object.rs | 2 +- 8 files changed, 200 insertions(+), 124 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b89c0803c7ed9a1b90fc3e8fc55eab10cee7b905..2d0cb8235d547c5486ffd89e3d54fd8d46a54f0c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -111,6 +111,15 @@ dependencies = [ "workspace", ] +[[package]] +name = "addr2line" +version = "0.24.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" +dependencies = [ + "gimli 0.31.1", +] + [[package]] name = "addr2line" version = "0.25.1" @@ -1997,7 +2006,7 @@ version = "0.3.76" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bb531853791a215d7c62a30daf0dde835f381ab5de4589cfe7c649d2cbe92bd6" dependencies = [ - "addr2line", + "addr2line 0.25.1", "cfg-if", "libc", "miniz_oxide", @@ -2656,9 +2665,9 @@ dependencies = [ [[package]] name = "cap-fs-ext" -version = "3.4.4" +version = "3.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e41cc18551193fe8fa6f15c1e3c799bc5ec9e2cfbfaa8ed46f37013e3e6c173c" +checksum = "d5528f85b1e134ae811704e41ef80930f56e795923f866813255bc342cc20654" dependencies = [ "cap-primitives", "cap-std", @@ -2668,9 +2677,9 @@ dependencies = [ [[package]] name = "cap-net-ext" -version = "3.4.4" +version = "3.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f83833816c66c986e913b22ac887cec216ea09301802054316fc5301809702c" +checksum = "20a158160765c6a7d0d8c072a53d772e4cb243f38b04bfcf6b4939cfbe7482e7" dependencies = [ "cap-primitives", "cap-std", @@ -2680,9 +2689,9 @@ dependencies = [ [[package]] name = "cap-primitives" -version = "3.4.4" +version = "3.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a1e394ed14f39f8bc26f59d4c0c010dbe7f0a1b9bafff451b1f98b67c8af62a" +checksum = "b6cf3aea8a5081171859ef57bc1606b1df6999df4f1110f8eef68b30098d1d3a" dependencies = [ "ambient-authority", "fs-set-times", @@ -2698,9 +2707,9 @@ dependencies = [ [[package]] name = "cap-rand" -version = "3.4.4" +version = "3.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0acb89ccf798a28683f00089d0630dfaceec087234eae0d308c05ddeaa941b40" +checksum = "d8144c22e24bbcf26ade86cb6501a0916c46b7e4787abdb0045a467eb1645a1d" dependencies = [ "ambient-authority", "rand 0.8.5", @@ -2708,9 +2717,9 @@ dependencies = [ [[package]] name = "cap-std" -version = "3.4.4" +version = "3.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07c0355ca583dd58f176c3c12489d684163861ede3c9efa6fd8bba314c984189" +checksum = "b6dc3090992a735d23219de5c204927163d922f42f575a0189b005c62d37549a" dependencies = [ "cap-primitives", "io-extras", @@ -2720,9 +2729,9 @@ dependencies = [ [[package]] name = "cap-time-ext" -version = "3.4.4" +version = "3.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "491af520b8770085daa0466978c75db90368c71896523f2464214e38359b1a5b" +checksum = "def102506ce40c11710a9b16e614af0cde8e76ae51b1f48c04b8d79f4b671a80" dependencies = [ "ambient-authority", "cap-primitives", @@ -3924,20 +3933,38 @@ dependencies = [ "libc", ] +[[package]] +name = "cranelift-assembler-x64" +version = "0.120.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5023e06632d8f351c2891793ccccfe4aef957954904392434038745fb6f1f68" +dependencies = [ + "cranelift-assembler-x64-meta", +] + +[[package]] +name = "cranelift-assembler-x64-meta" +version = "0.120.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1c4012b4c8c1f6eb05c0a0a540e3e1ee992631af51aa2bbb3e712903ce4fd65" +dependencies = [ + "cranelift-srcgen", +] + [[package]] name = "cranelift-bforest" -version = "0.116.1" +version = "0.120.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e15d04a0ce86cb36ead88ad68cf693ffd6cda47052b9e0ac114bc47fd9cd23c4" +checksum = "4d6d883b4942ef3a7104096b8bc6f2d1a41393f159ac8de12aed27b25d67f895" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-bitset" -version = "0.116.1" +version = "0.120.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c6e3969a7ce267259ce244b7867c5d3bc9e65b0a87e81039588dfdeaede9f34" +checksum = "db7b2ee9eec6ca8a716d900d5264d678fb2c290c58c46c8da7f94ee268175d17" dependencies = [ "serde", "serde_derive", @@ -3945,11 +3972,12 @@ dependencies = [ [[package]] name = "cranelift-codegen" -version = "0.116.1" +version = "0.120.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c22032c4cb42558371cf516bb47f26cdad1819d3475c133e93c49f50ebf304e" +checksum = "aeda0892577afdce1ac2e9a983a55f8c5b87a59334e1f79d8f735a2d7ba4f4b4" dependencies = [ "bumpalo", + "cranelift-assembler-x64", "cranelift-bforest", "cranelift-bitset", "cranelift-codegen-meta", @@ -3958,9 +3986,10 @@ dependencies = [ "cranelift-entity", "cranelift-isle", "gimli 0.31.1", - "hashbrown 0.14.5", + "hashbrown 0.15.5", "log", "postcard", + "pulley-interpreter", "regalloc2", "rustc-hash 2.1.1", "serde", @@ -3972,33 +4001,36 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.116.1" +version = "0.120.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c904bc71c61b27fc57827f4a1379f29de64fe95653b620a3db77d59655eee0b8" +checksum = "e461480d87f920c2787422463313326f67664e68108c14788ba1676f5edfcd15" dependencies = [ + "cranelift-assembler-x64-meta", "cranelift-codegen-shared", + "cranelift-srcgen", + "pulley-interpreter", ] [[package]] name = "cranelift-codegen-shared" -version = "0.116.1" +version = "0.120.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40180f5497572f644ce88c255480981ae2ec1d7bb4d8e0c0136a13b87a2f2ceb" +checksum = "976584d09f200c6c84c4b9ff7af64fc9ad0cb64dffa5780991edd3fe143a30a1" [[package]] name = "cranelift-control" -version = "0.116.1" +version = "0.120.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d132c6d0bd8a489563472afc171759da0707804a65ece7ceb15a8c6d7dd5ef" +checksum = "46d43d70f4e17c545aa88dbf4c84d4200755d27c6e3272ebe4de65802fa6a955" dependencies = [ "arbitrary", ] [[package]] name = "cranelift-entity" -version = "0.116.1" +version = "0.120.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b2d0d9618275474fbf679dd018ac6e009acbd6ae6850f6a67be33fb3b00b323" +checksum = "d75418674520cb400c8772bfd6e11a62736c78fc1b6e418195696841d1bf91f1" dependencies = [ "cranelift-bitset", "serde", @@ -4007,9 +4039,9 @@ dependencies = [ [[package]] name = "cranelift-frontend" -version = "0.116.1" +version = "0.120.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fac41e16729107393174b0c9e3730fb072866100e1e64e80a1a963b2e484d57" +checksum = "3c8b1a91c86687a344f3c52dd6dfb6e50db0dfa7f2e9c7711b060b3623e1fdeb" dependencies = [ "cranelift-codegen", "log", @@ -4019,21 +4051,27 @@ dependencies = [ [[package]] name = "cranelift-isle" -version = "0.116.1" +version = "0.120.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ca20d576e5070044d0a72a9effc2deacf4d6aa650403189d8ea50126483944d" +checksum = "711baa4e3432d4129295b39ec2b4040cc1b558874ba0a37d08e832e857db7285" [[package]] name = "cranelift-native" -version = "0.116.1" +version = "0.120.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8dee82f3f1f2c4cba9177f1cc5e350fe98764379bcd29340caa7b01f85076c7" +checksum = "41c83e8666e3bcc5ffeaf6f01f356f0e1f9dcd69ce5511a1efd7ca5722001a3f" dependencies = [ "cranelift-codegen", "libc", "target-lexicon 0.13.3", ] +[[package]] +name = "cranelift-srcgen" +version = "0.120.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02e3f4d783a55c64266d17dc67d2708852235732a100fc40dd9f1051adc64d7b" + [[package]] name = "crash-context" version = "0.6.3" @@ -12795,13 +12833,12 @@ checksum = "bd348ff538bc9caeda7ee8cad2d1d48236a1f443c1fa3913c6a02fe0043b1dd3" [[package]] name = "pulley-interpreter" -version = "29.0.1" +version = "33.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62d95f8575df49a2708398182f49a888cf9dc30210fb1fd2df87c889edcee75d" +checksum = "986beaef947a51d17b42b0ea18ceaa88450d35b6994737065ed505c39172db71" dependencies = [ "cranelift-bitset", "log", - "sptr", "wasmtime-math", ] @@ -13300,9 +13337,9 @@ dependencies = [ [[package]] name = "regalloc2" -version = "0.11.2" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc06e6b318142614e4a48bc725abbf08ff166694835c43c9dae5a9009704639a" +checksum = "5216b1837de2149f8bc8e6d5f88a9326b63b8c836ed58ce4a0a29ec736a59734" dependencies = [ "allocator-api2", "bumpalo", @@ -17311,9 +17348,9 @@ dependencies = [ [[package]] name = "tree-sitter" -version = "0.25.10" +version = "0.26.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78f873475d258561b06f1c595d93308a7ed124d9977cb26b148c2084a4a3cc87" +checksum = "974d205cc395652cfa8b37daa053fe56eebd429acf8dc055503fee648dae981e" dependencies = [ "cc", "regex", @@ -18400,6 +18437,16 @@ dependencies = [ "wasmparser 0.227.1", ] +[[package]] +name = "wasm-encoder" +version = "0.229.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38ba1d491ecacb085a2552025c10a675a6fddcbd03b1fc9b36c536010ce265d2" +dependencies = [ + "leb128fmt", + "wasmparser 0.229.0", +] + [[package]] name = "wasm-metadata" version = "0.201.0" @@ -18484,23 +18531,37 @@ dependencies = [ "semver", ] +[[package]] +name = "wasmparser" +version = "0.229.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0cc3b1f053f5d41aa55640a1fa9b6d1b8a9e4418d118ce308d20e24ff3575a8c" +dependencies = [ + "bitflags 2.9.4", + "hashbrown 0.15.5", + "indexmap", + "semver", + "serde", +] + [[package]] name = "wasmprinter" -version = "0.221.3" +version = "0.229.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7343c42a97f2926c7819ff81b64012092ae954c5d83ddd30c9fcdefd97d0b283" +checksum = "d25dac01892684a99b8fbfaf670eb6b56edea8a096438c75392daeb83156ae2e" dependencies = [ "anyhow", "termcolor", - "wasmparser 0.221.3", + "wasmparser 0.229.0", ] [[package]] name = "wasmtime" -version = "29.0.1" +version = "33.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11976a250672556d1c4c04c6d5d7656ac9192ac9edc42a4587d6c21460010e69" +checksum = "57373e1d8699662fb791270ac5dfac9da5c14f618ecf940cdb29dc3ad9472a3c" dependencies = [ + "addr2line 0.24.2", "anyhow", "async-trait", "bitflags 2.9.4", @@ -18508,7 +18569,7 @@ dependencies = [ "cc", "cfg-if", "encoding_rs", - "hashbrown 0.14.5", + "hashbrown 0.15.5", "indexmap", "libc", "log", @@ -18516,12 +18577,11 @@ dependencies = [ "memfd", "object 0.36.7", "once_cell", - "paste", "postcard", "psm", "pulley-interpreter", "rayon", - "rustix 0.38.44", + "rustix 1.1.2", "semver", "serde", "serde_derive", @@ -18529,7 +18589,7 @@ dependencies = [ "sptr", "target-lexicon 0.13.3", "trait-variant", - "wasmparser 0.221.3", + "wasmparser 0.229.0", "wasmtime-asm-macros", "wasmtime-component-macro", "wasmtime-component-util", @@ -18546,18 +18606,18 @@ dependencies = [ [[package]] name = "wasmtime-asm-macros" -version = "29.0.1" +version = "33.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f178b0d125201fbe9f75beaf849bd3e511891f9e45ba216a5b620802ccf64f2" +checksum = "bd0fc91372865167a695dc98d0d6771799a388a7541d3f34e939d0539d6583de" dependencies = [ "cfg-if", ] [[package]] name = "wasmtime-c-api-impl" -version = "29.0.1" +version = "33.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea30cef3608f2de5797c7bbb94c1ba4f3676d9a7f81ae86ced1b512e2766ed0c" +checksum = "46db556f1dccdd88e0672bd407162ab0036b72e5eccb0f4398d8251cba32dba1" dependencies = [ "anyhow", "log", @@ -18568,9 +18628,9 @@ dependencies = [ [[package]] name = "wasmtime-c-api-macros" -version = "29.0.1" +version = "33.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "022a79ebe1124d5d384d82463d7e61c6b4dd857d81f15cb8078974eeb86db65b" +checksum = "315cc6bc8cdc66f296accb26d7625ae64c1c7b6da6f189e8a72ce6594bf7bd36" dependencies = [ "proc-macro2", "quote", @@ -18578,9 +18638,9 @@ dependencies = [ [[package]] name = "wasmtime-component-macro" -version = "29.0.1" +version = "33.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d74de6592ed945d0a602f71243982a304d5d02f1e501b638addf57f42d57dfaf" +checksum = "25c9c7526675ff9a9794b115023c4af5128e3eb21389bfc3dc1fd344d549258f" dependencies = [ "anyhow", "proc-macro2", @@ -18588,20 +18648,20 @@ dependencies = [ "syn 2.0.106", "wasmtime-component-util", "wasmtime-wit-bindgen", - "wit-parser 0.221.3", + "wit-parser 0.229.0", ] [[package]] name = "wasmtime-component-util" -version = "29.0.1" +version = "33.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "707dc7b3c112ab5a366b30cfe2fb5b2f8e6a0f682f16df96a5ec582bfe6f056e" +checksum = "cc42ec8b078875804908d797cb4950fec781d9add9684c9026487fd8eb3f6291" [[package]] name = "wasmtime-cranelift" -version = "29.0.1" +version = "33.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "366be722674d4bf153290fbcbc4d7d16895cc82fb3e869f8d550ff768f9e9e87" +checksum = "b2bd72f0a6a0ffcc6a184ec86ac35c174e48ea0e97bbae277c8f15f8bf77a566" dependencies = [ "anyhow", "cfg-if", @@ -18611,22 +18671,23 @@ dependencies = [ "cranelift-frontend", "cranelift-native", "gimli 0.31.1", - "itertools 0.12.1", + "itertools 0.14.0", "log", "object 0.36.7", + "pulley-interpreter", "smallvec", "target-lexicon 0.13.3", - "thiserror 1.0.69", - "wasmparser 0.221.3", + "thiserror 2.0.17", + "wasmparser 0.229.0", "wasmtime-environ", "wasmtime-versioned-export-macros", ] [[package]] name = "wasmtime-environ" -version = "29.0.1" +version = "33.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdadc1af7097347aa276a4f008929810f726b5b46946971c660b6d421e9994ad" +checksum = "e6187bb108a23eb25d2a92aa65d6c89fb5ed53433a319038a2558567f3011ff2" dependencies = [ "anyhow", "cpp_demangle", @@ -18643,22 +18704,22 @@ dependencies = [ "serde_derive", "smallvec", "target-lexicon 0.13.3", - "wasm-encoder 0.221.3", - "wasmparser 0.221.3", + "wasm-encoder 0.229.0", + "wasmparser 0.229.0", "wasmprinter", "wasmtime-component-util", ] [[package]] name = "wasmtime-fiber" -version = "29.0.1" +version = "33.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccba90d4119f081bca91190485650730a617be1fff5228f8c4757ce133d21117" +checksum = "dc8965d2128c012329f390e24b8b2758dd93d01bf67e1a1a0dd3d8fd72f56873" dependencies = [ "anyhow", "cc", "cfg-if", - "rustix 0.38.44", + "rustix 1.1.2", "wasmtime-asm-macros", "wasmtime-versioned-export-macros", "windows-sys 0.59.0", @@ -18666,9 +18727,9 @@ dependencies = [ [[package]] name = "wasmtime-jit-icache-coherence" -version = "29.0.1" +version = "33.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec5e8552e01692e6c2e5293171704fed8abdec79d1a6995a0870ab190e5747d1" +checksum = "7af0e940cb062a45c0b3f01a926f77da5947149e99beb4e3dd9846d5b8f11619" dependencies = [ "anyhow", "cfg-if", @@ -18678,24 +18739,24 @@ dependencies = [ [[package]] name = "wasmtime-math" -version = "29.0.1" +version = "33.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29210ec2aa25e00f4d54605cedaf080f39ec01a872c5bd520ad04c67af1dde17" +checksum = "acfca360e719dda9a27e26944f2754ff2fd5bad88e21919c42c5a5f38ddd93cb" dependencies = [ "libm", ] [[package]] name = "wasmtime-slab" -version = "29.0.1" +version = "33.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb5821a96fa04ac14bc7b158bb3d5cd7729a053db5a74dad396cd513a5e5ccf" +checksum = "48e240559cada55c4b24af979d5f6c95e0029f5772f32027ec3c62b258aaff65" [[package]] name = "wasmtime-versioned-export-macros" -version = "29.0.1" +version = "33.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86ff86db216dc0240462de40c8290887a613dddf9685508eb39479037ba97b5b" +checksum = "d0963c1438357a3d8c0efe152b4ef5259846c1cf8b864340270744fe5b3bae5e" dependencies = [ "proc-macro2", "quote", @@ -18704,9 +18765,9 @@ dependencies = [ [[package]] name = "wasmtime-wasi" -version = "29.0.1" +version = "33.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d1be69bfcab1bdac74daa7a1f9695ab992b9c8e21b9b061e7d66434097e0ca4" +checksum = "4ae951b72c7c6749a1c15dcdfb6d940a2614c932b4a54f474636e78e2c744b4c" dependencies = [ "anyhow", "async-trait", @@ -18721,30 +18782,43 @@ dependencies = [ "futures 0.3.31", "io-extras", "io-lifetimes", - "rustix 0.38.44", + "rustix 1.1.2", "system-interface", - "thiserror 1.0.69", + "thiserror 2.0.17", "tokio", "tracing", - "trait-variant", "url", "wasmtime", + "wasmtime-wasi-io", "wiggle", "windows-sys 0.59.0", ] +[[package]] +name = "wasmtime-wasi-io" +version = "33.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a835790dcecc3d7051ec67da52ba9e04af25e1bc204275b9391e3f0042b10797" +dependencies = [ + "anyhow", + "async-trait", + "bytes 1.10.1", + "futures 0.3.31", + "wasmtime", +] + [[package]] name = "wasmtime-winch" -version = "29.0.1" +version = "33.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdbabfb8f20502d5e1d81092b9ead3682ae59988487aafcd7567387b7a43cf8f" +checksum = "cbc3b117d03d6eeabfa005a880c5c22c06503bb8820f3aa2e30f0e8d87b6752f" dependencies = [ "anyhow", "cranelift-codegen", "gimli 0.31.1", "object 0.36.7", "target-lexicon 0.13.3", - "wasmparser 0.221.3", + "wasmparser 0.229.0", "wasmtime-cranelift", "wasmtime-environ", "winch-codegen", @@ -18752,14 +18826,14 @@ dependencies = [ [[package]] name = "wasmtime-wit-bindgen" -version = "29.0.1" +version = "33.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8358319c2dd1e4db79e3c1c5d3a5af84956615343f9f89f4e4996a36816e06e6" +checksum = "1382f4f09390eab0d75d4994d0c3b0f6279f86a571807ec67a8253c87cf6a145" dependencies = [ "anyhow", "heck 0.5.0", "indexmap", - "wit-parser 0.221.3", + "wit-parser 0.229.0", ] [[package]] @@ -19053,14 +19127,14 @@ dependencies = [ [[package]] name = "wiggle" -version = "29.0.1" +version = "33.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b9af35bc9629c52c261465320a9a07959164928b4241980ba1cf923b9e6751d" +checksum = "649c1aca13ef9e9dccf2d5efbbebf12025bc5521c3fb7754355ef60f5eb810be" dependencies = [ "anyhow", "async-trait", "bitflags 2.9.4", - "thiserror 1.0.69", + "thiserror 2.0.17", "tracing", "wasmtime", "wiggle-macro", @@ -19068,24 +19142,23 @@ dependencies = [ [[package]] name = "wiggle-generate" -version = "29.0.1" +version = "33.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cf267dd05673912c8138f4b54acabe6bd53407d9d1536f0fadb6520dd16e101" +checksum = "164870fc34214ee42bd81b8ce9e7c179800fa1a7d4046d17a84e7f7bf422c8ad" dependencies = [ "anyhow", "heck 0.5.0", "proc-macro2", "quote", - "shellexpand 2.1.2", "syn 2.0.106", "witx", ] [[package]] name = "wiggle-macro" -version = "29.0.1" +version = "33.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08c5c473d4198e6c2d377f3809f713ff0c110cab88a0805ae099a82119ee250c" +checksum = "d873bb5b59ca703b5e41562e96a4796d1af61bf4cf80bf8a7abda755a380ec1c" dependencies = [ "proc-macro2", "quote", @@ -19126,18 +19199,19 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "winch-codegen" -version = "29.0.1" +version = "33.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f849ef2c5f46cb0a20af4b4487aaa239846e52e2c03f13fa3c784684552859c" +checksum = "7914c296fbcef59d1b89a15e82384d34dc9669bc09763f2ef068a28dd3a64ebf" dependencies = [ "anyhow", + "cranelift-assembler-x64", "cranelift-codegen", "gimli 0.31.1", "regalloc2", "smallvec", "target-lexicon 0.13.3", - "thiserror 1.0.69", - "wasmparser 0.221.3", + "thiserror 2.0.17", + "wasmparser 0.229.0", "wasmtime-cranelift", "wasmtime-environ", ] @@ -20035,9 +20109,9 @@ dependencies = [ [[package]] name = "wit-parser" -version = "0.221.3" +version = "0.227.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "896112579ed56b4a538b07a3d16e562d101ff6265c46b515ce0c701eef16b2ac" +checksum = "ddf445ed5157046e4baf56f9138c124a0824d4d1657e7204d71886ad8ce2fc11" dependencies = [ "anyhow", "id-arena", @@ -20048,14 +20122,14 @@ dependencies = [ "serde_derive", "serde_json", "unicode-xid", - "wasmparser 0.221.3", + "wasmparser 0.227.1", ] [[package]] name = "wit-parser" -version = "0.227.1" +version = "0.229.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddf445ed5157046e4baf56f9138c124a0824d4d1657e7204d71886ad8ce2fc11" +checksum = "459c6ba62bf511d6b5f2a845a2a736822e38059c1cfa0b644b467bbbfae4efa6" dependencies = [ "anyhow", "id-arena", @@ -20066,7 +20140,7 @@ dependencies = [ "serde_derive", "serde_json", "unicode-xid", - "wasmparser 0.227.1", + "wasmparser 0.229.0", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 903d17fc3378519d3e632f63c1a1a0e08e6513cb..f46ffa2583c022be8704e95684ddce65b19d3fab 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -663,7 +663,7 @@ tokio-socks = { version = "0.5.2", default-features = false, features = ["future toml = "0.8" toml_edit = { version = "0.22", default-features = false, features = ["display", "parse", "serde"] } tower-http = "0.4.4" -tree-sitter = { version = "0.25.10", features = ["wasm"] } +tree-sitter = { version = "0.26", features = ["wasm"] } tree-sitter-bash = "0.25.1" tree-sitter-c = "0.23" tree-sitter-cpp = { git = "https://github.com/tree-sitter/tree-sitter-cpp", rev = "5cb9b693cfd7bfacab1d9ff4acac1a4150700609" } @@ -697,7 +697,7 @@ uuid = { version = "1.1.2", features = ["v4", "v5", "v7", "serde"] } walkdir = "2.5" wasm-encoder = "0.221" wasmparser = "0.221" -wasmtime = { version = "29", default-features = false, features = [ +wasmtime = { version = "33", default-features = false, features = [ "async", "demangle", "runtime", @@ -706,7 +706,7 @@ wasmtime = { version = "29", default-features = false, features = [ "incremental-cache", "parallel-compilation", ] } -wasmtime-wasi = "29" +wasmtime-wasi = "33" wax = "0.6" which = "6.0.0" windows-core = "0.61" diff --git a/crates/editor/src/jsx_tag_auto_close.rs b/crates/editor/src/jsx_tag_auto_close.rs index e22fde313df4b99b7b650775ad7e7397e3c4f813..1d808c968d579569fb595a5a1a0ddaa4dbc718b3 100644 --- a/crates/editor/src/jsx_tag_auto_close.rs +++ b/crates/editor/src/jsx_tag_auto_close.rs @@ -19,7 +19,7 @@ pub struct JsxTagCompletionState { /// that corresponds to the tag name /// Note that this is not configurable, i.e. we assume the first /// named child of a tag node is the tag name -const TS_NODE_TAG_NAME_CHILD_INDEX: usize = 0; +const TS_NODE_TAG_NAME_CHILD_INDEX: u32 = 0; /// Maximum number of parent elements to walk back when checking if an open tag /// is already closed. diff --git a/crates/extension_host/src/wasm_host.rs b/crates/extension_host/src/wasm_host.rs index cecaf2039bc6dc049ece1177700a14eead3d86bc..a6e5768f16243ce6c6a4d250002e29d5db06a071 100644 --- a/crates/extension_host/src/wasm_host.rs +++ b/crates/extension_host/src/wasm_host.rs @@ -45,7 +45,7 @@ use wasmtime::{ CacheStore, Engine, Store, component::{Component, ResourceTable}, }; -use wasmtime_wasi::{self as wasi, WasiView}; +use wasmtime_wasi::p2::{self as wasi, IoView as _}; use wit::Extension; pub struct WasmHost { @@ -685,8 +685,8 @@ impl WasmHost { .await .context("failed to create extension work dir")?; - let file_perms = wasi::FilePerms::all(); - let dir_perms = wasi::DirPerms::all(); + let file_perms = wasmtime_wasi::FilePerms::all(); + let dir_perms = wasmtime_wasi::DirPerms::all(); let path = SanitizedPath::new(&extension_work_dir).to_string(); #[cfg(target_os = "windows")] let path = path.replace('\\', "/"); @@ -856,11 +856,13 @@ impl WasmState { } } -impl wasi::WasiView for WasmState { +impl wasi::IoView for WasmState { fn table(&mut self) -> &mut ResourceTable { &mut self.table } +} +impl wasi::WasiView for WasmState { fn ctx(&mut self) -> &mut wasi::WasiCtx { &mut self.ctx } diff --git a/crates/extension_host/src/wasm_host/wit.rs b/crates/extension_host/src/wasm_host/wit.rs index 5058c63365021a00dc9abf9fc05e9085757e161e..e080915b4fe1f18325843961db36e2fbc16bd418 100644 --- a/crates/extension_host/src/wasm_host/wit.rs +++ b/crates/extension_host/src/wasm_host/wit.rs @@ -45,7 +45,7 @@ pub fn new_linker( f: impl Fn(&mut Linker, fn(&mut WasmState) -> &mut WasmState) -> Result<()>, ) -> Linker { let mut linker = Linker::new(&wasm_engine(executor)); - wasmtime_wasi::add_to_linker_async(&mut linker).unwrap(); + wasmtime_wasi::p2::add_to_linker_async(&mut linker).unwrap(); f(&mut linker, wasi_view).unwrap(); linker } diff --git a/crates/extension_host/src/wasm_host/wit/since_v0_8_0.rs b/crates/extension_host/src/wasm_host/wit/since_v0_8_0.rs index a2776f9f3b5b055d00787fb59c9bbca582352b1f..b2e0a1a4fbbf302a41cd509c27df9f52dc9a788d 100644 --- a/crates/extension_host/src/wasm_host/wit/since_v0_8_0.rs +++ b/crates/extension_host/src/wasm_host/wit/since_v0_8_0.rs @@ -1,7 +1,7 @@ use crate::wasm_host::wit::since_v0_6_0::{ dap::{ - AttachRequest, BuildTaskDefinition, BuildTaskDefinitionTemplatePayload, LaunchRequest, - StartDebuggingRequestArguments, TcpArguments, TcpArgumentsTemplate, + BuildTaskDefinition, BuildTaskDefinitionTemplatePayload, StartDebuggingRequestArguments, + TcpArguments, TcpArgumentsTemplate, }, slash_command::SlashCommandOutputSection, }; diff --git a/crates/language/src/syntax_map/syntax_map_tests.rs b/crates/language/src/syntax_map/syntax_map_tests.rs index 1eb63772760719a381d16795ecde0c4a3293c789..2a9f7f172388f99543ac979938a3e8fec9db541a 100644 --- a/crates/language/src/syntax_map/syntax_map_tests.rs +++ b/crates/language/src/syntax_map/syntax_map_tests.rs @@ -1133,8 +1133,8 @@ fn check_interpolation( check_node_edits( depth, range, - old_node.child(i).unwrap(), - new_node.child(i).unwrap(), + old_node.child(i as u32).unwrap(), + new_node.child(i as u32).unwrap(), old_buffer, new_buffer, edits, diff --git a/crates/vim/src/object.rs b/crates/vim/src/object.rs index f11386d02d6846343645b6c7514603f16396163c..98c14855a3e20623c87d6204c1c4233f20008cbb 100644 --- a/crates/vim/src/object.rs +++ b/crates/vim/src/object.rs @@ -911,7 +911,7 @@ pub fn surrounding_html_tag( while let Some(cur_node) = last_child_node { if cur_node.child_count() >= 2 { let first_child = cur_node.child(0); - let last_child = cur_node.child(cur_node.child_count() - 1); + let last_child = cur_node.child(cur_node.child_count() as u32 - 1); if let (Some(first_child), Some(last_child)) = (first_child, last_child) { let open_tag = open_tag(buffer.chars_for_range(first_child.byte_range())); let close_tag = close_tag(buffer.chars_for_range(last_child.byte_range())); From 7098952a1ca2291d113a18b08477ee8a5aa663d9 Mon Sep 17 00:00:00 2001 From: Katie Geer Date: Tue, 16 Dec 2025 10:47:24 -0800 Subject: [PATCH 396/621] docs: Migrate from Intellij (#44928) Adding migration guide for Intellij as well as a doc of rules for agents to help write future docs Release Notes: - N/A... --- docs/.rules | 157 +++++++++++++++ docs/src/SUMMARY.md | 3 +- docs/src/migrate/intellij.md | 357 +++++++++++++++++++++++++++++++++++ 3 files changed, 516 insertions(+), 1 deletion(-) create mode 100644 docs/.rules create mode 100644 docs/src/migrate/intellij.md diff --git a/docs/.rules b/docs/.rules new file mode 100644 index 0000000000000000000000000000000000000000..17c0e97450ce50f6846c865d58289257f2008f5c --- /dev/null +++ b/docs/.rules @@ -0,0 +1,157 @@ +# Zed Documentation Guidelines + +## Voice and Tone + +### Core Principles + +- **Practical over promotional**: Focus on what users can do, not on selling Zed. Avoid marketing language like "powerful," "revolutionary," or "best-in-class." +- **Honest about limitations**: When Zed lacks a feature or doesn't match another tool's depth, say so directly. Pair limitations with workarounds or alternative workflows. +- **Direct and concise**: Use short sentences. Get to the point. Developers are scanning, not reading novels. +- **Second person**: Address the reader as "you." Avoid "the user" or "one." +- **Present tense**: "Zed opens the file" not "Zed will open the file." + +### What to Avoid + +- Superlatives without substance ("incredibly fast," "seamlessly integrated") +- Hedging language ("simply," "just," "easily")—if something is simple, the instructions will show it +- Apologetic tone for missing features—state the limitation and move on +- Comparisons that disparage other tools—be factual, not competitive +- Meta-commentary about honesty ("the honest take is...", "to be frank...", "honestly...")—let honesty show through frank assessments, not announcements + +## Content Structure + +### Page Organization + +1. **Start with the goal**: Open with what the reader will accomplish, not background +2. **Front-load the action**: Put the most common task first, edge cases later +3. **Use headers liberally**: Readers scan; headers help them find what they need +4. **End with "what's next"**: Link to related docs or logical next steps + +### Section Patterns + +For how-to content: +1. Brief context (1-2 sentences max) +2. Steps or instructions +3. Example (code block or screenshot reference) +4. Tips or gotchas (if any) + +For reference content: +1. What it is (definition) +2. How to access/configure it +3. Options/parameters table +4. Examples + +## Formatting Conventions + +### Keybindings + +- Use backticks for key combinations: `Cmd+Shift+P` +- Show both macOS and Linux/Windows when they differ: `Cmd+,` (macOS) or `Ctrl+,` (Linux/Windows) +- Use `+` to join simultaneous keys, space for sequences: `Cmd+K Cmd+C` + +### Code and Settings + +- Inline code for setting names, file paths, commands: `format_on_save`, `.zed/settings.json`, `zed .` +- Code blocks for JSON config, multi-line commands, or file contents +- Always show complete, working examples—not fragments + +### Terminal Commands + +Use `sh` code blocks for terminal commands, not plain backticks: + +```sh +brew install zed-editor/zed/zed +``` + +Not: +``` +brew install zed-editor/zed/zed +``` + +For single inline commands in prose, backticks are fine: `zed .` + +### Tables + +Use tables for: +- Keybinding comparisons between editors +- Settings mappings (e.g., VS Code → Zed) +- Feature comparisons with clear columns + +Format: +``` +| Action | Shortcut | Notes | +| --- | --- | --- | +| Open File | `Cmd+O` | Works from any context | +``` + +### Tips and Notes + +Use blockquote format with bold label: +``` +> **Tip:** Practical advice that helps bridge gaps or saves time. +``` + +Reserve tips for genuinely useful information, not padding. + +## Writing Guidelines + +### Settings Documentation + +- **Settings Editor first**: Show how to find and change settings in the UI before showing JSON +- **JSON as secondary**: Present JSON examples as "Or add this to your settings.json" for users who prefer direct editing +- **Complete examples**: Include the full JSON structure, not just the value + +### Migration Guides + +- **Jobs to be done**: Frame around tasks ("How do I search files?") not features ("File Search Feature") +- **Acknowledge the source**: Respect that users have muscle memory and preferences from their previous editor +- **Keybindings tables**: Essential for migration docs—show what maps, what's different, what's missing +- **Trade-offs section**: Be explicit about what the user gains and loses in the switch + +### Feature Documentation + +- **Start with the default**: Document the out-of-box experience first +- **Configuration options**: Group related settings together +- **Cross-link generously**: Link to related features, settings reference, and relevant guides + +## Terminology + +| Use | Instead of | +| --- | --- | +| folder | directory (in user-facing text) | +| project | workspace (Zed doesn't have workspaces) | +| Settings Editor | settings UI, preferences | +| command palette | command bar, action search | +| language server | LSP (spell out first use, then LSP is fine) | +| panel | tool window, sidebar (be specific: "Project Panel," "Terminal Panel") | + +## Examples + +### Good: Direct and actionable +``` +To format on save, open the Settings Editor (`Cmd+,`) and search for `format_on_save`. Set it to `on`. + +Or add this to your settings.json: +{ + "format_on_save": "on" +} +``` + +### Bad: Wordy and promotional +``` +Zed provides a powerful and seamless formatting experience. Simply navigate to the settings and you'll find the format_on_save option which enables Zed's incredible auto-formatting capabilities. +``` + +### Good: Honest about limitations +``` +Zed doesn't index your project like IntelliJ does. You open a folder and start working immediately—no waiting. The trade-off: cross-project analysis relies on language servers, which may not go as deep. + +**How to adapt:** +- Use `Cmd+Shift+F` for project-wide text search +- Use `Cmd+O` for symbol search (powered by your language server) +``` + +### Bad: Defensive or dismissive +``` +While some users might miss indexing, Zed's approach is actually better because it's faster. +``` diff --git a/docs/src/SUMMARY.md b/docs/src/SUMMARY.md index 6514bd6455d85fe390bebce10096fc4edc5a9f0a..d6dd7a0aef9737fb095e87705e813f87fd0ed683 100644 --- a/docs/src/SUMMARY.md +++ b/docs/src/SUMMARY.md @@ -87,9 +87,10 @@ - [Agent Server Extensions](./extensions/agent-servers.md) - [MCP Server Extensions](./extensions/mcp-extensions.md) -# Migrate +# Coming From... - [VS Code](./migrate/vs-code.md) +- [IntelliJ IDEA](./migrate/intellij.md) # Language Support diff --git a/docs/src/migrate/intellij.md b/docs/src/migrate/intellij.md new file mode 100644 index 0000000000000000000000000000000000000000..d931fde4f1c2cd98db6b154d7009feff6fcb6a5b --- /dev/null +++ b/docs/src/migrate/intellij.md @@ -0,0 +1,357 @@ +# How to Migrate from IntelliJ IDEA to Zed + +This guide covers how to set up Zed if you're coming from IntelliJ IDEA, including keybindings, settings, and the differences you should expect. + +## Install Zed + +Zed is available on macOS, Windows, and Linux. + +For macOS, you can download it from zed.dev/download, or install via Homebrew: + +```sh +brew install --cask zed +``` + +For Windows, download the installer from zed.dev/download, or install via winget: + +```sh +winget install Zed.Zed +``` + +For most Linux users, the easiest way to install Zed is through our installation script: + +```sh +curl -f https://zed.dev/install.sh | sh +``` + +After installation, you can launch Zed from your Applications folder (macOS), Start menu (Windows), or directly from the terminal using: +`zed .` +This opens the current directory in Zed. + +## Set Up the JetBrains Keymap + +If you're coming from IntelliJ, the fastest way to feel at home is to use the JetBrains keymap. During onboarding, you can select it as your base keymap. If you missed that step, you can change it anytime: + +1. Open Settings with `Cmd+,` (macOS) or `Ctrl+,` (Linux/Windows) +2. Search for `base_keymap` +3. Select `JetBrains` + +Or add this directly to your `settings.json`: + +```json +{ + "base_keymap": "JetBrains" +} +``` + +This maps familiar shortcuts like `Shift Shift` for Search Everywhere, `Cmd+O` for Go to Class, and `Cmd+Shift+A` for Find Action. + +## Set Up Editor Preferences + +You can configure settings manually in the Settings Editor. + +To edit your settings: + +1. `Cmd+,` to open the Settings Editor. +2. Run `zed: open settings` in the Command Palette. + +Settings IntelliJ users typically configure first: + +| Zed Setting | What it does | +| ----------------------- | ------------------------------------------------------------------------------- | +| `format_on_save` | Auto-format when saving. Set to `"on"` to enable. | +| `soft_wrap` | Wrap long lines. Options: `"none"`, `"editor_width"`, `"preferred_line_length"` | +| `preferred_line_length` | Column width for wrapping and rulers. Default is 80. | +| `inlay_hints` | Show parameter names and type hints inline, like IntelliJ's hints. | +| `relative_line_numbers` | Useful if you're coming from IdeaVim. | + +Zed also supports per-project settings. Create a `.zed/settings.json` file in your project root to override global settings for that project, similar to how you might use `.idea` folders in IntelliJ. + +> **Tip:** If you're joining an existing project, check `format_on_save` before making your first commit. Otherwise you might accidentally reformat an entire file when you only meant to change one line. + +## Open or Create a Project + +After setup, press `Cmd+Shift+O` (with JetBrains keymap) to open a folder. This becomes your workspace in Zed. Unlike IntelliJ, there's no project configuration wizard, no `.iml` files, and no SDK setup required. + +To start a new project, create a directory using your terminal or file manager, then open it in Zed. The editor will treat that folder as the root of your project. + +You can also launch Zed from the terminal inside any folder with: +`zed .` + +Once inside a project: + +- Use `Cmd+Shift+O` or `Cmd+E` to jump between files quickly (like IntelliJ's "Recent Files") +- Use `Cmd+Shift+A` or `Shift Shift` to open the Command Palette (like IntelliJ's "Search Everywhere") +- Use `Cmd+O` to search for symbols (like IntelliJ's "Go to Class") + +Open buffers appear as tabs across the top. The sidebar shows your file tree and Git status. Toggle it with `Cmd+1` (just like IntelliJ's Project tool window). + +## Differences in Keybindings + +If you chose the JetBrains keymap during onboarding, most of your shortcuts should already feel familiar. Here's a quick reference for how Zed compares to IntelliJ. + +### Common Shared Keybindings (Zed with JetBrains keymap ↔ IntelliJ) + +| Action | Shortcut | +| ----------------------------- | ----------------------- | +| Search Everywhere | `Shift Shift` | +| Find Action / Command Palette | `Cmd + Shift + A` | +| Go to File | `Cmd + Shift + O` | +| Go to Symbol / Class | `Cmd + O` | +| Recent Files | `Cmd + E` | +| Go to Definition | `Cmd + B` | +| Find Usages | `Alt + F7` | +| Rename Symbol | `Shift + F6` | +| Reformat Code | `Cmd + Alt + L` | +| Toggle Project Panel | `Cmd + 1` | +| Toggle Terminal | `Alt + F12` | +| Duplicate Line | `Cmd + D` | +| Delete Line | `Cmd + Backspace` | +| Move Line Up/Down | `Shift + Alt + Up/Down` | +| Expand/Shrink Selection | `Alt + Up/Down` | +| Comment Line | `Cmd + /` | +| Go Back / Forward | `Cmd + [` / `Cmd + ]` | +| Toggle Breakpoint | `Ctrl + F8` | + +### Different Keybindings (IntelliJ → Zed) + +| Action | IntelliJ | Zed (JetBrains keymap) | +| ---------------------- | ----------- | ------------------------ | +| File Structure | `Cmd + F12` | `Cmd + F12` (outline) | +| Navigate to Next Error | `F2` | `F2` | +| Run | `Ctrl + R` | `Ctrl + Alt + R` (tasks) | +| Debug | `Ctrl + D` | `Alt + Shift + F9` | +| Stop | `Cmd + F2` | `Ctrl + F2` | + +### Unique to Zed + +| Action | Shortcut | Notes | +| ----------------- | -------------------------- | ------------------------------ | +| Toggle Right Dock | `Cmd + R` | Assistant panel, notifications | +| Split Panes | `Cmd + K`, then arrow keys | Create splits in any direction | + +### How to Customize Keybindings + +- Open the Command Palette (`Cmd+Shift+A` or `Shift Shift`) +- Run `Zed: Open Keymap Editor` + +This opens a list of all available bindings. You can override individual shortcuts or remove conflicts. + +Zed also supports key sequences (multi-key shortcuts). + +## Differences in User Interfaces + +### No Indexing + +If you've used IntelliJ on large projects, you know the wait: "Indexing..." can take anywhere from 30 seconds to 15 minutes depending on project size. IntelliJ builds a comprehensive index of your entire codebase to power its code intelligence, and it re-indexes when dependencies change or after builds. + +Zed doesn't index. You open a folder and start working immediately. File search and navigation work instantly regardless of project size. + +The trade-off is real: IntelliJ's index powers features like finding all usages across your entire codebase, understanding class hierarchies, and detecting dead code. Zed delegates this work to language servers, which may not analyze as deeply or as broadly. + +**How to adapt:** + +- For project-wide symbol search, use `Cmd+O` / Go to Symbol (relies on your language server) +- For finding files by name, use `Cmd+Shift+O` / Go to File +- For text search across files, use `Cmd+Shift+F`—this is fast even on large codebases +- If you need deep static analysis for JVM code, consider running IntelliJ's inspections as a separate step or using standalone tools like Checkstyle, PMD, or SpotBugs + +### LSP vs. Native Language Intelligence + +IntelliJ has its own language analysis engine built from scratch for each supported language. For Java, Kotlin, and other JVM languages, this engine understands your code deeply: it resolves types, tracks data flow, knows about framework annotations, and offers dozens of specialized refactorings. + +Zed uses the Language Server Protocol (LSP) for code intelligence. Each language has its own server: `jdtls` for Java, `rust-analyzer` for Rust, and so on. + +For some languages, the LSP experience is excellent. TypeScript, Rust, and Go have mature language servers that provide fast, accurate completions, diagnostics, and refactorings. For JVM languages, the gap might be more noticeable. The Eclipse-based Java language server is capable, but it won't match IntelliJ's depth for things like: + +- Spring and Jakarta EE annotation processing +- Complex refactorings (extract interface, pull members up, change signature with all callers) +- Framework-aware inspections +- Automatic import optimization with custom ordering rules + +**How to adapt:** + +- Use `Alt+Enter` for available code actions—the list will vary by language server +- For Java, ensure `jdtls` is properly configured with your JDK path in settings + +### No Project Model + +IntelliJ manages projects through `.idea` folders containing XML configuration files, `.iml` module definitions, SDK assignments, and run configurations. This model enables IntelliJ to understand multi-module projects, manage dependencies automatically, and persist complex run/debug setups. + +Zed has no project model. A project is a folder. There's no wizard, no SDK selection screen, no module configuration. + +This means: + +- Build commands are manual. Zed doesn't detect Maven or Gradle projects. +- Run configurations don't exist. You define tasks or use the terminal. +- SDK management is external. Your language server uses whatever JDK is on your PATH. +- There are no module boundaries. Zed sees folders, not project structure. + +**How to adapt:** + +- Create a `.zed/settings.json` in your project root for project-specific settings +- Define common commands in `tasks.json` (open via Command Palette: `zed: open tasks`): + +```json +[ + { + "label": "build", + "command": "./gradlew build" + }, + { + "label": "run", + "command": "./gradlew bootRun" + }, + { + "label": "test current file", + "command": "./gradlew test --tests $ZED_STEM" + } +] +``` + +- Use `Ctrl+Alt+R` to run tasks quickly +- Lean on your terminal (`Alt+F12`) for anything tasks don't cover +- For multi-module projects, you can open each module as a separate Zed window, or open the root and navigate via file finder + +### No Framework Integration + +IntelliJ's value for enterprise Java development comes largely from its framework integration. Spring beans are understood and navigable. JPA entities get special treatment. Endpoints are indexed and searchable. Jakarta EE annotations modify how the IDE analyzes your code. + +Zed has none of this. The language server sees Java code as Java code, so it doesn't understand that `@Autowired` means something special or that this class is a REST controller. + +Similarly for other ecosystems: no Rails integration, no Django awareness, no Angular/React-specific tooling beyond what the TypeScript language server provides. + +**How to adapt:** + +- Use grep and file search liberally. `Cmd+Shift+F` with a regex can find endpoint definitions, bean names, or annotation usages. +- Rely on your language server's "find references" (`Alt+F7`) for navigation—it works, just without framework context +- For Spring Boot, keep the Actuator endpoints or a separate tool for understanding bean wiring +- Consider using framework-specific CLI tools (Spring CLI, Rails generators) from Zed's terminal + +> **Tip:** For database work, pick up a dedicated tool like DataGrip, DBeaver, or TablePlus. Many developers who switch to Zed keep DataGrip around specifically for SQL—it integrates well with your existing JetBrains license. + +If your daily work depends heavily on framework-aware navigation and refactoring, you'll feel the gap. Zed works best when you're comfortable navigating code through search rather than specialized tooling, or when your language has strong LSP support that covers most of what you need. + +### Tool Windows vs. Docks + +IntelliJ organizes auxiliary views into numbered tool windows (Project = 1, Git = 9, Terminal = Alt+F12, etc.). Zed uses a similar concept called "docks": + +| IntelliJ Tool Window | Zed Equivalent | Shortcut (JetBrains keymap) | +| -------------------- | -------------- | --------------------------- | +| Project (1) | Project Panel | `Cmd + 1` | +| Git (9 or Cmd+0) | Git Panel | `Cmd + 0` | +| Terminal (Alt+F12) | Terminal Panel | `Alt + F12` | +| Structure (7) | Outline Panel | `Cmd + 7` | +| Problems (6) | Diagnostics | `Cmd + 6` | +| Debug (5) | Debug Panel | `Cmd + 5` | + +Zed has three dock positions: left, bottom, and right. Panels can be moved between docks by dragging or through settings. + +> **Tip:** IntelliJ has an "Override IDE shortcuts" setting that lets terminal shortcuts like `Ctrl+Left/Right` work normally. In Zed, terminal keybindings are separate—check your keymap if familiar shortcuts aren't working in the terminal panel. + +### Debugging + +Both IntelliJ and Zed offer integrated debugging, but the experience differs: + +- Zed's debugger uses the Debug Adapter Protocol (DAP), supporting multiple languages +- Set breakpoints with `Ctrl+F8` +- Start debugging with `Alt+Shift+F9` +- Step through code with `F7` (step into), `F8` (step over), `Shift+F8` (step out) +- Continue execution with `F9` + +The Debug Panel (`Cmd+5`) shows variables, call stack, and breakpoints—similar to IntelliJ's Debug tool window. + +### Extensions vs. Plugins + +IntelliJ has a massive plugin ecosystem covering everything from language support to database tools to deployment integrations. + +Zed's extension ecosystem is smaller and more focused: + +- Language support and syntax highlighting +- Themes +- Slash commands for AI +- Context servers + +Several features that require plugins in other editors are built into Zed: + +- Real-time collaboration with voice chat +- AI coding assistance +- Built-in terminal +- Task runner +- LSP-based code intelligence + +You won't find one-to-one replacements for every IntelliJ plugin, especially for framework-specific tools, database clients, or application server integrations. For those workflows, you may need to use external tools alongside Zed. + +## Collaboration in Zed vs. IntelliJ + +IntelliJ offers Code With Me as a separate plugin for collaboration. Zed has collaboration built into the core experience. + +- Open the Collab Panel in the left dock +- Create a channel and [invite your collaborators](https://zed.dev/docs/collaboration#inviting-a-collaborator) to join +- [Share your screen or your codebase](https://zed.dev/docs/collaboration#share-a-project) directly + +Once connected, you'll see each other's cursors, selections, and edits in real time. Voice chat is included. There's no need for separate tools or third-party logins. + +## Using AI in Zed + +If you're used to AI assistants in IntelliJ (like GitHub Copilot or JetBrains AI), Zed offers similar capabilities with more flexibility. + +### Configuring GitHub Copilot + +1. Open Settings with `Cmd+,` (macOS) or `Ctrl+,` (Linux/Windows) +2. Navigate to **AI → Edit Predictions** +3. Click **Configure** next to "Configure Providers" +4. Under **GitHub Copilot**, click **Sign in to GitHub** + +Once signed in, just start typing. Zed will offer suggestions inline for you to accept. + +### Additional AI Options + +To use other AI models in Zed, you have several options: + +- Use Zed's hosted models, with higher rate limits. Requires [authentication](https://zed.dev/docs/accounts.html) and subscription to [Zed Pro](https://zed.dev/docs/ai/subscription.html). +- Bring your own [API keys](https://zed.dev/docs/ai/llm-providers.html), no authentication needed +- Use [external agents like Claude Code](https://zed.dev/docs/ai/external-agents.html) + +## Advanced Config and Productivity Tweaks + +Zed exposes advanced settings for power users who want to fine-tune their environment. + +Here are a few useful tweaks: + +**Format on Save:** + +```json +"format_on_save": "on" +``` + +**Enable direnv support:** + +```json +"load_direnv": "shell_hook" +``` + +**Configure language servers**: For Java development, you may want to configure the Java language server in your settings: + +```json +{ + "lsp": { + "jdtls": { + "settings": { + "java_home": "/path/to/jdk" + } + } + } +} +``` + +## Next Steps + +Now that you're set up, here are some resources to help you get the most out of Zed: + +- [Configuring Zed](../configuring-zed.md) — Customize settings, themes, and editor behavior +- [Key Bindings](../key-bindings.md) — Learn how to customize and extend your keymap +- [Tasks](../tasks.md) — Set up build and run commands for your projects +- [AI Features](../ai/overview.md) — Explore Zed's AI capabilities beyond code completion +- [Collaboration](../collaboration/overview.md) — Share your projects and code together in real time +- [Languages](../languages.md) — Language-specific setup guides, including Java and Kotlin From e4029c13c9b4b8153296a81b1550f10b78f3e0ed Mon Sep 17 00:00:00 2001 From: Bennet Bo Fenner Date: Tue, 16 Dec 2025 19:55:34 +0100 Subject: [PATCH 397/621] prompt_store: Remove unused PromptId::EditWorkflow (#45018) Release Notes: - N/A --- crates/prompt_store/src/prompt_store.rs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/crates/prompt_store/src/prompt_store.rs b/crates/prompt_store/src/prompt_store.rs index b69051b067c95674d8d09be76c5b4c607fd03f67..6417a7ad214c84258d4cc18eddc0b1c1d785ca18 100644 --- a/crates/prompt_store/src/prompt_store.rs +++ b/crates/prompt_store/src/prompt_store.rs @@ -55,7 +55,6 @@ pub struct PromptMetadata { #[serde(tag = "kind")] pub enum PromptId { User { uuid: UserPromptId }, - EditWorkflow, CommitMessage, } @@ -74,20 +73,19 @@ impl PromptId { pub fn is_built_in(&self) -> bool { match self { Self::User { .. } => false, - Self::EditWorkflow | Self::CommitMessage => true, + Self::CommitMessage => true, } } pub fn can_edit(&self) -> bool { match self { Self::User { .. } | Self::CommitMessage => true, - Self::EditWorkflow => false, } } pub fn default_content(&self) -> Option<&'static str> { match self { - Self::User { .. } | Self::EditWorkflow => None, + Self::User { .. } => None, Self::CommitMessage => Some(include_str!("../../git_ui/src/commit_message_prompt.txt")), } } @@ -119,7 +117,6 @@ impl std::fmt::Display for PromptId { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { PromptId::User { uuid } => write!(f, "{}", uuid.0), - PromptId::EditWorkflow => write!(f, "Edit workflow"), PromptId::CommitMessage => write!(f, "Commit message"), } } @@ -202,11 +199,6 @@ impl PromptStore { let metadata = db_env.create_database(&mut txn, Some("metadata.v2"))?; let bodies = db_env.create_database(&mut txn, Some("bodies.v2"))?; - // Remove edit workflow prompt, as we decided to opt into it using - // a slash command instead. - metadata.delete(&mut txn, &PromptId::EditWorkflow).ok(); - bodies.delete(&mut txn, &PromptId::EditWorkflow).ok(); - // Insert default commit message prompt if not present if metadata.get(&txn, &PromptId::CommitMessage)?.is_none() { metadata.put( From 91a976bf7b016f94ca400250bf116d6a25c1180a Mon Sep 17 00:00:00 2001 From: Josh Robson Chase Date: Tue, 16 Dec 2025 14:00:46 -0500 Subject: [PATCH 398/621] nix: Pin `cargo-about` to 0.8.2 (#44901) `cargo-about` got pinned to 0.8.2 in https://github.com/zed-industries/zed/pull/44012, but this isn't exactly "easy" to accomplish in nix. The version of nixpkgs in the flake inputs uses the proper version, but if you override the nixpkgs input or use the provided overlay, you might end up trying to build with a bad version of `cargo-about`. Since nixpkgs is versioned as a whole, your options are (in rough order of desirability): 1. Hope that nixpkgs simply includes multiple versions of the same package (common for things with stable major versions/breaking changes) 1. Use either `override` or `overrideAttrs` to provide different version/source attributes 1. Depend on multiple versions of nixpkgs to get the specific versions of the packages you want 1. Vendor the whole package build from a specific point in its history Option 1 is out - there's only one version of cargo-about in nixpkgs. Option 2 doesn't seem to work due to the way that `buildRustPackage` wraps the base `mkDerivation` which provides the `override` extension functions. There *might* be a way to make this work, but I haven't dug into the `buildRustPackage` internals enough to say for sure. Edit: I apparently can't read and the problems with this option were already solved for `cargo-bundle`, so this is the final approach! Option 3 always just feels a bit icky and opaque to me. Leaving Option 4. I usually find this approach to be "fine" for small package definitions that aren't actually much bigger than the overridden attributes would have be with the Option 2 approach. ~~Since the `cargo-about` definition is nice and small, this is the approach I chose.~~ ~~Since this has the potential to require a build of `cargo-about`, I'm only actually invoking its build if the provided version is wrong - more or less the same thing that's happening in the `generate-licenses` script, but nix-y.~~ Edit: Shouldn't ever cause a rebuild since there's only one 0.8.2 input source/vendored deps, so anything that was already using it will already be cached. I'm also updating nixpkgs to the latest unstable which currently has `cargo-about 0.8.4` to prove that this works. Unrelatedly, I also ran `nix fmt` as a drive-by change. `nix/build.nix` was a bit out of spec. Release Notes: - N/A --- flake.lock | 8 +-- nix/build.nix | 169 ++++++++++++++++++++++++++++---------------------- 2 files changed, 100 insertions(+), 77 deletions(-) diff --git a/flake.lock b/flake.lock index 3074b947ef51c387b5d20aba85478636f48de557..520dcb3f7469319dbf755bfd70103cb5de1b2c48 100644 --- a/flake.lock +++ b/flake.lock @@ -32,11 +32,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 315532800, - "narHash": "sha256-5CwQ80ucRHiqVbMEEbTFnjz70/axSJ0aliyzSaFSkmY=", - "rev": "f6b44b2401525650256b977063dbcf830f762369", + "lastModified": 1765772535, + "narHash": "sha256-I715zWsdVZ+CipmLtoCAeNG0etQywiWRE5PaWntnaYk=", + "rev": "09b8fda8959d761445f12b55f380d90375a1d6bb", "type": "tarball", - "url": "https://releases.nixos.org/nixpkgs/nixpkgs-25.11pre891648.f6b44b240152/nixexprs.tar.xz" + "url": "https://releases.nixos.org/nixpkgs/nixpkgs-26.05pre911985.09b8fda8959d/nixexprs.tar.xz" }, "original": { "type": "tarball", diff --git a/nix/build.nix b/nix/build.nix index 484049a421f8de839fc157a45795637a12bd23b4..16b03e9a53bd2118c9b5bf45cf8fb7720ee5022b 100644 --- a/nix/build.nix +++ b/nix/build.nix @@ -83,70 +83,94 @@ let cargoLock = ../Cargo.lock; - nativeBuildInputs = - [ - cmake - copyDesktopItems - curl - perl - pkg-config - protobuf - cargo-about - rustPlatform.bindgenHook - ] - ++ lib.optionals stdenv'.hostPlatform.isLinux [ makeWrapper ] - ++ lib.optionals stdenv'.hostPlatform.isDarwin [ - (cargo-bundle.overrideAttrs ( - new: old: { - version = "0.6.1-zed"; - src = fetchFromGitHub { - owner = "zed-industries"; - repo = "cargo-bundle"; - rev = "2be2669972dff3ddd4daf89a2cb29d2d06cad7c7"; - hash = "sha256-cSvW0ND148AGdIGWg/ku0yIacVgW+9f1Nsi+kAQxVrI="; - }; - cargoHash = "sha256-urn+A3yuw2uAO4HGmvQnKvWtHqvG9KHxNCCWTiytE4k="; - - # NOTE: can drop once upstream uses `finalAttrs` here: - # https://github.com/NixOS/nixpkgs/blob/10214747f5e6e7cb5b9bdf9e018a3c7b3032f5af/pkgs/build-support/rust/build-rust-package/default.nix#L104 - # - # See (for context): https://github.com/NixOS/nixpkgs/pull/382550 - cargoDeps = rustPlatform.fetchCargoVendor { - inherit (new) src; - hash = new.cargoHash; - patches = new.cargoPatches or []; - name = new.cargoDepsName or new.finalPackage.name; - }; - } - )) - ]; - - buildInputs = - [ - curl - fontconfig - freetype - # TODO: need staticlib of this for linking the musl remote server. - # should make it a separate derivation/flake output - # see https://crane.dev/examples/cross-musl.html - libgit2 - openssl - sqlite - zlib - zstd - ] - ++ lib.optionals stdenv'.hostPlatform.isLinux [ - alsa-lib - libxkbcommon - wayland - gpu-lib - xorg.libX11 - xorg.libxcb - ] - ++ lib.optionals stdenv'.hostPlatform.isDarwin [ - apple-sdk_15 - (darwinMinVersionHook "10.15") - ]; + nativeBuildInputs = [ + cmake + copyDesktopItems + curl + perl + pkg-config + protobuf + # Pin cargo-about to 0.8.2. Newer versions don't work with the current license identifiers + # See https://github.com/zed-industries/zed/pull/44012 + (cargo-about.overrideAttrs ( + new: old: rec { + version = "0.8.2"; + + src = fetchFromGitHub { + owner = "EmbarkStudios"; + repo = "cargo-about"; + tag = version; + sha256 = "sha256-cNKZpDlfqEXeOE5lmu79AcKOawkPpk4PQCsBzNtIEbs="; + }; + + cargoHash = "sha256-NnocSs6UkuF/mCM3lIdFk+r51Iz2bHuYzMT/gEbT/nk="; + + # NOTE: can drop once upstream uses `finalAttrs` here: + # https://github.com/NixOS/nixpkgs/blob/10214747f5e6e7cb5b9bdf9e018a3c7b3032f5af/pkgs/build-support/rust/build-rust-package/default.nix#L104 + # + # See (for context): https://github.com/NixOS/nixpkgs/pull/382550 + cargoDeps = rustPlatform.fetchCargoVendor { + inherit (new) src; + hash = new.cargoHash; + patches = new.cargoPatches or [ ]; + name = new.cargoDepsName or new.finalPackage.name; + }; + } + )) + rustPlatform.bindgenHook + ] + ++ lib.optionals stdenv'.hostPlatform.isLinux [ makeWrapper ] + ++ lib.optionals stdenv'.hostPlatform.isDarwin [ + (cargo-bundle.overrideAttrs ( + new: old: { + version = "0.6.1-zed"; + src = fetchFromGitHub { + owner = "zed-industries"; + repo = "cargo-bundle"; + rev = "2be2669972dff3ddd4daf89a2cb29d2d06cad7c7"; + hash = "sha256-cSvW0ND148AGdIGWg/ku0yIacVgW+9f1Nsi+kAQxVrI="; + }; + cargoHash = "sha256-urn+A3yuw2uAO4HGmvQnKvWtHqvG9KHxNCCWTiytE4k="; + + # NOTE: can drop once upstream uses `finalAttrs` here: + # https://github.com/NixOS/nixpkgs/blob/10214747f5e6e7cb5b9bdf9e018a3c7b3032f5af/pkgs/build-support/rust/build-rust-package/default.nix#L104 + # + # See (for context): https://github.com/NixOS/nixpkgs/pull/382550 + cargoDeps = rustPlatform.fetchCargoVendor { + inherit (new) src; + hash = new.cargoHash; + patches = new.cargoPatches or [ ]; + name = new.cargoDepsName or new.finalPackage.name; + }; + } + )) + ]; + + buildInputs = [ + curl + fontconfig + freetype + # TODO: need staticlib of this for linking the musl remote server. + # should make it a separate derivation/flake output + # see https://crane.dev/examples/cross-musl.html + libgit2 + openssl + sqlite + zlib + zstd + ] + ++ lib.optionals stdenv'.hostPlatform.isLinux [ + alsa-lib + libxkbcommon + wayland + gpu-lib + xorg.libX11 + xorg.libxcb + ] + ++ lib.optionals stdenv'.hostPlatform.isDarwin [ + apple-sdk_15 + (darwinMinVersionHook "10.15") + ]; cargoExtraArgs = "-p zed -p cli --locked --features=gpui/runtime_shaders"; @@ -177,7 +201,7 @@ let ZED_UPDATE_EXPLANATION = "Zed has been installed using Nix. Auto-updates have thus been disabled."; RELEASE_VERSION = version; LK_CUSTOM_WEBRTC = livekit-libwebrtc; - PROTOC="${protobuf}/bin/protoc"; + PROTOC = "${protobuf}/bin/protoc"; CARGO_PROFILE = profile; # need to handle some profiles specially https://github.com/rust-lang/cargo/issues/11053 @@ -217,14 +241,13 @@ let # `webrtc-sys` expects a staticlib; nixpkgs' `livekit-webrtc` has been patched to # produce a `dylib`... patching `webrtc-sys`'s build script is the easier option # TODO: send livekit sdk a PR to make this configurable - postPatch = - '' - substituteInPlace webrtc-sys/build.rs --replace-fail \ - "cargo:rustc-link-lib=static=webrtc" "cargo:rustc-link-lib=dylib=webrtc" - '' - + lib.optionalString withGLES '' - cat ${glesConfig} >> .cargo/config/config.toml - ''; + postPatch = '' + substituteInPlace webrtc-sys/build.rs --replace-fail \ + "cargo:rustc-link-lib=static=webrtc" "cargo:rustc-link-lib=dylib=webrtc" + '' + + lib.optionalString withGLES '' + cat ${glesConfig} >> .cargo/config/config.toml + ''; in crates: drv: if hasWebRtcSys crates then From 0c91f061c360468da86bd1cb88768ceae6f71308 Mon Sep 17 00:00:00 2001 From: "Oleksii (Alexey) Orlenko" Date: Tue, 16 Dec 2025 20:22:30 +0100 Subject: [PATCH 399/621] agent_ui: Implement favorite models selection (#44297) This PR solves my main pain point with Zed agent: I have a long list of available models from different providers, and I switch between a few of them depending on the context and the project. In particular, I use the same models from different providers depending on whether I'm working on a personal project or at my day job. Since I only care about a few models (none of which are in "recommended") that are scattered all over the list, switching between them is bothersome, even using search. This change adds a new option in `settings.json` (`agent.favorite_models`) and the UI to manipulate it directly from the list of available models. When any models are marked as favorites, they appear in a dedicated section at the very top of the list. Each model has a small icon button that appears on hover and allows to toggle whether it's marked as favorite. I implemented this on the UI level (i.e. there's no first-party knowledge about favorite models in the agent itself; in theory it could return favorite models as a group but it would make it harder to implement bespoke UI for the favorite models section and it also wouldn't work for text threads which don't use the ACP infrastructure). The feature is only enabled for the native agent but disabled for external agents because we can't easily map their model IDs to settings and there could be weird collisions between them. https://github.com/user-attachments/assets/cf23afe4-3883-45cb-9906-f55de3ea2a97 Closes https://github.com/zed-industries/zed/issues/31507 Release Notes: - Added the ability to mark language models as favorites and pin them to the top of the list. This feature is available in the native Zed agent (including text threads and the inline assistant), but not in external agents via ACP. --------- Co-authored-by: Danilo Leal Co-authored-by: Bennet Bo Fenner --- Cargo.lock | 1 + crates/acp_thread/src/connection.rs | 10 + crates/agent/src/agent.rs | 4 + crates/agent_settings/Cargo.toml | 1 + crates/agent_settings/src/agent_settings.rs | 12 +- crates/agent_ui/src/acp/model_selector.rs | 282 ++++++++++++++++-- .../manage_profiles_modal.rs | 45 ++- crates/agent_ui/src/agent_model_selector.rs | 37 ++- crates/agent_ui/src/agent_ui.rs | 2 + crates/agent_ui/src/favorite_models.rs | 57 ++++ .../agent_ui/src/language_model_selector.rs | 216 ++++++++++++-- crates/agent_ui/src/text_thread_editor.rs | 36 ++- .../src/ui/model_selector_components.rs | 35 ++- crates/settings/src/settings_content/agent.rs | 13 + 14 files changed, 653 insertions(+), 98 deletions(-) create mode 100644 crates/agent_ui/src/favorite_models.rs diff --git a/Cargo.lock b/Cargo.lock index 2d0cb8235d547c5486ffd89e3d54fd8d46a54f0c..6908a8ed5185ea71cc51a34d63990decaaf082d9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -301,6 +301,7 @@ dependencies = [ name = "agent_settings" version = "0.1.0" dependencies = [ + "agent-client-protocol", "anyhow", "cloud_llm_client", "collections", diff --git a/crates/acp_thread/src/connection.rs b/crates/acp_thread/src/connection.rs index 3c8c56b2c02cd775be030cb4c4b05a9c75f0d10f..a670ba601159ec323ad2c88695c30bf4aeae4118 100644 --- a/crates/acp_thread/src/connection.rs +++ b/crates/acp_thread/src/connection.rs @@ -202,6 +202,12 @@ pub trait AgentModelSelector: 'static { fn should_render_footer(&self) -> bool { false } + + /// Whether this selector supports the favorites feature. + /// Only the native agent uses the model ID format that maps to settings. + fn supports_favorites(&self) -> bool { + false + } } #[derive(Debug, Clone, PartialEq, Eq)] @@ -239,6 +245,10 @@ impl AgentModelList { AgentModelList::Grouped(groups) => groups.is_empty(), } } + + pub fn is_flat(&self) -> bool { + matches!(self, AgentModelList::Flat(_)) + } } #[cfg(feature = "test-support")] diff --git a/crates/agent/src/agent.rs b/crates/agent/src/agent.rs index 693d3abd4497c057a75b4f01c07bd51f311f1fdb..5e16f74682ef95a4e990ed5a124a0d6031acfb0e 100644 --- a/crates/agent/src/agent.rs +++ b/crates/agent/src/agent.rs @@ -1164,6 +1164,10 @@ impl acp_thread::AgentModelSelector for NativeAgentModelSelector { fn should_render_footer(&self) -> bool { true } + + fn supports_favorites(&self) -> bool { + true + } } impl acp_thread::AgentConnection for NativeAgentConnection { diff --git a/crates/agent_settings/Cargo.toml b/crates/agent_settings/Cargo.toml index 8ddcac24fe054d1226f2bbac49498fd35d6ed1c3..0d7163549f0a4b172773c9ac95dcbc84b7212667 100644 --- a/crates/agent_settings/Cargo.toml +++ b/crates/agent_settings/Cargo.toml @@ -12,6 +12,7 @@ workspace = true path = "src/agent_settings.rs" [dependencies] +agent-client-protocol.workspace = true anyhow.workspace = true cloud_llm_client.workspace = true collections.workspace = true diff --git a/crates/agent_settings/src/agent_settings.rs b/crates/agent_settings/src/agent_settings.rs index 25ca5c78d6b76145a1b1b5d19ac86246ff419d1d..b513ec1a70b6f7ab02382dfa312ea2d4d6a47234 100644 --- a/crates/agent_settings/src/agent_settings.rs +++ b/crates/agent_settings/src/agent_settings.rs @@ -2,7 +2,8 @@ mod agent_profile; use std::sync::Arc; -use collections::IndexMap; +use agent_client_protocol::ModelId; +use collections::{HashSet, IndexMap}; use gpui::{App, Pixels, px}; use language_model::LanguageModel; use project::DisableAiSettings; @@ -33,6 +34,7 @@ pub struct AgentSettings { pub commit_message_model: Option, pub thread_summary_model: Option, pub inline_alternatives: Vec, + pub favorite_models: Vec, pub default_profile: AgentProfileId, pub default_view: DefaultAgentView, pub profiles: IndexMap, @@ -96,6 +98,13 @@ impl AgentSettings { pub fn set_message_editor_max_lines(&self) -> usize { self.message_editor_min_lines * 2 } + + pub fn favorite_model_ids(&self) -> HashSet { + self.favorite_models + .iter() + .map(|sel| ModelId::new(format!("{}/{}", sel.provider.0, sel.model))) + .collect() + } } #[derive(Clone, Copy, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Default)] @@ -164,6 +173,7 @@ impl Settings for AgentSettings { commit_message_model: agent.commit_message_model, thread_summary_model: agent.thread_summary_model, inline_alternatives: agent.inline_alternatives.unwrap_or_default(), + favorite_models: agent.favorite_models, default_profile: AgentProfileId(agent.default_profile.unwrap()), default_view: agent.default_view.unwrap(), profiles: agent diff --git a/crates/agent_ui/src/acp/model_selector.rs b/crates/agent_ui/src/acp/model_selector.rs index 658b88e0c2a4f0b4203c5f1191c0a49cb4ad6fd5..f885ff12e598168abdf7727dc03e4814e5de3b49 100644 --- a/crates/agent_ui/src/acp/model_selector.rs +++ b/crates/agent_ui/src/acp/model_selector.rs @@ -1,18 +1,22 @@ use std::{cmp::Reverse, rc::Rc, sync::Arc}; use acp_thread::{AgentModelInfo, AgentModelList, AgentModelSelector}; +use agent_client_protocol::ModelId; use agent_servers::AgentServer; +use agent_settings::AgentSettings; use anyhow::Result; -use collections::IndexMap; +use collections::{HashSet, IndexMap}; use fs::Fs; use futures::FutureExt; use fuzzy::{StringMatchCandidate, match_strings}; use gpui::{ Action, AsyncWindowContext, BackgroundExecutor, DismissEvent, FocusHandle, Task, WeakEntity, }; +use itertools::Itertools; use ordered_float::OrderedFloat; use picker::{Picker, PickerDelegate}; -use ui::{DocumentationAside, DocumentationEdge, DocumentationSide, prelude::*}; +use settings::Settings; +use ui::{DocumentationAside, DocumentationEdge, DocumentationSide, IntoElement, prelude::*}; use util::ResultExt; use zed_actions::agent::OpenSettings; @@ -38,7 +42,7 @@ pub fn acp_model_selector( enum AcpModelPickerEntry { Separator(SharedString), - Model(AgentModelInfo), + Model(AgentModelInfo, bool), } pub struct AcpModelPickerDelegate { @@ -140,7 +144,7 @@ impl PickerDelegate for AcpModelPickerDelegate { _cx: &mut Context>, ) -> bool { match self.filtered_entries.get(ix) { - Some(AcpModelPickerEntry::Model(_)) => true, + Some(AcpModelPickerEntry::Model(_, _)) => true, Some(AcpModelPickerEntry::Separator(_)) | None => false, } } @@ -155,6 +159,12 @@ impl PickerDelegate for AcpModelPickerDelegate { window: &mut Window, cx: &mut Context>, ) -> Task<()> { + let favorites = if self.selector.supports_favorites() { + Arc::new(AgentSettings::get_global(cx).favorite_model_ids()) + } else { + Default::default() + }; + cx.spawn_in(window, async move |this, cx| { let filtered_models = match this .read_with(cx, |this, cx| { @@ -171,7 +181,7 @@ impl PickerDelegate for AcpModelPickerDelegate { this.update_in(cx, |this, window, cx| { this.delegate.filtered_entries = - info_list_to_picker_entries(filtered_models).collect(); + info_list_to_picker_entries(filtered_models, favorites); // Finds the currently selected model in the list let new_index = this .delegate @@ -179,7 +189,7 @@ impl PickerDelegate for AcpModelPickerDelegate { .as_ref() .and_then(|selected| { this.delegate.filtered_entries.iter().position(|entry| { - if let AcpModelPickerEntry::Model(model_info) = entry { + if let AcpModelPickerEntry::Model(model_info, _) = entry { model_info.id == selected.id } else { false @@ -195,7 +205,7 @@ impl PickerDelegate for AcpModelPickerDelegate { } fn confirm(&mut self, _secondary: bool, window: &mut Window, cx: &mut Context>) { - if let Some(AcpModelPickerEntry::Model(model_info)) = + if let Some(AcpModelPickerEntry::Model(model_info, _)) = self.filtered_entries.get(self.selected_index) { if window.modifiers().secondary() { @@ -233,7 +243,7 @@ impl PickerDelegate for AcpModelPickerDelegate { fn render_match( &self, ix: usize, - is_focused: bool, + selected: bool, _: &mut Window, cx: &mut Context>, ) -> Option { @@ -241,32 +251,53 @@ impl PickerDelegate for AcpModelPickerDelegate { AcpModelPickerEntry::Separator(title) => { Some(ModelSelectorHeader::new(title, ix > 1).into_any_element()) } - AcpModelPickerEntry::Model(model_info) => { + AcpModelPickerEntry::Model(model_info, is_favorite) => { let is_selected = Some(model_info) == self.selected_model.as_ref(); let default_model = self.agent_server.default_model(cx); let is_default = default_model.as_ref() == Some(&model_info.id); + let supports_favorites = self.selector.supports_favorites(); + + let is_favorite = *is_favorite; + let handle_action_click = { + let model_id = model_info.id.clone(); + let fs = self.fs.clone(); + + move |cx: &App| { + crate::favorite_models::toggle_model_id_in_settings( + model_id.clone(), + !is_favorite, + fs.clone(), + cx, + ); + } + }; + Some( div() .id(("model-picker-menu-child", ix)) .when_some(model_info.description.clone(), |this, description| { - this - .on_hover(cx.listener(move |menu, hovered, _, cx| { - if *hovered { - menu.delegate.selected_description = Some((ix, description.clone(), is_default)); - } else if matches!(menu.delegate.selected_description, Some((id, _, _)) if id == ix) { - menu.delegate.selected_description = None; - } - cx.notify(); - })) + this.on_hover(cx.listener(move |menu, hovered, _, cx| { + if *hovered { + menu.delegate.selected_description = + Some((ix, description.clone(), is_default)); + } else if matches!(menu.delegate.selected_description, Some((id, _, _)) if id == ix) { + menu.delegate.selected_description = None; + } + cx.notify(); + })) }) .child( ModelSelectorListItem::new(ix, model_info.name.clone()) - .is_focused(is_focused) + .when_some(model_info.icon, |this, icon| this.icon(icon)) .is_selected(is_selected) - .when_some(model_info.icon, |this, icon| this.icon(icon)), + .is_focused(selected) + .when(supports_favorites, |this| { + this.is_favorite(is_favorite) + .on_toggle_favorite(handle_action_click) + }), ) - .into_any_element() + .into_any_element(), ) } } @@ -314,18 +345,51 @@ impl PickerDelegate for AcpModelPickerDelegate { fn info_list_to_picker_entries( model_list: AgentModelList, -) -> impl Iterator { + favorites: Arc>, +) -> Vec { + let mut entries = Vec::new(); + + let all_models: Vec<_> = match &model_list { + AgentModelList::Flat(list) => list.iter().collect(), + AgentModelList::Grouped(index_map) => index_map.values().flatten().collect(), + }; + + let favorite_models: Vec<_> = all_models + .iter() + .filter(|m| favorites.contains(&m.id)) + .unique_by(|m| &m.id) + .collect(); + + let has_favorites = !favorite_models.is_empty(); + if has_favorites { + entries.push(AcpModelPickerEntry::Separator("Favorite".into())); + for model in favorite_models { + entries.push(AcpModelPickerEntry::Model((*model).clone(), true)); + } + } + match model_list { AgentModelList::Flat(list) => { - itertools::Either::Left(list.into_iter().map(AcpModelPickerEntry::Model)) + if has_favorites { + entries.push(AcpModelPickerEntry::Separator("All".into())); + } + for model in list { + let is_favorite = favorites.contains(&model.id); + entries.push(AcpModelPickerEntry::Model(model, is_favorite)); + } } AgentModelList::Grouped(index_map) => { - itertools::Either::Right(index_map.into_iter().flat_map(|(group_name, models)| { - std::iter::once(AcpModelPickerEntry::Separator(group_name.0)) - .chain(models.into_iter().map(AcpModelPickerEntry::Model)) - })) + for (group_name, models) in index_map { + entries.push(AcpModelPickerEntry::Separator(group_name.0)); + for model in models { + let is_favorite = favorites.contains(&model.id); + entries.push(AcpModelPickerEntry::Model(model, is_favorite)); + } + } } } + + entries } async fn fuzzy_search( @@ -447,6 +511,170 @@ mod tests { } } + fn create_favorites(models: Vec<&str>) -> Arc> { + Arc::new( + models + .into_iter() + .map(|m| ModelId::new(m.to_string())) + .collect(), + ) + } + + fn get_entry_model_ids(entries: &[AcpModelPickerEntry]) -> Vec<&str> { + entries + .iter() + .filter_map(|entry| match entry { + AcpModelPickerEntry::Model(info, _) => Some(info.id.0.as_ref()), + _ => None, + }) + .collect() + } + + fn get_entry_labels(entries: &[AcpModelPickerEntry]) -> Vec<&str> { + entries + .iter() + .map(|entry| match entry { + AcpModelPickerEntry::Model(info, _) => info.id.0.as_ref(), + AcpModelPickerEntry::Separator(s) => &s, + }) + .collect() + } + + #[gpui::test] + fn test_favorites_section_appears_when_favorites_exist(_cx: &mut TestAppContext) { + let models = create_model_list(vec![ + ("zed", vec!["zed/claude", "zed/gemini"]), + ("openai", vec!["openai/gpt-5"]), + ]); + let favorites = create_favorites(vec!["zed/gemini"]); + + let entries = info_list_to_picker_entries(models, favorites); + + assert!(matches!( + entries.first(), + Some(AcpModelPickerEntry::Separator(s)) if s == "Favorite" + )); + + let model_ids = get_entry_model_ids(&entries); + assert_eq!(model_ids[0], "zed/gemini"); + } + + #[gpui::test] + fn test_no_favorites_section_when_no_favorites(_cx: &mut TestAppContext) { + let models = create_model_list(vec![("zed", vec!["zed/claude", "zed/gemini"])]); + let favorites = create_favorites(vec![]); + + let entries = info_list_to_picker_entries(models, favorites); + + assert!(matches!( + entries.first(), + Some(AcpModelPickerEntry::Separator(s)) if s == "zed" + )); + } + + #[gpui::test] + fn test_models_have_correct_actions(_cx: &mut TestAppContext) { + let models = create_model_list(vec![ + ("zed", vec!["zed/claude", "zed/gemini"]), + ("openai", vec!["openai/gpt-5"]), + ]); + let favorites = create_favorites(vec!["zed/claude"]); + + let entries = info_list_to_picker_entries(models, favorites); + + for entry in &entries { + if let AcpModelPickerEntry::Model(info, is_favorite) = entry { + if info.id.0.as_ref() == "zed/claude" { + assert!(is_favorite, "zed/claude should be a favorite"); + } else { + assert!(!is_favorite, "{} should not be a favorite", info.id.0); + } + } + } + } + + #[gpui::test] + fn test_favorites_appear_in_both_sections(_cx: &mut TestAppContext) { + let models = create_model_list(vec![ + ("zed", vec!["zed/claude", "zed/gemini"]), + ("openai", vec!["openai/gpt-5", "openai/gpt-4"]), + ]); + let favorites = create_favorites(vec!["zed/gemini", "openai/gpt-5"]); + + let entries = info_list_to_picker_entries(models, favorites); + let model_ids = get_entry_model_ids(&entries); + + assert_eq!(model_ids[0], "zed/gemini"); + assert_eq!(model_ids[1], "openai/gpt-5"); + + assert!(model_ids[2..].contains(&"zed/gemini")); + assert!(model_ids[2..].contains(&"openai/gpt-5")); + } + + #[gpui::test] + fn test_favorites_are_not_duplicated_when_repeated_in_other_sections(_cx: &mut TestAppContext) { + let models = create_model_list(vec![ + ("Recommended", vec!["zed/claude", "anthropic/claude"]), + ("Zed", vec!["zed/claude", "zed/gpt-5"]), + ("Antropic", vec!["anthropic/claude"]), + ("OpenAI", vec!["openai/gpt-5"]), + ]); + + let favorites = create_favorites(vec!["zed/claude"]); + + let entries = info_list_to_picker_entries(models, favorites); + let labels = get_entry_labels(&entries); + + assert_eq!( + labels, + vec![ + "Favorite", + "zed/claude", + "Recommended", + "zed/claude", + "anthropic/claude", + "Zed", + "zed/claude", + "zed/gpt-5", + "Antropic", + "anthropic/claude", + "OpenAI", + "openai/gpt-5" + ] + ); + } + + #[gpui::test] + fn test_flat_model_list_with_favorites(_cx: &mut TestAppContext) { + let models = AgentModelList::Flat(vec![ + acp_thread::AgentModelInfo { + id: acp::ModelId::new("zed/claude".to_string()), + name: "Claude".into(), + description: None, + icon: None, + }, + acp_thread::AgentModelInfo { + id: acp::ModelId::new("zed/gemini".to_string()), + name: "Gemini".into(), + description: None, + icon: None, + }, + ]); + let favorites = create_favorites(vec!["zed/gemini"]); + + let entries = info_list_to_picker_entries(models, favorites); + + assert!(matches!( + entries.first(), + Some(AcpModelPickerEntry::Separator(s)) if s == "Favorite" + )); + + assert!(entries.iter().any(|e| matches!( + e, + AcpModelPickerEntry::Separator(s) if s == "All" + ))); + } + #[gpui::test] async fn test_fuzzy_match(cx: &mut TestAppContext) { let models = create_model_list(vec![ diff --git a/crates/agent_ui/src/agent_configuration/manage_profiles_modal.rs b/crates/agent_ui/src/agent_configuration/manage_profiles_modal.rs index ed00b2b5c716fdf27abc1c9d7c5850b36fce830f..127852fd50e81cf56ae37a7af430f88ae2accf99 100644 --- a/crates/agent_ui/src/agent_configuration/manage_profiles_modal.rs +++ b/crates/agent_ui/src/agent_configuration/manage_profiles_modal.rs @@ -222,7 +222,6 @@ impl ManageProfilesModal { let profile_id_for_closure = profile_id.clone(); let model_picker = cx.new(|cx| { - let fs = fs.clone(); let profile_id = profile_id_for_closure.clone(); language_model_selector( @@ -250,22 +249,36 @@ impl ManageProfilesModal { }) } }, - move |model, cx| { - let provider = model.provider_id().0.to_string(); - let model_id = model.id().0.to_string(); - let profile_id = profile_id.clone(); - - update_settings_file(fs.clone(), cx, move |settings, _cx| { - let agent_settings = settings.agent.get_or_insert_default(); - if let Some(profiles) = agent_settings.profiles.as_mut() { - if let Some(profile) = profiles.get_mut(profile_id.0.as_ref()) { - profile.default_model = Some(LanguageModelSelection { - provider: LanguageModelProviderSetting(provider.clone()), - model: model_id.clone(), - }); + { + let fs = fs.clone(); + move |model, cx| { + let provider = model.provider_id().0.to_string(); + let model_id = model.id().0.to_string(); + let profile_id = profile_id.clone(); + + update_settings_file(fs.clone(), cx, move |settings, _cx| { + let agent_settings = settings.agent.get_or_insert_default(); + if let Some(profiles) = agent_settings.profiles.as_mut() { + if let Some(profile) = profiles.get_mut(profile_id.0.as_ref()) { + profile.default_model = Some(LanguageModelSelection { + provider: LanguageModelProviderSetting(provider.clone()), + model: model_id.clone(), + }); + } } - } - }); + }); + } + }, + { + let fs = fs.clone(); + move |model, should_be_favorite, cx| { + crate::favorite_models::toggle_in_settings( + model, + should_be_favorite, + fs.clone(), + cx, + ); + } }, false, // Do not use popover styles for the model picker self.focus_handle.clone(), diff --git a/crates/agent_ui/src/agent_model_selector.rs b/crates/agent_ui/src/agent_model_selector.rs index 9c2634143099d2097b5c6492f81c56aa51f12491..ac57ed575d9d1b6de2c53d3e0e4a91b4bd16ab1a 100644 --- a/crates/agent_ui/src/agent_model_selector.rs +++ b/crates/agent_ui/src/agent_model_selector.rs @@ -29,26 +29,39 @@ impl AgentModelSelector { Self { selector: cx.new(move |cx| { - let fs = fs.clone(); language_model_selector( { let model_context = model_usage_context.clone(); move |cx| model_context.configured_model(cx) }, - move |model, cx| { - let provider = model.provider_id().0.to_string(); - let model_id = model.id().0.to_string(); - match &model_usage_context { - ModelUsageContext::InlineAssistant => { - update_settings_file(fs.clone(), cx, move |settings, _cx| { - settings - .agent - .get_or_insert_default() - .set_inline_assistant_model(provider.clone(), model_id); - }); + { + let fs = fs.clone(); + move |model, cx| { + let provider = model.provider_id().0.to_string(); + let model_id = model.id().0.to_string(); + match &model_usage_context { + ModelUsageContext::InlineAssistant => { + update_settings_file(fs.clone(), cx, move |settings, _cx| { + settings + .agent + .get_or_insert_default() + .set_inline_assistant_model(provider.clone(), model_id); + }); + } } } }, + { + let fs = fs.clone(); + move |model, should_be_favorite, cx| { + crate::favorite_models::toggle_in_settings( + model, + should_be_favorite, + fs.clone(), + cx, + ); + } + }, true, // Use popover styles for picker focus_handle_clone, window, diff --git a/crates/agent_ui/src/agent_ui.rs b/crates/agent_ui/src/agent_ui.rs index 4f759d6a9c7687d2cdf29752c489db2fcb1ffe68..1622d17f5852d825b9c8d69996fad7c89bb89dce 100644 --- a/crates/agent_ui/src/agent_ui.rs +++ b/crates/agent_ui/src/agent_ui.rs @@ -7,6 +7,7 @@ mod buffer_codegen; mod completion_provider; mod context; mod context_server_configuration; +mod favorite_models; mod inline_assistant; mod inline_prompt_editor; mod language_model_selector; @@ -467,6 +468,7 @@ mod tests { commit_message_model: None, thread_summary_model: None, inline_alternatives: vec![], + favorite_models: vec![], default_profile: AgentProfileId::default(), default_view: DefaultAgentView::Thread, profiles: Default::default(), diff --git a/crates/agent_ui/src/favorite_models.rs b/crates/agent_ui/src/favorite_models.rs new file mode 100644 index 0000000000000000000000000000000000000000..d8d4db976fc9916973eedd9174925fba75a06b2b --- /dev/null +++ b/crates/agent_ui/src/favorite_models.rs @@ -0,0 +1,57 @@ +use std::sync::Arc; + +use agent_client_protocol::ModelId; +use fs::Fs; +use language_model::LanguageModel; +use settings::{LanguageModelSelection, update_settings_file}; +use ui::App; + +fn language_model_to_selection(model: &Arc) -> LanguageModelSelection { + LanguageModelSelection { + provider: model.provider_id().to_string().into(), + model: model.id().0.to_string(), + } +} + +fn model_id_to_selection(model_id: &ModelId) -> LanguageModelSelection { + let id = model_id.0.as_ref(); + let (provider, model) = id.split_once('/').unwrap_or(("", id)); + LanguageModelSelection { + provider: provider.to_owned().into(), + model: model.to_owned(), + } +} + +pub fn toggle_in_settings( + model: Arc, + should_be_favorite: bool, + fs: Arc, + cx: &App, +) { + let selection = language_model_to_selection(&model); + update_settings_file(fs, cx, move |settings, _| { + let agent = settings.agent.get_or_insert_default(); + if should_be_favorite { + agent.add_favorite_model(selection.clone()); + } else { + agent.remove_favorite_model(&selection); + } + }); +} + +pub fn toggle_model_id_in_settings( + model_id: ModelId, + should_be_favorite: bool, + fs: Arc, + cx: &App, +) { + let selection = model_id_to_selection(&model_id); + update_settings_file(fs, cx, move |settings, _| { + let agent = settings.agent.get_or_insert_default(); + if should_be_favorite { + agent.add_favorite_model(selection.clone()); + } else { + agent.remove_favorite_model(&selection); + } + }); +} diff --git a/crates/agent_ui/src/language_model_selector.rs b/crates/agent_ui/src/language_model_selector.rs index 7e1c35eba45bf9a79d42b59374c8cdb2aa0cac21..7bb42fb330dcccb4b5401217d0181d3d616fe66f 100644 --- a/crates/agent_ui/src/language_model_selector.rs +++ b/crates/agent_ui/src/language_model_selector.rs @@ -1,16 +1,18 @@ use std::{cmp::Reverse, sync::Arc}; -use collections::IndexMap; +use agent_settings::AgentSettings; +use collections::{HashMap, HashSet, IndexMap}; use fuzzy::{StringMatch, StringMatchCandidate, match_strings}; use gpui::{ Action, AnyElement, App, BackgroundExecutor, DismissEvent, FocusHandle, Subscription, Task, }; use language_model::{ - AuthenticateError, ConfiguredModel, LanguageModel, LanguageModelProviderId, - LanguageModelRegistry, + AuthenticateError, ConfiguredModel, LanguageModel, LanguageModelId, LanguageModelProvider, + LanguageModelProviderId, LanguageModelRegistry, }; use ordered_float::OrderedFloat; use picker::{Picker, PickerDelegate}; +use settings::Settings; use ui::prelude::*; use zed_actions::agent::OpenSettings; @@ -18,12 +20,14 @@ use crate::ui::{ModelSelectorFooter, ModelSelectorHeader, ModelSelectorListItem} type OnModelChanged = Arc, &mut App) + 'static>; type GetActiveModel = Arc Option + 'static>; +type OnToggleFavorite = Arc, bool, &App) + 'static>; pub type LanguageModelSelector = Picker; pub fn language_model_selector( get_active_model: impl Fn(&App) -> Option + 'static, on_model_changed: impl Fn(Arc, &mut App) + 'static, + on_toggle_favorite: impl Fn(Arc, bool, &App) + 'static, popover_styles: bool, focus_handle: FocusHandle, window: &mut Window, @@ -32,6 +36,7 @@ pub fn language_model_selector( let delegate = LanguageModelPickerDelegate::new( get_active_model, on_model_changed, + on_toggle_favorite, popover_styles, focus_handle, window, @@ -49,7 +54,17 @@ pub fn language_model_selector( } fn all_models(cx: &App) -> GroupedModels { - let providers = LanguageModelRegistry::global(cx).read(cx).providers(); + let lm_registry = LanguageModelRegistry::global(cx).read(cx); + let providers = lm_registry.providers(); + + let mut favorites_index = FavoritesIndex::default(); + + for sel in &AgentSettings::get_global(cx).favorite_models { + favorites_index + .entry(sel.provider.0.clone().into()) + .or_default() + .insert(sel.model.clone().into()); + } let recommended = providers .iter() @@ -57,10 +72,7 @@ fn all_models(cx: &App) -> GroupedModels { provider .recommended_models(cx) .into_iter() - .map(|model| ModelInfo { - model, - icon: provider.icon(), - }) + .map(|model| ModelInfo::new(&**provider, model, &favorites_index)) }) .collect(); @@ -70,25 +82,44 @@ fn all_models(cx: &App) -> GroupedModels { provider .provided_models(cx) .into_iter() - .map(|model| ModelInfo { - model, - icon: provider.icon(), - }) + .map(|model| ModelInfo::new(&**provider, model, &favorites_index)) }) .collect(); GroupedModels::new(all, recommended) } +type FavoritesIndex = HashMap>; + #[derive(Clone)] struct ModelInfo { model: Arc, icon: IconName, + is_favorite: bool, +} + +impl ModelInfo { + fn new( + provider: &dyn LanguageModelProvider, + model: Arc, + favorites_index: &FavoritesIndex, + ) -> Self { + let is_favorite = favorites_index + .get(&provider.id()) + .map_or(false, |set| set.contains(&model.id())); + + Self { + model, + icon: provider.icon(), + is_favorite, + } + } } pub struct LanguageModelPickerDelegate { on_model_changed: OnModelChanged, get_active_model: GetActiveModel, + on_toggle_favorite: OnToggleFavorite, all_models: Arc, filtered_entries: Vec, selected_index: usize, @@ -102,6 +133,7 @@ impl LanguageModelPickerDelegate { fn new( get_active_model: impl Fn(&App) -> Option + 'static, on_model_changed: impl Fn(Arc, &mut App) + 'static, + on_toggle_favorite: impl Fn(Arc, bool, &App) + 'static, popover_styles: bool, focus_handle: FocusHandle, window: &mut Window, @@ -117,6 +149,7 @@ impl LanguageModelPickerDelegate { selected_index: Self::get_active_model_index(&entries, get_active_model(cx)), filtered_entries: entries, get_active_model: Arc::new(get_active_model), + on_toggle_favorite: Arc::new(on_toggle_favorite), _authenticate_all_providers_task: Self::authenticate_all_providers(cx), _subscriptions: vec![cx.subscribe_in( &LanguageModelRegistry::global(cx), @@ -219,12 +252,19 @@ impl LanguageModelPickerDelegate { } struct GroupedModels { + favorites: Vec, recommended: Vec, all: IndexMap>, } impl GroupedModels { pub fn new(all: Vec, recommended: Vec) -> Self { + let favorites = all + .iter() + .filter(|info| info.is_favorite) + .cloned() + .collect(); + let mut all_by_provider: IndexMap<_, Vec> = IndexMap::default(); for model in all { let provider = model.model.provider_id(); @@ -236,6 +276,7 @@ impl GroupedModels { } Self { + favorites, recommended, all: all_by_provider, } @@ -244,13 +285,18 @@ impl GroupedModels { fn entries(&self) -> Vec { let mut entries = Vec::new(); + if !self.favorites.is_empty() { + entries.push(LanguageModelPickerEntry::Separator("Favorite".into())); + for info in &self.favorites { + entries.push(LanguageModelPickerEntry::Model(info.clone())); + } + } + if !self.recommended.is_empty() { entries.push(LanguageModelPickerEntry::Separator("Recommended".into())); - entries.extend( - self.recommended - .iter() - .map(|info| LanguageModelPickerEntry::Model(info.clone())), - ); + for info in &self.recommended { + entries.push(LanguageModelPickerEntry::Model(info.clone())); + } } for models in self.all.values() { @@ -260,12 +306,11 @@ impl GroupedModels { entries.push(LanguageModelPickerEntry::Separator( models[0].model.provider_name().0, )); - entries.extend( - models - .iter() - .map(|info| LanguageModelPickerEntry::Model(info.clone())), - ); + for info in models { + entries.push(LanguageModelPickerEntry::Model(info.clone())); + } } + entries } } @@ -461,7 +506,7 @@ impl PickerDelegate for LanguageModelPickerDelegate { fn render_match( &self, ix: usize, - is_focused: bool, + selected: bool, _: &mut Window, cx: &mut Context>, ) -> Option { @@ -477,11 +522,20 @@ impl PickerDelegate for LanguageModelPickerDelegate { let is_selected = Some(model_info.model.provider_id()) == active_provider_id && Some(model_info.model.id()) == active_model_id; + let is_favorite = model_info.is_favorite; + let handle_action_click = { + let model = model_info.model.clone(); + let on_toggle_favorite = self.on_toggle_favorite.clone(); + move |cx: &App| on_toggle_favorite(model.clone(), !is_favorite, cx) + }; + Some( ModelSelectorListItem::new(ix, model_info.model.name().0) - .is_focused(is_focused) - .is_selected(is_selected) .icon(model_info.icon) + .is_selected(is_selected) + .is_focused(selected) + .is_favorite(is_favorite) + .on_toggle_favorite(handle_action_click) .into_any_element(), ) } @@ -493,12 +547,12 @@ impl PickerDelegate for LanguageModelPickerDelegate { _window: &mut Window, _cx: &mut Context>, ) -> Option { + let focus_handle = self.focus_handle.clone(); + if !self.popover_styles { return None; } - let focus_handle = self.focus_handle.clone(); - Some(ModelSelectorFooter::new(OpenSettings.boxed_clone(), focus_handle).into_any_element()) } } @@ -598,11 +652,24 @@ mod tests { } fn create_models(model_specs: Vec<(&str, &str)>) -> Vec { + create_models_with_favorites(model_specs, vec![]) + } + + fn create_models_with_favorites( + model_specs: Vec<(&str, &str)>, + favorites: Vec<(&str, &str)>, + ) -> Vec { model_specs .into_iter() - .map(|(provider, name)| ModelInfo { - model: Arc::new(TestLanguageModel::new(name, provider)), - icon: IconName::Ai, + .map(|(provider, name)| { + let is_favorite = favorites + .iter() + .any(|(fav_provider, fav_name)| *fav_provider == provider && *fav_name == name); + ModelInfo { + model: Arc::new(TestLanguageModel::new(name, provider)), + icon: IconName::Ai, + is_favorite, + } }) .collect() } @@ -740,4 +807,93 @@ mod tests { vec!["zed/claude", "zed/gemini", "copilot/claude"], ); } + + #[gpui::test] + fn test_favorites_section_appears_when_favorites_exist(_cx: &mut TestAppContext) { + let recommended_models = create_models(vec![("zed", "claude")]); + let all_models = create_models_with_favorites( + vec![("zed", "claude"), ("zed", "gemini"), ("openai", "gpt-4")], + vec![("zed", "gemini")], + ); + + let grouped_models = GroupedModels::new(all_models, recommended_models); + let entries = grouped_models.entries(); + + assert!(matches!( + entries.first(), + Some(LanguageModelPickerEntry::Separator(s)) if s == "Favorite" + )); + + assert_models_eq(grouped_models.favorites, vec!["zed/gemini"]); + } + + #[gpui::test] + fn test_no_favorites_section_when_no_favorites(_cx: &mut TestAppContext) { + let recommended_models = create_models(vec![("zed", "claude")]); + let all_models = create_models(vec![("zed", "claude"), ("zed", "gemini")]); + + let grouped_models = GroupedModels::new(all_models, recommended_models); + let entries = grouped_models.entries(); + + assert!(matches!( + entries.first(), + Some(LanguageModelPickerEntry::Separator(s)) if s == "Recommended" + )); + + assert!(grouped_models.favorites.is_empty()); + } + + #[gpui::test] + fn test_models_have_correct_actions(_cx: &mut TestAppContext) { + let recommended_models = + create_models_with_favorites(vec![("zed", "claude")], vec![("zed", "claude")]); + let all_models = create_models_with_favorites( + vec![("zed", "claude"), ("zed", "gemini"), ("openai", "gpt-4")], + vec![("zed", "claude")], + ); + + let grouped_models = GroupedModels::new(all_models, recommended_models); + let entries = grouped_models.entries(); + + for entry in &entries { + if let LanguageModelPickerEntry::Model(info) = entry { + if info.model.telemetry_id() == "zed/claude" { + assert!(info.is_favorite, "zed/claude should be a favorite"); + } else { + assert!( + !info.is_favorite, + "{} should not be a favorite", + info.model.telemetry_id() + ); + } + } + } + } + + #[gpui::test] + fn test_favorites_appear_in_other_sections(_cx: &mut TestAppContext) { + let favorites = vec![("zed", "gemini"), ("openai", "gpt-4")]; + + let recommended_models = + create_models_with_favorites(vec![("zed", "claude")], favorites.clone()); + + let all_models = create_models_with_favorites( + vec![ + ("zed", "claude"), + ("zed", "gemini"), + ("openai", "gpt-4"), + ("openai", "gpt-3.5"), + ], + favorites, + ); + + let grouped_models = GroupedModels::new(all_models, recommended_models); + + assert_models_eq(grouped_models.favorites, vec!["zed/gemini", "openai/gpt-4"]); + assert_models_eq(grouped_models.recommended, vec!["zed/claude"]); + assert_models_eq( + grouped_models.all.values().flatten().cloned().collect(), + vec!["zed/claude", "zed/gemini", "openai/gpt-4", "openai/gpt-3.5"], + ); + } } diff --git a/crates/agent_ui/src/text_thread_editor.rs b/crates/agent_ui/src/text_thread_editor.rs index 5e3f348c17de3cd0dae9f5fe41a2477211d6ddd8..881eb213a3886b894a778a34cb6ba129bf42c1a4 100644 --- a/crates/agent_ui/src/text_thread_editor.rs +++ b/crates/agent_ui/src/text_thread_editor.rs @@ -304,17 +304,31 @@ impl TextThreadEditor { language_model_selector: cx.new(|cx| { language_model_selector( |cx| LanguageModelRegistry::read_global(cx).default_model(), - move |model, cx| { - update_settings_file(fs.clone(), cx, move |settings, _| { - let provider = model.provider_id().0.to_string(); - let model = model.id().0.to_string(); - settings.agent.get_or_insert_default().set_model( - LanguageModelSelection { - provider: LanguageModelProviderSetting(provider), - model, - }, - ) - }); + { + let fs = fs.clone(); + move |model, cx| { + update_settings_file(fs.clone(), cx, move |settings, _| { + let provider = model.provider_id().0.to_string(); + let model = model.id().0.to_string(); + settings.agent.get_or_insert_default().set_model( + LanguageModelSelection { + provider: LanguageModelProviderSetting(provider), + model, + }, + ) + }); + } + }, + { + let fs = fs.clone(); + move |model, should_be_favorite, cx| { + crate::favorite_models::toggle_in_settings( + model, + should_be_favorite, + fs.clone(), + cx, + ); + } }, true, // Use popover styles for picker focus_handle, diff --git a/crates/agent_ui/src/ui/model_selector_components.rs b/crates/agent_ui/src/ui/model_selector_components.rs index 3218daef7c9aadae5cd45b2fc65807d8a32254bd..184c8e0ba2d3ea307c869e42a13b75f36e713c42 100644 --- a/crates/agent_ui/src/ui/model_selector_components.rs +++ b/crates/agent_ui/src/ui/model_selector_components.rs @@ -1,5 +1,5 @@ use gpui::{Action, FocusHandle, prelude::*}; -use ui::{KeyBinding, ListItem, ListItemSpacing, prelude::*}; +use ui::{ElevationIndex, KeyBinding, ListItem, ListItemSpacing, Tooltip, prelude::*}; #[derive(IntoElement)] pub struct ModelSelectorHeader { @@ -42,6 +42,8 @@ pub struct ModelSelectorListItem { icon: Option, is_selected: bool, is_focused: bool, + is_favorite: bool, + on_toggle_favorite: Option>, } impl ModelSelectorListItem { @@ -52,6 +54,8 @@ impl ModelSelectorListItem { icon: None, is_selected: false, is_focused: false, + is_favorite: false, + on_toggle_favorite: None, } } @@ -69,6 +73,16 @@ impl ModelSelectorListItem { self.is_focused = is_focused; self } + + pub fn is_favorite(mut self, is_favorite: bool) -> Self { + self.is_favorite = is_favorite; + self + } + + pub fn on_toggle_favorite(mut self, handler: impl Fn(&App) + 'static) -> Self { + self.on_toggle_favorite = Some(Box::new(handler)); + self + } } impl RenderOnce for ModelSelectorListItem { @@ -79,6 +93,8 @@ impl RenderOnce for ModelSelectorListItem { Color::Muted }; + let is_favorite = self.is_favorite; + ListItem::new(self.index) .inset(true) .spacing(ListItemSpacing::Sparse) @@ -103,6 +119,23 @@ impl RenderOnce for ModelSelectorListItem { .size(IconSize::Small), ) })) + .end_hover_slot(div().pr_2().when_some(self.on_toggle_favorite, { + |this, handle_click| { + let (icon, color, tooltip) = if is_favorite { + (IconName::StarFilled, Color::Accent, "Unfavorite Model") + } else { + (IconName::Star, Color::Default, "Favorite Model") + }; + this.child( + IconButton::new(("toggle-favorite", self.index), icon) + .layer(ElevationIndex::ElevatedSurface) + .icon_color(color) + .icon_size(IconSize::Small) + .tooltip(Tooltip::text(tooltip)) + .on_click(move |_, _, cx| (handle_click)(cx)), + ) + } + })) } } diff --git a/crates/settings/src/settings_content/agent.rs b/crates/settings/src/settings_content/agent.rs index f7a88deb7d8ba88db6497da2cf79035a64446456..d3a8e40084fc5db7fd348908b1b721617c7c8206 100644 --- a/crates/settings/src/settings_content/agent.rs +++ b/crates/settings/src/settings_content/agent.rs @@ -38,6 +38,9 @@ pub struct AgentSettingsContent { pub default_height: Option, /// The default model to use when creating new chats and for other features when a specific model is not specified. pub default_model: Option, + /// Favorite models to show at the top of the model selector. + #[serde(default)] + pub favorite_models: Vec, /// Model to use for the inline assistant. Defaults to default_model when not specified. pub inline_assistant_model: Option, /// Model to use for the inline assistant when streaming tools are enabled. @@ -176,6 +179,16 @@ impl AgentSettingsContent { pub fn set_profile(&mut self, profile_id: Arc) { self.default_profile = Some(profile_id); } + + pub fn add_favorite_model(&mut self, model: LanguageModelSelection) { + if !self.favorite_models.contains(&model) { + self.favorite_models.push(model); + } + } + + pub fn remove_favorite_model(&mut self, model: &LanguageModelSelection) { + self.favorite_models.retain(|m| m != model); + } } #[with_fallible_options] From d16619a654780aad7534caa2f3562a9b7cab423c Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Tue, 16 Dec 2025 14:32:41 -0500 Subject: [PATCH 400/621] Improve token count accuracy using Anthropic's API (#44943) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #38533 Screenshot 2025-12-16 at 2 32 21 PM Release Notes: - Use up-to-date token counts from LLM responses when reporting tokens used per thread --------- Co-authored-by: Claude Haiku 4.5 --- crates/agent/src/tests/mod.rs | 178 +++++++++++ crates/agent/src/thread.rs | 22 ++ crates/anthropic/src/anthropic.rs | 65 ++++ .../language_models/src/provider/anthropic.rs | 292 ++++++++++++++---- crates/language_models/src/provider/cloud.rs | 10 +- 5 files changed, 507 insertions(+), 60 deletions(-) diff --git a/crates/agent/src/tests/mod.rs b/crates/agent/src/tests/mod.rs index 5a581c5db80a4c4f527efc8b1711fbf16c8097f8..45028902e467fe67945ddf444c9ae417dcaed654 100644 --- a/crates/agent/src/tests/mod.rs +++ b/crates/agent/src/tests/mod.rs @@ -2809,3 +2809,181 @@ fn setup_context_server( cx.run_until_parked(); mcp_tool_calls_rx } + +#[gpui::test] +async fn test_tokens_before_message(cx: &mut TestAppContext) { + let ThreadTest { model, thread, .. } = setup(cx, TestModel::Fake).await; + let fake_model = model.as_fake(); + + // First message + let message_1_id = UserMessageId::new(); + thread + .update(cx, |thread, cx| { + thread.send(message_1_id.clone(), ["First message"], cx) + }) + .unwrap(); + cx.run_until_parked(); + + // Before any response, tokens_before_message should return None for first message + thread.read_with(cx, |thread, _| { + assert_eq!( + thread.tokens_before_message(&message_1_id), + None, + "First message should have no tokens before it" + ); + }); + + // Complete first message with usage + fake_model.send_last_completion_stream_text_chunk("Response 1"); + fake_model.send_last_completion_stream_event(LanguageModelCompletionEvent::UsageUpdate( + language_model::TokenUsage { + input_tokens: 100, + output_tokens: 50, + cache_creation_input_tokens: 0, + cache_read_input_tokens: 0, + }, + )); + fake_model.end_last_completion_stream(); + cx.run_until_parked(); + + // First message still has no tokens before it + thread.read_with(cx, |thread, _| { + assert_eq!( + thread.tokens_before_message(&message_1_id), + None, + "First message should still have no tokens before it after response" + ); + }); + + // Second message + let message_2_id = UserMessageId::new(); + thread + .update(cx, |thread, cx| { + thread.send(message_2_id.clone(), ["Second message"], cx) + }) + .unwrap(); + cx.run_until_parked(); + + // Second message should have first message's input tokens before it + thread.read_with(cx, |thread, _| { + assert_eq!( + thread.tokens_before_message(&message_2_id), + Some(100), + "Second message should have 100 tokens before it (from first request)" + ); + }); + + // Complete second message + fake_model.send_last_completion_stream_text_chunk("Response 2"); + fake_model.send_last_completion_stream_event(LanguageModelCompletionEvent::UsageUpdate( + language_model::TokenUsage { + input_tokens: 250, // Total for this request (includes previous context) + output_tokens: 75, + cache_creation_input_tokens: 0, + cache_read_input_tokens: 0, + }, + )); + fake_model.end_last_completion_stream(); + cx.run_until_parked(); + + // Third message + let message_3_id = UserMessageId::new(); + thread + .update(cx, |thread, cx| { + thread.send(message_3_id.clone(), ["Third message"], cx) + }) + .unwrap(); + cx.run_until_parked(); + + // Third message should have second message's input tokens (250) before it + thread.read_with(cx, |thread, _| { + assert_eq!( + thread.tokens_before_message(&message_3_id), + Some(250), + "Third message should have 250 tokens before it (from second request)" + ); + // Second message should still have 100 + assert_eq!( + thread.tokens_before_message(&message_2_id), + Some(100), + "Second message should still have 100 tokens before it" + ); + // First message still has none + assert_eq!( + thread.tokens_before_message(&message_1_id), + None, + "First message should still have no tokens before it" + ); + }); +} + +#[gpui::test] +async fn test_tokens_before_message_after_truncate(cx: &mut TestAppContext) { + let ThreadTest { model, thread, .. } = setup(cx, TestModel::Fake).await; + let fake_model = model.as_fake(); + + // Set up three messages with responses + let message_1_id = UserMessageId::new(); + thread + .update(cx, |thread, cx| { + thread.send(message_1_id.clone(), ["Message 1"], cx) + }) + .unwrap(); + cx.run_until_parked(); + fake_model.send_last_completion_stream_text_chunk("Response 1"); + fake_model.send_last_completion_stream_event(LanguageModelCompletionEvent::UsageUpdate( + language_model::TokenUsage { + input_tokens: 100, + output_tokens: 50, + cache_creation_input_tokens: 0, + cache_read_input_tokens: 0, + }, + )); + fake_model.end_last_completion_stream(); + cx.run_until_parked(); + + let message_2_id = UserMessageId::new(); + thread + .update(cx, |thread, cx| { + thread.send(message_2_id.clone(), ["Message 2"], cx) + }) + .unwrap(); + cx.run_until_parked(); + fake_model.send_last_completion_stream_text_chunk("Response 2"); + fake_model.send_last_completion_stream_event(LanguageModelCompletionEvent::UsageUpdate( + language_model::TokenUsage { + input_tokens: 250, + output_tokens: 75, + cache_creation_input_tokens: 0, + cache_read_input_tokens: 0, + }, + )); + fake_model.end_last_completion_stream(); + cx.run_until_parked(); + + // Verify initial state + thread.read_with(cx, |thread, _| { + assert_eq!(thread.tokens_before_message(&message_2_id), Some(100)); + }); + + // Truncate at message 2 (removes message 2 and everything after) + thread + .update(cx, |thread, cx| thread.truncate(message_2_id.clone(), cx)) + .unwrap(); + cx.run_until_parked(); + + // After truncation, message_2_id no longer exists, so lookup should return None + thread.read_with(cx, |thread, _| { + assert_eq!( + thread.tokens_before_message(&message_2_id), + None, + "After truncation, message 2 no longer exists" + ); + // Message 1 still exists but has no tokens before it + assert_eq!( + thread.tokens_before_message(&message_1_id), + None, + "First message still has no tokens before it" + ); + }); +} diff --git a/crates/agent/src/thread.rs b/crates/agent/src/thread.rs index bb22470b9e7db934f949a13b86fd13f9dc58beed..f8f46af5fe2bbea5888ded6e24495afee71680dd 100644 --- a/crates/agent/src/thread.rs +++ b/crates/agent/src/thread.rs @@ -1095,6 +1095,28 @@ impl Thread { }) } + /// Get the total input token count as of the message before the given message. + /// + /// Returns `None` if: + /// - `target_id` is the first message (no previous message) + /// - The previous message hasn't received a response yet (no usage data) + /// - `target_id` is not found in the messages + pub fn tokens_before_message(&self, target_id: &UserMessageId) -> Option { + let mut previous_user_message_id: Option<&UserMessageId> = None; + + for message in &self.messages { + if let Message::User(user_msg) = message { + if &user_msg.id == target_id { + let prev_id = previous_user_message_id?; + let usage = self.request_token_usage.get(prev_id)?; + return Some(usage.input_tokens); + } + previous_user_message_id = Some(&user_msg.id); + } + } + None + } + /// Look up the active profile and resolve its preferred model if one is configured. fn resolve_profile_model( profile_id: &AgentProfileId, diff --git a/crates/anthropic/src/anthropic.rs b/crates/anthropic/src/anthropic.rs index e976b7f5dc36905d2a32b4cdc04869f3267705fe..f0dde3eedea657ea2d2ebe9ede457e329bd8b9a5 100644 --- a/crates/anthropic/src/anthropic.rs +++ b/crates/anthropic/src/anthropic.rs @@ -1052,6 +1052,71 @@ pub fn parse_prompt_too_long(message: &str) -> Option { .ok() } +/// Request body for the token counting API. +/// Similar to `Request` but without `max_tokens` since it's not needed for counting. +#[derive(Debug, Serialize)] +pub struct CountTokensRequest { + pub model: String, + pub messages: Vec, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub system: Option, + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub tools: Vec, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub thinking: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub tool_choice: Option, +} + +/// Response from the token counting API. +#[derive(Debug, Deserialize)] +pub struct CountTokensResponse { + pub input_tokens: u64, +} + +/// Count the number of tokens in a message without creating it. +pub async fn count_tokens( + client: &dyn HttpClient, + api_url: &str, + api_key: &str, + request: CountTokensRequest, +) -> Result { + let uri = format!("{api_url}/v1/messages/count_tokens"); + + let request_builder = HttpRequest::builder() + .method(Method::POST) + .uri(uri) + .header("Anthropic-Version", "2023-06-01") + .header("X-Api-Key", api_key.trim()) + .header("Content-Type", "application/json"); + + let serialized_request = + serde_json::to_string(&request).map_err(AnthropicError::SerializeRequest)?; + let http_request = request_builder + .body(AsyncBody::from(serialized_request)) + .map_err(AnthropicError::BuildRequestBody)?; + + let mut response = client + .send(http_request) + .await + .map_err(AnthropicError::HttpSend)?; + + let rate_limits = RateLimitInfo::from_headers(response.headers()); + + if response.status().is_success() { + let mut body = String::new(); + response + .body_mut() + .read_to_string(&mut body) + .await + .map_err(AnthropicError::ReadResponse)?; + + serde_json::from_str(&body).map_err(AnthropicError::DeserializeResponse) + } else { + Err(handle_error_response(response, rate_limits).await) + } +} + #[test] fn test_match_window_exceeded() { let error = ApiError { diff --git a/crates/language_models/src/provider/anthropic.rs b/crates/language_models/src/provider/anthropic.rs index 25ba7615dc23e2561648e173588be6d93c28e295..d8c972399c33922386bfba4236e1369d03d338dc 100644 --- a/crates/language_models/src/provider/anthropic.rs +++ b/crates/language_models/src/provider/anthropic.rs @@ -1,6 +1,6 @@ use anthropic::{ - ANTHROPIC_API_URL, AnthropicError, AnthropicModelMode, ContentDelta, Event, ResponseContent, - ToolResultContent, ToolResultPart, Usage, + ANTHROPIC_API_URL, AnthropicError, AnthropicModelMode, ContentDelta, CountTokensRequest, Event, + ResponseContent, ToolResultContent, ToolResultPart, Usage, }; use anyhow::{Result, anyhow}; use collections::{BTreeMap, HashMap}; @@ -219,68 +219,215 @@ pub struct AnthropicModel { request_limiter: RateLimiter, } -pub fn count_anthropic_tokens( +/// Convert a LanguageModelRequest to an Anthropic CountTokensRequest. +pub fn into_anthropic_count_tokens_request( request: LanguageModelRequest, - cx: &App, -) -> BoxFuture<'static, Result> { - cx.background_spawn(async move { - let messages = request.messages; - let mut tokens_from_images = 0; - let mut string_messages = Vec::with_capacity(messages.len()); - - for message in messages { - use language_model::MessageContent; - - let mut string_contents = String::new(); - - for content in message.content { - match content { - MessageContent::Text(text) => { - string_contents.push_str(&text); - } - MessageContent::Thinking { .. } => { - // Thinking blocks are not included in the input token count. - } - MessageContent::RedactedThinking(_) => { - // Thinking blocks are not included in the input token count. - } - MessageContent::Image(image) => { - tokens_from_images += image.estimate_tokens(); - } - MessageContent::ToolUse(_tool_use) => { - // TODO: Estimate token usage from tool uses. - } - MessageContent::ToolResult(tool_result) => match &tool_result.content { - LanguageModelToolResultContent::Text(text) => { - string_contents.push_str(text); + model: String, + mode: AnthropicModelMode, +) -> CountTokensRequest { + let mut new_messages: Vec = Vec::new(); + let mut system_message = String::new(); + + for message in request.messages { + if message.contents_empty() { + continue; + } + + match message.role { + Role::User | Role::Assistant => { + let anthropic_message_content: Vec = message + .content + .into_iter() + .filter_map(|content| match content { + MessageContent::Text(text) => { + let text = if text.chars().last().is_some_and(|c| c.is_whitespace()) { + text.trim_end().to_string() + } else { + text + }; + if !text.is_empty() { + Some(anthropic::RequestContent::Text { + text, + cache_control: None, + }) + } else { + None + } + } + MessageContent::Thinking { + text: thinking, + signature, + } => { + if !thinking.is_empty() { + Some(anthropic::RequestContent::Thinking { + thinking, + signature: signature.unwrap_or_default(), + cache_control: None, + }) + } else { + None + } + } + MessageContent::RedactedThinking(data) => { + if !data.is_empty() { + Some(anthropic::RequestContent::RedactedThinking { data }) + } else { + None + } } - LanguageModelToolResultContent::Image(image) => { - tokens_from_images += image.estimate_tokens(); + MessageContent::Image(image) => Some(anthropic::RequestContent::Image { + source: anthropic::ImageSource { + source_type: "base64".to_string(), + media_type: "image/png".to_string(), + data: image.source.to_string(), + }, + cache_control: None, + }), + MessageContent::ToolUse(tool_use) => { + Some(anthropic::RequestContent::ToolUse { + id: tool_use.id.to_string(), + name: tool_use.name.to_string(), + input: tool_use.input, + cache_control: None, + }) + } + MessageContent::ToolResult(tool_result) => { + Some(anthropic::RequestContent::ToolResult { + tool_use_id: tool_result.tool_use_id.to_string(), + is_error: tool_result.is_error, + content: match tool_result.content { + LanguageModelToolResultContent::Text(text) => { + ToolResultContent::Plain(text.to_string()) + } + LanguageModelToolResultContent::Image(image) => { + ToolResultContent::Multipart(vec![ToolResultPart::Image { + source: anthropic::ImageSource { + source_type: "base64".to_string(), + media_type: "image/png".to_string(), + data: image.source.to_string(), + }, + }]) + } + }, + cache_control: None, + }) } - }, + }) + .collect(); + let anthropic_role = match message.role { + Role::User => anthropic::Role::User, + Role::Assistant => anthropic::Role::Assistant, + Role::System => unreachable!("System role should never occur here"), + }; + if let Some(last_message) = new_messages.last_mut() + && last_message.role == anthropic_role + { + last_message.content.extend(anthropic_message_content); + continue; } - } - if !string_contents.is_empty() { - string_messages.push(tiktoken_rs::ChatCompletionRequestMessage { - role: match message.role { - Role::User => "user".into(), - Role::Assistant => "assistant".into(), - Role::System => "system".into(), - }, - content: Some(string_contents), - name: None, - function_call: None, + new_messages.push(anthropic::Message { + role: anthropic_role, + content: anthropic_message_content, }); } + Role::System => { + if !system_message.is_empty() { + system_message.push_str("\n\n"); + } + system_message.push_str(&message.string_contents()); + } + } + } + + CountTokensRequest { + model, + messages: new_messages, + system: if system_message.is_empty() { + None + } else { + Some(anthropic::StringOrContents::String(system_message)) + }, + thinking: if request.thinking_allowed + && let AnthropicModelMode::Thinking { budget_tokens } = mode + { + Some(anthropic::Thinking::Enabled { budget_tokens }) + } else { + None + }, + tools: request + .tools + .into_iter() + .map(|tool| anthropic::Tool { + name: tool.name, + description: tool.description, + input_schema: tool.input_schema, + }) + .collect(), + tool_choice: request.tool_choice.map(|choice| match choice { + LanguageModelToolChoice::Auto => anthropic::ToolChoice::Auto, + LanguageModelToolChoice::Any => anthropic::ToolChoice::Any, + LanguageModelToolChoice::None => anthropic::ToolChoice::None, + }), + } +} + +/// Estimate tokens using tiktoken. Used as a fallback when the API is unavailable, +/// or by providers (like Zed Cloud) that don't have direct Anthropic API access. +pub fn count_anthropic_tokens_with_tiktoken(request: LanguageModelRequest) -> Result { + let messages = request.messages; + let mut tokens_from_images = 0; + let mut string_messages = Vec::with_capacity(messages.len()); + + for message in messages { + let mut string_contents = String::new(); + + for content in message.content { + match content { + MessageContent::Text(text) => { + string_contents.push_str(&text); + } + MessageContent::Thinking { .. } => { + // Thinking blocks are not included in the input token count. + } + MessageContent::RedactedThinking(_) => { + // Thinking blocks are not included in the input token count. + } + MessageContent::Image(image) => { + tokens_from_images += image.estimate_tokens(); + } + MessageContent::ToolUse(_tool_use) => { + // TODO: Estimate token usage from tool uses. + } + MessageContent::ToolResult(tool_result) => match &tool_result.content { + LanguageModelToolResultContent::Text(text) => { + string_contents.push_str(text); + } + LanguageModelToolResultContent::Image(image) => { + tokens_from_images += image.estimate_tokens(); + } + }, + } + } + + if !string_contents.is_empty() { + string_messages.push(tiktoken_rs::ChatCompletionRequestMessage { + role: match message.role { + Role::User => "user".into(), + Role::Assistant => "assistant".into(), + Role::System => "system".into(), + }, + content: Some(string_contents), + name: None, + function_call: None, + }); } + } - // Tiktoken doesn't yet support these models, so we manually use the - // same tokenizer as GPT-4. - tiktoken_rs::num_tokens_from_messages("gpt-4", &string_messages) - .map(|tokens| (tokens + tokens_from_images) as u64) - }) - .boxed() + // Tiktoken doesn't yet support these models, so we manually use the + // same tokenizer as GPT-4. + tiktoken_rs::num_tokens_from_messages("gpt-4", &string_messages) + .map(|tokens| (tokens + tokens_from_images) as u64) } impl AnthropicModel { @@ -386,7 +533,40 @@ impl LanguageModel for AnthropicModel { request: LanguageModelRequest, cx: &App, ) -> BoxFuture<'static, Result> { - count_anthropic_tokens(request, cx) + let http_client = self.http_client.clone(); + let model_id = self.model.request_id().to_string(); + let mode = self.model.mode(); + + let (api_key, api_url) = self.state.read_with(cx, |state, cx| { + let api_url = AnthropicLanguageModelProvider::api_url(cx); + ( + state.api_key_state.key(&api_url).map(|k| k.to_string()), + api_url.to_string(), + ) + }); + + async move { + // If no API key, fall back to tiktoken estimation + let Some(api_key) = api_key else { + return count_anthropic_tokens_with_tiktoken(request); + }; + + let count_request = + into_anthropic_count_tokens_request(request.clone(), model_id, mode); + + match anthropic::count_tokens(http_client.as_ref(), &api_url, &api_key, count_request) + .await + { + Ok(response) => Ok(response.input_tokens), + Err(err) => { + log::error!( + "Anthropic count_tokens API failed, falling back to tiktoken: {err:?}" + ); + count_anthropic_tokens_with_tiktoken(request) + } + } + } + .boxed() } fn stream_completion( diff --git a/crates/language_models/src/provider/cloud.rs b/crates/language_models/src/provider/cloud.rs index 508a77d38abcf2143170382e945ab6ce31f3a623..def1cef84d3166d08dcc7638ca5a29cabbd149c5 100644 --- a/crates/language_models/src/provider/cloud.rs +++ b/crates/language_models/src/provider/cloud.rs @@ -42,7 +42,9 @@ use thiserror::Error; use ui::{TintColor, prelude::*}; use util::{ResultExt as _, maybe}; -use crate::provider::anthropic::{AnthropicEventMapper, count_anthropic_tokens, into_anthropic}; +use crate::provider::anthropic::{ + AnthropicEventMapper, count_anthropic_tokens_with_tiktoken, into_anthropic, +}; use crate::provider::google::{GoogleEventMapper, into_google}; use crate::provider::open_ai::{OpenAiEventMapper, count_open_ai_tokens, into_open_ai}; use crate::provider::x_ai::count_xai_tokens; @@ -667,9 +669,9 @@ impl LanguageModel for CloudLanguageModel { cx: &App, ) -> BoxFuture<'static, Result> { match self.model.provider { - cloud_llm_client::LanguageModelProvider::Anthropic => { - count_anthropic_tokens(request, cx) - } + cloud_llm_client::LanguageModelProvider::Anthropic => cx + .background_spawn(async move { count_anthropic_tokens_with_tiktoken(request) }) + .boxed(), cloud_llm_client::LanguageModelProvider::OpenAi => { let model = match open_ai::Model::from_id(&self.model.id.0) { Ok(model) => model, From abcf5a127357e8d24b033550eed38c5966eee6cb Mon Sep 17 00:00:00 2001 From: "Joseph T. Lyons" Date: Tue, 16 Dec 2025 14:41:59 -0500 Subject: [PATCH 401/621] Revert "gpui: Take advantage of unified memory on Apple silicon (#44273)" (#45022) This reverts commit 2441dc3f6637431a781ae10b2e1aa8c4704b9502. Release Notes: - N/A --- crates/gpui/src/platform/mac/metal_atlas.rs | 9 --- .../gpui/src/platform/mac/metal_renderer.rs | 61 ++++--------------- 2 files changed, 12 insertions(+), 58 deletions(-) diff --git a/crates/gpui/src/platform/mac/metal_atlas.rs b/crates/gpui/src/platform/mac/metal_atlas.rs index 9b43efe361a0816e32e858a44cafec66c42e7f85..8282530c5efdc13ca95a1f04c0f6ef1a23c8366c 100644 --- a/crates/gpui/src/platform/mac/metal_atlas.rs +++ b/crates/gpui/src/platform/mac/metal_atlas.rs @@ -15,9 +15,6 @@ pub(crate) struct MetalAtlas(Mutex); impl MetalAtlas { pub(crate) fn new(device: Device) -> Self { MetalAtlas(Mutex::new(MetalAtlasState { - // Shared memory can be used only if CPU and GPU share the same memory space. - // https://developer.apple.com/documentation/metal/setting-resource-storage-modes - unified_memory: device.has_unified_memory(), device: AssertSend(device), monochrome_textures: Default::default(), polychrome_textures: Default::default(), @@ -32,7 +29,6 @@ impl MetalAtlas { struct MetalAtlasState { device: AssertSend, - unified_memory: bool, monochrome_textures: AtlasTextureList, polychrome_textures: AtlasTextureList, tiles_by_key: FxHashMap, @@ -150,11 +146,6 @@ impl MetalAtlasState { } texture_descriptor.set_pixel_format(pixel_format); texture_descriptor.set_usage(usage); - texture_descriptor.set_storage_mode(if self.unified_memory { - metal::MTLStorageMode::Shared - } else { - metal::MTLStorageMode::Managed - }); let metal_texture = self.device.new_texture(&texture_descriptor); let texture_list = match kind { diff --git a/crates/gpui/src/platform/mac/metal_renderer.rs b/crates/gpui/src/platform/mac/metal_renderer.rs index 6d7b82507fb581ec1f124e153e5bb91d3eaf9d25..550041a0ccb4cd39bc7a86317d9540e806af2a28 100644 --- a/crates/gpui/src/platform/mac/metal_renderer.rs +++ b/crates/gpui/src/platform/mac/metal_renderer.rs @@ -76,22 +76,12 @@ impl InstanceBufferPool { self.buffers.clear(); } - pub(crate) fn acquire( - &mut self, - device: &metal::Device, - unified_memory: bool, - ) -> InstanceBuffer { + pub(crate) fn acquire(&mut self, device: &metal::Device) -> InstanceBuffer { let buffer = self.buffers.pop().unwrap_or_else(|| { - let options = if unified_memory { - MTLResourceOptions::StorageModeShared - // Buffers are write only which can benefit from the combined cache - // https://developer.apple.com/documentation/metal/mtlresourceoptions/cpucachemodewritecombined - | MTLResourceOptions::CPUCacheModeWriteCombined - } else { - MTLResourceOptions::StorageModeManaged - }; - - device.new_buffer(self.buffer_size as u64, options) + device.new_buffer( + self.buffer_size as u64, + MTLResourceOptions::StorageModeManaged, + ) }); InstanceBuffer { metal_buffer: buffer, @@ -109,7 +99,6 @@ impl InstanceBufferPool { pub(crate) struct MetalRenderer { device: metal::Device, layer: metal::MetalLayer, - unified_memory: bool, presents_with_transaction: bool, command_queue: CommandQueue, paths_rasterization_pipeline_state: metal::RenderPipelineState, @@ -190,10 +179,6 @@ impl MetalRenderer { output } - // Shared memory can be used only if CPU and GPU share the same memory space. - // https://developer.apple.com/documentation/metal/setting-resource-storage-modes - let unified_memory = device.has_unified_memory(); - let unit_vertices = [ to_float2_bits(point(0., 0.)), to_float2_bits(point(1., 0.)), @@ -205,12 +190,7 @@ impl MetalRenderer { let unit_vertices = device.new_buffer_with_data( unit_vertices.as_ptr() as *const c_void, mem::size_of_val(&unit_vertices) as u64, - if unified_memory { - MTLResourceOptions::StorageModeShared - | MTLResourceOptions::CPUCacheModeWriteCombined - } else { - MTLResourceOptions::StorageModeManaged - }, + MTLResourceOptions::StorageModeManaged, ); let paths_rasterization_pipeline_state = build_path_rasterization_pipeline_state( @@ -288,7 +268,6 @@ impl MetalRenderer { device, layer, presents_with_transaction: false, - unified_memory, command_queue, paths_rasterization_pipeline_state, path_sprites_pipeline_state, @@ -358,23 +337,14 @@ impl MetalRenderer { texture_descriptor.set_width(size.width.0 as u64); texture_descriptor.set_height(size.height.0 as u64); texture_descriptor.set_pixel_format(metal::MTLPixelFormat::BGRA8Unorm); - texture_descriptor.set_storage_mode(metal::MTLStorageMode::Private); texture_descriptor .set_usage(metal::MTLTextureUsage::RenderTarget | metal::MTLTextureUsage::ShaderRead); self.path_intermediate_texture = Some(self.device.new_texture(&texture_descriptor)); if self.path_sample_count > 1 { - // https://developer.apple.com/documentation/metal/choosing-a-resource-storage-mode-for-apple-gpus - // Rendering MSAA textures are done in a single pass, so we can use memory-less storage on Apple Silicon - let storage_mode = if self.unified_memory { - metal::MTLStorageMode::Memoryless - } else { - metal::MTLStorageMode::Private - }; - let mut msaa_descriptor = texture_descriptor; msaa_descriptor.set_texture_type(metal::MTLTextureType::D2Multisample); - msaa_descriptor.set_storage_mode(storage_mode); + msaa_descriptor.set_storage_mode(metal::MTLStorageMode::Private); msaa_descriptor.set_sample_count(self.path_sample_count as _); self.path_intermediate_msaa_texture = Some(self.device.new_texture(&msaa_descriptor)); } else { @@ -408,10 +378,7 @@ impl MetalRenderer { }; loop { - let mut instance_buffer = self - .instance_buffer_pool - .lock() - .acquire(&self.device, self.unified_memory); + let mut instance_buffer = self.instance_buffer_pool.lock().acquire(&self.device); let command_buffer = self.draw_primitives(scene, &mut instance_buffer, drawable, viewport_size); @@ -583,14 +550,10 @@ impl MetalRenderer { command_encoder.end_encoding(); - if !self.unified_memory { - // Sync the instance buffer to the GPU - instance_buffer.metal_buffer.did_modify_range(NSRange { - location: 0, - length: instance_offset as NSUInteger, - }); - } - + instance_buffer.metal_buffer.did_modify_range(NSRange { + location: 0, + length: instance_offset as NSUInteger, + }); Ok(command_buffer.to_owned()) } From 7972baafe98b7d4acbc4b0a847944552c2a17a24 Mon Sep 17 00:00:00 2001 From: Bennet Bo Fenner Date: Tue, 16 Dec 2025 21:07:10 +0100 Subject: [PATCH 402/621] git: Prevent customizing commit message prompt for legacy Zed Pro users (#45016) We need to prevent this, since commit message generation did not count as a prompt in the old billing model. If users of Legacy Zed Pro customise the prompt, it will count as an actual prompt since our matching algorithm will fail. We can remove this once we stop supporting Legacy Zed Pro on 17 January. Release Notes: - N/A --- crates/git_ui/src/git_panel.rs | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs index d7be4dfe723e9cbe312420e920e4b4e90f080585..390f5cf2c28bfc0ff1aef5226e125d08db37dd68 100644 --- a/crates/git_ui/src/git_panel.rs +++ b/crates/git_ui/src/git_panel.rs @@ -43,7 +43,8 @@ use gpui::{ use itertools::Itertools; use language::{Buffer, File}; use language_model::{ - ConfiguredModel, LanguageModelRegistry, LanguageModelRequest, LanguageModelRequestMessage, Role, + ConfiguredModel, LanguageModelRegistry, LanguageModelRequest, LanguageModelRequestMessage, + Role, ZED_CLOUD_PROVIDER_ID, }; use menu::{Confirm, SecondaryConfirm, SelectFirst, SelectLast, SelectNext, SelectPrevious}; use multi_buffer::ExcerptInfo; @@ -2422,9 +2423,20 @@ impl GitPanel { } } - async fn load_commit_message_prompt(cx: &mut AsyncApp) -> String { + async fn load_commit_message_prompt( + is_using_legacy_zed_pro: bool, + cx: &mut AsyncApp, + ) -> String { const DEFAULT_PROMPT: &str = include_str!("commit_message_prompt.txt"); + // Remove this once we stop supporting legacy Zed Pro + // In legacy Zed Pro, Git commit summary generation did not count as a + // prompt. If the user changes the prompt, our classification will fail, + // meaning that users will be charged for generating commit messages. + if is_using_legacy_zed_pro { + return DEFAULT_PROMPT.to_string(); + } + let load = async { let store = cx.update(|cx| PromptStore::global(cx)).ok()?.await.ok()?; store @@ -2466,6 +2478,13 @@ impl GitPanel { let project = self.project.clone(); let repo_work_dir = repo.read(cx).work_directory_abs_path.clone(); + // Remove this once we stop supporting legacy Zed Pro + let is_using_legacy_zed_pro = provider.id() == ZED_CLOUD_PROVIDER_ID + && self.workspace.upgrade().map_or(false, |workspace| { + workspace.read(cx).user_store().read(cx).plan() + == Some(cloud_llm_client::Plan::V1(cloud_llm_client::PlanV1::ZedPro)) + }); + self.generate_commit_message_task = Some(cx.spawn(async move |this, mut cx| { async move { let _defer = cx.on_drop(&this, |this, _cx| { @@ -2501,7 +2520,7 @@ impl GitPanel { let rules_content = Self::load_project_rules(&project, &repo_work_dir, &mut cx).await; - let prompt = Self::load_commit_message_prompt(&mut cx).await; + let prompt = Self::load_commit_message_prompt(is_using_legacy_zed_pro, &mut cx).await; let subject = this.update(cx, |this, cx| { this.commit_editor.read(cx).text(cx).lines().next().map(ToOwned::to_owned).unwrap_or_default() From 301d7fbc6163df5e8404853f7686ee54e4168e85 Mon Sep 17 00:00:00 2001 From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Date: Tue, 16 Dec 2025 18:23:30 -0300 Subject: [PATCH 403/621] agent_ui: Add keybinding to cycle through favorited models (#45032) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Similar to how you can use `shift-tab` to cycle through profiles/modes, you can now use `alt-tab` to cycle through the language models you have favorited. Screenshot 2025-12-16 at 5  23@2x Release Notes: - agent: Added the ability to cycle through favorited models using the `alt-tab` keybinding. --- assets/keymaps/default-linux.json | 2 + assets/keymaps/default-macos.json | 5 ++ assets/keymaps/default-windows.json | 3 + crates/agent_ui/src/acp/model_selector.rs | 61 +++++++++++++++++++ .../src/acp/model_selector_popover.rs | 58 +++++++++++++++--- crates/agent_ui/src/acp/thread_view.rs | 11 +++- crates/agent_ui/src/agent_ui.rs | 2 + .../agent_ui/src/language_model_selector.rs | 35 +++++++++++ crates/agent_ui/src/text_thread_editor.rs | 54 ++++++++++++++-- .../src/ui/model_selector_components.rs | 8 +-- 10 files changed, 220 insertions(+), 19 deletions(-) diff --git a/assets/keymaps/default-linux.json b/assets/keymaps/default-linux.json index 5a37614180d46b4a79b97f9a23665cbf5372cc0a..1016a20bd6facdc8f5ef9163ebda3e03d451c5cf 100644 --- a/assets/keymaps/default-linux.json +++ b/assets/keymaps/default-linux.json @@ -252,6 +252,7 @@ "ctrl-y": "agent::AllowOnce", "ctrl-alt-y": "agent::AllowAlways", "ctrl-alt-z": "agent::RejectOnce", + "alt-tab": "agent::CycleFavoriteModels", }, }, { @@ -346,6 +347,7 @@ "ctrl-shift-y": "agent::KeepAll", "ctrl-shift-n": "agent::RejectAll", "shift-tab": "agent::CycleModeSelector", + "alt-tab": "agent::CycleFavoriteModels", }, }, { diff --git a/assets/keymaps/default-macos.json b/assets/keymaps/default-macos.json index 8c8094495e16a9f26adaa380f584abe5e3bc2947..c80edf01a02347cf678fe9cb24390f2fca41d70e 100644 --- a/assets/keymaps/default-macos.json +++ b/assets/keymaps/default-macos.json @@ -266,6 +266,7 @@ "cmd-g": "search::SelectNextMatch", "cmd-shift-g": "search::SelectPreviousMatch", "cmd-k l": "agent::OpenRulesLibrary", + "alt-tab": "agent::CycleFavoriteModels", }, }, { @@ -292,6 +293,7 @@ "cmd-y": "agent::AllowOnce", "cmd-alt-y": "agent::AllowAlways", "cmd-alt-z": "agent::RejectOnce", + "alt-tab": "agent::CycleFavoriteModels", }, }, { @@ -386,6 +388,7 @@ "cmd-shift-y": "agent::KeepAll", "cmd-shift-n": "agent::RejectAll", "shift-tab": "agent::CycleModeSelector", + "alt-tab": "agent::CycleFavoriteModels", }, }, { @@ -397,6 +400,7 @@ "cmd-shift-y": "agent::KeepAll", "cmd-shift-n": "agent::RejectAll", "shift-tab": "agent::CycleModeSelector", + "alt-tab": "agent::CycleFavoriteModels", }, }, { @@ -880,6 +884,7 @@ "use_key_equivalents": true, "bindings": { "cmd-alt-/": "agent::ToggleModelSelector", + "alt-tab": "agent::CycleFavoriteModels", "ctrl-[": "agent::CyclePreviousInlineAssist", "ctrl-]": "agent::CycleNextInlineAssist", "cmd-shift-enter": "inline_assistant::ThumbsUpResult", diff --git a/assets/keymaps/default-windows.json b/assets/keymaps/default-windows.json index 74320ae637080da92108f195eabca537e3a71406..dcc828ddf2ef63f3fef6e7e12d9349bead57572e 100644 --- a/assets/keymaps/default-windows.json +++ b/assets/keymaps/default-windows.json @@ -253,6 +253,7 @@ "shift-alt-a": "agent::AllowOnce", "ctrl-alt-y": "agent::AllowAlways", "shift-alt-z": "agent::RejectOnce", + "alt-tab": "agent::CycleFavoriteModels", }, }, { @@ -342,6 +343,7 @@ "ctrl-shift-y": "agent::KeepAll", "ctrl-shift-n": "agent::RejectAll", "shift-tab": "agent::CycleModeSelector", + "alt-tab": "agent::CycleFavoriteModels", }, }, { @@ -353,6 +355,7 @@ "ctrl-shift-y": "agent::KeepAll", "ctrl-shift-n": "agent::RejectAll", "shift-tab": "agent::CycleModeSelector", + "alt-tab": "agent::CycleFavoriteModels", }, }, { diff --git a/crates/agent_ui/src/acp/model_selector.rs b/crates/agent_ui/src/acp/model_selector.rs index f885ff12e598168abdf7727dc03e4814e5de3b49..cff5334a00472fd6f49abcb17897b4ed3c9f590e 100644 --- a/crates/agent_ui/src/acp/model_selector.rs +++ b/crates/agent_ui/src/acp/model_selector.rs @@ -119,6 +119,67 @@ impl AcpModelPickerDelegate { pub fn active_model(&self) -> Option<&AgentModelInfo> { self.selected_model.as_ref() } + + pub fn cycle_favorite_models(&mut self, window: &mut Window, cx: &mut Context>) { + if !self.selector.supports_favorites() { + return; + } + + let favorites = AgentSettings::get_global(cx).favorite_model_ids(); + + if favorites.is_empty() { + return; + } + + let Some(models) = self.models.clone() else { + return; + }; + + let all_models: Vec = match models { + AgentModelList::Flat(list) => list, + AgentModelList::Grouped(index_map) => index_map + .into_values() + .flatten() + .collect::>(), + }; + + let favorite_models = all_models + .iter() + .filter(|model| favorites.contains(&model.id)) + .unique_by(|model| &model.id) + .cloned() + .collect::>(); + + let current_id = self.selected_model.as_ref().map(|m| m.id.clone()); + + let current_index_in_favorites = current_id + .as_ref() + .and_then(|id| favorite_models.iter().position(|m| &m.id == id)) + .unwrap_or(usize::MAX); + + let next_index = if current_index_in_favorites == usize::MAX { + 0 + } else { + (current_index_in_favorites + 1) % favorite_models.len() + }; + + let next_model = favorite_models[next_index].clone(); + + self.selector + .select_model(next_model.id.clone(), cx) + .detach_and_log_err(cx); + + self.selected_model = Some(next_model); + + // Keep the picker selection aligned with the newly-selected model + if let Some(new_index) = self.filtered_entries.iter().position(|entry| { + matches!(entry, AcpModelPickerEntry::Model(model_info, _) if self.selected_model.as_ref().is_some_and(|selected| model_info.id == selected.id)) + }) { + self.set_selected_index(new_index, window, cx); + } else { + cx.notify(); + } + } } impl PickerDelegate for AcpModelPickerDelegate { diff --git a/crates/agent_ui/src/acp/model_selector_popover.rs b/crates/agent_ui/src/acp/model_selector_popover.rs index e2393c11bd6c23b79397abf274fb6539c0c7063f..d6709081863c9545fba4c6e2304f195e77b013df 100644 --- a/crates/agent_ui/src/acp/model_selector_popover.rs +++ b/crates/agent_ui/src/acp/model_selector_popover.rs @@ -3,15 +3,15 @@ use std::sync::Arc; use acp_thread::{AgentModelInfo, AgentModelSelector}; use agent_servers::AgentServer; +use agent_settings::AgentSettings; use fs::Fs; use gpui::{Entity, FocusHandle}; use picker::popover_menu::PickerPopoverMenu; -use ui::{ - ButtonLike, Context, IntoElement, PopoverMenuHandle, SharedString, TintColor, Tooltip, Window, - prelude::*, -}; +use settings::Settings as _; +use ui::{ButtonLike, KeyBinding, PopoverMenuHandle, TintColor, Tooltip, prelude::*}; use zed_actions::agent::ToggleModelSelector; +use crate::CycleFavoriteModels; use crate::acp::{AcpModelSelector, model_selector::acp_model_selector}; pub struct AcpModelSelectorPopover { @@ -54,6 +54,12 @@ impl AcpModelSelectorPopover { pub fn active_model<'a>(&self, cx: &'a App) -> Option<&'a AgentModelInfo> { self.selector.read(cx).delegate.active_model() } + + pub fn cycle_favorite_models(&self, window: &mut Window, cx: &mut Context) { + self.selector.update(cx, |selector, cx| { + selector.delegate.cycle_favorite_models(window, cx); + }); + } } impl Render for AcpModelSelectorPopover { @@ -74,6 +80,46 @@ impl Render for AcpModelSelectorPopover { (Color::Muted, IconName::ChevronDown) }; + let tooltip = Tooltip::element({ + move |_, cx| { + let focus_handle = focus_handle.clone(); + let should_show_cycle_row = !AgentSettings::get_global(cx) + .favorite_model_ids() + .is_empty(); + + v_flex() + .gap_1() + .child( + h_flex() + .gap_2() + .justify_between() + .child(Label::new("Change Model")) + .child(KeyBinding::for_action_in( + &ToggleModelSelector, + &focus_handle, + cx, + )), + ) + .when(should_show_cycle_row, |this| { + this.child( + h_flex() + .pt_1() + .gap_2() + .border_t_1() + .border_color(cx.theme().colors().border_variant) + .justify_between() + .child(Label::new("Cycle Favorited Models")) + .child(KeyBinding::for_action_in( + &CycleFavoriteModels, + &focus_handle, + cx, + )), + ) + }) + .into_any() + } + }); + PickerPopoverMenu::new( self.selector.clone(), ButtonLike::new("active-model") @@ -88,9 +134,7 @@ impl Render for AcpModelSelectorPopover { .ml_0p5(), ) .child(Icon::new(icon).color(Color::Muted).size(IconSize::XSmall)), - move |_window, cx| { - Tooltip::for_action_in("Change Model", &ToggleModelSelector, &focus_handle, cx) - }, + tooltip, gpui::Corner::BottomRight, cx, ) diff --git a/crates/agent_ui/src/acp/thread_view.rs b/crates/agent_ui/src/acp/thread_view.rs index 90134ebfb458a37f01ed99fe7345238c763e5418..05162348db060bff05aa7b1dd223815895f02e2d 100644 --- a/crates/agent_ui/src/acp/thread_view.rs +++ b/crates/agent_ui/src/acp/thread_view.rs @@ -66,8 +66,8 @@ use crate::profile_selector::{ProfileProvider, ProfileSelector}; use crate::ui::{AgentNotification, AgentNotificationEvent, BurnModeTooltip, UsageCallout}; use crate::{ AgentDiffPane, AgentPanel, AllowAlways, AllowOnce, ContinueThread, ContinueWithBurnMode, - CycleModeSelector, ExpandMessageEditor, Follow, KeepAll, NewThread, OpenAgentDiff, OpenHistory, - RejectAll, RejectOnce, ToggleBurnMode, ToggleProfileSelector, + CycleFavoriteModels, CycleModeSelector, ExpandMessageEditor, Follow, KeepAll, NewThread, + OpenAgentDiff, OpenHistory, RejectAll, RejectOnce, ToggleBurnMode, ToggleProfileSelector, }; #[derive(Copy, Clone, Debug, PartialEq, Eq)] @@ -4293,6 +4293,13 @@ impl AcpThreadView { .update(cx, |model_selector, cx| model_selector.toggle(window, cx)); } })) + .on_action(cx.listener(|this, _: &CycleFavoriteModels, window, cx| { + if let Some(model_selector) = this.model_selector.as_ref() { + model_selector.update(cx, |model_selector, cx| { + model_selector.cycle_favorite_models(window, cx); + }); + } + })) .p_2() .gap_2() .border_t_1() diff --git a/crates/agent_ui/src/agent_ui.rs b/crates/agent_ui/src/agent_ui.rs index 1622d17f5852d825b9c8d69996fad7c89bb89dce..c80c7b43644ab949e748609435e33dfe9f31d54e 100644 --- a/crates/agent_ui/src/agent_ui.rs +++ b/crates/agent_ui/src/agent_ui.rs @@ -68,6 +68,8 @@ actions!( ToggleProfileSelector, /// Cycles through available session modes. CycleModeSelector, + /// Cycles through favorited models in the ACP model selector. + CycleFavoriteModels, /// Expands the message editor to full size. ExpandMessageEditor, /// Removes all thread history. diff --git a/crates/agent_ui/src/language_model_selector.rs b/crates/agent_ui/src/language_model_selector.rs index 7bb42fb330dcccb4b5401217d0181d3d616fe66f..77c8c95255908dc54639ad7ac6c55f1e8b8151f0 100644 --- a/crates/agent_ui/src/language_model_selector.rs +++ b/crates/agent_ui/src/language_model_selector.rs @@ -249,6 +249,41 @@ impl LanguageModelPickerDelegate { pub fn active_model(&self, cx: &App) -> Option { (self.get_active_model)(cx) } + + pub fn cycle_favorite_models(&mut self, window: &mut Window, cx: &mut Context>) { + if self.all_models.favorites.is_empty() { + return; + } + + let active_model = (self.get_active_model)(cx); + let active_provider_id = active_model.as_ref().map(|m| m.provider.id()); + let active_model_id = active_model.as_ref().map(|m| m.model.id()); + + let current_index = self + .all_models + .favorites + .iter() + .position(|info| { + Some(info.model.provider_id()) == active_provider_id + && Some(info.model.id()) == active_model_id + }) + .unwrap_or(usize::MAX); + + let next_index = if current_index == usize::MAX { + 0 + } else { + (current_index + 1) % self.all_models.favorites.len() + }; + + let next_model = self.all_models.favorites[next_index].model.clone(); + + (self.on_model_changed)(next_model, cx); + + // Align the picker selection with the newly-active model + let new_index = + Self::get_active_model_index(&self.filtered_entries, (self.get_active_model)(cx)); + self.set_selected_index(new_index, window, cx); + } } struct GroupedModels { diff --git a/crates/agent_ui/src/text_thread_editor.rs b/crates/agent_ui/src/text_thread_editor.rs index 881eb213a3886b894a778a34cb6ba129bf42c1a4..947afe050639f89922873a12baa8b1eadfc44995 100644 --- a/crates/agent_ui/src/text_thread_editor.rs +++ b/crates/agent_ui/src/text_thread_editor.rs @@ -2,7 +2,7 @@ use crate::{ language_model_selector::{LanguageModelSelector, language_model_selector}, ui::BurnModeTooltip, }; -use agent_settings::CompletionMode; +use agent_settings::{AgentSettings, CompletionMode}; use anyhow::Result; use assistant_slash_command::{SlashCommand, SlashCommandOutputSection, SlashCommandWorkingSet}; use assistant_slash_commands::{DefaultSlashCommand, FileSlashCommand, selections_creases}; @@ -73,6 +73,8 @@ use workspace::{ }; use zed_actions::agent::{AddSelectionToThread, ToggleModelSelector}; +use crate::CycleFavoriteModels; + use crate::{slash_command::SlashCommandCompletionProvider, slash_command_picker}; use assistant_text_thread::{ CacheStatus, Content, InvokedSlashCommandId, InvokedSlashCommandStatus, Message, MessageId, @@ -2209,12 +2211,53 @@ impl TextThreadEditor { }; let focus_handle = self.editor().focus_handle(cx); + let (color, icon) = if self.language_model_selector_menu_handle.is_deployed() { (Color::Accent, IconName::ChevronUp) } else { (Color::Muted, IconName::ChevronDown) }; + let tooltip = Tooltip::element({ + move |_, cx| { + let focus_handle = focus_handle.clone(); + let should_show_cycle_row = !AgentSettings::get_global(cx) + .favorite_model_ids() + .is_empty(); + + v_flex() + .gap_1() + .child( + h_flex() + .gap_2() + .justify_between() + .child(Label::new("Change Model")) + .child(KeyBinding::for_action_in( + &ToggleModelSelector, + &focus_handle, + cx, + )), + ) + .when(should_show_cycle_row, |this| { + this.child( + h_flex() + .pt_1() + .gap_2() + .border_t_1() + .border_color(cx.theme().colors().border_variant) + .justify_between() + .child(Label::new("Cycle Favorited Models")) + .child(KeyBinding::for_action_in( + &CycleFavoriteModels, + &focus_handle, + cx, + )), + ) + }) + .into_any() + } + }); + PickerPopoverMenu::new( self.language_model_selector.clone(), ButtonLike::new("active-model") @@ -2231,9 +2274,7 @@ impl TextThreadEditor { ) .child(Icon::new(icon).color(color).size(IconSize::XSmall)), ), - move |_window, cx| { - Tooltip::for_action_in("Change Model", &ToggleModelSelector, &focus_handle, cx) - }, + tooltip, gpui::Corner::BottomRight, cx, ) @@ -2593,6 +2634,11 @@ impl Render for TextThreadEditor { .on_action(move |_: &ToggleModelSelector, window, cx| { language_model_selector.toggle(window, cx); }) + .on_action(cx.listener(|this, _: &CycleFavoriteModels, window, cx| { + this.language_model_selector.update(cx, |selector, cx| { + selector.delegate.cycle_favorite_models(window, cx); + }); + })) .size_full() .child( div() diff --git a/crates/agent_ui/src/ui/model_selector_components.rs b/crates/agent_ui/src/ui/model_selector_components.rs index 184c8e0ba2d3ea307c869e42a13b75f36e713c42..061b4f58288798696b068a091fb392c033906627 100644 --- a/crates/agent_ui/src/ui/model_selector_components.rs +++ b/crates/agent_ui/src/ui/model_selector_components.rs @@ -113,13 +113,9 @@ impl RenderOnce for ModelSelectorListItem { .child(Label::new(self.title).truncate()), ) .end_slot(div().pr_2().when(self.is_selected, |this| { - this.child( - Icon::new(IconName::Check) - .color(Color::Accent) - .size(IconSize::Small), - ) + this.child(Icon::new(IconName::Check).color(Color::Accent)) })) - .end_hover_slot(div().pr_2().when_some(self.on_toggle_favorite, { + .end_hover_slot(div().pr_1p5().when_some(self.on_toggle_favorite, { |this, handle_click| { let (icon, color, tooltip) = if is_favorite { (IconName::StarFilled, Color::Accent, "Unfavorite Model") From eba811a127170a0fba4ebdf47bf52865ee5f5dc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torstein=20S=C3=B8rnes?= Date: Tue, 16 Dec 2025 22:44:39 +0100 Subject: [PATCH 404/621] Add support for MCP tools/list_changed notification (#42453) ## Summary This PR adds support for the MCP (Model Context Protocol) `notifications/tools/list_changed` notification, enabling dynamic tool discovery when MCP servers add, remove, or modify their available tools at runtime. ## Release Notes: - Improved: MCP tools are now automatically reloaded when a context server sends a `tools/list_changed` notification, eliminating the need to restart the server to discover new tools. ## Changes - Register a notification handler for `notifications/tools/list_changed` in `ContextServerRegistry` - Automatically reload tools when the notification is received - Handler is registered both on initial server startup and when a server transitions to `Running` status ## Motivation The MCP specification includes a `notifications/tools/list_changed` notification to inform clients when the list of available tools has changed. Previously, Zed's agent would only load tools once when a context server started. This meant that: 1. If an MCP server dynamically registered new tools after initialization, they would not be available to the agent 2. The only way to refresh tools was to restart the entire context server 3. Tools that were removed or modified would remain in the old state until restart ## Implementation Details The implementation follows these steps: 1. When a context server transitions to `Running` status, register a notification handler for `notifications/tools/list_changed` 2. The handler captures a weak reference to the `ContextServerRegistry` entity 3. When the notification is received, spawn a task that calls `reload_tools_for_server` with the server ID 4. The existing `reload_tools_for_server` method handles fetching the updated tool list and notifying observers This approach is minimal and reuses existing tool-loading infrastructure. ## Testing - [x] Code compiles with `./script/clippy -p agent` - The notification handler infrastructure already exists and is tested in the codebase - The `reload_tools_for_server` method is already tested and working ## Benefits - Improves developer experience by enabling hot-reloading of MCP tools - Aligns with the MCP specification's capability negotiation system - No breaking changes to existing functionality - Enables more flexible and dynamic MCP server implementations ## Related Issues This implements part of the MCP specification that was already defined in the type system but not wired up to actually handle the notifications. --------- Co-authored-by: Agus Zubiaga --- Cargo.lock | 1 + .../src/tools/context_server_registry.rs | 68 +++++++++--- crates/context_server/Cargo.toml | 1 + crates/context_server/src/client.rs | 103 +++++++++++++++--- crates/context_server/src/context_server.rs | 16 --- crates/context_server/src/protocol.rs | 6 +- 6 files changed, 148 insertions(+), 47 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6908a8ed5185ea71cc51a34d63990decaaf082d9..080a6a4cf4183fb5cade03ba36072b448ab4b70a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3623,6 +3623,7 @@ dependencies = [ "serde", "serde_json", "settings", + "slotmap", "smol", "tempfile", "terminal", diff --git a/crates/agent/src/tools/context_server_registry.rs b/crates/agent/src/tools/context_server_registry.rs index 735a47ae9fb99decbf97beb74a590f13f8f74878..3b01b2feb7dd36615a8ba7c63d81a81694e0d268 100644 --- a/crates/agent/src/tools/context_server_registry.rs +++ b/crates/agent/src/tools/context_server_registry.rs @@ -2,7 +2,7 @@ use crate::{AgentToolOutput, AnyAgentTool, ToolCallEventStream}; use agent_client_protocol::ToolKind; use anyhow::{Result, anyhow, bail}; use collections::{BTreeMap, HashMap}; -use context_server::ContextServerId; +use context_server::{ContextServerId, client::NotificationSubscription}; use gpui::{App, AppContext, AsyncApp, Context, Entity, EventEmitter, SharedString, Task}; use project::context_server_store::{ContextServerStatus, ContextServerStore}; use std::sync::Arc; @@ -31,17 +31,7 @@ struct RegisteredContextServer { prompts: BTreeMap, load_tools: Task>, load_prompts: Task>, -} - -impl RegisteredContextServer { - fn new() -> Self { - Self { - tools: BTreeMap::default(), - prompts: BTreeMap::default(), - load_tools: Task::ready(Ok(())), - load_prompts: Task::ready(Ok(())), - } - } + _tools_updated_subscription: Option, } impl ContextServerRegistry { @@ -111,10 +101,57 @@ impl ContextServerRegistry { fn get_or_register_server( &mut self, server_id: &ContextServerId, + cx: &mut Context, ) -> &mut RegisteredContextServer { self.registered_servers .entry(server_id.clone()) - .or_insert_with(RegisteredContextServer::new) + .or_insert_with(|| Self::init_registered_server(server_id, &self.server_store, cx)) + } + + fn init_registered_server( + server_id: &ContextServerId, + server_store: &Entity, + cx: &mut Context, + ) -> RegisteredContextServer { + let tools_updated_subscription = server_store + .read(cx) + .get_running_server(server_id) + .and_then(|server| { + let client = server.client()?; + + if !client.capable(context_server::protocol::ServerCapability::Tools) { + return None; + } + + let server_id = server.id(); + let this = cx.entity().downgrade(); + + Some(client.on_notification( + "notifications/tools/list_changed", + Box::new(move |_params, cx: AsyncApp| { + let server_id = server_id.clone(); + let this = this.clone(); + cx.spawn(async move |cx| { + this.update(cx, |this, cx| { + log::info!( + "Received tools/list_changed notification for server {}", + server_id + ); + this.reload_tools_for_server(server_id, cx); + }) + }) + .detach(); + }), + )) + }); + + RegisteredContextServer { + tools: BTreeMap::default(), + prompts: BTreeMap::default(), + load_tools: Task::ready(Ok(())), + load_prompts: Task::ready(Ok(())), + _tools_updated_subscription: tools_updated_subscription, + } } fn reload_tools_for_server(&mut self, server_id: ContextServerId, cx: &mut Context) { @@ -124,11 +161,12 @@ impl ContextServerRegistry { let Some(client) = server.client() else { return; }; + if !client.capable(context_server::protocol::ServerCapability::Tools) { return; } - let registered_server = self.get_or_register_server(&server_id); + let registered_server = self.get_or_register_server(&server_id, cx); registered_server.load_tools = cx.spawn(async move |this, cx| { let response = client .request::(()) @@ -167,7 +205,7 @@ impl ContextServerRegistry { return; } - let registered_server = self.get_or_register_server(&server_id); + let registered_server = self.get_or_register_server(&server_id, cx); registered_server.load_prompts = cx.spawn(async move |this, cx| { let response = client diff --git a/crates/context_server/Cargo.toml b/crates/context_server/Cargo.toml index cb48b7e6f7d000ed7f2db7aaf3cfe4d6317fe278..539b873c3527b5a01f1dfcf7b768f0758dc869b5 100644 --- a/crates/context_server/Cargo.toml +++ b/crates/context_server/Cargo.toml @@ -29,6 +29,7 @@ schemars.workspace = true serde_json.workspace = true serde.workspace = true settings.workspace = true +slotmap.workspace = true smol.workspace = true tempfile.workspace = true url = { workspace = true, features = ["serde"] } diff --git a/crates/context_server/src/client.rs b/crates/context_server/src/client.rs index f891e96250f3334540aa859fe438c87297fc0100..605f24178916faa5173c32c28be6c80ee625cb6c 100644 --- a/crates/context_server/src/client.rs +++ b/crates/context_server/src/client.rs @@ -6,6 +6,7 @@ use parking_lot::Mutex; use postage::barrier; use serde::{Deserialize, Serialize, de::DeserializeOwned}; use serde_json::{Value, value::RawValue}; +use slotmap::SlotMap; use smol::channel; use std::{ fmt, @@ -50,7 +51,7 @@ pub(crate) struct Client { next_id: AtomicI32, outbound_tx: channel::Sender, name: Arc, - notification_handlers: Arc>>, + subscription_set: Arc>, response_handlers: Arc>>>, #[allow(clippy::type_complexity)] #[allow(dead_code)] @@ -191,21 +192,20 @@ impl Client { let (outbound_tx, outbound_rx) = channel::unbounded::(); let (output_done_tx, output_done_rx) = barrier::channel(); - let notification_handlers = - Arc::new(Mutex::new(HashMap::<_, NotificationHandler>::default())); + let subscription_set = Arc::new(Mutex::new(NotificationSubscriptionSet::default())); let response_handlers = Arc::new(Mutex::new(Some(HashMap::<_, ResponseHandler>::default()))); let request_handlers = Arc::new(Mutex::new(HashMap::<_, RequestHandler>::default())); let receive_input_task = cx.spawn({ - let notification_handlers = notification_handlers.clone(); + let subscription_set = subscription_set.clone(); let response_handlers = response_handlers.clone(); let request_handlers = request_handlers.clone(); let transport = transport.clone(); async move |cx| { Self::handle_input( transport, - notification_handlers, + subscription_set, request_handlers, response_handlers, cx, @@ -236,7 +236,7 @@ impl Client { Ok(Self { server_id, - notification_handlers, + subscription_set, response_handlers, name: server_name, next_id: Default::default(), @@ -257,7 +257,7 @@ impl Client { /// to pending requests) and notifications (which trigger registered handlers). async fn handle_input( transport: Arc, - notification_handlers: Arc>>, + subscription_set: Arc>, request_handlers: Arc>>, response_handlers: Arc>>>, cx: &mut AsyncApp, @@ -282,10 +282,11 @@ impl Client { handler(Ok(message.to_string())); } } else if let Ok(notification) = serde_json::from_str::(&message) { - let mut notification_handlers = notification_handlers.lock(); - if let Some(handler) = notification_handlers.get_mut(notification.method.as_str()) { - handler(notification.params.unwrap_or(Value::Null), cx.clone()); - } + subscription_set.lock().notify( + ¬ification.method, + notification.params.unwrap_or(Value::Null), + cx, + ) } else { log::error!("Unhandled JSON from context_server: {}", message); } @@ -451,12 +452,18 @@ impl Client { Ok(()) } + #[must_use] pub fn on_notification( &self, method: &'static str, f: Box, - ) { - self.notification_handlers.lock().insert(method, f); + ) -> NotificationSubscription { + let mut notification_subscriptions = self.subscription_set.lock(); + + NotificationSubscription { + id: notification_subscriptions.add_handler(method, f), + set: self.subscription_set.clone(), + } } } @@ -485,3 +492,73 @@ impl fmt::Debug for Client { .finish_non_exhaustive() } } + +slotmap::new_key_type! { + struct NotificationSubscriptionId; +} + +#[derive(Default)] +pub struct NotificationSubscriptionSet { + // we have very few subscriptions at the moment + methods: Vec<(&'static str, Vec)>, + handlers: SlotMap, +} + +impl NotificationSubscriptionSet { + #[must_use] + fn add_handler( + &mut self, + method: &'static str, + handler: NotificationHandler, + ) -> NotificationSubscriptionId { + let id = self.handlers.insert(handler); + if let Some((_, handler_ids)) = self + .methods + .iter_mut() + .find(|(probe_method, _)| method == *probe_method) + { + debug_assert!( + handler_ids.len() < 20, + "Too many MCP handlers for {}. Consider using a different data structure.", + method + ); + + handler_ids.push(id); + } else { + self.methods.push((method, vec![id])); + }; + id + } + + fn notify(&mut self, method: &str, payload: Value, cx: &mut AsyncApp) { + let Some((_, handler_ids)) = self + .methods + .iter_mut() + .find(|(probe_method, _)| method == *probe_method) + else { + return; + }; + + for handler_id in handler_ids { + if let Some(handler) = self.handlers.get_mut(*handler_id) { + handler(payload.clone(), cx.clone()); + } + } + } +} + +pub struct NotificationSubscription { + id: NotificationSubscriptionId, + set: Arc>, +} + +impl Drop for NotificationSubscription { + fn drop(&mut self) { + let mut set = self.set.lock(); + set.handlers.remove(self.id); + set.methods.retain_mut(|(_, handler_ids)| { + handler_ids.retain(|id| *id != self.id); + !handler_ids.is_empty() + }); + } +} diff --git a/crates/context_server/src/context_server.rs b/crates/context_server/src/context_server.rs index 553e845df87a2fec30b1afbffa05b970d5d672f6..92804549c69b01dd3729efb3a0b47905cd73d813 100644 --- a/crates/context_server/src/context_server.rs +++ b/crates/context_server/src/context_server.rs @@ -96,22 +96,6 @@ impl ContextServer { self.initialize(self.new_client(cx)?).await } - /// Starts the context server, making sure handlers are registered before initialization happens - pub async fn start_with_handlers( - &self, - notification_handlers: Vec<( - &'static str, - Box, - )>, - cx: &AsyncApp, - ) -> Result<()> { - let client = self.new_client(cx)?; - for (method, handler) in notification_handlers { - client.on_notification(method, handler); - } - self.initialize(client).await - } - fn new_client(&self, cx: &AsyncApp) -> Result { Ok(match &self.configuration { ContextServerTransport::Stdio(command, working_directory) => Client::stdio( diff --git a/crates/context_server/src/protocol.rs b/crates/context_server/src/protocol.rs index 5355f20f620b5bed76bf945e863fdb5cbcc2ff43..a218a8a3e0e6352997e4152214077cb3851317b3 100644 --- a/crates/context_server/src/protocol.rs +++ b/crates/context_server/src/protocol.rs @@ -12,7 +12,7 @@ use futures::channel::oneshot; use gpui::AsyncApp; use serde_json::Value; -use crate::client::Client; +use crate::client::{Client, NotificationSubscription}; use crate::types::{self, Notification, Request}; pub struct ModelContextProtocol { @@ -119,7 +119,7 @@ impl InitializedContextServerProtocol { &self, method: &'static str, f: Box, - ) { - self.inner.on_notification(method, f); + ) -> NotificationSubscription { + self.inner.on_notification(method, f) } } From 78cd106b6453e5893728698c4bb5555af82f15ca Mon Sep 17 00:00:00 2001 From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Date: Tue, 16 Dec 2025 18:47:56 -0300 Subject: [PATCH 405/621] inline assistant: Add some slight touch ups to the rating UI (#45034) Just touching up the tooltip casing, colors, and a bit of spacing. Also added the keybiniding to close the assistant. Maybe it was obvious already but I don't think it hurts. Release Notes: - N/A --- crates/agent_ui/src/inline_prompt_editor.rs | 86 ++++++++++++++++----- 1 file changed, 65 insertions(+), 21 deletions(-) diff --git a/crates/agent_ui/src/inline_prompt_editor.rs b/crates/agent_ui/src/inline_prompt_editor.rs index 51e65447b2f888ab70f5942baca108134b239593..517f8f08a6e7e9e31b2f88d1f5ee9444202009d5 100644 --- a/crates/agent_ui/src/inline_prompt_editor.rs +++ b/crates/agent_ui/src/inline_prompt_editor.rs @@ -844,26 +844,59 @@ impl PromptEditor { if show_rating_buttons { buttons.push( - IconButton::new("thumbs-down", IconName::ThumbsDown) - .icon_color(if rated { Color::Muted } else { Color::Default }) - .shape(IconButtonShape::Square) - .disabled(rated) - .tooltip(Tooltip::text("Bad result")) - .on_click(cx.listener(|this, _, window, cx| { - this.thumbs_down(&ThumbsDownResult, window, cx); - })) - .into_any_element(), - ); - - buttons.push( - IconButton::new("thumbs-up", IconName::ThumbsUp) - .icon_color(if rated { Color::Muted } else { Color::Default }) - .shape(IconButtonShape::Square) - .disabled(rated) - .tooltip(Tooltip::text("Good result")) - .on_click(cx.listener(|this, _, window, cx| { - this.thumbs_up(&ThumbsUpResult, window, cx); - })) + h_flex() + .pl_1() + .gap_1() + .border_l_1() + .border_color(cx.theme().colors().border_variant) + .child( + IconButton::new("thumbs-up", IconName::ThumbsUp) + .shape(IconButtonShape::Square) + .map(|this| { + if rated { + this.disabled(true) + .icon_color(Color::Ignored) + .tooltip(move |_, cx| { + Tooltip::with_meta( + "Good Result", + None, + "You already rated this result", + cx, + ) + }) + } else { + this.icon_color(Color::Muted) + .tooltip(Tooltip::text("Good Result")) + } + }) + .on_click(cx.listener(|this, _, window, cx| { + this.thumbs_up(&ThumbsUpResult, window, cx); + })), + ) + .child( + IconButton::new("thumbs-down", IconName::ThumbsDown) + .shape(IconButtonShape::Square) + .map(|this| { + if rated { + this.disabled(true) + .icon_color(Color::Ignored) + .tooltip(move |_, cx| { + Tooltip::with_meta( + "Bad Result", + None, + "You already rated this result", + cx, + ) + }) + } else { + this.icon_color(Color::Muted) + .tooltip(Tooltip::text("Bad Result")) + } + }) + .on_click(cx.listener(|this, _, window, cx| { + this.thumbs_down(&ThumbsDownResult, window, cx); + })), + ) .into_any_element(), ); } @@ -927,10 +960,21 @@ impl PromptEditor { } fn render_close_button(&self, cx: &mut Context) -> AnyElement { + let focus_handle = self.editor.focus_handle(cx); + IconButton::new("cancel", IconName::Close) .icon_color(Color::Muted) .shape(IconButtonShape::Square) - .tooltip(Tooltip::text("Close Assistant")) + .tooltip({ + move |_window, cx| { + Tooltip::for_action_in( + "Close Assistant", + &editor::actions::Cancel, + &focus_handle, + cx, + ) + } + }) .on_click(cx.listener(|_, _, _, cx| cx.emit(PromptEditorEvent::CancelRequested))) .into_any_element() } From ab4cd95e9c05fa786dc36934b683995e13c4a99f Mon Sep 17 00:00:00 2001 From: Remco Smits Date: Tue, 16 Dec 2025 22:53:30 +0100 Subject: [PATCH 406/621] git_ui: Fix select next/previous entry selects non-visible entry when tree view is enabled (#45030) Before this commit, we would select a non-visible entry when a directory is collapsed. Now we correctly select the visible entry that is visually the previous/next entry in the list. **Note**: I removed the `cx.notify()` call as it's already part of the `self.scroll_to_selected_entry(cx)` call. So we don't notify twice :). Follow-up: https://github.com/zed-industries/zed/pull/45002 **Before** https://github.com/user-attachments/assets/da0b8084-0081-4d98-ad8a-c11c3b95a1b7 **After** https://github.com/user-attachments/assets/8a16afb0-fdde-4317-b419-13143d5d608e Release Notes: - git_ui: Fix select next/previous entry selects non-visible entry when tree view is enabled --- crates/git_ui/src/git_panel.rs | 91 ++++++++++++++++++++++------------ 1 file changed, 59 insertions(+), 32 deletions(-) diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs index 390f5cf2c28bfc0ff1aef5226e125d08db37dd68..37926eae5db12c83ab69613a09c4eceda1f5ffeb 100644 --- a/crates/git_ui/src/git_panel.rs +++ b/crates/git_ui/src/git_panel.rs @@ -961,28 +961,44 @@ impl GitPanel { return; } - if let Some(selected_entry) = self.selected_entry { - let new_selected_entry = if selected_entry > 0 { - selected_entry - 1 - } else { - selected_entry - }; + let Some(selected_entry) = self.selected_entry else { + return; + }; - if matches!( - self.entries.get(new_selected_entry), - Some(GitListEntry::Header(..)) - ) { - if new_selected_entry > 0 { - self.selected_entry = Some(new_selected_entry - 1) - } - } else { - self.selected_entry = Some(new_selected_entry); + let new_index = match &self.view_mode { + GitPanelViewMode::Flat => selected_entry.saturating_sub(1), + GitPanelViewMode::Tree(state) => { + let Some(current_logical_index) = state + .logical_indices + .iter() + .position(|&i| i == selected_entry) + else { + return; + }; + + state.logical_indices[current_logical_index.saturating_sub(1)] } + }; - self.scroll_to_selected_entry(cx); + if selected_entry == 0 && new_index == 0 { + return; } - cx.notify(); + if matches!( + self.entries.get(new_index.saturating_sub(1)), + Some(GitListEntry::Header(..)) + ) && new_index == 0 + { + return; + } + + if matches!(self.entries.get(new_index), Some(GitListEntry::Header(..))) { + self.selected_entry = Some(new_index.saturating_sub(1)); + } else { + self.selected_entry = Some(new_index); + } + + self.scroll_to_selected_entry(cx); } fn select_next(&mut self, _: &SelectNext, _window: &mut Window, cx: &mut Context) { @@ -991,25 +1007,36 @@ impl GitPanel { return; } - if let Some(selected_entry) = self.selected_entry { - let new_selected_entry = if selected_entry < item_count - 1 { - selected_entry + 1 - } else { - selected_entry - }; - if matches!( - self.entries.get(new_selected_entry), - Some(GitListEntry::Header(..)) - ) { - self.selected_entry = Some(new_selected_entry + 1); - } else { - self.selected_entry = Some(new_selected_entry); + let Some(selected_entry) = self.selected_entry else { + return; + }; + + if selected_entry == item_count - 1 { + return; + } + + let new_index = match &self.view_mode { + GitPanelViewMode::Flat => selected_entry.saturating_add(1), + GitPanelViewMode::Tree(state) => { + let Some(current_logical_index) = state + .logical_indices + .iter() + .position(|&i| i == selected_entry) + else { + return; + }; + + state.logical_indices[current_logical_index.saturating_add(1)] } + }; - self.scroll_to_selected_entry(cx); + if matches!(self.entries.get(new_index), Some(GitListEntry::Header(..))) { + self.selected_entry = Some(new_index.saturating_add(1)); + } else { + self.selected_entry = Some(new_index); } - cx.notify(); + self.scroll_to_selected_entry(cx); } fn select_last(&mut self, _: &SelectLast, _window: &mut Window, cx: &mut Context) { From 3a013d8090e1a96461c66c6688ddd6e51bd5f896 Mon Sep 17 00:00:00 2001 From: Anthony Eid <56899983+Anthony-Eid@users.noreply.github.com> Date: Tue, 16 Dec 2025 17:03:30 -0500 Subject: [PATCH 407/621] gpui: Add `is_action_available_in` function (#45029) This compliments the `window.is_action_available` function that already exists. Release Notes: - N/A --- crates/gpui/src/window.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/crates/gpui/src/window.rs b/crates/gpui/src/window.rs index 36e46f6961ae8a1e8581b3c01987f4641377d677..c606409661eb022b8627fe9bc9f6c53565f5569f 100644 --- a/crates/gpui/src/window.rs +++ b/crates/gpui/src/window.rs @@ -1961,7 +1961,7 @@ impl Window { } /// Determine whether the given action is available along the dispatch path to the currently focused element. - pub fn is_action_available(&self, action: &dyn Action, cx: &mut App) -> bool { + pub fn is_action_available(&self, action: &dyn Action, cx: &App) -> bool { let node_id = self.focus_node_id_in_rendered_frame(self.focused(cx).map(|handle| handle.id)); self.rendered_frame @@ -1969,6 +1969,14 @@ impl Window { .is_action_available(action, node_id) } + /// Determine whether the given action is available along the dispatch path to the given focus_handle. + pub fn is_action_available_in(&self, action: &dyn Action, focus_handle: &FocusHandle) -> bool { + let node_id = self.focus_node_id_in_rendered_frame(Some(focus_handle.id)); + self.rendered_frame + .dispatch_tree + .is_action_available(action, node_id) + } + /// The position of the mouse relative to the window. pub fn mouse_position(&self) -> Point { self.mouse_position From 28868068098d4c761465624fe8d0cd331710aea8 Mon Sep 17 00:00:00 2001 From: "Joseph T. Lyons" Date: Tue, 16 Dec 2025 17:51:33 -0500 Subject: [PATCH 408/621] Display all branches and remotes by default in the branch picker (#45041) This both matches VS Code's branch picker and makes the "Filter Remotes" button make more sense. SCR-20251216-pgkv SCR-20251216-pgqp Release Notes: - Display all branches and remotes by default in the branch picker --- crates/git_ui/src/branch_picker.rs | 143 +++++++++++++++++------------ 1 file changed, 82 insertions(+), 61 deletions(-) diff --git a/crates/git_ui/src/branch_picker.rs b/crates/git_ui/src/branch_picker.rs index 79cd89d1485f6d99349b43d92c17261cf8a644e2..c7cf72cdbd880bbd0bca7611474b42a3a600cc48 100644 --- a/crates/git_ui/src/branch_picker.rs +++ b/crates/git_ui/src/branch_picker.rs @@ -316,17 +316,17 @@ impl Entry { #[derive(Clone, Copy, PartialEq)] enum BranchFilter { - /// Only show local branches - Local, - /// Only show remote branches + /// Show both local and remote branches. + All, + /// Only show remote branches. Remote, } impl BranchFilter { fn invert(&self) -> Self { match self { - BranchFilter::Local => BranchFilter::Remote, - BranchFilter::Remote => BranchFilter::Local, + BranchFilter::All => BranchFilter::Remote, + BranchFilter::Remote => BranchFilter::All, } } } @@ -375,7 +375,7 @@ impl BranchListDelegate { selected_index: 0, last_query: Default::default(), modifiers: Default::default(), - branch_filter: BranchFilter::Local, + branch_filter: BranchFilter::All, state: PickerState::List, focus_handle: cx.focus_handle(), } @@ -518,7 +518,7 @@ impl PickerDelegate for BranchListDelegate { match self.state { PickerState::List | PickerState::NewRemote | PickerState::NewBranch => { match self.branch_filter { - BranchFilter::Local => "Select branch…", + BranchFilter::All => "Select branch or remote…", BranchFilter::Remote => "Select remote…", } } @@ -560,8 +560,8 @@ impl PickerDelegate for BranchListDelegate { self.editor_position() == PickerEditorPosition::End, |this| { let tooltip_label = match self.branch_filter { - BranchFilter::Local => "Turn Off Remote Filter", - BranchFilter::Remote => "Filter Remote Branches", + BranchFilter::All => "Filter Remote Branches", + BranchFilter::Remote => "Show All Branches", }; this.gap_1().justify_between().child({ @@ -625,40 +625,38 @@ impl PickerDelegate for BranchListDelegate { return Task::ready(()); }; - let display_remotes = self.branch_filter; + let branch_filter = self.branch_filter; cx.spawn_in(window, async move |picker, cx| { + let branch_matches_filter = |branch: &Branch| match branch_filter { + BranchFilter::All => true, + BranchFilter::Remote => branch.is_remote(), + }; + let mut matches: Vec = if query.is_empty() { - all_branches + let mut matches: Vec = all_branches .into_iter() - .filter(|branch| { - if display_remotes == BranchFilter::Remote { - branch.is_remote() - } else { - !branch.is_remote() - } - }) + .filter(|branch| branch_matches_filter(branch)) .map(|branch| Entry::Branch { branch, positions: Vec::new(), }) - .collect() + .collect(); + + // Keep the existing recency sort within each group, but show local branches first. + matches.sort_by_key(|entry| entry.as_branch().is_some_and(|b| b.is_remote())); + + matches } else { let branches = all_branches .iter() - .filter(|branch| { - if display_remotes == BranchFilter::Remote { - branch.is_remote() - } else { - !branch.is_remote() - } - }) + .filter(|branch| branch_matches_filter(branch)) .collect::>(); let candidates = branches .iter() .enumerate() .map(|(ix, branch)| StringMatchCandidate::new(ix, branch.name())) .collect::>(); - fuzzy::match_strings( + let mut matches: Vec = fuzzy::match_strings( &candidates, &query, true, @@ -673,7 +671,12 @@ impl PickerDelegate for BranchListDelegate { branch: branches[candidate.candidate_id].clone(), positions: candidate.positions, }) - .collect() + .collect(); + + // Keep fuzzy-relevance ordering within local/remote groups, but show locals first. + matches.sort_by_key(|entry| entry.as_branch().is_some_and(|b| b.is_remote())); + + matches }; picker .update(cx, |picker, _| { @@ -841,10 +844,13 @@ impl PickerDelegate for BranchListDelegate { Entry::NewUrl { .. } | Entry::NewBranch { .. } | Entry::NewRemoteName { .. } => { Icon::new(IconName::Plus).color(Color::Muted) } - Entry::Branch { .. } => match self.branch_filter { - BranchFilter::Local => Icon::new(IconName::GitBranchAlt).color(Color::Muted), - BranchFilter::Remote => Icon::new(IconName::Screen).color(Color::Muted), - }, + Entry::Branch { branch, .. } => { + if branch.is_remote() { + Icon::new(IconName::Screen).color(Color::Muted) + } else { + Icon::new(IconName::GitBranchAlt).color(Color::Muted) + } + } }; let entry_title = match entry { @@ -1036,8 +1042,8 @@ impl PickerDelegate for BranchListDelegate { ) -> Option { matches!(self.state, PickerState::List).then(|| { let label = match self.branch_filter { - BranchFilter::Local => "Local", - BranchFilter::Remote => "Remote", + BranchFilter::All => "Branches", + BranchFilter::Remote => "Remotes", }; ListHeader::new(label).inset(true).into_any_element() @@ -1532,7 +1538,7 @@ mod tests { } #[gpui::test] - async fn test_update_remote_matches_with_query(cx: &mut TestAppContext) { + async fn test_branch_filter_shows_all_then_remotes_and_applies_query(cx: &mut TestAppContext) { init_test(cx); let branches = vec![ @@ -1547,34 +1553,49 @@ mod tests { update_branch_list_matches_with_empty_query(&branch_list, cx).await; - // Check matches, it should match all existing branches and no option to create new branch - branch_list - .update_in(cx, |branch_list, window, cx| { - branch_list.picker.update(cx, |picker, cx| { - assert_eq!(picker.delegate.matches.len(), 2); - let branches = picker - .delegate - .matches - .iter() - .map(|be| be.name()) - .collect::>(); - assert_eq!( - branches, - ["feature-ui", "develop"] - .into_iter() - .collect::>() - ); + branch_list.update(cx, |branch_list, cx| { + branch_list.picker.update(cx, |picker, _cx| { + assert_eq!(picker.delegate.matches.len(), 4); - // Verify the last entry is NOT the "create new branch" option - let last_match = picker.delegate.matches.last().unwrap(); - assert!(!last_match.is_new_branch()); - assert!(!last_match.is_new_url()); - picker.delegate.branch_filter = BranchFilter::Remote; - picker.delegate.update_matches(String::new(), window, cx) - }) + let branches = picker + .delegate + .matches + .iter() + .map(|be| be.name()) + .collect::>(); + assert_eq!( + branches, + ["origin/main", "fork/feature-auth", "feature-ui", "develop"] + .into_iter() + .collect::>() + ); + + // Locals should be listed before remotes. + let ordered = picker + .delegate + .matches + .iter() + .map(|be| be.name()) + .collect::>(); + assert_eq!( + ordered, + vec!["feature-ui", "develop", "origin/main", "fork/feature-auth"] + ); + + // Verify the last entry is NOT the "create new branch" option + let last_match = picker.delegate.matches.last().unwrap(); + assert!(!last_match.is_new_branch()); + assert!(!last_match.is_new_url()); }) - .await; - cx.run_until_parked(); + }); + + branch_list.update(cx, |branch_list, cx| { + branch_list.picker.update(cx, |picker, _cx| { + picker.delegate.branch_filter = BranchFilter::Remote; + }) + }); + + update_branch_list_matches_with_empty_query(&branch_list, cx).await; branch_list .update_in(cx, |branch_list, window, cx| { From bd20339f82c9c8f8b2d6d96d5c928ebc535b1295 Mon Sep 17 00:00:00 2001 From: Michael Benfield Date: Tue, 16 Dec 2025 15:30:36 -0800 Subject: [PATCH 409/621] Don't apply StripInvalidSpans for tool using inline assistant (#45040) It can occasionally mutilate the text when used with the tool format. Release Notes: - N/A --- crates/agent_ui/src/buffer_codegen.rs | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/crates/agent_ui/src/buffer_codegen.rs b/crates/agent_ui/src/buffer_codegen.rs index 25395278745a9eb18fbbfa1cd920af3e3b26e24d..87ce6d386b38f31a0d7b550aab00bb766ce75010 100644 --- a/crates/agent_ui/src/buffer_codegen.rs +++ b/crates/agent_ui/src/buffer_codegen.rs @@ -441,7 +441,8 @@ impl CodegenAlternative { }) .boxed_local() }; - self.generation = self.handle_stream(model, stream, cx); + self.generation = + self.handle_stream(model, /* strip_invalid_spans: */ true, stream, cx); } Ok(()) @@ -629,6 +630,7 @@ impl CodegenAlternative { pub fn handle_stream( &mut self, model: Arc, + strip_invalid_spans: bool, stream: impl 'static + Future>, cx: &mut Context, ) -> Task<()> { @@ -713,10 +715,16 @@ impl CodegenAlternative { let mut response_latency = None; let request_start = Instant::now(); let diff = async { - let chunks = StripInvalidSpans::new( - stream?.stream.map_err(|error| error.into()), - ); - futures::pin_mut!(chunks); + let raw_stream = stream?.stream.map_err(|error| error.into()); + + let stripped; + let mut chunks: Pin> + Send>> = + if strip_invalid_spans { + stripped = StripInvalidSpans::new(raw_stream); + Box::pin(stripped) + } else { + Box::pin(raw_stream) + }; let mut diff = StreamingDiff::new(selected_text.to_string()); let mut line_diff = LineDiff::default(); @@ -1307,7 +1315,12 @@ impl CodegenAlternative { let Some(task) = codegen .update(cx, move |codegen, cx| { - codegen.handle_stream(model, async { Ok(language_model_text_stream) }, cx) + codegen.handle_stream( + model, + /* strip_invalid_spans: */ false, + async { Ok(language_model_text_stream) }, + cx, + ) }) .ok() else { @@ -1846,6 +1859,7 @@ mod tests { codegen.update(cx, |codegen, cx| { codegen.generation = codegen.handle_stream( model, + /* strip_invalid_spans: */ false, future::ready(Ok(LanguageModelTextStream { message_id: None, stream: chunks_rx.map(Ok).boxed(), From 83de583fb1f8f0b6f1670494eec697171cf6f335 Mon Sep 17 00:00:00 2001 From: AidanV <84053180+AidanV@users.noreply.github.com> Date: Tue, 16 Dec 2025 18:57:26 -0500 Subject: [PATCH 410/621] nix: Resolve 'hostPlatform' rename warning in dev shell (#45045) This PR fixes the warning from entering the nix development shell: ``` evaluation warning: 'hostPlatform' has been renamed to/replaced by 'stdenv.hostPlatform' ``` Decided to go with `zed-editor = mkZed pkgs;` instead of `zed-editor = packages.${pkgs.stdenv.hostPlatform.system}.default;`, because it is simpler and with my understanding it is logically equivalent (i.e. we are getting `packages..default` which we can see in the definition of packages is equal to `mkZed pkgs;`). Release Notes: - N/A --- flake.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index fe7a09701beb714506742f2712cb3a74b676bc19..744ca708a3a2104f0050cd85e8ee05f04e49a713 100644 --- a/flake.nix +++ b/flake.nix @@ -37,14 +37,14 @@ rustToolchain = rustBin.fromRustupToolchainFile ./rust-toolchain.toml; }; in - rec { + { packages = forAllSystems (pkgs: rec { default = mkZed pkgs; debug = default.override { profile = "dev"; }; }); devShells = forAllSystems (pkgs: { default = pkgs.callPackage ./nix/shell.nix { - zed-editor = packages.${pkgs.hostPlatform.system}.default; + zed-editor = mkZed pkgs; }; }); formatter = forAllSystems (pkgs: pkgs.nixfmt-rfc-style); From af3902a33f86d6d7d030a1167f6151912a697c11 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Wed, 17 Dec 2025 01:59:34 +0200 Subject: [PATCH 411/621] Move DB away from the project (#45036) Follow-up of https://github.com/zed-industries/zed/pull/44887 This fixes remote server builds. Additionally: * slightly rewords workspace trust text in the security modal * eagerly ask for worktree trust on open Release Notes: - N/A --- .../remote_editing_collaboration_tests.rs | 2 + crates/editor/src/editor_tests.rs | 1 + crates/project/Cargo.toml | 1 - crates/project/src/persistence.rs | 355 +----------------- crates/project/src/project.rs | 1 - crates/project/src/trusted_worktrees.rs | 159 +++----- crates/remote_server/src/unix.rs | 3 +- crates/workspace/src/persistence.rs | 158 +++++++- crates/workspace/src/security_modal.rs | 6 +- crates/workspace/src/workspace.rs | 90 ++++- crates/zed/src/main.rs | 9 +- 11 files changed, 295 insertions(+), 490 deletions(-) diff --git a/crates/collab/src/tests/remote_editing_collaboration_tests.rs b/crates/collab/src/tests/remote_editing_collaboration_tests.rs index a66d7a1856c195a41a495123b468dc2b6ac8a1ca..5342b0bbd4b11afb24ccbaa6d4bf17df036cec76 100644 --- a/crates/collab/src/tests/remote_editing_collaboration_tests.rs +++ b/crates/collab/src/tests/remote_editing_collaboration_tests.rs @@ -859,9 +859,11 @@ async fn test_ssh_remote_worktree_trust(cx_a: &mut TestAppContext, server_cx: &m cx_a.update(|cx| { release_channel::init(semver::Version::new(0, 0, 0), cx); + project::trusted_worktrees::init(HashMap::default(), None, None, cx); }); server_cx.update(|cx| { release_channel::init(semver::Version::new(0, 0, 0), cx); + project::trusted_worktrees::init(HashMap::default(), None, None, cx); }); let mut server = TestServer::start(cx_a.executor().clone()).await; diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rs index f379b2b4e014ae7f51b5d8ffd842112dba54279b..84d3837d1cb516b6f70f6998ce588beed9bd9804 100644 --- a/crates/editor/src/editor_tests.rs +++ b/crates/editor/src/editor_tests.rs @@ -29370,6 +29370,7 @@ async fn test_find_references_single_case(cx: &mut TestAppContext) { #[gpui::test] async fn test_local_worktree_trust(cx: &mut TestAppContext) { init_test(cx, |_| {}); + cx.update(|cx| project::trusted_worktrees::init(HashMap::default(), None, None, cx)); cx.update(|cx| { SettingsStore::update_global(cx, |store, cx| { diff --git a/crates/project/Cargo.toml b/crates/project/Cargo.toml index b589af2d50c77b68da6d94334904505f104b37e8..f39c368218511b6ddf560dda1198ef5c06bd0a2e 100644 --- a/crates/project/Cargo.toml +++ b/crates/project/Cargo.toml @@ -40,7 +40,6 @@ clock.workspace = true collections.workspace = true context_server.workspace = true dap.workspace = true -db.workspace = true extension.workspace = true fancy-regex.workspace = true fs.workspace = true diff --git a/crates/project/src/persistence.rs b/crates/project/src/persistence.rs index be844c58384aa001fdbffa5fbac5dc513e98c535..5c4e664bdeba02a317da0610cf857e948bd5c93e 100644 --- a/crates/project/src/persistence.rs +++ b/crates/project/src/persistence.rs @@ -37,143 +37,7 @@ impl Domain for ProjectDb { db::static_connection!(PROJECT_DB, ProjectDb, []); -impl ProjectDb { - pub(crate) async fn save_trusted_worktrees( - &self, - trusted_worktrees: HashMap, HashSet>, - trusted_workspaces: HashSet>, - ) -> anyhow::Result<()> { - use anyhow::Context as _; - use db::sqlez::statement::Statement; - use itertools::Itertools as _; - - PROJECT_DB - .clear_trusted_worktrees() - .await - .context("clearing previous trust state")?; - - let trusted_worktrees = trusted_worktrees - .into_iter() - .flat_map(|(host, abs_paths)| { - abs_paths - .into_iter() - .map(move |abs_path| (Some(abs_path), host.clone())) - }) - .chain(trusted_workspaces.into_iter().map(|host| (None, host))) - .collect::>(); - let mut first_worktree; - let mut last_worktree = 0_usize; - for (count, placeholders) in std::iter::once("(?, ?, ?)") - .cycle() - .take(trusted_worktrees.len()) - .chunks(MAX_QUERY_PLACEHOLDERS / 3) - .into_iter() - .map(|chunk| { - let mut count = 0; - let placeholders = chunk - .inspect(|_| { - count += 1; - }) - .join(", "); - (count, placeholders) - }) - .collect::>() - { - first_worktree = last_worktree; - last_worktree = last_worktree + count; - let query = format!( - r#"INSERT INTO trusted_worktrees(absolute_path, user_name, host_name) -VALUES {placeholders};"# - ); - - let trusted_worktrees = trusted_worktrees[first_worktree..last_worktree].to_vec(); - self.write(move |conn| { - let mut statement = Statement::prepare(conn, query)?; - let mut next_index = 1; - for (abs_path, host) in trusted_worktrees { - let abs_path = abs_path.as_ref().map(|abs_path| abs_path.to_string_lossy()); - next_index = statement.bind( - &abs_path.as_ref().map(|abs_path| abs_path.as_ref()), - next_index, - )?; - next_index = statement.bind( - &host - .as_ref() - .and_then(|host| Some(host.user_name.as_ref()?.as_str())), - next_index, - )?; - next_index = statement.bind( - &host.as_ref().map(|host| host.host_identifier.as_str()), - next_index, - )?; - } - statement.exec() - }) - .await - .context("inserting new trusted state")?; - } - Ok(()) - } - - pub(crate) fn fetch_trusted_worktrees( - &self, - worktree_store: Option>, - host: Option, - cx: &App, - ) -> anyhow::Result, HashSet>> { - let trusted_worktrees = PROJECT_DB.trusted_worktrees()?; - Ok(trusted_worktrees - .into_iter() - .map(|(abs_path, user_name, host_name)| { - let db_host = match (user_name, host_name) { - (_, None) => None, - (None, Some(host_name)) => Some(RemoteHostLocation { - user_name: None, - host_identifier: SharedString::new(host_name), - }), - (Some(user_name), Some(host_name)) => Some(RemoteHostLocation { - user_name: Some(SharedString::new(user_name)), - host_identifier: SharedString::new(host_name), - }), - }; - - match abs_path { - Some(abs_path) => { - if db_host != host { - (db_host, PathTrust::AbsPath(abs_path)) - } else if let Some(worktree_store) = &worktree_store { - find_worktree_in_store(worktree_store.read(cx), &abs_path, cx) - .map(PathTrust::Worktree) - .map(|trusted_worktree| (host.clone(), trusted_worktree)) - .unwrap_or_else(|| (db_host.clone(), PathTrust::AbsPath(abs_path))) - } else { - (db_host, PathTrust::AbsPath(abs_path)) - } - } - None => (db_host, PathTrust::Workspace), - } - }) - .fold(HashMap::default(), |mut acc, (remote_host, path_trust)| { - acc.entry(remote_host) - .or_insert_with(HashSet::default) - .insert(path_trust); - acc - })) - } - - query! { - fn trusted_worktrees() -> Result, Option, Option)>> { - SELECT absolute_path, user_name, host_name - FROM trusted_worktrees - } - } - - query! { - pub async fn clear_trusted_worktrees() -> Result<()> { - DELETE FROM trusted_worktrees - } - } -} +impl ProjectDb {} #[cfg(test)] mod tests { @@ -192,220 +56,5 @@ mod tests { trusted_worktrees::{PathTrust, RemoteHostLocation}, }; - static TEST_LOCK: Mutex<()> = Mutex::new(()); - - #[gpui::test] - async fn test_save_and_fetch_trusted_worktrees(cx: &mut TestAppContext) { - cx.executor().allow_parking(); - let _guard = TEST_LOCK.lock().await; - PROJECT_DB.clear_trusted_worktrees().await.unwrap(); - cx.update(|cx| { - if cx.try_global::().is_none() { - let settings = SettingsStore::test(cx); - cx.set_global(settings); - } - }); - - let fs = FakeFs::new(cx.executor()); - fs.insert_tree( - path!("/"), - json!({ - "project_a": { "main.rs": "" }, - "project_b": { "lib.rs": "" } - }), - ) - .await; - - let project = Project::test( - fs, - [path!("/project_a").as_ref(), path!("/project_b").as_ref()], - cx, - ) - .await; - let worktree_store = project.read_with(cx, |p, _| p.worktree_store()); - - let mut trusted_paths: HashMap, HashSet> = - HashMap::default(); - trusted_paths.insert( - None, - HashSet::from_iter([ - PathBuf::from(path!("/project_a")), - PathBuf::from(path!("/project_b")), - ]), - ); - - PROJECT_DB - .save_trusted_worktrees(trusted_paths, HashSet::default()) - .await - .unwrap(); - - let fetched = cx.update(|cx| { - PROJECT_DB.fetch_trusted_worktrees(Some(worktree_store.clone()), None, cx) - }); - let fetched = fetched.unwrap(); - - let local_trust = fetched.get(&None).expect("should have local host entry"); - assert_eq!(local_trust.len(), 2); - assert!( - local_trust - .iter() - .all(|p| matches!(p, PathTrust::Worktree(_))) - ); - - let fetched_no_store = cx - .update(|cx| PROJECT_DB.fetch_trusted_worktrees(None, None, cx)) - .unwrap(); - let local_trust_no_store = fetched_no_store - .get(&None) - .expect("should have local host entry"); - assert_eq!(local_trust_no_store.len(), 2); - assert!( - local_trust_no_store - .iter() - .all(|p| matches!(p, PathTrust::AbsPath(_))) - ); - } - - #[gpui::test] - async fn test_save_and_fetch_workspace_trust(cx: &mut TestAppContext) { - cx.executor().allow_parking(); - let _guard = TEST_LOCK.lock().await; - PROJECT_DB.clear_trusted_worktrees().await.unwrap(); - cx.update(|cx| { - if cx.try_global::().is_none() { - let settings = SettingsStore::test(cx); - cx.set_global(settings); - } - }); - - let fs = FakeFs::new(cx.executor()); - fs.insert_tree(path!("/root"), json!({ "main.rs": "" })) - .await; - - let project = Project::test(fs, [path!("/root").as_ref()], cx).await; - let worktree_store = project.read_with(cx, |p, _| p.worktree_store()); - - let trusted_workspaces = HashSet::from_iter([None]); - PROJECT_DB - .save_trusted_worktrees(HashMap::default(), trusted_workspaces) - .await - .unwrap(); - - let fetched = cx.update(|cx| { - PROJECT_DB.fetch_trusted_worktrees(Some(worktree_store.clone()), None, cx) - }); - let fetched = fetched.unwrap(); - - let local_trust = fetched.get(&None).expect("should have local host entry"); - assert!(local_trust.contains(&PathTrust::Workspace)); - - let fetched_no_store = cx - .update(|cx| PROJECT_DB.fetch_trusted_worktrees(None, None, cx)) - .unwrap(); - let local_trust_no_store = fetched_no_store - .get(&None) - .expect("should have local host entry"); - assert!(local_trust_no_store.contains(&PathTrust::Workspace)); - } - - #[gpui::test] - async fn test_save_and_fetch_remote_host_trust(cx: &mut TestAppContext) { - cx.executor().allow_parking(); - let _guard = TEST_LOCK.lock().await; - PROJECT_DB.clear_trusted_worktrees().await.unwrap(); - cx.update(|cx| { - if cx.try_global::().is_none() { - let settings = SettingsStore::test(cx); - cx.set_global(settings); - } - }); - - let fs = FakeFs::new(cx.executor()); - fs.insert_tree(path!("/root"), json!({ "main.rs": "" })) - .await; - - let project = Project::test(fs, [path!("/root").as_ref()], cx).await; - let worktree_store = project.read_with(cx, |p, _| p.worktree_store()); - - let remote_host = Some(RemoteHostLocation { - user_name: Some(SharedString::from("testuser")), - host_identifier: SharedString::from("remote.example.com"), - }); - - let mut trusted_paths: HashMap, HashSet> = - HashMap::default(); - trusted_paths.insert( - remote_host.clone(), - HashSet::from_iter([PathBuf::from("/home/testuser/project")]), - ); - - PROJECT_DB - .save_trusted_worktrees(trusted_paths, HashSet::default()) - .await - .unwrap(); - - let fetched = cx.update(|cx| { - PROJECT_DB.fetch_trusted_worktrees(Some(worktree_store.clone()), None, cx) - }); - let fetched = fetched.unwrap(); - - let remote_trust = fetched - .get(&remote_host) - .expect("should have remote host entry"); - assert_eq!(remote_trust.len(), 1); - assert!(remote_trust - .iter() - .any(|p| matches!(p, PathTrust::AbsPath(path) if path == &PathBuf::from("/home/testuser/project")))); - - let fetched_no_store = cx - .update(|cx| PROJECT_DB.fetch_trusted_worktrees(None, None, cx)) - .unwrap(); - let remote_trust_no_store = fetched_no_store - .get(&remote_host) - .expect("should have remote host entry"); - assert_eq!(remote_trust_no_store.len(), 1); - assert!(remote_trust_no_store - .iter() - .any(|p| matches!(p, PathTrust::AbsPath(path) if path == &PathBuf::from("/home/testuser/project")))); - } - - #[gpui::test] - async fn test_clear_trusted_worktrees(cx: &mut TestAppContext) { - cx.executor().allow_parking(); - let _guard = TEST_LOCK.lock().await; - PROJECT_DB.clear_trusted_worktrees().await.unwrap(); - cx.update(|cx| { - if cx.try_global::().is_none() { - let settings = SettingsStore::test(cx); - cx.set_global(settings); - } - }); - - let fs = FakeFs::new(cx.executor()); - fs.insert_tree(path!("/root"), json!({ "main.rs": "" })) - .await; - - let project = Project::test(fs, [path!("/root").as_ref()], cx).await; - let worktree_store = project.read_with(cx, |p, _| p.worktree_store()); - - let trusted_workspaces = HashSet::from_iter([None]); - PROJECT_DB - .save_trusted_worktrees(HashMap::default(), trusted_workspaces) - .await - .unwrap(); - - PROJECT_DB.clear_trusted_worktrees().await.unwrap(); - - let fetched = cx.update(|cx| { - PROJECT_DB.fetch_trusted_worktrees(Some(worktree_store.clone()), None, cx) - }); - let fetched = fetched.unwrap(); - - assert!(fetched.is_empty(), "should be empty after clear"); - - let fetched_no_store = cx - .update(|cx| PROJECT_DB.fetch_trusted_worktrees(None, None, cx)) - .unwrap(); - assert!(fetched_no_store.is_empty(), "should be empty after clear"); - } + static TEST_WORKTREE_TRUST_LOCK: Mutex<()> = Mutex::new(()); } diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index 79d37f0e99f35f5c059a98017f5036e95e18bf01..bbf91eb3c18a53f32f48f1a044c991bf5cfd9fdf 100644 --- a/crates/project/src/project.rs +++ b/crates/project/src/project.rs @@ -10,7 +10,6 @@ pub mod image_store; pub mod lsp_command; pub mod lsp_store; mod manifest_tree; -mod persistence; pub mod prettier_store; mod project_search; pub mod project_settings; diff --git a/crates/project/src/trusted_worktrees.rs b/crates/project/src/trusted_worktrees.rs index 733e8d48294b863f8bf35cdb1ea458acd59dcadb..d9f5d4a7a43d8cb8b8220f4d3de8ca35d366a8f5 100644 --- a/crates/project/src/trusted_worktrees.rs +++ b/crates/project/src/trusted_worktrees.rs @@ -68,19 +68,21 @@ use util::debug_panic; use crate::{project_settings::ProjectSettings, worktree_store::WorktreeStore}; -#[cfg(not(any(test, feature = "test-support")))] -use crate::persistence::PROJECT_DB; -#[cfg(not(any(test, feature = "test-support")))] -use util::ResultExt as _; - pub fn init( + db_trusted_paths: TrustedPaths, downstream_client: Option<(AnyProtoClient, u64)>, upstream_client: Option<(AnyProtoClient, u64)>, cx: &mut App, ) { if TrustedWorktrees::try_get_global(cx).is_none() { - let trusted_worktrees = cx.new(|cx| { - TrustedWorktreesStore::new(None, None, downstream_client, upstream_client, cx) + let trusted_worktrees = cx.new(|_| { + TrustedWorktreesStore::new( + db_trusted_paths, + None, + None, + downstream_client, + upstream_client, + ) }); cx.set_global(TrustedWorktrees(trusted_worktrees)) } @@ -126,18 +128,7 @@ pub fn track_worktree_trust( } }); } - None => { - let trusted_worktrees = cx.new(|cx| { - TrustedWorktreesStore::new( - Some(worktree_store.clone()), - remote_host, - downstream_client, - upstream_client, - cx, - ) - }); - cx.set_global(TrustedWorktrees(trusted_worktrees)) - } + None => log::debug!("No TrustedWorktrees initialized, not tracking worktree trust"), } } @@ -212,9 +203,7 @@ pub struct TrustedWorktreesStore { downstream_client: Option<(AnyProtoClient, u64)>, upstream_client: Option<(AnyProtoClient, u64)>, worktree_stores: HashMap, Option>, - trusted_paths: HashMap, HashSet>, - #[cfg(not(any(test, feature = "test-support")))] - serialization_task: Task<()>, + trusted_paths: TrustedPaths, restricted: HashSet, remote_host: Option, restricted_workspaces: HashSet>, @@ -307,36 +296,16 @@ pub enum TrustedWorktreesEvent { impl EventEmitter for TrustedWorktreesStore {} +pub type TrustedPaths = HashMap, HashSet>; + impl TrustedWorktreesStore { fn new( + trusted_paths: TrustedPaths, worktree_store: Option>, remote_host: Option, downstream_client: Option<(AnyProtoClient, u64)>, upstream_client: Option<(AnyProtoClient, u64)>, - cx: &App, ) -> Self { - #[cfg(any(test, feature = "test-support"))] - let _ = cx; - - #[cfg(not(any(test, feature = "test-support")))] - let trusted_paths = if downstream_client.is_none() { - match PROJECT_DB.fetch_trusted_worktrees( - worktree_store.clone(), - remote_host.clone(), - cx, - ) { - Ok(trusted_paths) => trusted_paths, - Err(e) => { - log::error!("Failed to do initial trusted worktrees fetch: {e:#}"); - HashMap::default() - } - } - } else { - HashMap::default() - }; - #[cfg(any(test, feature = "test-support"))] - let trusted_paths = HashMap::, HashSet>::default(); - if let Some((upstream_client, upstream_project_id)) = &upstream_client { let trusted_paths = trusted_paths .iter() @@ -366,8 +335,6 @@ impl TrustedWorktreesStore { remote_host, restricted_workspaces: HashSet::default(), restricted: HashSet::default(), - #[cfg(not(any(test, feature = "test-support")))] - serialization_task: Task::ready(()), worktree_stores, } } @@ -496,41 +463,6 @@ impl TrustedWorktreesStore { trusted_paths.clone(), )); - #[cfg(not(any(test, feature = "test-support")))] - if self.downstream_client.is_none() { - let mut new_trusted_workspaces = HashSet::default(); - let new_trusted_worktrees = self - .trusted_paths - .clone() - .into_iter() - .map(|(host, paths)| { - let abs_paths = paths - .into_iter() - .flat_map(|path| match path { - PathTrust::Worktree(worktree_id) => self - .find_worktree_data(worktree_id, cx) - .map(|(abs_path, ..)| abs_path.to_path_buf()), - PathTrust::AbsPath(abs_path) => Some(abs_path), - PathTrust::Workspace => { - new_trusted_workspaces.insert(host.clone()); - None - } - }) - .collect(); - (host, abs_paths) - }) - .collect(); - // Do not persist auto trusted worktrees - if !ProjectSettings::get_global(cx).session.trust_all_worktrees { - self.serialization_task = cx.background_spawn(async move { - PROJECT_DB - .save_trusted_worktrees(new_trusted_worktrees, new_trusted_workspaces) - .await - .log_err(); - }); - } - } - if let Some((upstream_client, upstream_project_id)) = &self.upstream_client { let trusted_paths = trusted_paths .iter() @@ -578,31 +510,8 @@ impl TrustedWorktreesStore { /// Erases all trust information. /// Requires Zed's restart to take proper effect. - pub fn clear_trusted_paths(&mut self, cx: &App) -> Task<()> { - if self.downstream_client.is_none() { - self.trusted_paths.clear(); - - #[cfg(not(any(test, feature = "test-support")))] - { - let (tx, rx) = smol::channel::bounded(1); - self.serialization_task = cx.background_spawn(async move { - PROJECT_DB.clear_trusted_worktrees().await.log_err(); - tx.send(()).await.ok(); - }); - - return cx.background_spawn(async move { - rx.recv().await.ok(); - }); - } - - #[cfg(any(test, feature = "test-support"))] - { - let _ = cx; - Task::ready(()) - } - } else { - Task::ready(()) - } + pub fn clear_trusted_paths(&mut self) { + self.trusted_paths.clear(); } /// Checks whether a certain worktree is trusted (or on a larger trust level). @@ -785,6 +694,39 @@ impl TrustedWorktreesStore { } } + /// Returns a normalized representation of the trusted paths to store in the DB. + pub fn trusted_paths_for_serialization( + &mut self, + cx: &mut Context, + ) -> ( + HashSet>, + HashMap, HashSet>, + ) { + let mut new_trusted_workspaces = HashSet::default(); + let new_trusted_worktrees = self + .trusted_paths + .clone() + .into_iter() + .map(|(host, paths)| { + let abs_paths = paths + .into_iter() + .flat_map(|path| match path { + PathTrust::Worktree(worktree_id) => self + .find_worktree_data(worktree_id, cx) + .map(|(abs_path, ..)| abs_path.to_path_buf()), + PathTrust::AbsPath(abs_path) => Some(abs_path), + PathTrust::Workspace => { + new_trusted_workspaces.insert(host.clone()); + None + } + }) + .collect(); + (host, abs_paths) + }) + .collect(); + (new_trusted_workspaces, new_trusted_worktrees) + } + fn find_worktree_data( &mut self, worktree_id: WorktreeId, @@ -841,7 +783,7 @@ impl TrustedWorktreesStore { } } -pub(crate) fn find_worktree_in_store( +pub fn find_worktree_in_store( worktree_store: &WorktreeStore, abs_path: &Path, cx: &App, @@ -885,6 +827,7 @@ mod tests { cx: &mut TestAppContext, ) -> Entity { cx.update(|cx| { + init(HashMap::default(), None, None, cx); track_worktree_trust(worktree_store, None, None, None, cx); TrustedWorktrees::try_get_global(cx).expect("global should be set") }) diff --git a/crates/remote_server/src/unix.rs b/crates/remote_server/src/unix.rs index f4f769474b39f182ee90cbaf146e09eab440dc15..af603998171e19d4776d47479ff81aa08d26d258 100644 --- a/crates/remote_server/src/unix.rs +++ b/crates/remote_server/src/unix.rs @@ -2,6 +2,7 @@ use crate::HeadlessProject; use crate::headless_project::HeadlessAppState; use anyhow::{Context as _, Result, anyhow}; use client::ProxySettings; +use collections::HashMap; use project::trusted_worktrees; use util::ResultExt; @@ -419,7 +420,7 @@ pub fn execute_run( log::info!("gpui app started, initializing server"); let session = start_server(listeners, log_rx, cx, is_wsl_interop); - trusted_worktrees::init(Some((session.clone(), REMOTE_SERVER_PROJECT_ID)), None, cx); + trusted_worktrees::init(HashMap::default(), Some((session.clone(), REMOTE_SERVER_PROJECT_ID)), None, cx); GitHostingProviderRegistry::set_global(git_hosting_provider_registry, cx); git_hosting_providers::init(cx); diff --git a/crates/workspace/src/persistence.rs b/crates/workspace/src/persistence.rs index f1835caf8dd84e1f729e0415b5711ffa69981d9b..dc113db68e33dc527e6b8d2cb66f644bcd83b661 100644 --- a/crates/workspace/src/persistence.rs +++ b/crates/workspace/src/persistence.rs @@ -9,14 +9,18 @@ use std::{ }; use anyhow::{Context as _, Result, bail}; -use collections::{HashMap, IndexSet}; +use collections::{HashMap, HashSet, IndexSet}; use db::{ query, sqlez::{connection::Connection, domain::Domain}, sqlez_macros::sql, }; -use gpui::{Axis, Bounds, Task, WindowBounds, WindowId, point, size}; -use project::debugger::breakpoint_store::{BreakpointState, SourceBreakpoint}; +use gpui::{Axis, Bounds, Entity, Task, WindowBounds, WindowId, point, size}; +use project::{ + debugger::breakpoint_store::{BreakpointState, SourceBreakpoint}, + trusted_worktrees::{PathTrust, RemoteHostLocation, find_worktree_in_store}, + worktree_store::WorktreeStore, +}; use language::{LanguageName, Toolchain, ToolchainScope}; use project::WorktreeId; @@ -46,6 +50,11 @@ use model::{ use self::model::{DockStructure, SerializedWorkspaceLocation}; +// https://www.sqlite.org/limits.html +// > <..> the maximum value of a host parameter number is SQLITE_MAX_VARIABLE_NUMBER, +// > which defaults to <..> 32766 for SQLite versions after 3.32.0. +const MAX_QUERY_PLACEHOLDERS: usize = 32000; + #[derive(Copy, Clone, Debug, PartialEq)] pub(crate) struct SerializedAxis(pub(crate) gpui::Axis); impl sqlez::bindable::StaticColumnCount for SerializedAxis {} @@ -708,6 +717,14 @@ impl Domain for WorkspaceDb { ALTER TABLE remote_connections ADD COLUMN name TEXT; ALTER TABLE remote_connections ADD COLUMN container_id TEXT; ), + sql!( + CREATE TABLE IF NOT EXISTS trusted_worktrees ( + trust_id INTEGER PRIMARY KEY AUTOINCREMENT, + absolute_path TEXT, + user_name TEXT, + host_name TEXT + ) STRICT; + ), ]; // Allow recovering from bad migration that was initially shipped to nightly @@ -1796,6 +1813,141 @@ impl WorkspaceDb { Ok(()) }).await } + + pub(crate) async fn save_trusted_worktrees( + &self, + trusted_worktrees: HashMap, HashSet>, + trusted_workspaces: HashSet>, + ) -> anyhow::Result<()> { + use anyhow::Context as _; + use db::sqlez::statement::Statement; + use itertools::Itertools as _; + + DB.clear_trusted_worktrees() + .await + .context("clearing previous trust state")?; + + let trusted_worktrees = trusted_worktrees + .into_iter() + .flat_map(|(host, abs_paths)| { + abs_paths + .into_iter() + .map(move |abs_path| (Some(abs_path), host.clone())) + }) + .chain(trusted_workspaces.into_iter().map(|host| (None, host))) + .collect::>(); + let mut first_worktree; + let mut last_worktree = 0_usize; + for (count, placeholders) in std::iter::once("(?, ?, ?)") + .cycle() + .take(trusted_worktrees.len()) + .chunks(MAX_QUERY_PLACEHOLDERS / 3) + .into_iter() + .map(|chunk| { + let mut count = 0; + let placeholders = chunk + .inspect(|_| { + count += 1; + }) + .join(", "); + (count, placeholders) + }) + .collect::>() + { + first_worktree = last_worktree; + last_worktree = last_worktree + count; + let query = format!( + r#"INSERT INTO trusted_worktrees(absolute_path, user_name, host_name) +VALUES {placeholders};"# + ); + + let trusted_worktrees = trusted_worktrees[first_worktree..last_worktree].to_vec(); + self.write(move |conn| { + let mut statement = Statement::prepare(conn, query)?; + let mut next_index = 1; + for (abs_path, host) in trusted_worktrees { + let abs_path = abs_path.as_ref().map(|abs_path| abs_path.to_string_lossy()); + next_index = statement.bind( + &abs_path.as_ref().map(|abs_path| abs_path.as_ref()), + next_index, + )?; + next_index = statement.bind( + &host + .as_ref() + .and_then(|host| Some(host.user_name.as_ref()?.as_str())), + next_index, + )?; + next_index = statement.bind( + &host.as_ref().map(|host| host.host_identifier.as_str()), + next_index, + )?; + } + statement.exec() + }) + .await + .context("inserting new trusted state")?; + } + Ok(()) + } + + pub fn fetch_trusted_worktrees( + &self, + worktree_store: Option>, + host: Option, + cx: &App, + ) -> Result, HashSet>> { + let trusted_worktrees = DB.trusted_worktrees()?; + Ok(trusted_worktrees + .into_iter() + .map(|(abs_path, user_name, host_name)| { + let db_host = match (user_name, host_name) { + (_, None) => None, + (None, Some(host_name)) => Some(RemoteHostLocation { + user_name: None, + host_identifier: SharedString::new(host_name), + }), + (Some(user_name), Some(host_name)) => Some(RemoteHostLocation { + user_name: Some(SharedString::new(user_name)), + host_identifier: SharedString::new(host_name), + }), + }; + + match abs_path { + Some(abs_path) => { + if db_host != host { + (db_host, PathTrust::AbsPath(abs_path)) + } else if let Some(worktree_store) = &worktree_store { + find_worktree_in_store(worktree_store.read(cx), &abs_path, cx) + .map(PathTrust::Worktree) + .map(|trusted_worktree| (host.clone(), trusted_worktree)) + .unwrap_or_else(|| (db_host.clone(), PathTrust::AbsPath(abs_path))) + } else { + (db_host, PathTrust::AbsPath(abs_path)) + } + } + None => (db_host, PathTrust::Workspace), + } + }) + .fold(HashMap::default(), |mut acc, (remote_host, path_trust)| { + acc.entry(remote_host) + .or_insert_with(HashSet::default) + .insert(path_trust); + acc + })) + } + + query! { + fn trusted_worktrees() -> Result, Option, Option)>> { + SELECT absolute_path, user_name, host_name + FROM trusted_worktrees + } + } + + query! { + pub async fn clear_trusted_worktrees() -> Result<()> { + DELETE FROM trusted_worktrees + } + } } pub fn delete_unloaded_items( diff --git a/crates/workspace/src/security_modal.rs b/crates/workspace/src/security_modal.rs index f2a94ad81661a2572f35d1d746b04b31fa24f00c..44242a3588017aabf117300310dd10a4a28b292f 100644 --- a/crates/workspace/src/security_modal.rs +++ b/crates/workspace/src/security_modal.rs @@ -131,14 +131,14 @@ impl Render for SecurityModal { None => match &restricted_path.host { Some(remote_host) => match &remote_host.user_name { Some(user_name) => format!( - "Empty project ({}@{})", + "Workspace trust ({}@{})", user_name, remote_host.host_identifier ), None => { - format!("Empty project ({})", remote_host.host_identifier) + format!("Workspace trust ({})", remote_host.host_identifier) } }, - None => "Empty project".to_string(), + None => "Workspace trust".to_string(), }, }; h_flex() diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index 34593f5bc8f6af3b9cbac87e8fbff50d3f954a95..00412cfb75fce58b19a697e283f77c5a57ebb683 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -80,7 +80,7 @@ use project::{ debugger::{breakpoint_store::BreakpointStoreEvent, session::ThreadStatus}, project_settings::ProjectSettings, toolchain_store::ToolchainStoreEvent, - trusted_worktrees::TrustedWorktrees, + trusted_worktrees::{TrustedWorktrees, TrustedWorktreesEvent}, }; use remote::{ RemoteClientDelegate, RemoteConnection, RemoteConnectionOptions, @@ -1184,6 +1184,7 @@ pub struct Workspace { _observe_current_user: Task>, _schedule_serialize_workspace: Option>, _schedule_serialize_ssh_paths: Option>, + _schedule_serialize_worktree_trust: Task<()>, pane_history_timestamp: Arc, bounds: Bounds, pub centered_layout: bool, @@ -1229,16 +1230,43 @@ impl Workspace { window: &mut Window, cx: &mut Context, ) -> Self { - cx.observe_global::(|_, cx| { - if ProjectSettings::get_global(cx).session.trust_all_worktrees { - if let Some(trusted_worktrees) = TrustedWorktrees::try_get_global(cx) { - trusted_worktrees.update(cx, |trusted_worktrees, cx| { - trusted_worktrees.auto_trust_all(cx); - }) + if let Some(trusted_worktrees) = TrustedWorktrees::try_get_global(cx) { + cx.subscribe(&trusted_worktrees, |workspace, worktrees_store, e, cx| { + if let TrustedWorktreesEvent::Trusted(..) = e { + let (new_trusted_workspaces, new_trusted_worktrees) = worktrees_store + .update(cx, |worktrees_store, cx| { + worktrees_store.trusted_paths_for_serialization(cx) + }); + // Do not persist auto trusted worktrees + if !ProjectSettings::get_global(cx).session.trust_all_worktrees { + let timeout = cx.background_executor().timer(SERIALIZATION_THROTTLE_TIME); + workspace._schedule_serialize_worktree_trust = + cx.background_spawn(async move { + timeout.await; + persistence::DB + .save_trusted_worktrees( + new_trusted_worktrees, + new_trusted_workspaces, + ) + .await + .log_err(); + }); + } } - } - }) - .detach(); + }) + .detach(); + + cx.observe_global::(|_, cx| { + if ProjectSettings::get_global(cx).session.trust_all_worktrees { + if let Some(trusted_worktrees) = TrustedWorktrees::try_get_global(cx) { + trusted_worktrees.update(cx, |trusted_worktrees, cx| { + trusted_worktrees.auto_trust_all(cx); + }) + } + } + }) + .detach(); + } cx.subscribe_in(&project, window, move |this, _, event, window, cx| { match event { @@ -1250,11 +1278,25 @@ impl Workspace { this.collaborator_left(*peer_id, window, cx); } - project::Event::WorktreeRemoved(_) | project::Event::WorktreeAdded(_) => { - this.update_window_title(window, cx); - this.serialize_workspace(window, cx); - // This event could be triggered by `AddFolderToProject` or `RemoveFromProject`. - this.update_history(cx); + project::Event::WorktreeUpdatedEntries(worktree_id, _) => { + if let Some(trusted_worktrees) = TrustedWorktrees::try_get_global(cx) { + trusted_worktrees.update(cx, |trusted_worktrees, cx| { + trusted_worktrees.can_trust(*worktree_id, cx); + }); + } + } + + project::Event::WorktreeRemoved(_) => { + this.update_worktree_data(window, cx); + } + + project::Event::WorktreeAdded(worktree_id) => { + if let Some(trusted_worktrees) = TrustedWorktrees::try_get_global(cx) { + trusted_worktrees.update(cx, |trusted_worktrees, cx| { + trusted_worktrees.can_trust(*worktree_id, cx); + }); + } + this.update_worktree_data(window, cx); } project::Event::DisconnectedFromHost => { @@ -1540,6 +1582,7 @@ impl Workspace { _apply_leader_updates, _schedule_serialize_workspace: None, _schedule_serialize_ssh_paths: None, + _schedule_serialize_worktree_trust: Task::ready(()), leader_updates_tx, _subscriptions: subscriptions, pane_history_timestamp, @@ -5970,12 +6013,14 @@ impl Workspace { .on_action( cx.listener(|_: &mut Workspace, _: &ClearTrustedWorktrees, _, cx| { if let Some(trusted_worktrees) = TrustedWorktrees::try_get_global(cx) { - let clear_task = trusted_worktrees.update(cx, |trusted_worktrees, cx| { - trusted_worktrees.clear_trusted_paths(cx) + trusted_worktrees.update(cx, |trusted_worktrees, _| { + trusted_worktrees.clear_trusted_paths() }); + let clear_task = persistence::DB.clear_trusted_worktrees(); cx.spawn(async move |_, cx| { - clear_task.await; - cx.update(|cx| reload(cx)).ok(); + if clear_task.await.log_err().is_some() { + cx.update(|cx| reload(cx)).ok(); + } }) .detach(); } @@ -6496,6 +6541,13 @@ impl Workspace { } } } + + fn update_worktree_data(&mut self, window: &mut Window, cx: &mut Context<'_, Self>) { + self.update_window_title(window, cx); + self.serialize_workspace(window, cx); + // This event could be triggered by `AddFolderToProject` or `RemoveFromProject`. + self.update_history(cx); + } } fn leader_border_for_pane( diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rs index 353baba02cca9b0060a647f438fa8be4e81e9142..c8137a71c0f2a8524f6310d7cd711978ed833d1a 100644 --- a/crates/zed/src/main.rs +++ b/crates/zed/src/main.rs @@ -407,7 +407,14 @@ pub fn main() { }); app.run(move |cx| { - trusted_worktrees::init(None, None, cx); + let trusted_paths = match workspace::WORKSPACE_DB.fetch_trusted_worktrees(None, None, cx) { + Ok(trusted_paths) => trusted_paths, + Err(e) => { + log::error!("Failed to do initial trusted worktrees fetch: {e:#}"); + HashMap::default() + } + }; + trusted_worktrees::init(trusted_paths, None, None, cx); menu::init(); zed_actions::init(); From 4fe6dc06ea96b0f7a81f2fc7f2200ea27d4eb0a4 Mon Sep 17 00:00:00 2001 From: Anthony Eid <56899983+Anthony-Eid@users.noreply.github.com> Date: Tue, 16 Dec 2025 19:02:46 -0500 Subject: [PATCH 412/621] git: Align checkboxes in git panel (#45048) Before this fix checkboxes would overflow off the visible view which isn't ideal. This aligns the checkboxes by allowing the path name to overflow. #### Before image #### After image Release Notes: - N/A Co-authored-by: Cole Miller Co-authored-by: Matt Miller --- crates/git_ui/src/git_panel.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs index 37926eae5db12c83ab69613a09c4eceda1f5ffeb..8b32a79311f1f52036d8e54d182139d45bf64d10 100644 --- a/crates/git_ui/src/git_panel.rs +++ b/crates/git_ui/src/git_panel.rs @@ -4949,7 +4949,7 @@ impl GitPanel { cx.stop_propagation(); }, ) - .child(name_row) + .child(name_row.overflow_x_hidden()) .child( div() .id(checkbox_wrapper_id) @@ -5103,7 +5103,7 @@ impl GitPanel { this.toggle_directory(&key, window, cx); }) }) - .child(name_row) + .child(name_row.overflow_x_hidden()) .child( div() .id(checkbox_wrapper_id) From 975a76bbf09e2b3b0207c2d02947851591500c2f Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Wed, 17 Dec 2025 01:42:04 +0100 Subject: [PATCH 413/621] Bump Rust version to 1.92 (#44649) Release Notes: - N/A --------- Co-authored-by: Julia Ryan --- Dockerfile-collab | 2 +- crates/editor/src/editor.rs | 7 +++---- crates/git_ui/src/branch_picker.rs | 6 +++--- crates/gpui/src/elements/surface.rs | 1 + crates/gpui/src/elements/uniform_list.rs | 4 ++-- crates/language/src/buffer.rs | 3 +-- crates/project/src/lsp_store.rs | 14 ++++++-------- crates/vim/src/motion.rs | 8 +------- crates/zed/src/zed.rs | 2 ++ flake.lock | 22 ++++++++++------------ rust-toolchain.toml | 2 +- 11 files changed, 31 insertions(+), 40 deletions(-) diff --git a/Dockerfile-collab b/Dockerfile-collab index 68f898618a5d0cd1ad9999e5482c53dc0cb26da6..188e7daddfb471c41b237ca75469355cfc866ae3 100644 --- a/Dockerfile-collab +++ b/Dockerfile-collab @@ -1,6 +1,6 @@ # syntax = docker/dockerfile:1.2 -FROM rust:1.91.1-bookworm as builder +FROM rust:1.92-bookworm as builder WORKDIR app COPY . . diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index f4a83f900da68d90803b82c0aec1287fcaa71cd3..4072b1db7a1935e5dbb9c63d2a3aa19db270f131 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -15534,10 +15534,9 @@ impl Editor { I: IntoIterator, P: AsRef<[u8]>, { - let case_sensitive = self.select_next_is_case_sensitive.map_or_else( - || EditorSettings::get_global(cx).search.case_sensitive, - |value| value, - ); + let case_sensitive = self + .select_next_is_case_sensitive + .unwrap_or_else(|| EditorSettings::get_global(cx).search.case_sensitive); let mut builder = AhoCorasickBuilder::new(); builder.ascii_case_insensitive(!case_sensitive); diff --git a/crates/git_ui/src/branch_picker.rs b/crates/git_ui/src/branch_picker.rs index c7cf72cdbd880bbd0bca7611474b42a3a600cc48..cbf3fea72a9937a0ab882f9ccca2c4274afdf0e2 100644 --- a/crates/git_ui/src/branch_picker.rs +++ b/crates/git_ui/src/branch_picker.rs @@ -969,12 +969,12 @@ impl PickerDelegate for BranchListDelegate { "No commits found".into(), |subject| { if show_author_name - && author_name.is_some() + && let Some(author) = + author_name { format!( "{} • {}", - author_name.unwrap(), - subject + author, subject ) } else { subject.to_string() diff --git a/crates/gpui/src/elements/surface.rs b/crates/gpui/src/elements/surface.rs index b4fced1001b3f9881b66f2f93e81588c750aa64c..ac1c247b47ec81bca06e458827786f549ca2d747 100644 --- a/crates/gpui/src/elements/surface.rs +++ b/crates/gpui/src/elements/surface.rs @@ -29,6 +29,7 @@ pub struct Surface { } /// Create a new surface element. +#[cfg(target_os = "macos")] pub fn surface(source: impl Into) -> Surface { Surface { source: source.into(), diff --git a/crates/gpui/src/elements/uniform_list.rs b/crates/gpui/src/elements/uniform_list.rs index 1e38b0e7ac9abcf891201b7db61b819abe00ef1e..1ad71b97673e6f54015dbc67fa829725dd4fccb2 100644 --- a/crates/gpui/src/elements/uniform_list.rs +++ b/crates/gpui/src/elements/uniform_list.rs @@ -712,8 +712,8 @@ mod test { #[gpui::test] fn test_scroll_strategy_nearest(cx: &mut TestAppContext) { use crate::{ - Context, FocusHandle, ScrollStrategy, UniformListScrollHandle, Window, actions, div, - prelude::*, px, uniform_list, + Context, FocusHandle, ScrollStrategy, UniformListScrollHandle, Window, div, prelude::*, + px, uniform_list, }; use std::ops::Range; diff --git a/crates/language/src/buffer.rs b/crates/language/src/buffer.rs index 59795c375ab9b663339dbbebccc60062058c6ef9..a0ec214c765fccacff1c72e3f22de586570b3cd3 100644 --- a/crates/language/src/buffer.rs +++ b/crates/language/src/buffer.rs @@ -3303,8 +3303,7 @@ impl BufferSnapshot { // set its end to the outdent position if let Some(range_to_truncate) = indent_ranges .iter_mut() - .filter(|indent_range| indent_range.contains(&outdent_position)) - .next_back() + .rfind(|indent_range| indent_range.contains(&outdent_position)) { range_to_truncate.end = outdent_position; } diff --git a/crates/project/src/lsp_store.rs b/crates/project/src/lsp_store.rs index 2ea3dbf70fcb4359f3f5985cc6cd3bb4db7df009..83c2abfbb863166fd52e177dd75b497ca5111999 100644 --- a/crates/project/src/lsp_store.rs +++ b/crates/project/src/lsp_store.rs @@ -2285,12 +2285,10 @@ impl LocalLspStore { && lsp_action.data.is_some() && (lsp_action.command.is_none() || lsp_action.edit.is_none()) { - *lsp_action = Box::new( - lang_server - .request::(*lsp_action.clone()) - .await - .into_response()?, - ); + **lsp_action = lang_server + .request::(*lsp_action.clone()) + .await + .into_response()?; } } LspAction::CodeLens(lens) => { @@ -6480,7 +6478,7 @@ impl LspStore { server_id == *completion_server_id, "server_id mismatch, applying completion resolve for {server_id} but completion server id is {completion_server_id}" ); - *lsp_completion = Box::new(resolved_completion); + **lsp_completion = resolved_completion; *resolved = true; } Ok(()) @@ -6639,7 +6637,7 @@ impl LspStore { server_id == *completion_server_id, "remote server_id mismatch, applying completion resolve for {server_id} but completion server id is {completion_server_id}" ); - *lsp_completion = Box::new(resolved_lsp_completion); + **lsp_completion = resolved_lsp_completion; *resolved = true; } diff --git a/crates/vim/src/motion.rs b/crates/vim/src/motion.rs index 6ba28a1c236ada7c08eeabac9d9189991434a807..f2e629faf2dd4a5d1ff47a49278cdd022f75d8d4 100644 --- a/crates/vim/src/motion.rs +++ b/crates/vim/src/motion.rs @@ -1,5 +1,5 @@ use editor::{ - Anchor, Bias, BufferOffset, DisplayPoint, Editor, MultiBufferOffset, RowExt, ToOffset, ToPoint, + Anchor, Bias, BufferOffset, DisplayPoint, Editor, MultiBufferOffset, RowExt, ToOffset, display_map::{DisplayRow, DisplaySnapshot, FoldPoint, ToDisplayPoint}, movement::{ self, FindRange, TextLayoutDetails, find_boundary, find_preceding_boundary_display_point, @@ -2262,7 +2262,6 @@ fn go_to_line(map: &DisplaySnapshot, display_point: DisplayPoint, line: usize) - .offset_to_point(excerpt.map_offset_from_buffer(BufferOffset(offset))); return map.clip_point(map.point_to_display_point(point, Bias::Left), Bias::Left); } - let mut last_position = None; for (excerpt, buffer, range) in map.buffer_snapshot().excerpts() { let excerpt_range = language::ToOffset::to_offset(&range.context.start, buffer) ..language::ToOffset::to_offset(&range.context.end, buffer); @@ -2273,14 +2272,9 @@ fn go_to_line(map: &DisplaySnapshot, display_point: DisplayPoint, line: usize) - } else if offset <= excerpt_range.start { let anchor = Anchor::in_buffer(excerpt, range.context.start); return anchor.to_display_point(map); - } else { - last_position = Some(Anchor::in_buffer(excerpt, range.context.end)); } } - let mut last_point = last_position.unwrap().to_point(&map.buffer_snapshot()); - last_point.column = point.column; - map.clip_point( map.point_to_display_point( map.buffer_snapshot().clip_point(point, Bias::Left), diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs index c1d98936aa2ad20e6eef7f18bfed2d2c0615395a..fc5e74a76905d1ea45fa8bad2df12e22a23122e3 100644 --- a/crates/zed/src/zed.rs +++ b/crates/zed/src/zed.rs @@ -353,6 +353,8 @@ pub fn initialize_workspace( ) { let mut _on_close_subscription = bind_on_window_closed(cx); cx.observe_global::(move |cx| { + // A 1.92 regression causes unused-assignment to trigger on this variable. + _ = _on_close_subscription.is_some(); _on_close_subscription = bind_on_window_closed(cx); }) .detach(); diff --git a/flake.lock b/flake.lock index 520dcb3f7469319dbf755bfd70103cb5de1b2c48..561919d5745a2355aad14a4fe9972bf9fbf3d8d2 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "crane": { "locked": { - "lastModified": 1762538466, - "narHash": "sha256-8zrIPl6J+wLm9MH5ksHcW7BUHo7jSNOu0/hA0ohOOaM=", + "lastModified": 1765145449, + "narHash": "sha256-aBVHGWWRzSpfL++LubA0CwOOQ64WNLegrYHwsVuVN7A=", "owner": "ipetkov", "repo": "crane", - "rev": "0cea393fffb39575c46b7a0318386467272182fe", + "rev": "69f538cdce5955fcd47abfed4395dc6d5194c1c5", "type": "github" }, "original": { @@ -17,11 +17,11 @@ }, "flake-compat": { "locked": { - "lastModified": 1761588595, - "narHash": "sha256-XKUZz9zewJNUj46b4AJdiRZJAvSZ0Dqj2BNfXvFlJC4=", + "lastModified": 1765121682, + "narHash": "sha256-4VBOP18BFeiPkyhy9o4ssBNQEvfvv1kXkasAYd0+rrA=", "owner": "edolstra", "repo": "flake-compat", - "rev": "f387cd2afec9419c8ee37694406ca490c3f34ee5", + "rev": "65f23138d8d09a92e30f1e5c87611b23ef451bf3", "type": "github" }, "original": { @@ -53,16 +53,14 @@ }, "rust-overlay": { "inputs": { - "nixpkgs": [ - "nixpkgs" - ] + "nixpkgs": ["nixpkgs"] }, "locked": { - "lastModified": 1762915112, - "narHash": "sha256-d9j1g8nKmYDHy+/bIOPQTh9IwjRliqaTM0QLHMV92Ic=", + "lastModified": 1765465581, + "narHash": "sha256-fCXT0aZXmTalM3NPCTedVs9xb0egBG5BOZkcrYo5PGE=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "aa1e85921cfa04de7b6914982a94621fbec5cc02", + "rev": "99cc5667eece98bb35dcf35f7e511031a8b7a125", "type": "github" }, "original": { diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 59765d94abe9c04e6668203de31b598dd6b34dc7..e7cc22421d71ba35b592dd2163da1927c4abf118 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] -channel = "1.91.1" +channel = "1.92" profile = "minimal" components = [ "rustfmt", "clippy" ] targets = [ From 1c33dbcb667e6c019408b165740aef4008bbceb8 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 16 Dec 2025 17:41:06 -0800 Subject: [PATCH 414/621] Fix slow tree-sitter query execution by limiting the range that queries search (#39416) Part of https://github.com/zed-industries/zed/issues/39594 Closes https://github.com/zed-industries/zed/issues/4701 Closes https://github.com/zed-industries/zed/issues/42861 Closes https://github.com/zed-industries/zed/issues/44503 ~Depends on https://github.com/tree-sitter/tree-sitter/pull/4919~ Release Notes: - Fixed some performance bottlenecks related to syntax analysis when editing very large files --------- Co-authored-by: Kirill Bulatov --- crates/language/src/buffer.rs | 30 ++++++++++++++++++++---------- crates/language/src/syntax_map.rs | 21 ++++++++++++++++++++- 2 files changed, 40 insertions(+), 11 deletions(-) diff --git a/crates/language/src/buffer.rs b/crates/language/src/buffer.rs index a0ec214c765fccacff1c72e3f22de586570b3cd3..2a9b4ea1df4fc0b4772586f0e51016cdd1882722 100644 --- a/crates/language/src/buffer.rs +++ b/crates/language/src/buffer.rs @@ -8,8 +8,8 @@ use crate::{ outline::OutlineItem, row_chunk::RowChunks, syntax_map::{ - SyntaxLayer, SyntaxMap, SyntaxMapCapture, SyntaxMapCaptures, SyntaxMapMatch, - SyntaxMapMatches, SyntaxSnapshot, ToTreeSitterPoint, + MAX_BYTES_TO_QUERY, SyntaxLayer, SyntaxMap, SyntaxMapCapture, SyntaxMapCaptures, + SyntaxMapMatch, SyntaxMapMatches, SyntaxSnapshot, ToTreeSitterPoint, }, task_context::RunnableRange, text_diff::text_diff, @@ -3222,9 +3222,15 @@ impl BufferSnapshot { let start = Point::new(prev_non_blank_row.unwrap_or(row_range.start), 0); let end = Point::new(row_range.end, 0); let range = (start..end).to_offset(&self.text); - let mut matches = self.syntax.matches(range.clone(), &self.text, |grammar| { - Some(&grammar.indents_config.as_ref()?.query) - }); + let mut matches = self.syntax.matches_with_options( + range.clone(), + &self.text, + TreeSitterOptions { + max_bytes_to_query: Some(MAX_BYTES_TO_QUERY), + max_start_depth: None, + }, + |grammar| Some(&grammar.indents_config.as_ref()?.query), + ); let indent_configs = matches .grammars() .iter() @@ -4335,11 +4341,15 @@ impl BufferSnapshot { let mut opens = Vec::new(); let mut color_pairs = Vec::new(); - let mut matches = self - .syntax - .matches(chunk_range.clone(), &self.text, |grammar| { - grammar.brackets_config.as_ref().map(|c| &c.query) - }); + let mut matches = self.syntax.matches_with_options( + chunk_range.clone(), + &self.text, + TreeSitterOptions { + max_bytes_to_query: Some(MAX_BYTES_TO_QUERY), + max_start_depth: None, + }, + |grammar| grammar.brackets_config.as_ref().map(|c| &c.query), + ); let configs = matches .grammars() .iter() diff --git a/crates/language/src/syntax_map.rs b/crates/language/src/syntax_map.rs index 17285ca315fb64dd518d00039d28266c0a7f51ab..77e90c4ca89d0b6e5b8cb0a604175ec9a97e719e 100644 --- a/crates/language/src/syntax_map.rs +++ b/crates/language/src/syntax_map.rs @@ -21,6 +21,8 @@ use sum_tree::{Bias, Dimensions, SeekTarget, SumTree}; use text::{Anchor, BufferSnapshot, OffsetRangeExt, Point, Rope, ToOffset, ToPoint}; use tree_sitter::{Node, Query, QueryCapture, QueryCaptures, QueryCursor, QueryMatches, Tree}; +pub const MAX_BYTES_TO_QUERY: usize = 16 * 1024; + pub struct SyntaxMap { snapshot: SyntaxSnapshot, language_registry: Option>, @@ -1096,12 +1098,15 @@ impl<'a> SyntaxMapCaptures<'a> { #[derive(Default)] pub struct TreeSitterOptions { - max_start_depth: Option, + pub max_start_depth: Option, + pub max_bytes_to_query: Option, } + impl TreeSitterOptions { pub fn max_start_depth(max_start_depth: u32) -> Self { Self { max_start_depth: Some(max_start_depth), + max_bytes_to_query: None, } } } @@ -1135,6 +1140,14 @@ impl<'a> SyntaxMapMatches<'a> { }; cursor.set_max_start_depth(options.max_start_depth); + if let Some(max_bytes_to_query) = options.max_bytes_to_query { + let midpoint = (range.start + range.end) / 2; + let containing_range_start = midpoint.saturating_sub(max_bytes_to_query / 2); + let containing_range_end = + containing_range_start.saturating_add(max_bytes_to_query); + cursor.set_containing_byte_range(containing_range_start..containing_range_end); + } + cursor.set_byte_range(range.clone()); let matches = cursor.matches(query, layer.node(), TextProvider(text)); let grammar_index = result @@ -1642,6 +1655,10 @@ impl<'a> SyntaxLayer<'a> { let mut query_cursor = QueryCursorHandle::new(); query_cursor.set_byte_range(offset.saturating_sub(1)..offset.saturating_add(1)); + query_cursor.set_containing_byte_range( + offset.saturating_sub(MAX_BYTES_TO_QUERY / 2) + ..offset.saturating_add(MAX_BYTES_TO_QUERY / 2), + ); let mut smallest_match: Option<(u32, Range)> = None; let mut matches = query_cursor.matches(&config.query, self.node(), text); @@ -1928,6 +1945,8 @@ impl Drop for QueryCursorHandle { let mut cursor = self.0.take().unwrap(); cursor.set_byte_range(0..usize::MAX); cursor.set_point_range(Point::zero().to_ts_point()..Point::MAX.to_ts_point()); + cursor.set_containing_byte_range(0..usize::MAX); + cursor.set_containing_point_range(Point::zero().to_ts_point()..Point::MAX.to_ts_point()); QUERY_CURSORS.lock().push(cursor) } } From 92b1f1fffb5a1c91d40b9b27e906beb87b301246 Mon Sep 17 00:00:00 2001 From: Matthew Chisolm <39521893+mchisolm0@users.noreply.github.com> Date: Tue, 16 Dec 2025 22:59:47 -0600 Subject: [PATCH 415/621] workspace: Persist window values without project (#44937) Persist and restore window values (size, position, etc.) to the KV Store when there are no projects open. Relates to Discussion https://github.com/zed-industries/zed/discussions/24228#discussioncomment-15224666 Release Notes: - Added persistence for window size when no projects are open --------- Co-authored-by: Conrad Irwin --- crates/workspace/src/persistence.rs | 138 ++++++++++++++++++++++++---- crates/workspace/src/workspace.rs | 37 ++++++-- 2 files changed, 150 insertions(+), 25 deletions(-) diff --git a/crates/workspace/src/persistence.rs b/crates/workspace/src/persistence.rs index dc113db68e33dc527e6b8d2cb66f644bcd83b661..4a8aab364db3ec37f7f089b8dc3df4ca1114ee28 100644 --- a/crates/workspace/src/persistence.rs +++ b/crates/workspace/src/persistence.rs @@ -11,6 +11,7 @@ use std::{ use anyhow::{Context as _, Result, bail}; use collections::{HashMap, HashSet, IndexSet}; use db::{ + kvp::KEY_VALUE_STORE, query, sqlez::{connection::Connection, domain::Domain}, sqlez_macros::sql, @@ -27,6 +28,7 @@ use project::WorktreeId; use remote::{ DockerConnectionOptions, RemoteConnectionOptions, SshConnectionOptions, WslConnectionOptions, }; +use serde::{Deserialize, Serialize}; use sqlez::{ bindable::{Bind, Column, StaticColumnCount}, statement::Statement, @@ -163,6 +165,124 @@ impl Column for SerializedWindowBounds { } } +const DEFAULT_WINDOW_BOUNDS_KEY: &str = "default_window_bounds"; + +pub fn read_default_window_bounds() -> Option<(Uuid, WindowBounds)> { + let json_str = KEY_VALUE_STORE + .read_kvp(DEFAULT_WINDOW_BOUNDS_KEY) + .log_err() + .flatten()?; + + let (display_uuid, persisted) = + serde_json::from_str::<(Uuid, WindowBoundsJson)>(&json_str).ok()?; + Some((display_uuid, persisted.into())) +} + +pub async fn write_default_window_bounds( + bounds: WindowBounds, + display_uuid: Uuid, +) -> anyhow::Result<()> { + let persisted = WindowBoundsJson::from(bounds); + let json_str = serde_json::to_string(&(display_uuid, persisted))?; + KEY_VALUE_STORE + .write_kvp(DEFAULT_WINDOW_BOUNDS_KEY.to_string(), json_str) + .await?; + Ok(()) +} + +#[derive(Serialize, Deserialize)] +pub enum WindowBoundsJson { + Windowed { + x: i32, + y: i32, + width: i32, + height: i32, + }, + Maximized { + x: i32, + y: i32, + width: i32, + height: i32, + }, + Fullscreen { + x: i32, + y: i32, + width: i32, + height: i32, + }, +} + +impl From for WindowBoundsJson { + fn from(b: WindowBounds) -> Self { + match b { + WindowBounds::Windowed(bounds) => { + let origin = bounds.origin; + let size = bounds.size; + WindowBoundsJson::Windowed { + x: f32::from(origin.x).round() as i32, + y: f32::from(origin.y).round() as i32, + width: f32::from(size.width).round() as i32, + height: f32::from(size.height).round() as i32, + } + } + WindowBounds::Maximized(bounds) => { + let origin = bounds.origin; + let size = bounds.size; + WindowBoundsJson::Maximized { + x: f32::from(origin.x).round() as i32, + y: f32::from(origin.y).round() as i32, + width: f32::from(size.width).round() as i32, + height: f32::from(size.height).round() as i32, + } + } + WindowBounds::Fullscreen(bounds) => { + let origin = bounds.origin; + let size = bounds.size; + WindowBoundsJson::Fullscreen { + x: f32::from(origin.x).round() as i32, + y: f32::from(origin.y).round() as i32, + width: f32::from(size.width).round() as i32, + height: f32::from(size.height).round() as i32, + } + } + } + } +} + +impl From for WindowBounds { + fn from(n: WindowBoundsJson) -> Self { + match n { + WindowBoundsJson::Windowed { + x, + y, + width, + height, + } => WindowBounds::Windowed(Bounds { + origin: point(px(x as f32), px(y as f32)), + size: size(px(width as f32), px(height as f32)), + }), + WindowBoundsJson::Maximized { + x, + y, + width, + height, + } => WindowBounds::Maximized(Bounds { + origin: point(px(x as f32), px(y as f32)), + size: size(px(width as f32), px(height as f32)), + }), + WindowBoundsJson::Fullscreen { + x, + y, + width, + height, + } => WindowBounds::Fullscreen(Bounds { + origin: point(px(x as f32), px(y as f32)), + size: size(px(width as f32), px(height as f32)), + }), + } + } +} + #[derive(Debug)] pub struct Breakpoint { pub position: u32, @@ -1381,24 +1501,6 @@ impl WorkspaceDb { } } - pub(crate) fn last_window( - &self, - ) -> anyhow::Result<(Option, Option)> { - let mut prepared_query = - self.select::<(Option, Option)>(sql!( - SELECT - display, - window_state, window_x, window_y, window_width, window_height - FROM workspaces - WHERE paths - IS NOT NULL - ORDER BY timestamp DESC - LIMIT 1 - ))?; - let result = prepared_query()?; - Ok(result.into_iter().next().unwrap_or((None, None))) - } - query! { pub async fn delete_workspace_by_id(id: WorkspaceId) -> Result<()> { DELETE FROM workspaces diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index 00412cfb75fce58b19a697e283f77c5a57ebb683..5947cb1703b37017bf75bfe412603332b8d5016a 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -1508,6 +1508,15 @@ impl Workspace { && let Ok(display_uuid) = display.uuid() { let window_bounds = window.inner_window_bounds(); + let has_paths = !this.root_paths(cx).is_empty(); + if !has_paths { + cx.background_executor() + .spawn(persistence::write_default_window_bounds( + window_bounds, + display_uuid, + )) + .detach_and_log_err(cx); + } if let Some(database_id) = workspace_id { cx.background_executor() .spawn(DB.set_window_open_status( @@ -1516,6 +1525,13 @@ impl Workspace { display_uuid, )) .detach_and_log_err(cx); + } else { + cx.background_executor() + .spawn(persistence::write_default_window_bounds( + window_bounds, + display_uuid, + )) + .detach_and_log_err(cx); } } this.bounds_save_task_queued.take(); @@ -1724,6 +1740,7 @@ impl Workspace { window } else { let window_bounds_override = window_bounds_env_override(); + let is_empty_workspace = project_paths.is_empty(); let (window_bounds, display) = if let Some(bounds) = window_bounds_override { (Some(WindowBounds::Windowed(bounds)), None) @@ -1736,6 +1753,13 @@ impl Workspace { } else { (None, None) } + } else if is_empty_workspace { + // Empty workspace - try to restore the last known no-project window bounds + if let Some((display, bounds)) = persistence::read_default_window_bounds() { + (Some(bounds), Some(display)) + } else { + (None, None) + } } else { // New window - let GPUI's default_bounds() handle cascading (None, None) @@ -8820,14 +8844,13 @@ pub fn remote_workspace_position_from_db( } else { let restorable_bounds = serialized_workspace .as_ref() - .and_then(|workspace| Some((workspace.display?, workspace.window_bounds?))) - .or_else(|| { - let (display, window_bounds) = DB.last_window().log_err()?; - Some((display?, window_bounds?)) - }); + .and_then(|workspace| { + Some((workspace.display?, workspace.window_bounds.map(|b| b.0)?)) + }) + .or_else(|| persistence::read_default_window_bounds()); - if let Some((serialized_display, serialized_status)) = restorable_bounds { - (Some(serialized_status.0), Some(serialized_display)) + if let Some((serialized_display, serialized_bounds)) = restorable_bounds { + (Some(serialized_bounds), Some(serialized_display)) } else { (None, None) } From 76665a78d1ed9e630599a109320b659b2db3b364 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Tue, 16 Dec 2025 22:47:44 -0700 Subject: [PATCH 416/621] More secure auto-fixer (#44952) Split running `cargo clippy` out of the job that has access to ZIPPY secrets as a precaution against accidentally leaking the secrets through build.rs or something... Release Notes: - N/A --- .github/workflows/autofix_pr.yml | 78 ++++++++--- .../xtask/src/tasks/workflows/autofix_pr.rs | 129 ++++++++++++++---- 2 files changed, 159 insertions(+), 48 deletions(-) diff --git a/.github/workflows/autofix_pr.yml b/.github/workflows/autofix_pr.yml index 308849ccbeed0be7f9ab5c8f7e5846ed61a8724d..762b86c446f4592e8fd76c8f5a00cf8cf8ab3f38 100644 --- a/.github/workflows/autofix_pr.yml +++ b/.github/workflows/autofix_pr.yml @@ -9,26 +9,23 @@ on: description: pr_number required: true type: string + run_clippy: + description: run_clippy + type: boolean + default: 'true' jobs: run_autofix: runs-on: namespace-profile-16x32-ubuntu-2204 steps: - - id: get-app-token - name: autofix_pr::run_autofix::authenticate_as_zippy - uses: actions/create-github-app-token@bef1eaf1c0ac2b148ee2a0a74c65fbe6db0631f1 - with: - app-id: ${{ secrets.ZED_ZIPPY_APP_ID }} - private-key: ${{ secrets.ZED_ZIPPY_APP_PRIVATE_KEY }} - - name: steps::checkout_repo_with_token + - name: steps::checkout_repo uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 with: clean: false - token: ${{ steps.get-app-token.outputs.token }} - name: autofix_pr::run_autofix::checkout_pr run: gh pr checkout ${{ inputs.pr_number }} shell: bash -euxo pipefail {0} env: - GITHUB_TOKEN: ${{ steps.get-app-token.outputs.token }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: steps::setup_cargo_config run: | mkdir -p ./../.cargo @@ -58,26 +55,71 @@ jobs: run: cargo fmt --all shell: bash -euxo pipefail {0} - name: autofix_pr::run_autofix::run_clippy_fix + if: ${{ inputs.run_clippy }} run: cargo clippy --workspace --release --all-targets --all-features --fix --allow-dirty --allow-staged shell: bash -euxo pipefail {0} - - name: autofix_pr::run_autofix::commit_and_push + - id: create-patch + name: autofix_pr::run_autofix::create_patch run: | if git diff --quiet; then echo "No changes to commit" + echo "has_changes=false" >> "$GITHUB_OUTPUT" else - git add -A - git commit -m "Autofix" - git push + git diff > autofix.patch + echo "has_changes=true" >> "$GITHUB_OUTPUT" fi shell: bash -euxo pipefail {0} + - name: upload artifact autofix-patch + uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 + with: + name: autofix-patch + path: autofix.patch + if-no-files-found: ignore + retention-days: '1' + - name: steps::cleanup_cargo_config + if: always() + run: | + rm -rf ./../.cargo + shell: bash -euxo pipefail {0} + outputs: + has_changes: ${{ steps.create-patch.outputs.has_changes }} + commit_changes: + needs: + - run_autofix + if: needs.run_autofix.outputs.has_changes == 'true' + runs-on: namespace-profile-2x4-ubuntu-2404 + steps: + - id: get-app-token + name: autofix_pr::commit_changes::authenticate_as_zippy + uses: actions/create-github-app-token@bef1eaf1c0ac2b148ee2a0a74c65fbe6db0631f1 + with: + app-id: ${{ secrets.ZED_ZIPPY_APP_ID }} + private-key: ${{ secrets.ZED_ZIPPY_APP_PRIVATE_KEY }} + - name: steps::checkout_repo_with_token + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 + with: + clean: false + token: ${{ steps.get-app-token.outputs.token }} + - name: autofix_pr::commit_changes::checkout_pr + run: gh pr checkout ${{ inputs.pr_number }} + shell: bash -euxo pipefail {0} + env: + GITHUB_TOKEN: ${{ steps.get-app-token.outputs.token }} + - name: autofix_pr::download_patch_artifact + uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 + with: + name: autofix-patch + - name: autofix_pr::commit_changes::apply_patch + run: git apply autofix.patch + shell: bash -euxo pipefail {0} + - name: autofix_pr::commit_changes::commit_and_push + run: | + git commit -am "Autofix" + git push + shell: bash -euxo pipefail {0} env: GIT_COMMITTER_NAME: Zed Zippy GIT_COMMITTER_EMAIL: 234243425+zed-zippy[bot]@users.noreply.github.com GIT_AUTHOR_NAME: Zed Zippy GIT_AUTHOR_EMAIL: 234243425+zed-zippy[bot]@users.noreply.github.com GITHUB_TOKEN: ${{ steps.get-app-token.outputs.token }} - - name: steps::cleanup_cargo_config - if: always() - run: | - rm -rf ./../.cargo - shell: bash -euxo pipefail {0} diff --git a/tooling/xtask/src/tasks/workflows/autofix_pr.rs b/tooling/xtask/src/tasks/workflows/autofix_pr.rs index 835750e282dad39a3455fc0b5eb69bf82cc42201..44dd0f9ea9b840163767e15b973192e72b57f4a8 100644 --- a/tooling/xtask/src/tasks/workflows/autofix_pr.rs +++ b/tooling/xtask/src/tasks/workflows/autofix_pr.rs @@ -8,31 +8,49 @@ use crate::tasks::workflows::{ pub fn autofix_pr() -> Workflow { let pr_number = WorkflowInput::string("pr_number", None); - let autofix = run_autofix(&pr_number); + let run_clippy = WorkflowInput::bool("run_clippy", Some(true)); + let run_autofix = run_autofix(&pr_number, &run_clippy); + let commit_changes = commit_changes(&pr_number, &run_autofix); named::workflow() .run_name(format!("autofix PR #{pr_number}")) .on(Event::default().workflow_dispatch( - WorkflowDispatch::default().add_input(pr_number.name, pr_number.input()), + WorkflowDispatch::default() + .add_input(pr_number.name, pr_number.input()) + .add_input(run_clippy.name, run_clippy.input()), )) - .add_job(autofix.name, autofix.job) + .add_job(run_autofix.name.clone(), run_autofix.job) + .add_job(commit_changes.name, commit_changes.job) } -fn run_autofix(pr_number: &WorkflowInput) -> NamedJob { - fn authenticate_as_zippy() -> (Step, StepOutput) { - let step = named::uses( +const PATCH_ARTIFACT_NAME: &str = "autofix-patch"; +const PATCH_FILE_PATH: &str = "autofix.patch"; + +fn upload_patch_artifact() -> Step { + Step::new(format!("upload artifact {}", PATCH_ARTIFACT_NAME)) + .uses( "actions", - "create-github-app-token", - "bef1eaf1c0ac2b148ee2a0a74c65fbe6db0631f1", + "upload-artifact", + "330a01c490aca151604b8cf639adc76d48f6c5d4", // v5 ) - .add_with(("app-id", vars::ZED_ZIPPY_APP_ID)) - .add_with(("private-key", vars::ZED_ZIPPY_APP_PRIVATE_KEY)) - .id("get-app-token"); - let output = StepOutput::new(&step, "token"); - (step, output) - } + .add_with(("name", PATCH_ARTIFACT_NAME)) + .add_with(("path", PATCH_FILE_PATH)) + .add_with(("if-no-files-found", "ignore")) + .add_with(("retention-days", "1")) +} - fn checkout_pr(pr_number: &WorkflowInput, token: &StepOutput) -> Step { - named::bash(&format!("gh pr checkout {pr_number}")).add_env(("GITHUB_TOKEN", token)) +fn download_patch_artifact() -> Step { + named::uses( + "actions", + "download-artifact", + "018cc2cf5baa6db3ef3c5f8a56943fffe632ef53", // v6.0.0 + ) + .add_with(("name", PATCH_ARTIFACT_NAME)) +} + +fn run_autofix(pr_number: &WorkflowInput, run_clippy: &WorkflowInput) -> NamedJob { + fn checkout_pr(pr_number: &WorkflowInput) -> Step { + named::bash(&format!("gh pr checkout {pr_number}")) + .add_env(("GITHUB_TOKEN", vars::GITHUB_TOKEN)) } fn run_cargo_fmt() -> Step { @@ -49,16 +67,68 @@ fn run_autofix(pr_number: &WorkflowInput) -> NamedJob { named::bash("./script/prettier --write") } - fn commit_and_push(token: &StepOutput) -> Step { + fn create_patch() -> Step { named::bash(indoc::indoc! {r#" if git diff --quiet; then echo "No changes to commit" + echo "has_changes=false" >> "$GITHUB_OUTPUT" else - git add -A - git commit -m "Autofix" - git push + git diff > autofix.patch + echo "has_changes=true" >> "$GITHUB_OUTPUT" fi "#}) + .id("create-patch") + } + + named::job( + Job::default() + .runs_on(runners::LINUX_DEFAULT) + .outputs([( + "has_changes".to_owned(), + "${{ steps.create-patch.outputs.has_changes }}".to_owned(), + )]) + .add_step(steps::checkout_repo()) + .add_step(checkout_pr(pr_number)) + .add_step(steps::setup_cargo_config(runners::Platform::Linux)) + .add_step(steps::cache_rust_dependencies_namespace()) + .map(steps::install_linux_dependencies) + .add_step(steps::setup_pnpm()) + .add_step(run_prettier_fix()) + .add_step(run_cargo_fmt()) + .add_step(run_clippy_fix().if_condition(Expression::new(run_clippy.to_string()))) + .add_step(create_patch()) + .add_step(upload_patch_artifact()) + .add_step(steps::cleanup_cargo_config(runners::Platform::Linux)), + ) +} + +fn commit_changes(pr_number: &WorkflowInput, autofix_job: &NamedJob) -> NamedJob { + fn authenticate_as_zippy() -> (Step, StepOutput) { + let step = named::uses( + "actions", + "create-github-app-token", + "bef1eaf1c0ac2b148ee2a0a74c65fbe6db0631f1", + ) + .add_with(("app-id", vars::ZED_ZIPPY_APP_ID)) + .add_with(("private-key", vars::ZED_ZIPPY_APP_PRIVATE_KEY)) + .id("get-app-token"); + let output = StepOutput::new(&step, "token"); + (step, output) + } + + fn checkout_pr(pr_number: &WorkflowInput, token: &StepOutput) -> Step { + named::bash(&format!("gh pr checkout {pr_number}")).add_env(("GITHUB_TOKEN", token)) + } + + fn apply_patch() -> Step { + named::bash("git apply autofix.patch") + } + + fn commit_and_push(token: &StepOutput) -> Step { + named::bash(indoc::indoc! {r#" + git commit -am "Autofix" + git push + "#}) .add_env(("GIT_COMMITTER_NAME", "Zed Zippy")) .add_env(( "GIT_COMMITTER_EMAIL", @@ -76,18 +146,17 @@ fn run_autofix(pr_number: &WorkflowInput) -> NamedJob { named::job( Job::default() - .runs_on(runners::LINUX_DEFAULT) + .runs_on(runners::LINUX_SMALL) + .needs(vec![autofix_job.name.clone()]) + .cond(Expression::new(format!( + "needs.{}.outputs.has_changes == 'true'", + autofix_job.name + ))) .add_step(authenticate) .add_step(steps::checkout_repo_with_token(&token)) .add_step(checkout_pr(pr_number, &token)) - .add_step(steps::setup_cargo_config(runners::Platform::Linux)) - .add_step(steps::cache_rust_dependencies_namespace()) - .map(steps::install_linux_dependencies) - .add_step(steps::setup_pnpm()) - .add_step(run_prettier_fix()) - .add_step(run_cargo_fmt()) - .add_step(run_clippy_fix()) - .add_step(commit_and_push(&token)) - .add_step(steps::cleanup_cargo_config(runners::Platform::Linux)), + .add_step(download_patch_artifact()) + .add_step(apply_patch()) + .add_step(commit_and_push(&token)), ) } From 6f5da5e34e85654a3c5d1328b8508d83fed91535 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Tue, 16 Dec 2025 23:04:16 -0700 Subject: [PATCH 417/621] Fix NewWindow flicker by creating buffer synchronously (#44915) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #20613 Release Notes: - Fixed: New windows no longer flicker between "Open a file or project to get started" and an empty editor. --- When opening a new window (`cmd-shift-n`), the window rendered showing the empty state message before the editor was created, causing a visible flicker. **Changes:** - Modified `Workspace::new_local` to accept an optional `init` callback that executes inside the window build closure - The init callback runs within `cx.new` (the `build_root_view` closure), before `window.draw()` is called for the first render - Changed the NewWindow action handler to use `Project::create_local_buffer()` (synchronous) instead of `Editor::new_file()` (asynchronous) - Updated `open_new` to pass the editor creation callback to `new_local` - All other `new_local` call sites pass `None` to maintain existing behavior **Key Technical Detail:** The window creation sequence in `cx.open_window()` is: 1. `build_root_view` closure is called (creates workspace via `cx.new`) 2. `window.draw(cx)` is called (first render) 3. `open_window` returns The fix uses `Project::create_local_buffer()` which creates a buffer **synchronously** (returns `Entity` directly), rather than `Editor::new_file()` which is asynchronous (calls `project.create_buffer()` which returns a `Task`). The editor is created from this buffer inside the `cx.new` closure (step 1), ensuring it exists before step 2 renders the first frame. **Before:** ```rust let task = Workspace::new_local(Vec::new(), app_state, None, env, cx); cx.spawn(async move |cx| { let (workspace, _) = task.await?; // Window already drawn workspace.update(cx, |workspace, window, cx| { Editor::new_file(workspace, ...) // Async - editor not present for first render })?; }) ``` **After:** ```rust cx.open_window(options, { move |window, cx| { cx.new(|cx| { let mut workspace = Workspace::new(...); // Create buffer synchronously, then create editor if let Some(init) = init { init(&mut workspace, window, cx); // Uses create_local_buffer (sync) } workspace }) } })? ``` The editor is now part of the workspace before the window's first frame is rendered, eliminating the flicker.
Original prompt > > ---- > > *This section details on the original issue you should resolve* > > Opening a new window flickers before opening an empty buffer > ### Check for existing issues > > - [x] Completed > > ### Describe the bug / provide steps to reproduce it > > Opening a new window, with e.g. `cmd-shift-n`, flickers for a fraction of a second. The new window first shows the startup page, "Open a file or project to get started.". Then, a frame or two later, a new empty buffer opens. > > Not sure if I'm sensitive or something but these kinds of flashes can knock me out of focus/flow pretty easily. > > It'd be great to either have the empty buffer open from the first frame, or to have an option to simply not open that empty buffer when a new window is opened. > > ### Zed Version and System Specs > > Zed: v0.170.4 (Zed) > OS: macOS 14.6.1 > Memory: 36 GiB > Architecture: aarch64 > > ### If applicable, add screenshots or screencasts of the incorrect state / behavior > > https://github.com/user-attachments/assets/6d9ba791-8a02-4e13-857c-66a33eb0905b > > ### If applicable, attach your Zed.log file to this issue. > > N/A > > We should make sure that the window is created in the correct state, and not have an intermediate render before the editor opens. > > ## Comments on the Issue (you are @copilot in this section) > > > @ConradIrwin > Ugh, no. I don't believe I never noticed this before, but now I can't unsee it :s > > If you'd like to pair on this: https://cal.com/conradirwin/pairing, otherwise I'll see if I get around to it. > @ConradIrwin > Yeah... I wonder if that can be a preview tab or something. It's nice when you want it, but not so nice when you don't. > > Fixing this will also make zed-industries/zed#33334 feel much smoother. > @zelenenka > @robinplace do you maybe have an opportunity to test it with the latest stable version, 0.213.3? > >
- Fixes zed-industries/zed#23742 --- 💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: ConradIrwin <94272+ConradIrwin@users.noreply.github.com> Co-authored-by: Conrad Irwin --- crates/workspace/src/workspace.rs | 46 +++++++++++++++++++++++-------- crates/zed/src/zed.rs | 16 ++++++++++- 2 files changed, 50 insertions(+), 12 deletions(-) diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index 5947cb1703b37017bf75bfe412603332b8d5016a..516dc867ae14f7138dff0a968e210e214d0beb29 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -1627,6 +1627,7 @@ impl Workspace { app_state: Arc, requesting_window: Option>, env: Option>, + init: Option) + Send>>, cx: &mut App, ) -> Task< anyhow::Result<( @@ -1734,6 +1735,12 @@ impl Workspace { ); workspace.centered_layout = centered_layout; + + // Call init callback to add items before window renders + if let Some(init) = init { + init(&mut workspace, window, cx); + } + workspace }); })?; @@ -1785,6 +1792,12 @@ impl Workspace { cx, ); workspace.centered_layout = centered_layout; + + // Call init callback to add items before window renders + if let Some(init) = init { + init(&mut workspace, window, cx); + } + workspace }) } @@ -2350,7 +2363,7 @@ impl Workspace { Task::ready(Ok(callback(self, window, cx))) } else { let env = self.project.read(cx).cli_environment(cx); - let task = Self::new_local(Vec::new(), self.app_state.clone(), None, env, cx); + let task = Self::new_local(Vec::new(), self.app_state.clone(), None, env, None, cx); cx.spawn_in(window, async move |_vh, cx| { let (workspace, _) = task.await?; workspace.update(cx, callback) @@ -7758,7 +7771,14 @@ pub fn join_channel( // no open workspaces, make one to show the error in (blergh) let (window_handle, _) = cx .update(|cx| { - Workspace::new_local(vec![], app_state.clone(), requesting_window, None, cx) + Workspace::new_local( + vec![], + app_state.clone(), + requesting_window, + None, + None, + cx, + ) })? .await?; @@ -7824,7 +7844,7 @@ pub async fn get_any_active_workspace( // find an existing workspace to focus and show call controls let active_window = activate_any_workspace_window(&mut cx); if active_window.is_none() { - cx.update(|cx| Workspace::new_local(vec![], app_state.clone(), None, None, cx))? + cx.update(|cx| Workspace::new_local(vec![], app_state.clone(), None, None, None, cx))? .await?; } activate_any_workspace_window(&mut cx).context("could not open zed") @@ -7991,6 +8011,7 @@ pub fn open_paths( app_state.clone(), open_options.replace_window, open_options.env, + None, cx, ) })? @@ -8035,14 +8056,17 @@ pub fn open_new( cx: &mut App, init: impl FnOnce(&mut Workspace, &mut Window, &mut Context) + 'static + Send, ) -> Task> { - let task = Workspace::new_local(Vec::new(), app_state, None, open_options.env, cx); - cx.spawn(async move |cx| { - let (workspace, opened_paths) = task.await?; - workspace.update(cx, |workspace, window, cx| { - if opened_paths.is_empty() { - init(workspace, window, cx) - } - })?; + let task = Workspace::new_local( + Vec::new(), + app_state, + None, + open_options.env, + Some(Box::new(init)), + cx, + ); + cx.spawn(async move |_cx| { + let (_workspace, _opened_paths) = task.await?; + // Init callback is called synchronously during workspace creation Ok(()) }) } diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs index fc5e74a76905d1ea45fa8bad2df12e22a23122e3..d2764c5c334ba32730982fc55e80d6197de3a2aa 100644 --- a/crates/zed/src/zed.rs +++ b/crates/zed/src/zed.rs @@ -1111,7 +1111,21 @@ fn register_actions( cx, |workspace, window, cx| { cx.activate(true); - Editor::new_file(workspace, &Default::default(), window, cx) + // Create buffer synchronously to avoid flicker + let project = workspace.project().clone(); + let buffer = project.update(cx, |project, cx| { + project.create_local_buffer("", None, true, cx) + }); + let editor = cx.new(|cx| { + Editor::for_buffer(buffer, Some(project), window, cx) + }); + workspace.add_item_to_active_pane( + Box::new(editor), + None, + true, + window, + cx, + ); }, ) .detach(); From 949cbc2b185bbe0aa7a8d6429745265ee0f240ff Mon Sep 17 00:00:00 2001 From: tidely <43219534+tidely@users.noreply.github.com> Date: Wed, 17 Dec 2025 09:56:05 +0200 Subject: [PATCH 418/621] gpui: Remove intermediate allocations when reconstructing text from a `TextLayout` (#45037) Closes #ISSUE Remove some intermediate allocations when reconstructing text or wrapped text from a `TextLayout`. Currently creates a intermediate `Vec` which gets joined, when you could join an `impl Iterator` Release Notes: - N/A *or* Added/Fixed/Improved ... --- crates/gpui/src/elements/text.rs | 18 +++++++++++------- crates/markdown/src/markdown.rs | 9 ++++++--- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/crates/gpui/src/elements/text.rs b/crates/gpui/src/elements/text.rs index 914e8a286510a2ffd833db4c4d3ef85c84db073f..1b1bfd778c7bc746c67551eb31cf70f60b1485ea 100644 --- a/crates/gpui/src/elements/text.rs +++ b/crates/gpui/src/elements/text.rs @@ -6,6 +6,7 @@ use crate::{ register_tooltip_mouse_handlers, set_tooltip_on_window, }; use anyhow::Context as _; +use itertools::Itertools; use smallvec::SmallVec; use std::{ borrow::Cow, @@ -597,14 +598,14 @@ impl TextLayout { .unwrap() .lines .iter() - .map(|s| s.text.to_string()) - .collect::>() + .map(|s| &s.text) .join("\n") } /// The text for this layout (with soft-wraps as newlines) pub fn wrapped_text(&self) -> String { - let mut lines = Vec::new(); + let mut accumulator = String::new(); + for wrapped in self.0.borrow().as_ref().unwrap().lines.iter() { let mut seen = 0; for boundary in wrapped.layout.wrap_boundaries.iter() { @@ -612,13 +613,16 @@ impl TextLayout { [boundary.glyph_ix] .index; - lines.push(wrapped.text[seen..index].to_string()); + accumulator.push_str(&wrapped.text[seen..index]); + accumulator.push('\n'); seen = index; } - lines.push(wrapped.text[seen..].to_string()); + accumulator.push_str(&wrapped.text[seen..]); + accumulator.push('\n'); } - - lines.join("\n") + // Remove trailing newline + accumulator.pop(); + accumulator } } diff --git a/crates/markdown/src/markdown.rs b/crates/markdown/src/markdown.rs index 536d9fd6a2439e9b23b9f99d20a4aff425eda956..3654418e419bb58f5c9c29ac1baf7172a423156f 100644 --- a/crates/markdown/src/markdown.rs +++ b/crates/markdown/src/markdown.rs @@ -1919,7 +1919,7 @@ impl RenderedText { } fn text_for_range(&self, range: Range) -> String { - let mut ret = vec![]; + let mut accumulator = String::new(); for line in self.lines.iter() { if range.start > line.source_end { @@ -1944,9 +1944,12 @@ impl RenderedText { } .min(text.len()); - ret.push(text[start..end].to_string()); + accumulator.push_str(&text[start..end]); + accumulator.push('\n'); } - ret.join("\n") + // Remove trailing newline + accumulator.pop(); + accumulator } fn link_for_position(&self, position: Point) -> Option<&RenderedLink> { From 280864e7f260e43de186d77ad7119942f37f5562 Mon Sep 17 00:00:00 2001 From: Marco Mihai Condrache <52580954+marcocondrache@users.noreply.github.com> Date: Wed, 17 Dec 2025 08:59:27 +0100 Subject: [PATCH 419/621] remote: Support IPv6 when using SSH (#43591) Closes #33650 Release Notes: - Added support for remote connections over IPv6 --------- Signed-off-by: Marco Mihai Condrache <52580954+marcocondrache@users.noreply.github.com> --- .../recent_projects/src/remote_connections.rs | 4 +- crates/recent_projects/src/remote_servers.rs | 8 +- crates/remote/src/remote_client.rs | 6 +- crates/remote/src/transport/ssh.rs | 171 ++++++++++++++---- crates/workspace/src/persistence.rs | 20 +- 5 files changed, 159 insertions(+), 50 deletions(-) diff --git a/crates/recent_projects/src/remote_connections.rs b/crates/recent_projects/src/remote_connections.rs index be40df4d1c80c3a1dda7c3f8fdfa370bc231bbfb..1c6da9b82a9a661307fd5eec1cd647ceb6c292bb 100644 --- a/crates/recent_projects/src/remote_connections.rs +++ b/crates/recent_projects/src/remote_connections.rs @@ -52,7 +52,7 @@ impl SshSettings { pub fn fill_connection_options_from_settings(&self, options: &mut SshConnectionOptions) { for conn in self.ssh_connections() { - if conn.host == options.host + if conn.host == options.host.to_string() && conn.username == options.username && conn.port == options.port { @@ -72,7 +72,7 @@ impl SshSettings { username: Option, ) -> SshConnectionOptions { let mut options = SshConnectionOptions { - host, + host: host.into(), port, username, ..Default::default() diff --git a/crates/recent_projects/src/remote_servers.rs b/crates/recent_projects/src/remote_servers.rs index 84cc216805897d81ee8d7cbba3b0f6d8a66cbdf9..a4388c6026ab7aa6bbdfc75d025e095b5a2a6187 100644 --- a/crates/recent_projects/src/remote_servers.rs +++ b/crates/recent_projects/src/remote_servers.rs @@ -1518,7 +1518,7 @@ impl RemoteServerProjects { .ssh_connections .get_or_insert(Default::default()) .push(SshConnection { - host: SharedString::from(connection_options.host), + host: SharedString::from(connection_options.host.to_string()), username: connection_options.username, port: connection_options.port, projects: BTreeSet::new(), @@ -1983,7 +1983,7 @@ impl RemoteServerProjects { .size_full() .child(match &options { ViewServerOptionsState::Ssh { connection, .. } => SshConnectionHeader { - connection_string: connection.host.clone().into(), + connection_string: connection.host.to_string().into(), paths: Default::default(), nickname: connection.nickname.clone().map(|s| s.into()), is_wsl: false, @@ -2148,7 +2148,7 @@ impl RemoteServerProjects { window: &mut Window, cx: &mut Context, ) -> impl IntoElement { - let connection_string = SharedString::new(connection.host.clone()); + let connection_string = SharedString::new(connection.host.to_string()); v_flex() .child({ @@ -2659,7 +2659,7 @@ impl RemoteServerProjects { self.add_ssh_server( SshConnectionOptions { - host: ssh_config_host.to_string(), + host: ssh_config_host.to_string().into(), ..SshConnectionOptions::default() }, cx, diff --git a/crates/remote/src/remote_client.rs b/crates/remote/src/remote_client.rs index e8fa4fe4a3e727e823fc5912ddf3e940adf0f78f..9c6508e5f16027eb23225f0eceb1cb691f4a33c9 100644 --- a/crates/remote/src/remote_client.rs +++ b/crates/remote/src/remote_client.rs @@ -921,10 +921,12 @@ impl RemoteClient { client_cx: &mut gpui::TestAppContext, server_cx: &mut gpui::TestAppContext, ) -> (RemoteConnectionOptions, AnyProtoClient) { + use crate::transport::ssh::SshConnectionHost; + let port = client_cx .update(|cx| cx.default_global::().connections.len() as u16 + 1); let opts = RemoteConnectionOptions::Ssh(SshConnectionOptions { - host: "".to_string(), + host: SshConnectionHost::from("".to_string()), port: Some(port), ..Default::default() }); @@ -1089,7 +1091,7 @@ pub enum RemoteConnectionOptions { impl RemoteConnectionOptions { pub fn display_name(&self) -> String { match self { - RemoteConnectionOptions::Ssh(opts) => opts.host.clone(), + RemoteConnectionOptions::Ssh(opts) => opts.host.to_string(), RemoteConnectionOptions::Wsl(opts) => opts.distro_name.clone(), RemoteConnectionOptions::Docker(opts) => opts.name.clone(), } diff --git a/crates/remote/src/transport/ssh.rs b/crates/remote/src/transport/ssh.rs index c445c0565837d33dc044087fc53e6573e06ee54c..37921b88637f19b68f9625170d9d99e85b5a9bdf 100644 --- a/crates/remote/src/transport/ssh.rs +++ b/crates/remote/src/transport/ssh.rs @@ -23,6 +23,7 @@ use smol::{ process::{self, Child, Stdio}, }; use std::{ + net::IpAddr, path::{Path, PathBuf}, sync::Arc, time::Instant, @@ -47,9 +48,58 @@ pub(crate) struct SshRemoteConnection { _temp_dir: TempDir, } +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub enum SshConnectionHost { + IpAddr(IpAddr), + Hostname(String), +} + +impl SshConnectionHost { + pub fn to_bracketed_string(&self) -> String { + match self { + Self::IpAddr(IpAddr::V4(ip)) => ip.to_string(), + Self::IpAddr(IpAddr::V6(ip)) => format!("[{}]", ip), + Self::Hostname(hostname) => hostname.clone(), + } + } + + pub fn to_string(&self) -> String { + match self { + Self::IpAddr(ip) => ip.to_string(), + Self::Hostname(hostname) => hostname.clone(), + } + } +} + +impl From<&str> for SshConnectionHost { + fn from(value: &str) -> Self { + if let Ok(address) = value.parse() { + Self::IpAddr(address) + } else { + Self::Hostname(value.to_string()) + } + } +} + +impl From for SshConnectionHost { + fn from(value: String) -> Self { + if let Ok(address) = value.parse() { + Self::IpAddr(address) + } else { + Self::Hostname(value) + } + } +} + +impl Default for SshConnectionHost { + fn default() -> Self { + Self::Hostname(Default::default()) + } +} + #[derive(Debug, Default, Clone, PartialEq, Eq, Hash)] pub struct SshConnectionOptions { - pub host: String, + pub host: SshConnectionHost, pub username: Option, pub port: Option, pub password: Option, @@ -64,7 +114,7 @@ pub struct SshConnectionOptions { impl From for SshConnectionOptions { fn from(val: settings::SshConnection) -> Self { SshConnectionOptions { - host: val.host.into(), + host: val.host.to_string().into(), username: val.username, port: val.port, password: None, @@ -96,7 +146,7 @@ impl MasterProcess { askpass_script_path: &std::ffi::OsStr, additional_args: Vec, socket_path: &std::path::Path, - url: &str, + destination: &str, ) -> Result { let args = [ "-N", @@ -120,7 +170,7 @@ impl MasterProcess { master_process.arg(format!("ControlPath={}", socket_path.display())); - let process = master_process.arg(&url).spawn()?; + let process = master_process.arg(&destination).spawn()?; Ok(MasterProcess { process }) } @@ -143,7 +193,7 @@ impl MasterProcess { pub fn new( askpass_script_path: &std::ffi::OsStr, additional_args: Vec, - url: &str, + destination: &str, ) -> Result { // On Windows, `ControlMaster` and `ControlPath` are not supported: // https://github.com/PowerShell/Win32-OpenSSH/issues/405 @@ -165,7 +215,7 @@ impl MasterProcess { .env("SSH_ASKPASS_REQUIRE", "force") .env("SSH_ASKPASS", askpass_script_path) .args(additional_args) - .arg(url) + .arg(destination) .args(args); let process = master_process.spawn()?; @@ -412,7 +462,7 @@ impl SshRemoteConnection { ) -> Result { use askpass::AskPassResult; - let url = connection_options.ssh_url(); + let destination = connection_options.ssh_destination(); let temp_dir = tempfile::Builder::new() .prefix("zed-ssh-session") @@ -437,14 +487,14 @@ impl SshRemoteConnection { let mut master_process = MasterProcess::new( askpass.script_path().as_ref(), connection_options.additional_args(), - &url, + &destination, )?; #[cfg(not(target_os = "windows"))] let mut master_process = MasterProcess::new( askpass.script_path().as_ref(), connection_options.additional_args(), &socket_path, - &url, + &destination, )?; let result = select_biased! { @@ -840,7 +890,7 @@ impl SshRemoteConnection { } command.arg(src_path).arg(format!( "{}:{}", - self.socket.connection_options.scp_url(), + self.socket.connection_options.scp_destination(), dest_path_str )); command @@ -856,7 +906,7 @@ impl SshRemoteConnection { .unwrap_or_default(), ); command.arg("-b").arg("-"); - command.arg(self.socket.connection_options.scp_url()); + command.arg(self.socket.connection_options.scp_destination()); command.stdin(Stdio::piped()); command } @@ -986,7 +1036,7 @@ impl SshSocket { let separator = shell_kind.sequential_commands_separator(); let to_run = format!("cd{separator} {to_run}"); self.ssh_options(&mut command, true) - .arg(self.connection_options.ssh_url()); + .arg(self.connection_options.ssh_destination()); if !allow_pseudo_tty { command.arg("-T"); } @@ -1063,7 +1113,7 @@ impl SshSocket { "ControlMaster=no".to_string(), "-o".to_string(), format!("ControlPath={}", self.socket_path.display()), - self.connection_options.ssh_url(), + self.connection_options.ssh_destination(), ]); arguments } @@ -1071,7 +1121,7 @@ impl SshSocket { #[cfg(target_os = "windows")] fn ssh_args(&self) -> Vec { let mut arguments = self.connection_options.additional_args(); - arguments.push(self.connection_options.ssh_url()); + arguments.push(self.connection_options.ssh_destination()); arguments } @@ -1208,10 +1258,24 @@ impl SshConnectionOptions { input = rest; username = Some(u.to_string()); } - if let Some((rest, p)) = input.split_once(':') { + + // Handle port parsing, accounting for IPv6 addresses + // IPv6 addresses can be: 2001:db8::1 or [2001:db8::1]:22 + if input.starts_with('[') { + if let Some((rest, p)) = input.rsplit_once("]:") { + input = rest.strip_prefix('[').unwrap_or(rest); + port = p.parse().ok(); + } else if input.ends_with(']') { + input = input.strip_prefix('[').unwrap_or(input); + input = input.strip_suffix(']').unwrap_or(input); + } + } else if let Some((rest, p)) = input.rsplit_once(':') + && !rest.contains(":") + { input = rest; - port = p.parse().ok() + port = p.parse().ok(); } + hostname = Some(input.to_string()) } @@ -1225,7 +1289,7 @@ impl SshConnectionOptions { }; Ok(Self { - host: hostname, + host: hostname.into(), username, port, port_forwards, @@ -1237,19 +1301,16 @@ impl SshConnectionOptions { }) } - pub fn ssh_url(&self) -> String { - let mut result = String::from("ssh://"); + pub fn ssh_destination(&self) -> String { + let mut result = String::default(); if let Some(username) = &self.username { // Username might be: username1@username2@ip2 let username = urlencoding::encode(username); result.push_str(&username); result.push('@'); } - result.push_str(&self.host); - if let Some(port) = self.port { - result.push(':'); - result.push_str(&port.to_string()); - } + + result.push_str(&self.host.to_string()); result } @@ -1264,6 +1325,11 @@ impl SshConnectionOptions { args.extend(["-o".to_string(), format!("ConnectTimeout={}", timeout)]); } + if let Some(port) = self.port { + args.push("-p".to_string()); + args.push(port.to_string()); + } + if let Some(forwards) = &self.port_forwards { args.extend(forwards.iter().map(|pf| { let local_host = match &pf.local_host { @@ -1285,22 +1351,23 @@ impl SshConnectionOptions { args } - fn scp_url(&self) -> String { + fn scp_destination(&self) -> String { if let Some(username) = &self.username { - format!("{}@{}", username, self.host) + format!("{}@{}", username, self.host.to_bracketed_string()) } else { - self.host.clone() + self.host.to_string() } } pub fn connection_string(&self) -> String { - let host = if let Some(username) = &self.username { - format!("{}@{}", username, self.host) + let host = if let Some(port) = &self.port { + format!("{}:{}", self.host.to_bracketed_string(), port) } else { - self.host.clone() + self.host.to_string() }; - if let Some(port) = &self.port { - format!("{}:{}", host, port) + + if let Some(username) = &self.username { + format!("{}@{}", username, host) } else { host } @@ -1510,4 +1577,44 @@ mod tests { ] ); } + + #[test] + fn test_host_parsing() -> Result<()> { + let opts = SshConnectionOptions::parse_command_line("user@2001:db8::1")?; + assert_eq!(opts.host, "2001:db8::1".into()); + assert_eq!(opts.username, Some("user".to_string())); + assert_eq!(opts.port, None); + + let opts = SshConnectionOptions::parse_command_line("user@[2001:db8::1]:2222")?; + assert_eq!(opts.host, "2001:db8::1".into()); + assert_eq!(opts.username, Some("user".to_string())); + assert_eq!(opts.port, Some(2222)); + + let opts = SshConnectionOptions::parse_command_line("user@[2001:db8::1]")?; + assert_eq!(opts.host, "2001:db8::1".into()); + assert_eq!(opts.username, Some("user".to_string())); + assert_eq!(opts.port, None); + + let opts = SshConnectionOptions::parse_command_line("2001:db8::1")?; + assert_eq!(opts.host, "2001:db8::1".into()); + assert_eq!(opts.username, None); + assert_eq!(opts.port, None); + + let opts = SshConnectionOptions::parse_command_line("[2001:db8::1]:2222")?; + assert_eq!(opts.host, "2001:db8::1".into()); + assert_eq!(opts.username, None); + assert_eq!(opts.port, Some(2222)); + + let opts = SshConnectionOptions::parse_command_line("user@example.com:2222")?; + assert_eq!(opts.host, "example.com".into()); + assert_eq!(opts.username, Some("user".to_string())); + assert_eq!(opts.port, Some(2222)); + + let opts = SshConnectionOptions::parse_command_line("user@192.168.1.1:2222")?; + assert_eq!(opts.host, "192.168.1.1".into()); + assert_eq!(opts.username, Some("user".to_string())); + assert_eq!(opts.port, Some(2222)); + + Ok(()) + } } diff --git a/crates/workspace/src/persistence.rs b/crates/workspace/src/persistence.rs index 4a8aab364db3ec37f7f089b8dc3df4ca1114ee28..a992a9e1a20d1346a0c201afd72bb51327f00381 100644 --- a/crates/workspace/src/persistence.rs +++ b/crates/workspace/src/persistence.rs @@ -1273,7 +1273,7 @@ impl WorkspaceDb { match options { RemoteConnectionOptions::Ssh(options) => { kind = RemoteConnectionKind::Ssh; - host = Some(options.host); + host = Some(options.host.to_string()); port = options.port; user = options.username; } @@ -1486,7 +1486,7 @@ impl WorkspaceDb { user: user, })), RemoteConnectionKind::Ssh => Some(RemoteConnectionOptions::Ssh(SshConnectionOptions { - host: host?, + host: host?.into(), port, username: user, ..Default::default() @@ -2757,7 +2757,7 @@ mod tests { let connection_id = db .get_or_create_remote_connection(RemoteConnectionOptions::Ssh(SshConnectionOptions { - host: "my-host".to_string(), + host: "my-host".into(), port: Some(1234), ..Default::default() })) @@ -2946,7 +2946,7 @@ mod tests { .into_iter() .map(|(host, user)| async { let options = RemoteConnectionOptions::Ssh(SshConnectionOptions { - host: host.to_string(), + host: host.into(), username: Some(user.to_string()), ..Default::default() }); @@ -3037,7 +3037,7 @@ mod tests { let connection_id = db .get_or_create_remote_connection(RemoteConnectionOptions::Ssh(SshConnectionOptions { - host: host.clone(), + host: host.clone().into(), port, username: user.clone(), ..Default::default() @@ -3048,7 +3048,7 @@ mod tests { // Test that calling the function again with the same parameters returns the same project let same_connection = db .get_or_create_remote_connection(RemoteConnectionOptions::Ssh(SshConnectionOptions { - host: host.clone(), + host: host.clone().into(), port, username: user.clone(), ..Default::default() @@ -3065,7 +3065,7 @@ mod tests { let different_connection = db .get_or_create_remote_connection(RemoteConnectionOptions::Ssh(SshConnectionOptions { - host: host2.clone(), + host: host2.clone().into(), port: port2, username: user2.clone(), ..Default::default() @@ -3084,7 +3084,7 @@ mod tests { let connection_id = db .get_or_create_remote_connection(RemoteConnectionOptions::Ssh(SshConnectionOptions { - host: host.clone(), + host: host.clone().into(), port, username: None, ..Default::default() @@ -3094,7 +3094,7 @@ mod tests { let same_connection_id = db .get_or_create_remote_connection(RemoteConnectionOptions::Ssh(SshConnectionOptions { - host: host.clone(), + host: host.clone().into(), port, username: user.clone(), ..Default::default() @@ -3124,7 +3124,7 @@ mod tests { ids.push( db.get_or_create_remote_connection(RemoteConnectionOptions::Ssh( SshConnectionOptions { - host: host.clone(), + host: host.clone().into(), port: *port, username: user.clone(), ..Default::default() From edcde6d90c4a82a3ab64dda91e56bafaded28bc5 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Wed, 17 Dec 2025 09:28:59 +0100 Subject: [PATCH 420/621] Fix semantic merge conflict (#45078) Release Notes: - N/A *or* Added/Fixed/Improved ... --- crates/project/src/trusted_worktrees.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/project/src/trusted_worktrees.rs b/crates/project/src/trusted_worktrees.rs index d9f5d4a7a43d8cb8b8220f4d3de8ca35d366a8f5..9f849ceaf1db62c1a88e269565e95bc97bc56011 100644 --- a/crates/project/src/trusted_worktrees.rs +++ b/crates/project/src/trusted_worktrees.rs @@ -223,7 +223,7 @@ impl From for RemoteHostLocation { let (user_name, host_name) = match options { RemoteConnectionOptions::Ssh(ssh) => ( ssh.username.map(SharedString::new), - SharedString::new(ssh.host), + SharedString::new(ssh.host.to_string()), ), RemoteConnectionOptions::Wsl(wsl) => ( wsl.user.map(SharedString::new), From 25b89dd8e91dde4e9525bae81aec2994613366f9 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Wed, 17 Dec 2025 09:43:34 +0100 Subject: [PATCH 421/621] workspace: Don't debug display paths to users in trust popup (#45079) On windows this will render two backslashes otherwise Release Notes: - N/A *or* Added/Fixed/Improved ... --- crates/workspace/src/security_modal.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/workspace/src/security_modal.rs b/crates/workspace/src/security_modal.rs index 44242a3588017aabf117300310dd10a4a28b292f..1b5509d4d64e5b1377c9675fb49d2981e8173668 100644 --- a/crates/workspace/src/security_modal.rs +++ b/crates/workspace/src/security_modal.rs @@ -265,8 +265,8 @@ impl SecurityModal { } } 1 => Some(Cow::Owned(format!( - "Trust all projects in the {:?} folder", - self.shorten_path(available_parents[0]) + "Trust all projects in the {:} folder", + self.shorten_path(available_parents[0]).display() ))), _ => Some(Cow::Borrowed("Trust all projects in the parent folders")), } From 79e2e520128e4d08f159e1cec9d01d5c387aafad Mon Sep 17 00:00:00 2001 From: Mayank Verma Date: Wed, 17 Dec 2025 14:29:29 +0530 Subject: [PATCH 422/621] project: Clear stale settings when switching remote projects (#45021) Closes #44898 Release Notes: - Fixed stale settings persisting when switching remote projects --- crates/project/src/project.rs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index bbf91eb3c18a53f32f48f1a044c991bf5cfd9fdf..9152096508b76d34fe3b2209cba94b4755b6ac67 100644 --- a/crates/project/src/project.rs +++ b/crates/project/src/project.rs @@ -2483,13 +2483,11 @@ impl Project { cx: &mut Context, ) -> Result<()> { cx.update_global::(|store, cx| { - self.worktree_store.update(cx, |worktree_store, cx| { - for worktree in worktree_store.worktrees() { - store - .clear_local_settings(worktree.read(cx).id(), cx) - .log_err(); - } - }); + for worktree_metadata in &message.worktrees { + store + .clear_local_settings(WorktreeId::from_proto(worktree_metadata.id), cx) + .log_err(); + } }); self.join_project_response_message_id = message_id; @@ -4729,6 +4727,14 @@ impl Project { this.update(&mut cx, |this, cx| { // Don't handle messages that were sent before the response to us joining the project if envelope.message_id > this.join_project_response_message_id { + cx.update_global::(|store, cx| { + for worktree_metadata in &envelope.payload.worktrees { + store + .clear_local_settings(WorktreeId::from_proto(worktree_metadata.id), cx) + .log_err(); + } + }); + this.set_worktrees_from_proto(envelope.payload.worktrees, cx)?; } Ok(()) From c5b3b06b94f455383e736d163b181fc37eda7207 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Wed, 17 Dec 2025 10:04:10 +0100 Subject: [PATCH 423/621] python: Fetch non pre-release versions of `ty` (#45080) 0.0.2 is not a pre-release artifact unlike the previous one, so our version fetch ignored it. Fixes https://github.com/zed-industries/zed/issues/45061 Release Notes: - N/A *or* Added/Fixed/Improved ... --- crates/languages/src/python.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/languages/src/python.rs b/crates/languages/src/python.rs index fbdeb59b7f15a22d4f4097a3b0e60b4aeb9bf202..b987d059ccaf53126e427a36c4f598817acd63de 100644 --- a/crates/languages/src/python.rs +++ b/crates/languages/src/python.rs @@ -280,7 +280,7 @@ impl LspInstaller for TyLspAdapter { _: &mut AsyncApp, ) -> Result { let release = - latest_github_release("astral-sh/ty", true, true, delegate.http_client()).await?; + latest_github_release("astral-sh/ty", true, false, delegate.http_client()).await?; let (_, asset_name) = Self::build_asset_name()?; let asset = release .assets From 637ff342545523e66f2e2964e6c16fdeaa227dee Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Wed, 17 Dec 2025 10:17:45 +0100 Subject: [PATCH 424/621] Fix editor hang when positioned above viewport (#45077) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes the hang introduced in #44995 (which was reverted in #45011) and re-enables the optimization. ## Background PR #44995 introduced an optimization to skip rendering lines that are clipped by parent containers (e.g., when a large AutoHeight editor is inside a scrollable List). This significantly improved performance for large diffs in the Agent Panel. However, #45011 reverted this change because it caused the main thread to hang for 100+ seconds in certain scenarios, requiring a force quit to recover. ## Root Cause The original analysis in #45011 suggested that visible_bounds wasn’t being intersected properly, but that was incorrect—the intersection via with_content_mask works correctly. The actual bug: when an editor is positioned above the visible viewport (e.g., scrolled past in a List), the clipping calculation produces a start_row that exceeds max_row: 1. Editor’s bounds.origin.y becomes very negative (e.g., -10000px) 2. After intersection, visible_bounds.origin.y is at the viewport top (e.g., 0) 3. clipped_top_in_lines = (0 - (-10000)) / line_height = huge number 4. start_row = huge number, but end_row is clamped to max_row 5. This creates an invalid range where start_row > end_row This caused two different failures depending on build mode: - Debug mode: Panic from subtraction overflow in Range::len() - Release mode: Integer wraparound causing blocks_in_range to enter an infinite loop (the 100+ second hang) ## Fix Simply clamp start_row to max_row, ensuring the row range is always valid: ```rs let start_row = cmp::min( DisplayRow((scroll_position.y + clipped_top_in_lines).floor() as u32), max_row, ); ``` ## Testing Added a regression test that draws an editor at y=-10000 to simulate an editor that’s been scrolled past in a List. This would panic in debug mode (and hang in release mode) before the fix. Release Notes: - Improved agent panel performance when rendering large diffs. --- crates/editor/src/editor_tests.rs | 35 +++++++++++++++++++++++++++++++ crates/editor/src/element.rs | 19 +++++++++++++++-- crates/editor/src/test.rs | 8 +++---- 3 files changed, 55 insertions(+), 7 deletions(-) diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rs index 84d3837d1cb516b6f70f6998ce588beed9bd9804..be72cd347beda25b92525842d1f94e5ae18fa15f 100644 --- a/crates/editor/src/editor_tests.rs +++ b/crates/editor/src/editor_tests.rs @@ -29530,3 +29530,38 @@ async fn test_local_worktree_trust(cx: &mut TestAppContext) { trusted_worktrees.update(cx, |store, cx| store.can_trust(worktree_id, cx)); assert!(can_trust_after, "worktree should be trusted after trust()"); } + +#[gpui::test] +fn test_editor_rendering_when_positioned_above_viewport(cx: &mut TestAppContext) { + // This test reproduces a bug where drawing an editor at a position above the viewport + // (simulating what happens when an AutoHeight editor inside a List is scrolled past) + // causes an infinite loop in blocks_in_range. + // + // The issue: when the editor's bounds.origin.y is very negative (above the viewport), + // the content mask intersection produces visible_bounds with origin at the viewport top. + // This makes clipped_top_in_lines very large, causing start_row to exceed max_row. + // When blocks_in_range is called with start_row > max_row, the cursor seeks to the end + // but the while loop after seek never terminates because cursor.next() is a no-op at end. + init_test(cx, |_| {}); + + let window = cx.add_window(|_, _| gpui::Empty); + let mut cx = VisualTestContext::from_window(*window, cx); + + let buffer = cx.update(|_, cx| MultiBuffer::build_simple("a\nb\nc\nd\ne\nf\ng\nh\ni\nj\n", cx)); + let editor = cx.new_window_entity(|window, cx| build_editor(buffer, window, cx)); + + // Simulate a small viewport (500x500 pixels at origin 0,0) + cx.simulate_resize(gpui::size(px(500.), px(500.))); + + // Draw the editor at a very negative Y position, simulating an editor that's been + // scrolled way above the visible viewport (like in a List that has scrolled past it). + // The editor is 3000px tall but positioned at y=-10000, so it's entirely above the viewport. + // This should NOT hang - it should just render nothing. + cx.draw( + gpui::point(px(0.), px(-10000.)), + gpui::size(px(500.), px(3000.)), + |_, _| editor.clone(), + ); + + // If we get here without hanging, the test passes +} diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index 8de660275ba9b455aec610568c41347888654495..85b32324a1c1cc7fb84162fb120e8ef0e4e8b599 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -9164,6 +9164,15 @@ impl Element for EditorElement { let height_in_lines = f64::from(bounds.size.height / line_height); let max_row = snapshot.max_point().row().as_f64(); + // Calculate how much of the editor is clipped by parent containers (e.g., List). + // This allows us to only render lines that are actually visible, which is + // critical for performance when large AutoHeight editors are inside Lists. + let visible_bounds = window.content_mask().bounds; + let clipped_top = (visible_bounds.origin.y - bounds.origin.y).max(px(0.)); + let clipped_top_in_lines = f64::from(clipped_top / line_height); + let visible_height_in_lines = + f64::from(visible_bounds.size.height / line_height); + // The max scroll position for the top of the window let max_scroll_top = if matches!( snapshot.mode, @@ -9220,10 +9229,16 @@ impl Element for EditorElement { let mut scroll_position = snapshot.scroll_position(); // The scroll position is a fractional point, the whole number of which represents // the top of the window in terms of display rows. - let start_row = DisplayRow(scroll_position.y as u32); + // We add clipped_top_in_lines to skip rows that are clipped by parent containers, + // but we don't modify scroll_position itself since the parent handles positioning. let max_row = snapshot.max_point().row(); + let start_row = cmp::min( + DisplayRow((scroll_position.y + clipped_top_in_lines).floor() as u32), + max_row, + ); let end_row = cmp::min( - (scroll_position.y + height_in_lines).ceil() as u32, + (scroll_position.y + clipped_top_in_lines + visible_height_in_lines).ceil() + as u32, max_row.next_row().0, ); let end_row = DisplayRow(end_row); diff --git a/crates/editor/src/test.rs b/crates/editor/src/test.rs index 5a0652bdd199a638f92234b1d50232071db18e07..1cc619385446502db6a3a0dceb6e70fa4b4e8416 100644 --- a/crates/editor/src/test.rs +++ b/crates/editor/src/test.rs @@ -176,11 +176,9 @@ pub fn block_content_for_tests( } pub fn editor_content_with_blocks(editor: &Entity, cx: &mut VisualTestContext) -> String { - cx.draw( - gpui::Point::default(), - size(px(3000.0), px(3000.0)), - |_, _| editor.clone(), - ); + let draw_size = size(px(3000.0), px(3000.0)); + cx.simulate_resize(draw_size); + cx.draw(gpui::Point::default(), draw_size, |_, _| editor.clone()); let (snapshot, mut lines, blocks) = editor.update_in(cx, |editor, window, cx| { let snapshot = editor.snapshot(window, cx); let text = editor.display_text(cx); From a7bab0b0506845a9d67d92319b513a16cd7647cd Mon Sep 17 00:00:00 2001 From: Jeff Brennan <42007840+jeffbrennan@users.noreply.github.com> Date: Wed, 17 Dec 2025 05:10:39 -0500 Subject: [PATCH 425/621] language: Fix auto-indentation for Python code blocks in Markdown (#43853) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #43722 Release Notes: - Fixed an issue where auto-indentation didn’t work correctly for Python code blocks in Markdown. --------- Co-authored-by: Smit Barmase --- crates/editor/src/editor_tests.rs | 42 +++++++++++++++++++++++++++++++ crates/language/src/buffer.rs | 35 ++++++++++++++++++-------- 2 files changed, 67 insertions(+), 10 deletions(-) diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rs index be72cd347beda25b92525842d1f94e5ae18fa15f..bac3d12638a23bc54f4a981b874da35b77894fff 100644 --- a/crates/editor/src/editor_tests.rs +++ b/crates/editor/src/editor_tests.rs @@ -25972,6 +25972,48 @@ async fn test_indent_on_newline_for_python(cx: &mut TestAppContext) { "}); } +#[gpui::test] +async fn test_python_indent_in_markdown(cx: &mut TestAppContext) { + init_test(cx, |_| {}); + + let language_registry = Arc::new(language::LanguageRegistry::test(cx.executor())); + let python_lang = languages::language("python", tree_sitter_python::LANGUAGE.into()); + language_registry.add(markdown_lang()); + language_registry.add(python_lang); + + let mut cx = EditorTestContext::new(cx).await; + cx.update_buffer(|buffer, cx| { + buffer.set_language_registry(language_registry); + buffer.set_language(Some(markdown_lang()), cx); + }); + + // Test that `else:` correctly outdents to match `if:` inside the Python code block + cx.set_state(indoc! {" + # Heading + + ```python + def main(): + if condition: + pass + ˇ + ``` + "}); + cx.update_editor(|editor, window, cx| { + editor.handle_input("else:", window, cx); + }); + cx.run_until_parked(); + cx.assert_editor_state(indoc! {" + # Heading + + ```python + def main(): + if condition: + pass + else:ˇ + ``` + "}); +} + #[gpui::test] async fn test_tab_in_leading_whitespace_auto_indents_for_bash(cx: &mut TestAppContext) { init_test(cx, |_| {}); diff --git a/crates/language/src/buffer.rs b/crates/language/src/buffer.rs index 2a9b4ea1df4fc0b4772586f0e51016cdd1882722..39003773f83718c6c61d4cfda55b9528f7c6eb2a 100644 --- a/crates/language/src/buffer.rs +++ b/crates/language/src/buffer.rs @@ -3216,6 +3216,7 @@ impl BufferSnapshot { struct StartPosition { start: Point, suffix: SharedString, + language: Arc, } // Find the suggested indentation ranges based on the syntax tree. @@ -3259,6 +3260,7 @@ impl BufferSnapshot { start_positions.push(StartPosition { start: Point::from_ts_point(capture.node.start_position()), suffix: suffix.clone(), + language: mat.language.clone(), }); } } @@ -3319,7 +3321,7 @@ impl BufferSnapshot { // Find the suggested indentation increases and decreased based on regexes. let mut regex_outdent_map = HashMap::default(); - let mut last_seen_suffix: HashMap> = HashMap::default(); + let mut last_seen_suffix: HashMap> = HashMap::default(); let mut start_positions_iter = start_positions.iter().peekable(); let mut indent_change_rows = Vec::<(u32, Ordering)>::new(); @@ -3327,14 +3329,21 @@ impl BufferSnapshot { Point::new(prev_non_blank_row.unwrap_or(row_range.start), 0) ..Point::new(row_range.end, 0), |row, line| { - if config + let indent_len = self.indent_size_for_line(row).len; + let row_language = self.language_at(Point::new(row, indent_len)).cloned(); + let row_language_config = row_language + .as_ref() + .map(|lang| lang.config()) + .unwrap_or(config); + + if row_language_config .decrease_indent_pattern .as_ref() .is_some_and(|regex| regex.is_match(line)) { indent_change_rows.push((row, Ordering::Less)); } - if config + if row_language_config .increase_indent_pattern .as_ref() .is_some_and(|regex| regex.is_match(line)) @@ -3343,16 +3352,16 @@ impl BufferSnapshot { } while let Some(pos) = start_positions_iter.peek() { if pos.start.row < row { - let pos = start_positions_iter.next().unwrap(); + let pos = start_positions_iter.next().unwrap().clone(); last_seen_suffix .entry(pos.suffix.to_string()) .or_default() - .push(pos.start); + .push(pos); } else { break; } } - for rule in &config.decrease_indent_patterns { + for rule in &row_language_config.decrease_indent_patterns { if rule.pattern.as_ref().is_some_and(|r| r.is_match(line)) { let row_start_column = self.indent_size_for_line(row).len; let basis_row = rule @@ -3360,10 +3369,16 @@ impl BufferSnapshot { .iter() .filter_map(|valid_suffix| last_seen_suffix.get(valid_suffix)) .flatten() - .filter(|start_point| start_point.column <= row_start_column) - .max_by_key(|start_point| start_point.row); - if let Some(outdent_to_row) = basis_row { - regex_outdent_map.insert(row, outdent_to_row.row); + .filter(|pos| { + row_language + .as_ref() + .or(self.language.as_ref()) + .is_some_and(|lang| Arc::ptr_eq(lang, &pos.language)) + }) + .filter(|pos| pos.start.column <= row_start_column) + .max_by_key(|pos| pos.start.row); + if let Some(outdent_to) = basis_row { + regex_outdent_map.insert(row, outdent_to.start.row); } break; } From 93246163c677d226e184606f3782f54edccc7fc2 Mon Sep 17 00:00:00 2001 From: Anthony Eid <56899983+Anthony-Eid@users.noreply.github.com> Date: Wed, 17 Dec 2025 05:20:43 -0500 Subject: [PATCH 426/621] git: Fix deletion icon button in branch list deleting the wrong branch (#45087) Closes #45033 This bug happened because the deletion icon would use the selected entry index to choose what branch to delete. This works for all cases except when hovering on an entry, so the fix was passing in the entry index to the deletion button on_click handler. I also disabled the deletion button from working if a branch is HEAD, because it's an illegal operation to delete a branch a user is currently on. Finally, I made WeakEntity a non-optional field on `BranchList` because a workspace should always be present, and it's used to show toast notifications when a git operation fails. The popover view wouldn't have a workspace before, so users wouldn't get error messages when a git operation failed in that view. Release Notes: - git: Fix bug where branch list deletion button would delete the wrong branch --- crates/git_ui/src/branch_picker.rs | 139 ++++++++++++++++------------- crates/git_ui/src/commit_modal.rs | 11 ++- crates/git_ui/src/git_panel.rs | 16 +++- 3 files changed, 101 insertions(+), 65 deletions(-) diff --git a/crates/git_ui/src/branch_picker.rs b/crates/git_ui/src/branch_picker.rs index cbf3fea72a9937a0ab882f9ccca2c4274afdf0e2..7395f1588fececcf4f374ec0e66cdac6024656d7 100644 --- a/crates/git_ui/src/branch_picker.rs +++ b/crates/git_ui/src/branch_picker.rs @@ -72,25 +72,19 @@ pub fn open( let repository = workspace.project().read(cx).active_repository(cx); let style = BranchListStyle::Modal; workspace.toggle_modal(window, cx, |window, cx| { - BranchList::new( - Some(workspace_handle), - repository, - style, - rems(34.), - window, - cx, - ) + BranchList::new(workspace_handle, repository, style, rems(34.), window, cx) }) } pub fn popover( + workspace: WeakEntity, repository: Option>, window: &mut Window, cx: &mut App, ) -> Entity { cx.new(|cx| { let list = BranchList::new( - None, + workspace, repository, BranchListStyle::Popover, rems(20.), @@ -117,7 +111,7 @@ pub struct BranchList { impl BranchList { fn new( - workspace: Option>, + workspace: WeakEntity, repository: Option>, style: BranchListStyle, width: Rems, @@ -332,7 +326,7 @@ impl BranchFilter { } pub struct BranchListDelegate { - workspace: Option>, + workspace: WeakEntity, matches: Vec, all_branches: Option>, default_branch: Option, @@ -360,7 +354,7 @@ enum PickerState { impl BranchListDelegate { fn new( - workspace: Option>, + workspace: WeakEntity, repo: Option>, style: BranchListStyle, cx: &mut Context, @@ -464,7 +458,7 @@ impl BranchListDelegate { log::error!("Failed to delete branch: {}", e); } - if let Some(workspace) = workspace.and_then(|w| w.upgrade()) { + if let Some(workspace) = workspace.upgrade() { cx.update(|_window, cx| { if is_remote { show_error_toast( @@ -880,19 +874,21 @@ impl PickerDelegate for BranchListDelegate { Entry::NewUrl { .. } | Entry::NewBranch { .. } | Entry::NewRemoteName { .. } ); - let delete_branch_button = IconButton::new("delete", IconName::Trash) - .tooltip(move |_, cx| { - Tooltip::for_action_in( - "Delete Branch", - &branch_picker::DeleteBranch, - &focus_handle, - cx, - ) - }) - .on_click(cx.listener(|this, _, window, cx| { - let selected_idx = this.delegate.selected_index(); - this.delegate.delete_at(selected_idx, window, cx); - })); + let deleted_branch_icon = |entry_ix: usize, is_head_branch: bool| { + IconButton::new(("delete", entry_ix), IconName::Trash) + .tooltip(move |_, cx| { + Tooltip::for_action_in( + "Delete Branch", + &branch_picker::DeleteBranch, + &focus_handle, + cx, + ) + }) + .disabled(is_head_branch) + .on_click(cx.listener(move |this, _, window, cx| { + this.delegate.delete_at(entry_ix, window, cx); + })) + }; let create_from_default_button = self.default_branch.as_ref().map(|default_branch| { let tooltip_label: SharedString = format!("Create New From: {default_branch}").into(); @@ -1008,10 +1004,12 @@ impl PickerDelegate for BranchListDelegate { self.editor_position() == PickerEditorPosition::End && !is_new_items, |this| { this.map(|this| { + let is_head_branch = + entry.as_branch().is_some_and(|branch| branch.is_head); if self.selected_index() == ix { - this.end_slot(delete_branch_button) + this.end_slot(deleted_branch_icon(ix, is_head_branch)) } else { - this.end_hover_slot(delete_branch_button) + this.end_hover_slot(deleted_branch_icon(ix, is_head_branch)) } }) }, @@ -1236,7 +1234,7 @@ mod tests { use super::*; use git::repository::{CommitSummary, Remote}; - use gpui::{TestAppContext, VisualTestContext}; + use gpui::{AppContext, TestAppContext, VisualTestContext}; use project::{FakeFs, Project}; use rand::{Rng, rngs::StdRng}; use serde_json::json; @@ -1285,35 +1283,47 @@ mod tests { ] } - fn init_branch_list_test( + async fn init_branch_list_test( repository: Option>, branches: Vec, cx: &mut TestAppContext, ) -> (Entity, VisualTestContext) { - let window = cx.add_window(|window, cx| { - let mut delegate = - BranchListDelegate::new(None, repository, BranchListStyle::Modal, cx); - delegate.all_branches = Some(branches); - let picker = cx.new(|cx| Picker::uniform_list(delegate, window, cx)); - let picker_focus_handle = picker.focus_handle(cx); - picker.update(cx, |picker, _| { - picker.delegate.focus_handle = picker_focus_handle.clone(); - }); + let fs = FakeFs::new(cx.executor()); + let project = Project::test(fs, [], cx).await; - let _subscription = cx.subscribe(&picker, |_, _, _, cx| { - cx.emit(DismissEvent); - }); + let workspace = cx.add_window(|window, cx| Workspace::test_new(project, window, cx)); - BranchList { - picker, - picker_focus_handle, - width: rems(34.), - _subscription, - } - }); + let branch_list = workspace + .update(cx, |workspace, window, cx| { + cx.new(|cx| { + let mut delegate = BranchListDelegate::new( + workspace.weak_handle(), + repository, + BranchListStyle::Modal, + cx, + ); + delegate.all_branches = Some(branches); + let picker = cx.new(|cx| Picker::uniform_list(delegate, window, cx)); + let picker_focus_handle = picker.focus_handle(cx); + picker.update(cx, |picker, _| { + picker.delegate.focus_handle = picker_focus_handle.clone(); + }); + + let _subscription = cx.subscribe(&picker, |_, _, _, cx| { + cx.emit(DismissEvent); + }); - let branch_list = window.root(cx).unwrap(); - let cx = VisualTestContext::from_window(*window, cx); + BranchList { + picker, + picker_focus_handle, + width: rems(34.), + _subscription, + } + }) + }) + .unwrap(); + + let cx = VisualTestContext::from_window(*workspace, cx); (branch_list, cx) } @@ -1349,7 +1359,7 @@ mod tests { init_test(cx); let branches = create_test_branches(); - let (branch_list, mut ctx) = init_branch_list_test(None, branches, cx); + let (branch_list, mut ctx) = init_branch_list_test(None, branches, cx).await; let cx = &mut ctx; branch_list @@ -1425,7 +1435,7 @@ mod tests { .await; cx.run_until_parked(); - let (branch_list, mut ctx) = init_branch_list_test(repository.into(), branches, cx); + let (branch_list, mut ctx) = init_branch_list_test(repository.into(), branches, cx).await; let cx = &mut ctx; update_branch_list_matches_with_empty_query(&branch_list, cx).await; @@ -1490,7 +1500,7 @@ mod tests { .await; cx.run_until_parked(); - let (branch_list, mut ctx) = init_branch_list_test(repository.into(), branches, cx); + let (branch_list, mut ctx) = init_branch_list_test(repository.into(), branches, cx).await; let cx = &mut ctx; // Enable remote filter branch_list.update(cx, |branch_list, cx| { @@ -1548,7 +1558,7 @@ mod tests { create_test_branch("develop", false, None, Some(700)), ]; - let (branch_list, mut ctx) = init_branch_list_test(None, branches, cx); + let (branch_list, mut ctx) = init_branch_list_test(None, branches, cx).await; let cx = &mut ctx; update_branch_list_matches_with_empty_query(&branch_list, cx).await; @@ -1658,7 +1668,8 @@ mod tests { create_test_branch(FEATURE_BRANCH, false, None, Some(900)), ]; - let (branch_list, mut ctx) = init_branch_list_test(repository.into(), branches, test_cx); + let (branch_list, mut ctx) = + init_branch_list_test(repository.into(), branches, test_cx).await; let cx = &mut ctx; branch_list @@ -1717,7 +1728,7 @@ mod tests { let repository = init_fake_repository(cx).await; let branches = vec![create_test_branch("main", true, None, Some(1000))]; - let (branch_list, mut ctx) = init_branch_list_test(repository.into(), branches, cx); + let (branch_list, mut ctx) = init_branch_list_test(repository.into(), branches, cx).await; let cx = &mut ctx; branch_list @@ -1795,7 +1806,7 @@ mod tests { init_test(cx); let branches = vec![create_test_branch("main_branch", true, None, Some(1000))]; - let (branch_list, mut ctx) = init_branch_list_test(None, branches, cx); + let (branch_list, mut ctx) = init_branch_list_test(None, branches, cx).await; let cx = &mut ctx; branch_list @@ -1858,7 +1869,7 @@ mod tests { init_test(cx); let branches = vec![create_test_branch("main", true, None, Some(1000))]; - let (branch_list, mut ctx) = init_branch_list_test(None, branches, cx); + let (branch_list, mut ctx) = init_branch_list_test(None, branches, cx).await; let cx = &mut ctx; let subscription = cx.update(|_, cx| { @@ -1870,6 +1881,11 @@ mod tests { branch_list .update_in(cx, |branch_list, window, cx| { window.focus(&branch_list.picker_focus_handle); + assert!( + branch_list.picker_focus_handle.is_focused(window), + "Branch picker should be focused when selecting an entry" + ); + branch_list.picker.update(cx, |picker, cx| { picker .delegate @@ -1881,6 +1897,9 @@ mod tests { cx.run_until_parked(); branch_list.update_in(cx, |branch_list, window, cx| { + // Re-focus the picker since workspace initialization during run_until_parked + window.focus(&branch_list.picker_focus_handle); + branch_list.picker.update(cx, |picker, cx| { let last_match = picker.delegate.matches.last().unwrap(); assert!(last_match.is_new_url()); @@ -1914,7 +1933,7 @@ mod tests { .map(|i| create_test_branch(&format!("branch-{:02}", i), i == 0, None, Some(i * 100))) .collect(); - let (branch_list, mut ctx) = init_branch_list_test(None, branches, cx); + let (branch_list, mut ctx) = init_branch_list_test(None, branches, cx).await; let cx = &mut ctx; update_branch_list_matches_with_empty_query(&branch_list, cx).await; diff --git a/crates/git_ui/src/commit_modal.rs b/crates/git_ui/src/commit_modal.rs index 822b2c8385c2d573ceb2dc2872a685c47ff51379..291a96f47590b145b5c190150af54bd3d43c2fff 100644 --- a/crates/git_ui/src/commit_modal.rs +++ b/crates/git_ui/src/commit_modal.rs @@ -337,6 +337,7 @@ impl CommitModal { active_repo, is_amend_pending, is_signoff_enabled, + workspace, ) = self.git_panel.update(cx, |git_panel, cx| { let (can_commit, tooltip) = git_panel.configure_commit_button(cx); let title = git_panel.commit_button_title(); @@ -354,6 +355,7 @@ impl CommitModal { active_repo, is_amend_pending, is_signoff_enabled, + git_panel.workspace.clone(), ) }); @@ -375,7 +377,14 @@ impl CommitModal { .style(ButtonStyle::Transparent); let branch_picker = PopoverMenu::new("popover-button") - .menu(move |window, cx| Some(branch_picker::popover(active_repo.clone(), window, cx))) + .menu(move |window, cx| { + Some(branch_picker::popover( + workspace.clone(), + active_repo.clone(), + window, + cx, + )) + }) .with_handle(self.branch_list_handle.clone()) .trigger_with_tooltip( branch_picker_button, diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs index 8b32a79311f1f52036d8e54d182139d45bf64d10..1426ed1e65412da5cb8be22e7592e5a42917b367 100644 --- a/crates/git_ui/src/git_panel.rs +++ b/crates/git_ui/src/git_panel.rs @@ -594,7 +594,7 @@ pub struct GitPanel { tracked_staged_count: usize, update_visible_entries_task: Task<()>, width: Option, - workspace: WeakEntity, + pub(crate) workspace: WeakEntity, context_menu: Option<(Entity, Point, Subscription)>, modal_open: bool, show_placeholders: bool, @@ -5617,10 +5617,14 @@ impl RenderOnce for PanelRepoFooter { .as_ref() .map(|panel| panel.read(cx).project.clone()); - let repo = self + let (workspace, repo) = self .git_panel .as_ref() - .and_then(|panel| panel.read(cx).active_repository.clone()); + .map(|panel| { + let panel = panel.read(cx); + (panel.workspace.clone(), panel.active_repository.clone()) + }) + .unzip(); let single_repo = project .as_ref() @@ -5708,7 +5712,11 @@ impl RenderOnce for PanelRepoFooter { }); let branch_selector = PopoverMenu::new("popover-button") - .menu(move |window, cx| Some(branch_picker::popover(repo.clone(), window, cx))) + .menu(move |window, cx| { + let workspace = workspace.clone()?; + let repo = repo.clone().flatten(); + Some(branch_picker::popover(workspace, repo, window, cx)) + }) .trigger_with_tooltip( branch_selector_button, Tooltip::for_action_title("Switch Branch", &zed_actions::git::Switch), From f5ba029313556c28ec4c80f376f82900d8a88fbc Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Wed, 17 Dec 2025 11:31:18 +0100 Subject: [PATCH 427/621] remote: Implement client side connection support for windows remotes (#45084) Obviously this doesn't do too much without having an actual windows server binary for the remote side, but it does at least improve the error message as right now we will complain about `uname` not being a valid powershell command. Release Notes: - N/A *or* Added/Fixed/Improved ... --- .../recent_projects/src/remote_connections.rs | 8 +- crates/remote/src/remote.rs | 5 +- crates/remote/src/remote_client.rs | 55 +++++- crates/remote/src/transport.rs | 68 ++++--- crates/remote/src/transport/docker.rs | 14 +- crates/remote/src/transport/ssh.rs | 182 ++++++++++++++---- crates/remote/src/transport/wsl.rs | 7 +- 7 files changed, 254 insertions(+), 85 deletions(-) diff --git a/crates/recent_projects/src/remote_connections.rs b/crates/recent_projects/src/remote_connections.rs index 1c6da9b82a9a661307fd5eec1cd647ceb6c292bb..e8349601b5303331c0a6a38aca306fe57ab07ed3 100644 --- a/crates/recent_projects/src/remote_connections.rs +++ b/crates/recent_projects/src/remote_connections.rs @@ -533,8 +533,8 @@ impl remote::RemoteClientDelegate for RemoteClientDelegate { AutoUpdater::download_remote_server_release( release_channel, version.clone(), - platform.os, - platform.arch, + platform.os.as_str(), + platform.arch.as_str(), move |status, cx| this.set_status(Some(status), cx), cx, ) @@ -564,8 +564,8 @@ impl remote::RemoteClientDelegate for RemoteClientDelegate { AutoUpdater::get_remote_server_release_url( release_channel, version, - platform.os, - platform.arch, + platform.os.as_str(), + platform.arch.as_str(), cx, ) .await diff --git a/crates/remote/src/remote.rs b/crates/remote/src/remote.rs index 51b71c988a6dc57e875b3baa28103bef0d8fd729..2db918ecce331acac91bb974df1b784f0d6532b3 100644 --- a/crates/remote/src/remote.rs +++ b/crates/remote/src/remote.rs @@ -7,8 +7,9 @@ mod transport; #[cfg(target_os = "windows")] pub use remote_client::OpenWslPath; pub use remote_client::{ - ConnectionIdentifier, ConnectionState, RemoteClient, RemoteClientDelegate, RemoteClientEvent, - RemoteConnection, RemoteConnectionOptions, RemotePlatform, connect, + ConnectionIdentifier, ConnectionState, RemoteArch, RemoteClient, RemoteClientDelegate, + RemoteClientEvent, RemoteConnection, RemoteConnectionOptions, RemoteOs, RemotePlatform, + connect, }; pub use transport::docker::DockerConnectionOptions; pub use transport::ssh::{SshConnectionOptions, SshPortForwardOption}; diff --git a/crates/remote/src/remote_client.rs b/crates/remote/src/remote_client.rs index 9c6508e5f16027eb23225f0eceb1cb691f4a33c9..79bdbe540d070bfa18a6417622b386458ff221a8 100644 --- a/crates/remote/src/remote_client.rs +++ b/crates/remote/src/remote_client.rs @@ -49,10 +49,58 @@ use util::{ paths::{PathStyle, RemotePathBuf}, }; +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +pub enum RemoteOs { + Linux, + MacOs, + Windows, +} + +impl RemoteOs { + pub fn as_str(&self) -> &'static str { + match self { + RemoteOs::Linux => "linux", + RemoteOs::MacOs => "macos", + RemoteOs::Windows => "windows", + } + } + + pub fn is_windows(&self) -> bool { + matches!(self, RemoteOs::Windows) + } +} + +impl std::fmt::Display for RemoteOs { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +pub enum RemoteArch { + X86_64, + Aarch64, +} + +impl RemoteArch { + pub fn as_str(&self) -> &'static str { + match self { + RemoteArch::X86_64 => "x86_64", + RemoteArch::Aarch64 => "aarch64", + } + } +} + +impl std::fmt::Display for RemoteArch { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + #[derive(Copy, Clone, Debug)] pub struct RemotePlatform { - pub os: &'static str, - pub arch: &'static str, + pub os: RemoteOs, + pub arch: RemoteArch, } #[derive(Clone, Debug)] @@ -89,7 +137,8 @@ pub trait RemoteClientDelegate: Send + Sync { const MAX_MISSED_HEARTBEATS: usize = 5; const HEARTBEAT_INTERVAL: Duration = Duration::from_secs(5); const HEARTBEAT_TIMEOUT: Duration = Duration::from_secs(5); -const INITIAL_CONNECTION_TIMEOUT: Duration = Duration::from_secs(60); +const INITIAL_CONNECTION_TIMEOUT: Duration = + Duration::from_secs(if cfg!(debug_assertions) { 5 } else { 60 }); const MAX_RECONNECT_ATTEMPTS: usize = 3; diff --git a/crates/remote/src/transport.rs b/crates/remote/src/transport.rs index 4cafbf60eec338addbb43e46d156960621301ab0..ebf643352fce8a14d88b7c870b177d2c6b7e7de0 100644 --- a/crates/remote/src/transport.rs +++ b/crates/remote/src/transport.rs @@ -1,5 +1,5 @@ use crate::{ - RemotePlatform, + RemoteArch, RemoteOs, RemotePlatform, json_log::LogRecord, protocol::{MESSAGE_LEN_SIZE, message_len_from_buffer, read_message_with_len, write_message}, }; @@ -26,8 +26,8 @@ fn parse_platform(output: &str) -> Result { }; let os = match os { - "Darwin" => "macos", - "Linux" => "linux", + "Darwin" => RemoteOs::MacOs, + "Linux" => RemoteOs::Linux, _ => anyhow::bail!( "Prebuilt remote servers are not yet available for {os:?}. See https://zed.dev/docs/remote-development" ), @@ -39,9 +39,9 @@ fn parse_platform(output: &str) -> Result { || arch.starts_with("arm64") || arch.starts_with("aarch64") { - "aarch64" + RemoteArch::Aarch64 } else if arch.starts_with("x86") { - "x86_64" + RemoteArch::X86_64 } else { anyhow::bail!( "Prebuilt remote servers are not yet available for {arch:?}. See https://zed.dev/docs/remote-development" @@ -193,7 +193,8 @@ async fn build_remote_server_from_source( .await?; anyhow::ensure!( output.status.success(), - "Failed to run command: {command:?}" + "Failed to run command: {command:?}: output: {}", + String::from_utf8_lossy(&output.stderr) ); Ok(()) } @@ -203,14 +204,15 @@ async fn build_remote_server_from_source( "{}-{}", platform.arch, match platform.os { - "linux" => + RemoteOs::Linux => if use_musl { "unknown-linux-musl" } else { "unknown-linux-gnu" }, - "macos" => "apple-darwin", - _ => anyhow::bail!("can't cross compile for: {:?}", platform), + RemoteOs::MacOs => "apple-darwin", + RemoteOs::Windows if cfg!(windows) => "pc-windows-msvc", + RemoteOs::Windows => "pc-windows-gnu", } ); let mut rust_flags = match std::env::var("RUSTFLAGS") { @@ -221,7 +223,7 @@ async fn build_remote_server_from_source( String::new() } }; - if platform.os == "linux" && use_musl { + if platform.os == RemoteOs::Linux && use_musl { rust_flags.push_str(" -C target-feature=+crt-static"); if let Ok(path) = std::env::var("ZED_ZSTD_MUSL_LIB") { @@ -232,7 +234,9 @@ async fn build_remote_server_from_source( rust_flags.push_str(" -C link-arg=-fuse-ld=mold"); } - if platform.arch == std::env::consts::ARCH && platform.os == std::env::consts::OS { + if platform.arch.as_str() == std::env::consts::ARCH + && platform.os.as_str() == std::env::consts::OS + { delegate.set_status(Some("Building remote server binary from source"), cx); log::info!("building remote server binary from source"); run_cmd( @@ -308,7 +312,8 @@ async fn build_remote_server_from_source( .join("remote_server") .join(&triple) .join("debug") - .join("remote_server"); + .join("remote_server") + .with_extension(if platform.os.is_windows() { "exe" } else { "" }); let path = if !build_remote_server.contains("nocompress") { delegate.set_status(Some("Compressing binary"), cx); @@ -374,35 +379,44 @@ mod tests { #[test] fn test_parse_platform() { let result = parse_platform("Linux x86_64\n").unwrap(); - assert_eq!(result.os, "linux"); - assert_eq!(result.arch, "x86_64"); + assert_eq!(result.os, RemoteOs::Linux); + assert_eq!(result.arch, RemoteArch::X86_64); let result = parse_platform("Darwin arm64\n").unwrap(); - assert_eq!(result.os, "macos"); - assert_eq!(result.arch, "aarch64"); + assert_eq!(result.os, RemoteOs::MacOs); + assert_eq!(result.arch, RemoteArch::Aarch64); let result = parse_platform("Linux x86_64").unwrap(); - assert_eq!(result.os, "linux"); - assert_eq!(result.arch, "x86_64"); + assert_eq!(result.os, RemoteOs::Linux); + assert_eq!(result.arch, RemoteArch::X86_64); let result = parse_platform("some shell init output\nLinux aarch64\n").unwrap(); - assert_eq!(result.os, "linux"); - assert_eq!(result.arch, "aarch64"); + assert_eq!(result.os, RemoteOs::Linux); + assert_eq!(result.arch, RemoteArch::Aarch64); let result = parse_platform("some shell init output\nLinux aarch64").unwrap(); - assert_eq!(result.os, "linux"); - assert_eq!(result.arch, "aarch64"); + assert_eq!(result.os, RemoteOs::Linux); + assert_eq!(result.arch, RemoteArch::Aarch64); - assert_eq!(parse_platform("Linux armv8l\n").unwrap().arch, "aarch64"); - assert_eq!(parse_platform("Linux aarch64\n").unwrap().arch, "aarch64"); - assert_eq!(parse_platform("Linux x86_64\n").unwrap().arch, "x86_64"); + assert_eq!( + parse_platform("Linux armv8l\n").unwrap().arch, + RemoteArch::Aarch64 + ); + assert_eq!( + parse_platform("Linux aarch64\n").unwrap().arch, + RemoteArch::Aarch64 + ); + assert_eq!( + parse_platform("Linux x86_64\n").unwrap().arch, + RemoteArch::X86_64 + ); let result = parse_platform( r#"Linux x86_64 - What you're referring to as Linux, is in fact, GNU/Linux...\n"#, ) .unwrap(); - assert_eq!(result.os, "linux"); - assert_eq!(result.arch, "x86_64"); + assert_eq!(result.os, RemoteOs::Linux); + assert_eq!(result.arch, RemoteArch::X86_64); assert!(parse_platform("Windows x86_64\n").is_err()); assert!(parse_platform("Linux armv7l\n").is_err()); diff --git a/crates/remote/src/transport/docker.rs b/crates/remote/src/transport/docker.rs index 09f5935ec621260e933f11f46aa57493a31ace6d..9c14aa874941a5cdcd824d4adaeb41d694e347d8 100644 --- a/crates/remote/src/transport/docker.rs +++ b/crates/remote/src/transport/docker.rs @@ -24,8 +24,8 @@ use gpui::{App, AppContext, AsyncApp, Task}; use rpc::proto::Envelope; use crate::{ - RemoteClientDelegate, RemoteConnection, RemoteConnectionOptions, RemotePlatform, - remote_client::CommandTemplate, + RemoteArch, RemoteClientDelegate, RemoteConnection, RemoteConnectionOptions, RemoteOs, + RemotePlatform, remote_client::CommandTemplate, }; #[derive(Debug, Default, Clone, PartialEq, Eq, Hash)] @@ -70,7 +70,7 @@ impl DockerExecConnection { let remote_platform = this.check_remote_platform().await?; this.path_style = match remote_platform.os { - "windows" => Some(PathStyle::Windows), + RemoteOs::Windows => Some(PathStyle::Windows), _ => Some(PathStyle::Posix), }; @@ -124,8 +124,8 @@ impl DockerExecConnection { }; let os = match os.trim() { - "Darwin" => "macos", - "Linux" => "linux", + "Darwin" => RemoteOs::MacOs, + "Linux" => RemoteOs::Linux, _ => anyhow::bail!( "Prebuilt remote servers are not yet available for {os:?}. See https://zed.dev/docs/remote-development" ), @@ -136,9 +136,9 @@ impl DockerExecConnection { || arch.starts_with("arm64") || arch.starts_with("aarch64") { - "aarch64" + RemoteArch::Aarch64 } else if arch.starts_with("x86") { - "x86_64" + RemoteArch::X86_64 } else { anyhow::bail!( "Prebuilt remote servers are not yet available for {arch:?}. See https://zed.dev/docs/remote-development" diff --git a/crates/remote/src/transport/ssh.rs b/crates/remote/src/transport/ssh.rs index 37921b88637f19b68f9625170d9d99e85b5a9bdf..6c8eb49c1c2158322a275e064162b53e2f5f3d5e 100644 --- a/crates/remote/src/transport/ssh.rs +++ b/crates/remote/src/transport/ssh.rs @@ -1,5 +1,5 @@ use crate::{ - RemoteClientDelegate, RemotePlatform, + RemoteArch, RemoteClientDelegate, RemoteOs, RemotePlatform, remote_client::{CommandTemplate, RemoteConnection, RemoteConnectionOptions}, transport::{parse_platform, parse_shell}, }; @@ -402,30 +402,50 @@ impl RemoteConnection for SshRemoteConnection { delegate: Arc, cx: &mut AsyncApp, ) -> Task> { + const VARS: [&str; 3] = ["RUST_LOG", "RUST_BACKTRACE", "ZED_GENERATE_MINIDUMPS"]; delegate.set_status(Some("Starting proxy"), cx); let Some(remote_binary_path) = self.remote_binary_path.clone() else { return Task::ready(Err(anyhow!("Remote binary path not set"))); }; - let mut proxy_args = vec![]; - for env_var in ["RUST_LOG", "RUST_BACKTRACE", "ZED_GENERATE_MINIDUMPS"] { - if let Some(value) = std::env::var(env_var).ok() { - proxy_args.push(format!("{}='{}'", env_var, value)); + let mut ssh_command = if self.ssh_platform.os.is_windows() { + // TODO: Set the `VARS` environment variables, we do not have `env` on windows + // so this needs a different approach + let mut proxy_args = vec![]; + proxy_args.push("proxy".to_owned()); + proxy_args.push("--identifier".to_owned()); + proxy_args.push(unique_identifier); + + if reconnect { + proxy_args.push("--reconnect".to_owned()); } - } - proxy_args.push(remote_binary_path.display(self.path_style()).into_owned()); - proxy_args.push("proxy".to_owned()); - proxy_args.push("--identifier".to_owned()); - proxy_args.push(unique_identifier); + self.socket.ssh_command( + self.ssh_shell_kind, + &remote_binary_path.display(self.path_style()), + &proxy_args, + false, + ) + } else { + let mut proxy_args = vec![]; + for env_var in VARS { + if let Some(value) = std::env::var(env_var).ok() { + proxy_args.push(format!("{}='{}'", env_var, value)); + } + } + proxy_args.push(remote_binary_path.display(self.path_style()).into_owned()); + proxy_args.push("proxy".to_owned()); + proxy_args.push("--identifier".to_owned()); + proxy_args.push(unique_identifier); - if reconnect { - proxy_args.push("--reconnect".to_owned()); - } + if reconnect { + proxy_args.push("--reconnect".to_owned()); + } + self.socket + .ssh_command(self.ssh_shell_kind, "env", &proxy_args, false) + }; - let ssh_proxy_process = match self - .socket - .ssh_command(self.ssh_shell_kind, "env", &proxy_args, false) + let ssh_proxy_process = match ssh_command // IMPORTANT: we kill this process when we drop the task that uses it. .kill_on_drop(true) .spawn() @@ -545,22 +565,20 @@ impl SshRemoteConnection { .await?; drop(askpass); - let ssh_shell = socket.shell().await; + let is_windows = socket.probe_is_windows().await; + log::info!("Remote is windows: {}", is_windows); + + let ssh_shell = socket.shell(is_windows).await; log::info!("Remote shell discovered: {}", ssh_shell); - let ssh_platform = socket.platform(ShellKind::new(&ssh_shell, false)).await?; + + let ssh_shell_kind = ShellKind::new(&ssh_shell, is_windows); + let ssh_platform = socket.platform(ssh_shell_kind, is_windows).await?; log::info!("Remote platform discovered: {:?}", ssh_platform); - let ssh_path_style = match ssh_platform.os { - "windows" => PathStyle::Windows, - _ => PathStyle::Posix, + + let (ssh_path_style, ssh_default_system_shell) = match ssh_platform.os { + RemoteOs::Windows => (PathStyle::Windows, ssh_shell.clone()), + _ => (PathStyle::Posix, String::from("/bin/sh")), }; - let ssh_default_system_shell = String::from("/bin/sh"); - let ssh_shell_kind = ShellKind::new( - &ssh_shell, - match ssh_platform.os { - "windows" => true, - _ => false, - }, - ); let mut this = Self { socket, @@ -596,9 +614,14 @@ impl SshRemoteConnection { _ => version.to_string(), }; let binary_name = format!( - "zed-remote-server-{}-{}", + "zed-remote-server-{}-{}{}", release_channel.dev_name(), - version_str + version_str, + if self.ssh_platform.os.is_windows() { + ".exe" + } else { + "" + } ); let dst_path = paths::remote_server_dir_relative().join(RelPath::unix(&binary_name).unwrap()); @@ -710,14 +733,19 @@ impl SshRemoteConnection { cx: &mut AsyncApp, ) -> Result<()> { if let Some(parent) = tmp_path_gz.parent() { - self.socket + let res = self + .socket .run_command( self.ssh_shell_kind, "mkdir", &["-p", parent.display(self.path_style()).as_ref()], true, ) - .await?; + .await; + if !self.ssh_platform.os.is_windows() { + // mkdir fails on windows if the path already exists ... + res?; + } } delegate.set_status(Some("Downloading remote development server on host"), cx); @@ -805,17 +833,24 @@ impl SshRemoteConnection { cx: &mut AsyncApp, ) -> Result<()> { if let Some(parent) = tmp_path_gz.parent() { - self.socket + let res = self + .socket .run_command( self.ssh_shell_kind, "mkdir", &["-p", parent.display(self.path_style()).as_ref()], true, ) - .await?; + .await; + if !self.ssh_platform.os.is_windows() { + // mkdir fails on windows if the path already exists ... + res?; + } } - let src_stat = fs::metadata(&src_path).await?; + let src_stat = fs::metadata(&src_path) + .await + .with_context(|| format!("failed to get metadata for {:?}", src_path))?; let size = src_stat.len(); let t0 = Instant::now(); @@ -866,7 +901,7 @@ impl SshRemoteConnection { }; let args = shell_kind.args_for_shell(false, script.to_string()); self.socket - .run_command(shell_kind, "sh", &args, true) + .run_command(self.ssh_shell_kind, "sh", &args, true) .await?; Ok(()) } @@ -1054,6 +1089,7 @@ impl SshSocket { ) -> Result { let mut command = self.ssh_command(shell_kind, program, args, allow_pseudo_tty); let output = command.output().await?; + log::debug!("{:?}: {:?}", command, output); anyhow::ensure!( output.status.success(), "failed to run command {command:?}: {}", @@ -1125,12 +1161,71 @@ impl SshSocket { arguments } - async fn platform(&self, shell: ShellKind) -> Result { - let output = self.run_command(shell, "uname", &["-sm"], false).await?; + async fn platform(&self, shell: ShellKind, is_windows: bool) -> Result { + if is_windows { + self.platform_windows(shell).await + } else { + self.platform_posix(shell).await + } + } + + async fn platform_posix(&self, shell: ShellKind) -> Result { + let output = self + .run_command(shell, "uname", &["-sm"], false) + .await + .context("Failed to run 'uname -sm' to determine platform")?; parse_platform(&output) } - async fn shell(&self) -> String { + async fn platform_windows(&self, shell: ShellKind) -> Result { + let output = self + .run_command( + shell, + "cmd", + &["/c", "echo", "%PROCESSOR_ARCHITECTURE%"], + false, + ) + .await + .context( + "Failed to run 'echo %PROCESSOR_ARCHITECTURE%' to determine Windows architecture", + )?; + + Ok(RemotePlatform { + os: RemoteOs::Windows, + arch: match output.trim() { + "AMD64" => RemoteArch::X86_64, + "ARM64" => RemoteArch::Aarch64, + arch => anyhow::bail!( + "Prebuilt remote servers are not yet available for windows-{arch}. See https://zed.dev/docs/remote-development" + ), + }, + }) + } + + /// Probes whether the remote host is running Windows. + /// + /// This is done by attempting to run a simple Windows-specific command. + /// If it succeeds and returns Windows-like output, we assume it's Windows. + async fn probe_is_windows(&self) -> bool { + match self + .run_command(ShellKind::PowerShell, "cmd", &["/c", "ver"], false) + .await + { + // Windows 'ver' command outputs something like "Microsoft Windows [Version 10.0.19045.5011]" + Ok(output) => output.trim().contains("indows"), + Err(_) => false, + } + } + + async fn shell(&self, is_windows: bool) -> String { + if is_windows { + self.shell_windows().await + } else { + self.shell_posix().await + } + } + + async fn shell_posix(&self) -> String { const DEFAULT_SHELL: &str = "sh"; match self .run_command(ShellKind::Posix, "sh", &["-c", "echo $SHELL"], false) @@ -1143,6 +1238,13 @@ impl SshSocket { } } } + + async fn shell_windows(&self) -> String { + // powershell is always the default, and cannot really be removed from the system + // so we can rely on that fact and reasonably assume that we will be running in a + // powershell environment + "powershell.exe".to_owned() + } } fn parse_port_number(port_str: &str) -> Result { diff --git a/crates/remote/src/transport/wsl.rs b/crates/remote/src/transport/wsl.rs index d27648e67840681765248ae1cce12c15d7a13228..32dd9ebe8247bb4a0b631a79b1a93deb621e6ed1 100644 --- a/crates/remote/src/transport/wsl.rs +++ b/crates/remote/src/transport/wsl.rs @@ -1,5 +1,5 @@ use crate::{ - RemoteClientDelegate, RemotePlatform, + RemoteArch, RemoteClientDelegate, RemoteOs, RemotePlatform, remote_client::{CommandTemplate, RemoteConnection, RemoteConnectionOptions}, transport::{parse_platform, parse_shell}, }; @@ -70,7 +70,10 @@ impl WslRemoteConnection { let mut this = Self { connection_options, remote_binary_path: None, - platform: RemotePlatform { os: "", arch: "" }, + platform: RemotePlatform { + os: RemoteOs::Linux, + arch: RemoteArch::X86_64, + }, shell: String::new(), shell_kind: ShellKind::Posix, default_system_shell: String::from("/bin/sh"), From 14958a47ed2356ef635d7eaf441bca538536aba1 Mon Sep 17 00:00:00 2001 From: Dino Date: Wed, 17 Dec 2025 10:31:36 +0000 Subject: [PATCH 428/621] vim: Attempt to fix flaky vim tests on windows (#45089) Both `test_miniquotes_object` and `test_minibrackets_object` rely on tree-sitter parsing for `MultiBufferSnapshot.bracket_ranges` to find quote/bracket pairs. The `VimTestContext.set_state` call eventually triggers async tree-sitter parsing, but `run_until_parked` doesn't guarantee parsing completion. We suspect this is what might be causing the flakiness on Windows, as the syntax might not yet be parsed when the `VimTestContext.simulate_keystrokes` call is made, so there's no bracket pairs returned. This commit adds an explicit await call on `Bufffer.parsing_idle` after each `VimTestContext.set_state` call, to ensure tree-sitter parsing completes before simulating keystrokes. Release Notes: - N/A --- crates/vim/src/object.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/crates/vim/src/object.rs b/crates/vim/src/object.rs index 98c14855a3e20623c87d6204c1c4233f20008cbb..02150332405c6d5ea4d5dd78f477348be968fddf 100644 --- a/crates/vim/src/object.rs +++ b/crates/vim/src/object.rs @@ -2807,9 +2807,8 @@ mod test { for (keystrokes, initial_state, expected_state, expected_mode) in TEST_CASES { cx.set_state(initial_state, Mode::Normal); - + cx.buffer(|buffer, _| buffer.parsing_idle()).await; cx.simulate_keystrokes(keystrokes); - cx.assert_state(expected_state, *expected_mode); } @@ -2830,9 +2829,8 @@ mod test { for (keystrokes, initial_state, mode) in INVALID_CASES { cx.set_state(initial_state, Mode::Normal); - + cx.buffer(|buffer, _| buffer.parsing_idle()).await; cx.simulate_keystrokes(keystrokes); - cx.assert_state(initial_state, *mode); } } @@ -3185,9 +3183,8 @@ mod test { for (keystrokes, initial_state, expected_state, expected_mode) in TEST_CASES { cx.set_state(initial_state, Mode::Normal); - + cx.buffer(|buffer, _| buffer.parsing_idle()).await; cx.simulate_keystrokes(keystrokes); - cx.assert_state(expected_state, *expected_mode); } @@ -3208,9 +3205,8 @@ mod test { for (keystrokes, initial_state, mode) in INVALID_CASES { cx.set_state(initial_state, Mode::Normal); - + cx.buffer(|buffer, _| buffer.parsing_idle()).await; cx.simulate_keystrokes(keystrokes); - cx.assert_state(initial_state, *mode); } } From 010b871a8e94d50f1ae33cb60819b46a9334e332 Mon Sep 17 00:00:00 2001 From: Anthony Eid <56899983+Anthony-Eid@users.noreply.github.com> Date: Wed, 17 Dec 2025 05:52:27 -0500 Subject: [PATCH 429/621] git: Show pure white space changes in word diffs (#45090) Closes #44624 Before this change, white space would be trimmed from word diff ranges. Users found this behavior confusing, so we're changing it to be more inline with how GitHub treats whitespace in their word diffs. Release Notes: - git: Word diffs won't filter out pure whitespace diffs now --- crates/buffer_diff/src/buffer_diff.rs | 11 +++- crates/language/src/text_diff.rs | 61 +++---------------- crates/multi_buffer/src/multi_buffer_tests.rs | 13 ++++ 3 files changed, 30 insertions(+), 55 deletions(-) diff --git a/crates/buffer_diff/src/buffer_diff.rs b/crates/buffer_diff/src/buffer_diff.rs index 55de3f968bc1cc9ff5d640b0d3ca30221e413632..22525096d3cbca456aa114b5acc9b4239b570dda 100644 --- a/crates/buffer_diff/src/buffer_diff.rs +++ b/crates/buffer_diff/src/buffer_diff.rs @@ -2155,7 +2155,7 @@ mod tests { let range = diff_1.inner.compare(&empty_diff.inner, &buffer).unwrap(); assert_eq!(range.to_point(&buffer), Point::new(0, 0)..Point::new(8, 0)); - // Edit does not affect the diff. + // Edit does affects the diff because it recalculates word diffs. buffer.edit_via_marked_text( &" one @@ -2170,7 +2170,14 @@ mod tests { .unindent(), ); let diff_2 = BufferDiffSnapshot::new_sync(buffer.clone(), base_text.clone(), cx); - assert_eq!(None, diff_2.inner.compare(&diff_1.inner, &buffer)); + assert_eq!( + Point::new(4, 0)..Point::new(5, 0), + diff_2 + .inner + .compare(&diff_1.inner, &buffer) + .unwrap() + .to_point(&buffer) + ); // Edit turns a deletion hunk into a modification. buffer.edit_via_marked_text( diff --git a/crates/language/src/text_diff.rs b/crates/language/src/text_diff.rs index 1fb94b9f5e87015f317e3e88a963c06c7ea41b70..bc07ec73f0ad2c4738a2ca5f6ff955b53327acc3 100644 --- a/crates/language/src/text_diff.rs +++ b/crates/language/src/text_diff.rs @@ -48,7 +48,6 @@ pub fn text_diff(old_text: &str, new_text: &str) -> Vec<(Range, Arc) /// /// Returns a tuple of (old_ranges, new_ranges) where each vector contains /// the byte ranges of changed words in the respective text. -/// Whitespace-only changes are excluded from the results. pub fn word_diff_ranges( old_text: &str, new_text: &str, @@ -62,23 +61,23 @@ pub fn word_diff_ranges( let mut new_ranges: Vec> = Vec::new(); diff_internal(&input, |old_byte_range, new_byte_range, _, _| { - for range in split_on_whitespace(old_text, &old_byte_range) { + if !old_byte_range.is_empty() { if let Some(last) = old_ranges.last_mut() - && last.end >= range.start + && last.end >= old_byte_range.start { - last.end = range.end; + last.end = old_byte_range.end; } else { - old_ranges.push(range); + old_ranges.push(old_byte_range); } } - for range in split_on_whitespace(new_text, &new_byte_range) { + if !new_byte_range.is_empty() { if let Some(last) = new_ranges.last_mut() - && last.end >= range.start + && last.end >= new_byte_range.start { - last.end = range.end; + last.end = new_byte_range.end; } else { - new_ranges.push(range); + new_ranges.push(new_byte_range); } } }); @@ -86,50 +85,6 @@ pub fn word_diff_ranges( (old_ranges, new_ranges) } -fn split_on_whitespace(text: &str, range: &Range) -> Vec> { - if range.is_empty() { - return Vec::new(); - } - - let slice = &text[range.clone()]; - let mut ranges = Vec::new(); - let mut offset = 0; - - for line in slice.lines() { - let line_start = offset; - let line_end = line_start + line.len(); - offset = line_end + 1; - let trimmed = line.trim(); - - if !trimmed.is_empty() { - let leading = line.len() - line.trim_start().len(); - let trailing = line.len() - line.trim_end().len(); - let trimmed_start = range.start + line_start + leading; - let trimmed_end = range.start + line_end - trailing; - - let original_line_start = text[..range.start + line_start] - .rfind('\n') - .map(|i| i + 1) - .unwrap_or(0); - let original_line_end = text[range.start + line_start..] - .find('\n') - .map(|i| range.start + line_start + i) - .unwrap_or(text.len()); - let original_line = &text[original_line_start..original_line_end]; - let original_trimmed_start = - original_line_start + (original_line.len() - original_line.trim_start().len()); - let original_trimmed_end = - original_line_end - (original_line.len() - original_line.trim_end().len()); - - if trimmed_start > original_trimmed_start || trimmed_end < original_trimmed_end { - ranges.push(trimmed_start..trimmed_end); - } - } - } - - ranges -} - pub struct DiffOptions { pub language_scope: Option, pub max_word_diff_len: usize, diff --git a/crates/multi_buffer/src/multi_buffer_tests.rs b/crates/multi_buffer/src/multi_buffer_tests.rs index fc2edcac15be72c60309c5c386393ad83c387860..fb6dce079268e3dfed868a0c65c81bd12e226704 100644 --- a/crates/multi_buffer/src/multi_buffer_tests.rs +++ b/crates/multi_buffer/src/multi_buffer_tests.rs @@ -4480,6 +4480,19 @@ async fn test_word_diff_simple_replacement(cx: &mut TestAppContext) { assert_eq!(word_diffs, vec!["world", "bar", "WORLD", "BAR"]); } +#[gpui::test] +async fn test_word_diff_white_space(cx: &mut TestAppContext) { + let settings_store = cx.update(|cx| SettingsStore::test(cx)); + cx.set_global(settings_store); + + let base_text = "hello world foo bar\n"; + let modified_text = " hello world foo bar\n"; + + let word_diffs = collect_word_diffs(base_text, modified_text, cx); + + assert_eq!(word_diffs, vec![" "]); +} + #[gpui::test] async fn test_word_diff_consecutive_modified_lines(cx: &mut TestAppContext) { let settings_store = cx.update(|cx| SettingsStore::test(cx)); From c0b3422941bbc2a110c1999ff288ff99aa77aeca Mon Sep 17 00:00:00 2001 From: tidely <43219534+tidely@users.noreply.github.com> Date: Wed, 17 Dec 2025 13:27:06 +0200 Subject: [PATCH 430/621] node_runtime: Use `semver::Version` to represent package versions (#44342) Closes #ISSUE This PR is rather a nice to have change than anything critical, so review priority should remain low. Switch to using `semver::Version` for representing node binary and npm package versions. This is in an effort to root out implicit behavior and improve type safety when interacting with the `node_runtime` crate by catching invalid versions where they appear. Currently Zed may implicitly assume the current version is correct, or always install the newest version when a invalid version is passed. `semver::Version` also doesn't require the heap, which is probably more of a fun fact than anything useful. `npm_install_packages` still takes versions as a `&str`, because `latest` can be used to fetch the latest version on npm. This could likely be made into an enum as well, but would make the PR even larger. I tested changes with some node based language servers and external agents, which all worked fine. It would be nice to have some e2e tests for node. To be safe I'd put it on nightly after a Wednesday release. Release Notes: - N/A *or* Added/Fixed/Improved ... --- Cargo.lock | 2 + crates/copilot/src/copilot.rs | 5 +- .../src/wasm_host/wit/since_v0_8_0.rs | 2 + crates/language/Cargo.toml | 1 + crates/language/src/language.rs | 3 +- crates/languages/Cargo.toml | 1 + crates/languages/src/css.rs | 10 +-- crates/languages/src/json.rs | 10 +-- crates/languages/src/python.rs | 11 ++-- crates/languages/src/tailwind.rs | 10 +-- crates/languages/src/typescript.rs | 19 +++--- crates/languages/src/vtsls.rs | 19 +++--- crates/languages/src/yaml.rs | 11 ++-- crates/node_runtime/src/node_runtime.rs | 65 ++++++++----------- crates/project/src/agent_server_store.rs | 20 +++--- crates/project/src/debugger/session.rs | 23 ++++--- crates/project/src/lsp_store.rs | 3 +- crates/project/src/prettier_store.rs | 2 +- 18 files changed, 118 insertions(+), 99 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 080a6a4cf4183fb5cade03ba36072b448ab4b70a..20f19de832c567c6866731f128f049bd77d7be57 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8814,6 +8814,7 @@ dependencies = [ "regex", "rpc", "schemars", + "semver", "serde", "serde_json", "settings", @@ -9048,6 +9049,7 @@ dependencies = [ "regex", "rope", "rust-embed", + "semver", "serde", "serde_json", "serde_json_lenient", diff --git a/crates/copilot/src/copilot.rs b/crates/copilot/src/copilot.rs index 45f0796bf53acfef1fb1e81146c0de7c5187fb99..f248fbdb43ec37b19ca951992df6a7ddbc4f7313 100644 --- a/crates/copilot/src/copilot.rs +++ b/crates/copilot/src/copilot.rs @@ -1246,7 +1246,10 @@ async fn get_copilot_lsp(fs: Arc, node_runtime: NodeRuntime) -> anyhow:: .await; if should_install { node_runtime - .npm_install_packages(paths::copilot_dir(), &[(PACKAGE_NAME, &latest_version)]) + .npm_install_packages( + paths::copilot_dir(), + &[(PACKAGE_NAME, &latest_version.to_string())], + ) .await?; } diff --git a/crates/extension_host/src/wasm_host/wit/since_v0_8_0.rs b/crates/extension_host/src/wasm_host/wit/since_v0_8_0.rs index b2e0a1a4fbbf302a41cd509c27df9f52dc9a788d..8b3f8e86b71e959eade1e5d3710ce66b5b2d3008 100644 --- a/crates/extension_host/src/wasm_host/wit/since_v0_8_0.rs +++ b/crates/extension_host/src/wasm_host/wit/since_v0_8_0.rs @@ -736,6 +736,7 @@ impl nodejs::Host for WasmState { .node_runtime .npm_package_latest_version(&package_name) .await + .map(|v| v.to_string()) .to_wasmtime_result() } @@ -747,6 +748,7 @@ impl nodejs::Host for WasmState { .node_runtime .npm_package_installed_version(&self.work_dir(), &package_name) .await + .map(|option| option.map(|version| version.to_string())) .to_wasmtime_result() } diff --git a/crates/language/Cargo.toml b/crates/language/Cargo.toml index 49ea681290c3edc878391a337c5423fa795dba4f..3ba93476d2a9fa5371b9d146cfc0c5833a748842 100644 --- a/crates/language/Cargo.toml +++ b/crates/language/Cargo.toml @@ -48,6 +48,7 @@ rand = { workspace = true, optional = true } regex.workspace = true rpc.workspace = true schemars.workspace = true +semver.workspace = true serde.workspace = true serde_json.workspace = true settings.workspace = true diff --git a/crates/language/src/language.rs b/crates/language/src/language.rs index b0805c4ddd9d1203a1f1a3071e8640fd016c1fb1..eceb68f3e578fda97af292fee395a8ac4f0829c9 100644 --- a/crates/language/src/language.rs +++ b/crates/language/src/language.rs @@ -43,6 +43,7 @@ pub use manifest::{ManifestDelegate, ManifestName, ManifestProvider, ManifestQue use parking_lot::Mutex; use regex::Regex; use schemars::{JsonSchema, SchemaGenerator, json_schema}; +use semver::Version; use serde::{Deserialize, Deserializer, Serialize, Serializer, de}; use serde_json::Value; use settings::WorktreeId; @@ -347,7 +348,7 @@ pub trait LspAdapterDelegate: Send + Sync { async fn npm_package_installed_version( &self, package_name: &str, - ) -> Result>; + ) -> Result>; async fn which(&self, command: &OsStr) -> Option; async fn shell_env(&self) -> HashMap; async fn read_text_file(&self, path: &RelPath) -> Result; diff --git a/crates/languages/Cargo.toml b/crates/languages/Cargo.toml index c0aa9c39aacd86e45071bfe7f7289e50cb64b9b1..8529bdb82ace33d6f3c747ed707b9aac9d319627 100644 --- a/crates/languages/Cargo.toml +++ b/crates/languages/Cargo.toml @@ -68,6 +68,7 @@ serde_json.workspace = true serde_json_lenient.workspace = true settings.workspace = true smallvec.workspace = true +semver.workspace = true smol.workspace = true snippet.workspace = true task.workspace = true diff --git a/crates/languages/src/css.rs b/crates/languages/src/css.rs index 6a925586a622adbf6d8e2e3b1076278c3680a39a..ca6bbd827e1c58beb13244d61e69d5c14a29c89d 100644 --- a/crates/languages/src/css.rs +++ b/crates/languages/src/css.rs @@ -5,6 +5,7 @@ use language::{LspAdapter, LspAdapterDelegate, LspInstaller, Toolchain}; use lsp::{LanguageServerBinary, LanguageServerName, Uri}; use node_runtime::{NodeRuntime, VersionStrategy}; use project::lsp_store::language_server_settings; +use semver::Version; use serde_json::json; use std::{ ffi::OsString, @@ -32,14 +33,14 @@ impl CssLspAdapter { } impl LspInstaller for CssLspAdapter { - type BinaryVersion = String; + type BinaryVersion = Version; async fn fetch_latest_server_version( &self, _: &dyn LspAdapterDelegate, _: bool, _: &mut AsyncApp, - ) -> Result { + ) -> Result { self.node .npm_package_latest_version("vscode-langservers-extracted") .await @@ -65,11 +66,12 @@ impl LspInstaller for CssLspAdapter { async fn fetch_server_binary( &self, - latest_version: String, + latest_version: Self::BinaryVersion, container_dir: PathBuf, _: &dyn LspAdapterDelegate, ) -> Result { let server_path = container_dir.join(SERVER_PATH); + let latest_version = latest_version.to_string(); self.node .npm_install_packages( @@ -87,7 +89,7 @@ impl LspInstaller for CssLspAdapter { async fn check_if_version_installed( &self, - version: &String, + version: &Self::BinaryVersion, container_dir: &PathBuf, _: &dyn LspAdapterDelegate, ) -> Option { diff --git a/crates/languages/src/json.rs b/crates/languages/src/json.rs index 5168ba6e6188da62745df72a031f1d3bcda9a5d2..5e0f4907ef09973ad5d7b4f67c19ced1f1ddf05e 100644 --- a/crates/languages/src/json.rs +++ b/crates/languages/src/json.rs @@ -13,6 +13,7 @@ use language::{ use lsp::{LanguageServerBinary, LanguageServerName, Uri}; use node_runtime::{NodeRuntime, VersionStrategy}; use project::lsp_store::language_server_settings; +use semver::Version; use serde_json::{Value, json}; use smol::{ fs::{self}, @@ -142,14 +143,14 @@ impl JsonLspAdapter { } impl LspInstaller for JsonLspAdapter { - type BinaryVersion = String; + type BinaryVersion = Version; async fn fetch_latest_server_version( &self, _: &dyn LspAdapterDelegate, _: bool, _: &mut AsyncApp, - ) -> Result { + ) -> Result { self.node .npm_package_latest_version(Self::PACKAGE_NAME) .await @@ -175,7 +176,7 @@ impl LspInstaller for JsonLspAdapter { async fn check_if_version_installed( &self, - version: &String, + version: &Self::BinaryVersion, container_dir: &PathBuf, _: &dyn LspAdapterDelegate, ) -> Option { @@ -204,11 +205,12 @@ impl LspInstaller for JsonLspAdapter { async fn fetch_server_binary( &self, - latest_version: String, + latest_version: Self::BinaryVersion, container_dir: PathBuf, _: &dyn LspAdapterDelegate, ) -> Result { let server_path = container_dir.join(SERVER_PATH); + let latest_version = latest_version.to_string(); self.node .npm_install_packages( diff --git a/crates/languages/src/python.rs b/crates/languages/src/python.rs index b987d059ccaf53126e427a36c4f598817acd63de..77d4be6f49a4928731d39d2154cbe4f0e38024ef 100644 --- a/crates/languages/src/python.rs +++ b/crates/languages/src/python.rs @@ -19,6 +19,7 @@ use pet_core::python_environment::{PythonEnvironment, PythonEnvironmentKind}; use pet_virtualenv::is_virtualenv_dir; use project::Fs; use project::lsp_store::language_server_settings; +use semver::Version; use serde::{Deserialize, Serialize}; use serde_json::{Value, json}; use settings::Settings; @@ -621,14 +622,14 @@ impl LspAdapter for PyrightLspAdapter { } impl LspInstaller for PyrightLspAdapter { - type BinaryVersion = String; + type BinaryVersion = Version; async fn fetch_latest_server_version( &self, _: &dyn LspAdapterDelegate, _: bool, _: &mut AsyncApp, - ) -> Result { + ) -> Result { self.node .npm_package_latest_version(Self::SERVER_NAME.as_ref()) .await @@ -672,6 +673,7 @@ impl LspInstaller for PyrightLspAdapter { delegate: &dyn LspAdapterDelegate, ) -> Result { let server_path = container_dir.join(Self::SERVER_PATH); + let latest_version = latest_version.to_string(); self.node .npm_install_packages( @@ -2040,14 +2042,14 @@ impl LspAdapter for BasedPyrightLspAdapter { } impl LspInstaller for BasedPyrightLspAdapter { - type BinaryVersion = String; + type BinaryVersion = Version; async fn fetch_latest_server_version( &self, _: &dyn LspAdapterDelegate, _: bool, _: &mut AsyncApp, - ) -> Result { + ) -> Result { self.node .npm_package_latest_version(Self::SERVER_NAME.as_ref()) .await @@ -2092,6 +2094,7 @@ impl LspInstaller for BasedPyrightLspAdapter { delegate: &dyn LspAdapterDelegate, ) -> Result { let server_path = container_dir.join(Self::SERVER_PATH); + let latest_version = latest_version.to_string(); self.node .npm_install_packages( diff --git a/crates/languages/src/tailwind.rs b/crates/languages/src/tailwind.rs index 7e23c4ba5255c0413904797d1f8094e67834fa6a..b4b6f76cec28d5d21c31ea67aa72ead6814eae7d 100644 --- a/crates/languages/src/tailwind.rs +++ b/crates/languages/src/tailwind.rs @@ -6,6 +6,7 @@ use language::{LanguageName, LspAdapter, LspAdapterDelegate, LspInstaller, Toolc use lsp::{LanguageServerBinary, LanguageServerName, Uri}; use node_runtime::{NodeRuntime, VersionStrategy}; use project::lsp_store::language_server_settings; +use semver::Version; use serde_json::{Value, json}; use std::{ ffi::OsString, @@ -39,14 +40,14 @@ impl TailwindLspAdapter { } impl LspInstaller for TailwindLspAdapter { - type BinaryVersion = String; + type BinaryVersion = Version; async fn fetch_latest_server_version( &self, _: &dyn LspAdapterDelegate, _: bool, _: &mut AsyncApp, - ) -> Result { + ) -> Result { self.node .npm_package_latest_version(Self::PACKAGE_NAME) .await @@ -70,11 +71,12 @@ impl LspInstaller for TailwindLspAdapter { async fn fetch_server_binary( &self, - latest_version: String, + latest_version: Self::BinaryVersion, container_dir: PathBuf, _: &dyn LspAdapterDelegate, ) -> Result { let server_path = container_dir.join(SERVER_PATH); + let latest_version = latest_version.to_string(); self.node .npm_install_packages( @@ -92,7 +94,7 @@ impl LspInstaller for TailwindLspAdapter { async fn check_if_version_installed( &self, - version: &String, + version: &Self::BinaryVersion, container_dir: &PathBuf, _: &dyn LspAdapterDelegate, ) -> Option { diff --git a/crates/languages/src/typescript.rs b/crates/languages/src/typescript.rs index 7daf178d37229a5b051461e199c3dbf8d830cf22..4f9476d5afa488074b3d770b9f007d155b4863e7 100644 --- a/crates/languages/src/typescript.rs +++ b/crates/languages/src/typescript.rs @@ -12,6 +12,7 @@ use language::{ use lsp::{CodeActionKind, LanguageServerBinary, LanguageServerName, Uri}; use node_runtime::{NodeRuntime, VersionStrategy}; use project::{Fs, lsp_store::language_server_settings}; +use semver::Version; use serde_json::{Value, json}; use smol::lock::RwLock; use std::{ @@ -635,8 +636,8 @@ impl TypeScriptLspAdapter { } pub struct TypeScriptVersions { - typescript_version: String, - server_version: String, + typescript_version: Version, + server_version: Version, } impl LspInstaller for TypeScriptLspAdapter { @@ -647,7 +648,7 @@ impl LspInstaller for TypeScriptLspAdapter { _: &dyn LspAdapterDelegate, _: bool, _: &mut AsyncApp, - ) -> Result { + ) -> Result { Ok(TypeScriptVersions { typescript_version: self .node @@ -662,7 +663,7 @@ impl LspInstaller for TypeScriptLspAdapter { async fn check_if_version_installed( &self, - version: &TypeScriptVersions, + version: &Self::BinaryVersion, container_dir: &PathBuf, _: &dyn LspAdapterDelegate, ) -> Option { @@ -674,7 +675,7 @@ impl LspInstaller for TypeScriptLspAdapter { Self::PACKAGE_NAME, &server_path, container_dir, - VersionStrategy::Latest(version.typescript_version.as_str()), + VersionStrategy::Latest(&version.typescript_version), ) .await { @@ -687,7 +688,7 @@ impl LspInstaller for TypeScriptLspAdapter { Self::SERVER_PACKAGE_NAME, &server_path, container_dir, - VersionStrategy::Latest(version.server_version.as_str()), + VersionStrategy::Latest(&version.server_version), ) .await { @@ -703,7 +704,7 @@ impl LspInstaller for TypeScriptLspAdapter { async fn fetch_server_binary( &self, - latest_version: TypeScriptVersions, + latest_version: Self::BinaryVersion, container_dir: PathBuf, _: &dyn LspAdapterDelegate, ) -> Result { @@ -715,11 +716,11 @@ impl LspInstaller for TypeScriptLspAdapter { &[ ( Self::PACKAGE_NAME, - latest_version.typescript_version.as_str(), + &latest_version.typescript_version.to_string(), ), ( Self::SERVER_PACKAGE_NAME, - latest_version.server_version.as_str(), + &latest_version.server_version.to_string(), ), ], ) diff --git a/crates/languages/src/vtsls.rs b/crates/languages/src/vtsls.rs index b21ae1a4de24e0a8035e8fda7d61223b5143c5ff..3d38e022afe06f79d7e555263183a948c941f337 100644 --- a/crates/languages/src/vtsls.rs +++ b/crates/languages/src/vtsls.rs @@ -7,6 +7,7 @@ use lsp::{CodeActionKind, LanguageServerBinary, LanguageServerName, Uri}; use node_runtime::{NodeRuntime, VersionStrategy}; use project::{Fs, lsp_store::language_server_settings}; use regex::Regex; +use semver::Version; use serde_json::Value; use std::{ ffi::OsString, @@ -74,8 +75,8 @@ impl VtslsLspAdapter { } pub struct TypeScriptVersions { - typescript_version: String, - server_version: String, + typescript_version: Version, + server_version: Version, } const SERVER_NAME: LanguageServerName = LanguageServerName::new_static("vtsls"); @@ -88,7 +89,7 @@ impl LspInstaller for VtslsLspAdapter { _: &dyn LspAdapterDelegate, _: bool, _: &mut AsyncApp, - ) -> Result { + ) -> Result { Ok(TypeScriptVersions { typescript_version: self.node.npm_package_latest_version("typescript").await?, server_version: self @@ -115,12 +116,15 @@ impl LspInstaller for VtslsLspAdapter { async fn fetch_server_binary( &self, - latest_version: TypeScriptVersions, + latest_version: Self::BinaryVersion, container_dir: PathBuf, _: &dyn LspAdapterDelegate, ) -> Result { let server_path = container_dir.join(Self::SERVER_PATH); + let typescript_version = latest_version.typescript_version.to_string(); + let server_version = latest_version.server_version.to_string(); + let mut packages_to_install = Vec::new(); if self @@ -133,7 +137,7 @@ impl LspInstaller for VtslsLspAdapter { ) .await { - packages_to_install.push((Self::PACKAGE_NAME, latest_version.server_version.as_str())); + packages_to_install.push((Self::PACKAGE_NAME, server_version.as_str())); } if self @@ -146,10 +150,7 @@ impl LspInstaller for VtslsLspAdapter { ) .await { - packages_to_install.push(( - Self::TYPESCRIPT_PACKAGE_NAME, - latest_version.typescript_version.as_str(), - )); + packages_to_install.push((Self::TYPESCRIPT_PACKAGE_NAME, typescript_version.as_str())); } self.node diff --git a/crates/languages/src/yaml.rs b/crates/languages/src/yaml.rs index 57f254a68f126ac7f05c57d25ef0f920103f2233..6c1d8bc2d9e74578868dc687ec76a3b95790c5a9 100644 --- a/crates/languages/src/yaml.rs +++ b/crates/languages/src/yaml.rs @@ -7,6 +7,7 @@ use language::{ use lsp::{LanguageServerBinary, LanguageServerName, Uri}; use node_runtime::{NodeRuntime, VersionStrategy}; use project::lsp_store::language_server_settings; +use semver::Version; use serde_json::Value; use settings::{Settings, SettingsLocation}; use std::{ @@ -35,14 +36,14 @@ impl YamlLspAdapter { } impl LspInstaller for YamlLspAdapter { - type BinaryVersion = String; + type BinaryVersion = Version; async fn fetch_latest_server_version( &self, _: &dyn LspAdapterDelegate, _: bool, _: &mut AsyncApp, - ) -> Result { + ) -> Result { self.node .npm_package_latest_version("yaml-language-server") .await @@ -66,7 +67,7 @@ impl LspInstaller for YamlLspAdapter { async fn fetch_server_binary( &self, - latest_version: String, + latest_version: Self::BinaryVersion, container_dir: PathBuf, _: &dyn LspAdapterDelegate, ) -> Result { @@ -75,7 +76,7 @@ impl LspInstaller for YamlLspAdapter { self.node .npm_install_packages( &container_dir, - &[(Self::PACKAGE_NAME, latest_version.as_str())], + &[(Self::PACKAGE_NAME, &latest_version.to_string())], ) .await?; @@ -88,7 +89,7 @@ impl LspInstaller for YamlLspAdapter { async fn check_if_version_installed( &self, - version: &String, + version: &Self::BinaryVersion, container_dir: &PathBuf, _: &dyn LspAdapterDelegate, ) -> Option { diff --git a/crates/node_runtime/src/node_runtime.rs b/crates/node_runtime/src/node_runtime.rs index 322117cd717cac5c604ba215a2a1c7e0f7d87f06..5e4297988b665c3b89771838ef629ee87e88fb5b 100644 --- a/crates/node_runtime/src/node_runtime.rs +++ b/crates/node_runtime/src/node_runtime.rs @@ -34,9 +34,9 @@ pub struct NodeBinaryOptions { pub enum VersionStrategy<'a> { /// Install if current version doesn't match pinned version - Pin(&'a str), + Pin(&'a Version), /// Install if current version is older than latest version - Latest(&'a str), + Latest(&'a Version), } #[derive(Clone)] @@ -230,14 +230,14 @@ impl NodeRuntime { &self, local_package_directory: &Path, name: &str, - ) -> Result> { + ) -> Result> { self.instance() .await .npm_package_installed_version(local_package_directory, name) .await } - pub async fn npm_package_latest_version(&self, name: &str) -> Result { + pub async fn npm_package_latest_version(&self, name: &str) -> Result { let http = self.0.lock().await.http.clone(); let output = self .instance() @@ -280,16 +280,19 @@ impl NodeRuntime { .map(|(name, version)| format!("{name}@{version}")) .collect(); - let mut arguments: Vec<_> = packages.iter().map(|p| p.as_str()).collect(); - arguments.extend_from_slice(&[ - "--save-exact", - "--fetch-retry-mintimeout", - "2000", - "--fetch-retry-maxtimeout", - "5000", - "--fetch-timeout", - "5000", - ]); + let arguments: Vec<_> = packages + .iter() + .map(|p| p.as_str()) + .chain([ + "--save-exact", + "--fetch-retry-mintimeout", + "2000", + "--fetch-retry-maxtimeout", + "5000", + "--fetch-timeout", + "5000", + ]) + .collect(); // This is also wrong because the directory is wrong. self.run_npm_subcommand(Some(directory), "install", &arguments) @@ -320,23 +323,9 @@ impl NodeRuntime { return true; }; - let Some(installed_version) = Version::parse(&installed_version).log_err() else { - return true; - }; - match version_strategy { - VersionStrategy::Pin(pinned_version) => { - let Some(pinned_version) = Version::parse(pinned_version).log_err() else { - return true; - }; - installed_version != pinned_version - } - VersionStrategy::Latest(latest_version) => { - let Some(latest_version) = Version::parse(latest_version).log_err() else { - return true; - }; - installed_version < latest_version - } + VersionStrategy::Pin(pinned_version) => &installed_version != pinned_version, + VersionStrategy::Latest(latest_version) => &installed_version < latest_version, } } } @@ -351,12 +340,12 @@ enum ArchiveType { pub struct NpmInfo { #[serde(default)] dist_tags: NpmInfoDistTags, - versions: Vec, + versions: Vec, } #[derive(Debug, Deserialize, Default)] pub struct NpmInfoDistTags { - latest: Option, + latest: Option, } #[async_trait::async_trait] @@ -376,7 +365,7 @@ trait NodeRuntimeTrait: Send + Sync { &self, local_package_directory: &Path, name: &str, - ) -> Result>; + ) -> Result>; } #[derive(Clone)] @@ -610,7 +599,7 @@ impl NodeRuntimeTrait for ManagedNodeRuntime { &self, local_package_directory: &Path, name: &str, - ) -> Result> { + ) -> Result> { read_package_installed_version(local_package_directory.join("node_modules"), name).await } } @@ -735,7 +724,7 @@ impl NodeRuntimeTrait for SystemNodeRuntime { &self, local_package_directory: &Path, name: &str, - ) -> Result> { + ) -> Result> { read_package_installed_version(local_package_directory.join("node_modules"), name).await // todo: allow returning a globally installed version (requires callers not to hard-code the path) } @@ -744,7 +733,7 @@ impl NodeRuntimeTrait for SystemNodeRuntime { pub async fn read_package_installed_version( node_module_directory: PathBuf, name: &str, -) -> Result> { +) -> Result> { let package_json_path = node_module_directory.join(name).join("package.json"); let mut file = match fs::File::open(package_json_path).await { @@ -760,7 +749,7 @@ pub async fn read_package_installed_version( #[derive(Deserialize)] struct PackageJson { - version: String, + version: Version, } let mut contents = String::new(); @@ -797,7 +786,7 @@ impl NodeRuntimeTrait for UnavailableNodeRuntime { &self, _local_package_directory: &Path, _: &str, - ) -> Result> { + ) -> Result> { bail!("{}", self.error_message) } } diff --git a/crates/project/src/agent_server_store.rs b/crates/project/src/agent_server_store.rs index a2cc57beae9702e4d5b495a135e7c357c638c17a..287b25935676e2d5a09e92285a6cc94b81e52e13 100644 --- a/crates/project/src/agent_server_store.rs +++ b/crates/project/src/agent_server_store.rs @@ -22,6 +22,7 @@ use rpc::{ proto::{self, ExternalExtensionAgent}, }; use schemars::JsonSchema; +use semver::Version; use serde::{Deserialize, Serialize}; use settings::{RegisterSetting, SettingsStore}; use task::{Shell, SpawnInTerminal}; @@ -974,11 +975,10 @@ fn get_or_npm_install_builtin_agent( } versions.sort(); - let newest_version = if let Some((version, file_name)) = versions.last().cloned() + let newest_version = if let Some((version, _)) = versions.last().cloned() && minimum_version.is_none_or(|minimum_version| version >= minimum_version) { - versions.pop(); - Some(file_name) + versions.pop() } else { None }; @@ -1004,9 +1004,8 @@ fn get_or_npm_install_builtin_agent( }) .detach(); - let version = if let Some(file_name) = newest_version { + let version = if let Some((version, file_name)) = newest_version { cx.background_spawn({ - let file_name = file_name.clone(); let dir = dir.clone(); let fs = fs.clone(); async move { @@ -1015,7 +1014,7 @@ fn get_or_npm_install_builtin_agent( .await .ok(); if let Some(latest_version) = latest_version - && &latest_version != &file_name.to_string_lossy() + && latest_version != version { let download_result = download_latest_version( fs, @@ -1028,7 +1027,9 @@ fn get_or_npm_install_builtin_agent( if let Some(mut new_version_available) = new_version_available && download_result.is_some() { - new_version_available.send(Some(latest_version)).ok(); + new_version_available + .send(Some(latest_version.to_string())) + .ok(); } } } @@ -1047,6 +1048,7 @@ fn get_or_npm_install_builtin_agent( package_name.clone(), )) .await? + .to_string() .into() }; @@ -1093,7 +1095,7 @@ async fn download_latest_version( dir: PathBuf, node_runtime: NodeRuntime, package_name: SharedString, -) -> Result { +) -> Result { log::debug!("downloading latest version of {package_name}"); let tmp_dir = tempfile::tempdir_in(&dir)?; @@ -1109,7 +1111,7 @@ async fn download_latest_version( fs.rename( &tmp_dir.keep(), - &dir.join(&version), + &dir.join(version.to_string()), RenameOptions { ignore_if_exists: true, overwrite: true, diff --git a/crates/project/src/debugger/session.rs b/crates/project/src/debugger/session.rs index 82a139ea242889f89c3a6a0c6d41e83e00cbfec2..1bc41df4bd89b4a32b71ed4f0bec0a61e729f998 100644 --- a/crates/project/src/debugger/session.rs +++ b/crates/project/src/debugger/session.rs @@ -3118,10 +3118,11 @@ async fn get_or_install_companion(node: NodeRuntime, cx: &mut AsyncApp) -> Resul .await .context("getting installed companion version")? .context("companion was not installed")?; - smol::fs::rename(temp_dir.path(), dir.join(&version)) + let version_folder = dir.join(version.to_string()); + smol::fs::rename(temp_dir.path(), &version_folder) .await .context("moving companion package into place")?; - Ok(dir.join(version)) + Ok(version_folder) } let dir = paths::debug_adapters_dir().join("js-debug-companion"); @@ -3134,19 +3135,23 @@ async fn get_or_install_companion(node: NodeRuntime, cx: &mut AsyncApp) -> Resul .await .context("creating companion installation directory")?; - let mut children = smol::fs::read_dir(&dir) + let children = smol::fs::read_dir(&dir) .await .context("reading companion installation directory")? .try_collect::>() .await .context("reading companion installation directory entries")?; - children - .sort_by_key(|child| semver::Version::parse(child.file_name().to_str()?).ok()); - let latest_installed_version = children.last().and_then(|child| { - let version = child.file_name().into_string().ok()?; - Some((child.path(), version)) - }); + let latest_installed_version = children + .iter() + .filter_map(|child| { + Some(( + child.path(), + semver::Version::parse(child.file_name().to_str()?).ok()?, + )) + }) + .max_by_key(|(_, version)| version.clone()); + let latest_version = node .npm_package_latest_version(PACKAGE_NAME) .await diff --git a/crates/project/src/lsp_store.rs b/crates/project/src/lsp_store.rs index 83c2abfbb863166fd52e177dd75b497ca5111999..9b3eeebed79724196290738b51376e412ca11b22 100644 --- a/crates/project/src/lsp_store.rs +++ b/crates/project/src/lsp_store.rs @@ -93,6 +93,7 @@ use rpc::{ AnyProtoClient, ErrorCode, ErrorExt as _, proto::{LspRequestId, LspRequestMessage as _}, }; +use semver::Version; use serde::Serialize; use serde_json::Value; use settings::{Settings, SettingsLocation, SettingsStore}; @@ -13981,7 +13982,7 @@ impl LspAdapterDelegate for LocalLspAdapterDelegate { async fn npm_package_installed_version( &self, package_name: &str, - ) -> Result> { + ) -> Result> { let local_package_directory = self.worktree_root_path(); let node_modules_directory = local_package_directory.join("node_modules"); diff --git a/crates/project/src/prettier_store.rs b/crates/project/src/prettier_store.rs index 40deac76404ddb4378fe08cae931d0f0e3583487..a8b6fe37701d85d06d837a0a5e494e2a294777ec 100644 --- a/crates/project/src/prettier_store.rs +++ b/crates/project/src/prettier_store.rs @@ -905,7 +905,7 @@ async fn install_prettier_packages( .with_context(|| { format!("fetching latest npm version for package {returned_package_name}") })?; - anyhow::Ok((returned_package_name, latest_version)) + anyhow::Ok((returned_package_name, latest_version.to_string())) }), ) .await From edf21a38c18070554602441eeb8d3cfcf1ca0210 Mon Sep 17 00:00:00 2001 From: Shardul Vaidya <31039336+5herlocked@users.noreply.github.com> Date: Wed, 17 Dec 2025 06:54:57 -0500 Subject: [PATCH 431/621] bedrock: Add Bedrock API key authentication support (#41393) --- Cargo.lock | 65 +-- Cargo.toml | 10 +- crates/bedrock/src/bedrock.rs | 2 +- .../language_models/src/provider/bedrock.rs | 455 ++++++++++++------ .../src/settings_content/language_model.rs | 2 + 5 files changed, 351 insertions(+), 183 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 20f19de832c567c6866731f128f049bd77d7be57..de9cb227c6cfb799099abf446c1bdee61ec85bff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1441,9 +1441,9 @@ dependencies = [ [[package]] name = "aws-config" -version = "1.8.8" +version = "1.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37cf2b6af2a95a20e266782b4f76f1a5e12bf412a9db2de9c1e9123b9d8c0ad8" +checksum = "1856b1b48b65f71a4dd940b1c0931f9a7b646d4a924b9828ffefc1454714668a" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1507,9 +1507,9 @@ dependencies = [ [[package]] name = "aws-runtime" -version = "1.5.12" +version = "1.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa006bb32360ed90ac51203feafb9d02e3d21046e1fd3a450a404b90ea73e5d" +checksum = "9f2402da1a5e16868ba98725e5d73f26b8116eaa892e56f2cd0bf5eec7985f70" dependencies = [ "aws-credential-types", "aws-sigv4", @@ -1532,9 +1532,9 @@ dependencies = [ [[package]] name = "aws-sdk-bedrockruntime" -version = "1.109.0" +version = "1.112.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbfdfd941dcb253c17bf70baddbf1e5b22f19e29d313d2e049bad4b1dadb2011" +checksum = "c06c037e6823696d752702ec2bad758d3cf95d1b92b712c8ac7e93824b5e2391" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1614,9 +1614,9 @@ dependencies = [ [[package]] name = "aws-sdk-sso" -version = "1.86.0" +version = "1.88.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a0abbfab841446cce6e87af853a3ba2cc1bc9afcd3f3550dd556c43d434c86d" +checksum = "d05b276777560aa9a196dbba2e3aada4d8006d3d7eeb3ba7fe0c317227d933c4" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1636,9 +1636,9 @@ dependencies = [ [[package]] name = "aws-sdk-ssooidc" -version = "1.88.0" +version = "1.90.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a68d675582afea0e94d38b6ca9c5aaae4ca14f1d36faa6edb19b42e687e70d7" +checksum = "f9be14d6d9cd761fac3fd234a0f47f7ed6c0df62d83c0eeb7012750e4732879b" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1658,9 +1658,9 @@ dependencies = [ [[package]] name = "aws-sdk-sts" -version = "1.88.0" +version = "1.90.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d30990923f4f675523c51eb1c0dec9b752fb267b36a61e83cbc219c9d86da715" +checksum = "98a862d704c817d865c8740b62d8bbeb5adcb30965e93b471df8a5bcefa20a80" dependencies = [ "aws-credential-types", "aws-runtime", @@ -1681,9 +1681,9 @@ dependencies = [ [[package]] name = "aws-sigv4" -version = "1.3.5" +version = "1.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bffc03068fbb9c8dd5ce1c6fb240678a5cffb86fb2b7b1985c999c4b83c8df68" +checksum = "c35452ec3f001e1f2f6db107b6373f1f48f05ec63ba2c5c9fa91f07dad32af11" dependencies = [ "aws-credential-types", "aws-smithy-eventstream", @@ -1740,9 +1740,9 @@ dependencies = [ [[package]] name = "aws-smithy-eventstream" -version = "0.60.12" +version = "0.60.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9656b85088f8d9dc7ad40f9a6c7228e1e8447cdf4b046c87e152e0805dea02fa" +checksum = "e29a304f8319781a39808847efb39561351b1bb76e933da7aa90232673638658" dependencies = [ "aws-smithy-types", "bytes 1.10.1", @@ -1751,9 +1751,9 @@ dependencies = [ [[package]] name = "aws-smithy-http" -version = "0.62.4" +version = "0.62.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3feafd437c763db26aa04e0cc7591185d0961e64c61885bece0fb9d50ceac671" +checksum = "445d5d720c99eed0b4aa674ed00d835d9b1427dd73e04adaf2f94c6b2d6f9fca" dependencies = [ "aws-smithy-eventstream", "aws-smithy-runtime-api", @@ -1761,6 +1761,7 @@ dependencies = [ "bytes 1.10.1", "bytes-utils", "futures-core", + "futures-util", "http 0.2.12", "http 1.3.1", "http-body 0.4.6", @@ -1772,9 +1773,9 @@ dependencies = [ [[package]] name = "aws-smithy-http-client" -version = "1.1.3" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1053b5e587e6fa40ce5a79ea27957b04ba660baa02b28b7436f64850152234f1" +checksum = "623254723e8dfd535f566ee7b2381645f8981da086b5c4aa26c0c41582bb1d2c" dependencies = [ "aws-smithy-async", "aws-smithy-runtime-api", @@ -1802,9 +1803,9 @@ dependencies = [ [[package]] name = "aws-smithy-json" -version = "0.61.6" +version = "0.61.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cff418fc8ec5cadf8173b10125f05c2e7e1d46771406187b2c878557d4503390" +checksum = "2db31f727935fc63c6eeae8b37b438847639ec330a9161ece694efba257e0c54" dependencies = [ "aws-smithy-types", ] @@ -1830,9 +1831,9 @@ dependencies = [ [[package]] name = "aws-smithy-runtime" -version = "1.9.3" +version = "1.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40ab99739082da5347660c556689256438defae3bcefd66c52b095905730e404" +checksum = "0bbe9d018d646b96c7be063dd07987849862b0e6d07c778aad7d93d1be6c1ef0" dependencies = [ "aws-smithy-async", "aws-smithy-http", @@ -1854,9 +1855,9 @@ dependencies = [ [[package]] name = "aws-smithy-runtime-api" -version = "1.9.1" +version = "1.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3683c5b152d2ad753607179ed71988e8cfd52964443b4f74fd8e552d0bbfeb46" +checksum = "ec7204f9fd94749a7c53b26da1b961b4ac36bf070ef1e0b94bb09f79d4f6c193" dependencies = [ "aws-smithy-async", "aws-smithy-types", @@ -1871,9 +1872,9 @@ dependencies = [ [[package]] name = "aws-smithy-types" -version = "1.3.3" +version = "1.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f5b3a7486f6690ba25952cabf1e7d75e34d69eaff5081904a47bc79074d6457" +checksum = "25f535879a207fce0db74b679cfc3e91a3159c8144d717d55f5832aea9eef46e" dependencies = [ "base64-simd", "bytes 1.10.1", @@ -1897,18 +1898,18 @@ dependencies = [ [[package]] name = "aws-smithy-xml" -version = "0.60.11" +version = "0.60.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9c34127e8c624bc2999f3b657e749c1393bedc9cd97b92a804db8ced4d2e163" +checksum = "eab77cdd036b11056d2a30a7af7b775789fb024bf216acc13884c6c97752ae56" dependencies = [ "xmlparser", ] [[package]] name = "aws-types" -version = "1.3.9" +version = "1.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2fd329bf0e901ff3f60425691410c69094dc2a1f34b331f37bfc4e9ac1565a1" +checksum = "d79fb68e3d7fe5d4833ea34dc87d2e97d26d3086cb3da660bb6b1f76d98680b6" dependencies = [ "aws-credential-types", "aws-smithy-async", diff --git a/Cargo.toml b/Cargo.toml index f46ffa2583c022be8704e95684ddce65b19d3fab..a8002e207d7ba9d3699832ac76be530e1979ead4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -455,15 +455,15 @@ async-task = "4.7" async-trait = "0.1" async-tungstenite = "0.31.0" async_zip = { version = "0.0.18", features = ["deflate", "deflate64"] } -aws-config = { version = "1.6.1", features = ["behavior-version-latest"] } -aws-credential-types = { version = "1.2.2", features = [ +aws-config = { version = "1.8.10", features = ["behavior-version-latest"] } +aws-credential-types = { version = "1.2.8", features = [ "hardcoded-credentials", ] } -aws-sdk-bedrockruntime = { version = "1.80.0", features = [ +aws-sdk-bedrockruntime = { version = "1.112.0", features = [ "behavior-version-latest", ] } -aws-smithy-runtime-api = { version = "1.7.4", features = ["http-1x", "client"] } -aws-smithy-types = { version = "1.3.0", features = ["http-body-1-x"] } +aws-smithy-runtime-api = { version = "1.9.2", features = ["http-1x", "client"] } +aws-smithy-types = { version = "1.3.4", features = ["http-body-1-x"] } backtrace = "0.3" base64 = "0.22" bincode = "1.2.1" diff --git a/crates/bedrock/src/bedrock.rs b/crates/bedrock/src/bedrock.rs index ec0b4070906fdfd31195668312b3e7b425cd28ee..744dde38076a5a12c9bc957a75e2435b1b753d96 100644 --- a/crates/bedrock/src/bedrock.rs +++ b/crates/bedrock/src/bedrock.rs @@ -87,7 +87,7 @@ pub async fn stream_completion( Ok(None) => None, Err(err) => Some(( Err(BedrockError::ClientError(anyhow!( - "{:?}", + "{}", aws_sdk_bedrockruntime::error::DisplayErrorContext(err) ))), stream, diff --git a/crates/language_models/src/provider/bedrock.rs b/crates/language_models/src/provider/bedrock.rs index b85a038bb235d97bd9de8614f19764ecabf7bbfe..9273234161a8169abf68190ca8fe4627b8f769dc 100644 --- a/crates/language_models/src/provider/bedrock.rs +++ b/crates/language_models/src/provider/bedrock.rs @@ -5,7 +5,7 @@ use std::sync::Arc; use anyhow::{Context as _, Result, anyhow}; use aws_config::stalled_stream_protection::StalledStreamProtectionConfig; use aws_config::{BehaviorVersion, Region}; -use aws_credential_types::Credentials; +use aws_credential_types::{Credentials, Token}; use aws_http_client::AwsHttpClient; use bedrock::bedrock_client::Client as BedrockClient; use bedrock::bedrock_client::config::timeout::TimeoutConfig; @@ -30,18 +30,19 @@ use gpui::{ use gpui_tokio::Tokio; use http_client::HttpClient; use language_model::{ - AuthenticateError, LanguageModel, LanguageModelCacheConfiguration, + AuthenticateError, EnvVar, LanguageModel, LanguageModelCacheConfiguration, LanguageModelCompletionError, LanguageModelCompletionEvent, LanguageModelId, LanguageModelName, LanguageModelProvider, LanguageModelProviderId, LanguageModelProviderName, LanguageModelProviderState, LanguageModelRequest, LanguageModelToolChoice, LanguageModelToolResultContent, LanguageModelToolUse, MessageContent, RateLimiter, Role, - TokenUsage, + TokenUsage, env_var, }; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use serde_json::Value; use settings::{BedrockAvailableModel as AvailableModel, Settings, SettingsStore}; use smol::lock::OnceCell; +use std::sync::LazyLock; use strum::{EnumIter, IntoEnumIterator, IntoStaticStr}; use ui::{ButtonLink, ConfiguredApiCard, List, ListBulletItem, prelude::*}; use ui_input::InputField; @@ -54,12 +55,52 @@ actions!(bedrock, [Tab, TabPrev]); const PROVIDER_ID: LanguageModelProviderId = LanguageModelProviderId::new("amazon-bedrock"); const PROVIDER_NAME: LanguageModelProviderName = LanguageModelProviderName::new("Amazon Bedrock"); +/// Credentials stored in the keychain for static authentication. +/// Region is handled separately since it's orthogonal to auth method. #[derive(Default, Clone, Deserialize, Serialize, PartialEq, Debug)] pub struct BedrockCredentials { pub access_key_id: String, pub secret_access_key: String, pub session_token: Option, - pub region: String, + pub bearer_token: Option, +} + +/// Resolved authentication configuration for Bedrock. +/// Settings take priority over UX-provided credentials. +#[derive(Clone, Debug, PartialEq)] +pub enum BedrockAuth { + /// Use default AWS credential provider chain (IMDSv2, PodIdentity, env vars, etc.) + Automatic, + /// Use AWS named profile from ~/.aws/credentials or ~/.aws/config + NamedProfile { profile_name: String }, + /// Use AWS SSO profile + SingleSignOn { profile_name: String }, + /// Use IAM credentials (access key + secret + optional session token) + IamCredentials { + access_key_id: String, + secret_access_key: String, + session_token: Option, + }, + /// Use Bedrock API Key (bearer token authentication) + ApiKey { api_key: String }, +} + +impl BedrockCredentials { + /// Convert stored credentials to the appropriate auth variant. + /// Prefers API key if present, otherwise uses IAM credentials. + fn into_auth(self) -> Option { + if let Some(api_key) = self.bearer_token.filter(|t| !t.is_empty()) { + Some(BedrockAuth::ApiKey { api_key }) + } else if !self.access_key_id.is_empty() && !self.secret_access_key.is_empty() { + Some(BedrockAuth::IamCredentials { + access_key_id: self.access_key_id, + secret_access_key: self.secret_access_key, + session_token: self.session_token.filter(|t| !t.is_empty()), + }) + } else { + None + } + } } #[derive(Default, Clone, Debug, PartialEq)] @@ -79,6 +120,8 @@ pub enum BedrockAuthMethod { NamedProfile, #[serde(rename = "sso")] SingleSignOn, + #[serde(rename = "api_key")] + ApiKey, /// IMDSv2, PodIdentity, env vars, etc. #[serde(rename = "default")] Automatic, @@ -90,6 +133,7 @@ impl From for BedrockAuthMethod { settings::BedrockAuthMethodContent::SingleSignOn => BedrockAuthMethod::SingleSignOn, settings::BedrockAuthMethodContent::Automatic => BedrockAuthMethod::Automatic, settings::BedrockAuthMethodContent::NamedProfile => BedrockAuthMethod::NamedProfile, + settings::BedrockAuthMethodContent::ApiKey => BedrockAuthMethod::ApiKey, } } } @@ -130,23 +174,26 @@ impl From for ModelMode { const AMAZON_AWS_URL: &str = "https://amazonaws.com"; // These environment variables all use a `ZED_` prefix because we don't want to overwrite the user's AWS credentials. -const ZED_BEDROCK_ACCESS_KEY_ID_VAR: &str = "ZED_ACCESS_KEY_ID"; -const ZED_BEDROCK_SECRET_ACCESS_KEY_VAR: &str = "ZED_SECRET_ACCESS_KEY"; -const ZED_BEDROCK_SESSION_TOKEN_VAR: &str = "ZED_SESSION_TOKEN"; -const ZED_AWS_PROFILE_VAR: &str = "ZED_AWS_PROFILE"; -const ZED_BEDROCK_REGION_VAR: &str = "ZED_AWS_REGION"; -const ZED_AWS_CREDENTIALS_VAR: &str = "ZED_AWS_CREDENTIALS"; -const ZED_AWS_ENDPOINT_VAR: &str = "ZED_AWS_ENDPOINT"; +static ZED_BEDROCK_ACCESS_KEY_ID_VAR: LazyLock = env_var!("ZED_ACCESS_KEY_ID"); +static ZED_BEDROCK_SECRET_ACCESS_KEY_VAR: LazyLock = env_var!("ZED_SECRET_ACCESS_KEY"); +static ZED_BEDROCK_SESSION_TOKEN_VAR: LazyLock = env_var!("ZED_SESSION_TOKEN"); +static ZED_AWS_PROFILE_VAR: LazyLock = env_var!("ZED_AWS_PROFILE"); +static ZED_BEDROCK_REGION_VAR: LazyLock = env_var!("ZED_AWS_REGION"); +static ZED_AWS_ENDPOINT_VAR: LazyLock = env_var!("ZED_AWS_ENDPOINT"); +static ZED_BEDROCK_BEARER_TOKEN_VAR: LazyLock = env_var!("ZED_BEDROCK_BEARER_TOKEN"); pub struct State { - credentials: Option, + /// The resolved authentication method. Settings take priority over UX credentials. + auth: Option, + /// Raw settings from settings.json settings: Option, + /// Whether credentials came from environment variables (only relevant for static credentials) credentials_from_env: bool, _subscription: Subscription, } impl State { - fn reset_credentials(&self, cx: &mut Context) -> Task> { + fn reset_auth(&self, cx: &mut Context) -> Task> { let credentials_provider = ::global(cx); cx.spawn(async move |this, cx| { credentials_provider @@ -154,19 +201,19 @@ impl State { .await .log_err(); this.update(cx, |this, cx| { - this.credentials = None; + this.auth = None; this.credentials_from_env = false; - this.settings = None; cx.notify(); }) }) } - fn set_credentials( + fn set_static_credentials( &mut self, credentials: BedrockCredentials, cx: &mut Context, ) -> Task> { + let auth = credentials.clone().into_auth(); let credentials_provider = ::global(cx); cx.spawn(async move |this, cx| { credentials_provider @@ -178,50 +225,131 @@ impl State { ) .await?; this.update(cx, |this, cx| { - this.credentials = Some(credentials); + this.auth = auth; + this.credentials_from_env = false; cx.notify(); }) }) } fn is_authenticated(&self) -> bool { - let derived = self - .settings - .as_ref() - .and_then(|s| s.authentication_method.as_ref()); - let creds = self.credentials.as_ref(); - - derived.is_some() || creds.is_some() + self.auth.is_some() } + /// Resolve authentication. Settings take priority over UX-provided credentials. fn authenticate(&self, cx: &mut Context) -> Task> { if self.is_authenticated() { return Task::ready(Ok(())); } + // Step 1: Check if settings specify an auth method (enterprise control) + if let Some(settings) = &self.settings { + if let Some(method) = &settings.authentication_method { + let profile_name = settings + .profile_name + .clone() + .unwrap_or_else(|| "default".to_string()); + + let auth = match method { + BedrockAuthMethod::Automatic => BedrockAuth::Automatic, + BedrockAuthMethod::NamedProfile => BedrockAuth::NamedProfile { profile_name }, + BedrockAuthMethod::SingleSignOn => BedrockAuth::SingleSignOn { profile_name }, + BedrockAuthMethod::ApiKey => { + // ApiKey method means "use static credentials from keychain/env" + // Fall through to load them below + return self.load_static_credentials(cx); + } + }; + + return cx.spawn(async move |this, cx| { + this.update(cx, |this, cx| { + this.auth = Some(auth); + this.credentials_from_env = false; + cx.notify(); + })?; + Ok(()) + }); + } + } + + // Step 2: No settings auth method - try to load static credentials + self.load_static_credentials(cx) + } + + /// Load static credentials from environment variables or keychain. + fn load_static_credentials( + &self, + cx: &mut Context, + ) -> Task> { let credentials_provider = ::global(cx); cx.spawn(async move |this, cx| { - let (credentials, from_env) = - if let Ok(credentials) = std::env::var(ZED_AWS_CREDENTIALS_VAR) { - (credentials, true) - } else { - let (_, credentials) = credentials_provider - .read_credentials(AMAZON_AWS_URL, cx) - .await? - .ok_or_else(|| AuthenticateError::CredentialsNotFound)?; + // Try environment variables first + let (auth, from_env) = if let Some(bearer_token) = &ZED_BEDROCK_BEARER_TOKEN_VAR.value { + if !bearer_token.is_empty() { ( - String::from_utf8(credentials) - .context("invalid {PROVIDER_NAME} credentials")?, - false, + Some(BedrockAuth::ApiKey { + api_key: bearer_token.to_string(), + }), + true, ) - }; + } else { + (None, false) + } + } else if let Some(access_key_id) = &ZED_BEDROCK_ACCESS_KEY_ID_VAR.value { + if let Some(secret_access_key) = &ZED_BEDROCK_SECRET_ACCESS_KEY_VAR.value { + if !access_key_id.is_empty() && !secret_access_key.is_empty() { + let session_token = ZED_BEDROCK_SESSION_TOKEN_VAR + .value + .as_deref() + .filter(|s| !s.is_empty()) + .map(|s| s.to_string()); + ( + Some(BedrockAuth::IamCredentials { + access_key_id: access_key_id.to_string(), + secret_access_key: secret_access_key.to_string(), + session_token, + }), + true, + ) + } else { + (None, false) + } + } else { + (None, false) + } + } else { + (None, false) + }; + + // If we got auth from env vars, use it + if let Some(auth) = auth { + this.update(cx, |this, cx| { + this.auth = Some(auth); + this.credentials_from_env = from_env; + cx.notify(); + })?; + return Ok(()); + } + + // Try keychain + let (_, credentials_bytes) = credentials_provider + .read_credentials(AMAZON_AWS_URL, cx) + .await? + .ok_or(AuthenticateError::CredentialsNotFound)?; + + let credentials_str = String::from_utf8(credentials_bytes) + .context("invalid {PROVIDER_NAME} credentials")?; let credentials: BedrockCredentials = - serde_json::from_str(&credentials).context("failed to parse credentials")?; + serde_json::from_str(&credentials_str).context("failed to parse credentials")?; + + let auth = credentials + .into_auth() + .ok_or(AuthenticateError::CredentialsNotFound)?; this.update(cx, |this, cx| { - this.credentials = Some(credentials); - this.credentials_from_env = from_env; + this.auth = Some(auth); + this.credentials_from_env = false; cx.notify(); })?; @@ -229,15 +357,19 @@ impl State { }) } + /// Get the resolved region. Checks env var, then settings, then defaults to us-east-1. fn get_region(&self) -> String { - // Get region - from credentials or directly from settings - let credentials_region = self.credentials.as_ref().map(|s| s.region.clone()); - let settings_region = self.settings.as_ref().and_then(|s| s.region.clone()); - - // Use credentials region if available, otherwise use settings region, finally fall back to default - credentials_region - .or(settings_region) - .unwrap_or(String::from("us-east-1")) + // Priority: env var > settings > default + if let Some(region) = ZED_BEDROCK_REGION_VAR.value.as_deref() { + if !region.is_empty() { + return region.to_string(); + } + } + + self.settings + .as_ref() + .and_then(|s| s.region.clone()) + .unwrap_or_else(|| "us-east-1".to_string()) } fn get_allow_global(&self) -> bool { @@ -257,7 +389,7 @@ pub struct BedrockLanguageModelProvider { impl BedrockLanguageModelProvider { pub fn new(http_client: Arc, cx: &mut App) -> Self { let state = cx.new(|cx| State { - credentials: None, + auth: None, settings: Some(AllLanguageModelSettings::get_global(cx).bedrock.clone()), credentials_from_env: false, _subscription: cx.observe_global::(|_, cx| { @@ -266,7 +398,7 @@ impl BedrockLanguageModelProvider { }); Self { - http_client: AwsHttpClient::new(http_client.clone()), + http_client: AwsHttpClient::new(http_client), handle: Tokio::handle(cx), state, } @@ -312,7 +444,6 @@ impl LanguageModelProvider for BedrockLanguageModelProvider { for model in bedrock::Model::iter() { if !matches!(model, bedrock::Model::Custom { .. }) { - // TODO: Sonnet 3.7 vs. 3.7 Thinking bug is here. models.insert(model.id().to_string(), model); } } @@ -366,8 +497,7 @@ impl LanguageModelProvider for BedrockLanguageModelProvider { } fn reset_credentials(&self, cx: &mut App) -> Task> { - self.state - .update(cx, |state, cx| state.reset_credentials(cx)) + self.state.update(cx, |state, cx| state.reset_auth(cx)) } } @@ -393,25 +523,11 @@ impl BedrockModel { fn get_or_init_client(&self, cx: &AsyncApp) -> anyhow::Result<&BedrockClient> { self.client .get_or_try_init_blocking(|| { - let (auth_method, credentials, endpoint, region, settings) = - cx.read_entity(&self.state, |state, _cx| { - let auth_method = state - .settings - .as_ref() - .and_then(|s| s.authentication_method.clone()); - - let endpoint = state.settings.as_ref().and_then(|s| s.endpoint.clone()); - - let region = state.get_region(); - - ( - auth_method, - state.credentials.clone(), - endpoint, - region, - state.settings.clone(), - ) - })?; + let (auth, endpoint, region) = cx.read_entity(&self.state, |state, _cx| { + let endpoint = state.settings.as_ref().and_then(|s| s.endpoint.clone()); + let region = state.get_region(); + (state.auth.clone(), endpoint, region) + })?; let mut config_builder = aws_config::defaults(BehaviorVersion::latest()) .stalled_stream_protection(StalledStreamProtectionConfig::disabled()) @@ -425,37 +541,39 @@ impl BedrockModel { config_builder = config_builder.endpoint_url(endpoint_url); } - match auth_method { - None => { - if let Some(creds) = credentials { - let aws_creds = Credentials::new( - creds.access_key_id, - creds.secret_access_key, - creds.session_token, - None, - "zed-bedrock-provider", - ); - config_builder = config_builder.credentials_provider(aws_creds); - } + match auth { + Some(BedrockAuth::Automatic) | None => { + // Use default AWS credential provider chain } - Some(BedrockAuthMethod::NamedProfile) - | Some(BedrockAuthMethod::SingleSignOn) => { - // Currently NamedProfile and SSO behave the same way but only the instructions change - // Until we support BearerAuth through SSO, this will not change. - let profile_name = settings - .and_then(|s| s.profile_name) - .unwrap_or_else(|| "default".to_string()); - + Some(BedrockAuth::NamedProfile { profile_name }) + | Some(BedrockAuth::SingleSignOn { profile_name }) => { if !profile_name.is_empty() { config_builder = config_builder.profile_name(profile_name); } } - Some(BedrockAuthMethod::Automatic) => { - // Use default credential provider chain + Some(BedrockAuth::IamCredentials { + access_key_id, + secret_access_key, + session_token, + }) => { + let aws_creds = Credentials::new( + access_key_id, + secret_access_key, + session_token, + None, + "zed-bedrock-provider", + ); + config_builder = config_builder.credentials_provider(aws_creds); + } + Some(BedrockAuth::ApiKey { api_key }) => { + config_builder = config_builder + .auth_scheme_preference(["httpBearerAuth".into()]) // https://github.com/smithy-lang/smithy-rs/pull/4241 + .token_provider(Token::new(api_key, None)); } } let config = self.handle.block_on(config_builder.load()); + anyhow::Ok(BedrockClient::new(&config)) }) .context("initializing Bedrock client")?; @@ -1024,7 +1142,7 @@ struct ConfigurationView { access_key_id_editor: Entity, secret_access_key_editor: Entity, session_token_editor: Entity, - region_editor: Entity, + bearer_token_editor: Entity, state: Entity, load_credentials_task: Option>, focus_handle: FocusHandle, @@ -1035,7 +1153,7 @@ impl ConfigurationView { const PLACEHOLDER_SECRET_ACCESS_KEY_TEXT: &'static str = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; const PLACEHOLDER_SESSION_TOKEN_TEXT: &'static str = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; - const PLACEHOLDER_REGION: &'static str = "us-east-1"; + const PLACEHOLDER_BEARER_TOKEN_TEXT: &'static str = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; fn new(state: Entity, window: &mut Window, cx: &mut Context) -> Self { let focus_handle = cx.focus_handle(); @@ -1066,9 +1184,9 @@ impl ConfigurationView { .tab_stop(true) }); - let region_editor = cx.new(|cx| { - InputField::new(window, cx, Self::PLACEHOLDER_REGION) - .label("Region") + let bearer_token_editor = cx.new(|cx| { + InputField::new(window, cx, Self::PLACEHOLDER_BEARER_TOKEN_TEXT) + .label("Bedrock API Key") .tab_index(3) .tab_stop(true) }); @@ -1095,7 +1213,7 @@ impl ConfigurationView { access_key_id_editor, secret_access_key_editor, session_token_editor, - region_editor, + bearer_token_editor, state, load_credentials_task, focus_handle, @@ -1131,25 +1249,30 @@ impl ConfigurationView { } else { Some(session_token) }; - let region = self.region_editor.read(cx).text(cx).trim().to_string(); - let region = if region.is_empty() { - "us-east-1".to_string() + let bearer_token = self + .bearer_token_editor + .read(cx) + .text(cx) + .trim() + .to_string(); + let bearer_token = if bearer_token.is_empty() { + None } else { - region + Some(bearer_token) }; let state = self.state.clone(); cx.spawn(async move |_, cx| { state .update(cx, |state, cx| { - let credentials: BedrockCredentials = BedrockCredentials { - region: region.clone(), - access_key_id: access_key_id.clone(), - secret_access_key: secret_access_key.clone(), - session_token: session_token.clone(), + let credentials = BedrockCredentials { + access_key_id, + secret_access_key, + session_token, + bearer_token, }; - state.set_credentials(credentials, cx) + state.set_static_credentials(credentials, cx) })? .await }) @@ -1163,16 +1286,12 @@ impl ConfigurationView { .update(cx, |editor, cx| editor.set_text("", window, cx)); self.session_token_editor .update(cx, |editor, cx| editor.set_text("", window, cx)); - self.region_editor + self.bearer_token_editor .update(cx, |editor, cx| editor.set_text("", window, cx)); let state = self.state.clone(); - cx.spawn(async move |_, cx| { - state - .update(cx, |state, cx| state.reset_credentials(cx))? - .await - }) - .detach_and_log_err(cx); + cx.spawn(async move |_, cx| state.update(cx, |state, cx| state.reset_auth(cx))?.await) + .detach_and_log_err(cx); } fn should_render_editor(&self, cx: &Context) -> bool { @@ -1195,9 +1314,11 @@ impl ConfigurationView { impl Render for ConfigurationView { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { - let env_var_set = self.state.read(cx).credentials_from_env; - let bedrock_settings = self.state.read(cx).settings.as_ref(); - let bedrock_method = bedrock_settings + let state = self.state.read(cx); + let env_var_set = state.credentials_from_env; + let auth = state.auth.clone(); + let settings_auth_method = state + .settings .as_ref() .and_then(|s| s.authentication_method.clone()); @@ -1205,34 +1326,62 @@ impl Render for ConfigurationView { return div().child(Label::new("Loading credentials...")).into_any(); } - let configured_label = if env_var_set { - format!( - "Access Key ID is set in {ZED_BEDROCK_ACCESS_KEY_ID_VAR}, Secret Key is set in {ZED_BEDROCK_SECRET_ACCESS_KEY_VAR}, Region is set in {ZED_BEDROCK_REGION_VAR} environment variables." - ) - } else { - match bedrock_method { - Some(BedrockAuthMethod::Automatic) => "You are using automatic credentials.".into(), - Some(BedrockAuthMethod::NamedProfile) => "You are using named profile.".into(), - Some(BedrockAuthMethod::SingleSignOn) => { - "You are using a single sign on profile.".into() - } - None => "You are using static credentials.".into(), + let configured_label = match &auth { + Some(BedrockAuth::Automatic) => { + "Using automatic credentials (AWS default chain)".into() } + Some(BedrockAuth::NamedProfile { profile_name }) => { + format!("Using AWS profile: {profile_name}") + } + Some(BedrockAuth::SingleSignOn { profile_name }) => { + format!("Using AWS SSO profile: {profile_name}") + } + Some(BedrockAuth::IamCredentials { .. }) if env_var_set => { + format!( + "Using IAM credentials from {} and {} environment variables", + ZED_BEDROCK_ACCESS_KEY_ID_VAR.name, ZED_BEDROCK_SECRET_ACCESS_KEY_VAR.name + ) + } + Some(BedrockAuth::IamCredentials { .. }) => "Using IAM credentials".into(), + Some(BedrockAuth::ApiKey { .. }) if env_var_set => { + format!( + "Using Bedrock API Key from {} environment variable", + ZED_BEDROCK_BEARER_TOKEN_VAR.name + ) + } + Some(BedrockAuth::ApiKey { .. }) => "Using Bedrock API Key".into(), + None => "Not authenticated".into(), }; + // Determine if credentials can be reset + // Settings-derived auth (non-ApiKey) cannot be reset from UI + let is_settings_derived = matches!( + settings_auth_method, + Some(BedrockAuthMethod::Automatic) + | Some(BedrockAuthMethod::NamedProfile) + | Some(BedrockAuthMethod::SingleSignOn) + ); + let tooltip_label = if env_var_set { Some(format!( - "To reset your credentials, unset the {ZED_BEDROCK_ACCESS_KEY_ID_VAR}, {ZED_BEDROCK_SECRET_ACCESS_KEY_VAR}, and {ZED_BEDROCK_REGION_VAR} environment variables." + "To reset your credentials, unset the {}, {}, and {} or {} environment variables.", + ZED_BEDROCK_ACCESS_KEY_ID_VAR.name, + ZED_BEDROCK_SECRET_ACCESS_KEY_VAR.name, + ZED_BEDROCK_SESSION_TOKEN_VAR.name, + ZED_BEDROCK_BEARER_TOKEN_VAR.name )) - } else if bedrock_method.is_some() { - Some("You cannot reset credentials as they're being derived, check Zed settings to understand how.".to_string()) + } else if is_settings_derived { + Some( + "Authentication method is configured in settings. Edit settings.json to change." + .to_string(), + ) } else { None }; if self.should_render_editor(cx) { return ConfiguredApiCard::new(configured_label) - .disabled(env_var_set || bedrock_method.is_some()) + .disabled(env_var_set || is_settings_derived) .on_click(cx.listener(|this, _, window, cx| this.reset_credentials(window, cx))) .when_some(tooltip_label, |this, label| this.tooltip_label(label)) .into_any_element(); @@ -1262,7 +1411,7 @@ impl Render for ConfigurationView { .child(self.render_static_credentials_ui()) .child( Label::new( - format!("You can also assign the {ZED_BEDROCK_ACCESS_KEY_ID_VAR}, {ZED_BEDROCK_SECRET_ACCESS_KEY_VAR} AND {ZED_BEDROCK_REGION_VAR} environment variables and restart Zed."), + format!("You can also assign the {}, {} AND {} environment variables (or {} for Bedrock API Key authentication) and restart Zed.", ZED_BEDROCK_ACCESS_KEY_ID_VAR.name, ZED_BEDROCK_SECRET_ACCESS_KEY_VAR.name, ZED_BEDROCK_REGION_VAR.name, ZED_BEDROCK_BEARER_TOKEN_VAR.name), ) .size(LabelSize::Small) .color(Color::Muted) @@ -1270,7 +1419,7 @@ impl Render for ConfigurationView { ) .child( Label::new( - format!("Optionally, if your environment uses AWS CLI profiles, you can set {ZED_AWS_PROFILE_VAR}; if it requires a custom endpoint, you can set {ZED_AWS_ENDPOINT_VAR}; and if it requires a Session Token, you can set {ZED_BEDROCK_SESSION_TOKEN_VAR}."), + format!("Optionally, if your environment uses AWS CLI profiles, you can set {}; if it requires a custom endpoint, you can set {}; and if it requires a Session Token, you can set {}.", ZED_AWS_PROFILE_VAR.name, ZED_AWS_ENDPOINT_VAR.name, ZED_BEDROCK_SESSION_TOKEN_VAR.name), ) .size(LabelSize::Small) .color(Color::Muted), @@ -1292,31 +1441,47 @@ impl ConfigurationView { ) .child( Label::new( - "This method uses your AWS access key ID and secret access key directly.", + "This method uses your AWS access key ID and secret access key, or a Bedrock API Key.", ) ) .child( List::new() .child( ListBulletItem::new("") - .child(Label::new("Create an IAM user in the AWS console with programmatic access")) + .child(Label::new("For access keys: Create an IAM user in the AWS console with programmatic access")) .child(ButtonLink::new("IAM Console", "https://us-east-1.console.aws.amazon.com/iam/home?region=us-east-1#/users")) ) .child( ListBulletItem::new("") - .child(Label::new("Attach the necessary Bedrock permissions to this")) - .child(ButtonLink::new("user", "https://docs.aws.amazon.com/bedrock/latest/userguide/inference-prereq.html")) + .child(Label::new("For Bedrock API Keys: Generate an API key from the")) + .child(ButtonLink::new("Bedrock Console", "https://docs.aws.amazon.com/bedrock/latest/userguide/api-keys-use.html")) ) .child( - ListBulletItem::new("Copy the access key ID and secret access key when provided") + ListBulletItem::new("") + .child(Label::new("Attach the necessary Bedrock permissions to this")) + .child(ButtonLink::new("user", "https://docs.aws.amazon.com/bedrock/latest/userguide/inference-prereq.html")) ) .child( - ListBulletItem::new("Enter these credentials below") - ) + ListBulletItem::new("Enter either access keys OR a Bedrock API Key below (not both)") + ), ) .child(self.access_key_id_editor.clone()) .child(self.secret_access_key_editor.clone()) .child(self.session_token_editor.clone()) - .child(self.region_editor.clone()) + .child( + Label::new("OR") + .size(LabelSize::Default) + .weight(FontWeight::BOLD) + .my_1(), + ) + .child(self.bearer_token_editor.clone()) + .child( + Label::new( + format!("Region is configured via {} environment variable or settings.json (defaults to us-east-1).", ZED_BEDROCK_REGION_VAR.name), + ) + .size(LabelSize::Small) + .color(Color::Muted) + .mt_2(), + ) } } diff --git a/crates/settings/src/settings_content/language_model.rs b/crates/settings/src/settings_content/language_model.rs index b106f3d9925cb4afe058cff44649f998c8b73d8a..e523286e5f56af88110c2d4a7d874c22195ea2b1 100644 --- a/crates/settings/src/settings_content/language_model.rs +++ b/crates/settings/src/settings_content/language_model.rs @@ -83,6 +83,8 @@ pub enum BedrockAuthMethodContent { NamedProfile, #[serde(rename = "sso")] SingleSignOn, + #[serde(rename = "api_key")] + ApiKey, /// IMDSv2, PodIdentity, env vars, etc. #[serde(rename = "default")] Automatic, From b29e8244d5f74dd4cd34be2fff1386b51ff5e462 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yara=20=F0=9F=8F=B3=EF=B8=8F=E2=80=8D=E2=9A=A7=EF=B8=8F?= Date: Wed, 17 Dec 2025 13:06:46 +0100 Subject: [PATCH 432/621] Fix Yara's GitHub handle (#45095) Release Notes: - N/A --- REVIEWERS.conl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/REVIEWERS.conl b/REVIEWERS.conl index 45155ba3468f29062b58aa9094defc7f86110885..bca694d7a06fe1112f7f8bab158dad63a365ea74 100644 --- a/REVIEWERS.conl +++ b/REVIEWERS.conl @@ -28,7 +28,7 @@ ai = @rtfeldman audio - = @dvdsk + = @yara-blue crashes = @p1n3appl3 @@ -53,7 +53,7 @@ extension git = @cole-miller = @danilo-leal - = @dvdsk + = @yara-blue = @kubkon = @Anthony-Eid = @cameron1024 @@ -76,7 +76,7 @@ languages linux = @cole-miller - = @dvdsk + = @yara-blue = @p1n3appl3 = @probably-neb = @smitbarmase @@ -92,7 +92,7 @@ multi_buffer = @SomeoneToIgnore pickers - = @dvdsk + = @yara-blue = @p1n3appl3 = @SomeoneToIgnore From 4af26f085280f1e3a889400b443592f881081445 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Wed, 17 Dec 2025 13:42:43 +0100 Subject: [PATCH 433/621] Fix tab bar button flickering when opening menus (#45098) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #33018 ### Problem When opening a `PopoverMenu` or `RightClickMenu`, the pane's tab bar buttons would flicker (disappear for a couple frames then reappear). This happened because: 1. The menu is created and `window.focus()` was called immediately 2. However, menus are rendered using `deferred()`, so their focus handles aren't connected in the dispatch tree until after the deferred draw callback runs 3. When the pane checks `has_focus()`, it calls `contains_focused()` which walks up the focus hierarchy — but the menu's focus handle isn't linked yet 4. `has_focus()` returns false → tab bar buttons disappear 5. Next frame, the menu is rendered and linked → `has_focus()` returns true → buttons reappear ### Solution Delay the focus transfer by 2 frames using nested `on_next_frame()` calls before focusing the menu. **Why 2 frames instead of 1?** The frame lifecycle in GPUI runs `next_frame_callbacks` BEFORE `draw()`: ``` on_request_frame: 1. Run next_frame_callbacks 2. window.draw() ← menu rendered here via deferred() 3. Present ``` So: - **Frame 1**: First `on_next_frame` callback runs, queues second callback. Then `draw()` renders the menu and connects its focus handle to the dispatch tree. - **Frame 2**: Second `on_next_frame` callback runs and focuses the menu. Now the focus handle is connected (from Frame 1's draw), so `contains_focused()` returns true. With only 1 frame, the focus would happen BEFORE `draw()`, when the menu's focus handle isn't connected yet. This follows the same pattern established in b709996ec6 which fixed the identical issue for the editor's `MouseContextMenu`. --- crates/ui/src/components/popover_menu.rs | 14 +++++++++++++- crates/ui/src/components/right_click_menu.rs | 14 +++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/crates/ui/src/components/popover_menu.rs b/crates/ui/src/components/popover_menu.rs index b1a52bec8fdf1f7030b5b321bed7702d602ff212..7fdb39126b5244e367a4646c6ef6df1547a8a52f 100644 --- a/crates/ui/src/components/popover_menu.rs +++ b/crates/ui/src/components/popover_menu.rs @@ -287,7 +287,19 @@ fn show_menu( window.refresh(); }) .detach(); - window.focus(&new_menu.focus_handle(cx)); + + // Since menus are rendered in a deferred fashion, their focus handles are + // not linked in the dispatch tree until after the deferred draw callback + // runs. We need to wait for that to happen before focusing it, so that + // calling `contains_focused` on the parent's focus handle returns `true` + // when the menu is focused. This prevents the pane's tab bar buttons from + // flickering when opening popover menus. + let focus_handle = new_menu.focus_handle(cx); + window.on_next_frame(move |window, _cx| { + window.on_next_frame(move |window, _cx| { + window.focus(&focus_handle); + }); + }); *menu.borrow_mut() = Some(new_menu); window.refresh(); diff --git a/crates/ui/src/components/right_click_menu.rs b/crates/ui/src/components/right_click_menu.rs index dff423073710121bb0bc0fafdb8ab3108b746bde..5b654c295e8c9721cd38af8b4807ba5d8e6d6cb9 100644 --- a/crates/ui/src/components/right_click_menu.rs +++ b/crates/ui/src/components/right_click_menu.rs @@ -259,7 +259,19 @@ impl Element for RightClickMenu { window.refresh(); }) .detach(); - window.focus(&new_menu.focus_handle(cx)); + + // Since menus are rendered in a deferred fashion, their focus handles are + // not linked in the dispatch tree until after the deferred draw callback + // runs. We need to wait for that to happen before focusing it, so that + // calling `contains_focused` on the parent's focus handle returns `true` + // when the menu is focused. This prevents the pane's tab bar buttons from + // flickering when opening menus. + let focus_handle = new_menu.focus_handle(cx); + window.on_next_frame(move |window, _cx| { + window.on_next_frame(move |window, _cx| { + window.focus(&focus_handle); + }); + }); *menu.borrow_mut() = Some(new_menu); *position.borrow_mut() = if let Some(child_bounds) = child_bounds { if let Some(attach) = attach { From 9b8bc63524a50fba6699558df60e973961618280 Mon Sep 17 00:00:00 2001 From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Date: Wed, 17 Dec 2025 09:49:19 -0300 Subject: [PATCH 434/621] Revert "Remove CopyAsMarkdown" (#45101) Reverts https://github.com/zed-industries/zed/pull/44933. It turns out that if you're copying agent responses to paste it anywhere else that isn't the message editor (e.g., for a follow up prompt), getting Markdown formatting is helpful. However, with the revert, the underlying issue in https://github.com/zed-industries/zed/issues/42958 remains, so I'll reopen that issue, unfortunately. Release Notes: - N/A --- assets/keymaps/default-linux.json | 6 +++--- assets/keymaps/default-macos.json | 2 +- assets/keymaps/default-windows.json | 2 +- crates/markdown/src/markdown.rs | 18 ++++++++++++++++++ 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/assets/keymaps/default-linux.json b/assets/keymaps/default-linux.json index 1016a20bd6facdc8f5ef9163ebda3e03d451c5cf..f09ac0a812c3e875618c57da15bcf16e1f983d6e 100644 --- a/assets/keymaps/default-linux.json +++ b/assets/keymaps/default-linux.json @@ -264,9 +264,9 @@ { "context": "AgentPanel > Markdown", "bindings": { - "copy": "markdown::Copy", - "ctrl-insert": "markdown::Copy", - "ctrl-c": "markdown::Copy", + "copy": "markdown::CopyAsMarkdown", + "ctrl-insert": "markdown::CopyAsMarkdown", + "ctrl-c": "markdown::CopyAsMarkdown", }, }, { diff --git a/assets/keymaps/default-macos.json b/assets/keymaps/default-macos.json index c80edf01a02347cf678fe9cb24390f2fca41d70e..1d489771febc770e300b63e265024ffca3d14a90 100644 --- a/assets/keymaps/default-macos.json +++ b/assets/keymaps/default-macos.json @@ -306,7 +306,7 @@ "context": "AgentPanel > Markdown", "use_key_equivalents": true, "bindings": { - "cmd-c": "markdown::Copy", + "cmd-c": "markdown::CopyAsMarkdown", }, }, { diff --git a/assets/keymaps/default-windows.json b/assets/keymaps/default-windows.json index dcc828ddf2ef63f3fef6e7e12d9349bead57572e..9154cc43afb86c287329229c6f0d699f59a82b36 100644 --- a/assets/keymaps/default-windows.json +++ b/assets/keymaps/default-windows.json @@ -267,7 +267,7 @@ "context": "AgentPanel > Markdown", "use_key_equivalents": true, "bindings": { - "ctrl-c": "markdown::Copy", + "ctrl-c": "markdown::CopyAsMarkdown", }, }, { diff --git a/crates/markdown/src/markdown.rs b/crates/markdown/src/markdown.rs index 3654418e419bb58f5c9c29ac1baf7172a423156f..706fe894699afe8d1ae32c0525214ec6bf614912 100644 --- a/crates/markdown/src/markdown.rs +++ b/crates/markdown/src/markdown.rs @@ -151,6 +151,8 @@ actions!( [ /// Copies the selected text to the clipboard. Copy, + /// Copies the selected text as markdown to the clipboard. + CopyAsMarkdown ] ); @@ -295,6 +297,14 @@ impl Markdown { cx.write_to_clipboard(ClipboardItem::new_string(text)); } + fn copy_as_markdown(&self, _: &mut Window, cx: &mut Context) { + if self.selection.end <= self.selection.start { + return; + } + let text = self.source[self.selection.start..self.selection.end].to_string(); + cx.write_to_clipboard(ClipboardItem::new_string(text)); + } + fn parse(&mut self, cx: &mut Context) { if self.source.is_empty() { return; @@ -1356,6 +1366,14 @@ impl Element for MarkdownElement { } } }); + window.on_action(std::any::TypeId::of::(), { + let entity = self.markdown.clone(); + move |_, phase, window, cx| { + if phase == DispatchPhase::Bubble { + entity.update(cx, move |this, cx| this.copy_as_markdown(window, cx)) + } + } + }); self.paint_mouse_listeners(hitbox, &rendered_markdown.text, window, cx); rendered_markdown.element.paint(window, cx); From acae823fb10d27b0a8b324df64fc0218f63adf06 Mon Sep 17 00:00:00 2001 From: Aero Date: Wed, 17 Dec 2025 21:22:17 +0800 Subject: [PATCH 435/621] agent_ui: Add regeneration button to text and agent thread titles (#43859) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Screenshot 2025-12-17 at 10  10@2x Release Notes: - agent: Added the ability to regenerate the auto-summarized title of threads to the "Regenerate Thread Title" button available the ellipsis menu of the agent panel. --------- Co-authored-by: Danilo Leal --- crates/agent/src/thread.rs | 6 +- crates/agent_ui/src/acp/thread_view.rs | 11 +++ crates/agent_ui/src/agent_panel.rs | 112 ++++++++++++++++++++++++- 3 files changed, 125 insertions(+), 4 deletions(-) diff --git a/crates/agent/src/thread.rs b/crates/agent/src/thread.rs index f8f46af5fe2bbea5888ded6e24495afee71680dd..ef3ca23c3caf816a28e91e9e75b21f2cc80451e7 100644 --- a/crates/agent/src/thread.rs +++ b/crates/agent/src/thread.rs @@ -1725,6 +1725,10 @@ impl Thread { self.pending_summary_generation.is_some() } + pub fn is_generating_title(&self) -> bool { + self.pending_title_generation.is_some() + } + pub fn summary(&mut self, cx: &mut Context) -> Shared>> { if let Some(summary) = self.summary.as_ref() { return Task::ready(Some(summary.clone())).shared(); @@ -1792,7 +1796,7 @@ impl Thread { task } - fn generate_title(&mut self, cx: &mut Context) { + pub fn generate_title(&mut self, cx: &mut Context) { let Some(model) = self.summarization_model.clone() else { return; }; diff --git a/crates/agent_ui/src/acp/thread_view.rs b/crates/agent_ui/src/acp/thread_view.rs index 05162348db060bff05aa7b1dd223815895f02e2d..e7c40db7118468ae9d43bb5976992d05b745f182 100644 --- a/crates/agent_ui/src/acp/thread_view.rs +++ b/crates/agent_ui/src/acp/thread_view.rs @@ -1898,6 +1898,17 @@ impl AcpThreadView { }) } + pub fn has_user_submitted_prompt(&self, cx: &App) -> bool { + self.thread().is_some_and(|thread| { + thread.read(cx).entries().iter().any(|entry| { + matches!( + entry, + AgentThreadEntry::UserMessage(user_message) if user_message.id.is_some() + ) + }) + }) + } + fn authorize_tool_call( &mut self, tool_call_id: acp::ToolCallId, diff --git a/crates/agent_ui/src/agent_panel.rs b/crates/agent_ui/src/agent_panel.rs index ff8cf8db969e9ef2d1d86b306c0f38fb66a67fde..071283e7224f08efd0f8df2cdf7a1aca63419081 100644 --- a/crates/agent_ui/src/agent_panel.rs +++ b/crates/agent_ui/src/agent_panel.rs @@ -1749,8 +1749,13 @@ impl AgentPanel { let content = match &self.active_view { ActiveView::ExternalAgentThread { thread_view } => { + let is_generating_title = thread_view + .read(cx) + .as_native_thread(cx) + .map_or(false, |t| t.read(cx).is_generating_title()); + if let Some(title_editor) = thread_view.read(cx).title_editor() { - div() + let container = div() .w_full() .on_action({ let thread_view = thread_view.downgrade(); @@ -1768,8 +1773,21 @@ impl AgentPanel { } } }) - .child(title_editor) - .into_any_element() + .child(title_editor); + + if is_generating_title { + container + .with_animation( + "generating_title", + Animation::new(Duration::from_secs(2)) + .repeat() + .with_easing(pulsating_between(0.4, 0.8)), + |div, delta| div.opacity(delta), + ) + .into_any_element() + } else { + container.into_any_element() + } } else { Label::new(thread_view.read(cx).title(cx)) .color(Color::Muted) @@ -1799,6 +1817,13 @@ impl AgentPanel { Label::new(LOADING_SUMMARY_PLACEHOLDER) .truncate() .color(Color::Muted) + .with_animation( + "generating_title", + Animation::new(Duration::from_secs(2)) + .repeat() + .with_easing(pulsating_between(0.4, 0.8)), + |label, delta| label.alpha(delta), + ) .into_any_element() } } @@ -1842,6 +1867,25 @@ impl AgentPanel { .into_any() } + fn handle_regenerate_thread_title(thread_view: Entity, cx: &mut App) { + thread_view.update(cx, |thread_view, cx| { + if let Some(thread) = thread_view.as_native_thread(cx) { + thread.update(cx, |thread, cx| { + thread.generate_title(cx); + }); + } + }); + } + + fn handle_regenerate_text_thread_title( + text_thread_editor: Entity, + cx: &mut App, + ) { + text_thread_editor.update(cx, |text_thread_editor, cx| { + text_thread_editor.regenerate_summary(cx); + }); + } + fn render_panel_options_menu( &self, window: &mut Window, @@ -1861,6 +1905,35 @@ impl AgentPanel { let selected_agent = self.selected_agent.clone(); + let text_thread_view = match &self.active_view { + ActiveView::TextThread { + text_thread_editor, .. + } => Some(text_thread_editor.clone()), + _ => None, + }; + let text_thread_with_messages = match &self.active_view { + ActiveView::TextThread { + text_thread_editor, .. + } => text_thread_editor + .read(cx) + .text_thread() + .read(cx) + .messages(cx) + .any(|message| message.role == language_model::Role::Assistant), + _ => false, + }; + + let thread_view = match &self.active_view { + ActiveView::ExternalAgentThread { thread_view } => Some(thread_view.clone()), + _ => None, + }; + let thread_with_messages = match &self.active_view { + ActiveView::ExternalAgentThread { thread_view } => { + thread_view.read(cx).has_user_submitted_prompt(cx) + } + _ => false, + }; + PopoverMenu::new("agent-options-menu") .trigger_with_tooltip( IconButton::new("agent-options-menu", IconName::Ellipsis) @@ -1883,6 +1956,7 @@ impl AgentPanel { 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()) @@ -1920,6 +1994,38 @@ impl AgentPanel { .separator() } + if thread_with_messages | text_thread_with_messages { + menu = menu.header("Current Thread"); + + if let Some(text_thread_view) = text_thread_view.as_ref() { + menu = menu + .entry("Regenerate Thread Title", None, { + let text_thread_view = text_thread_view.clone(); + move |_, cx| { + Self::handle_regenerate_text_thread_title( + text_thread_view.clone(), + cx, + ); + } + }) + .separator(); + } + + if let Some(thread_view) = thread_view.as_ref() { + menu = menu + .entry("Regenerate Thread Title", None, { + let thread_view = thread_view.clone(); + move |_, cx| { + Self::handle_regenerate_thread_title( + thread_view.clone(), + cx, + ); + } + }) + .separator(); + } + } + menu = menu .header("MCP Servers") .action( From 71e8b5504cd0432832e87460ef10cd00940b8489 Mon Sep 17 00:00:00 2001 From: Bennet Bo Fenner Date: Wed, 17 Dec 2025 14:25:48 +0100 Subject: [PATCH 436/621] nightly: Temporarly delete commit message prompt from rules library (#45106) Relevant for Nightly Users only, follow up to #45004. In case you use nightly this will break preview/stable since deserialisation will fail. Shipping this to Nightly so that staff does not run into this issue. We can revert this PR in the following days. I'll make a follow up PR which only stores the prompt in the database in case you customise it. Release Notes: - N/A --- crates/prompt_store/src/prompt_store.rs | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/crates/prompt_store/src/prompt_store.rs b/crates/prompt_store/src/prompt_store.rs index 6417a7ad214c84258d4cc18eddc0b1c1d785ca18..7823f7a6957caf282f4ad7f1d6f884971364518e 100644 --- a/crates/prompt_store/src/prompt_store.rs +++ b/crates/prompt_store/src/prompt_store.rs @@ -199,24 +199,8 @@ impl PromptStore { let metadata = db_env.create_database(&mut txn, Some("metadata.v2"))?; let bodies = db_env.create_database(&mut txn, Some("bodies.v2"))?; - // Insert default commit message prompt if not present - if metadata.get(&txn, &PromptId::CommitMessage)?.is_none() { - metadata.put( - &mut txn, - &PromptId::CommitMessage, - &PromptMetadata { - id: PromptId::CommitMessage, - title: Some("Git Commit Message".into()), - default: false, - saved_at: Utc::now(), - }, - )?; - } - if bodies.get(&txn, &PromptId::CommitMessage)?.is_none() { - let commit_message_prompt = - include_str!("../../git_ui/src/commit_message_prompt.txt"); - bodies.put(&mut txn, &PromptId::CommitMessage, commit_message_prompt)?; - } + metadata.delete(&mut txn, &PromptId::CommitMessage)?; + bodies.delete(&mut txn, &PromptId::CommitMessage)?; txn.commit()?; From 1b24b442c6d44437a896b8537d0200c3716ef319 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Eriksson?= Date: Wed, 17 Dec 2025 15:16:37 +0100 Subject: [PATCH 437/621] docs: Add Tailwind configuration section for JavaScript/TypeScript (#45057) Addresses some tasks in #43969. Namely adding TailwindCSS documentation for the following languages: HTML, JavaScript and Typescript. **Some Notes** - Maybe the additional information in the HTML section is unnecessary, unsure open to suggestions. - I tried utilizing capturing groups with alternatives like `\\.(add|remove|toggle|contains)` but this didn't seem to work, so I was forced to use multiple lines. Release Notes: - N/A --------- Co-authored-by: Danilo Leal --- docs/src/languages/javascript.md | 30 +++++++++++++++++++++++++++++- docs/src/languages/ruby.md | 11 ++--------- docs/src/languages/tailwindcss.md | 30 ++++++++++++++++-------------- docs/src/languages/typescript.md | 30 +++++++++++++++++++++++++++++- 4 files changed, 76 insertions(+), 25 deletions(-) diff --git a/docs/src/languages/javascript.md b/docs/src/languages/javascript.md index 1b87dac5553f0dc44153d4706be1dd4bd2e341d5..f043c642b305a8dba2b0985a75954438bb024c4c 100644 --- a/docs/src/languages/javascript.md +++ b/docs/src/languages/javascript.md @@ -175,6 +175,34 @@ You can configure ESLint's `workingDirectory` setting: } ``` +## Using the Tailwind CSS Language Server with JavaScript + +To get all the features (autocomplete, linting, etc.) from the [Tailwind CSS language server](https://github.com/tailwindlabs/tailwindcss-intellisense/tree/HEAD/packages/tailwindcss-language-server#readme) in vanilla JavaScript files (`.js`), you can customize the `classRegex` field under it in your `settings.json`: + +```json [settings] +{ + "lsp": { + "tailwindcss-language-server": { + "settings": { + "experimental": { + "classRegex": [ + "\\.className\\s*[+]?=\\s*['\"]([^'\"]*)['\"]", + "\\.setAttributeNS\\(.*,\\s*['\"]class['\"],\\s*['\"]([^'\"]*)['\"]", + "\\.setAttribute\\(['\"]class['\"],\\s*['\"]([^'\"]*)['\"]", + "\\.classList\\.add\\(['\"]([^'\"]*)['\"]", + "\\.classList\\.remove\\(['\"]([^'\"]*)['\"]", + "\\.classList\\.toggle\\(['\"]([^'\"]*)['\"]", + "\\.classList\\.contains\\(['\"]([^'\"]*)['\"]", + "\\.classList\\.replace\\(\\s*['\"]([^'\"]*)['\"]", + "\\.classList\\.replace\\([^,)]+,\\s*['\"]([^'\"]*)['\"]" + ] + } + } + } + } +} +``` + ## Debugging Zed supports debugging JavaScript code out of the box with `vscode-js-debug`. @@ -186,7 +214,7 @@ The following can be debugged without writing additional configuration: Run {#action debugger::Start} ({#kb debugger::Start}) to see a contextual list of these predefined debug tasks. > **Note:** Bun test is automatically detected when `@types/bun` is present in `package.json`. -> + > **Note:** Node test is automatically detected when `@types/node` is present in `package.json` (requires Node.js 20+). As for all languages, configurations from `.vscode/launch.json` are also available for debugging in Zed. diff --git a/docs/src/languages/ruby.md b/docs/src/languages/ruby.md index 7e072ac5d32ab990584a2c2b0be57eb3076b1ec9..f7f0ccce83354fb24372f6916f27c63156f8cb3c 100644 --- a/docs/src/languages/ruby.md +++ b/docs/src/languages/ruby.md @@ -258,17 +258,10 @@ To enable Steep, add `\"steep\"` to the `language_servers` list for Ruby in your ## Using the Tailwind CSS Language Server with Ruby -It's possible to use the [Tailwind CSS Language Server](https://github.com/tailwindlabs/tailwindcss-intellisense/tree/HEAD/packages/tailwindcss-language-server#readme) in Ruby and ERB files. - -In order to do that, you need to configure the language server so that it knows about where to look for CSS classes in Ruby/ERB files by adding the following to your `settings.json`: +To get all the features (autocomplete, linting, etc.) from the [Tailwind CSS language server](https://github.com/tailwindlabs/tailwindcss-intellisense/tree/HEAD/packages/tailwindcss-language-server#readme) in Ruby/ERB files, you need to configure the language server so that it knows about where to look for CSS classes by adding the following to your `settings.json`: ```json [settings] { - "languages": { - "Ruby": { - "language_servers": ["tailwindcss-language-server", "..."] - } - }, "lsp": { "tailwindcss-language-server": { "settings": { @@ -281,7 +274,7 @@ In order to do that, you need to configure the language server so that it knows } ``` -With these settings you will get completions for Tailwind CSS classes in HTML attributes inside ERB files and inside Ruby/ERB strings that are coming after a `class:` key. Examples: +With these settings, you will get completions for Tailwind CSS classes in HTML attributes inside ERB files and inside Ruby/ERB strings that are coming after a `class:` key. Examples: ```rb # Ruby file: diff --git a/docs/src/languages/tailwindcss.md b/docs/src/languages/tailwindcss.md index be9c9437d1382dfd356120663ebea2c1fe012684..457c71f9768610f5bfdf345e72c27311632f1bef 100644 --- a/docs/src/languages/tailwindcss.md +++ b/docs/src/languages/tailwindcss.md @@ -4,9 +4,23 @@ Zed has built-in support for Tailwind CSS autocomplete, linting, and hover previ - Language Server: [tailwindlabs/tailwindcss-intellisense](https://github.com/tailwindlabs/tailwindcss-intellisense) +Languages which can be used with Tailwind CSS in Zed: + +- [Astro](./astro.md) +- [CSS](./css.md) +- [ERB](./ruby.md) +- [Gleam](./gleam.md) +- [HEEx](./elixir.md#heex) +- [HTML](./html.md) +- [TypeScript](./typescript.md) +- [JavaScript](./javascript.md) +- [PHP](./php.md) +- [Svelte](./svelte.md) +- [Vue](./vue.md) + ## Configuration -To configure the Tailwind CSS language server, refer [to the extension settings](https://github.com/tailwindlabs/tailwindcss-intellisense?tab=readme-ov-file#extension-settings) and add them to the `lsp` section of your `settings.json`: +If by default the language server isn't enough to make Tailwind work for a given language, you can configure the language server settings and add them to the `lsp` section of your `settings.json`: ```json [settings] { @@ -23,19 +37,7 @@ To configure the Tailwind CSS language server, refer [to the extension settings] } ``` -Languages which can be used with Tailwind CSS in Zed: - -- [Astro](./astro.md) -- [CSS](./css.md) -- [ERB](./ruby.md) -- [Gleam](./gleam.md) -- [HEEx](./elixir.md#heex) -- [HTML](./html.md) -- [TypeScript](./typescript.md) -- [JavaScript](./javascript.md) -- [PHP](./php.md) -- [Svelte](./svelte.md) -- [Vue](./vue.md) +Refer to [the Tailwind CSS language server settings docs](https://github.com/tailwindlabs/tailwindcss-intellisense?tab=readme-ov-file#extension-settings) for more information. ### Prettier Plugin diff --git a/docs/src/languages/typescript.md b/docs/src/languages/typescript.md index a6ec5b71ecb1815aeb4ff3811eec6f9a5c57a54b..d4fccc38f8a460e9ec097dee249a6441bd34a344 100644 --- a/docs/src/languages/typescript.md +++ b/docs/src/languages/typescript.md @@ -45,6 +45,34 @@ Prettier will also be used for TypeScript files by default. To disable this: } ``` +## Using the Tailwind CSS Language Server with TypeScript + +To get all the features (autocomplete, linting, etc.) from the [Tailwind CSS language server](https://github.com/tailwindlabs/tailwindcss-intellisense/tree/HEAD/packages/tailwindcss-language-server#readme) in vanilla TypeScript files (`.ts`), you can customize the `classRegex` field under it in your `settings.json`: + +```json [settings] +{ + "lsp": { + "tailwindcss-language-server": { + "settings": { + "experimental": { + "classRegex": [ + "\\.className\\s*[+]?=\\s*['\"]([^'\"]*)['\"]", + "\\.setAttributeNS\\(.*,\\s*['\"]class['\"],\\s*['\"]([^'\"]*)['\"]", + "\\.setAttribute\\(['\"]class['\"],\\s*['\"]([^'\"]*)['\"]", + "\\.classList\\.add\\(['\"]([^'\"]*)['\"]", + "\\.classList\\.remove\\(['\"]([^'\"]*)['\"]", + "\\.classList\\.toggle\\(['\"]([^'\"]*)['\"]", + "\\.classList\\.contains\\(['\"]([^'\"]*)['\"]", + "\\.classList\\.replace\\(\\s*['\"]([^'\"]*)['\"]", + "\\.classList\\.replace\\([^,)]+,\\s*['\"]([^'\"]*)['\"]" + ] + } + } + } + } +} +``` + ## Large projects `vtsls` may run out of memory on very large projects. We default the limit to 8092 (8 GiB) vs. the default of 3072 but this may not be sufficient for you: @@ -167,7 +195,7 @@ The following can be debugged without writing additional configuration: Run {#action debugger::Start} ({#kb debugger::Start}) to see a contextual list of these predefined debug tasks. > **Note:** Bun test is automatically detected when `@types/bun` is present in `package.json`. -> + > **Note:** Node test is automatically detected when `@types/node` is present in `package.json` (requires Node.js 20+). As for all languages, configurations from `.vscode/launch.json` are also available for debugging in Zed. From 0c304c0e1b7d72ce1e81242ba0df2ab99754088d Mon Sep 17 00:00:00 2001 From: Gaauwe Rombouts Date: Wed, 17 Dec 2025 15:19:01 +0100 Subject: [PATCH 438/621] lsp: Persist vtsls update imports on rename choice (#45105) Closes #35930 When a TypeScript file is renamed or moved, vtsls can automatically update the imports in other files. It pops up a message with the option to always automatically update imports. This choice would previously only be remembered for the current session and would pop up again after a restart. Now we persist that choice to the vtsls LSP settings in Zed, so that it remembers across editor sessions. Release Notes: - When renaming a TypeScript or JavaScript file, the selected option to automatically update imports will now be remembered across editor sessions. --- crates/language/src/language.rs | 20 ++++++++++++ crates/languages/src/vtsls.rs | 57 ++++++++++++++++++++++++++++++++- crates/project/src/lsp_store.rs | 11 +++++++ 3 files changed, 87 insertions(+), 1 deletion(-) diff --git a/crates/language/src/language.rs b/crates/language/src/language.rs index eceb68f3e578fda97af292fee395a8ac4f0829c9..a573e3d78a4de03c6ccf382c80bc33eaf0b5690d 100644 --- a/crates/language/src/language.rs +++ b/crates/language/src/language.rs @@ -330,6 +330,10 @@ impl CachedLspAdapter { .cloned() .unwrap_or_else(|| language_name.lsp_id()) } + + pub fn process_prompt_response(&self, context: &PromptResponseContext, cx: &mut AsyncApp) { + self.adapter.process_prompt_response(context, cx) + } } /// [`LspAdapterDelegate`] allows [`LspAdapter]` implementations to interface with the application @@ -355,6 +359,17 @@ pub trait LspAdapterDelegate: Send + Sync { async fn try_exec(&self, binary: LanguageServerBinary) -> Result<()>; } +/// Context provided to LSP adapters when a user responds to a ShowMessageRequest prompt. +/// This allows adapters to intercept preference selections (like "Always" or "Never") +/// and potentially persist them to Zed's settings. +#[derive(Debug, Clone)] +pub struct PromptResponseContext { + /// The original message shown to the user + pub message: String, + /// The action (button) the user selected + pub selected_action: lsp::MessageActionItem, +} + #[async_trait(?Send)] pub trait LspAdapter: 'static + Send + Sync + DynLspInstaller { fn name(&self) -> LanguageServerName; @@ -511,6 +526,11 @@ pub trait LspAdapter: 'static + Send + Sync + DynLspInstaller { fn is_extension(&self) -> bool { false } + + /// Called when a user responds to a ShowMessageRequest from this language server. + /// This allows adapters to intercept preference selections (like "Always" or "Never") + /// for settings that should be persisted to Zed's settings file. + fn process_prompt_response(&self, _context: &PromptResponseContext, _cx: &mut AsyncApp) {} } pub trait LspInstaller { diff --git a/crates/languages/src/vtsls.rs b/crates/languages/src/vtsls.rs index 3d38e022afe06f79d7e555263183a948c941f337..29b21a7cd80f1f0457e7720d68a6fb37954a02c5 100644 --- a/crates/languages/src/vtsls.rs +++ b/crates/languages/src/vtsls.rs @@ -2,13 +2,17 @@ use anyhow::Result; use async_trait::async_trait; use collections::HashMap; use gpui::AsyncApp; -use language::{LanguageName, LspAdapter, LspAdapterDelegate, LspInstaller, Toolchain}; +use language::{ + LanguageName, LspAdapter, LspAdapterDelegate, LspInstaller, PromptResponseContext, Toolchain, +}; use lsp::{CodeActionKind, LanguageServerBinary, LanguageServerName, Uri}; use node_runtime::{NodeRuntime, VersionStrategy}; use project::{Fs, lsp_store::language_server_settings}; use regex::Regex; use semver::Version; use serde_json::Value; +use serde_json::json; +use settings::update_settings_file; use std::{ ffi::OsString, path::{Path, PathBuf}, @@ -16,6 +20,11 @@ use std::{ }; use util::{ResultExt, maybe, merge_json_value_into}; +const ACTION_ALWAYS: &str = "Always"; +const ACTION_NEVER: &str = "Never"; +const UPDATE_IMPORTS_MESSAGE_PATTERN: &str = "Update imports for"; +const VTSLS_SERVER_NAME: &str = "vtsls"; + fn typescript_server_binary_arguments(server_path: &Path) -> Vec { vec![server_path.into(), "--stdio".into()] } @@ -302,6 +311,52 @@ impl LspAdapter for VtslsLspAdapter { (LanguageName::new_static("TSX"), "typescriptreact".into()), ]) } + + fn process_prompt_response(&self, context: &PromptResponseContext, cx: &mut AsyncApp) { + let selected_title = context.selected_action.title.as_str(); + let is_preference_response = + selected_title == ACTION_ALWAYS || selected_title == ACTION_NEVER; + if !is_preference_response { + return; + } + + if context.message.contains(UPDATE_IMPORTS_MESSAGE_PATTERN) { + let setting_value = match selected_title { + ACTION_ALWAYS => "always", + ACTION_NEVER => "never", + _ => return, + }; + + let settings = json!({ + "typescript": { + "updateImportsOnFileMove": { + "enabled": setting_value + } + }, + "javascript": { + "updateImportsOnFileMove": { + "enabled": setting_value + } + } + }); + + let _ = cx.update(|cx| { + update_settings_file(self.fs.clone(), cx, move |content, _| { + let lsp_settings = content + .project + .lsp + .entry(VTSLS_SERVER_NAME.into()) + .or_default(); + + if let Some(existing) = &mut lsp_settings.settings { + merge_json_value_into(settings, existing); + } else { + lsp_settings.settings = Some(settings); + } + }); + }); + } + } } async fn get_cached_ts_server_binary( diff --git a/crates/project/src/lsp_store.rs b/crates/project/src/lsp_store.rs index 9b3eeebed79724196290738b51376e412ca11b22..f3ebac277b027232d2043213aa393492dbc1dfdb 100644 --- a/crates/project/src/lsp_store.rs +++ b/crates/project/src/lsp_store.rs @@ -1056,12 +1056,15 @@ impl LocalLspStore { .on_request::({ let this = lsp_store.clone(); let name = name.to_string(); + let adapter = adapter.clone(); move |params, cx| { let this = this.clone(); let name = name.to_string(); + let adapter = adapter.clone(); let mut cx = cx.clone(); async move { let actions = params.actions.unwrap_or_default(); + let message = params.message.clone(); let (tx, rx) = smol::channel::bounded(1); let request = LanguageServerPromptRequest { level: match params.typ { @@ -1082,6 +1085,14 @@ impl LocalLspStore { .is_ok(); if did_update { let response = rx.recv().await.ok(); + if let Some(ref selected_action) = response { + let context = language::PromptResponseContext { + message, + selected_action: selected_action.clone(), + }; + adapter.process_prompt_response(&context, &mut cx) + } + Ok(response) } else { Ok(None) From c186877ff740c41a225c268f9c0bd47496d2acb2 Mon Sep 17 00:00:00 2001 From: Gaauwe Rombouts Date: Wed, 17 Dec 2025 15:29:48 +0100 Subject: [PATCH 439/621] lsp: Open updated imports in multibuffer after file rename (#45110) Fixes an issue where we would update the imports after a file rename in TypeScript, but those changes wouldn't surface anywhere until those buffers were manually opened (https://github.com/zed-industries/zed/issues/35930#issuecomment-3366852945). In https://github.com/zed-industries/zed/pull/36681 we already added support for opening a multibuffer with edits, but vtsls has a different flow for renames. Release Notes: - Files with updated imports now open in a multibuffer when renaming or moving TypeScript or JavaScript files --- crates/editor/src/editor.rs | 114 +++++++++++++++++++++----------- crates/project/src/lsp_store.rs | 5 +- crates/project/src/project.rs | 4 ++ 3 files changed, 82 insertions(+), 41 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 4072b1db7a1935e5dbb9c63d2a3aa19db270f131..a66d92ceb8b0b6fa1631d0636294fbe3bd42af06 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -2063,46 +2063,34 @@ impl Editor { }) }); }); - let edited_buffers_already_open = { - let other_editors: Vec> = workspace - .read(cx) - .panes() - .iter() - .flat_map(|pane| pane.read(cx).items_of_type::()) - .filter(|editor| editor.entity_id() != cx.entity_id()) - .collect(); - - transaction.0.keys().all(|buffer| { - other_editors.iter().any(|editor| { - let multi_buffer = editor.read(cx).buffer(); - multi_buffer.read(cx).is_singleton() - && multi_buffer.read(cx).as_singleton().map_or( - false, - |singleton| { - singleton.entity_id() == buffer.entity_id() - }, - ) - }) - }) - }; - if !edited_buffers_already_open { - let workspace = workspace.downgrade(); - let transaction = transaction.clone(); - cx.defer_in(window, move |_, window, cx| { - cx.spawn_in(window, async move |editor, cx| { - Self::open_project_transaction( - &editor, - workspace, - transaction, - "Rename".to_string(), - cx, - ) - .await - .ok() - }) - .detach(); - }); - } + + Self::open_transaction_for_hidden_buffers( + workspace, + transaction.clone(), + "Rename".to_string(), + window, + cx, + ); + } + } + + project::Event::WorkspaceEditApplied(transaction) => { + let Some(workspace) = editor.workspace() else { + return; + }; + let Some(active_editor) = workspace.read(cx).active_item_as::(cx) + else { + return; + }; + + if active_editor.entity_id() == cx.entity_id() { + Self::open_transaction_for_hidden_buffers( + workspace, + transaction.clone(), + "LSP Edit".to_string(), + window, + cx, + ); } } @@ -6672,6 +6660,52 @@ impl Editor { } } + fn open_transaction_for_hidden_buffers( + workspace: Entity, + transaction: ProjectTransaction, + title: String, + window: &mut Window, + cx: &mut Context, + ) { + if transaction.0.is_empty() { + return; + } + + let edited_buffers_already_open = { + let other_editors: Vec> = workspace + .read(cx) + .panes() + .iter() + .flat_map(|pane| pane.read(cx).items_of_type::()) + .filter(|editor| editor.entity_id() != cx.entity_id()) + .collect(); + + transaction.0.keys().all(|buffer| { + other_editors.iter().any(|editor| { + let multi_buffer = editor.read(cx).buffer(); + multi_buffer.read(cx).is_singleton() + && multi_buffer + .read(cx) + .as_singleton() + .map_or(false, |singleton| { + singleton.entity_id() == buffer.entity_id() + }) + }) + }) + }; + if !edited_buffers_already_open { + let workspace = workspace.downgrade(); + cx.defer_in(window, move |_, window, cx| { + cx.spawn_in(window, async move |editor, cx| { + Self::open_project_transaction(&editor, workspace, transaction, title, cx) + .await + .ok() + }) + .detach(); + }); + } + } + pub async fn open_project_transaction( editor: &WeakEntity, workspace: WeakEntity, diff --git a/crates/project/src/lsp_store.rs b/crates/project/src/lsp_store.rs index f3ebac277b027232d2043213aa393492dbc1dfdb..6696ec8c4c280199a55d098ab63a321f126eea5e 100644 --- a/crates/project/src/lsp_store.rs +++ b/crates/project/src/lsp_store.rs @@ -3311,8 +3311,10 @@ impl LocalLspStore { ) .await .log_err(); - this.update(cx, |this, _| { + this.update(cx, |this, cx| { if let Some(transaction) = transaction { + cx.emit(LspStoreEvent::WorkspaceEditApplied(transaction.clone())); + this.as_local_mut() .unwrap() .last_workspace_edits_by_language_server @@ -3852,6 +3854,7 @@ pub enum LspStoreEvent { edits: Vec<(lsp::Range, Snippet)>, most_recent_edit: clock::Lamport, }, + WorkspaceEditApplied(ProjectTransaction), } #[derive(Clone, Debug, Serialize)] diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index 9152096508b76d34fe3b2209cba94b4755b6ac67..b348fcdae2c414aa1b3f34f616ca3426899fe1d3 100644 --- a/crates/project/src/project.rs +++ b/crates/project/src/project.rs @@ -350,6 +350,7 @@ pub enum Event { SnippetEdit(BufferId, Vec<(lsp::Range, Snippet)>), ExpandedAllForEntry(WorktreeId, ProjectEntryId), EntryRenamed(ProjectTransaction, ProjectPath, PathBuf), + WorkspaceEditApplied(ProjectTransaction), AgentLocationChanged, } @@ -3249,6 +3250,9 @@ impl Project { cx.emit(Event::SnippetEdit(*buffer_id, edits.clone())) } } + LspStoreEvent::WorkspaceEditApplied(transaction) => { + cx.emit(Event::WorkspaceEditApplied(transaction.clone())) + } } } From a16f0712c8b4a1c63bdc919aca5780af25e4469c Mon Sep 17 00:00:00 2001 From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Date: Wed, 17 Dec 2025 11:36:01 -0300 Subject: [PATCH 440/621] agent_ui: Fix double axis scroll in the edited files list (#45116) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, the list of edit files had a double axis scroll issue because the list itself scrolled vertically and each file row would scroll horizontally, causing a bad UX. The horizontal scroll intention was so that you could see the whole path, but I've included it in the tooltip in case it becomes obscured due to a small panel width. Screenshot 2025-12-17 at 11  24@2x Release Notes: - agent: N/A --- crates/agent_ui/src/acp/thread_view.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/crates/agent_ui/src/acp/thread_view.rs b/crates/agent_ui/src/acp/thread_view.rs index e7c40db7118468ae9d43bb5976992d05b745f182..63f0054ab7e1d25145974c3862ec7361007bace6 100644 --- a/crates/agent_ui/src/acp/thread_view.rs +++ b/crates/agent_ui/src/acp/thread_view.rs @@ -4121,6 +4121,8 @@ impl AcpThreadView { .ml_1p5() }); + let full_path = path.display(path_style).to_string(); + let file_icon = FileIcons::get_icon(path.as_std_path(), cx) .map(Icon::from_path) .map(|icon| icon.color(Color::Muted).size(IconSize::Small)) @@ -4154,7 +4156,6 @@ impl AcpThreadView { .relative() .pr_8() .w_full() - .overflow_x_scroll() .child( h_flex() .id(("file-name-path", index)) @@ -4166,7 +4167,14 @@ impl AcpThreadView { .child(file_icon) .children(file_name) .children(file_path) - .tooltip(Tooltip::text("Go to File")) + .tooltip(move |_, cx| { + Tooltip::with_meta( + "Go to File", + None, + full_path.clone(), + cx, + ) + }) .on_click({ let buffer = buffer.clone(); cx.listener(move |this, _, window, cx| { From 5b8e4e58c5f548ff1eda6ccd57997e2fda89e4b6 Mon Sep 17 00:00:00 2001 From: Remco Smits Date: Wed, 17 Dec 2025 16:31:36 +0100 Subject: [PATCH 441/621] git_ui: Fix select first entry selects the wrong visual first entry when tree view is enabled (#45108) This PR fixes a bug where the select first didn't select the first visual entry when the first entry is a collapsed directory. Follow-up: https://github.com/zed-industries/zed/pull/45030 **Before**: https://github.com/user-attachments/assets/5e5865cc-ec0f-471d-a81b-9521fb70df41 **After**: https://github.com/user-attachments/assets/05562572-e43f-4d1e-9638-80e4dccc0998 Release Notes: - git_ui: Fix select first entry selects the wrong visual first entry when tree view is enabled --- crates/git_ui/src/git_panel.rs | 42 ++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs index 1426ed1e65412da5cb8be22e7592e5a42917b367..cc9227093034ac0fa42b55324c0c2ab74a44903e 100644 --- a/crates/git_ui/src/git_panel.rs +++ b/crates/git_ui/src/git_panel.rs @@ -279,6 +279,13 @@ impl GitListEntry { _ => None, } } + + fn directory_entry(&self) -> Option<&GitTreeDirEntry> { + match self { + GitListEntry::Directory(entry) => Some(entry), + _ => None, + } + } } enum GitPanelViewMode { @@ -895,12 +902,6 @@ impl GitPanel { cx.notify(); } - fn first_status_entry_index(&self) -> Option { - self.entries - .iter() - .position(|entry| entry.status_entry().is_some()) - } - fn expand_selected_entry( &mut self, _: &ExpandSelectedEntry, @@ -944,7 +945,21 @@ impl GitPanel { } fn select_first(&mut self, _: &SelectFirst, _window: &mut Window, cx: &mut Context) { - if let Some(first_entry) = self.first_status_entry_index() { + let first_entry = match &self.view_mode { + GitPanelViewMode::Flat => self + .entries + .iter() + .position(|entry| entry.status_entry().is_some()), + GitPanelViewMode::Tree(state) => { + let index = self.entries.iter().position(|entry| { + entry.status_entry().is_some() || entry.directory_entry().is_some() + }); + + index.map(|index| state.logical_indices[index]) + } + }; + + if let Some(first_entry) = first_entry { self.selected_entry = Some(first_entry); self.scroll_to_selected_entry(cx); } @@ -1053,15 +1068,13 @@ impl GitPanel { cx.notify(); } - fn select_first_entry_if_none(&mut self, cx: &mut Context) { + fn select_first_entry_if_none(&mut self, window: &mut Window, cx: &mut Context) { let have_entries = self .active_repository .as_ref() .is_some_and(|active_repository| active_repository.read(cx).status_summary().count > 0); if have_entries && self.selected_entry.is_none() { - self.selected_entry = self.first_status_entry_index(); - self.scroll_to_selected_entry(cx); - cx.notify(); + self.select_first(&SelectFirst, window, cx); } } @@ -1071,10 +1084,9 @@ impl GitPanel { window: &mut Window, cx: &mut Context, ) { - self.select_first_entry_if_none(cx); - self.focus_handle.focus(window); - cx.notify(); + + self.select_first_entry_if_none(window, cx); } fn get_selected_entry(&self) -> Option<&GitListEntry> { @@ -3549,7 +3561,7 @@ impl GitPanel { self.bulk_staging = bulk_staging; } - self.select_first_entry_if_none(cx); + self.select_first_entry_if_none(window, cx); let suggested_commit_message = self.suggest_commit_message(cx); let placeholder_text = suggested_commit_message.unwrap_or("Enter commit message".into()); From 00ee06137ecda0bc00efce23797711a25990f10f Mon Sep 17 00:00:00 2001 From: peter schilling Date: Wed, 17 Dec 2025 07:32:37 -0800 Subject: [PATCH 442/621] Allow opening git commit view via URI scheme (#43341) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add support for `zed://git/commit/#` (**EDIT:** now changed to `zed://git/commit/?repo=`) URI scheme to access the git commit view implement parsing and handling of git commit URIs to navigate directly to commit views from external links. the main use case for me is to use OSC8 hyperlinks to link from a git sha into zed. this allows me e.g. to easily navigate from a terminal into zed **questions** - is this URI scheme appropriate? it was the first one i thought of, but wondering if `?ref=` might make more sense – the git/commit namespace was also an equally arbitrary choice
video demo showing navigation from zed's built in terminal https://github.com/user-attachments/assets/18ad7e64-6b39-44b2-a440-1a9eb71cd212
video demo showing navigation from ghostty to zed's commit view https://github.com/user-attachments/assets/1825e753-523f-4f98-b59c-7188ae2f5f19
Release Notes: - Added support for `zed://git/commit/?repo=` URI scheme to access the git commit view --------- Co-authored-by: Agus Zubiaga --- crates/zed/src/main.rs | 38 ++++++++++ crates/zed/src/zed/open_listener.rs | 107 ++++++++++++++++++++++++++++ 2 files changed, 145 insertions(+) diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rs index c8137a71c0f2a8524f6310d7cd711978ed833d1a..bd26812a1a3037e9d7fe0bf38c84c61143cc23e8 100644 --- a/crates/zed/src/main.rs +++ b/crates/zed/src/main.rs @@ -900,6 +900,44 @@ fn handle_open_request(request: OpenRequest, app_state: Arc, cx: &mut }) .detach_and_log_err(cx); } + OpenRequestKind::GitCommit { sha } => { + cx.spawn(async move |cx| { + let paths_with_position = + derive_paths_with_position(app_state.fs.as_ref(), request.open_paths).await; + let (workspace, _results) = open_paths_with_positions( + &paths_with_position, + &[], + app_state, + workspace::OpenOptions::default(), + cx, + ) + .await?; + + workspace + .update(cx, |workspace, window, cx| { + let Some(repo) = workspace.project().read(cx).active_repository(cx) + else { + log::error!("no active repository found for commit view"); + return Err(anyhow::anyhow!("no active repository found")); + }; + + git_ui::commit_view::CommitView::open( + sha, + repo.downgrade(), + workspace.weak_handle(), + None, + None, + window, + cx, + ); + Ok(()) + }) + .log_err(); + + anyhow::Ok(()) + }) + .detach_and_log_err(cx); + } } return; diff --git a/crates/zed/src/zed/open_listener.rs b/crates/zed/src/zed/open_listener.rs index 6352c20e5c0dcd0bd25063ca3a7bbcae87e48e3f..d61de0a291f3d3e7869225c0e07424cc3523f69b 100644 --- a/crates/zed/src/zed/open_listener.rs +++ b/crates/zed/src/zed/open_listener.rs @@ -58,6 +58,9 @@ pub enum OpenRequestKind { /// `None` opens settings without navigating to a specific path. setting_path: Option, }, + GitCommit { + sha: String, + }, } impl OpenRequest { @@ -110,6 +113,8 @@ impl OpenRequest { this.kind = Some(OpenRequestKind::Setting { setting_path: Some(setting_path.to_string()), }); + } else if let Some(commit_path) = url.strip_prefix("zed://git/commit/") { + this.parse_git_commit_url(commit_path)? } else if url.starts_with("ssh://") { this.parse_ssh_file_path(&url, cx)? } else if let Some(zed_link) = parse_zed_link(&url, cx) { @@ -138,6 +143,28 @@ impl OpenRequest { } } + fn parse_git_commit_url(&mut self, commit_path: &str) -> Result<()> { + // Format: ?repo= + let (sha, query) = commit_path + .split_once('?') + .context("invalid git commit url: missing query string")?; + anyhow::ensure!(!sha.is_empty(), "invalid git commit url: missing sha"); + + let repo = url::form_urlencoded::parse(query.as_bytes()) + .find_map(|(key, value)| (key == "repo").then_some(value)) + .filter(|s| !s.is_empty()) + .context("invalid git commit url: missing repo query parameter")? + .to_string(); + + self.open_paths.push(repo); + + self.kind = Some(OpenRequestKind::GitCommit { + sha: sha.to_string(), + }); + + Ok(()) + } + fn parse_ssh_file_path(&mut self, file: &str, cx: &App) -> Result<()> { let url = url::Url::parse(file)?; let host = url @@ -688,6 +715,86 @@ mod tests { assert_eq!(request.open_paths, vec!["/"]); } + #[gpui::test] + fn test_parse_git_commit_url(cx: &mut TestAppContext) { + let _app_state = init_test(cx); + + // Test basic git commit URL + let request = cx.update(|cx| { + OpenRequest::parse( + RawOpenRequest { + urls: vec!["zed://git/commit/abc123?repo=path/to/repo".into()], + ..Default::default() + }, + cx, + ) + .unwrap() + }); + + match request.kind.unwrap() { + OpenRequestKind::GitCommit { sha } => { + assert_eq!(sha, "abc123"); + } + _ => panic!("expected GitCommit variant"), + } + // Verify path was added to open_paths for workspace routing + assert_eq!(request.open_paths, vec!["path/to/repo"]); + + // Test with URL encoded path + let request = cx.update(|cx| { + OpenRequest::parse( + RawOpenRequest { + urls: vec!["zed://git/commit/def456?repo=path%20with%20spaces".into()], + ..Default::default() + }, + cx, + ) + .unwrap() + }); + + match request.kind.unwrap() { + OpenRequestKind::GitCommit { sha } => { + assert_eq!(sha, "def456"); + } + _ => panic!("expected GitCommit variant"), + } + assert_eq!(request.open_paths, vec!["path with spaces"]); + + // Test with empty path + cx.update(|cx| { + assert!( + OpenRequest::parse( + RawOpenRequest { + urls: vec!["zed://git/commit/abc123?repo=".into()], + ..Default::default() + }, + cx, + ) + .unwrap_err() + .to_string() + .contains("missing repo") + ); + }); + + // Test error case: missing SHA + let result = cx.update(|cx| { + OpenRequest::parse( + RawOpenRequest { + urls: vec!["zed://git/commit/abc123?foo=bar".into()], + ..Default::default() + }, + cx, + ) + }); + assert!(result.is_err()); + assert!( + result + .unwrap_err() + .to_string() + .contains("missing repo query parameter") + ); + } + #[gpui::test] async fn test_open_workspace_with_directory(cx: &mut TestAppContext) { let app_state = init_test(cx); From 1cf3422787cea9fe494ba37fcbab1c7a1a2ae899 Mon Sep 17 00:00:00 2001 From: Smit Barmase Date: Wed, 17 Dec 2025 21:06:22 +0530 Subject: [PATCH 443/621] editor: Separate delimiters computation from the newline method (#45119) Some refactoring I ran into while working on automatic Markdown list continuation on newline. This PR: - Moves `comment_delimiter` and `documentation_delimiter` computation outside of newline method. - Adds `NewlineFormatting`, which holds info about how newlines affect indentation and other formatting we need. - Moves newline-specific methods into the new `NewlineFormatting` struct. Release Notes: - N/A --- crates/editor/src/editor.rs | 537 +++++++++++++++++++----------------- 1 file changed, 282 insertions(+), 255 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index a66d92ceb8b0b6fa1631d0636294fbe3bd42af06..f9ffd835245ebb2ac7df8e8b7b667a1501c254fd 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -124,8 +124,9 @@ use language::{ AutoindentMode, BlockCommentConfig, BracketMatch, BracketPair, Buffer, BufferRow, BufferSnapshot, Capability, CharClassifier, CharKind, CharScopeContext, CodeLabel, CursorShape, DiagnosticEntryRef, DiffOptions, EditPredictionsMode, EditPreview, HighlightedText, IndentKind, - IndentSize, Language, LanguageName, LanguageRegistry, OffsetRangeExt, OutlineItem, Point, - Runnable, Selection, SelectionGoal, TextObject, TransactionId, TreeSitterOptions, WordsQuery, + IndentSize, Language, LanguageName, LanguageRegistry, LanguageScope, OffsetRangeExt, + OutlineItem, Point, Runnable, Selection, SelectionGoal, TextObject, TransactionId, + TreeSitterOptions, WordsQuery, language_settings::{ self, LanguageSettings, LspInsertMode, RewrapBehavior, WordsCompletionMode, all_language_settings, language_settings, @@ -4790,205 +4791,51 @@ impl Editor { let end = selection.end; let selection_is_empty = start == end; let language_scope = buffer.language_scope_at(start); - let ( - comment_delimiter, - doc_delimiter, - insert_extra_newline, - indent_on_newline, - indent_on_extra_newline, - ) = if let Some(language) = &language_scope { - let mut insert_extra_newline = - insert_extra_newline_brackets(&buffer, start..end, language) - || insert_extra_newline_tree_sitter(&buffer, start..end); - - // Comment extension on newline is allowed only for cursor selections - let comment_delimiter = maybe!({ - if !selection_is_empty { - return None; - } - - if !multi_buffer.language_settings(cx).extend_comment_on_newline { - return None; - } - - let delimiters = language.line_comment_prefixes(); - let max_len_of_delimiter = - delimiters.iter().map(|delimiter| delimiter.len()).max()?; - let (snapshot, range) = - buffer.buffer_line_for_row(MultiBufferRow(start_point.row))?; - - let num_of_whitespaces = snapshot - .chars_for_range(range.clone()) - .take_while(|c| c.is_whitespace()) - .count(); - let comment_candidate = snapshot - .chars_for_range(range.clone()) - .skip(num_of_whitespaces) - .take(max_len_of_delimiter) - .collect::(); - let (delimiter, trimmed_len) = delimiters - .iter() - .filter_map(|delimiter| { - let prefix = delimiter.trim_end(); - if comment_candidate.starts_with(prefix) { - Some((delimiter, prefix.len())) - } else { - None - } - }) - .max_by_key(|(_, len)| *len)?; - - if let Some(BlockCommentConfig { - start: block_start, .. - }) = language.block_comment() - { - let block_start_trimmed = block_start.trim_end(); - if block_start_trimmed.starts_with(delimiter.trim_end()) { - let line_content = snapshot - .chars_for_range(range) - .skip(num_of_whitespaces) - .take(block_start_trimmed.len()) - .collect::(); - - if line_content.starts_with(block_start_trimmed) { - return None; - } + let (comment_delimiter, doc_delimiter, newline_formatting) = + if let Some(language) = &language_scope { + let mut newline_formatting = + NewlineFormatting::new(&buffer, start..end, language); + + // Comment extension on newline is allowed only for cursor selections + let comment_delimiter = maybe!({ + if !selection_is_empty { + return None; } - } - let cursor_is_placed_after_comment_marker = - num_of_whitespaces + trimmed_len <= start_point.column as usize; - if cursor_is_placed_after_comment_marker { - Some(delimiter.clone()) - } else { - None - } - }); - - let mut indent_on_newline = IndentSize::spaces(0); - let mut indent_on_extra_newline = IndentSize::spaces(0); - - let doc_delimiter = maybe!({ - if !selection_is_empty { - return None; - } - - if !multi_buffer.language_settings(cx).extend_comment_on_newline { - return None; - } - - let BlockCommentConfig { - start: start_tag, - end: end_tag, - prefix: delimiter, - tab_size: len, - } = language.documentation_comment()?; - let is_within_block_comment = buffer - .language_scope_at(start_point) - .is_some_and(|scope| scope.override_name() == Some("comment")); - if !is_within_block_comment { - return None; - } - - let (snapshot, range) = - buffer.buffer_line_for_row(MultiBufferRow(start_point.row))?; - - let num_of_whitespaces = snapshot - .chars_for_range(range.clone()) - .take_while(|c| c.is_whitespace()) - .count(); - - // It is safe to use a column from MultiBufferPoint in context of a single buffer ranges, because we're only ever looking at a single line at a time. - let column = start_point.column; - let cursor_is_after_start_tag = { - let start_tag_len = start_tag.len(); - let start_tag_line = snapshot - .chars_for_range(range.clone()) - .skip(num_of_whitespaces) - .take(start_tag_len) - .collect::(); - if start_tag_line.starts_with(start_tag.as_ref()) { - num_of_whitespaces + start_tag_len <= column as usize - } else { - false + if !multi_buffer.language_settings(cx).extend_comment_on_newline + { + return None; } - }; - let cursor_is_after_delimiter = { - let delimiter_trim = delimiter.trim_end(); - let delimiter_line = snapshot - .chars_for_range(range.clone()) - .skip(num_of_whitespaces) - .take(delimiter_trim.len()) - .collect::(); - if delimiter_line.starts_with(delimiter_trim) { - num_of_whitespaces + delimiter_trim.len() <= column as usize - } else { - false - } - }; + return comment_delimiter_for_newline( + &start_point, + &buffer, + language, + ); + }); - let cursor_is_before_end_tag_if_exists = { - let mut char_position = 0u32; - let mut end_tag_offset = None; - - 'outer: for chunk in snapshot.text_for_range(range) { - if let Some(byte_pos) = chunk.find(&**end_tag) { - let chars_before_match = - chunk[..byte_pos].chars().count() as u32; - end_tag_offset = - Some(char_position + chars_before_match); - break 'outer; - } - char_position += chunk.chars().count() as u32; + let doc_delimiter = maybe!({ + if !selection_is_empty { + return None; } - if let Some(end_tag_offset) = end_tag_offset { - let cursor_is_before_end_tag = column <= end_tag_offset; - if cursor_is_after_start_tag { - if cursor_is_before_end_tag { - insert_extra_newline = true; - } - let cursor_is_at_start_of_end_tag = - column == end_tag_offset; - if cursor_is_at_start_of_end_tag { - indent_on_extra_newline.len = *len; - } - } - cursor_is_before_end_tag - } else { - true + if !multi_buffer.language_settings(cx).extend_comment_on_newline + { + return None; } - }; - if (cursor_is_after_start_tag || cursor_is_after_delimiter) - && cursor_is_before_end_tag_if_exists - { - if cursor_is_after_start_tag { - indent_on_newline.len = *len; - } - Some(delimiter.clone()) - } else { - None - } - }); + return documentation_delimiter_for_newline( + &start_point, + &buffer, + language, + &mut newline_formatting, + ); + }); - ( - comment_delimiter, - doc_delimiter, - insert_extra_newline, - indent_on_newline, - indent_on_extra_newline, - ) - } else { - ( - None, - None, - false, - IndentSize::default(), - IndentSize::default(), - ) - }; + (comment_delimiter, doc_delimiter, newline_formatting) + } else { + (None, None, NewlineFormatting::default()) + }; let prevent_auto_indent = doc_delimiter.is_some(); let delimiter = comment_delimiter.or(doc_delimiter); @@ -4998,28 +4845,28 @@ impl Editor { let mut new_text = String::with_capacity( 1 + capacity_for_delimiter + existing_indent.len as usize - + indent_on_newline.len as usize - + indent_on_extra_newline.len as usize, + + newline_formatting.indent_on_newline.len as usize + + newline_formatting.indent_on_extra_newline.len as usize, ); new_text.push('\n'); new_text.extend(existing_indent.chars()); - new_text.extend(indent_on_newline.chars()); + new_text.extend(newline_formatting.indent_on_newline.chars()); if let Some(delimiter) = &delimiter { new_text.push_str(delimiter); } - if insert_extra_newline { + if newline_formatting.insert_extra_newline { new_text.push('\n'); new_text.extend(existing_indent.chars()); - new_text.extend(indent_on_extra_newline.chars()); + new_text.extend(newline_formatting.indent_on_extra_newline.chars()); } let anchor = buffer.anchor_after(end); let new_selection = selection.map(|_| anchor); ( ((start..end, new_text), prevent_auto_indent), - (insert_extra_newline, new_selection), + (newline_formatting.insert_extra_newline, new_selection), ) }) .unzip() @@ -23507,76 +23354,256 @@ struct CompletionEdit { snippet: Option, } -fn insert_extra_newline_brackets( +fn comment_delimiter_for_newline( + start_point: &Point, buffer: &MultiBufferSnapshot, - range: Range, - language: &language::LanguageScope, -) -> bool { - let leading_whitespace_len = buffer - .reversed_chars_at(range.start) - .take_while(|c| c.is_whitespace() && *c != '\n') - .map(|c| c.len_utf8()) - .sum::(); - let trailing_whitespace_len = buffer - .chars_at(range.end) - .take_while(|c| c.is_whitespace() && *c != '\n') - .map(|c| c.len_utf8()) - .sum::(); - let range = range.start - leading_whitespace_len..range.end + trailing_whitespace_len; - - language.brackets().any(|(pair, enabled)| { - let pair_start = pair.start.trim_end(); - let pair_end = pair.end.trim_start(); - - enabled - && pair.newline - && buffer.contains_str_at(range.end, pair_end) - && buffer.contains_str_at( - range.start.saturating_sub_usize(pair_start.len()), - pair_start, - ) - }) + language: &LanguageScope, +) -> Option> { + let delimiters = language.line_comment_prefixes(); + let max_len_of_delimiter = delimiters.iter().map(|delimiter| delimiter.len()).max()?; + let (snapshot, range) = buffer.buffer_line_for_row(MultiBufferRow(start_point.row))?; + + let num_of_whitespaces = snapshot + .chars_for_range(range.clone()) + .take_while(|c| c.is_whitespace()) + .count(); + let comment_candidate = snapshot + .chars_for_range(range.clone()) + .skip(num_of_whitespaces) + .take(max_len_of_delimiter) + .collect::(); + let (delimiter, trimmed_len) = delimiters + .iter() + .filter_map(|delimiter| { + let prefix = delimiter.trim_end(); + if comment_candidate.starts_with(prefix) { + Some((delimiter, prefix.len())) + } else { + None + } + }) + .max_by_key(|(_, len)| *len)?; + + if let Some(BlockCommentConfig { + start: block_start, .. + }) = language.block_comment() + { + let block_start_trimmed = block_start.trim_end(); + if block_start_trimmed.starts_with(delimiter.trim_end()) { + let line_content = snapshot + .chars_for_range(range) + .skip(num_of_whitespaces) + .take(block_start_trimmed.len()) + .collect::(); + + if line_content.starts_with(block_start_trimmed) { + return None; + } + } + } + + let cursor_is_placed_after_comment_marker = + num_of_whitespaces + trimmed_len <= start_point.column as usize; + if cursor_is_placed_after_comment_marker { + Some(delimiter.clone()) + } else { + None + } } -fn insert_extra_newline_tree_sitter( +fn documentation_delimiter_for_newline( + start_point: &Point, buffer: &MultiBufferSnapshot, - range: Range, -) -> bool { - let (buffer, range) = match buffer.range_to_buffer_ranges(range).as_slice() { - [(buffer, range, _)] => (*buffer, range.clone()), - _ => return false, + language: &LanguageScope, + newline_formatting: &mut NewlineFormatting, +) -> Option> { + let BlockCommentConfig { + start: start_tag, + end: end_tag, + prefix: delimiter, + tab_size: len, + } = language.documentation_comment()?; + let is_within_block_comment = buffer + .language_scope_at(*start_point) + .is_some_and(|scope| scope.override_name() == Some("comment")); + if !is_within_block_comment { + return None; + } + + let (snapshot, range) = buffer.buffer_line_for_row(MultiBufferRow(start_point.row))?; + + let num_of_whitespaces = snapshot + .chars_for_range(range.clone()) + .take_while(|c| c.is_whitespace()) + .count(); + + // It is safe to use a column from MultiBufferPoint in context of a single buffer ranges, because we're only ever looking at a single line at a time. + let column = start_point.column; + let cursor_is_after_start_tag = { + let start_tag_len = start_tag.len(); + let start_tag_line = snapshot + .chars_for_range(range.clone()) + .skip(num_of_whitespaces) + .take(start_tag_len) + .collect::(); + if start_tag_line.starts_with(start_tag.as_ref()) { + num_of_whitespaces + start_tag_len <= column as usize + } else { + false + } }; - let pair = { - let mut result: Option> = None; - for pair in buffer - .all_bracket_ranges(range.start.0..range.end.0) - .filter(move |pair| { - pair.open_range.start <= range.start.0 && pair.close_range.end >= range.end.0 - }) - { - let len = pair.close_range.end - pair.open_range.start; + let cursor_is_after_delimiter = { + let delimiter_trim = delimiter.trim_end(); + let delimiter_line = snapshot + .chars_for_range(range.clone()) + .skip(num_of_whitespaces) + .take(delimiter_trim.len()) + .collect::(); + if delimiter_line.starts_with(delimiter_trim) { + num_of_whitespaces + delimiter_trim.len() <= column as usize + } else { + false + } + }; - if let Some(existing) = &result { - let existing_len = existing.close_range.end - existing.open_range.start; - if len > existing_len { - continue; + let cursor_is_before_end_tag_if_exists = { + let mut char_position = 0u32; + let mut end_tag_offset = None; + + 'outer: for chunk in snapshot.text_for_range(range) { + if let Some(byte_pos) = chunk.find(&**end_tag) { + let chars_before_match = chunk[..byte_pos].chars().count() as u32; + end_tag_offset = Some(char_position + chars_before_match); + break 'outer; + } + char_position += chunk.chars().count() as u32; + } + + if let Some(end_tag_offset) = end_tag_offset { + let cursor_is_before_end_tag = column <= end_tag_offset; + if cursor_is_after_start_tag { + if cursor_is_before_end_tag { + newline_formatting.insert_extra_newline = true; + } + let cursor_is_at_start_of_end_tag = column == end_tag_offset; + if cursor_is_at_start_of_end_tag { + newline_formatting.indent_on_extra_newline.len = *len; } } + cursor_is_before_end_tag + } else { + true + } + }; - result = Some(pair); + if (cursor_is_after_start_tag || cursor_is_after_delimiter) + && cursor_is_before_end_tag_if_exists + { + if cursor_is_after_start_tag { + newline_formatting.indent_on_newline.len = *len; } + Some(delimiter.clone()) + } else { + None + } +} - result - }; - let Some(pair) = pair else { - return false; - }; - pair.newline_only - && buffer - .chars_for_range(pair.open_range.end..range.start.0) - .chain(buffer.chars_for_range(range.end.0..pair.close_range.start)) - .all(|c| c.is_whitespace() && c != '\n') +#[derive(Debug, Default)] +struct NewlineFormatting { + insert_extra_newline: bool, + indent_on_newline: IndentSize, + indent_on_extra_newline: IndentSize, +} + +impl NewlineFormatting { + fn new( + buffer: &MultiBufferSnapshot, + range: Range, + language: &LanguageScope, + ) -> Self { + Self { + insert_extra_newline: Self::insert_extra_newline_brackets( + buffer, + range.clone(), + language, + ) || Self::insert_extra_newline_tree_sitter(buffer, range), + indent_on_newline: IndentSize::spaces(0), + indent_on_extra_newline: IndentSize::spaces(0), + } + } + + fn insert_extra_newline_brackets( + buffer: &MultiBufferSnapshot, + range: Range, + language: &language::LanguageScope, + ) -> bool { + let leading_whitespace_len = buffer + .reversed_chars_at(range.start) + .take_while(|c| c.is_whitespace() && *c != '\n') + .map(|c| c.len_utf8()) + .sum::(); + let trailing_whitespace_len = buffer + .chars_at(range.end) + .take_while(|c| c.is_whitespace() && *c != '\n') + .map(|c| c.len_utf8()) + .sum::(); + let range = range.start - leading_whitespace_len..range.end + trailing_whitespace_len; + + language.brackets().any(|(pair, enabled)| { + let pair_start = pair.start.trim_end(); + let pair_end = pair.end.trim_start(); + + enabled + && pair.newline + && buffer.contains_str_at(range.end, pair_end) + && buffer.contains_str_at( + range.start.saturating_sub_usize(pair_start.len()), + pair_start, + ) + }) + } + + fn insert_extra_newline_tree_sitter( + buffer: &MultiBufferSnapshot, + range: Range, + ) -> bool { + let (buffer, range) = match buffer.range_to_buffer_ranges(range).as_slice() { + [(buffer, range, _)] => (*buffer, range.clone()), + _ => return false, + }; + let pair = { + let mut result: Option> = None; + + for pair in buffer + .all_bracket_ranges(range.start.0..range.end.0) + .filter(move |pair| { + pair.open_range.start <= range.start.0 && pair.close_range.end >= range.end.0 + }) + { + let len = pair.close_range.end - pair.open_range.start; + + if let Some(existing) = &result { + let existing_len = existing.close_range.end - existing.open_range.start; + if len > existing_len { + continue; + } + } + + result = Some(pair); + } + + result + }; + let Some(pair) = pair else { + return false; + }; + pair.newline_only + && buffer + .chars_for_range(pair.open_range.end..range.start.0) + .chain(buffer.chars_for_range(range.end.0..pair.close_range.start)) + .all(|c| c.is_whitespace() && c != '\n') + } } fn update_uncommitted_diff_for_buffer( From 1705a7ce4e86fd2160e32b16e1e3ebe6c92d4dfa Mon Sep 17 00:00:00 2001 From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Date: Wed, 17 Dec 2025 13:00:50 -0300 Subject: [PATCH 444/621] ui: Remove `InlineCode` component (#45123) We recently added this `InlineCode` component but I'd forgotten that many months ago I also introduced an `inline_code` method to the Label component which does the same thing. That means we don't need a standalone component at all! Release Notes: - N/A --- .../language_models/src/provider/lmstudio.rs | 4 +- crates/language_models/src/provider/ollama.rs | 10 +-- crates/ui/src/components.rs | 2 - crates/ui/src/components/inline_code.rs | 64 ------------------- 4 files changed, 7 insertions(+), 73 deletions(-) delete mode 100644 crates/ui/src/components/inline_code.rs diff --git a/crates/language_models/src/provider/lmstudio.rs b/crates/language_models/src/provider/lmstudio.rs index 8e42d12db4c24ef6a66ddef470a34c620ed7ee00..94f99f10afc8928fb7fbc8526ab46e7dca37a5ce 100644 --- a/crates/language_models/src/provider/lmstudio.rs +++ b/crates/language_models/src/provider/lmstudio.rs @@ -20,7 +20,7 @@ use settings::{Settings, SettingsStore}; use std::pin::Pin; use std::str::FromStr; use std::{collections::BTreeMap, sync::Arc}; -use ui::{ButtonLike, Indicator, InlineCode, List, ListBulletItem, prelude::*}; +use ui::{ButtonLike, Indicator, List, ListBulletItem, prelude::*}; use util::ResultExt; use crate::AllLanguageModelSettings; @@ -691,7 +691,7 @@ impl Render for ConfigurationView { .child( ListBulletItem::new("") .child(Label::new("To get your first model, try running")) - .child(InlineCode::new("lms get qwen2.5-coder-7b")), + .child(Label::new("lms get qwen2.5-coder-7b").inline_code(cx)), ), ), ) diff --git a/crates/language_models/src/provider/ollama.rs b/crates/language_models/src/provider/ollama.rs index 6f3c49f8669885bfd02e5b11b81a091b1248227c..c5a8bf41711563110cbcb5d81698b7029b04a713 100644 --- a/crates/language_models/src/provider/ollama.rs +++ b/crates/language_models/src/provider/ollama.rs @@ -23,8 +23,8 @@ use std::sync::LazyLock; use std::sync::atomic::{AtomicU64, Ordering}; use std::{collections::HashMap, sync::Arc}; use ui::{ - ButtonLike, ButtonLink, ConfiguredApiCard, ElevationIndex, InlineCode, List, ListBulletItem, - Tooltip, prelude::*, + ButtonLike, ButtonLink, ConfiguredApiCard, ElevationIndex, List, ListBulletItem, Tooltip, + prelude::*, }; use ui_input::InputField; @@ -724,7 +724,7 @@ impl ConfigurationView { cx.notify(); } - fn render_instructions() -> Div { + fn render_instructions(cx: &mut Context) -> Div { v_flex() .gap_2() .child(Label::new( @@ -742,7 +742,7 @@ impl ConfigurationView { .child( ListBulletItem::new("") .child(Label::new("Start Ollama and download a model:")) - .child(InlineCode::new("ollama run gpt-oss:20b")), + .child(Label::new("ollama run gpt-oss:20b").inline_code(cx)), ) .child(ListBulletItem::new( "Click 'Connect' below to start using Ollama in Zed", @@ -833,7 +833,7 @@ impl Render for ConfigurationView { v_flex() .gap_2() - .child(Self::render_instructions()) + .child(Self::render_instructions(cx)) .child(self.render_api_url_editor(cx)) .child(self.render_api_key_editor(cx)) .child( diff --git a/crates/ui/src/components.rs b/crates/ui/src/components.rs index c9cb943277c6c6a5e6bc1b472040c31d9caac45c..c08e46c5882cf3c9e0a8e205c8b23224d3a7a8e1 100644 --- a/crates/ui/src/components.rs +++ b/crates/ui/src/components.rs @@ -17,7 +17,6 @@ mod icon; mod image; mod indent_guides; mod indicator; -mod inline_code; mod keybinding; mod keybinding_hint; mod label; @@ -64,7 +63,6 @@ pub use icon::*; pub use image::*; pub use indent_guides::*; pub use indicator::*; -pub use inline_code::*; pub use keybinding::*; pub use keybinding_hint::*; pub use label::*; diff --git a/crates/ui/src/components/inline_code.rs b/crates/ui/src/components/inline_code.rs deleted file mode 100644 index 43507127fef478e5a38cfad2d84446673af15f2e..0000000000000000000000000000000000000000 --- a/crates/ui/src/components/inline_code.rs +++ /dev/null @@ -1,64 +0,0 @@ -use crate::prelude::*; -use gpui::{AnyElement, IntoElement, ParentElement, Styled}; - -/// InlineCode mimics the way inline code is rendered when wrapped in backticks in Markdown. -/// -/// # Usage Example -/// -/// ``` -/// use ui::InlineCode; -/// -/// let InlineCode = InlineCode::new("
hey
"); -/// ``` -#[derive(IntoElement, RegisterComponent)] -pub struct InlineCode { - label: SharedString, - label_size: LabelSize, -} - -impl InlineCode { - pub fn new(label: impl Into) -> Self { - Self { - label: label.into(), - label_size: LabelSize::Default, - } - } - - /// Sets the size of the label. - pub fn label_size(mut self, size: LabelSize) -> Self { - self.label_size = size; - self - } -} - -impl RenderOnce for InlineCode { - fn render(self, _: &mut Window, cx: &mut App) -> impl IntoElement { - h_flex() - .min_w_0() - .px_0p5() - .overflow_hidden() - .bg(cx.theme().colors().text.opacity(0.05)) - .child(Label::new(self.label).size(self.label_size).buffer_font(cx)) - } -} - -impl Component for InlineCode { - fn scope() -> ComponentScope { - ComponentScope::DataDisplay - } - - fn preview(_window: &mut Window, _cx: &mut App) -> Option { - Some( - v_flex() - .gap_6() - .child( - example_group(vec![single_example( - "Simple", - InlineCode::new("zed.dev").into_any_element(), - )]) - .vertical(), - ) - .into_any_element(), - ) - } -} From 80aefbe8e15d560e38e829b326c159d07c4ff09f Mon Sep 17 00:00:00 2001 From: "Joseph T. Lyons" Date: Wed, 17 Dec 2025 11:14:29 -0500 Subject: [PATCH 445/621] Unified wording for discarding file changes in git panel (#45124) In the `...` menu, we use `Discard...` SCR-20251217-kbdh But in the context menu of each entry, we use "Restore..." SCR-20251217-kbcj This PR just makes this more consistent, by using "Discard..." in the second case. Release Notes: - Unified wording for discarding file changes in git panel --- crates/git_ui/src/git_panel.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs index cc9227093034ac0fa42b55324c0c2ab74a44903e..b855d9b98708fe81328d69106ac1dda3b374080e 100644 --- a/crates/git_ui/src/git_panel.rs +++ b/crates/git_ui/src/git_panel.rs @@ -1220,14 +1220,14 @@ impl GitPanel { let prompt = window.prompt( PromptLevel::Warning, &format!( - "Are you sure you want to restore {}?", + "Are you sure you want to discard changes to {}?", entry .repo_path .file_name() .unwrap_or(entry.repo_path.display(path_style).as_ref()), ), None, - &["Restore", "Cancel"], + &["Discard Changes", "Cancel"], cx, ); cx.background_spawn(prompt) @@ -4710,7 +4710,7 @@ impl GitPanel { let restore_title = if entry.status.is_created() { "Trash File" } else { - "Restore File" + "Discard Changes" }; let context_menu = ContextMenu::build(window, cx, |context_menu, _, _| { let is_created = entry.status.is_created(); From 1446d84941cf0f04912559f31a399bb79053238b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yara=20=F0=9F=8F=B3=EF=B8=8F=E2=80=8D=E2=9A=A7=EF=B8=8F?= Date: Wed, 17 Dec 2025 17:14:57 +0100 Subject: [PATCH 446/621] Blockmap sync fix (#44743) Release Notes: - Improved display map rendering performance with many lines in the the multi-buffer. --------- Co-authored-by: cameron Co-authored-by: Cole Miller --- .mailmap | 3 + crates/editor/src/display_map.rs | 49 +++++++++ crates/editor/src/display_map/block_map.rs | 3 +- crates/editor/src/display_map/inlay_map.rs | 9 ++ crates/editor/src/display_map/wrap_map.rs | 118 ++++++++++++++++++--- crates/gpui/src/test.rs | 5 +- crates/ztracing/src/lib.rs | 22 ++-- 7 files changed, 185 insertions(+), 24 deletions(-) diff --git a/.mailmap b/.mailmap index db4632d6ca34346d3e8fa289222d7f310b7bdfe5..1e956c52cf76589fc016e1410122ccd94e4818ae 100644 --- a/.mailmap +++ b/.mailmap @@ -141,6 +141,9 @@ Uladzislau Kaminski Uladzislau Kaminski Vitaly Slobodin Vitaly Slobodin +Yara +Yara +Yara Will Bradley Will Bradley WindSoilder diff --git a/crates/editor/src/display_map.rs b/crates/editor/src/display_map.rs index cab5b3686ee2f77dade059b434b1090cf9b2f7e5..413766cb283dfa2c5de0351b3ff10ff9b90a9c56 100644 --- a/crates/editor/src/display_map.rs +++ b/crates/editor/src/display_map.rs @@ -14,8 +14,57 @@ //! - [`DisplayMap`] that adds background highlights to the regions of text. //! Each one of those builds on top of preceding map. //! +//! ## Structure of the display map layers +//! +//! Each layer in the map (and the multibuffer itself to some extent) has a few +//! structures that are used to implement the public API available to the layer +//! above: +//! - a `Transform` type - this represents a region of text that the layer in +//! question is "managing", that it transforms into a more "processed" text +//! for the layer above. For example, the inlay map has an `enum Transform` +//! that has two variants: +//! - `Isomorphic`, representing a region of text that has no inlay hints (i.e. +//! is passed through the map transparently) +//! - `Inlay`, representing a location where an inlay hint is to be inserted. +//! - a `TransformSummary` type, which is usually a struct with two fields: +//! [`input: TextSummary`][`TextSummary`] and [`output: TextSummary`][`TextSummary`]. Here, +//! `input` corresponds to "text in the layer below", and `output` corresponds to the text +//! exposed to the layer above. So in the inlay map case, a `Transform::Isomorphic`'s summary is +//! just `input = output = summary`, where `summary` is the [`TextSummary`] stored in that +//! variant. Conversely, a `Transform::Inlay` always has an empty `input` summary, because it's +//! not "replacing" any text that exists on disk. The `output` is the summary of the inlay text +//! to be injected. - Various newtype wrappers for co-ordinate spaces (e.g. [`WrapRow`] +//! represents a row index, after soft-wrapping (and all lower layers)). +//! - A `Snapshot` type (e.g. [`InlaySnapshot`]) that captures the state of a layer at a specific +//! point in time. +//! - various APIs which drill through the layers below to work with the underlying text. Notably: +//! - `fn text_summary_for_offset()` returns a [`TextSummary`] for the range in the co-ordinate +//! space that the map in question is responsible for. +//! - `fn
_point_to__point()` converts a point in co-ordinate space `A` into co-ordinate +//! space `B`. +//! - A [`RowInfo`] iterator (e.g. [`InlayBufferRows`]) and a [`Chunk`] iterator +//! (e.g. [`InlayChunks`]) +//! - A `sync` function (e.g. [`InlayMap::sync`]) that takes a snapshot and list of [`Edit`]s, +//! and returns a new snapshot and a list of transformed [`Edit`]s. Note that the generic +//! parameter on `Edit` changes, since these methods take in edits in the co-ordinate space of +//! the lower layer, and return edits in their own co-ordinate space. The term "edit" is +//! slightly misleading, since an [`Edit`] doesn't tell you what changed - rather it can be +//! thought of as a "region to invalidate". In theory, it would be correct to always use a +//! single edit that covers the entire range. However, this would lead to lots of unnecessary +//! recalculation. +//! +//! See the docs for the [`inlay_map`] module for a more in-depth explanation of how a single layer +//! works. +//! //! [Editor]: crate::Editor //! [EditorElement]: crate::element::EditorElement +//! [`TextSummary`]: multi_buffer::MBTextSummary +//! [`WrapRow`]: wrap_map::WrapRow +//! [`InlayBufferRows`]: inlay_map::InlayBufferRows +//! [`InlayChunks`]: inlay_map::InlayChunks +//! [`Edit`]: text::Edit +//! [`Edit`]: text::Edit +//! [`Chunk`]: language::Chunk #[macro_use] mod dimensions; diff --git a/crates/editor/src/display_map/block_map.rs b/crates/editor/src/display_map/block_map.rs index 9c7f9d8632224208248a6585fc6f94939ee076fe..15bf012cd907da2455c1a2205bcccd363162fd46 100644 --- a/crates/editor/src/display_map/block_map.rs +++ b/crates/editor/src/display_map/block_map.rs @@ -545,7 +545,7 @@ impl BlockMap { { let max_point = wrap_snapshot.max_point(); let edit_start = wrap_snapshot.prev_row_boundary(max_point); - let edit_end = max_point.row() + WrapRow(1); + let edit_end = max_point.row() + WrapRow(1); // this is end of file edits = edits.compose([WrapEdit { old: edit_start..edit_end, new: edit_start..edit_end, @@ -715,6 +715,7 @@ impl BlockMap { let placement = block.placement.to_wrap_row(wrap_snapshot)?; if let BlockPlacement::Above(row) = placement && row < new_start + // this will be true more often now { return None; } diff --git a/crates/editor/src/display_map/inlay_map.rs b/crates/editor/src/display_map/inlay_map.rs index d85f761a82e2f466b6868c4ce28bcb3a4e6b061d..cbdc4b18fee452163c5a11932c968cb7cc500f96 100644 --- a/crates/editor/src/display_map/inlay_map.rs +++ b/crates/editor/src/display_map/inlay_map.rs @@ -1,3 +1,10 @@ +//! The inlay map. See the [`display_map`][super] docs for an overview of how the inlay map fits +//! into the rest of the [`DisplayMap`][super::DisplayMap]. Much of the documentation for this +//! module generalizes to other layers. +//! +//! The core of this module is the [`InlayMap`] struct, which maintains a vec of [`Inlay`]s, and +//! [`InlaySnapshot`], which holds a sum tree of [`Transform`]s. + use crate::{ ChunkRenderer, HighlightStyles, inlays::{Inlay, InlayContent}, @@ -69,7 +76,9 @@ impl sum_tree::Item for Transform { #[derive(Clone, Debug, Default)] struct TransformSummary { + /// Summary of the text before inlays have been applied. input: MBTextSummary, + /// Summary of the text after inlays have been applied. output: MBTextSummary, } diff --git a/crates/editor/src/display_map/wrap_map.rs b/crates/editor/src/display_map/wrap_map.rs index 4d6b79d06170a22aaffafa05e0f144219e4d20a7..879ca11be1a84ffd44daa6e53677b06887172026 100644 --- a/crates/editor/src/display_map/wrap_map.rs +++ b/crates/editor/src/display_map/wrap_map.rs @@ -840,35 +840,62 @@ impl WrapSnapshot { self.tab_point_to_wrap_point(self.tab_snapshot.clip_point(self.to_tab_point(point), bias)) } - #[ztracing::instrument(skip_all, fields(point=?point, ret))] - pub fn prev_row_boundary(&self, mut point: WrapPoint) -> WrapRow { + /// Try to find a TabRow start that is also a WrapRow start + /// Every TabRow start is a WrapRow start + #[ztracing::instrument(skip_all, fields(point=?point))] + pub fn prev_row_boundary(&self, point: WrapPoint) -> WrapRow { if self.transforms.is_empty() { return WrapRow(0); } - *point.column_mut() = 0; + let point = WrapPoint::new(point.row(), 0); let mut cursor = self .transforms .cursor::>(()); - // start + cursor.seek(&point, Bias::Right); - // end if cursor.item().is_none() { cursor.prev(); } - // start + // real newline fake fake + // text: helloworldasldlfjasd\njdlasfalsk\naskdjfasdkfj\n + // dimensions v v v v v + // transforms |-------|-----NW----|-----W------|-----W------| + // cursor ^ ^^^^^^^^^^^^^ ^ + // (^) ^^^^^^^^^^^^^^ + // point: ^ + // point(col_zero): (^) + while let Some(transform) = cursor.item() { - if transform.is_isomorphic() && cursor.start().1.column() == 0 { - return cmp::min(cursor.end().0.row(), point.row()); - } else { - cursor.prev(); + if transform.is_isomorphic() { + // this transform only has real linefeeds + let tab_summary = &transform.summary.input; + // is the wrap just before the end of the transform a tab row? + // thats only if this transform has at least one newline + // + // "this wrap row is a tab row" <=> self.to_tab_point(WrapPoint::new(wrap_row, 0)).column() == 0 + + // Note on comparison: + // We have code that relies on this to be row > 1 + // It should work with row >= 1 but it does not :( + // + // That means that if every line is wrapped we walk back all the + // way to the start. Which invalidates the entire state triggering + // a full re-render. + if tab_summary.lines.row > 1 { + let wrap_point_at_end = cursor.end().0.row(); + return cmp::min(wrap_point_at_end - RowDelta(1), point.row()); + } else if cursor.start().1.column() == 0 { + return cmp::min(cursor.end().0.row(), point.row()); + } } + + cursor.prev(); } - // end - unreachable!() + WrapRow(0) } #[ztracing::instrument(skip_all)] @@ -891,13 +918,11 @@ impl WrapSnapshot { } #[cfg(test)] - #[ztracing::instrument(skip_all)] pub fn text(&self) -> String { self.text_chunks(WrapRow(0)).collect() } #[cfg(test)] - #[ztracing::instrument(skip_all)] pub fn text_chunks(&self, wrap_row: WrapRow) -> impl Iterator { self.chunks( wrap_row..self.max_point().row() + WrapRow(1), @@ -1298,6 +1323,71 @@ mod tests { use text::Rope; use theme::LoadThemes; + #[gpui::test] + async fn test_prev_row_boundary(cx: &mut gpui::TestAppContext) { + init_test(cx); + + fn test_wrap_snapshot( + text: &str, + soft_wrap_every: usize, // font size multiple + cx: &mut gpui::TestAppContext, + ) -> WrapSnapshot { + let text_system = cx.read(|cx| cx.text_system().clone()); + let tab_size = 4.try_into().unwrap(); + let font = test_font(); + let _font_id = text_system.resolve_font(&font); + let font_size = px(14.0); + // this is very much an estimate to try and get the wrapping to + // occur at `soft_wrap_every` we check that it pans out for every test case + let soft_wrapping = Some(font_size * soft_wrap_every * 0.6); + + let buffer = cx.new(|cx| language::Buffer::local(text, cx)); + let buffer = cx.new(|cx| MultiBuffer::singleton(buffer, cx)); + let buffer_snapshot = buffer.read_with(cx, |buffer, cx| buffer.snapshot(cx)); + let (_inlay_map, inlay_snapshot) = InlayMap::new(buffer_snapshot); + let (_fold_map, fold_snapshot) = FoldMap::new(inlay_snapshot); + let (mut tab_map, _) = TabMap::new(fold_snapshot, tab_size); + let tabs_snapshot = tab_map.set_max_expansion_column(32); + let (_wrap_map, wrap_snapshot) = + cx.update(|cx| WrapMap::new(tabs_snapshot, font, font_size, soft_wrapping, cx)); + + wrap_snapshot + } + + // These two should pass but dont, see the comparison note in + // prev_row_boundary about why. + // + // // 0123 4567 wrap_rows + // let wrap_snapshot = test_wrap_snapshot("1234\n5678", 1, cx); + // assert_eq!(wrap_snapshot.text(), "1\n2\n3\n4\n5\n6\n7\n8"); + // let row = wrap_snapshot.prev_row_boundary(wrap_snapshot.max_point()); + // assert_eq!(row.0, 3); + + // // 012 345 678 wrap_rows + // let wrap_snapshot = test_wrap_snapshot("123\n456\n789", 1, cx); + // assert_eq!(wrap_snapshot.text(), "1\n2\n3\n4\n5\n6\n7\n8\n9"); + // let row = wrap_snapshot.prev_row_boundary(wrap_snapshot.max_point()); + // assert_eq!(row.0, 5); + + // 012345678 wrap_rows + let wrap_snapshot = test_wrap_snapshot("123456789", 1, cx); + assert_eq!(wrap_snapshot.text(), "1\n2\n3\n4\n5\n6\n7\n8\n9"); + let row = wrap_snapshot.prev_row_boundary(wrap_snapshot.max_point()); + assert_eq!(row.0, 0); + + // 111 2222 44 wrap_rows + let wrap_snapshot = test_wrap_snapshot("123\n4567\n\n89", 4, cx); + assert_eq!(wrap_snapshot.text(), "123\n4567\n\n89"); + let row = wrap_snapshot.prev_row_boundary(wrap_snapshot.max_point()); + assert_eq!(row.0, 2); + + // 11 2223 wrap_rows + let wrap_snapshot = test_wrap_snapshot("12\n3456\n\n", 3, cx); + assert_eq!(wrap_snapshot.text(), "12\n345\n6\n\n"); + let row = wrap_snapshot.prev_row_boundary(wrap_snapshot.max_point()); + assert_eq!(row.0, 3); + } + #[gpui::test(iterations = 100)] async fn test_random_wraps(cx: &mut gpui::TestAppContext, mut rng: StdRng) { // todo this test is flaky diff --git a/crates/gpui/src/test.rs b/crates/gpui/src/test.rs index 5ae72d2be1688893374e16a55445558b5bc33040..2a5711a01a9c8f2874cea4803fc517089cafd0fe 100644 --- a/crates/gpui/src/test.rs +++ b/crates/gpui/src/test.rs @@ -69,7 +69,10 @@ pub fn run_test( std::mem::forget(error); } else { if is_multiple_runs { - eprintln!("failing seed: {}", seed); + eprintln!("failing seed: {seed}"); + eprintln!( + "You can rerun from this seed by setting the environmental variable SEED to {seed}" + ); } if let Some(on_fail_fn) = on_fail_fn { on_fail_fn() diff --git a/crates/ztracing/src/lib.rs b/crates/ztracing/src/lib.rs index b9b318cc3565d8ced2a5496f1240409542d23c5a..c9007be1ed43150ef877d51c882aee77845e5bd6 100644 --- a/crates/ztracing/src/lib.rs +++ b/crates/ztracing/src/lib.rs @@ -1,8 +1,8 @@ -pub use tracing::Level; +pub use tracing::{Level, field}; #[cfg(ztracing)] pub use tracing::{ - debug_span, error_span, event, info_span, instrument, span, trace_span, warn_span, + Span, debug_span, error_span, event, info_span, instrument, span, trace_span, warn_span, }; #[cfg(not(ztracing))] pub use ztracing_macro::instrument; @@ -26,17 +26,23 @@ pub use __consume_all_tokens as span; #[macro_export] macro_rules! __consume_all_tokens { ($($t:tt)*) => { - $crate::FakeSpan + $crate::Span }; } -pub struct FakeSpan; -impl FakeSpan { +#[cfg(not(ztracing))] +pub struct Span; + +#[cfg(not(ztracing))] +impl Span { + pub fn current() -> Self { + Self + } + pub fn enter(&self) {} -} -// #[cfg(not(ztracing))] -// pub use span; + pub fn record(&self, _t: T, _s: S) {} +} #[cfg(ztracing)] pub fn init() { From 081e820c43d9786287c85cf942024aa1adf88695 Mon Sep 17 00:00:00 2001 From: Katie Geer Date: Wed, 17 Dec 2025 08:28:32 -0800 Subject: [PATCH 447/621] docs: Dev container (#44498) Release Notes: - N/A --------- Co-authored-by: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Co-authored-by: Danilo Leal --- docs/src/SUMMARY.md | 1 + docs/src/dev-containers.md | 50 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 docs/src/dev-containers.md diff --git a/docs/src/SUMMARY.md b/docs/src/SUMMARY.md index d6dd7a0aef9737fb095e87705e813f87fd0ed683..d64aed93de16e8806b5e384452816c5d62ed621d 100644 --- a/docs/src/SUMMARY.md +++ b/docs/src/SUMMARY.md @@ -46,6 +46,7 @@ - [Tasks](./tasks.md) - [Tab Switcher](./tab-switcher.md) - [Remote Development](./remote-development.md) +- [Dev Containers](./dev-containers.md) - [Environment Variables](./environment.md) - [REPL](./repl.md) diff --git a/docs/src/dev-containers.md b/docs/src/dev-containers.md new file mode 100644 index 0000000000000000000000000000000000000000..c87b204ee9cded48edb95752dd234fa55df71338 --- /dev/null +++ b/docs/src/dev-containers.md @@ -0,0 +1,50 @@ +# Dev Containers + +Dev Containers provide a consistent, reproducible development environment by defining your project's dependencies, tools, and settings in a container configuration. + +If your repository includes a `.devcontainer/devcontainer.json` file, Zed can open a project inside a development container. + +## Requirements + +- Docker must be installed and available in your `PATH`. Zed requires the `docker` command to be present. If you use Podman, you can alias it to `docker` (e.g., `alias docker=podman`). +- Your project must contain a `.devcontainer/devcontainer.json` directory/file. + +## Using Dev Containers in Zed + +### Automatic prompt + +When you open a project that contains the `.devcontainer/devcontainer.json` directory/file, Zed will display a prompt asking whether to open the project inside the dev container. Choosing "Open in Container" will: + +1. Build the dev container image (if needed). +2. Launch the container. +3. Reopen the project connected to the container environment. + +### Manual open + +If you dismiss the prompt or want to reopen the project inside a container later, you can use Zed's command palette to run the "Project: Open Remote" command and select the option to open the project in a dev container. +Alternatively, you can reach for the Remote Projects modal (through the {#kb projects::OpenRemote} binding) and choose the "Connect Dev Container" option. + +## Editing the dev container configuration + +If you modify `.devcontainer/devcontainer.json`, Zed does not currently rebuild or reload the container automatically. After changing configuration: + +- Stop or kill the existing container manually (e.g., via `docker kill `). +- Reopen the project in the container. + +## Working in a Dev Container + +Once connected, Zed operates inside the container environment for tasks, terminals, and language servers. +Files are linked from your workspace into the container according to the dev container specification. + +## Known Limitations + +> **Note:** This feature is still in development. + +- **Extensions:** Zed does not yet manage extensions separately for container environments. The host's extensions are used as-is. +- **Port forwarding:** Only the `appPort` field is supported. `forwardPorts` and other advanced port-forwarding features are not implemented. +- **Configuration changes:** Updates to `devcontainer.json` do not trigger automatic rebuilds or reloads; containers must be manually restarted. + +## See also + +- [Remote Development](./remote-development.md) for connecting to remote servers over SSH. +- [Tasks](./tasks.md) for running commands in the integrated terminal. From f6c944f8651c8dedbb0f0e3fdc9c13f955f5e7a6 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Wed, 17 Dec 2025 17:28:42 +0100 Subject: [PATCH 448/621] Fix focus lost when navigating to settings subpages (#45111) Fixes #42668 When clicking 'Configure' to enter a settings subpage, focus was being lost because push_sub_page only called cx.notify() without managing focus. Similarly, pop_sub_page had the same issue when navigating back. This fix: - Adds window parameter to push_sub_page and pop_sub_page - Focuses the content area when entering/leaving subpages - Resets scroll position when entering a subpage Release Notes: - Fixed a bug that prevented keyboard navigation in the settings window. --- crates/settings_ui/src/settings_ui.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/crates/settings_ui/src/settings_ui.rs b/crates/settings_ui/src/settings_ui.rs index 40678f6cf8d1c6773ccf1168e065cb318ae9f14f..101f52159a263910fba0d65782f06784f8183fd0 100644 --- a/crates/settings_ui/src/settings_ui.rs +++ b/crates/settings_ui/src/settings_ui.rs @@ -890,7 +890,7 @@ impl SettingsPageItem { .size(ButtonSize::Medium) .on_click({ let sub_page_link = sub_page_link.clone(); - cx.listener(move |this, _, _, cx| { + cx.listener(move |this, _, window, cx| { let mut section_index = item_index; let current_page = this.current_page(); @@ -909,7 +909,7 @@ impl SettingsPageItem { ) }; - this.push_sub_page(sub_page_link.clone(), header, cx) + this.push_sub_page(sub_page_link.clone(), header, window, cx) }) }), ) @@ -2995,8 +2995,8 @@ impl SettingsWindow { IconButton::new("back-btn", IconName::ArrowLeft) .icon_size(IconSize::Small) .shape(IconButtonShape::Square) - .on_click(cx.listener(|this, _, _, cx| { - this.pop_sub_page(cx); + .on_click(cx.listener(|this, _, window, cx| { + this.pop_sub_page(window, cx); })), ) .child(self.render_sub_page_breadcrumbs()), @@ -3355,17 +3355,22 @@ impl SettingsWindow { &mut self, sub_page_link: SubPageLink, section_header: &'static str, + window: &mut Window, cx: &mut Context, ) { sub_page_stack_mut().push(SubPage { link: sub_page_link, section_header, }); + self.sub_page_scroll_handle + .set_offset(point(px(0.), px(0.))); + self.content_focus_handle.focus_handle(cx).focus(window); cx.notify(); } - fn pop_sub_page(&mut self, cx: &mut Context) { + fn pop_sub_page(&mut self, window: &mut Window, cx: &mut Context) { sub_page_stack_mut().pop(); + self.content_focus_handle.focus_handle(cx).focus(window); cx.notify(); } From 74b4013e67ce1a11497806300ca886ba4231ef15 Mon Sep 17 00:00:00 2001 From: Ramon <55579979+van-sprundel@users.noreply.github.com> Date: Wed, 17 Dec 2025 17:32:50 +0100 Subject: [PATCH 449/621] git: Mark entries as pending when staging a files making the staged highlighting more "optimistic" (#43434) This at least speeds it up, not sure if this would close the issue On main (342eba6f220625c015d00334c6bc354f0e2c52e1): https://github.com/user-attachments/assets/55d10187-b4e6-410d-9002-06509e8015c9 This branch: https://github.com/user-attachments/assets/e9a5c14f-9694-4321-a81c-88d6f62fb342 Closes #26870 Release Notes: - Added optimistic staged hunk updating --- crates/project/src/git_store.rs | 81 +++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/crates/project/src/git_store.rs b/crates/project/src/git_store.rs index c73ab914b788fb92e69ea3a47db5446223098c2d..a414a03320a2defa4c9dbd4b6193a131e761d2c7 100644 --- a/crates/project/src/git_store.rs +++ b/crates/project/src/git_store.rs @@ -1672,6 +1672,59 @@ impl GitStore { } } + fn mark_entries_pending_by_project_paths( + &mut self, + project_paths: &[ProjectPath], + stage: bool, + cx: &mut Context, + ) { + let buffer_store = &self.buffer_store; + + for project_path in project_paths { + let Some(buffer) = buffer_store.read(cx).get_by_path(project_path) else { + continue; + }; + + let buffer_id = buffer.read(cx).remote_id(); + let Some(diff_state) = self.diffs.get(&buffer_id) else { + continue; + }; + + diff_state.update(cx, |diff_state, cx| { + let Some(uncommitted_diff) = diff_state.uncommitted_diff() else { + return; + }; + + let buffer_snapshot = buffer.read(cx).text_snapshot(); + let file_exists = buffer + .read(cx) + .file() + .is_some_and(|file| file.disk_state().exists()); + + let all_hunks: Vec<_> = uncommitted_diff + .read(cx) + .hunks_intersecting_range( + text::Anchor::MIN..text::Anchor::MAX, + &buffer_snapshot, + cx, + ) + .collect(); + + if !all_hunks.is_empty() { + uncommitted_diff.update(cx, |diff, cx| { + diff.stage_or_unstage_hunks( + stage, + &all_hunks, + &buffer_snapshot, + file_exists, + cx, + ); + }); + } + }); + } + } + pub fn git_clone( &self, repo: String, @@ -4200,6 +4253,28 @@ impl Repository { save_futures } + fn mark_entries_pending_for_stage( + &self, + entries: &[RepoPath], + stage: bool, + cx: &mut Context, + ) { + let Some(git_store) = self.git_store() else { + return; + }; + + let mut project_paths = Vec::new(); + for repo_path in entries { + if let Some(project_path) = self.repo_path_to_project_path(repo_path, cx) { + project_paths.push(project_path); + } + } + + git_store.update(cx, move |git_store, cx| { + git_store.mark_entries_pending_by_project_paths(&project_paths, stage, cx); + }); + } + pub fn stage_entries( &mut self, entries: Vec, @@ -4208,6 +4283,9 @@ impl Repository { if entries.is_empty() { return Task::ready(Ok(())); } + + self.mark_entries_pending_for_stage(&entries, true, cx); + let id = self.id; let save_tasks = self.save_buffers(&entries, cx); let paths = entries @@ -4273,6 +4351,9 @@ impl Repository { if entries.is_empty() { return Task::ready(Ok(())); } + + self.mark_entries_pending_for_stage(&entries, false, cx); + let id = self.id; let save_tasks = self.save_buffers(&entries, cx); let paths = entries From ad58f1f68b322e9654c993b6fe32fd35fb091b30 Mon Sep 17 00:00:00 2001 From: Katie Geer Date: Wed, 17 Dec 2025 08:44:48 -0800 Subject: [PATCH 450/621] docs: Add migrate docs for Webstorm / Pycharm / RustRover (#45128) Release Notes: - N/A --- docs/.rules | 1 + docs/src/SUMMARY.md | 3 + docs/src/migrate/_research-notes.md | 73 ++++ docs/src/migrate/intellij.md | 6 +- docs/src/migrate/pycharm.md | 438 ++++++++++++++++++++++++ docs/src/migrate/rustrover.md | 501 ++++++++++++++++++++++++++++ docs/src/migrate/webstorm.md | 455 +++++++++++++++++++++++++ 7 files changed, 1474 insertions(+), 3 deletions(-) create mode 100644 docs/src/migrate/_research-notes.md create mode 100644 docs/src/migrate/pycharm.md create mode 100644 docs/src/migrate/rustrover.md create mode 100644 docs/src/migrate/webstorm.md diff --git a/docs/.rules b/docs/.rules index 17c0e97450ce50f6846c865d58289257f2008f5c..4e6ca312f13b12a54a73d736ffeed8a8e09061ef 100644 --- a/docs/.rules +++ b/docs/.rules @@ -17,6 +17,7 @@ - Apologetic tone for missing features—state the limitation and move on - Comparisons that disparage other tools—be factual, not competitive - Meta-commentary about honesty ("the honest take is...", "to be frank...", "honestly...")—let honesty show through frank assessments, not announcements +- LLM-isms and filler words ("entirely," "certainly,", "deeply," "definitely," "actually")—these add nothing ## Content Structure diff --git a/docs/src/SUMMARY.md b/docs/src/SUMMARY.md index d64aed93de16e8806b5e384452816c5d62ed621d..1f9c5750ea76b35a2f7f5464b7b6684401108d2b 100644 --- a/docs/src/SUMMARY.md +++ b/docs/src/SUMMARY.md @@ -92,6 +92,9 @@ - [VS Code](./migrate/vs-code.md) - [IntelliJ IDEA](./migrate/intellij.md) +- [PyCharm](./migrate/pycharm.md) +- [WebStorm](./migrate/webstorm.md) +- [RustRover](./migrate/rustrover.md) # Language Support diff --git a/docs/src/migrate/_research-notes.md b/docs/src/migrate/_research-notes.md new file mode 100644 index 0000000000000000000000000000000000000000..e23a3d3529a9762368e1721f97a6720382cd764b --- /dev/null +++ b/docs/src/migrate/_research-notes.md @@ -0,0 +1,73 @@ + + +# Migration Research Notes + +## Completed Guides + +All three JetBrains migration guides have been populated with full content: + +1. **pycharm.md** - Python development, virtual environments, Ruff/Pyright, Django/Flask workflows +2. **webstorm.md** - JavaScript/TypeScript development, npm workflows, framework considerations +3. **rustrover.md** - Rust development, rust-analyzer parity, Cargo workflows, licensing notes + +## Key Sources Used + +- IntelliJ IDEA migration doc (structural template) +- JetBrains PyCharm Getting Started docs +- JetBrains WebStorm Getting Started docs +- JetBrains RustRover Quick Start Guide +- External community feedback (Reddit, Hacker News, Medium) + +## External Quotes Incorporated + +### WebStorm Guide + +> "I work for AWS and the applications I deal with are massive. Often I need to keep many projects open due to tight dependencies. I'm talking about complex microservices and micro frontend infrastructure which oftentimes lead to 2-15 minutes of indexing wait time whenever I open a project or build the system locally." + +### RustRover Guide + +- Noted rust-analyzer shared foundation between RustRover and Zed +- Addressed licensing/telemetry concerns that motivate some users to switch +- Included debugger caveats based on community feedback + +## Cross-Cutting Themes Applied to All Guides + +### Universal Pain Points Addressed + +1. Indexing (instant in Zed) +2. Resource usage (Zed is lightweight) +3. Startup time (Zed is near-instant) +4. UI clutter (Zed is minimal by design) + +### Universal Missing Features Documented + +- No project model / SDK management +- No database tools +- No framework-specific integration +- No visual run configurations (use tasks) +- No built-in HTTP client + +### JetBrains Keymap Emphasized + +All three guides emphasize: + +- Select JetBrains keymap during onboarding or in settings +- `Shift Shift` for Search Everywhere works +- Most familiar shortcuts preserved + +## Next Steps (Optional Enhancements) + +- [ ] Cross-link guides to JetBrains docs for users who want to reference original IDE features +- [ ] Add a consolidated "hub page" linking to all migration guides +- [ ] Consider adding VS Code migration guide using similar structure +- [ ] Review for tone consistency against Zed Documentation Guidelines diff --git a/docs/src/migrate/intellij.md b/docs/src/migrate/intellij.md index d931fde4f1c2cd98db6b154d7009feff6fcb6a5b..24c85774ec5686f605d1d781913d0873ac0abd7f 100644 --- a/docs/src/migrate/intellij.md +++ b/docs/src/migrate/intellij.md @@ -33,7 +33,7 @@ This opens the current directory in Zed. If you're coming from IntelliJ, the fastest way to feel at home is to use the JetBrains keymap. During onboarding, you can select it as your base keymap. If you missed that step, you can change it anytime: 1. Open Settings with `Cmd+,` (macOS) or `Ctrl+,` (Linux/Windows) -2. Search for `base_keymap` +2. Search for `Base Keymap` 3. Select `JetBrains` Or add this directly to your `settings.json`: @@ -147,7 +147,7 @@ If you've used IntelliJ on large projects, you know the wait: "Indexing..." can Zed doesn't index. You open a folder and start working immediately. File search and navigation work instantly regardless of project size. -The trade-off is real: IntelliJ's index powers features like finding all usages across your entire codebase, understanding class hierarchies, and detecting dead code. Zed delegates this work to language servers, which may not analyze as deeply or as broadly. +IntelliJ's index powers features like finding all usages across your entire codebase, understanding class hierarchies, and detecting dead code. Zed delegates this work to language servers, which may not analyze at the same depth. **How to adapt:** @@ -158,7 +158,7 @@ The trade-off is real: IntelliJ's index powers features like finding all usages ### LSP vs. Native Language Intelligence -IntelliJ has its own language analysis engine built from scratch for each supported language. For Java, Kotlin, and other JVM languages, this engine understands your code deeply: it resolves types, tracks data flow, knows about framework annotations, and offers dozens of specialized refactorings. +IntelliJ has its own language analysis engine built from scratch for each supported language. For Java, Kotlin, and other JVM languages, this engine understands your code thoroughly: it resolves types, tracks data flow, knows about framework annotations, and offers dozens of specialized refactorings. Zed uses the Language Server Protocol (LSP) for code intelligence. Each language has its own server: `jdtls` for Java, `rust-analyzer` for Rust, and so on. diff --git a/docs/src/migrate/pycharm.md b/docs/src/migrate/pycharm.md new file mode 100644 index 0000000000000000000000000000000000000000..636bc69eeba1c09b3e0e8a0d74ccd859aedbb342 --- /dev/null +++ b/docs/src/migrate/pycharm.md @@ -0,0 +1,438 @@ +# How to Migrate from PyCharm to Zed + +This guide covers how to set up Zed if you're coming from PyCharm, including keybindings, settings, and the differences you should expect. + +## Install Zed + +Zed is available on macOS, Windows, and Linux. + +For macOS, you can download it from zed.dev/download, or install via Homebrew: + +```sh +brew install --cask zed +``` + +For Windows, download the installer from zed.dev/download, or install via winget: + +```sh +winget install Zed.Zed +``` + +For most Linux users, the easiest way to install Zed is through our installation script: + +```sh +curl -f https://zed.dev/install.sh | sh +``` + +After installation, you can launch Zed from your Applications folder (macOS), Start menu (Windows), or directly from the terminal using: +`zed .` +This opens the current directory in Zed. + +## Set Up the JetBrains Keymap + +If you're coming from PyCharm, the fastest way to feel at home is to use the JetBrains keymap. During onboarding, you can select it as your base keymap. If you missed that step, you can change it anytime: + +1. Open Settings with `Cmd+,` (macOS) or `Ctrl+,` (Linux/Windows) +2. Search for `Base Keymap` +3. Select `JetBrains` + +Or add this directly to your `settings.json`: + +```json +{ + "base_keymap": "JetBrains" +} +``` + +This maps familiar shortcuts like `Shift Shift` for Search Everywhere, `Cmd+O` for Go to Class, and `Cmd+Shift+A` for Find Action. + +## Set Up Editor Preferences + +You can configure settings manually in the Settings Editor. + +To edit your settings: + +1. `Cmd+,` to open the Settings Editor. +2. Run `zed: open settings` in the Command Palette. + +Settings PyCharm users typically configure first: + +| Zed Setting | What it does | +| ----------------------- | ------------------------------------------------------------------------------- | +| `format_on_save` | Auto-format when saving. Set to `"on"` to enable. | +| `soft_wrap` | Wrap long lines. Options: `"none"`, `"editor_width"`, `"preferred_line_length"` | +| `preferred_line_length` | Column width for wrapping and rulers. Default is 80, PEP 8 recommends 79. | +| `inlay_hints` | Show parameter names and type hints inline, like PyCharm's hints. | +| `relative_line_numbers` | Useful if you're coming from IdeaVim. | + +Zed also supports per-project settings. Create a `.zed/settings.json` file in your project root to override global settings for that project, similar to how you might use `.idea` folders in PyCharm. + +> **Tip:** If you're joining an existing project, check `format_on_save` before making your first commit. Otherwise you might accidentally reformat an entire file when you only meant to change one line. + +## Open or Create a Project + +After setup, press `Cmd+Shift+O` (with JetBrains keymap) to open a folder. This becomes your workspace in Zed. Unlike PyCharm, there's no project configuration wizard, no interpreter selection dialog, and no project structure setup required. + +To start a new project, create a directory using your terminal or file manager, then open it in Zed. The editor will treat that folder as the root of your project. + +You can also launch Zed from the terminal inside any folder with: +`zed .` + +Once inside a project: + +- Use `Cmd+Shift+O` or `Cmd+E` to jump between files quickly (like PyCharm's "Recent Files") +- Use `Cmd+Shift+A` or `Shift Shift` to open the Command Palette (like PyCharm's "Search Everywhere") +- Use `Cmd+O` to search for symbols (like PyCharm's "Go to Symbol") + +Open buffers appear as tabs across the top. The sidebar shows your file tree and Git status. Toggle it with `Cmd+1` (just like PyCharm's Project tool window). + +## Differences in Keybindings + +If you chose the JetBrains keymap during onboarding, most of your shortcuts should already feel familiar. Here's a quick reference for how Zed compares to PyCharm. + +### Common Shared Keybindings + +| Action | Shortcut | +| ----------------------------- | ----------------------- | +| Search Everywhere | `Shift Shift` | +| Find Action / Command Palette | `Cmd + Shift + A` | +| Go to File | `Cmd + Shift + O` | +| Go to Symbol | `Cmd + O` | +| Recent Files | `Cmd + E` | +| Go to Definition | `Cmd + B` | +| Find Usages | `Alt + F7` | +| Rename Symbol | `Shift + F6` | +| Reformat Code | `Cmd + Alt + L` | +| Toggle Project Panel | `Cmd + 1` | +| Toggle Terminal | `Alt + F12` | +| Duplicate Line | `Cmd + D` | +| Delete Line | `Cmd + Backspace` | +| Move Line Up/Down | `Shift + Alt + Up/Down` | +| Expand/Shrink Selection | `Alt + Up/Down` | +| Comment Line | `Cmd + /` | +| Go Back / Forward | `Cmd + [` / `Cmd + ]` | +| Toggle Breakpoint | `Ctrl + F8` | + +### Different Keybindings (PyCharm → Zed) + +| Action | PyCharm | Zed (JetBrains keymap) | +| ---------------------- | ----------- | ------------------------ | +| File Structure | `Cmd + F12` | `Cmd + F12` (outline) | +| Navigate to Next Error | `F2` | `F2` | +| Run | `Ctrl + R` | `Ctrl + Alt + R` (tasks) | +| Debug | `Ctrl + D` | `Alt + Shift + F9` | +| Stop | `Cmd + F2` | `Ctrl + F2` | + +### Unique to Zed + +| Action | Shortcut | Notes | +| ----------------- | -------------------------- | ------------------------------ | +| Toggle Right Dock | `Cmd + R` | Assistant panel, notifications | +| Split Panes | `Cmd + K`, then arrow keys | Create splits in any direction | + +### How to Customize Keybindings + +- Open the Command Palette (`Cmd+Shift+A` or `Shift Shift`) +- Run `Zed: Open Keymap Editor` + +This opens a list of all available bindings. You can override individual shortcuts or remove conflicts. + +Zed also supports key sequences (multi-key shortcuts). + +## Differences in User Interfaces + +### No Indexing + +If you've used PyCharm on large projects, you know the wait: "Indexing..." can take anywhere from 30 seconds to several minutes depending on project size and dependencies. PyCharm builds a comprehensive index of your entire codebase to power its code intelligence, and it re-indexes when dependencies change or when you install new packages. + +Zed doesn't index. You open a folder and start working immediately. File search and navigation work instantly regardless of project size. For many PyCharm users, this alone is reason enough to switch—no more waiting, no more "Indexing paused" interruptions. + +PyCharm's index powers features like finding all usages across your entire codebase, understanding class hierarchies, and detecting unused imports project-wide. Zed delegates this work to language servers, which may not analyze as deeply or as broadly. + +**How to adapt:** + +- For project-wide symbol search, use `Cmd+O` / Go to Symbol (relies on your language server) +- For finding files by name, use `Cmd+Shift+O` / Go to File +- For text search across files, use `Cmd+Shift+F`—this is fast even on large codebases +- For deep static analysis, consider running tools like `mypy`, `pylint`, or `ruff check` from the terminal + +### LSP vs. Native Language Intelligence + +PyCharm has its own language analysis engine built specifically for Python. This engine understands your code deeply: it resolves types without annotations, tracks data flow, knows about Django models and Flask routes, and offers specialized refactorings. + +Zed uses the Language Server Protocol (LSP) for code intelligence. For Python, Zed provides several language servers out of the box: + +- **basedpyright** (default) — Fast type checking and completions +- **Ruff** (default) — Linting and formatting +- **Ty** — Up-and-coming language server from Astral, built for speed +- **Pyright** — Microsoft's type checker +- **PyLSP** — Plugin-based server with tool integrations + +The LSP experience for Python is strong. basedpyright provides accurate completions, type checking, and navigation. Ruff handles formatting and linting with excellent performance. + +Where you might notice differences: + +- Framework-specific intelligence (Django ORM, Flask routes) isn't built-in +- Some complex refactorings (extract method with proper scope analysis) may be less sophisticated +- Auto-import suggestions depend on what the language server knows about your environment + +**How to adapt:** + +- Use `Alt+Enter` for available code actions—the list will vary by language server +- Ensure your virtual environment is selected so the language server can resolve your dependencies +- Use Ruff for fast, consistent formatting (it's enabled by default) +- For code inspection similar to PyCharm's "Inspect Code," run `ruff check .` or check the Diagnostics panel (`Cmd+6`)—basedpyright and Ruff together catch many of the same issues + +### Virtual Environments and Interpreters + +In PyCharm, you select a Python interpreter through a GUI, and PyCharm manages the connection between your project and that interpreter. It shows available packages, lets you install new ones, and keeps track of which environment each project uses. + +Zed handles virtual environments through its toolchain system: + +- Zed automatically discovers virtual environments in common locations (`.venv`, `venv`, `.env`, `env`) +- When a virtual environment is detected, the terminal auto-activates it +- Language servers are automatically configured to use the discovered environment +- You can manually select a toolchain if auto-detection picks the wrong one + +**How to adapt:** + +- Create your virtual environment with `python -m venv .venv` or `uv sync` +- Open the folder in Zed—it will detect the environment automatically +- If you need to switch environments, use the toolchain selector +- For conda environments, ensure they're activated in your shell before launching Zed + +> **Tip:** If basedpyright shows import errors for packages you've installed, check that Zed has selected the correct virtual environment. Use the toolchain selector to verify or change the active environment. + +### No Project Model + +PyCharm manages projects through `.idea` folders containing XML configuration files, interpreter assignments, and run configurations. This model lets PyCharm remember your interpreter choice, manage dependencies through the UI, and persist complex run/debug setups. + +Zed has no project model. A project is a folder. There's no wizard, no interpreter selection screen, no project structure configuration. + +This means: + +- Run configurations don't exist. You define tasks or use the terminal. Your existing PyCharm run configs in `.idea/` won't be read—you'll recreate the ones you need in `tasks.json`. +- Interpreter management is external. Zed discovers environments but doesn't create them. +- Dependencies are managed through pip, uv, poetry, or conda—not through the editor. +- There's no Python Console (interactive REPL) panel. Use `python` or `ipython` in the terminal instead. + +**How to adapt:** + +- Create a `.zed/settings.json` in your project root for project-specific settings +- Define common commands in `tasks.json` (open via Command Palette: `zed: open tasks`): + +```json +[ + { + "label": "run", + "command": "python main.py" + }, + { + "label": "test", + "command": "pytest" + }, + { + "label": "test current file", + "command": "pytest $ZED_FILE" + } +] +``` + +- Use `Ctrl+Alt+R` to run tasks quickly +- Lean on your terminal (`Alt+F12`) for anything tasks don't cover + +### No Framework Integration + +PyCharm Professional's value for web development comes largely from its framework integration. Django templates are understood and navigable. Flask routes are indexed. SQLAlchemy models get special treatment. Template variables autocomplete. + +Zed has none of this. The language server sees Python code as Python code—it doesn't understand that `@app.route` defines an endpoint or that a Django model class creates database tables. + +**How to adapt:** + +- Use grep and file search liberally. `Cmd+Shift+F` with a regex can find route definitions, model classes, or template usages. +- Rely on your language server's "find references" (`Alt+F7`) for navigation—it works, just without framework context +- Consider using framework-specific CLI tools (`python manage.py`, `flask routes`) from Zed's terminal + +> **Tip:** For database work, pick up a dedicated tool like DataGrip, DBeaver, or TablePlus. Many developers who switch to Zed keep DataGrip around specifically for SQL. + +### Tool Windows vs. Docks + +PyCharm organizes auxiliary views into numbered tool windows (Project = 1, Python Console = 4, Terminal = Alt+F12, etc.). Zed uses a similar concept called "docks": + +| PyCharm Tool Window | Zed Equivalent | Shortcut (JetBrains keymap) | +| ------------------- | -------------- | --------------------------- | +| Project (1) | Project Panel | `Cmd + 1` | +| Git (9 or Cmd+0) | Git Panel | `Cmd + 0` | +| Terminal (Alt+F12) | Terminal Panel | `Alt + F12` | +| Structure (7) | Outline Panel | `Cmd + 7` | +| Problems (6) | Diagnostics | `Cmd + 6` | +| Debug (5) | Debug Panel | `Cmd + 5` | + +Zed has three dock positions: left, bottom, and right. Panels can be moved between docks by dragging or through settings. + +### Debugging + +Both PyCharm and Zed offer integrated debugging, but the experience differs: + +- Zed uses `debugpy` (the same debug adapter that VS Code uses) +- Set breakpoints with `Ctrl+F8` +- Start debugging with `Alt+Shift+F9` or press `F4` and select a debug target +- Step through code with `F7` (step into), `F8` (step over), `Shift+F8` (step out) +- Continue execution with `F9` + +Zed can automatically detect debuggable entry points. Press `F4` to see available options, including: + +- Python scripts +- Modules +- pytest tests + +For more control, create a `.zed/debug.json` file: + +```json +[ + { + "label": "Debug Current File", + "adapter": "Debugpy", + "program": "$ZED_FILE", + "request": "launch" + }, + { + "label": "Debug Flask App", + "adapter": "Debugpy", + "request": "launch", + "module": "flask", + "args": ["run", "--debug"], + "env": { + "FLASK_APP": "app.py" + } + } +] +``` + +### Running Tests + +PyCharm has a dedicated test runner with a visual interface showing pass/fail status for each test. Zed provides test running through: + +- **Gutter icons** — Click the play button next to test functions or classes +- **Tasks** — Define pytest or unittest commands in `tasks.json` +- **Terminal** — Run `pytest` directly + +The test output appears in the terminal panel. For pytest, use `--tb=short` for concise tracebacks or `-v` for verbose output. + +### Extensions vs. Plugins + +PyCharm has a plugin ecosystem covering everything from additional language support to database tools to deployment integrations. + +Zed's extension ecosystem is smaller and more focused: + +- Language support and syntax highlighting +- Themes +- Slash commands for AI +- Context servers + +Several features that require plugins in PyCharm are built into Zed: + +- Real-time collaboration with voice chat +- AI coding assistance +- Built-in terminal +- Task runner +- LSP-based code intelligence +- Ruff formatting and linting + +### What's Not in Zed + +To set expectations clearly, here's what PyCharm offers that Zed doesn't have: + +- **Scientific Mode / Jupyter integration** — For notebooks and data science workflows, use JupyterLab or VS Code with the Jupyter extension alongside Zed for your Python editing +- **Database tools** — Use DataGrip, DBeaver, or TablePlus +- **Django/Flask template navigation** — Use file search and grep +- **Visual package manager** — Use pip, uv, or poetry from the terminal +- **Remote interpreters** — Zed has remote development, but it works differently +- **Profiler integration** — Use cProfile, py-spy, or similar tools externally + +## Collaboration in Zed vs. PyCharm + +PyCharm offers Code With Me as a separate plugin for collaboration. Zed has collaboration built into the core experience. + +- Open the Collab Panel in the left dock +- Create a channel and [invite your collaborators](https://zed.dev/docs/collaboration#inviting-a-collaborator) to join +- [Share your screen or your codebase](https://zed.dev/docs/collaboration#share-a-project) directly + +Once connected, you'll see each other's cursors, selections, and edits in real time. Voice chat is included. There's no need for separate tools or third-party logins. + +## Using AI in Zed + +If you're used to AI assistants in PyCharm (like GitHub Copilot or JetBrains AI Assistant), Zed offers similar capabilities with more flexibility. + +### Configuring GitHub Copilot + +1. Open Settings with `Cmd+,` (macOS) or `Ctrl+,` (Linux/Windows) +2. Navigate to **AI → Edit Predictions** +3. Click **Configure** next to "Configure Providers" +4. Under **GitHub Copilot**, click **Sign in to GitHub** + +Once signed in, just start typing. Zed will offer suggestions inline for you to accept. + +### Additional AI Options + +To use other AI models in Zed, you have several options: + +- Use Zed's hosted models, with higher rate limits. Requires [authentication](https://zed.dev/docs/accounts.html) and subscription to [Zed Pro](https://zed.dev/docs/ai/subscription.html). +- Bring your own [API keys](https://zed.dev/docs/ai/llm-providers.html), no authentication needed +- Use [external agents like Claude Code](https://zed.dev/docs/ai/external-agents.html) + +## Advanced Config and Productivity Tweaks + +Zed exposes advanced settings for power users who want to fine-tune their environment. + +Here are a few useful tweaks: + +**Format on Save:** + +```json +"format_on_save": "on" +``` + +**Enable direnv support (useful for Python projects using direnv):** + +```json +"load_direnv": "shell_hook" +``` + +**Customize virtual environment detection:** + +```json +{ + "terminal": { + "detect_venv": { + "on": { + "directories": [".venv", "venv", ".env", "env"], + "activate_script": "default" + } + } + } +} +``` + +**Configure basedpyright type checking strictness:** + +If you find basedpyright too strict or too lenient, configure it in your project's `pyrightconfig.json`: + +```json +{ + "typeCheckingMode": "basic" +} +``` + +Options are `"off"`, `"basic"`, `"standard"` (default), `"strict"`, or `"all"`. + +## Next Steps + +Now that you're set up, here are some resources to help you get the most out of Zed: + +- [Configuring Zed](../configuring-zed.md) — Customize settings, themes, and editor behavior +- [Key Bindings](../key-bindings.md) — Learn how to customize and extend your keymap +- [Tasks](../tasks.md) — Set up build and run commands for your projects +- [AI Features](../ai/overview.md) — Explore Zed's AI capabilities beyond code completion +- [Collaboration](../collaboration/overview.md) — Share your projects and code together in real time +- [Python in Zed](../languages/python.md) — Python-specific setup and configuration diff --git a/docs/src/migrate/rustrover.md b/docs/src/migrate/rustrover.md new file mode 100644 index 0000000000000000000000000000000000000000..4d0e85cfe9b981243044290929070e87876987d3 --- /dev/null +++ b/docs/src/migrate/rustrover.md @@ -0,0 +1,501 @@ +# How to Migrate from RustRover to Zed + +This guide covers how to set up Zed if you're coming from RustRover, including keybindings, settings, and the differences you should expect as a Rust developer. + +## Install Zed + +Zed is available on macOS, Windows, and Linux. + +For macOS, you can download it from zed.dev/download, or install via Homebrew: + +```sh +brew install --cask zed +``` + +For Windows, download the installer from zed.dev/download, or install via winget: + +```sh +winget install Zed.Zed +``` + +For most Linux users, the easiest way to install Zed is through our installation script: + +```sh +curl -f https://zed.dev/install.sh | sh +``` + +After installation, you can launch Zed from your Applications folder (macOS), Start menu (Windows), or directly from the terminal using: +`zed .` +This opens the current directory in Zed. + +## Set Up the JetBrains Keymap + +If you're coming from RustRover, the fastest way to feel at home is to use the JetBrains keymap. During onboarding, you can select it as your base keymap. If you missed that step, you can change it anytime: + +1. Open Settings with `Cmd+,` (macOS) or `Ctrl+,` (Linux/Windows) +2. Search for `Base Keymap` +3. Select `JetBrains` + +Or add this directly to your `settings.json`: + +```json +{ + "base_keymap": "JetBrains" +} +``` + +This maps familiar shortcuts like `Shift Shift` for Search Everywhere, `Cmd+O` for Go to Class, and `Cmd+Shift+A` for Find Action. + +## Set Up Editor Preferences + +You can configure settings manually in the Settings Editor. + +To edit your settings: + +1. `Cmd+,` to open the Settings Editor. +2. Run `zed: open settings` in the Command Palette. + +Settings RustRover users typically configure first: + +| Zed Setting | What it does | +| ----------------------- | ------------------------------------------------------------------------------- | +| `format_on_save` | Auto-format when saving. Set to `"on"` to enable (uses rustfmt by default). | +| `soft_wrap` | Wrap long lines. Options: `"none"`, `"editor_width"`, `"preferred_line_length"` | +| `preferred_line_length` | Column width for wrapping and rulers. Rust convention is 100. | +| `inlay_hints` | Show type hints, parameter names, and chaining hints inline. | +| `relative_line_numbers` | Useful if you're coming from IdeaVim. | + +Zed also supports per-project settings. Create a `.zed/settings.json` file in your project root to override global settings for that project, similar to how you might use `.idea` folders in RustRover. + +> **Tip:** If you're joining an existing project, check `format_on_save` before making your first commit. Otherwise you might accidentally reformat an entire file when you only meant to change one line. + +## Open or Create a Project + +After setup, press `Cmd+Shift+O` (with JetBrains keymap) to open a folder. This becomes your workspace in Zed. Unlike RustRover, there's no project configuration wizard, no toolchain selection dialog, and no Cargo project setup screen. + +To start a new project, use Cargo from the terminal: + +```sh +cargo new my_project +cd my_project +zed . +``` + +Or for a library: + +```sh +cargo new --lib my_library +``` + +You can also launch Zed from the terminal inside any existing Cargo project with: +`zed .` + +Once inside a project: + +- Use `Cmd+Shift+O` or `Cmd+E` to jump between files quickly (like RustRover's "Recent Files") +- Use `Cmd+Shift+A` or `Shift Shift` to open the Command Palette (like RustRover's "Search Everywhere") +- Use `Cmd+O` to search for symbols (like RustRover's "Go to Symbol") + +Open buffers appear as tabs across the top. The sidebar shows your file tree and Git status. Toggle it with `Cmd+1` (just like RustRover's Project tool window). + +## Differences in Keybindings + +If you chose the JetBrains keymap during onboarding, most of your shortcuts should already feel familiar. Here's a quick reference for how Zed compares to RustRover. + +### Common Shared Keybindings + +| Action | Shortcut | +| ----------------------------- | ----------------------- | +| Search Everywhere | `Shift Shift` | +| Find Action / Command Palette | `Cmd + Shift + A` | +| Go to File | `Cmd + Shift + O` | +| Go to Symbol | `Cmd + O` | +| Recent Files | `Cmd + E` | +| Go to Definition | `Cmd + B` | +| Find Usages | `Alt + F7` | +| Rename Symbol | `Shift + F6` | +| Reformat Code | `Cmd + Alt + L` | +| Toggle Project Panel | `Cmd + 1` | +| Toggle Terminal | `Alt + F12` | +| Duplicate Line | `Cmd + D` | +| Delete Line | `Cmd + Backspace` | +| Move Line Up/Down | `Shift + Alt + Up/Down` | +| Expand/Shrink Selection | `Alt + Up/Down` | +| Comment Line | `Cmd + /` | +| Go Back / Forward | `Cmd + [` / `Cmd + ]` | +| Toggle Breakpoint | `Ctrl + F8` | + +### Different Keybindings (RustRover → Zed) + +| Action | RustRover | Zed (JetBrains keymap) | +| ---------------------- | ----------- | ------------------------ | +| File Structure | `Cmd + F12` | `Cmd + F12` (outline) | +| Navigate to Next Error | `F2` | `F2` | +| Run | `Ctrl + R` | `Ctrl + Alt + R` (tasks) | +| Debug | `Ctrl + D` | `Alt + Shift + F9` | +| Stop | `Cmd + F2` | `Ctrl + F2` | +| Expand Macro | `Alt+Enter` | `Cmd + Shift + M` | + +### Unique to Zed + +| Action | Shortcut | Notes | +| ----------------- | -------------------------- | ------------------------------ | +| Toggle Right Dock | `Cmd + R` | Assistant panel, notifications | +| Split Panes | `Cmd + K`, then arrow keys | Create splits in any direction | + +### How to Customize Keybindings + +- Open the Command Palette (`Cmd+Shift+A` or `Shift Shift`) +- Run `Zed: Open Keymap Editor` + +This opens a list of all available bindings. You can override individual shortcuts or remove conflicts. + +Zed also supports key sequences (multi-key shortcuts). + +## Differences in User Interfaces + +### No Indexing + +RustRover indexes your project when you first open it to build a model of your codebase. This process runs whenever you open a project or when dependencies change via Cargo. + +Zed skips the indexing step. You open a folder and start working right away. Since both editors rely on rust-analyzer for Rust intelligence, the analysis still happens—but in Zed it runs in the background without blocking the UI or showing modal progress dialogs. + +**How to adapt:** + +- Use `Cmd+O` to search symbols across your crate (rust-analyzer handles this) +- Jump to files by name with `Cmd+Shift+O` +- `Cmd+Shift+F` gives you fast text search across the entire project +- For linting and deeper checks, run `cargo clippy` in the terminal + +### rust-analyzer: Shared Foundation, Different Integration + +Here's what makes the RustRover-to-Zed transition unique: **both editors use rust-analyzer** for Rust language intelligence. This means the core code analysis—completions, go-to-definition, find references, type inference—is fundamentally the same. + +RustRover integrates rust-analyzer into its JetBrains platform, adding a GUI layer, additional refactorings, and its own indexing on top. Zed uses rust-analyzer more directly through the Language Server Protocol (LSP). + +What this means for you: + +- **Completions** — Same quality, powered by rust-analyzer +- **Type inference** — Identical, it's the same engine +- **Go to definition / Find usages** — Works the same way +- **Macro expansion** — Available in both (use `Cmd+Shift+M` in Zed) +- **Inlay hints** — Both support type hints, parameter hints, and chaining hints + +Where you might notice differences: + +- Some refactorings available in RustRover may not have rust-analyzer equivalents +- RustRover's GUI for configuring rust-analyzer is replaced by JSON configuration in Zed +- RustRover-specific inspections (beyond Clippy) won't exist in Zed + +**How to adapt:** + +- Use `Alt+Enter` for available code actions—rust-analyzer provides many +- Configure rust-analyzer settings in `.zed/settings.json` for project-specific needs +- Run `cargo clippy` for linting (it integrates with rust-analyzer diagnostics) + +### No Project Model + +RustRover manages projects through `.idea` folders containing XML configuration files, toolchain assignments, and run configurations. The Cargo tool window provides a visual interface for your project structure, targets, and dependencies. + +Zed keeps it simpler: a project is a folder with a `Cargo.toml`. No project wizard, no toolchain dialogs, no visual Cargo management layer. + +In practice: + +- Run configurations don't carry over. Your `.idea/` setup stays behind—define the commands you need in `tasks.json` instead. +- Toolchains are managed externally via `rustup`. +- Dependencies live in `Cargo.toml`. Edit the file directly; rust-analyzer provides completions for crate names and versions. + +**How to adapt:** + +- Create a `.zed/settings.json` in your project root for project-specific settings +- Define common commands in `tasks.json` (open via Command Palette: `zed: open tasks`): + +```json +[ + { + "label": "cargo run", + "command": "cargo run" + }, + { + "label": "cargo build", + "command": "cargo build" + }, + { + "label": "cargo test", + "command": "cargo test" + }, + { + "label": "cargo clippy", + "command": "cargo clippy" + }, + { + "label": "cargo run --release", + "command": "cargo run --release" + } +] +``` + +- Use `Ctrl+Alt+R` to run tasks quickly +- Lean on your terminal (`Alt+F12`) for anything tasks don't cover + +### No Cargo Integration UI + +RustRover's Cargo tool window provides visual access to your project's targets, dependencies, and common Cargo commands. You can run builds, tests, and benchmarks with a click. + +Zed doesn't have a Cargo GUI. You work with Cargo through: + +- **Terminal** — Run any Cargo command directly +- **Tasks** — Define shortcuts for common commands +- **Gutter icons** — Run tests and binaries with clickable icons + +**How to adapt:** + +- Get comfortable with Cargo CLI commands: `cargo build`, `cargo run`, `cargo test`, `cargo clippy`, `cargo doc` +- Use tasks for commands you run frequently +- For dependency management, edit `Cargo.toml` directly (rust-analyzer provides completions for crate names and versions) + +### Tool Windows vs. Docks + +RustRover organizes auxiliary views into numbered tool windows (Project = 1, Cargo = Alt+1, Terminal = Alt+F12, etc.). Zed uses a similar concept called "docks": + +| RustRover Tool Window | Zed Equivalent | Shortcut (JetBrains keymap) | +| --------------------- | -------------- | --------------------------- | +| Project (1) | Project Panel | `Cmd + 1` | +| Git (9 or Cmd+0) | Git Panel | `Cmd + 0` | +| Terminal (Alt+F12) | Terminal Panel | `Alt + F12` | +| Structure (7) | Outline Panel | `Cmd + 7` | +| Problems (6) | Diagnostics | `Cmd + 6` | +| Debug (5) | Debug Panel | `Cmd + 5` | + +Zed has three dock positions: left, bottom, and right. Panels can be moved between docks by dragging or through settings. + +Note that there's no dedicated Cargo tool window in Zed. Use the terminal or define tasks for your common Cargo commands. + +### Debugging + +Both RustRover and Zed offer integrated debugging for Rust, but using different backends: + +- RustRover uses its own debugger integration +- Zed uses **CodeLLDB** (the same debug adapter popular in VS Code) + +To debug Rust code in Zed: + +- Set breakpoints with `Ctrl+F8` +- Start debugging with `Alt+Shift+F9` or press `F4` and select a debug target +- Step through code with `F7` (step into), `F8` (step over), `Shift+F8` (step out) +- Continue execution with `F9` + +Zed can automatically detect debuggable targets in your Cargo project. Press `F4` to see available options. + +For more control, create a `.zed/debug.json` file: + +```json +[ + { + "label": "Debug Binary", + "adapter": "CodeLLDB", + "request": "launch", + "program": "${workspaceFolder}/target/debug/my_project" + }, + { + "label": "Debug Tests", + "adapter": "CodeLLDB", + "request": "launch", + "cargo": { + "args": ["test", "--no-run"], + "filter": { + "kind": "test" + } + } + }, + { + "label": "Debug with Arguments", + "adapter": "CodeLLDB", + "request": "launch", + "program": "${workspaceFolder}/target/debug/my_project", + "args": ["--config", "dev.toml"] + } +] +``` + +> **Note:** Some users have reported that RustRover's debugger can have issues with variable inspection and breakpoints in certain scenarios. CodeLLDB in Zed provides a solid alternative, though debugging Rust can be challenging in any editor due to optimizations and macro-generated code. + +### Running Tests + +RustRover has a dedicated test runner with a visual interface showing pass/fail status for each test. Zed provides test running through: + +- **Gutter icons** — Click the play button next to `#[test]` functions or test modules +- **Tasks** — Define `cargo test` commands in `tasks.json` +- **Terminal** — Run `cargo test` directly + +The test output appears in the terminal panel. For more detailed output, use: + +- `cargo test -- --nocapture` to see println! output +- `cargo test -- --test-threads=1` for sequential test execution +- `cargo test specific_test_name` to run a single test + +### Extensions vs. Plugins + +RustRover has a plugin ecosystem, though it's more limited than other JetBrains IDEs since Rust support is built-in. + +Zed's extension ecosystem is smaller and more focused: + +- Language support and syntax highlighting +- Themes +- Slash commands for AI +- Context servers + +Several features that might require plugins in other editors are built into Zed: + +- Real-time collaboration with voice chat +- AI coding assistance +- Built-in terminal +- Task runner +- rust-analyzer integration +- rustfmt formatting + +### What's Not in Zed + +To set expectations clearly, here's what RustRover offers that Zed doesn't have: + +- **Cargo.toml GUI editor** — Edit the file directly (rust-analyzer helps with completions) +- **Visual dependency management** — Use `cargo add`, `cargo remove`, or edit `Cargo.toml` +- **Profiler integration** — Use `cargo flamegraph`, `perf`, or external profiling tools +- **Database tools** — Use DataGrip, DBeaver, or TablePlus +- **HTTP Client** — Use tools like `curl`, `httpie`, or Postman +- **Coverage visualization** — Use `cargo tarpaulin` or `cargo llvm-cov` externally + +## A Note on Licensing and Telemetry + +If you're moving from RustRover partly due to licensing concerns or telemetry policies, you should know: + +- **Zed is open source** (MIT licensed for the editor, AGPL for collaboration services) +- **Telemetry is optional** and can be disabled during onboarding or in settings +- **No license tiers**: All features are available to everyone + +## Collaboration in Zed vs. RustRover + +RustRover offers Code With Me as a separate feature for collaboration. Zed has collaboration built into the core experience. + +- Open the Collab Panel in the left dock +- Create a channel and [invite your collaborators](https://zed.dev/docs/collaboration#inviting-a-collaborator) to join +- [Share your screen or your codebase](https://zed.dev/docs/collaboration#share-a-project) directly + +Once connected, you'll see each other's cursors, selections, and edits in real time. Voice chat is included. There's no need for separate tools or third-party logins. + +## Using AI in Zed + +If you're used to AI assistants in RustRover (like JetBrains AI Assistant), Zed offers similar capabilities with more flexibility. + +### Configuring GitHub Copilot + +1. Open Settings with `Cmd+,` (macOS) or `Ctrl+,` (Linux/Windows) +2. Navigate to **AI → Edit Predictions** +3. Click **Configure** next to "Configure Providers" +4. Under **GitHub Copilot**, click **Sign in to GitHub** + +Once signed in, just start typing. Zed will offer suggestions inline for you to accept. + +### Additional AI Options + +To use other AI models in Zed, you have several options: + +- Use Zed's hosted models, with higher rate limits. Requires [authentication](https://zed.dev/docs/accounts.html) and subscription to [Zed Pro](https://zed.dev/docs/ai/subscription.html). +- Bring your own [API keys](https://zed.dev/docs/ai/llm-providers.html), no authentication needed +- Use [external agents like Claude Code](https://zed.dev/docs/ai/external-agents.html) + +## Advanced Config and Productivity Tweaks + +Zed exposes advanced settings for power users who want to fine-tune their environment. + +Here are a few useful tweaks for Rust developers: + +**Format on Save (uses rustfmt by default):** + +```json +"format_on_save": "on" +``` + +**Configure inlay hints for Rust:** + +```json +{ + "inlay_hints": { + "enabled": true, + "show_type_hints": true, + "show_parameter_hints": true, + "show_other_hints": true + } +} +``` + +**Configure rust-analyzer settings:** + +```json +{ + "lsp": { + "rust-analyzer": { + "initialization_options": { + "checkOnSave": { + "command": "clippy" + }, + "cargo": { + "allFeatures": true + }, + "procMacro": { + "enable": true + } + } + } + } +} +``` + +**Use a separate target directory for rust-analyzer (faster builds):** + +```json +{ + "lsp": { + "rust-analyzer": { + "initialization_options": { + "rust-analyzer.cargo.targetDir": true + } + } + } +} +``` + +This tells rust-analyzer to use `target/rust-analyzer` instead of `target`, so IDE analysis doesn't conflict with your manual `cargo build` commands. + +**Enable direnv support (useful for Rust projects using direnv):** + +```json +"load_direnv": "shell_hook" +``` + +**Configure linked projects for workspaces:** + +If you work with multiple Cargo projects that aren't in a workspace, you can tell rust-analyzer about them: + +```json +{ + "lsp": { + "rust-analyzer": { + "initialization_options": { + "linkedProjects": ["./project-a/Cargo.toml", "./project-b/Cargo.toml"] + } + } + } +} +``` + +## Next Steps + +Now that you're set up, here are some resources to help you get the most out of Zed: + +- [Configuring Zed](../configuring-zed.md) — Customize settings, themes, and editor behavior +- [Key Bindings](../key-bindings.md) — Learn how to customize and extend your keymap +- [Tasks](../tasks.md) — Set up build and run commands for your projects +- [AI Features](../ai/overview.md) — Explore Zed's AI capabilities beyond code completion +- [Collaboration](../collaboration/overview.md) — Share your projects and code together in real time +- [Rust in Zed](../languages/rust.md) — Rust-specific setup and configuration diff --git a/docs/src/migrate/webstorm.md b/docs/src/migrate/webstorm.md new file mode 100644 index 0000000000000000000000000000000000000000..78b80b355b47370a821f08fd6108d947182f0acf --- /dev/null +++ b/docs/src/migrate/webstorm.md @@ -0,0 +1,455 @@ +# How to Migrate from WebStorm to Zed + +This guide covers how to set up Zed if you're coming from WebStorm, including keybindings, settings, and the differences you should expect as a JavaScript/TypeScript developer. + +## Install Zed + +Zed is available on macOS, Windows, and Linux. + +For macOS, you can download it from zed.dev/download, or install via Homebrew: + +```sh +brew install --cask zed +``` + +For Windows, download the installer from zed.dev/download, or install via winget: + +```sh +winget install Zed.Zed +``` + +For most Linux users, the easiest way to install Zed is through our installation script: + +```sh +curl -f https://zed.dev/install.sh | sh +``` + +After installation, you can launch Zed from your Applications folder (macOS), Start menu (Windows), or directly from the terminal using: +`zed .` +This opens the current directory in Zed. + +## Set Up the JetBrains Keymap + +If you're coming from WebStorm, the fastest way to feel at home is to use the JetBrains keymap. During onboarding, you can select it as your base keymap. If you missed that step, you can change it anytime: + +1. Open Settings with `Cmd+,` (macOS) or `Ctrl+,` (Linux/Windows) +2. Search for `Base Keymap` +3. Select `JetBrains` + +Or add this directly to your `settings.json`: + +```json +{ + "base_keymap": "JetBrains" +} +``` + +This maps familiar shortcuts like `Shift Shift` for Search Everywhere, `Cmd+O` for Go to Class, and `Cmd+Shift+A` for Find Action. + +## Set Up Editor Preferences + +You can configure settings manually in the Settings Editor. + +To edit your settings: + +1. `Cmd+,` to open the Settings Editor. +2. Run `zed: open settings` in the Command Palette. + +Settings WebStorm users typically configure first: + +| Zed Setting | What it does | +| ----------------------- | ------------------------------------------------------------------------------- | +| `format_on_save` | Auto-format when saving. Set to `"on"` to enable. | +| `soft_wrap` | Wrap long lines. Options: `"none"`, `"editor_width"`, `"preferred_line_length"` | +| `preferred_line_length` | Column width for wrapping and rulers. Default is 80. | +| `inlay_hints` | Show parameter names and type hints inline, like WebStorm's hints. | +| `relative_line_numbers` | Useful if you're coming from IdeaVim. | + +Zed also supports per-project settings. Create a `.zed/settings.json` file in your project root to override global settings for that project, similar to how you might use `.idea` folders in WebStorm. + +> **Tip:** If you're joining an existing project, check `format_on_save` before making your first commit. Otherwise you might accidentally reformat an entire file when you only meant to change one line. + +## Open or Create a Project + +After setup, press `Cmd+Shift+O` (with JetBrains keymap) to open a folder. This becomes your workspace in Zed. Unlike WebStorm, there's no project configuration wizard, no framework selection dialog, and no project structure setup required. + +To start a new project, create a directory using your terminal or file manager, then open it in Zed. The editor will treat that folder as the root of your project. For new projects, you'd typically run `npm init`, `pnpm create`, or your framework's CLI tool first, then open the resulting folder in Zed. + +You can also launch Zed from the terminal inside any folder with: +`zed .` + +Once inside a project: + +- Use `Cmd+Shift+O` or `Cmd+E` to jump between files quickly (like WebStorm's "Recent Files") +- Use `Cmd+Shift+A` or `Shift Shift` to open the Command Palette (like WebStorm's "Search Everywhere") +- Use `Cmd+O` to search for symbols (like WebStorm's "Go to Symbol") + +Open buffers appear as tabs across the top. The sidebar shows your file tree and Git status. Toggle it with `Cmd+1` (just like WebStorm's Project tool window). + +## Differences in Keybindings + +If you chose the JetBrains keymap during onboarding, most of your shortcuts should already feel familiar. Here's a quick reference for how Zed compares to WebStorm. + +### Common Shared Keybindings + +| Action | Shortcut | +| ----------------------------- | ----------------------- | +| Search Everywhere | `Shift Shift` | +| Find Action / Command Palette | `Cmd + Shift + A` | +| Go to File | `Cmd + Shift + O` | +| Go to Symbol | `Cmd + O` | +| Recent Files | `Cmd + E` | +| Go to Definition | `Cmd + B` | +| Find Usages | `Alt + F7` | +| Rename Symbol | `Shift + F6` | +| Reformat Code | `Cmd + Alt + L` | +| Toggle Project Panel | `Cmd + 1` | +| Toggle Terminal | `Alt + F12` | +| Duplicate Line | `Cmd + D` | +| Delete Line | `Cmd + Backspace` | +| Move Line Up/Down | `Shift + Alt + Up/Down` | +| Expand/Shrink Selection | `Alt + Up/Down` | +| Comment Line | `Cmd + /` | +| Go Back / Forward | `Cmd + [` / `Cmd + ]` | +| Toggle Breakpoint | `Ctrl + F8` | + +### Different Keybindings (WebStorm → Zed) + +| Action | WebStorm | Zed (JetBrains keymap) | +| ---------------------- | ----------- | ------------------------ | +| File Structure | `Cmd + F12` | `Cmd + F12` (outline) | +| Navigate to Next Error | `F2` | `F2` | +| Run | `Ctrl + R` | `Ctrl + Alt + R` (tasks) | +| Debug | `Ctrl + D` | `Alt + Shift + F9` | +| Stop | `Cmd + F2` | `Ctrl + F2` | + +### Unique to Zed + +| Action | Shortcut | Notes | +| ----------------- | -------------------------- | ------------------------------ | +| Toggle Right Dock | `Cmd + R` | Assistant panel, notifications | +| Split Panes | `Cmd + K`, then arrow keys | Create splits in any direction | + +### How to Customize Keybindings + +- Open the Command Palette (`Cmd+Shift+A` or `Shift Shift`) +- Run `Zed: Open Keymap Editor` + +This opens a list of all available bindings. You can override individual shortcuts or remove conflicts. + +Zed also supports key sequences (multi-key shortcuts). + +## Differences in User Interfaces + +### No Indexing + +If you've used WebStorm on large projects, you know the wait. Opening a project with many dependencies can mean watching "Indexing..." for anywhere from 30 seconds to several minutes. WebStorm indexes your entire codebase and `node_modules` to power its code intelligence, and re-indexes when dependencies change. + +Zed doesn't index. You open a folder and start coding immediately—no progress bars, no "Indexing paused" banners. File search and navigation stay fast regardless of project size or how many `node_modules` dependencies you have. + +WebStorm's index enables features like finding all usages across your entire codebase, tracking import hierarchies, and flagging unused exports project-wide. Zed relies on language servers for this analysis, which may not cover as much ground. + +**How to adapt:** + +- Search symbols across the project with `Cmd+O` (powered by the TypeScript language server) +- Find files by name with `Cmd+Shift+O` +- Use `Cmd+Shift+F` for text search—it stays fast even in large monorepos +- Run `tsc --noEmit` or `eslint .` from the terminal when you need deeper project-wide analysis + +### LSP vs. Native Language Intelligence + +WebStorm has its own JavaScript and TypeScript analysis engine built by JetBrains. This engine understands your code deeply: it resolves types, tracks data flow, knows about framework-specific patterns, and offers specialized refactorings. + +Zed uses the Language Server Protocol (LSP) for code intelligence. For JavaScript and TypeScript, Zed supports: + +- **vtsls** (default) — Fast TypeScript language server with excellent performance +- **typescript-language-server** — The standard TypeScript LSP implementation +- **ESLint** — Linting integration +- **Prettier** — Code formatting (built-in) + +The TypeScript LSP experience is mature and robust. You get accurate completions, type checking, go-to-definition, and find-references. The experience is comparable to VS Code, which uses the same underlying TypeScript services. + +Where you might notice differences: + +- Framework-specific intelligence (Angular templates, Vue SFCs) may be less integrated +- Some complex refactorings (extract component with proper imports) may be less sophisticated +- Auto-import suggestions depend on what the language server knows about your project + +**How to adapt:** + +- Use `Alt+Enter` for available code actions—the list will vary by language server +- Ensure your `tsconfig.json` is properly configured so the language server understands your project structure +- Use Prettier for consistent formatting (it's enabled by default for JS/TS) +- For code inspection similar to WebStorm's "Inspect Code," check the Diagnostics panel (`Cmd+6`)—ESLint and TypeScript together catch many of the same issues + +### No Project Model + +WebStorm manages projects through `.idea` folders containing XML configuration files, framework detection, and run configurations. This model lets WebStorm remember your project settings, manage npm scripts through the UI, and persist run/debug setups. + +Zed takes a different approach: a project is just a folder. There's no setup wizard, no framework detection dialog, no project structure to configure. + +What this means in practice: + +- Run configurations aren't a thing. Define reusable commands in `tasks.json` instead. Note that your existing `.idea/` configurations won't carry over—you'll set up the ones you need fresh. +- npm scripts live in the terminal. Run `npm run dev`, `pnpm build`, or `yarn test` directly—there's no dedicated npm panel. +- No framework detection. Zed treats React, Angular, Vue, and vanilla JS/TS the same way. + +**How to adapt:** + +- Create a `.zed/settings.json` in your project root for project-specific settings +- Define common commands in `tasks.json` (open via Command Palette: `zed: open tasks`): + +```json +[ + { + "label": "dev", + "command": "npm run dev" + }, + { + "label": "build", + "command": "npm run build" + }, + { + "label": "test", + "command": "npm test" + }, + { + "label": "test current file", + "command": "npm test -- $ZED_FILE" + } +] +``` + +- Use `Ctrl+Alt+R` to run tasks quickly +- Lean on your terminal (`Alt+F12`) for anything tasks don't cover + +### No Framework Integration + +WebStorm's value for web development comes largely from its framework integration. React components get special treatment. Angular has dedicated tooling. Vue single-file components are fully understood. The npm tool window shows all your scripts. + +Zed has none of this built-in. The TypeScript language server sees your code as TypeScript—it doesn't understand that a function is a React component or that a file is an Angular service. + +**How to adapt:** + +- Use grep and file search liberally. `Cmd+Shift+F` with a regex can find component definitions, route configurations, or API endpoints. +- Rely on your language server's "find references" (`Alt+F7`) for navigation—it works, just without framework context +- Consider using framework-specific CLI tools (`ng`, `next`, `vite`) from Zed's terminal +- For React, JSX/TSX syntax and TypeScript types still provide good intelligence + +> **Tip:** For projects with complex configurations, keep your framework's documentation handy. Zed's speed comes with less hand-holding for framework-specific features. + +### Tool Windows vs. Docks + +WebStorm organizes auxiliary views into numbered tool windows (Project = 1, npm = Alt+F11, Terminal = Alt+F12, etc.). Zed uses a similar concept called "docks": + +| WebStorm Tool Window | Zed Equivalent | Shortcut (JetBrains keymap) | +| -------------------- | -------------- | --------------------------- | +| Project (1) | Project Panel | `Cmd + 1` | +| Git (9 or Cmd+0) | Git Panel | `Cmd + 0` | +| Terminal (Alt+F12) | Terminal Panel | `Alt + F12` | +| Structure (7) | Outline Panel | `Cmd + 7` | +| Problems (6) | Diagnostics | `Cmd + 6` | +| Debug (5) | Debug Panel | `Cmd + 5` | + +Zed has three dock positions: left, bottom, and right. Panels can be moved between docks by dragging or through settings. + +Note that there's no dedicated npm tool window in Zed. Use the terminal or define tasks for your common npm scripts. + +### Debugging + +Both WebStorm and Zed offer integrated debugging for JavaScript and TypeScript: + +- Zed uses `vscode-js-debug` (the same debug adapter that VS Code uses) +- Set breakpoints with `Ctrl+F8` +- Start debugging with `Alt+Shift+F9` or press `F4` and select a debug target +- Step through code with `F7` (step into), `F8` (step over), `Shift+F8` (step out) +- Continue execution with `F9` + +Zed can debug: + +- Node.js applications and scripts +- Chrome/browser JavaScript +- Jest, Mocha, Vitest, and other test frameworks +- Next.js (both server and client-side) + +For more control, create a `.zed/debug.json` file: + +```json +[ + { + "label": "Debug Current File", + "adapter": "JavaScript", + "program": "$ZED_FILE", + "request": "launch" + }, + { + "label": "Debug Node Server", + "adapter": "JavaScript", + "request": "launch", + "program": "${workspaceFolder}/src/server.js" + }, + { + "label": "Attach to Chrome", + "adapter": "JavaScript", + "request": "attach", + "port": 9222 + } +] +``` + +Zed also recognizes `.vscode/launch.json` configurations, so existing VS Code debug setups often work out of the box. + +### Running Tests + +WebStorm has a dedicated test runner with a visual interface showing pass/fail status for each test. Zed provides test running through: + +- **Gutter icons** — Click the play button next to test functions or describe blocks +- **Tasks** — Define test commands in `tasks.json` +- **Terminal** — Run `npm test`, `jest`, `vitest`, etc. directly + +Zed supports auto-detection for common test frameworks: + +- Jest +- Mocha +- Vitest +- Jasmine +- Bun test +- Node.js test runner + +The test output appears in the terminal panel. For Jest, use `--verbose` for detailed output or `--watch` for continuous testing during development. + +### Extensions vs. Plugins + +WebStorm has a plugin ecosystem covering additional language support, themes, and tool integrations. + +Zed's extension ecosystem is smaller and more focused: + +- Language support and syntax highlighting +- Themes +- Slash commands for AI +- Context servers + +Several features that require plugins in WebStorm are built into Zed: + +- Real-time collaboration with voice chat +- AI coding assistance +- Built-in terminal +- Task runner +- LSP-based code intelligence +- Prettier formatting +- ESLint integration + +### What's Not in Zed + +To set expectations clearly, here's what WebStorm offers that Zed doesn't have: + +- **npm tool window** — Use the terminal or tasks instead +- **HTTP Client** — Use tools like Postman, Insomnia, or curl +- **Database tools** — Use DataGrip, DBeaver, or TablePlus +- **Framework-specific tooling** (Angular schematics, React refactorings) — Use CLI tools +- **Visual package.json editor** — Edit the file directly +- **Built-in REST client** — Use external tools or extensions +- **Profiler integration** — Use Chrome DevTools or Node.js profiling tools + +## Collaboration in Zed vs. WebStorm + +WebStorm offers Code With Me as a separate feature for collaboration. Zed has collaboration built into the core experience. + +- Open the Collab Panel in the left dock +- Create a channel and [invite your collaborators](https://zed.dev/docs/collaboration#inviting-a-collaborator) to join +- [Share your screen or your codebase](https://zed.dev/docs/collaboration#share-a-project) directly + +Once connected, you'll see each other's cursors, selections, and edits in real time. Voice chat is included. There's no need for separate tools or third-party logins. + +## Using AI in Zed + +If you're used to AI assistants in WebStorm (like GitHub Copilot, JetBrains AI Assistant, or Junie), Zed offers similar capabilities with more flexibility. + +### Configuring GitHub Copilot + +1. Open Settings with `Cmd+,` (macOS) or `Ctrl+,` (Linux/Windows) +2. Navigate to **AI → Edit Predictions** +3. Click **Configure** next to "Configure Providers" +4. Under **GitHub Copilot**, click **Sign in to GitHub** + +Once signed in, just start typing. Zed will offer suggestions inline for you to accept. + +### Additional AI Options + +To use other AI models in Zed, you have several options: + +- Use Zed's hosted models, with higher rate limits. Requires [authentication](https://zed.dev/docs/accounts.html) and subscription to [Zed Pro](https://zed.dev/docs/ai/subscription.html). +- Bring your own [API keys](https://zed.dev/docs/ai/llm-providers.html), no authentication needed +- Use [external agents like Claude Code](https://zed.dev/docs/ai/external-agents.html) + +## Advanced Config and Productivity Tweaks + +Zed exposes advanced settings for power users who want to fine-tune their environment. + +Here are a few useful tweaks for JavaScript/TypeScript developers: + +**Format on Save:** + +```json +"format_on_save": "on" +``` + +**Configure Prettier as the default formatter:** + +```json +{ + "formatter": { + "external": { + "command": "prettier", + "arguments": ["--stdin-filepath", "{buffer_path}"] + } + } +} +``` + +**Enable ESLint code actions:** + +```json +{ + "lsp": { + "eslint": { + "settings": { + "codeActionOnSave": { + "rules": ["import/order"] + } + } + } + } +} +``` + +**Configure TypeScript strict mode hints:** + +In your `tsconfig.json`, enable strict mode for better type checking: + +```json +{ + "compilerOptions": { + "strict": true, + "noUncheckedIndexedAccess": true + } +} +``` + +**Enable direnv support (useful for projects using direnv for environment variables):** + +```json +"load_direnv": "shell_hook" +``` + +## Next Steps + +Now that you're set up, here are some resources to help you get the most out of Zed: + +- [Configuring Zed](../configuring-zed.md) — Customize settings, themes, and editor behavior +- [Key Bindings](../key-bindings.md) — Learn how to customize and extend your keymap +- [Tasks](../tasks.md) — Set up build and run commands for your projects +- [AI Features](../ai/overview.md) — Explore Zed's AI capabilities beyond code completion +- [Collaboration](../collaboration/overview.md) — Share your projects and code together in real time +- [JavaScript in Zed](../languages/javascript.md) — JavaScript-specific setup and configuration +- [TypeScript in Zed](../languages/typescript.md) — TypeScript-specific setup and configuration From f084e20c56afec3c823a743e3278eade9515f2dd Mon Sep 17 00:00:00 2001 From: Xipeng Jin <56369076+xipeng-jin@users.noreply.github.com> Date: Wed, 17 Dec 2025 11:51:16 -0500 Subject: [PATCH 451/621] Fix stale pending keybinding indicators on focus change (#44678) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #ISSUE Problem: - The status bar’s pending keystroke indicator (shown next to --NORMAL-- in Vim mode) didn’t clear when focus moved to another context, e.g. hitting g in the editor then clicking the Git panel. The keymap state correctly canceled the prefix, but observers that render the indicator never received a “pending input changed” notification, so the UI kept showing stale prefixes until a new keystroke occurred. Fix: - The change introduces a `pending_input_changed_queued` flag and a new helper `notify_pending_input_if_needed` which will flushes the queued notification as soon as we have an App context. The `pending_input_changed` now resets the flag after notifying subscribers. Before: https://github.com/user-attachments/assets/7bec4c34-acbf-42bd-b0d1-88df5ff099aa After: https://github.com/user-attachments/assets/2264dc93-3405-4d63-ad8f-50ada6733ae7 Release Notes: - Fixed: pending keybinding prefixes on the status bar now clear immediately when focus moves to another panel or UI context. --------- Co-authored-by: Nathan Sobo Co-authored-by: Conrad Irwin --- crates/agent_ui/src/acp/message_editor.rs | 6 +- crates/agent_ui/src/acp/thread_view.rs | 14 +- .../add_llm_provider_modal.rs | 10 +- .../configure_context_server_modal.rs | 2 +- .../manage_profiles_modal.rs | 16 +- crates/agent_ui/src/agent_diff.rs | 8 +- crates/agent_ui/src/agent_panel.rs | 16 +- crates/agent_ui/src/inline_assistant.rs | 4 +- crates/agent_ui/src/inline_prompt_editor.rs | 2 +- .../agent_ui/src/terminal_inline_assistant.rs | 6 +- crates/agent_ui/src/text_thread_editor.rs | 2 +- .../agent_ui/src/ui/acp_onboarding_modal.rs | 4 +- .../src/ui/claude_code_onboarding_modal.rs | 4 +- crates/agent_ui/src/ui/onboarding_modal.rs | 4 +- crates/collab_ui/src/collab_panel.rs | 16 +- .../src/collab_panel/channel_modal.rs | 2 +- crates/command_palette/src/command_palette.rs | 6 +- .../src/copilot_edit_prediction_delegate.rs | 4 +- crates/copilot/src/sign_in.rs | 4 +- crates/debugger_ui/src/debugger_panel.rs | 4 +- crates/debugger_ui/src/new_process_modal.rs | 22 +- crates/debugger_ui/src/onboarding_modal.rs | 4 +- crates/debugger_ui/src/session/running.rs | 2 +- .../src/session/running/breakpoint_list.rs | 10 +- .../src/session/running/console.rs | 2 +- .../src/session/running/memory_view.rs | 2 +- .../src/session/running/variable_list.rs | 4 +- crates/diagnostics/src/buffer_diagnostics.rs | 6 +- crates/diagnostics/src/diagnostic_renderer.rs | 2 +- crates/diagnostics/src/diagnostics.rs | 6 +- .../edit_prediction/src/onboarding_modal.rs | 4 +- .../src/rate_prediction_modal.rs | 2 +- crates/editor/benches/editor_render.rs | 6 +- crates/editor/src/editor.rs | 20 +- crates/editor/src/editor_tests.rs | 2 +- crates/editor/src/hover_links.rs | 2 +- crates/editor/src/mouse_context_menu.rs | 10 +- .../src/test/editor_lsp_test_context.rs | 2 +- crates/editor/src/test/editor_test_context.rs | 4 +- crates/file_finder/src/file_finder.rs | 2 +- crates/git_ui/src/branch_picker.rs | 6 +- crates/git_ui/src/commit_modal.rs | 6 +- crates/git_ui/src/file_history_view.rs | 4 +- crates/git_ui/src/git_panel.rs | 18 +- crates/git_ui/src/git_ui.rs | 2 +- crates/git_ui/src/onboarding.rs | 4 +- crates/git_ui/src/project_diff.rs | 10 +- crates/go_to_line/src/go_to_line.rs | 2 +- crates/gpui/examples/focus_visible.rs | 10 +- crates/gpui/examples/input.rs | 2 +- crates/gpui/examples/on_window_close_quit.rs | 4 +- crates/gpui/examples/tab_stop.rs | 10 +- crates/gpui/src/app.rs | 7 +- crates/gpui/src/app/async_context.rs | 2 +- crates/gpui/src/app/context.rs | 4 +- crates/gpui/src/app/test_context.rs | 2 +- crates/gpui/src/elements/div.rs | 6 +- crates/gpui/src/elements/uniform_list.rs | 2 +- crates/gpui/src/interactive.rs | 4 +- crates/gpui/src/key_dispatch.rs | 218 +++++++++++++++++- crates/gpui/src/window.rs | 28 ++- crates/gpui/src/window/prompts.rs | 6 +- .../gpui_macros/src/derive_visual_context.rs | 2 +- crates/keymap_editor/src/keymap_editor.rs | 28 +-- .../src/ui_components/keystroke_input.rs | 4 +- .../language_models/src/provider/bedrock.rs | 8 +- crates/language_tools/src/lsp_log_view.rs | 14 +- crates/language_tools/src/syntax_tree_view.rs | 2 +- crates/markdown/src/markdown.rs | 2 +- .../src/markdown_preview_view.rs | 4 +- crates/onboarding/src/onboarding.rs | 6 +- crates/outline/src/outline.rs | 2 +- crates/outline_panel/src/outline_panel.rs | 12 +- crates/picker/src/picker.rs | 2 +- crates/project_panel/src/project_panel.rs | 18 +- .../recent_projects/src/remote_connections.rs | 2 +- crates/recent_projects/src/remote_servers.rs | 24 +- crates/rules_library/src/rules_library.rs | 14 +- crates/search/src/buffer_search.rs | 26 +-- crates/search/src/project_search.rs | 16 +- crates/search/src/search.rs | 2 +- crates/search/src/search_bar.rs | 2 +- crates/settings_ui/src/settings_ui.rs | 53 ++--- crates/terminal_view/src/terminal_element.rs | 4 +- crates/terminal_view/src/terminal_panel.rs | 20 +- crates/terminal_view/src/terminal_view.rs | 2 +- crates/title_bar/src/title_bar.rs | 2 +- .../src/toolchain_selector.rs | 10 +- crates/ui/src/components/context_menu.rs | 4 +- crates/ui/src/components/navigable.rs | 4 +- crates/ui/src/components/popover_menu.rs | 6 +- crates/ui/src/components/right_click_menu.rs | 6 +- crates/ui_input/src/number_field.rs | 4 +- crates/workspace/src/dock.rs | 8 +- crates/workspace/src/item.rs | 2 +- crates/workspace/src/modal_layer.rs | 4 +- crates/workspace/src/pane.rs | 10 +- crates/workspace/src/welcome.rs | 4 +- crates/workspace/src/workspace.rs | 40 ++-- crates/zed/src/main.rs | 2 +- crates/zed/src/zed.rs | 2 +- crates/zed/src/zed/component_preview.rs | 4 +- 102 files changed, 606 insertions(+), 380 deletions(-) diff --git a/crates/agent_ui/src/acp/message_editor.rs b/crates/agent_ui/src/acp/message_editor.rs index 5e9c55cc56868ac2e7db65043d13eb46efcd89a6..308230a24c6d2ba7fb0c3995b886e9e924d8e1b7 100644 --- a/crates/agent_ui/src/acp/message_editor.rs +++ b/crates/agent_ui/src/acp/message_editor.rs @@ -1365,7 +1365,7 @@ mod tests { cx, ); }); - message_editor.read(cx).focus_handle(cx).focus(window); + message_editor.read(cx).focus_handle(cx).focus(window, cx); message_editor.read(cx).editor().clone() }); @@ -1587,7 +1587,7 @@ mod tests { cx, ); }); - message_editor.read(cx).focus_handle(cx).focus(window); + message_editor.read(cx).focus_handle(cx).focus(window, cx); let editor = message_editor.read(cx).editor().clone(); (message_editor, editor) }); @@ -2315,7 +2315,7 @@ mod tests { cx, ); }); - message_editor.read(cx).focus_handle(cx).focus(window); + message_editor.read(cx).focus_handle(cx).focus(window, cx); let editor = message_editor.read(cx).editor().clone(); (message_editor, editor) }); diff --git a/crates/agent_ui/src/acp/thread_view.rs b/crates/agent_ui/src/acp/thread_view.rs index 63f0054ab7e1d25145974c3862ec7361007bace6..9e9af499727ad8478fa5fc1d46dc3b3bf8e20a71 100644 --- a/crates/agent_ui/src/acp/thread_view.rs +++ b/crates/agent_ui/src/acp/thread_view.rs @@ -253,7 +253,7 @@ impl ThreadFeedbackState { editor }); - editor.read(cx).focus_handle(cx).focus(window); + editor.read(cx).focus_handle(cx).focus(window, cx); editor } } @@ -682,7 +682,7 @@ impl AcpThreadView { }) }); - this.message_editor.focus_handle(cx).focus(window); + this.message_editor.focus_handle(cx).focus(window, cx); cx.notify(); } @@ -784,7 +784,7 @@ impl AcpThreadView { _subscription: subscription, }; if this.message_editor.focus_handle(cx).is_focused(window) { - this.focus_handle.focus(window) + this.focus_handle.focus(window, cx) } cx.notify(); }) @@ -804,7 +804,7 @@ impl AcpThreadView { ThreadState::LoadError(LoadError::Other(format!("{:#}", err).into())) } if self.message_editor.focus_handle(cx).is_focused(window) { - self.focus_handle.focus(window) + self.focus_handle.focus(window, cx) } cx.notify(); } @@ -1270,7 +1270,7 @@ impl AcpThreadView { } }) }; - self.focus_handle(cx).focus(window); + self.focus_handle(cx).focus(window, cx); cx.notify(); } @@ -1322,7 +1322,7 @@ impl AcpThreadView { .await?; this.update_in(cx, |this, window, cx| { this.send_impl(message_editor, window, cx); - this.focus_handle(cx).focus(window); + this.focus_handle(cx).focus(window, cx); })?; anyhow::Ok(()) }) @@ -1465,7 +1465,7 @@ impl AcpThreadView { self.thread_retry_status.take(); self.thread_state = ThreadState::LoadError(error.clone()); if self.message_editor.focus_handle(cx).is_focused(window) { - self.focus_handle.focus(window) + self.focus_handle.focus(window, cx) } } AcpThreadEvent::TitleUpdated => { diff --git a/crates/agent_ui/src/agent_configuration/add_llm_provider_modal.rs b/crates/agent_ui/src/agent_configuration/add_llm_provider_modal.rs index 02269511bb9a4d9b95fe27b66e3ca0a9e5c498c5..e443df33b4ddcaeba32b9b2623c0fdca85fac51c 100644 --- a/crates/agent_ui/src/agent_configuration/add_llm_provider_modal.rs +++ b/crates/agent_ui/src/agent_configuration/add_llm_provider_modal.rs @@ -446,17 +446,17 @@ impl AddLlmProviderModal { }) } - fn on_tab(&mut self, _: &menu::SelectNext, window: &mut Window, _: &mut Context) { - window.focus_next(); + fn on_tab(&mut self, _: &menu::SelectNext, window: &mut Window, cx: &mut Context) { + window.focus_next(cx); } fn on_tab_prev( &mut self, _: &menu::SelectPrevious, window: &mut Window, - _: &mut Context, + cx: &mut Context, ) { - window.focus_prev(); + window.focus_prev(cx); } } @@ -493,7 +493,7 @@ impl Render for AddLlmProviderModal { .on_action(cx.listener(Self::on_tab)) .on_action(cx.listener(Self::on_tab_prev)) .capture_any_mouse_down(cx.listener(|this, _, window, cx| { - this.focus_handle(cx).focus(window); + this.focus_handle(cx).focus(window, cx); })) .child( Modal::new("configure-context-server", None) diff --git a/crates/agent_ui/src/agent_configuration/configure_context_server_modal.rs b/crates/agent_ui/src/agent_configuration/configure_context_server_modal.rs index a0f0be886a1bf5e1485a2d36440b9f91648ef0c6..b30f1494f0d4dcbf3ef63cc7f549d16374f4899b 100644 --- a/crates/agent_ui/src/agent_configuration/configure_context_server_modal.rs +++ b/crates/agent_ui/src/agent_configuration/configure_context_server_modal.rs @@ -831,7 +831,7 @@ impl Render for ConfigureContextServerModal { }), ) .capture_any_mouse_down(cx.listener(|this, _, window, cx| { - this.focus_handle(cx).focus(window); + this.focus_handle(cx).focus(window, cx); })) .child( Modal::new("configure-context-server", None) diff --git a/crates/agent_ui/src/agent_configuration/manage_profiles_modal.rs b/crates/agent_ui/src/agent_configuration/manage_profiles_modal.rs index 127852fd50e81cf56ae37a7af430f88ae2accf99..c7f395ebbd813cfd7c28f33a7e69ec32f6d90fca 100644 --- a/crates/agent_ui/src/agent_configuration/manage_profiles_modal.rs +++ b/crates/agent_ui/src/agent_configuration/manage_profiles_modal.rs @@ -156,7 +156,7 @@ impl ManageProfilesModal { cx.observe_global_in::(window, |this, window, cx| { if matches!(this.mode, Mode::ChooseProfile(_)) { this.mode = Mode::choose_profile(window, cx); - this.focus_handle(cx).focus(window); + this.focus_handle(cx).focus(window, cx); cx.notify(); } }); @@ -173,7 +173,7 @@ impl ManageProfilesModal { fn choose_profile(&mut self, window: &mut Window, cx: &mut Context) { self.mode = Mode::choose_profile(window, cx); - self.focus_handle(cx).focus(window); + self.focus_handle(cx).focus(window, cx); } fn new_profile( @@ -191,7 +191,7 @@ impl ManageProfilesModal { name_editor, base_profile_id, }); - self.focus_handle(cx).focus(window); + self.focus_handle(cx).focus(window, cx); } pub fn view_profile( @@ -209,7 +209,7 @@ impl ManageProfilesModal { delete_profile: NavigableEntry::focusable(cx), cancel_item: NavigableEntry::focusable(cx), }); - self.focus_handle(cx).focus(window); + self.focus_handle(cx).focus(window, cx); } fn configure_default_model( @@ -300,7 +300,7 @@ impl ManageProfilesModal { model_picker, _subscription: dismiss_subscription, }; - self.focus_handle(cx).focus(window); + self.focus_handle(cx).focus(window, cx); } fn configure_mcp_tools( @@ -336,7 +336,7 @@ impl ManageProfilesModal { tool_picker, _subscription: dismiss_subscription, }; - self.focus_handle(cx).focus(window); + self.focus_handle(cx).focus(window, cx); } fn configure_builtin_tools( @@ -377,7 +377,7 @@ impl ManageProfilesModal { tool_picker, _subscription: dismiss_subscription, }; - self.focus_handle(cx).focus(window); + self.focus_handle(cx).focus(window, cx); } fn confirm(&mut self, window: &mut Window, cx: &mut Context) { @@ -951,7 +951,7 @@ impl Render for ManageProfilesModal { .on_action(cx.listener(|this, _: &menu::Cancel, window, cx| this.cancel(window, cx))) .on_action(cx.listener(|this, _: &menu::Confirm, window, cx| this.confirm(window, cx))) .capture_any_mouse_down(cx.listener(|this, _, window, cx| { - this.focus_handle(cx).focus(window); + this.focus_handle(cx).focus(window, cx); })) .on_mouse_down_out(cx.listener(|_this, _, _, cx| cx.emit(DismissEvent))) .child(match &self.mode { diff --git a/crates/agent_ui/src/agent_diff.rs b/crates/agent_ui/src/agent_diff.rs index 06fce64819d3ce66b9e39f2b83cbebefb6ba9698..91d345b7ebb9dae5225626d7a054d0de1882dfe0 100644 --- a/crates/agent_ui/src/agent_diff.rs +++ b/crates/agent_ui/src/agent_diff.rs @@ -212,10 +212,10 @@ impl AgentDiffPane { .focus_handle(cx) .contains_focused(window, cx) { - self.focus_handle.focus(window); + self.focus_handle.focus(window, cx); } else if self.focus_handle.is_focused(window) && !self.multibuffer.read(cx).is_empty() { self.editor.update(cx, |editor, cx| { - editor.focus_handle(cx).focus(window); + editor.focus_handle(cx).focus(window, cx); }); } } @@ -874,12 +874,12 @@ impl AgentDiffToolbar { match active_item { AgentDiffToolbarItem::Pane(agent_diff) => { if let Some(agent_diff) = agent_diff.upgrade() { - agent_diff.focus_handle(cx).focus(window); + agent_diff.focus_handle(cx).focus(window, cx); } } AgentDiffToolbarItem::Editor { editor, .. } => { if let Some(editor) = editor.upgrade() { - editor.read(cx).focus_handle(cx).focus(window); + editor.read(cx).focus_handle(cx).focus(window, cx); } } } diff --git a/crates/agent_ui/src/agent_panel.rs b/crates/agent_ui/src/agent_panel.rs index 071283e7224f08efd0f8df2cdf7a1aca63419081..e41c8b7f5482b3709db2492f5fd81b6f3e7d6eb0 100644 --- a/crates/agent_ui/src/agent_panel.rs +++ b/crates/agent_ui/src/agent_panel.rs @@ -880,7 +880,7 @@ impl AgentPanel { window, cx, ); - text_thread_editor.focus_handle(cx).focus(window); + text_thread_editor.focus_handle(cx).focus(window, cx); } fn external_thread( @@ -1034,7 +1034,7 @@ impl AgentPanel { if let Some(thread_view) = self.active_thread_view() { thread_view.update(cx, |view, cx| { view.expand_message_editor(&ExpandMessageEditor, window, cx); - view.focus_handle(cx).focus(window); + view.focus_handle(cx).focus(window, cx); }); } } @@ -1115,12 +1115,12 @@ impl AgentPanel { match &self.active_view { ActiveView::ExternalAgentThread { thread_view } => { - thread_view.focus_handle(cx).focus(window); + thread_view.focus_handle(cx).focus(window, cx); } ActiveView::TextThread { text_thread_editor, .. } => { - text_thread_editor.focus_handle(cx).focus(window); + text_thread_editor.focus_handle(cx).focus(window, cx); } ActiveView::History | ActiveView::Configuration => {} } @@ -1268,7 +1268,7 @@ impl AgentPanel { Self::handle_agent_configuration_event, )); - configuration.focus_handle(cx).focus(window); + configuration.focus_handle(cx).focus(window, cx); } } @@ -1404,7 +1404,7 @@ impl AgentPanel { } if focus { - self.focus_handle(cx).focus(window); + self.focus_handle(cx).focus(window, cx); } } @@ -1761,7 +1761,7 @@ impl AgentPanel { let thread_view = thread_view.downgrade(); move |_: &menu::Confirm, window, cx| { if let Some(thread_view) = thread_view.upgrade() { - thread_view.focus_handle(cx).focus(window); + thread_view.focus_handle(cx).focus(window, cx); } } }) @@ -1769,7 +1769,7 @@ impl AgentPanel { let thread_view = thread_view.downgrade(); move |_: &editor::actions::Cancel, window, cx| { if let Some(thread_view) = thread_view.upgrade() { - thread_view.focus_handle(cx).focus(window); + thread_view.focus_handle(cx).focus(window, cx); } } }) diff --git a/crates/agent_ui/src/inline_assistant.rs b/crates/agent_ui/src/inline_assistant.rs index 6e3ab7a162bc69a5b0ec081b060b4a2ba08b09aa..052d8598a76d1044c6d97b5378041b5cd12e23b3 100644 --- a/crates/agent_ui/src/inline_assistant.rs +++ b/crates/agent_ui/src/inline_assistant.rs @@ -1197,7 +1197,7 @@ impl InlineAssistant { assist .editor - .update(cx, |editor, cx| window.focus(&editor.focus_handle(cx))) + .update(cx, |editor, cx| window.focus(&editor.focus_handle(cx), cx)) .ok(); } @@ -1209,7 +1209,7 @@ impl InlineAssistant { if let Some(decorations) = assist.decorations.as_ref() { decorations.prompt_editor.update(cx, |prompt_editor, cx| { prompt_editor.editor.update(cx, |editor, cx| { - window.focus(&editor.focus_handle(cx)); + window.focus(&editor.focus_handle(cx), cx); editor.select_all(&SelectAll, window, cx); }) }); diff --git a/crates/agent_ui/src/inline_prompt_editor.rs b/crates/agent_ui/src/inline_prompt_editor.rs index 517f8f08a6e7e9e31b2f88d1f5ee9444202009d5..8d96d56ea67cc9366df420b23e2221636d3450fb 100644 --- a/crates/agent_ui/src/inline_prompt_editor.rs +++ b/crates/agent_ui/src/inline_prompt_editor.rs @@ -357,7 +357,7 @@ impl PromptEditor { creases = insert_message_creases(&mut editor, &existing_creases, window, cx); if focus { - window.focus(&editor.focus_handle(cx)); + window.focus(&editor.focus_handle(cx), cx); } editor }); diff --git a/crates/agent_ui/src/terminal_inline_assistant.rs b/crates/agent_ui/src/terminal_inline_assistant.rs index 84a74242b80d0b2f8479b3c6dbca1c7d0bb2cb6d..cacbc316bb84e74e5c369451791f777a9bf58e82 100644 --- a/crates/agent_ui/src/terminal_inline_assistant.rs +++ b/crates/agent_ui/src/terminal_inline_assistant.rs @@ -127,7 +127,7 @@ impl TerminalInlineAssistant { if let Some(prompt_editor) = assist.prompt_editor.as_ref() { prompt_editor.update(cx, |this, cx| { this.editor.update(cx, |editor, cx| { - window.focus(&editor.focus_handle(cx)); + window.focus(&editor.focus_handle(cx), cx); editor.select_all(&SelectAll, window, cx); }); }); @@ -292,7 +292,7 @@ impl TerminalInlineAssistant { .terminal .update(cx, |this, cx| { this.clear_block_below_cursor(cx); - this.focus_handle(cx).focus(window); + this.focus_handle(cx).focus(window, cx); }) .log_err(); @@ -369,7 +369,7 @@ impl TerminalInlineAssistant { .terminal .update(cx, |this, cx| { this.clear_block_below_cursor(cx); - this.focus_handle(cx).focus(window); + this.focus_handle(cx).focus(window, cx); }) .is_ok() } diff --git a/crates/agent_ui/src/text_thread_editor.rs b/crates/agent_ui/src/text_thread_editor.rs index 947afe050639f89922873a12baa8b1eadfc44995..b26ee44ce53503f3f9b9e77b27a22c0bc39d6473 100644 --- a/crates/agent_ui/src/text_thread_editor.rs +++ b/crates/agent_ui/src/text_thread_editor.rs @@ -1341,7 +1341,7 @@ impl TextThreadEditor { if let Some((text, _)) = Self::get_selection_or_code_block(&context_editor_view, cx) { active_editor_view.update(cx, |editor, cx| { editor.insert(&text, window, cx); - editor.focus_handle(cx).focus(window); + editor.focus_handle(cx).focus(window, cx); }) } } diff --git a/crates/agent_ui/src/ui/acp_onboarding_modal.rs b/crates/agent_ui/src/ui/acp_onboarding_modal.rs index 8433904fb3b540c2d78c8634b7a6755303d6e15c..e48a36bd5af3eff578e230195dc2247900977173 100644 --- a/crates/agent_ui/src/ui/acp_onboarding_modal.rs +++ b/crates/agent_ui/src/ui/acp_onboarding_modal.rs @@ -222,8 +222,8 @@ impl Render for AcpOnboardingModal { acp_onboarding_event!("Canceled", trigger = "Action"); cx.emit(DismissEvent); })) - .on_any_mouse_down(cx.listener(|this, _: &MouseDownEvent, window, _cx| { - this.focus_handle.focus(window); + .on_any_mouse_down(cx.listener(|this, _: &MouseDownEvent, window, cx| { + this.focus_handle.focus(window, cx); })) .child(illustration) .child( diff --git a/crates/agent_ui/src/ui/claude_code_onboarding_modal.rs b/crates/agent_ui/src/ui/claude_code_onboarding_modal.rs index 06980f18977aefe228bb7f09962e69fe2b3a5068..a8f007666d8957a7195fdf36b612b578b16f543c 100644 --- a/crates/agent_ui/src/ui/claude_code_onboarding_modal.rs +++ b/crates/agent_ui/src/ui/claude_code_onboarding_modal.rs @@ -230,8 +230,8 @@ impl Render for ClaudeCodeOnboardingModal { claude_code_onboarding_event!("Canceled", trigger = "Action"); cx.emit(DismissEvent); })) - .on_any_mouse_down(cx.listener(|this, _: &MouseDownEvent, window, _cx| { - this.focus_handle.focus(window); + .on_any_mouse_down(cx.listener(|this, _: &MouseDownEvent, window, cx| { + this.focus_handle.focus(window, cx); })) .child(illustration) .child( diff --git a/crates/agent_ui/src/ui/onboarding_modal.rs b/crates/agent_ui/src/ui/onboarding_modal.rs index ad404afa784974631f914e6fece2de6b6c7d6a46..b8ec2b00657efca29fede32a5cc23b669ede66e7 100644 --- a/crates/agent_ui/src/ui/onboarding_modal.rs +++ b/crates/agent_ui/src/ui/onboarding_modal.rs @@ -83,8 +83,8 @@ impl Render for AgentOnboardingModal { agent_onboarding_event!("Canceled", trigger = "Action"); cx.emit(DismissEvent); })) - .on_any_mouse_down(cx.listener(|this, _: &MouseDownEvent, window, _cx| { - this.focus_handle.focus(window); + .on_any_mouse_down(cx.listener(|this, _: &MouseDownEvent, window, cx| { + this.focus_handle.focus(window, cx); })) .child( div() diff --git a/crates/collab_ui/src/collab_panel.rs b/crates/collab_ui/src/collab_panel.rs index 2f1e2842cbd2f5024df0608578b7cb7f4bbc158d..0ae4ff270bd672ca028d638484b9a23f5981de1a 100644 --- a/crates/collab_ui/src/collab_panel.rs +++ b/crates/collab_ui/src/collab_panel.rs @@ -1252,7 +1252,7 @@ impl CollabPanel { context_menu }); - window.focus(&context_menu.focus_handle(cx)); + window.focus(&context_menu.focus_handle(cx), cx); let subscription = cx.subscribe_in( &context_menu, window, @@ -1424,7 +1424,7 @@ impl CollabPanel { context_menu }); - window.focus(&context_menu.focus_handle(cx)); + window.focus(&context_menu.focus_handle(cx), cx); let subscription = cx.subscribe_in( &context_menu, window, @@ -1487,7 +1487,7 @@ impl CollabPanel { }) }); - window.focus(&context_menu.focus_handle(cx)); + window.focus(&context_menu.focus_handle(cx), cx); let subscription = cx.subscribe_in( &context_menu, window, @@ -1521,9 +1521,9 @@ impl CollabPanel { if cx.stop_active_drag(window) { return; } else if self.take_editing_state(window, cx) { - window.focus(&self.filter_editor.focus_handle(cx)); + window.focus(&self.filter_editor.focus_handle(cx), cx); } else if !self.reset_filter_editor_text(window, cx) { - self.focus_handle.focus(window); + self.focus_handle.focus(window, cx); } if self.context_menu.is_some() { @@ -1826,7 +1826,7 @@ impl CollabPanel { }); self.update_entries(false, cx); self.select_channel_editor(); - window.focus(&self.channel_name_editor.focus_handle(cx)); + window.focus(&self.channel_name_editor.focus_handle(cx), cx); cx.notify(); } @@ -1851,7 +1851,7 @@ impl CollabPanel { }); self.update_entries(false, cx); self.select_channel_editor(); - window.focus(&self.channel_name_editor.focus_handle(cx)); + window.focus(&self.channel_name_editor.focus_handle(cx), cx); cx.notify(); } @@ -1900,7 +1900,7 @@ impl CollabPanel { editor.set_text(channel.name.clone(), window, cx); editor.select_all(&Default::default(), window, cx); }); - window.focus(&self.channel_name_editor.focus_handle(cx)); + window.focus(&self.channel_name_editor.focus_handle(cx), cx); self.update_entries(false, cx); self.select_channel_editor(); } diff --git a/crates/collab_ui/src/collab_panel/channel_modal.rs b/crates/collab_ui/src/collab_panel/channel_modal.rs index 9d882562cab710f562145087e5c38474fda4808b..ae5b537f2c66dc273d504a70f2b75cb8bec0be20 100644 --- a/crates/collab_ui/src/collab_panel/channel_modal.rs +++ b/crates/collab_ui/src/collab_panel/channel_modal.rs @@ -642,7 +642,7 @@ impl ChannelModalDelegate { }); menu }); - window.focus(&context_menu.focus_handle(cx)); + window.focus(&context_menu.focus_handle(cx), cx); let subscription = cx.subscribe_in( &context_menu, window, diff --git a/crates/command_palette/src/command_palette.rs b/crates/command_palette/src/command_palette.rs index daf97bf676e27b5dd81ce4882c102dbfdefc502a..038b58ac5f4e90544232ccc8da55d0ca71ec28df 100644 --- a/crates/command_palette/src/command_palette.rs +++ b/crates/command_palette/src/command_palette.rs @@ -588,7 +588,7 @@ impl PickerDelegate for CommandPaletteDelegate { }) .detach_and_log_err(cx); let action = command.action; - window.focus(&self.previous_focus_handle); + window.focus(&self.previous_focus_handle, cx); self.dismissed(window, cx); window.dispatch_action(action, cx); } @@ -784,7 +784,7 @@ mod tests { workspace.update_in(cx, |workspace, window, cx| { workspace.add_item_to_active_pane(Box::new(editor.clone()), None, true, window, cx); - editor.update(cx, |editor, cx| window.focus(&editor.focus_handle(cx))) + editor.update(cx, |editor, cx| window.focus(&editor.focus_handle(cx), cx)) }); cx.simulate_keystrokes("cmd-shift-p"); @@ -855,7 +855,7 @@ mod tests { workspace.update_in(cx, |workspace, window, cx| { workspace.add_item_to_active_pane(Box::new(editor.clone()), None, true, window, cx); - editor.update(cx, |editor, cx| window.focus(&editor.focus_handle(cx))) + editor.update(cx, |editor, cx| window.focus(&editor.focus_handle(cx), cx)) }); // Test normalize (trimming whitespace and double colons) diff --git a/crates/copilot/src/copilot_edit_prediction_delegate.rs b/crates/copilot/src/copilot_edit_prediction_delegate.rs index 0e0cfe6cdca78d2a8b382269ce1ca9a340d1e69c..bbda32e1102f096e96a41cbc59268f597b1629ba 100644 --- a/crates/copilot/src/copilot_edit_prediction_delegate.rs +++ b/crates/copilot/src/copilot_edit_prediction_delegate.rs @@ -753,7 +753,7 @@ mod tests { editor .update(cx, |editor, window, cx| { use gpui::Focusable; - window.focus(&editor.focus_handle(cx)); + window.focus(&editor.focus_handle(cx), cx); }) .unwrap(); let copilot_provider = cx.new(|_| CopilotEditPredictionDelegate::new(copilot)); @@ -1000,7 +1000,7 @@ mod tests { editor .update(cx, |editor, window, cx| { use gpui::Focusable; - window.focus(&editor.focus_handle(cx)) + window.focus(&editor.focus_handle(cx), cx) }) .unwrap(); let copilot_provider = cx.new(|_| CopilotEditPredictionDelegate::new(copilot)); diff --git a/crates/copilot/src/sign_in.rs b/crates/copilot/src/sign_in.rs index 20e31525a8fdb09fce04934d3445d51ba4226a2e..4f71a34408e23f099d4d3c145d86af24e607e3c3 100644 --- a/crates/copilot/src/sign_in.rs +++ b/crates/copilot/src/sign_in.rs @@ -435,8 +435,8 @@ impl Render for CopilotCodeVerification { .on_action(cx.listener(|_, _: &menu::Cancel, _, cx| { cx.emit(DismissEvent); })) - .on_any_mouse_down(cx.listener(|this, _: &MouseDownEvent, window, _| { - window.focus(&this.focus_handle); + .on_any_mouse_down(cx.listener(|this, _: &MouseDownEvent, window, cx| { + window.focus(&this.focus_handle, cx); })) .child( Vector::new(VectorName::ZedXCopilot, rems(8.), rems(4.)) diff --git a/crates/debugger_ui/src/debugger_panel.rs b/crates/debugger_ui/src/debugger_panel.rs index 104a85dc097c575e7a4cd8f4a66a98a8bb6b0d69..35ce80d3f64e362735c1c020363dbbfc2703a101 100644 --- a/crates/debugger_ui/src/debugger_panel.rs +++ b/crates/debugger_ui/src/debugger_panel.rs @@ -577,7 +577,7 @@ impl DebugPanel { menu }); - window.focus(&context_menu.focus_handle(cx)); + window.focus(&context_menu.focus_handle(cx), cx); let subscription = cx.subscribe(&context_menu, |this, _, _: &DismissEvent, cx| { this.context_menu.take(); cx.notify(); @@ -1052,7 +1052,7 @@ impl DebugPanel { cx: &mut Context, ) { debug_assert!(self.sessions_with_children.contains_key(&session_item)); - session_item.focus_handle(cx).focus(window); + session_item.focus_handle(cx).focus(window, cx); session_item.update(cx, |this, cx| { this.running_state().update(cx, |this, cx| { this.go_to_selected_stack_frame(window, cx); diff --git a/crates/debugger_ui/src/new_process_modal.rs b/crates/debugger_ui/src/new_process_modal.rs index 8aaa61aad6380752a7bdd62ee35635ebb6d160e4..68e391562b57d530a21624b0626173eeb7a67c16 100644 --- a/crates/debugger_ui/src/new_process_modal.rs +++ b/crates/debugger_ui/src/new_process_modal.rs @@ -574,7 +574,7 @@ impl Render for NewProcessModal { NewProcessMode::Launch => NewProcessMode::Task, }; - this.mode_focus_handle(cx).focus(window); + this.mode_focus_handle(cx).focus(window, cx); })) .on_action( cx.listener(|this, _: &pane::ActivatePreviousItem, window, cx| { @@ -585,7 +585,7 @@ impl Render for NewProcessModal { NewProcessMode::Launch => NewProcessMode::Attach, }; - this.mode_focus_handle(cx).focus(window); + this.mode_focus_handle(cx).focus(window, cx); }), ) .child( @@ -602,7 +602,7 @@ impl Render for NewProcessModal { NewProcessMode::Task.to_string(), cx.listener(|this, _, window, cx| { this.mode = NewProcessMode::Task; - this.mode_focus_handle(cx).focus(window); + this.mode_focus_handle(cx).focus(window, cx); cx.notify(); }), ) @@ -611,7 +611,7 @@ impl Render for NewProcessModal { NewProcessMode::Debug.to_string(), cx.listener(|this, _, window, cx| { this.mode = NewProcessMode::Debug; - this.mode_focus_handle(cx).focus(window); + this.mode_focus_handle(cx).focus(window, cx); cx.notify(); }), ) @@ -629,7 +629,7 @@ impl Render for NewProcessModal { cx, ); } - this.mode_focus_handle(cx).focus(window); + this.mode_focus_handle(cx).focus(window, cx); cx.notify(); }), ) @@ -638,7 +638,7 @@ impl Render for NewProcessModal { NewProcessMode::Launch.to_string(), cx.listener(|this, _, window, cx| { this.mode = NewProcessMode::Launch; - this.mode_focus_handle(cx).focus(window); + this.mode_focus_handle(cx).focus(window, cx); cx.notify(); }), ) @@ -840,17 +840,17 @@ impl ConfigureMode { } } - fn on_tab(&mut self, _: &menu::SelectNext, window: &mut Window, _: &mut Context) { - window.focus_next(); + fn on_tab(&mut self, _: &menu::SelectNext, window: &mut Window, cx: &mut Context) { + window.focus_next(cx); } fn on_tab_prev( &mut self, _: &menu::SelectPrevious, window: &mut Window, - _: &mut Context, + cx: &mut Context, ) { - window.focus_prev(); + window.focus_prev(cx); } fn render( @@ -923,7 +923,7 @@ impl AttachMode { window, cx, ); - window.focus(&modal.focus_handle(cx)); + window.focus(&modal.focus_handle(cx), cx); modal }); diff --git a/crates/debugger_ui/src/onboarding_modal.rs b/crates/debugger_ui/src/onboarding_modal.rs index 18205209983421691046e8a9d93eb6de32cd4563..b6f1ab944183c4f44d2bc5f6855731abb65ce1f7 100644 --- a/crates/debugger_ui/src/onboarding_modal.rs +++ b/crates/debugger_ui/src/onboarding_modal.rs @@ -83,8 +83,8 @@ impl Render for DebuggerOnboardingModal { debugger_onboarding_event!("Canceled", trigger = "Action"); cx.emit(DismissEvent); })) - .on_any_mouse_down(cx.listener(|this, _: &MouseDownEvent, window, _cx| { - this.focus_handle.focus(window); + .on_any_mouse_down(cx.listener(|this, _: &MouseDownEvent, window, cx| { + this.focus_handle.focus(window, cx); })) .child( div() diff --git a/crates/debugger_ui/src/session/running.rs b/crates/debugger_ui/src/session/running.rs index 4898ec95ca3c5b55669896b3c1d898326851c0c3..422207d3cbf4880e0c8e3c02e01dbe373800ea62 100644 --- a/crates/debugger_ui/src/session/running.rs +++ b/crates/debugger_ui/src/session/running.rs @@ -604,7 +604,7 @@ impl DebugTerminal { let focus_handle = cx.focus_handle(); let focus_subscription = cx.on_focus(&focus_handle, window, |this, window, cx| { if let Some(terminal) = this.terminal.as_ref() { - terminal.focus_handle(cx).focus(window); + terminal.focus_handle(cx).focus(window, cx); } }); diff --git a/crates/debugger_ui/src/session/running/breakpoint_list.rs b/crates/debugger_ui/src/session/running/breakpoint_list.rs index 2c7e2074678290356b7669228dcf29008f1cc36b..f154757429a2bbfe153ee40c2c513dd06f05aa03 100644 --- a/crates/debugger_ui/src/session/running/breakpoint_list.rs +++ b/crates/debugger_ui/src/session/running/breakpoint_list.rs @@ -310,7 +310,7 @@ impl BreakpointList { fn dismiss(&mut self, _: &menu::Cancel, window: &mut Window, cx: &mut Context) { if self.input.focus_handle(cx).contains_focused(window, cx) { - self.focus_handle.focus(window); + self.focus_handle.focus(window, cx); } else if self.strip_mode.is_some() { self.strip_mode.take(); cx.notify(); @@ -364,9 +364,9 @@ impl BreakpointList { } } } - self.focus_handle.focus(window); + self.focus_handle.focus(window, cx); } else { - handle.focus(window); + handle.focus(window, cx); } return; @@ -627,7 +627,7 @@ impl BreakpointList { .on_click({ let focus_handle = focus_handle.clone(); move |_, window, cx| { - focus_handle.focus(window); + focus_handle.focus(window, cx); window.dispatch_action(ToggleEnableBreakpoint.boxed_clone(), cx) } }), @@ -654,7 +654,7 @@ impl BreakpointList { ) .on_click({ move |_, window, cx| { - focus_handle.focus(window); + focus_handle.focus(window, cx); window.dispatch_action(UnsetBreakpoint.boxed_clone(), cx) } }), diff --git a/crates/debugger_ui/src/session/running/console.rs b/crates/debugger_ui/src/session/running/console.rs index 927a57dc8bdf956eb7f7ff63d3ea058500abf6c3..040953bff6e8f0efa6045c1629c964ac98929547 100644 --- a/crates/debugger_ui/src/session/running/console.rs +++ b/crates/debugger_ui/src/session/running/console.rs @@ -105,7 +105,7 @@ impl Console { cx.subscribe(&stack_frame_list, Self::handle_stack_frame_list_events), cx.on_focus(&focus_handle, window, |console, window, cx| { if console.is_running(cx) { - console.query_bar.focus_handle(cx).focus(window); + console.query_bar.focus_handle(cx).focus(window, cx); } }), ]; diff --git a/crates/debugger_ui/src/session/running/memory_view.rs b/crates/debugger_ui/src/session/running/memory_view.rs index 55a8e8429eb23cd0bfcaa7d592d16797c061d2ae..f10e5179e37f87be0e27985b557fcb63cf089a42 100644 --- a/crates/debugger_ui/src/session/running/memory_view.rs +++ b/crates/debugger_ui/src/session/running/memory_view.rs @@ -403,7 +403,7 @@ impl MemoryView { this.set_placeholder_text("Write to Selected Memory Range", window, cx); }); self.is_writing_memory = true; - self.query_editor.focus_handle(cx).focus(window); + self.query_editor.focus_handle(cx).focus(window, cx); } else { self.query_editor.update(cx, |this, cx| { this.clear(window, cx); diff --git a/crates/debugger_ui/src/session/running/variable_list.rs b/crates/debugger_ui/src/session/running/variable_list.rs index 7b23cd685d93e6353d68dc57cd3998099ea56ad7..8329a6baf04061cc33e8130a4e6b3a33b35267b6 100644 --- a/crates/debugger_ui/src/session/running/variable_list.rs +++ b/crates/debugger_ui/src/session/running/variable_list.rs @@ -529,7 +529,7 @@ impl VariableList { fn cancel(&mut self, _: &menu::Cancel, window: &mut Window, cx: &mut Context) { self.edited_path.take(); - self.focus_handle.focus(window); + self.focus_handle.focus(window, cx); cx.notify(); } @@ -1067,7 +1067,7 @@ impl VariableList { editor.select_all(&editor::actions::SelectAll, window, cx); editor }); - editor.focus_handle(cx).focus(window); + editor.focus_handle(cx).focus(window, cx); editor } diff --git a/crates/diagnostics/src/buffer_diagnostics.rs b/crates/diagnostics/src/buffer_diagnostics.rs index ca28f2805adca78846a66e7b1f4d9f3fc57bb557..ba10f6fbdabf05a095a7fed7c6ae682d4dc177c7 100644 --- a/crates/diagnostics/src/buffer_diagnostics.rs +++ b/crates/diagnostics/src/buffer_diagnostics.rs @@ -175,7 +175,7 @@ impl BufferDiagnosticsEditor { // `BufferDiagnosticsEditor` instance. EditorEvent::Focused => { if buffer_diagnostics_editor.multibuffer.read(cx).is_empty() { - window.focus(&buffer_diagnostics_editor.focus_handle); + window.focus(&buffer_diagnostics_editor.focus_handle, cx); } } EditorEvent::Blurred => { @@ -517,7 +517,7 @@ impl BufferDiagnosticsEditor { .editor .read(cx) .focus_handle(cx) - .focus(window); + .focus(window, cx); } } } @@ -617,7 +617,7 @@ impl BufferDiagnosticsEditor { // not empty, focus on the editor instead, which will allow the user to // start interacting and editing the buffer's contents. if self.focus_handle.is_focused(window) && !self.multibuffer.read(cx).is_empty() { - self.editor.focus_handle(cx).focus(window) + self.editor.focus_handle(cx).focus(window, cx) } } diff --git a/crates/diagnostics/src/diagnostic_renderer.rs b/crates/diagnostics/src/diagnostic_renderer.rs index 72ad7b591413832183bb85d58d188e692d46ffad..521752ff1959fccc12b74857e342ff33a0444f3f 100644 --- a/crates/diagnostics/src/diagnostic_renderer.rs +++ b/crates/diagnostics/src/diagnostic_renderer.rs @@ -315,6 +315,6 @@ impl DiagnosticBlock { editor.change_selections(Default::default(), window, cx, |s| { s.select_ranges([range.start..range.start]); }); - window.focus(&editor.focus_handle(cx)); + window.focus(&editor.focus_handle(cx), cx); } } diff --git a/crates/diagnostics/src/diagnostics.rs b/crates/diagnostics/src/diagnostics.rs index 0999bebdb6aa9ca744e3a5121670a1b7357411a9..d85eb07f68619e15bfe44d26282db3a3e49df4f3 100644 --- a/crates/diagnostics/src/diagnostics.rs +++ b/crates/diagnostics/src/diagnostics.rs @@ -243,7 +243,7 @@ impl ProjectDiagnosticsEditor { match event { EditorEvent::Focused => { if this.multibuffer.read(cx).is_empty() { - window.focus(&this.focus_handle); + window.focus(&this.focus_handle, cx); } } EditorEvent::Blurred => this.close_diagnosticless_buffers(cx, false), @@ -434,7 +434,7 @@ impl ProjectDiagnosticsEditor { fn focus_in(&mut self, window: &mut Window, cx: &mut Context) { if self.focus_handle.is_focused(window) && !self.multibuffer.read(cx).is_empty() { - self.editor.focus_handle(cx).focus(window) + self.editor.focus_handle(cx).focus(window, cx) } } @@ -650,7 +650,7 @@ impl ProjectDiagnosticsEditor { }) }); if this.focus_handle.is_focused(window) { - this.editor.read(cx).focus_handle(cx).focus(window); + this.editor.read(cx).focus_handle(cx).focus(window, cx); } } diff --git a/crates/edit_prediction/src/onboarding_modal.rs b/crates/edit_prediction/src/onboarding_modal.rs index ed7adfc75476afb07f9c56b9c9c03abbbcef1134..97f529ae38df350ef21ffc04b79df6e8e6a7a501 100644 --- a/crates/edit_prediction/src/onboarding_modal.rs +++ b/crates/edit_prediction/src/onboarding_modal.rs @@ -131,8 +131,8 @@ impl Render for ZedPredictModal { onboarding_event!("Cancelled", trigger = "Action"); cx.emit(DismissEvent); })) - .on_any_mouse_down(cx.listener(|this, _: &MouseDownEvent, window, _cx| { - this.focus_handle.focus(window); + .on_any_mouse_down(cx.listener(|this, _: &MouseDownEvent, window, cx| { + this.focus_handle.focus(window, cx); })) .child( div() diff --git a/crates/edit_prediction_ui/src/rate_prediction_modal.rs b/crates/edit_prediction_ui/src/rate_prediction_modal.rs index 22e82bc445b394cc122e1cb1aa3604b45c25d1d1..1af65ad58083e3cccfa51ea7b674da01cad810a0 100644 --- a/crates/edit_prediction_ui/src/rate_prediction_modal.rs +++ b/crates/edit_prediction_ui/src/rate_prediction_modal.rs @@ -305,7 +305,7 @@ impl RatePredictionsModal { && prediction.id == prev_prediction.prediction.id { if focus { - window.focus(&prev_prediction.feedback_editor.focus_handle(cx)); + window.focus(&prev_prediction.feedback_editor.focus_handle(cx), cx); } return; } diff --git a/crates/editor/benches/editor_render.rs b/crates/editor/benches/editor_render.rs index 4323c6c973f3729623d8939ca89ecf3ac403bcbf..daaeede790cbd75a7238a81559513c5d3165a054 100644 --- a/crates/editor/benches/editor_render.rs +++ b/crates/editor/benches/editor_render.rs @@ -29,7 +29,7 @@ fn editor_input_with_1000_cursors(bencher: &mut Bencher<'_>, cx: &TestAppContext ); editor }); - window.focus(&editor.focus_handle(cx)); + window.focus(&editor.focus_handle(cx), cx); editor }); @@ -72,7 +72,7 @@ fn open_editor_with_one_long_line(bencher: &mut Bencher<'_>, args: &(String, Tes editor.set_style(editor::EditorStyle::default(), window, cx); editor }); - window.focus(&editor.focus_handle(cx)); + window.focus(&editor.focus_handle(cx), cx); editor }); }); @@ -100,7 +100,7 @@ fn editor_render(bencher: &mut Bencher<'_>, cx: &TestAppContext) { editor.set_style(editor::EditorStyle::default(), window, cx); editor }); - window.focus(&editor.focus_handle(cx)); + window.focus(&editor.focus_handle(cx), cx); editor }); diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index f9ffd835245ebb2ac7df8e8b7b667a1501c254fd..7da06c3d8de91709cdcea8cbc923918464021079 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -3816,7 +3816,7 @@ impl Editor { ) { if !self.focus_handle.is_focused(window) { self.last_focused_descendant = None; - window.focus(&self.focus_handle); + window.focus(&self.focus_handle, cx); } let display_map = self.display_map.update(cx, |map, cx| map.snapshot(cx)); @@ -3921,7 +3921,7 @@ impl Editor { ) { if !self.focus_handle.is_focused(window) { self.last_focused_descendant = None; - window.focus(&self.focus_handle); + window.focus(&self.focus_handle, cx); } let display_map = self.display_map.update(cx, |map, cx| map.snapshot(cx)); @@ -6712,7 +6712,7 @@ impl Editor { }) }) .on_click(cx.listener(move |editor, _: &ClickEvent, window, cx| { - window.focus(&editor.focus_handle(cx)); + window.focus(&editor.focus_handle(cx), cx); editor.toggle_code_actions( &crate::actions::ToggleCodeActions { deployed_from: Some(crate::actions::CodeActionSource::Indicator( @@ -8605,7 +8605,7 @@ impl Editor { BreakpointEditAction::Toggle }; - window.focus(&editor.focus_handle(cx)); + window.focus(&editor.focus_handle(cx), cx); editor.edit_breakpoint_at_anchor( position, breakpoint.as_ref().clone(), @@ -8797,7 +8797,7 @@ impl Editor { ClickEvent::Mouse(e) => e.down.button == MouseButton::Left, }; - window.focus(&editor.focus_handle(cx)); + window.focus(&editor.focus_handle(cx), cx); editor.toggle_code_actions( &ToggleCodeActions { deployed_from: Some(CodeActionSource::RunMenu(row)), @@ -11212,7 +11212,7 @@ impl Editor { }]; let focus_handle = bp_prompt.focus_handle(cx); - window.focus(&focus_handle); + window.focus(&focus_handle, cx); let block_ids = self.insert_blocks(blocks, None, cx); bp_prompt.update(cx, |prompt, _| { @@ -18039,7 +18039,7 @@ impl Editor { cx, ); let rename_focus_handle = rename_editor.focus_handle(cx); - window.focus(&rename_focus_handle); + window.focus(&rename_focus_handle, cx); let block_id = this.insert_blocks( [BlockProperties { style: BlockStyle::Flex, @@ -18153,7 +18153,7 @@ impl Editor { ) -> Option { let rename = self.pending_rename.take()?; if rename.editor.focus_handle(cx).is_focused(window) { - window.focus(&self.focus_handle); + window.focus(&self.focus_handle, cx); } self.remove_blocks( @@ -22723,7 +22723,7 @@ impl Editor { .take() .and_then(|descendant| descendant.upgrade()) { - window.focus(&descendant); + window.focus(&descendant, cx); } else { if let Some(blame) = self.blame.as_ref() { blame.update(cx, GitBlame::focus) @@ -25969,7 +25969,7 @@ impl BreakpointPromptEditor { self.editor .update(cx, |editor, cx| { editor.remove_blocks(self.block_ids.clone(), None, cx); - window.focus(&editor.focus_handle); + window.focus(&editor.focus_handle, cx); }) .log_err(); } diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rs index bac3d12638a23bc54f4a981b874da35b77894fff..1b84197471bd9ad65dc0ac31bf42c6ddc5ee3bf5 100644 --- a/crates/editor/src/editor_tests.rs +++ b/crates/editor/src/editor_tests.rs @@ -18201,7 +18201,7 @@ async fn test_on_type_formatting_not_triggered(cx: &mut TestAppContext) { ); editor_handle.update_in(cx, |editor, window, cx| { - window.focus(&editor.focus_handle(cx)); + window.focus(&editor.focus_handle(cx), cx); editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| { s.select_ranges([Point::new(0, 21)..Point::new(0, 20)]) }); diff --git a/crates/editor/src/hover_links.rs b/crates/editor/src/hover_links.rs index d7e4169a721765e0f93805bf0c157033bf0cafab..1c00acbfa9f1a69cbe01c45758db5a0cd4fee757 100644 --- a/crates/editor/src/hover_links.rs +++ b/crates/editor/src/hover_links.rs @@ -218,7 +218,7 @@ impl Editor { self.hide_hovered_link(cx); if !hovered_link_state.links.is_empty() { if !self.focus_handle.is_focused(window) { - window.focus(&self.focus_handle); + window.focus(&self.focus_handle, cx); } // exclude links pointing back to the current anchor diff --git a/crates/editor/src/mouse_context_menu.rs b/crates/editor/src/mouse_context_menu.rs index 36521d46a6c20223e973346b9d1e9391db3306ca..7314991bd5e4842f395383888a87b4e2db7e0a0c 100644 --- a/crates/editor/src/mouse_context_menu.rs +++ b/crates/editor/src/mouse_context_menu.rs @@ -90,8 +90,8 @@ impl MouseContextMenu { // `true` when the `ContextMenu` is focused. let focus_handle = context_menu_focus.clone(); cx.on_next_frame(window, move |_, window, cx| { - cx.on_next_frame(window, move |_, window, _cx| { - window.focus(&focus_handle); + cx.on_next_frame(window, move |_, window, cx| { + window.focus(&focus_handle, cx); }); }); @@ -100,7 +100,7 @@ impl MouseContextMenu { move |editor, _, _event: &DismissEvent, window, cx| { editor.mouse_context_menu.take(); if context_menu_focus.contains_focused(window, cx) { - window.focus(&editor.focus_handle(cx)); + window.focus(&editor.focus_handle(cx), cx); } } }); @@ -127,7 +127,7 @@ impl MouseContextMenu { } editor.mouse_context_menu.take(); if context_menu_focus.contains_focused(window, cx) { - window.focus(&editor.focus_handle(cx)); + window.focus(&editor.focus_handle(cx), cx); } }, ); @@ -161,7 +161,7 @@ pub fn deploy_context_menu( cx: &mut Context, ) { if !editor.is_focused(window) { - window.focus(&editor.focus_handle(cx)); + window.focus(&editor.focus_handle(cx), cx); } // Don't show context menu for inline editors diff --git a/crates/editor/src/test/editor_lsp_test_context.rs b/crates/editor/src/test/editor_lsp_test_context.rs index 3afe0e6134221fc69837abd30618f2b74ae069f5..7c4c0e48d36dbb9f74a1c835c63fa2b91c5681d9 100644 --- a/crates/editor/src/test/editor_lsp_test_context.rs +++ b/crates/editor/src/test/editor_lsp_test_context.rs @@ -126,7 +126,7 @@ impl EditorLspTestContext { .read(cx) .nav_history_for_item(&cx.entity()); editor.set_nav_history(Some(nav_history)); - window.focus(&editor.focus_handle(cx)) + window.focus(&editor.focus_handle(cx), cx) }); let lsp = fake_servers.next().await.unwrap(); diff --git a/crates/editor/src/test/editor_test_context.rs b/crates/editor/src/test/editor_test_context.rs index bcfaeea3a7330539b2f2790e7dbe9a4969c76981..267058691d0070678830ba9d7c40f54a9363737b 100644 --- a/crates/editor/src/test/editor_test_context.rs +++ b/crates/editor/src/test/editor_test_context.rs @@ -78,7 +78,7 @@ impl EditorTestContext { cx, ); - window.focus(&editor.focus_handle(cx)); + window.focus(&editor.focus_handle(cx), cx); editor }); let editor_view = editor.root(cx).unwrap(); @@ -139,7 +139,7 @@ impl EditorTestContext { let editor = cx.add_window(|window, cx| { let editor = build_editor(buffer, window, cx); - window.focus(&editor.focus_handle(cx)); + window.focus(&editor.focus_handle(cx), cx); editor }); diff --git a/crates/file_finder/src/file_finder.rs b/crates/file_finder/src/file_finder.rs index 050d7a45a1b46e94a195f88e49fd6795ce37f09f..73b21bb828a598d5bbc53c0ecf4511988c30bc65 100644 --- a/crates/file_finder/src/file_finder.rs +++ b/crates/file_finder/src/file_finder.rs @@ -1713,7 +1713,7 @@ impl PickerDelegate for FileFinderDelegate { ui::IconPosition::End, Some(ToggleIncludeIgnored.boxed_clone()), move |window, cx| { - window.focus(&focus_handle); + window.focus(&focus_handle, cx); window.dispatch_action( ToggleIncludeIgnored.boxed_clone(), cx, diff --git a/crates/git_ui/src/branch_picker.rs b/crates/git_ui/src/branch_picker.rs index 7395f1588fececcf4f374ec0e66cdac6024656d7..4db37e91b8720e51ff0416cc471842483ab1d0ca 100644 --- a/crates/git_ui/src/branch_picker.rs +++ b/crates/git_ui/src/branch_picker.rs @@ -91,7 +91,7 @@ pub fn popover( window, cx, ); - list.focus_handle(cx).focus(window); + list.focus_handle(cx).focus(window, cx); list }) } @@ -1880,7 +1880,7 @@ mod tests { branch_list .update_in(cx, |branch_list, window, cx| { - window.focus(&branch_list.picker_focus_handle); + window.focus(&branch_list.picker_focus_handle, cx); assert!( branch_list.picker_focus_handle.is_focused(window), "Branch picker should be focused when selecting an entry" @@ -1898,7 +1898,7 @@ mod tests { branch_list.update_in(cx, |branch_list, window, cx| { // Re-focus the picker since workspace initialization during run_until_parked - window.focus(&branch_list.picker_focus_handle); + window.focus(&branch_list.picker_focus_handle, cx); branch_list.picker.update(cx, |picker, cx| { let last_match = picker.delegate.matches.last().unwrap(); diff --git a/crates/git_ui/src/commit_modal.rs b/crates/git_ui/src/commit_modal.rs index 291a96f47590b145b5c190150af54bd3d43c2fff..e154933adc794221159c7f1b28b3d1e33cf1854d 100644 --- a/crates/git_ui/src/commit_modal.rs +++ b/crates/git_ui/src/commit_modal.rs @@ -521,7 +521,7 @@ impl CommitModal { fn toggle_branch_selector(&mut self, window: &mut Window, cx: &mut Context) { if self.branch_list_handle.is_focused(window, cx) { - self.focus_handle(cx).focus(window) + self.focus_handle(cx).focus(window, cx) } else { self.branch_list_handle.toggle(window, cx); } @@ -587,8 +587,8 @@ impl Render for CommitModal { .bg(cx.theme().colors().editor_background) .border_1() .border_color(cx.theme().colors().border_variant) - .on_click(cx.listener(move |_, _: &ClickEvent, window, _cx| { - window.focus(&editor_focus_handle); + .on_click(cx.listener(move |_, _: &ClickEvent, window, cx| { + window.focus(&editor_focus_handle, cx); })) .child( div() diff --git a/crates/git_ui/src/file_history_view.rs b/crates/git_ui/src/file_history_view.rs index 4e91fe7e06a5823caac5bf00be8f48cc98dc8da4..f48160719ba5d9b00b8961b75e9ea402c80dd06a 100644 --- a/crates/git_ui/src/file_history_view.rs +++ b/crates/git_ui/src/file_history_view.rs @@ -633,9 +633,9 @@ impl Item for FileHistoryView { &mut self, _workspace: &mut Workspace, window: &mut Window, - _cx: &mut Context, + cx: &mut Context, ) { - window.focus(&self.focus_handle); + window.focus(&self.focus_handle, cx); } fn show_toolbar(&self) -> bool { diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs index b855d9b98708fe81328d69106ac1dda3b374080e..cf73406b3851b46ad1a7d056d6cb335666b9ac65 100644 --- a/crates/git_ui/src/git_panel.rs +++ b/crates/git_ui/src/git_panel.rs @@ -1063,7 +1063,7 @@ impl GitPanel { fn focus_editor(&mut self, _: &FocusEditor, window: &mut Window, cx: &mut Context) { self.commit_editor.update(cx, |editor, cx| { - window.focus(&editor.focus_handle(cx)); + window.focus(&editor.focus_handle(cx), cx); }); cx.notify(); } @@ -1084,8 +1084,7 @@ impl GitPanel { window: &mut Window, cx: &mut Context, ) { - self.focus_handle.focus(window); - + self.focus_handle.focus(window, cx); self.select_first_entry_if_none(window, cx); } @@ -1107,7 +1106,7 @@ impl GitPanel { .project_path_to_repo_path(&project_path, cx) .as_ref() { - project_diff.focus_handle(cx).focus(window); + project_diff.focus_handle(cx).focus(window, cx); project_diff.update(cx, |project_diff, cx| project_diff.autoscroll(cx)); return None; }; @@ -1117,7 +1116,7 @@ impl GitPanel { ProjectDiff::deploy_at(workspace, Some(entry.clone()), window, cx); }) .ok(); - self.focus_handle.focus(window); + self.focus_handle.focus(window, cx); Some(()) }); @@ -2128,7 +2127,10 @@ impl GitPanel { let commit_message = self.custom_or_suggested_commit_message(window, cx); let Some(mut message) = commit_message else { - self.commit_editor.read(cx).focus_handle(cx).focus(window); + self.commit_editor + .read(cx) + .focus_handle(cx) + .focus(window, cx); return; }; @@ -4146,7 +4148,7 @@ impl GitPanel { .border_color(cx.theme().colors().border) .cursor_text() .on_click(cx.listener(move |this, _: &ClickEvent, window, cx| { - window.focus(&this.commit_editor.focus_handle(cx)); + window.focus(&this.commit_editor.focus_handle(cx), cx); })) .child( h_flex() @@ -4940,7 +4942,7 @@ impl GitPanel { this.open_file(&Default::default(), window, cx) } else { this.open_diff(&Default::default(), window, cx); - this.focus_handle.focus(window); + this.focus_handle.focus(window, cx); } }) }) diff --git a/crates/git_ui/src/git_ui.rs b/crates/git_ui/src/git_ui.rs index 54adc8130d78e80af5c561541efb8128f1b2a017..5f50e4ef8029d8f57cd159bc7da68b668b628f48 100644 --- a/crates/git_ui/src/git_ui.rs +++ b/crates/git_ui/src/git_ui.rs @@ -817,7 +817,7 @@ impl GitCloneModal { }); let focus_handle = repo_input.focus_handle(cx); - window.focus(&focus_handle); + window.focus(&focus_handle, cx); Self { panel, diff --git a/crates/git_ui/src/onboarding.rs b/crates/git_ui/src/onboarding.rs index d1709e043b92216e974c1a4f451db5c28b98f773..eccb18a5400647ff86e44f4426d271d6c9361164 100644 --- a/crates/git_ui/src/onboarding.rs +++ b/crates/git_ui/src/onboarding.rs @@ -85,8 +85,8 @@ impl Render for GitOnboardingModal { git_onboarding_event!("Cancelled", trigger = "Action"); cx.emit(DismissEvent); })) - .on_any_mouse_down(cx.listener(|this, _: &MouseDownEvent, window, _cx| { - this.focus_handle.focus(window); + .on_any_mouse_down(cx.listener(|this, _: &MouseDownEvent, window, cx| { + this.focus_handle.focus(window, cx); })) .child( div().p_1p5().absolute().inset_0().h(px(160.)).child( diff --git a/crates/git_ui/src/project_diff.rs b/crates/git_ui/src/project_diff.rs index 4d7a27354b1b4b6e972579e73c48bcd4c2448a5c..0e0632d9d049f54a648f65c55a96d639c9103e4d 100644 --- a/crates/git_ui/src/project_diff.rs +++ b/crates/git_ui/src/project_diff.rs @@ -492,7 +492,7 @@ impl ProjectDiff { if editor.focus_handle(cx).contains_focused(window, cx) && self.multibuffer.read(cx).is_empty() { - self.focus_handle.focus(window) + self.focus_handle.focus(window, cx) } } @@ -597,10 +597,10 @@ impl ProjectDiff { .focus_handle(cx) .contains_focused(window, cx) { - self.focus_handle.focus(window); + self.focus_handle.focus(window, cx); } else if self.focus_handle.is_focused(window) && !self.multibuffer.read(cx).is_empty() { self.editor.update(cx, |editor, cx| { - editor.focus_handle(cx).focus(window); + editor.focus_handle(cx).focus(window, cx); }); } if self.pending_scroll.as_ref() == Some(&path_key) { @@ -983,7 +983,7 @@ impl Render for ProjectDiff { cx, )) .on_click(move |_, window, cx| { - window.focus(&keybinding_focus_handle); + window.focus(&keybinding_focus_handle, cx); window.dispatch_action( Box::new(CloseActiveItem::default()), cx, @@ -1153,7 +1153,7 @@ impl ProjectDiffToolbar { fn dispatch_action(&self, action: &dyn Action, window: &mut Window, cx: &mut Context) { if let Some(project_diff) = self.project_diff(cx) { - project_diff.focus_handle(cx).focus(window); + project_diff.focus_handle(cx).focus(window, cx); } let action = action.boxed_clone(); cx.defer(move |cx| { diff --git a/crates/go_to_line/src/go_to_line.rs b/crates/go_to_line/src/go_to_line.rs index 461b0be659fc3ffb7b7bc984485dc68ece988500..7c42972a75420ae87bf3c5b9caaf041852efc009 100644 --- a/crates/go_to_line/src/go_to_line.rs +++ b/crates/go_to_line/src/go_to_line.rs @@ -268,7 +268,7 @@ impl GoToLine { cx, |s| s.select_anchor_ranges([start..start]), ); - editor.focus_handle(cx).focus(window); + editor.focus_handle(cx).focus(window, cx); cx.notify() }); self.prev_scroll_position.take(); diff --git a/crates/gpui/examples/focus_visible.rs b/crates/gpui/examples/focus_visible.rs index 737317cabadb7d3358c9c0497b52d4c2ff2e1028..d7c15396f0381ef29b3d6600347fd90a602256f5 100644 --- a/crates/gpui/examples/focus_visible.rs +++ b/crates/gpui/examples/focus_visible.rs @@ -29,7 +29,7 @@ impl Example { ]; let focus_handle = cx.focus_handle(); - window.focus(&focus_handle); + window.focus(&focus_handle, cx); Self { focus_handle, @@ -40,13 +40,13 @@ impl Example { } } - fn on_tab(&mut self, _: &Tab, window: &mut Window, _: &mut Context) { - window.focus_next(); + fn on_tab(&mut self, _: &Tab, window: &mut Window, cx: &mut Context) { + window.focus_next(cx); self.message = SharedString::from("Pressed Tab - focus-visible border should appear!"); } - fn on_tab_prev(&mut self, _: &TabPrev, window: &mut Window, _: &mut Context) { - window.focus_prev(); + fn on_tab_prev(&mut self, _: &TabPrev, window: &mut Window, cx: &mut Context) { + window.focus_prev(cx); self.message = SharedString::from("Pressed Shift-Tab - focus-visible border should appear!"); } diff --git a/crates/gpui/examples/input.rs b/crates/gpui/examples/input.rs index 37115feaa551a787562e7299c9d44bcc97b5fca3..44fae4ffe6bb9e120a8f96c10e0af8f4f8026cdd 100644 --- a/crates/gpui/examples/input.rs +++ b/crates/gpui/examples/input.rs @@ -736,7 +736,7 @@ fn main() { window .update(cx, |view, window, cx| { - window.focus(&view.text_input.focus_handle(cx)); + window.focus(&view.text_input.focus_handle(cx), cx); cx.activate(true); }) .unwrap(); diff --git a/crates/gpui/examples/on_window_close_quit.rs b/crates/gpui/examples/on_window_close_quit.rs index 8fe24001445d94b1629bf766294d850d0918a5e8..9a2b2f2fee43f753aece55d076be647ad8060965 100644 --- a/crates/gpui/examples/on_window_close_quit.rs +++ b/crates/gpui/examples/on_window_close_quit.rs @@ -55,7 +55,7 @@ fn main() { cx.activate(false); cx.new(|cx| { let focus_handle = cx.focus_handle(); - focus_handle.focus(window); + focus_handle.focus(window, cx); ExampleWindow { focus_handle } }) }, @@ -72,7 +72,7 @@ fn main() { |window, cx| { cx.new(|cx| { let focus_handle = cx.focus_handle(); - focus_handle.focus(window); + focus_handle.focus(window, cx); ExampleWindow { focus_handle } }) }, diff --git a/crates/gpui/examples/tab_stop.rs b/crates/gpui/examples/tab_stop.rs index 8dbcbeccb7351fda18e8d36fe38d8f26c4a70cc9..4d99da1a07a123e9a18b3c64a90834c31bd76909 100644 --- a/crates/gpui/examples/tab_stop.rs +++ b/crates/gpui/examples/tab_stop.rs @@ -22,7 +22,7 @@ impl Example { ]; let focus_handle = cx.focus_handle(); - window.focus(&focus_handle); + window.focus(&focus_handle, cx); Self { focus_handle, @@ -31,13 +31,13 @@ impl Example { } } - fn on_tab(&mut self, _: &Tab, window: &mut Window, _: &mut Context) { - window.focus_next(); + fn on_tab(&mut self, _: &Tab, window: &mut Window, cx: &mut Context) { + window.focus_next(cx); self.message = SharedString::from("You have pressed `Tab`."); } - fn on_tab_prev(&mut self, _: &TabPrev, window: &mut Window, _: &mut Context) { - window.focus_prev(); + fn on_tab_prev(&mut self, _: &TabPrev, window: &mut Window, cx: &mut Context) { + window.focus_prev(cx); self.message = SharedString::from("You have pressed `Shift-Tab`."); } } diff --git a/crates/gpui/src/app.rs b/crates/gpui/src/app.rs index aa1acae33b8fb55fc5e2f8fa8c0f5b8bb91758f3..7bd0daf56a466666b8cf5ae70f6b7cb5597a0d10 100644 --- a/crates/gpui/src/app.rs +++ b/crates/gpui/src/app.rs @@ -1900,8 +1900,11 @@ impl App { pub(crate) fn clear_pending_keystrokes(&mut self) { for window in self.windows() { window - .update(self, |_, window, _| { - window.clear_pending_keystrokes(); + .update(self, |_, window, cx| { + if window.pending_input_keystrokes().is_some() { + window.clear_pending_keystrokes(); + window.pending_input_changed(cx); + } }) .ok(); } diff --git a/crates/gpui/src/app/async_context.rs b/crates/gpui/src/app/async_context.rs index f5dcd30ae943954cbc042e1ce02edad39370a04a..805dfced162cd27f0cc785a8282ae3b802c2873a 100644 --- a/crates/gpui/src/app/async_context.rs +++ b/crates/gpui/src/app/async_context.rs @@ -487,7 +487,7 @@ impl VisualContext for AsyncWindowContext { V: Focusable, { self.app.update_window(self.window, |_, window, cx| { - view.read(cx).focus_handle(cx).focus(window); + view.read(cx).focus_handle(cx).focus(window, cx); }) } } diff --git a/crates/gpui/src/app/context.rs b/crates/gpui/src/app/context.rs index 27ccbecaf83cafe7bf7562c32a164268a74a396b..b780ca426c15c99030f24ee48bde978ad38526e7 100644 --- a/crates/gpui/src/app/context.rs +++ b/crates/gpui/src/app/context.rs @@ -285,7 +285,7 @@ impl<'a, T: 'static> Context<'a, T> { /// Focus the given view in the given window. View type is required to implement Focusable. pub fn focus_view(&mut self, view: &Entity, window: &mut Window) { - window.focus(&view.focus_handle(self)); + window.focus(&view.focus_handle(self), self); } /// Sets a given callback to be run on the next frame. @@ -732,7 +732,7 @@ impl<'a, T: 'static> Context<'a, T> { { let view = self.entity(); window.defer(self, move |window, cx| { - view.read(cx).focus_handle(cx).focus(window) + view.read(cx).focus_handle(cx).focus(window, cx) }) } } diff --git a/crates/gpui/src/app/test_context.rs b/crates/gpui/src/app/test_context.rs index 5be2e394e8edfd26a25c70c79c321a7fb8fdc8ba..9b982f9a1ca3c14b99dfc93e938aafe4e2f75cff 100644 --- a/crates/gpui/src/app/test_context.rs +++ b/crates/gpui/src/app/test_context.rs @@ -1045,7 +1045,7 @@ impl VisualContext for VisualTestContext { fn focus(&mut self, view: &Entity) -> Self::Result<()> { self.window .update(&mut self.cx, |_, window, cx| { - view.read(cx).focus_handle(cx).focus(window) + view.read(cx).focus_handle(cx).focus(window, cx) }) .unwrap() } diff --git a/crates/gpui/src/elements/div.rs b/crates/gpui/src/elements/div.rs index 374fd2c55a8e1cd5280d6ea9378a64c265a5c508..cf55edefaf70c080e171a8e21b350fd3c6d82f75 100644 --- a/crates/gpui/src/elements/div.rs +++ b/crates/gpui/src/elements/div.rs @@ -654,7 +654,7 @@ pub trait InteractiveElement: Sized { /// Set whether this element is a tab stop. /// /// When false, the element remains in tab-index order but cannot be reached via keyboard navigation. - /// Useful for container elements: focus the container, then call `window.focus_next()` to focus + /// Useful for container elements: focus the container, then call `window.focus_next(cx)` to focus /// the first tab stop inside it while having the container element itself be unreachable via the keyboard. /// Should only be used with `tab_index`. fn tab_stop(mut self, tab_stop: bool) -> Self { @@ -2096,12 +2096,12 @@ impl Interactivity { // This behavior can be suppressed by using `cx.prevent_default()`. if let Some(focus_handle) = self.tracked_focus_handle.clone() { let hitbox = hitbox.clone(); - window.on_mouse_event(move |_: &MouseDownEvent, phase, window, _| { + window.on_mouse_event(move |_: &MouseDownEvent, phase, window, cx| { if phase == DispatchPhase::Bubble && hitbox.is_hovered(window) && !window.default_prevented() { - window.focus(&focus_handle); + window.focus(&focus_handle, cx); // If there is a parent that is also focusable, prevent it // from transferring focus because we already did so. window.prevent_default(); diff --git a/crates/gpui/src/elements/uniform_list.rs b/crates/gpui/src/elements/uniform_list.rs index 1ad71b97673e6f54015dbc67fa829725dd4fccb2..a7486f0c00ac4e11ef807af90f6fb75b74b5d142 100644 --- a/crates/gpui/src/elements/uniform_list.rs +++ b/crates/gpui/src/elements/uniform_list.rs @@ -788,7 +788,7 @@ mod test { let (view, cx) = cx.add_window_view(|window, cx| { let focus_handle = cx.focus_handle(); - window.focus(&focus_handle); + window.focus(&focus_handle, cx); TestView { scroll_handle: UniformListScrollHandle::new(), index: 0, diff --git a/crates/gpui/src/interactive.rs b/crates/gpui/src/interactive.rs index 6852b9596a3f74e1d533fc2a7e9a7b7eeab71cda..a500ac46f0bbf96fc2b9d326a3a61da42c40b7ec 100644 --- a/crates/gpui/src/interactive.rs +++ b/crates/gpui/src/interactive.rs @@ -705,8 +705,8 @@ mod test { }); window - .update(cx, |test_view, window, _cx| { - window.focus(&test_view.focus_handle) + .update(cx, |test_view, window, cx| { + window.focus(&test_view.focus_handle, cx) }) .unwrap(); diff --git a/crates/gpui/src/key_dispatch.rs b/crates/gpui/src/key_dispatch.rs index ae4553408fa8d0dc7ed640319ae0b0a178465b74..85aa550fa96ca76e46f8d75ab84e91a7e9ba43cd 100644 --- a/crates/gpui/src/key_dispatch.rs +++ b/crates/gpui/src/key_dispatch.rs @@ -610,8 +610,8 @@ impl DispatchTree { #[cfg(test)] mod tests { use crate::{ - self as gpui, DispatchResult, Element, ElementId, GlobalElementId, InspectorElementId, - Keystroke, LayoutId, Style, + self as gpui, AppContext, DispatchResult, Element, ElementId, GlobalElementId, + InspectorElementId, Keystroke, LayoutId, Style, }; use core::panic; use smallvec::SmallVec; @@ -619,8 +619,8 @@ mod tests { use crate::{ Action, ActionRegistry, App, Bounds, Context, DispatchTree, FocusHandle, InputHandler, - IntoElement, KeyBinding, KeyContext, Keymap, Pixels, Point, Render, TestAppContext, - UTF16Selection, Window, + IntoElement, KeyBinding, KeyContext, Keymap, Pixels, Point, Render, Subscription, + TestAppContext, UTF16Selection, Window, }; #[derive(PartialEq, Eq)] @@ -723,6 +723,213 @@ mod tests { assert!(!result.pending_has_binding); } + #[crate::test] + fn test_pending_input_observers_notified_on_focus_change(cx: &mut TestAppContext) { + #[derive(Clone)] + struct CustomElement { + focus_handle: FocusHandle, + text: Rc>, + } + + impl CustomElement { + fn new(cx: &mut Context) -> Self { + Self { + focus_handle: cx.focus_handle(), + text: Rc::default(), + } + } + } + + impl Element for CustomElement { + type RequestLayoutState = (); + + type PrepaintState = (); + + fn id(&self) -> Option { + Some("custom".into()) + } + + fn source_location(&self) -> Option<&'static panic::Location<'static>> { + None + } + + fn request_layout( + &mut self, + _: Option<&GlobalElementId>, + _: Option<&InspectorElementId>, + window: &mut Window, + cx: &mut App, + ) -> (LayoutId, Self::RequestLayoutState) { + (window.request_layout(Style::default(), [], cx), ()) + } + + fn prepaint( + &mut self, + _: Option<&GlobalElementId>, + _: Option<&InspectorElementId>, + _: Bounds, + _: &mut Self::RequestLayoutState, + window: &mut Window, + cx: &mut App, + ) -> Self::PrepaintState { + window.set_focus_handle(&self.focus_handle, cx); + } + + fn paint( + &mut self, + _: Option<&GlobalElementId>, + _: Option<&InspectorElementId>, + _: Bounds, + _: &mut Self::RequestLayoutState, + _: &mut Self::PrepaintState, + window: &mut Window, + cx: &mut App, + ) { + let mut key_context = KeyContext::default(); + key_context.add("Terminal"); + window.set_key_context(key_context); + window.handle_input(&self.focus_handle, self.clone(), cx); + window.on_action(std::any::TypeId::of::(), |_, _, _, _| {}); + } + } + + impl IntoElement for CustomElement { + type Element = Self; + + fn into_element(self) -> Self::Element { + self + } + } + + impl InputHandler for CustomElement { + fn selected_text_range( + &mut self, + _: bool, + _: &mut Window, + _: &mut App, + ) -> Option { + None + } + + fn marked_text_range(&mut self, _: &mut Window, _: &mut App) -> Option> { + None + } + + fn text_for_range( + &mut self, + _: Range, + _: &mut Option>, + _: &mut Window, + _: &mut App, + ) -> Option { + None + } + + fn replace_text_in_range( + &mut self, + replacement_range: Option>, + text: &str, + _: &mut Window, + _: &mut App, + ) { + if replacement_range.is_some() { + unimplemented!() + } + self.text.borrow_mut().push_str(text) + } + + fn replace_and_mark_text_in_range( + &mut self, + replacement_range: Option>, + new_text: &str, + _: Option>, + _: &mut Window, + _: &mut App, + ) { + if replacement_range.is_some() { + unimplemented!() + } + self.text.borrow_mut().push_str(new_text) + } + + fn unmark_text(&mut self, _: &mut Window, _: &mut App) {} + + fn bounds_for_range( + &mut self, + _: Range, + _: &mut Window, + _: &mut App, + ) -> Option> { + None + } + + fn character_index_for_point( + &mut self, + _: Point, + _: &mut Window, + _: &mut App, + ) -> Option { + None + } + } + + impl Render for CustomElement { + fn render(&mut self, _: &mut Window, _: &mut Context) -> impl IntoElement { + self.clone() + } + } + + cx.update(|cx| { + cx.bind_keys([KeyBinding::new("ctrl-b", TestAction, Some("Terminal"))]); + cx.bind_keys([KeyBinding::new("ctrl-b h", TestAction, Some("Terminal"))]); + }); + + let (test, cx) = cx.add_window_view(|_, cx| CustomElement::new(cx)); + let focus_handle = test.update(cx, |test, _| test.focus_handle.clone()); + + let pending_input_changed_count = Rc::new(RefCell::new(0usize)); + let pending_input_changed_count_for_observer = pending_input_changed_count.clone(); + + struct PendingInputObserver { + _subscription: Subscription, + } + + let _observer = cx.update(|window, cx| { + cx.new(|cx| PendingInputObserver { + _subscription: cx.observe_pending_input(window, move |_, _, _| { + *pending_input_changed_count_for_observer.borrow_mut() += 1; + }), + }) + }); + + cx.update(|window, cx| { + window.focus(&focus_handle, cx); + window.activate_window(); + }); + + cx.simulate_keystrokes("ctrl-b"); + + let count_after_pending = Rc::new(RefCell::new(0usize)); + let count_after_pending_for_assertion = count_after_pending.clone(); + + cx.update(|window, cx| { + assert!(window.has_pending_keystrokes()); + *count_after_pending.borrow_mut() = *pending_input_changed_count.borrow(); + assert!(*count_after_pending.borrow() > 0); + + window.focus(&cx.focus_handle(), cx); + + assert!(!window.has_pending_keystrokes()); + }); + + // Focus-triggered pending-input notifications are deferred to the end of the current + // effect cycle, so the observer callback should run after the focus update completes. + cx.update(|_, _| { + let count_after_focus_change = *pending_input_changed_count.borrow(); + assert!(count_after_focus_change > *count_after_pending_for_assertion.borrow()); + }); + } + #[crate::test] fn test_input_handler_pending(cx: &mut TestAppContext) { #[derive(Clone)] @@ -876,8 +1083,9 @@ mod tests { cx.bind_keys([KeyBinding::new("ctrl-b h", TestAction, Some("Terminal"))]); }); let (test, cx) = cx.add_window_view(|_, cx| CustomElement::new(cx)); + let focus_handle = test.update(cx, |test, _| test.focus_handle.clone()); cx.update(|window, cx| { - window.focus(&test.read(cx).focus_handle); + window.focus(&focus_handle, cx); window.activate_window(); }); cx.simulate_keystrokes("ctrl-b ["); diff --git a/crates/gpui/src/window.rs b/crates/gpui/src/window.rs index c606409661eb022b8627fe9bc9f6c53565f5569f..dd20f71c22e388e0c739083d45941270ac8eac8e 100644 --- a/crates/gpui/src/window.rs +++ b/crates/gpui/src/window.rs @@ -345,8 +345,8 @@ impl FocusHandle { } /// Moves the focus to the element associated with this handle. - pub fn focus(&self, window: &mut Window) { - window.focus(self) + pub fn focus(&self, window: &mut Window, cx: &mut App) { + window.focus(self, cx) } /// Obtains whether the element associated with this handle is currently focused. @@ -1436,13 +1436,25 @@ impl Window { } /// Move focus to the element associated with the given [`FocusHandle`]. - pub fn focus(&mut self, handle: &FocusHandle) { + pub fn focus(&mut self, handle: &FocusHandle, cx: &mut App) { if !self.focus_enabled || self.focus == Some(handle.id) { return; } self.focus = Some(handle.id); self.clear_pending_keystrokes(); + + // Avoid re-entrant entity updates by deferring observer notifications to the end of the + // current effect cycle, and only for this window. + let window_handle = self.handle; + cx.defer(move |cx| { + window_handle + .update(cx, |_, window, cx| { + window.pending_input_changed(cx); + }) + .ok(); + }); + self.refresh(); } @@ -1463,24 +1475,24 @@ impl Window { } /// Move focus to next tab stop. - pub fn focus_next(&mut self) { + pub fn focus_next(&mut self, cx: &mut App) { if !self.focus_enabled { return; } if let Some(handle) = self.rendered_frame.tab_stops.next(self.focus.as_ref()) { - self.focus(&handle) + self.focus(&handle, cx) } } /// Move focus to previous tab stop. - pub fn focus_prev(&mut self) { + pub fn focus_prev(&mut self, cx: &mut App) { if !self.focus_enabled { return; } if let Some(handle) = self.rendered_frame.tab_stops.prev(self.focus.as_ref()) { - self.focus(&handle) + self.focus(&handle, cx) } } @@ -4020,7 +4032,7 @@ impl Window { self.dispatch_keystroke_observers(event, None, context_stack, cx); } - fn pending_input_changed(&mut self, cx: &mut App) { + pub(crate) fn pending_input_changed(&mut self, cx: &mut App) { self.pending_input_observers .clone() .retain(&(), |callback| callback(self, cx)); diff --git a/crates/gpui/src/window/prompts.rs b/crates/gpui/src/window/prompts.rs index 63ad1668bec298a6b59d218bf7d4ca7cdce11e8c..980c6f6812405a8fbf4f8c6e24388ab4f967a94c 100644 --- a/crates/gpui/src/window/prompts.rs +++ b/crates/gpui/src/window/prompts.rs @@ -44,10 +44,10 @@ impl PromptHandle { if let Some(sender) = sender.take() { sender.send(e.0).ok(); window_handle - .update(cx, |_, window, _cx| { + .update(cx, |_, window, cx| { window.prompt.take(); if let Some(previous_focus) = &previous_focus { - window.focus(previous_focus); + window.focus(previous_focus, cx); } }) .ok(); @@ -55,7 +55,7 @@ impl PromptHandle { }) .detach(); - window.focus(&view.focus_handle(cx)); + window.focus(&view.focus_handle(cx), cx); RenderablePromptHandle { view: Box::new(view), diff --git a/crates/gpui_macros/src/derive_visual_context.rs b/crates/gpui_macros/src/derive_visual_context.rs index f2681bb29b92f31d31599ebb7201a42a482283d8..b827e753d9678efba01d3fdd77f8e66ea62b6bbd 100644 --- a/crates/gpui_macros/src/derive_visual_context.rs +++ b/crates/gpui_macros/src/derive_visual_context.rs @@ -62,7 +62,7 @@ pub fn derive_visual_context(input: TokenStream) -> TokenStream { V: gpui::Focusable, { let focus_handle = gpui::Focusable::focus_handle(entity, self.#app_variable); - self.#window_variable.focus(&focus_handle) + self.#window_variable.focus(&focus_handle, self.#app_variable) } } }; diff --git a/crates/keymap_editor/src/keymap_editor.rs b/crates/keymap_editor/src/keymap_editor.rs index 9e243d32151e3caeec2b8c51c7889d2ebe93f29b..be20feaf5f8c1feea5b08fa3a6a3b542b26ef5ce 100644 --- a/crates/keymap_editor/src/keymap_editor.rs +++ b/crates/keymap_editor/src/keymap_editor.rs @@ -911,7 +911,7 @@ impl KeymapEditor { .focus_handle(cx) .contains_focused(window, cx) { - window.focus(&self.filter_editor.focus_handle(cx)); + window.focus(&self.filter_editor.focus_handle(cx), cx); } else { self.filter_editor.update(cx, |editor, cx| { editor.select_all(&Default::default(), window, cx); @@ -948,7 +948,7 @@ impl KeymapEditor { if let Some(scroll_strategy) = scroll { self.scroll_to_item(index, scroll_strategy, cx); } - window.focus(&self.focus_handle); + window.focus(&self.focus_handle, cx); cx.notify(); } } @@ -998,7 +998,7 @@ impl KeymapEditor { }); let context_menu_handle = context_menu.focus_handle(cx); - window.defer(cx, move |window, _cx| window.focus(&context_menu_handle)); + window.defer(cx, move |window, cx| window.focus(&context_menu_handle, cx)); let subscription = cx.subscribe_in( &context_menu, window, @@ -1014,7 +1014,7 @@ impl KeymapEditor { fn dismiss_context_menu(&mut self, window: &mut Window, cx: &mut Context) { self.context_menu.take(); - window.focus(&self.focus_handle); + window.focus(&self.focus_handle, cx); cx.notify(); } @@ -1230,7 +1230,7 @@ impl KeymapEditor { window, cx, ); - window.focus(&modal.focus_handle(cx)); + window.focus(&modal.focus_handle(cx), cx); modal }); }) @@ -1338,7 +1338,7 @@ impl KeymapEditor { editor.stop_recording(&StopRecording, window, cx); editor.clear_keystrokes(&ClearKeystrokes, window, cx); }); - window.focus(&self.filter_editor.focus_handle(cx)); + window.focus(&self.filter_editor.focus_handle(cx), cx); } } } @@ -2698,32 +2698,32 @@ impl KeybindingEditorModalFocusState { .map(|i| i as i32) } - fn focus_index(&self, mut index: i32, window: &mut Window) { + fn focus_index(&self, mut index: i32, window: &mut Window, cx: &mut App) { if index < 0 { index = self.handles.len() as i32 - 1; } if index >= self.handles.len() as i32 { index = 0; } - window.focus(&self.handles[index as usize]); + window.focus(&self.handles[index as usize], cx); } - fn focus_next(&self, window: &mut Window, cx: &App) { + fn focus_next(&self, window: &mut Window, cx: &mut App) { let index_to_focus = if let Some(index) = self.focused_index(window, cx) { index + 1 } else { 0 }; - self.focus_index(index_to_focus, window); + self.focus_index(index_to_focus, window, cx); } - fn focus_previous(&self, window: &mut Window, cx: &App) { + fn focus_previous(&self, window: &mut Window, cx: &mut App) { let index_to_focus = if let Some(index) = self.focused_index(window, cx) { index - 1 } else { self.handles.len() as i32 - 1 }; - self.focus_index(index_to_focus, window); + self.focus_index(index_to_focus, window, cx); } } @@ -2757,7 +2757,7 @@ impl ActionArgumentsEditor { ) -> Self { let focus_handle = cx.focus_handle(); cx.on_focus_in(&focus_handle, window, |this, window, cx| { - this.editor.focus_handle(cx).focus(window); + this.editor.focus_handle(cx).focus(window, cx); }) .detach(); let editor = cx.new(|cx| { @@ -2810,7 +2810,7 @@ impl ActionArgumentsEditor { this.update_in(cx, |this, window, cx| { if this.editor.focus_handle(cx).is_focused(window) { - editor.focus_handle(cx).focus(window); + editor.focus_handle(cx).focus(window, cx); } this.editor = editor; this.backup_temp_dir = backup_temp_dir; diff --git a/crates/keymap_editor/src/ui_components/keystroke_input.rs b/crates/keymap_editor/src/ui_components/keystroke_input.rs index 6936de784f9d5c16b218d0952c41d6336299a0f9..496a8ae7e6359bc169845542a0f05800008a4786 100644 --- a/crates/keymap_editor/src/ui_components/keystroke_input.rs +++ b/crates/keymap_editor/src/ui_components/keystroke_input.rs @@ -388,7 +388,7 @@ impl KeystrokeInput { window: &mut Window, cx: &mut Context, ) { - window.focus(&self.inner_focus_handle); + window.focus(&self.inner_focus_handle, cx); self.clear_keystrokes(&ClearKeystrokes, window, cx); self.previous_modifiers = window.modifiers(); #[cfg(test)] @@ -407,7 +407,7 @@ impl KeystrokeInput { if !self.is_recording(window) { return; } - window.focus(&self.outer_focus_handle); + window.focus(&self.outer_focus_handle, cx); if let Some(close_keystrokes_start) = self.close_keystrokes_start.take() && close_keystrokes_start < self.keystrokes.len() { diff --git a/crates/language_models/src/provider/bedrock.rs b/crates/language_models/src/provider/bedrock.rs index 9273234161a8169abf68190ca8fe4627b8f769dc..286f9ec1a4bf67c22868cf83e00e7b46e0737ba8 100644 --- a/crates/language_models/src/provider/bedrock.rs +++ b/crates/language_models/src/provider/bedrock.rs @@ -1298,17 +1298,17 @@ impl ConfigurationView { self.state.read(cx).is_authenticated() } - fn on_tab(&mut self, _: &menu::SelectNext, window: &mut Window, _: &mut Context) { - window.focus_next(); + fn on_tab(&mut self, _: &menu::SelectNext, window: &mut Window, cx: &mut Context) { + window.focus_next(cx); } fn on_tab_prev( &mut self, _: &menu::SelectPrevious, window: &mut Window, - _: &mut Context, + cx: &mut Context, ) { - window.focus_prev(); + window.focus_prev(cx); } } diff --git a/crates/language_tools/src/lsp_log_view.rs b/crates/language_tools/src/lsp_log_view.rs index 314dcc0b9bde998a0fec65b2847ae13641f0d011..6fc061cd07edd9e22609ba698f27860b1b905765 100644 --- a/crates/language_tools/src/lsp_log_view.rs +++ b/crates/language_tools/src/lsp_log_view.rs @@ -269,7 +269,7 @@ impl LspLogView { let focus_handle = cx.focus_handle(); let focus_subscription = cx.on_focus(&focus_handle, window, |log_view, window, cx| { - window.focus(&log_view.editor.focus_handle(cx)); + window.focus(&log_view.editor.focus_handle(cx), cx); }); cx.on_release(|log_view, cx| { @@ -462,7 +462,7 @@ impl LspLogView { self.editor_subscriptions = editor_subscriptions; cx.notify(); } - self.editor.read(cx).focus_handle(cx).focus(window); + self.editor.read(cx).focus_handle(cx).focus(window, cx); self.log_store.update(cx, |log_store, cx| { let state = log_store.get_language_server_state(server_id)?; state.toggled_log_kind = Some(LogKind::Logs); @@ -494,7 +494,7 @@ impl LspLogView { cx.notify(); } - self.editor.read(cx).focus_handle(cx).focus(window); + self.editor.read(cx).focus_handle(cx).focus(window, cx); } fn show_trace_for_server( @@ -528,7 +528,7 @@ impl LspLogView { }); cx.notify(); } - self.editor.read(cx).focus_handle(cx).focus(window); + self.editor.read(cx).focus_handle(cx).focus(window, cx); } fn show_rpc_trace_for_server( @@ -572,7 +572,7 @@ impl LspLogView { cx.notify(); } - self.editor.read(cx).focus_handle(cx).focus(window); + self.editor.read(cx).focus_handle(cx).focus(window, cx); } fn toggle_rpc_trace_for_server( @@ -660,7 +660,7 @@ impl LspLogView { self.editor = editor; self.editor_subscriptions = editor_subscriptions; cx.notify(); - self.editor.read(cx).focus_handle(cx).focus(window); + self.editor.read(cx).focus_handle(cx).focus(window, cx); self.log_store.update(cx, |log_store, cx| { let state = log_store.get_language_server_state(server_id)?; if let Some(log_kind) = state.toggled_log_kind.take() { @@ -1314,7 +1314,7 @@ impl LspLogToolbarItemView { log_view.show_rpc_trace_for_server(id, window, cx); cx.notify(); } - window.focus(&log_view.focus_handle); + window.focus(&log_view.focus_handle, cx); }); } cx.notify(); diff --git a/crates/language_tools/src/syntax_tree_view.rs b/crates/language_tools/src/syntax_tree_view.rs index 0fbcdcca5eca80a01738888266389db5a678f3e8..15776e07d6d18835885ac5bafb2b29191d9e6bed 100644 --- a/crates/language_tools/src/syntax_tree_view.rs +++ b/crates/language_tools/src/syntax_tree_view.rs @@ -659,7 +659,7 @@ impl SyntaxTreeToolbarItemView { buffer_state.active_layer = Some(layer.to_owned()); view.selected_descendant_ix = None; cx.notify(); - view.focus_handle.focus(window); + view.focus_handle.focus(window, cx); Some(()) }) } diff --git a/crates/markdown/src/markdown.rs b/crates/markdown/src/markdown.rs index 706fe894699afe8d1ae32c0525214ec6bf614912..0bc3b9eb726e1782bafb2a31229ea21f308adc6e 100644 --- a/crates/markdown/src/markdown.rs +++ b/crates/markdown/src/markdown.rs @@ -707,7 +707,7 @@ impl MarkdownElement { pending: true, mode, }; - window.focus(&markdown.focus_handle); + window.focus(&markdown.focus_handle, cx); } window.prevent_default(); diff --git a/crates/markdown_preview/src/markdown_preview_view.rs b/crates/markdown_preview/src/markdown_preview_view.rs index 20613b112eeccf76ec8be12bddc49c12b600ff9b..650f369309561d76669289737277b45fb99af5ec 100644 --- a/crates/markdown_preview/src/markdown_preview_view.rs +++ b/crates/markdown_preview/src/markdown_preview_view.rs @@ -96,7 +96,7 @@ impl MarkdownPreviewView { pane.add_item(Box::new(view.clone()), false, false, None, window, cx) } }); - editor.focus_handle(cx).focus(window); + editor.focus_handle(cx).focus(window, cx); cx.notify(); } }); @@ -370,7 +370,7 @@ impl MarkdownPreviewView { cx, |selections| selections.select_ranges(vec![selection]), ); - window.focus(&editor.focus_handle(cx)); + window.focus(&editor.focus_handle(cx), cx); }); } } diff --git a/crates/onboarding/src/onboarding.rs b/crates/onboarding/src/onboarding.rs index 66402f33d31c6e9ce5894c56872c8d92d2c4c36c..495a55411fc936d476dfa0d443e155d1fa7faecd 100644 --- a/crates/onboarding/src/onboarding.rs +++ b/crates/onboarding/src/onboarding.rs @@ -190,7 +190,7 @@ pub fn show_onboarding_view(app_state: Arc, cx: &mut App) -> Task(); - window.focus(&active_editor.focus_handle(cx)); + window.focus(&active_editor.focus_handle(cx), cx); } }); diff --git a/crates/outline_panel/src/outline_panel.rs b/crates/outline_panel/src/outline_panel.rs index 8dbf7b681d9be45bda0fd9803cbb8e2cd434e921..5a32bd73b74a9e8caade1042a381983af0da71d3 100644 --- a/crates/outline_panel/src/outline_panel.rs +++ b/crates/outline_panel/src/outline_panel.rs @@ -998,9 +998,9 @@ impl OutlinePanel { fn cancel(&mut self, _: &Cancel, window: &mut Window, cx: &mut Context) { if self.filter_editor.focus_handle(cx).is_focused(window) { - self.focus_handle.focus(window); + self.focus_handle.focus(window, cx); } else { - self.filter_editor.focus_handle(cx).focus(window); + self.filter_editor.focus_handle(cx).focus(window, cx); } if self.context_menu.is_some() { @@ -1153,9 +1153,9 @@ impl OutlinePanel { } if change_focus { - active_editor.focus_handle(cx).focus(window); + active_editor.focus_handle(cx).focus(window, cx); } else { - self.focus_handle.focus(window); + self.focus_handle.focus(window, cx); } } } @@ -1458,7 +1458,7 @@ impl OutlinePanel { Box::new(zed_actions::workspace::CopyRelativePath), ) }); - window.focus(&context_menu.focus_handle(cx)); + window.focus(&context_menu.focus_handle(cx), cx); let subscription = cx.subscribe(&context_menu, |outline_panel, _, _: &DismissEvent, cx| { outline_panel.context_menu.take(); cx.notify(); @@ -4539,7 +4539,7 @@ impl OutlinePanel { cx: &mut Context, ) { if focus { - self.focus_handle.focus(window); + self.focus_handle.focus(window, cx); } let ix = self .cached_entries diff --git a/crates/picker/src/picker.rs b/crates/picker/src/picker.rs index 3d6ae27dfa0c6b60088995de6ccc1d85b08c9428..2da40b5bf4b47651df7236b0decb25fac67a3b1b 100644 --- a/crates/picker/src/picker.rs +++ b/crates/picker/src/picker.rs @@ -384,7 +384,7 @@ impl Picker { } pub fn focus(&self, window: &mut Window, cx: &mut App) { - self.focus_handle(cx).focus(window); + self.focus_handle(cx).focus(window, cx); } /// Handles the selecting an index, and passing the change to the delegate. diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rs index ea667ecbb479ca347914ee11ec789a14f29cf474..00aba96ef428eea643e8868e513ab9c3aaa1b910 100644 --- a/crates/project_panel/src/project_panel.rs +++ b/crates/project_panel/src/project_panel.rs @@ -880,7 +880,7 @@ impl ProjectPanel { }); if !focus_opened_item { let focus_handle = project_panel.read(cx).focus_handle.clone(); - window.focus(&focus_handle); + window.focus(&focus_handle, cx); } } } @@ -1169,7 +1169,7 @@ impl ProjectPanel { }) }); - window.focus(&context_menu.focus_handle(cx)); + window.focus(&context_menu.focus_handle(cx), cx); let subscription = cx.subscribe(&context_menu, |this, _, _: &DismissEvent, cx| { this.context_menu.take(); cx.notify(); @@ -1376,7 +1376,7 @@ impl ProjectPanel { } }); self.update_visible_entries(Some((worktree_id, entry_id)), false, false, window, cx); - window.focus(&self.focus_handle); + window.focus(&self.focus_handle, cx); cx.notify(); } } @@ -1399,7 +1399,7 @@ impl ProjectPanel { } } self.update_visible_entries(Some((worktree_id, entry_id)), false, false, window, cx); - window.focus(&self.focus_handle); + window.focus(&self.focus_handle, cx); cx.notify(); } } @@ -1719,7 +1719,7 @@ impl ProjectPanel { }; if let Some(existing) = worktree.read(cx).entry_for_path(&new_path) { if existing.id == entry.id && refocus { - window.focus(&self.focus_handle); + window.focus(&self.focus_handle, cx); } return None; } @@ -1730,7 +1730,7 @@ impl ProjectPanel { }; if refocus { - window.focus(&self.focus_handle); + window.focus(&self.focus_handle, cx); } edit_state.processing_filename = Some(filename); cx.notify(); @@ -1839,7 +1839,7 @@ impl ProjectPanel { self.autoscroll(cx); } - window.focus(&self.focus_handle); + window.focus(&self.focus_handle, cx); cx.notify(); } @@ -3616,7 +3616,7 @@ impl ProjectPanel { if this.update_visible_entries_task.focus_filename_editor { this.update_visible_entries_task.focus_filename_editor = false; this.filename_editor.update(cx, |editor, cx| { - window.focus(&editor.focus_handle(cx)); + window.focus(&editor.focus_handle(cx), cx); }); } if this.update_visible_entries_task.autoscroll { @@ -5952,7 +5952,7 @@ impl Render for ProjectPanel { cx.stop_propagation(); this.state.selection = None; this.marked_entries.clear(); - this.focus_handle(cx).focus(window); + this.focus_handle(cx).focus(window, cx); })) .on_mouse_down( MouseButton::Right, diff --git a/crates/recent_projects/src/remote_connections.rs b/crates/recent_projects/src/remote_connections.rs index e8349601b5303331c0a6a38aca306fe57ab07ed3..1bab31b4d0ebb80444c40c99feb984ebd23feb60 100644 --- a/crates/recent_projects/src/remote_connections.rs +++ b/crates/recent_projects/src/remote_connections.rs @@ -209,7 +209,7 @@ impl RemoteConnectionPrompt { let markdown = cx.new(|cx| Markdown::new_text(prompt.into(), cx)); self.prompt = Some((markdown, tx)); self.status_message.take(); - window.focus(&self.editor.focus_handle(cx)); + window.focus(&self.editor.focus_handle(cx), cx); cx.notify(); } diff --git a/crates/recent_projects/src/remote_servers.rs b/crates/recent_projects/src/remote_servers.rs index a4388c6026ab7aa6bbdfc75d025e095b5a2a6187..15735b6664e4b72749b0149013d02428eb2735de 100644 --- a/crates/recent_projects/src/remote_servers.rs +++ b/crates/recent_projects/src/remote_servers.rs @@ -76,7 +76,7 @@ impl CreateRemoteServer { fn new(window: &mut Window, cx: &mut App) -> Self { let address_editor = cx.new(|cx| Editor::single_line(window, cx)); address_editor.update(cx, |this, cx| { - this.focus_handle(cx).focus(window); + this.focus_handle(cx).focus(window, cx); }); Self { address_editor, @@ -107,7 +107,7 @@ struct CreateRemoteDevContainer { impl CreateRemoteDevContainer { fn new(window: &mut Window, cx: &mut Context) -> Self { let entries = std::array::from_fn(|_| NavigableEntry::focusable(cx)); - entries[0].focus_handle.focus(window); + entries[0].focus_handle.focus(window, cx); Self { entries, progress: DevContainerCreationProgress::Initial, @@ -199,7 +199,7 @@ impl EditNicknameState { this.set_text(starting_text, window, cx); } }); - this.editor.focus_handle(cx).focus(window); + this.editor.focus_handle(cx).focus(window, cx); this } } @@ -792,7 +792,7 @@ impl RemoteServerProjects { this.retained_connections.push(client); this.add_ssh_server(connection_options, cx); this.mode = Mode::default_mode(&this.ssh_config_servers, cx); - this.focus_handle(cx).focus(window); + this.focus_handle(cx).focus(window, cx); cx.notify() }) .log_err(), @@ -875,7 +875,7 @@ impl RemoteServerProjects { crate::add_wsl_distro(fs, &connection_options, cx); this.mode = Mode::default_mode(&BTreeSet::new(), cx); - this.focus_handle(cx).focus(window); + this.focus_handle(cx).focus(window, cx); cx.notify(); }), _ => this.update(cx, |this, cx| { @@ -924,7 +924,7 @@ impl RemoteServerProjects { return; } }); - self.focus_handle(cx).focus(window); + self.focus_handle(cx).focus(window, cx); cx.notify(); } @@ -933,7 +933,7 @@ impl RemoteServerProjects { CreateRemoteDevContainer::new(window, cx) .progress(DevContainerCreationProgress::Creating), ); - self.focus_handle(cx).focus(window); + self.focus_handle(cx).focus(window, cx); cx.notify(); } @@ -1068,7 +1068,7 @@ impl RemoteServerProjects { } }); self.mode = Mode::default_mode(&self.ssh_config_servers, cx); - self.focus_handle.focus(window); + self.focus_handle.focus(window, cx); } #[cfg(target_os = "windows")] Mode::AddWslDistro(state) => { @@ -1094,7 +1094,7 @@ impl RemoteServerProjects { } _ => { self.mode = Mode::default_mode(&self.ssh_config_servers, cx); - self.focus_handle(cx).focus(window); + self.focus_handle(cx).focus(window, cx); cx.notify(); } } @@ -1640,7 +1640,7 @@ impl RemoteServerProjects { ) -> impl IntoElement { match &state.progress { DevContainerCreationProgress::Error(message) => { - self.focus_handle(cx).focus(window); + self.focus_handle(cx).focus(window, cx); return div() .track_focus(&self.focus_handle(cx)) .size_full() @@ -1952,7 +1952,7 @@ impl RemoteServerProjects { let connection_prompt = state.connection_prompt.clone(); state.picker.update(cx, |picker, cx| { - picker.focus_handle(cx).focus(window); + picker.focus_handle(cx).focus(window, cx); }); v_flex() @@ -2752,7 +2752,7 @@ impl Render for RemoteServerProjects { .on_action(cx.listener(Self::cancel)) .on_action(cx.listener(Self::confirm)) .capture_any_mouse_down(cx.listener(|this, _, window, cx| { - this.focus_handle(cx).focus(window); + this.focus_handle(cx).focus(window, cx); })) .on_mouse_down_out(cx.listener(|this, _, _, cx| { if matches!(this.mode, Mode::Default(_)) { diff --git a/crates/rules_library/src/rules_library.rs b/crates/rules_library/src/rules_library.rs index 00cf939f7af45f7701cd9d3599a103ece4a6f393..642d6b64f79ed0f52b9cdb7feee900cf87af83cc 100644 --- a/crates/rules_library/src/rules_library.rs +++ b/crates/rules_library/src/rules_library.rs @@ -720,7 +720,7 @@ impl RulesLibrary { if focus { rule_editor .body_editor - .update(cx, |editor, cx| window.focus(&editor.focus_handle(cx))); + .update(cx, |editor, cx| window.focus(&editor.focus_handle(cx), cx)); } self.set_active_rule(Some(prompt_id), window, cx); } else if let Some(rule_metadata) = self.store.read(cx).metadata(prompt_id) { @@ -763,7 +763,7 @@ impl RulesLibrary { editor.set_current_line_highlight(Some(CurrentLineHighlight::None)); editor.set_completion_provider(Some(make_completion_provider())); if focus { - window.focus(&editor.focus_handle(cx)); + window.focus(&editor.focus_handle(cx), cx); } editor }); @@ -939,7 +939,7 @@ impl RulesLibrary { if let Some(active_rule) = self.active_rule_id { self.rule_editors[&active_rule] .body_editor - .update(cx, |editor, cx| window.focus(&editor.focus_handle(cx))); + .update(cx, |editor, cx| window.focus(&editor.focus_handle(cx), cx)); cx.stop_propagation(); } } @@ -998,7 +998,7 @@ impl RulesLibrary { if let Some(rule_id) = self.active_rule_id && let Some(rule_editor) = self.rule_editors.get(&rule_id) { - window.focus(&rule_editor.body_editor.focus_handle(cx)); + window.focus(&rule_editor.body_editor.focus_handle(cx), cx); } } @@ -1011,7 +1011,7 @@ impl RulesLibrary { if let Some(rule_id) = self.active_rule_id && let Some(rule_editor) = self.rule_editors.get(&rule_id) { - window.focus(&rule_editor.title_editor.focus_handle(cx)); + window.focus(&rule_editor.title_editor.focus_handle(cx), cx); } } @@ -1308,8 +1308,8 @@ impl RulesLibrary { .size_full() .relative() .overflow_hidden() - .on_click(cx.listener(move |_, _, window, _| { - window.focus(&focus_handle); + .on_click(cx.listener(move |_, _, window, cx| { + window.focus(&focus_handle, cx); })) .child( h_flex() diff --git a/crates/search/src/buffer_search.rs b/crates/search/src/buffer_search.rs index 686d385aa07accac168062fa598790b36e80199f..66641e91a882b0b994e16673e3c65a1d51f27650 100644 --- a/crates/search/src/buffer_search.rs +++ b/crates/search/src/buffer_search.rs @@ -518,7 +518,7 @@ impl BufferSearchBar { pub fn register(registrar: &mut impl SearchActionsRegistrar) { registrar.register_handler(ForDeployed(|this, _: &FocusSearch, window, cx| { - this.query_editor.focus_handle(cx).focus(window); + this.query_editor.focus_handle(cx).focus(window, cx); this.select_query(window, cx); })); registrar.register_handler(ForDeployed( @@ -706,7 +706,7 @@ impl BufferSearchBar { active_editor.search_bar_visibility_changed(false, window, cx); active_editor.toggle_filtered_search_ranges(None, window, cx); let handle = active_editor.item_focus_handle(cx); - self.focus(&handle, window); + self.focus(&handle, window, cx); } cx.emit(Event::UpdateLocation); @@ -749,7 +749,7 @@ impl BufferSearchBar { self.select_query(window, cx); } - window.focus(&handle); + window.focus(&handle, cx); } return true; } @@ -878,7 +878,7 @@ impl BufferSearchBar { } pub fn focus_replace(&mut self, window: &mut Window, cx: &mut Context) { - self.focus(&self.replacement_editor.focus_handle(cx), window); + self.focus(&self.replacement_editor.focus_handle(cx), window, cx); cx.notify(); } @@ -909,7 +909,7 @@ impl BufferSearchBar { pub fn focus_editor(&mut self, _: &FocusEditor, window: &mut Window, cx: &mut Context) { if let Some(active_editor) = self.active_searchable_item.as_ref() { let handle = active_editor.item_focus_handle(cx); - window.focus(&handle); + window.focus(&handle, cx); } } @@ -1384,7 +1384,7 @@ impl BufferSearchBar { Direction::Prev => (current_index - 1) % handles.len(), }; let next_focus_handle = &handles[new_index]; - self.focus(next_focus_handle, window); + self.focus(next_focus_handle, window, cx); cx.stop_propagation(); } @@ -1431,9 +1431,9 @@ impl BufferSearchBar { } } - fn focus(&self, handle: &gpui::FocusHandle, window: &mut Window) { + fn focus(&self, handle: &gpui::FocusHandle, window: &mut Window, cx: &mut App) { window.invalidate_character_coordinates(); - window.focus(handle); + window.focus(handle, cx); } fn toggle_replace(&mut self, _: &ToggleReplace, window: &mut Window, cx: &mut Context) { @@ -1444,7 +1444,7 @@ impl BufferSearchBar { } else { self.query_editor.focus_handle(cx) }; - self.focus(&handle, window); + self.focus(&handle, window, cx); cx.notify(); } } @@ -2038,7 +2038,7 @@ mod tests { .update(cx, |_, window, cx| { search_bar.update(cx, |search_bar, cx| { let handle = search_bar.query_editor.focus_handle(cx); - window.focus(&handle); + window.focus(&handle, cx); search_bar.activate_current_match(window, cx); }); assert!( @@ -2056,7 +2056,7 @@ mod tests { search_bar.update(cx, |search_bar, cx| { assert_eq!(search_bar.active_match_index, Some(0)); let handle = search_bar.query_editor.focus_handle(cx); - window.focus(&handle); + window.focus(&handle, cx); search_bar.select_all_matches(&SelectAllMatches, window, cx); }); assert!( @@ -2109,7 +2109,7 @@ mod tests { "Match index should be updated to the next one" ); let handle = search_bar.query_editor.focus_handle(cx); - window.focus(&handle); + window.focus(&handle, cx); search_bar.select_all_matches(&SelectAllMatches, window, cx); }); }) @@ -2175,7 +2175,7 @@ mod tests { .update(cx, |_, window, cx| { search_bar.update(cx, |search_bar, cx| { let handle = search_bar.query_editor.focus_handle(cx); - window.focus(&handle); + window.focus(&handle, cx); search_bar.search("abas_nonexistent_match", None, true, window, cx) }) }) diff --git a/crates/search/src/project_search.rs b/crates/search/src/project_search.rs index 278f2e86b7b13fd5a82777054c12ff2e1b6239bb..e0bbf58ce6f1d0c752914bbbfa6fcdf70ea30175 100644 --- a/crates/search/src/project_search.rs +++ b/crates/search/src/project_search.rs @@ -954,9 +954,9 @@ impl ProjectSearchView { cx.on_next_frame(window, |this, window, cx| { if this.focus_handle.is_focused(window) { if this.has_matches() { - this.results_editor.focus_handle(cx).focus(window); + this.results_editor.focus_handle(cx).focus(window, cx); } else { - this.query_editor.focus_handle(cx).focus(window); + this.query_editor.focus_handle(cx).focus(window, cx); } } }); @@ -1453,7 +1453,7 @@ impl ProjectSearchView { query_editor.select_all(&SelectAll, window, cx); }); let editor_handle = self.query_editor.focus_handle(cx); - window.focus(&editor_handle); + window.focus(&editor_handle, cx); } fn set_query(&mut self, query: &str, window: &mut Window, cx: &mut Context) { @@ -1493,7 +1493,7 @@ impl ProjectSearchView { }); }); let results_handle = self.results_editor.focus_handle(cx); - window.focus(&results_handle); + window.focus(&results_handle, cx); } fn entity_changed(&mut self, window: &mut Window, cx: &mut Context) { @@ -1750,7 +1750,7 @@ impl ProjectSearchBar { fn focus_search(&mut self, window: &mut Window, cx: &mut Context) { if let Some(search_view) = self.active_project_search.as_ref() { search_view.update(cx, |search_view, cx| { - search_view.query_editor.focus_handle(cx).focus(window); + search_view.query_editor.focus_handle(cx).focus(window, cx); }); } } @@ -1783,7 +1783,7 @@ impl ProjectSearchBar { Direction::Prev => (current_index - 1) % views.len(), }; let next_focus_handle = &views[new_index]; - window.focus(next_focus_handle); + window.focus(next_focus_handle, cx); cx.stop_propagation(); }); } @@ -1832,7 +1832,7 @@ impl ProjectSearchBar { } else { this.query_editor.focus_handle(cx) }; - window.focus(&editor_to_focus); + window.focus(&editor_to_focus, cx); cx.notify(); }); } @@ -4352,7 +4352,7 @@ pub mod tests { let buffer_search_query = "search bar query"; buffer_search_bar .update_in(&mut cx, |buffer_search_bar, window, cx| { - buffer_search_bar.focus_handle(cx).focus(window); + buffer_search_bar.focus_handle(cx).focus(window, cx); buffer_search_bar.search(buffer_search_query, None, true, window, cx) }) .await diff --git a/crates/search/src/search.rs b/crates/search/src/search.rs index 6663f8c3184aba9fedbcd5faa3d80d5889181074..3aa40894ea91ed7af3441fad210f6ce0f9e1dd53 100644 --- a/crates/search/src/search.rs +++ b/crates/search/src/search.rs @@ -143,7 +143,7 @@ impl SearchOption { let focus_handle = focus_handle.clone(); button.on_click(move |_: &ClickEvent, window, cx| { if !focus_handle.is_focused(window) { - window.focus(&focus_handle); + window.focus(&focus_handle, cx); } window.dispatch_action(action.boxed_clone(), cx); }) diff --git a/crates/search/src/search_bar.rs b/crates/search/src/search_bar.rs index 13b4df9574aa6b2568dd6db25c6b63551d9b6d03..a1f6c070724c4d57b438c452ef4b4ae3cf20e66d 100644 --- a/crates/search/src/search_bar.rs +++ b/crates/search/src/search_bar.rs @@ -27,7 +27,7 @@ pub(super) fn render_action_button( let focus_handle = focus_handle.clone(); move |_, window, cx| { if !focus_handle.is_focused(window) { - window.focus(&focus_handle); + window.focus(&focus_handle, cx); } window.dispatch_action(action.boxed_clone(), cx); } diff --git a/crates/settings_ui/src/settings_ui.rs b/crates/settings_ui/src/settings_ui.rs index 101f52159a263910fba0d65782f06784f8183fd0..0ec6d0aee308ce3c20b67a5db9c6a6d9224bf229 100644 --- a/crates/settings_ui/src/settings_ui.rs +++ b/crates/settings_ui/src/settings_ui.rs @@ -345,8 +345,8 @@ impl NonFocusableHandle { fn from_handle(handle: FocusHandle, window: &mut Window, cx: &mut App) -> Entity { cx.new(|cx| { let _subscription = cx.on_focus(&handle, window, { - move |_, window, _| { - window.focus_next(); + move |_, window, cx| { + window.focus_next(cx); } }); Self { @@ -1537,7 +1537,7 @@ impl SettingsWindow { this.build_search_index(); this.search_bar.update(cx, |editor, cx| { - editor.focus_handle(cx).focus(window); + editor.focus_handle(cx).focus(window, cx); }); this @@ -2174,7 +2174,7 @@ impl SettingsWindow { let focus_handle = focus_handle.clone(); move |this, _: &gpui::ClickEvent, window, cx| { this.change_file(ix, window, cx); - focus_handle.focus(window); + focus_handle.focus(window, cx); } })) }; @@ -2251,7 +2251,7 @@ impl SettingsWindow { this.update(cx, |this, cx| { this.change_file(ix, window, cx); }); - focus_handle.focus(window); + focus_handle.focus(window, cx); } }, ); @@ -2385,7 +2385,7 @@ impl SettingsWindow { let focused_entry_parent = this.root_entry_containing(focused_entry); if this.navbar_entries[focused_entry_parent].expanded { this.toggle_navbar_entry(focused_entry_parent); - window.focus(&this.navbar_entries[focused_entry_parent].focus_handle); + window.focus(&this.navbar_entries[focused_entry_parent].focus_handle, cx); } cx.notify(); })) @@ -2534,6 +2534,7 @@ impl SettingsWindow { window.focus( &this.navbar_entries[entry_index] .focus_handle, + cx, ); cx.notify(); }, @@ -2658,7 +2659,7 @@ impl SettingsWindow { // back to back. cx.on_next_frame(window, move |_, window, cx| { if let Some(handle) = handle_to_focus.as_ref() { - window.focus(handle); + window.focus(handle, cx); } cx.on_next_frame(window, |_, _, cx| { @@ -2725,7 +2726,7 @@ impl SettingsWindow { }; self.navbar_scroll_handle .scroll_to_item(position, gpui::ScrollStrategy::Top); - window.focus(&self.navbar_entries[nav_entry_index].focus_handle); + window.focus(&self.navbar_entries[nav_entry_index].focus_handle, cx); cx.notify(); } @@ -3100,7 +3101,7 @@ impl SettingsWindow { .id("settings-ui-page") .on_action(cx.listener(|this, _: &menu::SelectNext, window, cx| { if !sub_page_stack().is_empty() { - window.focus_next(); + window.focus_next(cx); return; } for (logical_index, (actual_index, _)) in this.visible_page_items().enumerate() { @@ -3120,7 +3121,7 @@ impl SettingsWindow { cx.on_next_frame(window, |_, window, cx| { cx.notify(); cx.on_next_frame(window, |_, window, cx| { - window.focus_next(); + window.focus_next(cx); cx.notify(); }); }); @@ -3128,11 +3129,11 @@ impl SettingsWindow { return; } } - window.focus_next(); + window.focus_next(cx); })) .on_action(cx.listener(|this, _: &menu::SelectPrevious, window, cx| { if !sub_page_stack().is_empty() { - window.focus_prev(); + window.focus_prev(cx); return; } let mut prev_was_header = false; @@ -3152,7 +3153,7 @@ impl SettingsWindow { cx.on_next_frame(window, |_, window, cx| { cx.notify(); cx.on_next_frame(window, |_, window, cx| { - window.focus_prev(); + window.focus_prev(cx); cx.notify(); }); }); @@ -3161,7 +3162,7 @@ impl SettingsWindow { } prev_was_header = is_header; } - window.focus_prev(); + window.focus_prev(cx); })) .when(sub_page_stack().is_empty(), |this| { this.vertical_scrollbar_for(&self.list_state, window, cx) @@ -3364,19 +3365,19 @@ impl SettingsWindow { }); self.sub_page_scroll_handle .set_offset(point(px(0.), px(0.))); - self.content_focus_handle.focus_handle(cx).focus(window); + self.content_focus_handle.focus_handle(cx).focus(window, cx); cx.notify(); } fn pop_sub_page(&mut self, window: &mut Window, cx: &mut Context) { sub_page_stack_mut().pop(); - self.content_focus_handle.focus_handle(cx).focus(window); + self.content_focus_handle.focus_handle(cx).focus(window, cx); cx.notify(); } - fn focus_file_at_index(&mut self, index: usize, window: &mut Window) { + fn focus_file_at_index(&mut self, index: usize, window: &mut Window, cx: &mut App) { if let Some((_, handle)) = self.files.get(index) { - handle.focus(window); + handle.focus(window, cx); } } @@ -3456,7 +3457,7 @@ impl Render for SettingsWindow { window.minimize_window(); }) .on_action(cx.listener(|this, _: &search::FocusSearch, window, cx| { - this.search_bar.focus_handle(cx).focus(window); + this.search_bar.focus_handle(cx).focus(window, cx); })) .on_action(cx.listener(|this, _: &ToggleFocusNav, window, cx| { if this @@ -3476,8 +3477,8 @@ impl Render for SettingsWindow { } })) .on_action(cx.listener( - |this, FocusFile(file_index): &FocusFile, window, _| { - this.focus_file_at_index(*file_index as usize, window); + |this, FocusFile(file_index): &FocusFile, window, cx| { + this.focus_file_at_index(*file_index as usize, window, cx); }, )) .on_action(cx.listener(|this, _: &FocusNextFile, window, cx| { @@ -3485,11 +3486,11 @@ impl Render for SettingsWindow { this.focused_file_index(window, cx) + 1, this.files.len().saturating_sub(1), ); - this.focus_file_at_index(next_index, window); + this.focus_file_at_index(next_index, window, cx); })) .on_action(cx.listener(|this, _: &FocusPreviousFile, window, cx| { let prev_index = this.focused_file_index(window, cx).saturating_sub(1); - this.focus_file_at_index(prev_index, window); + this.focus_file_at_index(prev_index, window, cx); })) .on_action(cx.listener(|this, _: &menu::SelectNext, window, cx| { if this @@ -3499,11 +3500,11 @@ impl Render for SettingsWindow { { this.focus_and_scroll_to_first_visible_nav_entry(window, cx); } else { - window.focus_next(); + window.focus_next(cx); } })) - .on_action(|_: &menu::SelectPrevious, window, _| { - window.focus_prev(); + .on_action(|_: &menu::SelectPrevious, window, cx| { + window.focus_prev(cx); }) .flex() .flex_row() diff --git a/crates/terminal_view/src/terminal_element.rs b/crates/terminal_view/src/terminal_element.rs index fd9568b0c582d4c191267183e296976f3d429eb3..b5324b7c6c7e0c467c657b122717fbf17cf9f7b9 100644 --- a/crates/terminal_view/src/terminal_element.rs +++ b/crates/terminal_view/src/terminal_element.rs @@ -632,7 +632,7 @@ impl TerminalElement { ) -> impl Fn(&E, &mut Window, &mut App) { move |event, window, cx| { if steal_focus { - window.focus(&focus_handle); + window.focus(&focus_handle, cx); } else if !focus_handle.is_focused(window) { return; } @@ -661,7 +661,7 @@ impl TerminalElement { let terminal_view = terminal_view.clone(); move |e, window, cx| { - window.focus(&focus); + window.focus(&focus, cx); let scroll_top = terminal_view.read(cx).scroll_top; terminal.update(cx, |terminal, cx| { diff --git a/crates/terminal_view/src/terminal_panel.rs b/crates/terminal_view/src/terminal_panel.rs index fb660e759c75aee9752cbaa3bdc8c8e0a47615e3..85c6b81f406597e097cabc27408d3df70aad6395 100644 --- a/crates/terminal_view/src/terminal_panel.rs +++ b/crates/terminal_view/src/terminal_panel.rs @@ -351,7 +351,7 @@ impl TerminalPanel { } else if let Some(focus_on_pane) = focus_on_pane.as_ref().or_else(|| self.center.panes().pop()) { - focus_on_pane.focus_handle(cx).focus(window); + focus_on_pane.focus_handle(cx).focus(window, cx); } } pane::Event::ZoomIn => { @@ -397,7 +397,7 @@ impl TerminalPanel { .center .split(&pane, &new_pane, direction, cx) .log_err(); - window.focus(&new_pane.focus_handle(cx)); + window.focus(&new_pane.focus_handle(cx), cx); }) .ok(); }) @@ -419,7 +419,7 @@ impl TerminalPanel { pane.add_item(item, true, true, None, window, cx); }); self.center.split(&pane, &new_pane, direction, cx).log_err(); - window.focus(&new_pane.focus_handle(cx)); + window.focus(&new_pane.focus_handle(cx), cx); } } pane::Event::Focus => { @@ -998,7 +998,7 @@ impl TerminalPanel { RevealStrategy::NoFocus => match reveal_target { RevealTarget::Center => { task_workspace.update_in(cx, |workspace, window, cx| { - workspace.active_pane().focus_handle(cx).focus(window); + workspace.active_pane().focus_handle(cx).focus(window, cx); })?; } RevealTarget::Dock => { @@ -1053,7 +1053,7 @@ impl TerminalPanel { .center .find_pane_in_direction(&self.active_pane, direction, cx) { - window.focus(&pane.focus_handle(cx)); + window.focus(&pane.focus_handle(cx), cx); } else { self.workspace .update(cx, |workspace, cx| { @@ -1297,7 +1297,7 @@ fn add_paths_to_terminal( .active_item() .and_then(|item| item.downcast::()) { - window.focus(&terminal_view.focus_handle(cx)); + window.focus(&terminal_view.focus_handle(cx), cx); let mut new_text = paths.iter().map(|path| format!(" {path:?}")).join(""); new_text.push(' '); terminal_view.update(cx, |terminal_view, cx| { @@ -1451,7 +1451,7 @@ impl Render for TerminalPanel { .position(|pane| **pane == terminal_panel.active_pane) { let next_ix = (ix + 1) % panes.len(); - window.focus(&panes[next_ix].focus_handle(cx)); + window.focus(&panes[next_ix].focus_handle(cx), cx); } }), ) @@ -1463,7 +1463,7 @@ impl Render for TerminalPanel { .position(|pane| **pane == terminal_panel.active_pane) { let prev_ix = cmp::min(ix.wrapping_sub(1), panes.len() - 1); - window.focus(&panes[prev_ix].focus_handle(cx)); + window.focus(&panes[prev_ix].focus_handle(cx), cx); } }, )) @@ -1471,7 +1471,7 @@ impl Render for TerminalPanel { cx.listener(|terminal_panel, action: &ActivatePane, window, cx| { let panes = terminal_panel.center.panes(); if let Some(&pane) = panes.get(action.0) { - window.focus(&pane.read(cx).focus_handle(cx)); + window.focus(&pane.read(cx).focus_handle(cx), cx); } else { let future = terminal_panel.new_pane_with_cloned_active_terminal(window, cx); @@ -1490,7 +1490,7 @@ impl Render for TerminalPanel { ) .log_err(); let new_pane = new_pane.read(cx); - window.focus(&new_pane.focus_handle(cx)); + window.focus(&new_pane.focus_handle(cx), cx); }, ); } diff --git a/crates/terminal_view/src/terminal_view.rs b/crates/terminal_view/src/terminal_view.rs index 98f7a17a2778e05b258f2ab6135cb94ba91ba547..54808934ba7b098a695a8b104a048a379966e6f1 100644 --- a/crates/terminal_view/src/terminal_view.rs +++ b/crates/terminal_view/src/terminal_view.rs @@ -409,7 +409,7 @@ impl TerminalView { ) }); - window.focus(&context_menu.focus_handle(cx)); + window.focus(&context_menu.focus_handle(cx), cx); let subscription = cx.subscribe_in( &context_menu, window, diff --git a/crates/title_bar/src/title_bar.rs b/crates/title_bar/src/title_bar.rs index 608fea7383176460cb4b7519824cd2dc118dbb69..23572677919509d859a141cb09cce8f5822697ef 100644 --- a/crates/title_bar/src/title_bar.rs +++ b/crates/title_bar/src/title_bar.rs @@ -605,7 +605,7 @@ impl TitleBar { }) .on_click(move |_, window, cx| { let _ = workspace.update(cx, |this, cx| { - window.focus(&this.active_pane().focus_handle(cx)); + window.focus(&this.active_pane().focus_handle(cx), cx); window.dispatch_action(zed_actions::git::Branch.boxed_clone(), cx); }); }) diff --git a/crates/toolchain_selector/src/toolchain_selector.rs b/crates/toolchain_selector/src/toolchain_selector.rs index b58b2f8d699f59c15525c452543cf5bdf071ad2c..f7262c248f15f0f68fcd7a903ee01cac6b22d0af 100644 --- a/crates/toolchain_selector/src/toolchain_selector.rs +++ b/crates/toolchain_selector/src/toolchain_selector.rs @@ -225,7 +225,7 @@ impl AddToolchainState { ); }); *input_state = Self::wait_for_path(rx, window, cx); - this.focus_handle(cx).focus(window); + this.focus_handle(cx).focus(window, cx); } }); return Err(anyhow::anyhow!("Failed to resolve toolchain")); @@ -260,7 +260,7 @@ impl AddToolchainState { toolchain, scope_picker, }; - this.focus_handle(cx).focus(window); + this.focus_handle(cx).focus(window, cx); }); Result::<_, anyhow::Error>::Ok(()) @@ -333,7 +333,7 @@ impl AddToolchainState { }); _ = self.weak.update(cx, |this, cx| { this.state = State::Search((this.create_search_state)(window, cx)); - this.focus_handle(cx).focus(window); + this.focus_handle(cx).focus(window, cx); cx.notify(); }); } @@ -383,7 +383,7 @@ impl Render for AddToolchainState { &weak, |this: &mut ToolchainSelector, _: &menu::Cancel, window, cx| { this.state = State::Search((this.create_search_state)(window, cx)); - this.state.focus_handle(cx).focus(window); + this.state.focus_handle(cx).focus(window, cx); cx.notify(); }, )) @@ -703,7 +703,7 @@ impl ToolchainSelector { window, cx, )); - self.state.focus_handle(cx).focus(window); + self.state.focus_handle(cx).focus(window, cx); cx.notify(); } } diff --git a/crates/ui/src/components/context_menu.rs b/crates/ui/src/components/context_menu.rs index a4bae647408f860ec8425266a26efc173099f225..756a2a9364193d6f1cdace8ed8c92cecf401a864 100644 --- a/crates/ui/src/components/context_menu.rs +++ b/crates/ui/src/components/context_menu.rs @@ -562,7 +562,7 @@ impl ContextMenu { action: Some(action.boxed_clone()), handler: Rc::new(move |context, window, cx| { if let Some(context) = &context { - window.focus(context); + window.focus(context, cx); } window.dispatch_action(action.boxed_clone(), cx); }), @@ -594,7 +594,7 @@ impl ContextMenu { action: Some(action.boxed_clone()), handler: Rc::new(move |context, window, cx| { if let Some(context) = &context { - window.focus(context); + window.focus(context, cx); } window.dispatch_action(action.boxed_clone(), cx); }), diff --git a/crates/ui/src/components/navigable.rs b/crates/ui/src/components/navigable.rs index a592bcc36f4cc490c4676a83660ace050025ee39..07e761f9c0c14daf551d272c1a1894da84e1b3cf 100644 --- a/crates/ui/src/components/navigable.rs +++ b/crates/ui/src/components/navigable.rs @@ -75,7 +75,7 @@ impl RenderOnce for Navigable { }) .unwrap_or(0); if let Some(entry) = children.get(target) { - entry.focus_handle.focus(window); + entry.focus_handle.focus(window, cx); if let Some(anchor) = &entry.scroll_anchor { anchor.scroll_to(window, cx); } @@ -89,7 +89,7 @@ impl RenderOnce for Navigable { .and_then(|index| index.checked_sub(1)) .or(children.len().checked_sub(1)); if let Some(entry) = target.and_then(|target| children.get(target)) { - entry.focus_handle.focus(window); + entry.focus_handle.focus(window, cx); if let Some(anchor) = &entry.scroll_anchor { anchor.scroll_to(window, cx); } diff --git a/crates/ui/src/components/popover_menu.rs b/crates/ui/src/components/popover_menu.rs index 7fdb39126b5244e367a4646c6ef6df1547a8a52f..cd79e50ce01b1f4e697b252801c2ae76765726d2 100644 --- a/crates/ui/src/components/popover_menu.rs +++ b/crates/ui/src/components/popover_menu.rs @@ -281,7 +281,7 @@ fn show_menu( if modal.focus_handle(cx).contains_focused(window, cx) && let Some(previous_focus_handle) = previous_focus_handle.as_ref() { - window.focus(previous_focus_handle); + window.focus(previous_focus_handle, cx); } *menu2.borrow_mut() = None; window.refresh(); @@ -296,8 +296,8 @@ fn show_menu( // flickering when opening popover menus. let focus_handle = new_menu.focus_handle(cx); window.on_next_frame(move |window, _cx| { - window.on_next_frame(move |window, _cx| { - window.focus(&focus_handle); + window.on_next_frame(move |window, cx| { + window.focus(&focus_handle, cx); }); }); *menu.borrow_mut() = Some(new_menu); diff --git a/crates/ui/src/components/right_click_menu.rs b/crates/ui/src/components/right_click_menu.rs index 5b654c295e8c9721cd38af8b4807ba5d8e6d6cb9..faf2cb3429b610727209e13188656c174aefb655 100644 --- a/crates/ui/src/components/right_click_menu.rs +++ b/crates/ui/src/components/right_click_menu.rs @@ -253,7 +253,7 @@ impl Element for RightClickMenu { && let Some(previous_focus_handle) = previous_focus_handle.as_ref() { - window.focus(previous_focus_handle); + window.focus(previous_focus_handle, cx); } *menu2.borrow_mut() = None; window.refresh(); @@ -268,8 +268,8 @@ impl Element for RightClickMenu { // flickering when opening menus. let focus_handle = new_menu.focus_handle(cx); window.on_next_frame(move |window, _cx| { - window.on_next_frame(move |window, _cx| { - window.focus(&focus_handle); + window.on_next_frame(move |window, cx| { + window.focus(&focus_handle, cx); }); }); *menu.borrow_mut() = Some(new_menu); diff --git a/crates/ui_input/src/number_field.rs b/crates/ui_input/src/number_field.rs index ee5c57b43b7c44db1c2ded122d3d4272a541c32e..2d596a2498f445f6a0d18ce48b02bddf20aee8da 100644 --- a/crates/ui_input/src/number_field.rs +++ b/crates/ui_input/src/number_field.rs @@ -476,7 +476,7 @@ impl RenderOnce for NumberField { if let Some(previous) = previous_focus_handle.as_ref() { - window.focus(previous); + window.focus(previous, cx); } on_change(&new_value, window, cx); }; @@ -485,7 +485,7 @@ impl RenderOnce for NumberField { }) .detach(); - window.focus(&editor.focus_handle(cx)); + window.focus(&editor.focus_handle(cx), cx); editor } diff --git a/crates/workspace/src/dock.rs b/crates/workspace/src/dock.rs index edc5705a28ecd7d378c0f959ac82a6493c82d325..b358cf7b53ff16bae3756499470a2a55211618a8 100644 --- a/crates/workspace/src/dock.rs +++ b/crates/workspace/src/dock.rs @@ -350,7 +350,7 @@ impl Dock { let focus_subscription = cx.on_focus(&focus_handle, window, |dock: &mut Dock, window, cx| { if let Some(active_entry) = dock.active_panel_entry() { - active_entry.panel.panel_focus_handle(cx).focus(window) + active_entry.panel.panel_focus_handle(cx).focus(window, cx) } }); let zoom_subscription = cx.subscribe(&workspace, |dock, workspace, e: &Event, cx| { @@ -593,7 +593,7 @@ impl Dock { this.set_panel_zoomed(&panel.to_any(), true, window, cx); if !PanelHandle::panel_focus_handle(panel, cx).contains_focused(window, cx) { - window.focus(&panel.focus_handle(cx)); + window.focus(&panel.focus_handle(cx), cx); } workspace .update(cx, |workspace, cx| { @@ -625,7 +625,7 @@ impl Dock { { this.set_open(true, window, cx); this.activate_panel(ix, window, cx); - window.focus(&panel.read(cx).focus_handle(cx)); + window.focus(&panel.read(cx).focus_handle(cx), cx); } } PanelEvent::Close => { @@ -1052,7 +1052,7 @@ impl Render for PanelButtons { name = name, toggle_state = !is_open ); - window.focus(&focus_handle); + window.focus(&focus_handle, cx); window.dispatch_action(action.boxed_clone(), cx) } }) diff --git a/crates/workspace/src/item.rs b/crates/workspace/src/item.rs index bb4b10fa63dc884b8cf0ab8eee8e3bc34880b2a5..4bde632ce720dad792d19677c60ab62fd51d3637 100644 --- a/crates/workspace/src/item.rs +++ b/crates/workspace/src/item.rs @@ -1042,7 +1042,7 @@ impl ItemHandle for Entity { fn relay_action(&self, action: Box, window: &mut Window, cx: &mut App) { self.update(cx, |this, cx| { - this.focus_handle(cx).focus(window); + this.focus_handle(cx).focus(window, cx); window.dispatch_action(action, cx); }) } diff --git a/crates/workspace/src/modal_layer.rs b/crates/workspace/src/modal_layer.rs index d6f10f703100d89bef5babd4baa590df5fa0c8fd..10b24497a28faf68ed0820211f0d8860da558786 100644 --- a/crates/workspace/src/modal_layer.rs +++ b/crates/workspace/src/modal_layer.rs @@ -116,7 +116,7 @@ impl ModalLayer { focus_handle, }); cx.defer_in(window, move |_, window, cx| { - window.focus(&new_modal.focus_handle(cx)); + window.focus(&new_modal.focus_handle(cx), cx); }); cx.notify(); } @@ -144,7 +144,7 @@ impl ModalLayer { if let Some(previous_focus) = active_modal.previous_focus_handle && active_modal.focus_handle.contains_focused(window, cx) { - previous_focus.focus(window); + previous_focus.focus(window, cx); } cx.notify(); } diff --git a/crates/workspace/src/pane.rs b/crates/workspace/src/pane.rs index 036723c13755ff2a7b2b10e9684d822f239a8e0b..f6256aee46b9e2b5c29c020e9ee12f6ff510210f 100644 --- a/crates/workspace/src/pane.rs +++ b/crates/workspace/src/pane.rs @@ -625,11 +625,11 @@ impl Pane { self.last_focus_handle_by_item.get(&active_item.item_id()) && let Some(focus_handle) = weak_last_focus_handle.upgrade() { - focus_handle.focus(window); + focus_handle.focus(window, cx); return; } - active_item.item_focus_handle(cx).focus(window); + active_item.item_focus_handle(cx).focus(window, cx); } else if let Some(focused) = window.focused(cx) && !self.context_menu_focused(window, cx) { @@ -638,7 +638,7 @@ impl Pane { } } else if let Some(welcome_page) = self.welcome_page.as_ref() { if self.focus_handle.is_focused(window) { - welcome_page.read(cx).focus_handle(cx).focus(window); + welcome_page.read(cx).focus_handle(cx).focus(window, cx); } } } @@ -1999,7 +1999,7 @@ impl Pane { let should_activate = activate_pane || self.has_focus(window, cx); if self.items.len() == 1 && should_activate { - self.focus_handle.focus(window); + self.focus_handle.focus(window, cx); } else { self.activate_item( index_to_activate, @@ -2350,7 +2350,7 @@ impl Pane { pub fn focus_active_item(&mut self, window: &mut Window, cx: &mut Context) { if let Some(active_item) = self.active_item() { let focus_handle = active_item.item_focus_handle(cx); - window.focus(&focus_handle); + window.focus(&focus_handle, cx); } } diff --git a/crates/workspace/src/welcome.rs b/crates/workspace/src/welcome.rs index 93ff1ea266ff9f40b64064ea03d9bd1b91161300..4d84f3072f87ffa3246a313cbc749ddd61287d25 100644 --- a/crates/workspace/src/welcome.rs +++ b/crates/workspace/src/welcome.rs @@ -250,12 +250,12 @@ impl WelcomePage { } fn select_next(&mut self, _: &SelectNext, window: &mut Window, cx: &mut Context) { - window.focus_next(); + window.focus_next(cx); cx.notify(); } fn select_previous(&mut self, _: &SelectPrevious, window: &mut Window, cx: &mut Context) { - window.focus_prev(); + window.focus_prev(cx); cx.notify(); } diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index 516dc867ae14f7138dff0a968e210e214d0beb29..9baf2a2d6c2155f0c30221be1308d8296c0b62a0 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -1393,7 +1393,7 @@ impl Workspace { cx.on_focus_lost(window, |this, window, cx| { let focus_handle = this.focus_handle(cx); - window.focus(&focus_handle); + window.focus(&focus_handle, cx); }) .detach(); @@ -1417,7 +1417,7 @@ impl Workspace { cx.subscribe_in(¢er_pane, window, Self::handle_pane_event) .detach(); - window.focus(¢er_pane.focus_handle(cx)); + window.focus(¢er_pane.focus_handle(cx), cx); cx.emit(Event::PaneAdded(center_pane.clone())); @@ -2057,7 +2057,7 @@ impl Workspace { ) -> Task> { let to_load = if let Some(pane) = pane.upgrade() { pane.update(cx, |pane, cx| { - window.focus(&pane.focus_handle(cx)); + window.focus(&pane.focus_handle(cx), cx); loop { // Retrieve the weak item handle from the history. let entry = pane.nav_history_mut().pop(mode, cx)?; @@ -3176,7 +3176,7 @@ impl Workspace { } } else { let focus_handle = &active_panel.panel_focus_handle(cx); - window.focus(focus_handle); + window.focus(focus_handle, cx); reveal_dock = true; } } @@ -3188,7 +3188,7 @@ impl Workspace { if focus_center { self.active_pane - .update(cx, |pane, cx| window.focus(&pane.focus_handle(cx))) + .update(cx, |pane, cx| window.focus(&pane.focus_handle(cx), cx)) } cx.notify(); @@ -3356,7 +3356,7 @@ impl Workspace { if let Some(panel) = panel.as_ref() { if should_focus(&**panel, window, cx) { dock.set_open(true, window, cx); - panel.panel_focus_handle(cx).focus(window); + panel.panel_focus_handle(cx).focus(window, cx); } else { focus_center = true; } @@ -3366,7 +3366,7 @@ impl Workspace { if focus_center { self.active_pane - .update(cx, |pane, cx| window.focus(&pane.focus_handle(cx))) + .update(cx, |pane, cx| window.focus(&pane.focus_handle(cx), cx)) } result_panel = panel; @@ -3440,7 +3440,7 @@ impl Workspace { if focus_center { self.active_pane - .update(cx, |pane, cx| window.focus(&pane.focus_handle(cx))) + .update(cx, |pane, cx| window.focus(&pane.focus_handle(cx), cx)) } if self.zoomed_position != dock_to_reveal { @@ -3471,7 +3471,7 @@ impl Workspace { .detach(); self.panes.push(pane.clone()); - window.focus(&pane.focus_handle(cx)); + window.focus(&pane.focus_handle(cx), cx); cx.emit(Event::PaneAdded(pane.clone())); pane @@ -3866,7 +3866,7 @@ impl Workspace { ) { let panes = self.center.panes(); if let Some(pane) = panes.get(action.0).map(|p| (*p).clone()) { - window.focus(&pane.focus_handle(cx)); + window.focus(&pane.focus_handle(cx), cx); } else { self.split_and_clone(self.active_pane.clone(), SplitDirection::Right, window, cx) .detach(); @@ -3936,7 +3936,7 @@ impl Workspace { if let Some(ix) = panes.iter().position(|pane| **pane == self.active_pane) { let next_ix = (ix + 1) % panes.len(); let next_pane = panes[next_ix].clone(); - window.focus(&next_pane.focus_handle(cx)); + window.focus(&next_pane.focus_handle(cx), cx); } } @@ -3945,7 +3945,7 @@ impl Workspace { if let Some(ix) = panes.iter().position(|pane| **pane == self.active_pane) { let prev_ix = cmp::min(ix.wrapping_sub(1), panes.len() - 1); let prev_pane = panes[prev_ix].clone(); - window.focus(&prev_pane.focus_handle(cx)); + window.focus(&prev_pane.focus_handle(cx), cx); } } @@ -4041,7 +4041,7 @@ impl Workspace { Some(ActivateInDirectionTarget::Pane(pane)) => { let pane = pane.read(cx); if let Some(item) = pane.active_item() { - item.item_focus_handle(cx).focus(window); + item.item_focus_handle(cx).focus(window, cx); } else { log::error!( "Could not find a focus target when in switching focus in {direction} direction for a pane", @@ -4053,7 +4053,7 @@ impl Workspace { window.defer(cx, move |window, cx| { let dock = dock.read(cx); if let Some(panel) = dock.active_panel() { - panel.panel_focus_handle(cx).focus(window); + panel.panel_focus_handle(cx).focus(window, cx); } else { log::error!("Could not find a focus target when in switching focus in {direction} direction for a {:?} dock", dock.position()); } @@ -4673,7 +4673,7 @@ impl Workspace { // if you're already following, find the right pane and focus it. if let Some(follower_state) = self.follower_states.get(&leader_id) { - window.focus(&follower_state.pane().focus_handle(cx)); + window.focus(&follower_state.pane().focus_handle(cx), cx); return; } @@ -5485,12 +5485,12 @@ impl Workspace { ) { self.panes.retain(|p| p != pane); if let Some(focus_on) = focus_on { - focus_on.update(cx, |pane, cx| window.focus(&pane.focus_handle(cx))); + focus_on.update(cx, |pane, cx| window.focus(&pane.focus_handle(cx), cx)); } else if self.active_pane() == pane { self.panes .last() .unwrap() - .update(cx, |pane, cx| window.focus(&pane.focus_handle(cx))); + .update(cx, |pane, cx| window.focus(&pane.focus_handle(cx), cx)); } if self.last_active_center_pane == Some(pane.downgrade()) { self.last_active_center_pane = None; @@ -6248,7 +6248,7 @@ impl Workspace { let workspace = Self::new(Default::default(), project, app_state, window, cx); workspace .active_pane - .update(cx, |pane, cx| window.focus(&pane.focus_handle(cx))); + .update(cx, |pane, cx| window.focus(&pane.focus_handle(cx), cx)); workspace } @@ -8722,7 +8722,7 @@ fn move_all_items( // This automatically removes duplicate items in the pane to_pane.update(cx, |destination, cx| { destination.add_item(item_handle, true, true, None, window, cx); - window.focus(&destination.focus_handle(cx)) + window.focus(&destination.focus_handle(cx), cx) }); } } @@ -8766,7 +8766,7 @@ pub fn move_item( cx, ); if activate { - window.focus(&destination.focus_handle(cx)) + window.focus(&destination.focus_handle(cx), cx) } }); } diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rs index bd26812a1a3037e9d7fe0bf38c84c61143cc23e8..f527872ad8c90c4db2782fde62dcbe6a5320e4d7 100644 --- a/crates/zed/src/main.rs +++ b/crates/zed/src/main.rs @@ -819,7 +819,7 @@ fn handle_open_request(request: OpenRequest, app_state: Arc, cx: &mut workspace::get_any_active_workspace(app_state, cx.clone()).await?; workspace.update(cx, |workspace, window, cx| { if let Some(panel) = workspace.panel::(cx) { - panel.focus_handle(cx).focus(window); + panel.focus_handle(cx).focus(window, cx); } }) }) diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs index d2764c5c334ba32730982fc55e80d6197de3a2aa..f6218c97c31b98db76a2ae46b3f89876d426ac33 100644 --- a/crates/zed/src/zed.rs +++ b/crates/zed/src/zed.rs @@ -477,7 +477,7 @@ pub fn initialize_workspace( initialize_panels(prompt_builder.clone(), window, cx); register_actions(app_state.clone(), workspace, window, cx); - workspace.focus_handle(cx).focus(window); + workspace.focus_handle(cx).focus(window, cx); }) .detach(); } diff --git a/crates/zed/src/zed/component_preview.rs b/crates/zed/src/zed/component_preview.rs index 14a46d8882d1d3d371c50e9886062a124917a48d..e3c7fc8df542448d5b8b290e96405546be7b4b1e 100644 --- a/crates/zed/src/zed/component_preview.rs +++ b/crates/zed/src/zed/component_preview.rs @@ -161,7 +161,7 @@ impl ComponentPreview { component_preview.update_component_list(cx); let focus_handle = component_preview.filter_editor.read(cx).focus_handle(cx); - window.focus(&focus_handle); + window.focus(&focus_handle, cx); Ok(component_preview) } @@ -770,7 +770,7 @@ impl Item for ComponentPreview { self.workspace_id = workspace.database_id(); let focus_handle = self.filter_editor.read(cx).focus_handle(cx); - window.focus(&focus_handle); + window.focus(&focus_handle, cx); } } From ec6702aa736b54307f11f0727de1eaaef942b29a Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Wed, 17 Dec 2025 18:53:42 +0200 Subject: [PATCH 452/621] Remove global workspace trust concept (#45129) Follow-up of https://github.com/zed-industries/zed/pull/44887 Trims the worktree trust mechanism to the actual `worktree`s, so now "global", workspace-level things like `prettier`, `NodeRuntime`, `copilot` and global MCP servers are considered as "trusted" a priori. In the future, a separate mechanism for those will be considered and added. Release Notes: - N/A --- crates/agent_ui/src/agent_panel.rs | 131 +---- crates/agent_ui/src/agent_ui.rs | 10 - crates/edit_prediction_cli/src/headless.rs | 2 +- crates/eval/src/eval.rs | 2 +- crates/node_runtime/src/node_runtime.rs | 9 - crates/project/src/context_server_store.rs | 19 - crates/project/src/project.rs | 5 +- crates/project/src/trusted_worktrees.rs | 538 +------------------ crates/project_benchmarks/src/main.rs | 2 +- crates/proto/proto/worktree.proto | 6 +- crates/remote_server/src/headless_project.rs | 5 +- crates/remote_server/src/unix.rs | 4 - crates/workspace/src/persistence.rs | 30 +- crates/workspace/src/security_modal.rs | 72 +-- crates/workspace/src/workspace.rs | 13 +- crates/zed/src/main.rs | 10 +- docs/src/worktree-trust.md | 18 +- 17 files changed, 77 insertions(+), 799 deletions(-) diff --git a/crates/agent_ui/src/agent_panel.rs b/crates/agent_ui/src/agent_panel.rs index e41c8b7f5482b3709db2492f5fd81b6f3e7d6eb0..294cd8b4888950f6ea92d6bea1eba78c3d6d6de2 100644 --- a/crates/agent_ui/src/agent_panel.rs +++ b/crates/agent_ui/src/agent_panel.rs @@ -7,7 +7,6 @@ use db::kvp::{Dismissable, KEY_VALUE_STORE}; use project::{ ExternalAgentServerName, agent_server_store::{CLAUDE_CODE_NAME, CODEX_NAME, GEMINI_NAME}, - trusted_worktrees::{RemoteHostLocation, TrustedWorktrees, wait_for_workspace_trust}, }; use serde::{Deserialize, Serialize}; use settings::{ @@ -264,17 +263,6 @@ impl AgentType { Self::Custom { .. } => Some(IconName::Sparkle), } } - - fn is_mcp(&self) -> bool { - match self { - Self::NativeAgent => false, - Self::TextThread => false, - Self::Custom { .. } => false, - Self::Gemini => true, - Self::ClaudeCode => true, - Self::Codex => true, - } - } } impl From for AgentType { @@ -455,9 +443,7 @@ pub struct AgentPanel { pending_serialization: Option>>, onboarding: Entity, selected_agent: AgentType, - new_agent_thread_task: Task<()>, show_trust_workspace_message: bool, - _worktree_trust_subscription: Option, } impl AgentPanel { @@ -681,48 +667,6 @@ impl AgentPanel { None }; - let mut show_trust_workspace_message = false; - let worktree_trust_subscription = - TrustedWorktrees::try_get_global(cx).and_then(|trusted_worktrees| { - let has_global_trust = trusted_worktrees.update(cx, |trusted_worktrees, cx| { - trusted_worktrees.can_trust_workspace( - project - .read(cx) - .remote_connection_options(cx) - .map(RemoteHostLocation::from), - cx, - ) - }); - if has_global_trust { - None - } else { - show_trust_workspace_message = true; - let project = project.clone(); - Some(cx.subscribe( - &trusted_worktrees, - move |agent_panel, trusted_worktrees, _, cx| { - let new_show_trust_workspace_message = - !trusted_worktrees.update(cx, |trusted_worktrees, cx| { - trusted_worktrees.can_trust_workspace( - project - .read(cx) - .remote_connection_options(cx) - .map(RemoteHostLocation::from), - cx, - ) - }); - if new_show_trust_workspace_message - != agent_panel.show_trust_workspace_message - { - agent_panel.show_trust_workspace_message = - new_show_trust_workspace_message; - cx.notify(); - }; - }, - )) - } - }); - let mut panel = Self { active_view, workspace, @@ -745,14 +689,12 @@ impl AgentPanel { height: None, zoomed: false, pending_serialization: None, - new_agent_thread_task: Task::ready(()), onboarding, acp_history, history_store, selected_agent: AgentType::default(), loading: false, - show_trust_workspace_message, - _worktree_trust_subscription: worktree_trust_subscription, + show_trust_workspace_message: false, }; // Initial sync of agent servers from extensions @@ -945,47 +887,6 @@ impl AgentPanel { } }; - if ext_agent.is_mcp() { - let wait_task = this.update(cx, |agent_panel, cx| { - agent_panel.project.update(cx, |project, cx| { - wait_for_workspace_trust( - project.remote_connection_options(cx), - "context servers", - cx, - ) - }) - })?; - if let Some(wait_task) = wait_task { - this.update_in(cx, |agent_panel, window, cx| { - agent_panel.show_trust_workspace_message = true; - cx.notify(); - agent_panel.new_agent_thread_task = - cx.spawn_in(window, async move |agent_panel, cx| { - wait_task.await; - let server = ext_agent.server(fs, history); - agent_panel - .update_in(cx, |agent_panel, window, cx| { - agent_panel.show_trust_workspace_message = false; - cx.notify(); - agent_panel._external_thread( - server, - resume_thread, - summarize_thread, - workspace, - project, - loading, - ext_agent, - window, - cx, - ); - }) - .ok(); - }); - })?; - return Ok(()); - } - } - let server = ext_agent.server(fs, history); this.update_in(cx, |agent_panel, window, cx| { agent_panel._external_thread( @@ -1510,36 +1411,6 @@ impl AgentPanel { window: &mut Window, cx: &mut Context, ) { - let wait_task = if agent.is_mcp() { - self.project.update(cx, |project, cx| { - wait_for_workspace_trust( - project.remote_connection_options(cx), - "context servers", - cx, - ) - }) - } else { - None - }; - if let Some(wait_task) = wait_task { - self.show_trust_workspace_message = true; - cx.notify(); - self.new_agent_thread_task = cx.spawn_in(window, async move |agent_panel, cx| { - wait_task.await; - agent_panel - .update_in(cx, |agent_panel, window, cx| { - agent_panel.show_trust_workspace_message = false; - cx.notify(); - agent_panel._new_agent_thread(agent, window, cx); - }) - .ok(); - }); - } else { - self._new_agent_thread(agent, window, cx); - } - } - - fn _new_agent_thread(&mut self, agent: AgentType, window: &mut Window, cx: &mut Context) { match agent { AgentType::TextThread => { window.dispatch_action(NewTextThread.boxed_clone(), cx); diff --git a/crates/agent_ui/src/agent_ui.rs b/crates/agent_ui/src/agent_ui.rs index c80c7b43644ab949e748609435e33dfe9f31d54e..02cb7e59948b10274302bd8cd6f74f1accbd30a3 100644 --- a/crates/agent_ui/src/agent_ui.rs +++ b/crates/agent_ui/src/agent_ui.rs @@ -174,16 +174,6 @@ impl ExternalAgent { Self::Custom { name } => Rc::new(agent_servers::CustomAgentServer::new(name.clone())), } } - - pub fn is_mcp(&self) -> bool { - match self { - Self::Gemini => true, - Self::ClaudeCode => true, - Self::Codex => true, - Self::NativeAgent => false, - Self::Custom { .. } => false, - } - } } /// Opens the profile management interface for configuring agent tools and settings. diff --git a/crates/edit_prediction_cli/src/headless.rs b/crates/edit_prediction_cli/src/headless.rs index 489e78d364d0fdbb08b93eab89fd5f91f345f68e..da96e7ef6520e952e2b7696eee6b82c243e90e4e 100644 --- a/crates/edit_prediction_cli/src/headless.rs +++ b/crates/edit_prediction_cli/src/headless.rs @@ -114,7 +114,7 @@ pub fn init(cx: &mut App) -> EpAppState { tx.send(Some(options)).log_err(); }) .detach(); - let node_runtime = NodeRuntime::new(client.http_client(), None, rx, None); + let node_runtime = NodeRuntime::new(client.http_client(), None, rx); let extension_host_proxy = ExtensionHostProxy::global(cx); diff --git a/crates/eval/src/eval.rs b/crates/eval/src/eval.rs index 3a2891922c80b95c85f0daed25603bea14b41842..80633696b7d5e655bb7db3627568b881642cf62c 100644 --- a/crates/eval/src/eval.rs +++ b/crates/eval/src/eval.rs @@ -422,7 +422,7 @@ pub fn init(cx: &mut App) -> Arc { tx.send(Some(options)).log_err(); }) .detach(); - let node_runtime = NodeRuntime::new(client.http_client(), None, rx, None); + let node_runtime = NodeRuntime::new(client.http_client(), None, rx); let extension_host_proxy = ExtensionHostProxy::global(cx); debug_adapter_extension::init(extension_host_proxy.clone(), cx); diff --git a/crates/node_runtime/src/node_runtime.rs b/crates/node_runtime/src/node_runtime.rs index 5e4297988b665c3b89771838ef629ee87e88fb5b..eb8a5b45797baf7329554cb0b8d4a4f67a1f6579 100644 --- a/crates/node_runtime/src/node_runtime.rs +++ b/crates/node_runtime/src/node_runtime.rs @@ -9,8 +9,6 @@ use serde::Deserialize; use smol::io::BufReader; use smol::{fs, lock::Mutex}; use std::fmt::Display; -use std::future::Future; -use std::pin::Pin; use std::{ env::{self, consts}, ffi::OsString, @@ -48,7 +46,6 @@ struct NodeRuntimeState { last_options: Option, options: watch::Receiver>, shell_env_loaded: Shared>, - trust_task: Option + Send>>>, } impl NodeRuntime { @@ -56,11 +53,9 @@ impl NodeRuntime { http: Arc, shell_env_loaded: Option>, options: watch::Receiver>, - trust_task: Option + Send>>>, ) -> Self { NodeRuntime(Arc::new(Mutex::new(NodeRuntimeState { http, - trust_task, instance: None, last_options: None, options, @@ -75,15 +70,11 @@ impl NodeRuntime { last_options: None, options: watch::channel(Some(NodeBinaryOptions::default())).1, shell_env_loaded: oneshot::channel().1.shared(), - trust_task: None, }))) } async fn instance(&self) -> Box { let mut state = self.0.lock().await; - if let Some(trust_task) = state.trust_task.take() { - trust_task.await; - } let options = loop { if let Some(options) = state.options.borrow().as_ref() { diff --git a/crates/project/src/context_server_store.rs b/crates/project/src/context_server_store.rs index 7d060db887b1b5d07dd4d6de9ca85297adfd0c6f..7ba46a46872ba57c758baccf9f67b0039818ee75 100644 --- a/crates/project/src/context_server_store.rs +++ b/crates/project/src/context_server_store.rs @@ -15,7 +15,6 @@ use util::{ResultExt as _, rel_path::RelPath}; use crate::{ Project, project_settings::{ContextServerSettings, ProjectSettings}, - trusted_worktrees::wait_for_workspace_trust, worktree_store::WorktreeStore, }; @@ -333,15 +332,6 @@ impl ContextServerStore { pub fn start_server(&mut self, server: Arc, cx: &mut Context) { cx.spawn(async move |this, cx| { - let wait_task = this.update(cx, |context_server_store, cx| { - context_server_store.project.update(cx, |project, cx| { - let remote_host = project.remote_connection_options(cx); - wait_for_workspace_trust(remote_host, "context servers", cx) - }) - })??; - if let Some(wait_task) = wait_task { - wait_task.await; - } let this = this.upgrade().context("Context server store dropped")?; let settings = this .update(cx, |this, _| { @@ -582,15 +572,6 @@ impl ContextServerStore { } async fn maintain_servers(this: WeakEntity, cx: &mut AsyncApp) -> Result<()> { - let wait_task = this.update(cx, |context_server_store, cx| { - context_server_store.project.update(cx, |project, cx| { - let remote_host = project.remote_connection_options(cx); - wait_for_workspace_trust(remote_host, "context servers", cx) - }) - })??; - if let Some(wait_task) = wait_task { - wait_task.await; - } let (mut configured_servers, registry, worktree_store) = this.update(cx, |this, _| { ( this.context_server_settings.clone(), diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index b348fcdae2c414aa1b3f34f616ca3426899fe1d3..8b57413b22ac95a16e35a95d70a04b3ae49d4b31 100644 --- a/crates/project/src/project.rs +++ b/crates/project/src/project.rs @@ -4895,16 +4895,13 @@ impl Project { .update(|cx| TrustedWorktrees::try_get_global(cx))? .context("missing trusted worktrees")?; trusted_worktrees.update(&mut cx, |trusted_worktrees, cx| { - let mut restricted_paths = envelope + let restricted_paths = envelope .payload .worktree_ids .into_iter() .map(WorktreeId::from_proto) .map(PathTrust::Worktree) .collect::>(); - if envelope.payload.restrict_workspace { - restricted_paths.insert(PathTrust::Workspace); - } let remote_host = this .read(cx) .remote_connection_options(cx) diff --git a/crates/project/src/trusted_worktrees.rs b/crates/project/src/trusted_worktrees.rs index 9f849ceaf1db62c1a88e269565e95bc97bc56011..0e1a8b4011bf56b150fe99a502eece905dcc9d78 100644 --- a/crates/project/src/trusted_worktrees.rs +++ b/crates/project/src/trusted_worktrees.rs @@ -27,36 +27,20 @@ //! Spawning a language server is potentially dangerous, and Zed needs to restrict that by default. //! Each single file worktree requires a separate trust permission, unless a more global level is trusted. //! -//! * "workspace" -//! -//! Even an empty Zed instance with no files or directories open is potentially dangerous: opening an Assistant Panel and creating new external agent thread might require installing and running MCP servers. -//! -//! Disabling the entire panel is possible with ai-related settings. -//! Yet when it's enabled, it's still reasonably safe to use remote AI agents and control their permissions in the Assistant Panel. -//! -//! Unlike that, MCP servers are similar to language servers and may require fetching, installing and running packages or binaries. -//! Given that those servers are not tied to any particular worktree, this level of trust is required to operate any MCP server. -//! -//! Workspace level of trust assumes all single file worktrees are trusted too, for the same host: if we allow global MCP server-related functionality, we can already allow spawning language servers for single file worktrees as well. -//! //! * "directory worktree" //! //! If a directory is open in Zed, it's a full worktree which may spawn multiple language servers associated with it. //! Each such worktree requires a separate trust permission, so each separate directory worktree has to be trusted separately, unless a more global level is trusted. //! -//! When a directory worktree is trusted and language servers are allowed to be downloaded and started, hence we also allow workspace level of trust (hence, "single file worktree" level of trust also). +//! When a directory worktree is trusted and language servers are allowed to be downloaded and started, hence, "single file worktree" level of trust also. //! //! * "path override" //! //! To ease trusting multiple directory worktrees at once, it's possible to trust a parent directory of a certain directory worktree opened in Zed. //! Trusting a directory means trusting all its subdirectories as well, including all current and potential directory worktrees. -//! -//! If we trust multiple projects to install and spawn various language server processes, we can also allow workspace trust requests for MCP servers installation and spawning. use collections::{HashMap, HashSet}; -use gpui::{ - App, AppContext as _, Context, Entity, EventEmitter, Global, SharedString, Task, WeakEntity, -}; +use gpui::{App, AppContext as _, Context, Entity, EventEmitter, Global, SharedString, WeakEntity}; use remote::RemoteConnectionOptions; use rpc::{AnyProtoClient, proto}; use settings::{Settings as _, WorktreeId}; @@ -132,57 +116,6 @@ pub fn track_worktree_trust( } } -/// Waits until at least [`PathTrust::Workspace`] level of trust is granted for the host the [`TrustedWorktrees`] was initialized with. -pub fn wait_for_default_workspace_trust( - what_waits: &'static str, - cx: &mut App, -) -> Option> { - let trusted_worktrees = TrustedWorktrees::try_get_global(cx)?; - wait_for_workspace_trust( - trusted_worktrees.read(cx).remote_host.clone(), - what_waits, - cx, - ) -} - -/// Waits until at least [`PathTrust::Workspace`] level of trust is granted for a particular host. -pub fn wait_for_workspace_trust( - remote_host: Option>, - what_waits: &'static str, - cx: &mut App, -) -> Option> { - let trusted_worktrees = TrustedWorktrees::try_get_global(cx)?; - let remote_host = remote_host.map(|host| host.into()); - - let remote_host = if trusted_worktrees.update(cx, |trusted_worktrees, cx| { - trusted_worktrees.can_trust_workspace(remote_host.clone(), cx) - }) { - None - } else { - Some(remote_host) - }?; - - Some(cx.spawn(async move |cx| { - log::info!("Waiting for workspace to be trusted before starting {what_waits}"); - let (tx, restricted_worktrees_task) = smol::channel::bounded::<()>(1); - let Ok(_subscription) = cx.update(|cx| { - cx.subscribe(&trusted_worktrees, move |_, e, _| { - if let TrustedWorktreesEvent::Trusted(trusted_host, trusted_paths) = e { - if trusted_host == &remote_host && trusted_paths.contains(&PathTrust::Workspace) - { - log::info!("Workspace is trusted for {what_waits}"); - tx.send_blocking(()).ok(); - } - } - }) - }) else { - return; - }; - - restricted_worktrees_task.recv().await.ok(); - })) -} - /// A collection of worktree trust metadata, can be accessed globally (if initialized) and subscribed to. pub struct TrustedWorktrees(Entity); @@ -205,8 +138,6 @@ pub struct TrustedWorktreesStore { worktree_stores: HashMap, Option>, trusted_paths: TrustedPaths, restricted: HashSet, - remote_host: Option, - restricted_workspaces: HashSet>, } /// An identifier of a host to split the trust questions by. @@ -246,9 +177,6 @@ impl From for RemoteHostLocation { /// See module-level documentation on the trust model. #[derive(Debug, PartialEq, Eq, Clone, Hash)] pub enum PathTrust { - /// General, no worktrees or files open case. - /// E.g. MCP servers can be spawned from a blank Zed instance, but will do `npm i` and other potentially malicious actions. - Workspace, /// A worktree that is familiar to this workspace. /// Either a single file or a directory worktree. Worktree(WorktreeId), @@ -260,9 +188,6 @@ pub enum PathTrust { impl PathTrust { fn to_proto(&self) -> proto::PathTrust { match self { - Self::Workspace => proto::PathTrust { - content: Some(proto::path_trust::Content::Workspace(0)), - }, Self::Worktree(worktree_id) => proto::PathTrust { content: Some(proto::path_trust::Content::WorktreeId( worktree_id.to_proto(), @@ -282,7 +207,6 @@ impl PathTrust { Self::Worktree(WorktreeId::from_proto(id)) } proto::path_trust::Content::AbsPath(path) => Self::AbsPath(PathBuf::from(path)), - proto::path_trust::Content::Workspace(_) => Self::Workspace, }) } } @@ -322,9 +246,7 @@ impl TrustedWorktreesStore { } let worktree_stores = match worktree_store { - Some(worktree_store) => { - HashMap::from_iter([(worktree_store.downgrade(), remote_host.clone())]) - } + Some(worktree_store) => HashMap::from_iter([(worktree_store.downgrade(), remote_host)]), None => HashMap::default(), }; @@ -332,8 +254,6 @@ impl TrustedWorktreesStore { trusted_paths, downstream_client, upstream_client, - remote_host, - restricted_workspaces: HashSet::default(), restricted: HashSet::default(), worktree_stores, } @@ -345,11 +265,9 @@ impl TrustedWorktreesStore { worktree_store: &Entity, cx: &App, ) -> bool { - let Some(remote_host) = self.worktree_stores.get(&worktree_store.downgrade()) else { - return false; - }; - self.restricted_workspaces.contains(remote_host) - || self.restricted.iter().any(|restricted_worktree| { + self.worktree_stores + .contains_key(&worktree_store.downgrade()) + && self.restricted.iter().any(|restricted_worktree| { worktree_store .read(cx) .worktree_for_id(*restricted_worktree, cx) @@ -366,7 +284,6 @@ impl TrustedWorktreesStore { remote_host: Option, cx: &mut Context, ) { - let mut new_workspace_trusted = false; let mut new_trusted_single_file_worktrees = HashSet::default(); let mut new_trusted_other_worktrees = HashSet::default(); let mut new_trusted_abs_paths = HashSet::default(); @@ -377,7 +294,6 @@ impl TrustedWorktreesStore { .flat_map(|current_trusted| current_trusted.iter()), ) { match trusted_path { - PathTrust::Workspace => new_workspace_trusted = true, PathTrust::Worktree(worktree_id) => { self.restricted.remove(worktree_id); if let Some((abs_path, is_file, host)) = @@ -388,13 +304,11 @@ impl TrustedWorktreesStore { new_trusted_single_file_worktrees.insert(*worktree_id); } else { new_trusted_other_worktrees.insert((abs_path, *worktree_id)); - new_workspace_trusted = true; } } } } PathTrust::AbsPath(path) => { - new_workspace_trusted = true; debug_assert!( path.is_absolute(), "Cannot trust non-absolute path {path:?}" @@ -404,11 +318,6 @@ impl TrustedWorktreesStore { } } - if new_workspace_trusted { - new_trusted_single_file_worktrees.clear(); - self.restricted_workspaces.remove(&remote_host); - trusted_paths.insert(PathTrust::Workspace); - } new_trusted_other_worktrees.retain(|(worktree_abs_path, _)| { new_trusted_abs_paths .iter() @@ -428,8 +337,7 @@ impl TrustedWorktreesStore { if restricted_host != remote_host { return true; } - let retain = (!is_file - || (!new_workspace_trusted && new_trusted_other_worktrees.is_empty())) + let retain = (!is_file || new_trusted_other_worktrees.is_empty()) && new_trusted_abs_paths.iter().all(|new_trusted_path| { !restricted_worktree_path.starts_with(new_trusted_path) }); @@ -453,9 +361,6 @@ impl TrustedWorktreesStore { .into_iter() .map(PathTrust::Worktree), ); - if trusted_paths.is_empty() && new_workspace_trusted { - trusted_paths.insert(PathTrust::Workspace); - } } cx.emit(TrustedWorktreesEvent::Trusted( @@ -489,13 +394,6 @@ impl TrustedWorktreesStore { ) { for restricted_path in restricted_paths { match restricted_path { - PathTrust::Workspace => { - self.restricted_workspaces.insert(remote_host.clone()); - cx.emit(TrustedWorktreesEvent::Restricted( - remote_host.clone(), - HashSet::from_iter([PathTrust::Workspace]), - )); - } PathTrust::Worktree(worktree_id) => { self.restricted.insert(worktree_id); cx.emit(TrustedWorktreesEvent::Restricted( @@ -568,7 +466,6 @@ impl TrustedWorktreesStore { downstream_client .send(proto::RestrictWorktrees { project_id: *downstream_project_id, - restrict_workspace: false, worktree_ids: vec![worktree_id.to_proto()], }) .ok(); @@ -577,7 +474,6 @@ impl TrustedWorktreesStore { upstream_client .send(proto::RestrictWorktrees { project_id: *upstream_project_id, - restrict_workspace: false, worktree_ids: vec![worktree_id.to_proto()], }) .ok(); @@ -585,61 +481,12 @@ impl TrustedWorktreesStore { false } - /// Checks whether a certain worktree is trusted globally (or on a larger trust level). - /// If not, emits [`TrustedWorktreesEvent::Restricted`] event if checked for the first time and not trusted. - /// - /// No events or data adjustment happens when `trust_all_worktrees` auto trust is enabled. - pub fn can_trust_workspace( - &mut self, - remote_host: Option, - cx: &mut Context, - ) -> bool { - if ProjectSettings::get_global(cx).session.trust_all_worktrees { - return true; - } - if self.restricted_workspaces.contains(&remote_host) { - return false; - } - if self.trusted_paths.contains_key(&remote_host) { - return true; - } - - self.restricted_workspaces.insert(remote_host.clone()); - cx.emit(TrustedWorktreesEvent::Restricted( - remote_host.clone(), - HashSet::from_iter([PathTrust::Workspace]), - )); - - if remote_host == self.remote_host { - if let Some((downstream_client, downstream_project_id)) = &self.downstream_client { - downstream_client - .send(proto::RestrictWorktrees { - project_id: *downstream_project_id, - restrict_workspace: true, - worktree_ids: Vec::new(), - }) - .ok(); - } - if let Some((upstream_client, upstream_project_id)) = &self.upstream_client { - upstream_client - .send(proto::RestrictWorktrees { - project_id: *upstream_project_id, - restrict_workspace: true, - worktree_ids: Vec::new(), - }) - .ok(); - } - } - false - } - - /// Lists all explicitly restricted worktrees (via [`TrustedWorktreesStore::can_trust`] and [`TrustedWorktreesStore::can_trust_workspace`] method calls) for a particular worktree store on a particular host. + /// Lists all explicitly restricted worktrees (via [`TrustedWorktreesStore::can_trust`] method calls) for a particular worktree store on a particular host. pub fn restricted_worktrees( &self, worktree_store: &WorktreeStore, - remote_host: Option, cx: &App, - ) -> HashSet)>> { + ) -> HashSet<(WorktreeId, Arc)> { let mut single_file_paths = HashSet::default(); let other_paths = self .restricted @@ -649,19 +496,16 @@ impl TrustedWorktreesStore { let worktree = worktree.read(cx); let abs_path = worktree.abs_path(); if worktree.is_single_file() { - single_file_paths.insert(Some((restricted_worktree_id, abs_path))); + single_file_paths.insert((restricted_worktree_id, abs_path)); None } else { Some((restricted_worktree_id, abs_path)) } }) - .map(Some) .collect::>(); if !other_paths.is_empty() { return other_paths; - } else if self.restricted_workspaces.contains(&remote_host) { - return HashSet::from_iter([None]); } else { single_file_paths } @@ -670,7 +514,7 @@ impl TrustedWorktreesStore { /// Switches the "trust nothing" mode to "automatically trust everything". /// This does not influence already persisted data, but stops adding new worktrees there. pub fn auto_trust_all(&mut self, cx: &mut Context) { - for (remote_host, mut worktrees) in std::mem::take(&mut self.restricted) + for (remote_host, worktrees) in std::mem::take(&mut self.restricted) .into_iter() .flat_map(|restricted_worktree| { let (_, _, host) = self.find_worktree_data(restricted_worktree, cx)?; @@ -683,26 +527,15 @@ impl TrustedWorktreesStore { acc }) { - if self.restricted_workspaces.remove(&remote_host) { - worktrees.insert(PathTrust::Workspace); - } self.trust(worktrees, remote_host, cx); } - - for remote_host in std::mem::take(&mut self.restricted_workspaces) { - self.trust(HashSet::from_iter([PathTrust::Workspace]), remote_host, cx); - } } /// Returns a normalized representation of the trusted paths to store in the DB. pub fn trusted_paths_for_serialization( &mut self, cx: &mut Context, - ) -> ( - HashSet>, - HashMap, HashSet>, - ) { - let mut new_trusted_workspaces = HashSet::default(); + ) -> HashMap, HashSet> { let new_trusted_worktrees = self .trusted_paths .clone() @@ -715,16 +548,12 @@ impl TrustedWorktreesStore { .find_worktree_data(worktree_id, cx) .map(|(abs_path, ..)| abs_path.to_path_buf()), PathTrust::AbsPath(abs_path) => Some(abs_path), - PathTrust::Workspace => { - new_trusted_workspaces.insert(host.clone()); - None - } }) .collect(); (host, abs_paths) }) .collect(); - (new_trusted_workspaces, new_trusted_worktrees) + new_trusted_worktrees } fn find_worktree_data( @@ -888,15 +717,9 @@ mod tests { assert!(has_restricted, "should have restricted worktrees"); let restricted = worktree_store.read_with(cx, |ws, cx| { - trusted_worktrees - .read(cx) - .restricted_worktrees(ws, None, cx) + trusted_worktrees.read(cx).restricted_worktrees(ws, cx) }); - assert!( - restricted - .iter() - .any(|r| r.as_ref().map(|(id, _)| *id) == Some(worktree_id)) - ); + assert!(restricted.iter().any(|(id, _)| *id == worktree_id)); events.borrow_mut().clear(); @@ -941,9 +764,7 @@ mod tests { ); let restricted_after = worktree_store.read_with(cx, |ws, cx| { - trusted_worktrees - .read(cx) - .restricted_worktrees(ws, None, cx) + trusted_worktrees.read(cx).restricted_worktrees(ws, cx) }); assert!( restricted_after.is_empty(), @@ -951,92 +772,6 @@ mod tests { ); } - #[gpui::test] - async fn test_workspace_trust_no_worktrees(cx: &mut TestAppContext) { - init_test(cx); - - let fs = FakeFs::new(cx.executor()); - fs.insert_tree(path!("/root"), json!({})).await; - - let project = Project::test(fs, Vec::<&Path>::new(), cx).await; - let worktree_store = project.read_with(cx, |project, _| project.worktree_store()); - - let trusted_worktrees = init_trust_global(worktree_store, cx); - - let events: Rc>> = Rc::default(); - cx.update({ - let events = events.clone(); - |cx| { - cx.subscribe(&trusted_worktrees, move |_, event, _| { - events.borrow_mut().push(match event { - TrustedWorktreesEvent::Trusted(host, paths) => { - TrustedWorktreesEvent::Trusted(host.clone(), paths.clone()) - } - TrustedWorktreesEvent::Restricted(host, paths) => { - TrustedWorktreesEvent::Restricted(host.clone(), paths.clone()) - } - }); - }) - } - }) - .detach(); - - let can_trust_workspace = - trusted_worktrees.update(cx, |store, cx| store.can_trust_workspace(None, cx)); - assert!( - !can_trust_workspace, - "workspace should be restricted by default" - ); - - { - let events = events.borrow(); - assert_eq!(events.len(), 1); - match &events[0] { - TrustedWorktreesEvent::Restricted(host, paths) => { - assert!(host.is_none()); - assert!(paths.contains(&PathTrust::Workspace)); - } - _ => panic!("expected Restricted event"), - } - } - - events.borrow_mut().clear(); - - let can_trust_workspace_again = - trusted_worktrees.update(cx, |store, cx| store.can_trust_workspace(None, cx)); - assert!( - !can_trust_workspace_again, - "workspace should still be restricted" - ); - assert!( - events.borrow().is_empty(), - "no duplicate Restricted event on repeated can_trust_workspace" - ); - - trusted_worktrees.update(cx, |store, cx| { - store.trust(HashSet::from_iter([PathTrust::Workspace]), None, cx); - }); - - { - let events = events.borrow(); - assert_eq!(events.len(), 1); - match &events[0] { - TrustedWorktreesEvent::Trusted(host, paths) => { - assert!(host.is_none()); - assert!(paths.contains(&PathTrust::Workspace)); - } - _ => panic!("expected Trusted event"), - } - } - - let can_trust_workspace_after = - trusted_worktrees.update(cx, |store, cx| store.can_trust_workspace(None, cx)); - assert!( - can_trust_workspace_after, - "workspace should be trusted after trust()" - ); - } - #[gpui::test] async fn test_single_file_worktree_trust(cx: &mut TestAppContext) { init_test(cx); @@ -1122,58 +857,6 @@ mod tests { ); } - #[gpui::test] - async fn test_workspace_trust_unlocks_single_file_worktree(cx: &mut TestAppContext) { - init_test(cx); - - let fs = FakeFs::new(cx.executor()); - fs.insert_tree(path!("/root"), json!({ "foo.rs": "fn foo() {}" })) - .await; - - let project = Project::test(fs, [path!("/root/foo.rs").as_ref()], cx).await; - let worktree_store = project.read_with(cx, |project, _| project.worktree_store()); - let worktree_id = worktree_store.read_with(cx, |store, cx| { - let worktree = store.worktrees().next().unwrap(); - let worktree = worktree.read(cx); - assert!(worktree.is_single_file(), "expected single-file worktree"); - worktree.id() - }); - - let trusted_worktrees = init_trust_global(worktree_store, cx); - - let can_trust_workspace = - trusted_worktrees.update(cx, |store, cx| store.can_trust_workspace(None, cx)); - assert!( - !can_trust_workspace, - "workspace should be restricted by default" - ); - - let can_trust_file = - trusted_worktrees.update(cx, |store, cx| store.can_trust(worktree_id, cx)); - assert!( - !can_trust_file, - "single-file worktree should be restricted by default" - ); - - trusted_worktrees.update(cx, |store, cx| { - store.trust(HashSet::from_iter([PathTrust::Workspace]), None, cx); - }); - - let can_trust_workspace_after = - trusted_worktrees.update(cx, |store, cx| store.can_trust_workspace(None, cx)); - assert!( - can_trust_workspace_after, - "workspace should be trusted after trust(Workspace)" - ); - - let can_trust_file_after = - trusted_worktrees.update(cx, |store, cx| store.can_trust(worktree_id, cx)); - assert!( - can_trust_file_after, - "single-file worktree should be trusted after workspace trust" - ); - } - #[gpui::test] async fn test_multiple_single_file_worktrees_trust_one(cx: &mut TestAppContext) { init_test(cx); @@ -1319,47 +1002,6 @@ mod tests { assert!(can_trust_b, "project_b should now be trusted"); } - #[gpui::test] - async fn test_directory_worktree_trust_enables_workspace(cx: &mut TestAppContext) { - init_test(cx); - - let fs = FakeFs::new(cx.executor()); - fs.insert_tree(path!("/root"), json!({ "main.rs": "fn main() {}" })) - .await; - - let project = Project::test(fs, [path!("/root").as_ref()], cx).await; - let worktree_store = project.read_with(cx, |project, _| project.worktree_store()); - let worktree_id = worktree_store.read_with(cx, |store, cx| { - let worktree = store.worktrees().next().unwrap(); - assert!(!worktree.read(cx).is_single_file()); - worktree.read(cx).id() - }); - - let trusted_worktrees = init_trust_global(worktree_store, cx); - - let can_trust_workspace = - trusted_worktrees.update(cx, |store, cx| store.can_trust_workspace(None, cx)); - assert!( - !can_trust_workspace, - "workspace should be restricted initially" - ); - - trusted_worktrees.update(cx, |store, cx| { - store.trust( - HashSet::from_iter([PathTrust::Worktree(worktree_id)]), - None, - cx, - ); - }); - - let can_trust_workspace_after = - trusted_worktrees.update(cx, |store, cx| store.can_trust_workspace(None, cx)); - assert!( - can_trust_workspace_after, - "workspace should be trusted after trusting directory worktree" - ); - } - #[gpui::test] async fn test_directory_worktree_trust_enables_single_file(cx: &mut TestAppContext) { init_test(cx); @@ -1428,7 +1070,7 @@ mod tests { let fs = FakeFs::new(cx.executor()); fs.insert_tree( - path!("/workspace"), + path!("/root"), json!({ "project_a": { "main.rs": "fn main() {}" }, "project_b": { "lib.rs": "pub fn lib() {}" } @@ -1439,8 +1081,8 @@ mod tests { let project = Project::test( fs, [ - path!("/workspace/project_a").as_ref(), - path!("/workspace/project_b").as_ref(), + path!("/root/project_a").as_ref(), + path!("/root/project_b").as_ref(), ], cx, ) @@ -1464,7 +1106,7 @@ mod tests { trusted_worktrees.update(cx, |store, cx| { store.trust( - HashSet::from_iter([PathTrust::AbsPath(PathBuf::from(path!("/workspace")))]), + HashSet::from_iter([PathTrust::AbsPath(PathBuf::from(path!("/root")))]), None, cx, ); @@ -1539,12 +1181,6 @@ mod tests { trusted_worktrees.update(cx, |store, cx| store.can_trust(worktree_id, cx)); assert!(!can_trust, "worktree should be restricted initially"); } - let can_trust_workspace = - trusted_worktrees.update(cx, |store, cx| store.can_trust_workspace(None, cx)); - assert!( - !can_trust_workspace, - "workspace should be restricted initially" - ); let has_restricted = trusted_worktrees.read_with(cx, |store, cx| { store.has_restricted_worktrees(&worktree_store, cx) @@ -1566,13 +1202,6 @@ mod tests { ); } - let can_trust_workspace = - trusted_worktrees.update(cx, |store, cx| store.can_trust_workspace(None, cx)); - assert!( - can_trust_workspace, - "workspace should be trusted after auto_trust_all" - ); - let has_restricted_after = trusted_worktrees.read_with(cx, |store, cx| { store.has_restricted_worktrees(&worktree_store, cx) }); @@ -1592,100 +1221,6 @@ mod tests { ); } - #[gpui::test] - async fn test_wait_for_global_trust_already_trusted(cx: &mut TestAppContext) { - init_test(cx); - - let fs = FakeFs::new(cx.executor()); - fs.insert_tree(path!("/root"), json!({ "main.rs": "fn main() {}" })) - .await; - - let project = Project::test(fs, [path!("/root").as_ref()], cx).await; - let worktree_store = project.read_with(cx, |project, _| project.worktree_store()); - - let trusted_worktrees = init_trust_global(worktree_store, cx); - - trusted_worktrees.update(cx, |store, cx| { - store.trust(HashSet::from_iter([PathTrust::Workspace]), None, cx); - }); - - let task = cx.update(|cx| wait_for_workspace_trust(None::, "test", cx)); - assert!(task.is_none(), "should return None when already trusted"); - } - - #[gpui::test] - async fn test_wait_for_workspace_trust_resolves_on_trust(cx: &mut TestAppContext) { - init_test(cx); - - let fs = FakeFs::new(cx.executor()); - fs.insert_tree(path!("/root"), json!({ "main.rs": "fn main() {}" })) - .await; - - let project = Project::test(fs, [path!("/root").as_ref()], cx).await; - let worktree_store = project.read_with(cx, |project, _| project.worktree_store()); - - let trusted_worktrees = init_trust_global(worktree_store, cx); - - let task = cx.update(|cx| wait_for_workspace_trust(None::, "test", cx)); - assert!( - task.is_some(), - "should return Some(Task) when not yet trusted" - ); - - let task = task.unwrap(); - - cx.executor().run_until_parked(); - - trusted_worktrees.update(cx, |store, cx| { - store.trust(HashSet::from_iter([PathTrust::Workspace]), None, cx); - }); - - cx.executor().run_until_parked(); - task.await; - } - - #[gpui::test] - async fn test_wait_for_default_workspace_trust_resolves_on_directory_worktree_trust( - cx: &mut TestAppContext, - ) { - init_test(cx); - - let fs = FakeFs::new(cx.executor()); - fs.insert_tree(path!("/root"), json!({ "main.rs": "fn main() {}" })) - .await; - - let project = Project::test(fs, [path!("/root").as_ref()], cx).await; - let worktree_store = project.read_with(cx, |project, _| project.worktree_store()); - let worktree_id = worktree_store.read_with(cx, |store, cx| { - let worktree = store.worktrees().next().unwrap(); - assert!(!worktree.read(cx).is_single_file()); - worktree.read(cx).id() - }); - - let trusted_worktrees = init_trust_global(worktree_store, cx); - - let task = cx.update(|cx| wait_for_default_workspace_trust("test", cx)); - assert!( - task.is_some(), - "should return Some(Task) when not yet trusted" - ); - - let task = task.unwrap(); - - cx.executor().run_until_parked(); - - trusted_worktrees.update(cx, |store, cx| { - store.trust( - HashSet::from_iter([PathTrust::Worktree(worktree_id)]), - None, - cx, - ); - }); - - cx.executor().run_until_parked(); - task.await; - } - #[gpui::test] async fn test_trust_restrict_trust_cycle(cx: &mut TestAppContext) { init_test(cx); @@ -1820,36 +1355,11 @@ mod tests { let trusted_worktrees = init_trust_global(worktree_store, cx); let host_a: Option = None; - let host_b = Some(RemoteHostLocation { - user_name: Some("user".into()), - host_identifier: "remote-host".into(), - }); let can_trust_local = trusted_worktrees.update(cx, |store, cx| store.can_trust(local_worktree, cx)); assert!(!can_trust_local, "local worktree restricted on host_a"); - trusted_worktrees.update(cx, |store, cx| { - store.trust( - HashSet::from_iter([PathTrust::Workspace]), - host_b.clone(), - cx, - ); - }); - - let can_trust_workspace_a = trusted_worktrees.update(cx, |store, cx| { - store.can_trust_workspace(host_a.clone(), cx) - }); - assert!( - !can_trust_workspace_a, - "host_a workspace should still be restricted" - ); - - let can_trust_workspace_b = trusted_worktrees.update(cx, |store, cx| { - store.can_trust_workspace(host_b.clone(), cx) - }); - assert!(can_trust_workspace_b, "host_b workspace should be trusted"); - trusted_worktrees.update(cx, |store, cx| { store.trust( HashSet::from_iter([PathTrust::Worktree(local_worktree)]), @@ -1864,13 +1374,5 @@ mod tests { can_trust_local_after, "local worktree should be trusted on host_a" ); - - let can_trust_workspace_a_after = trusted_worktrees.update(cx, |store, cx| { - store.can_trust_workspace(host_a.clone(), cx) - }); - assert!( - can_trust_workspace_a_after, - "host_a workspace should be trusted after directory trust" - ); } } diff --git a/crates/project_benchmarks/src/main.rs b/crates/project_benchmarks/src/main.rs index 03c25bc464af06793e351f27588b023ec8eb3eb9..e4ddbb6cf2c7b6984df2533963bdf6bf88eacba0 100644 --- a/crates/project_benchmarks/src/main.rs +++ b/crates/project_benchmarks/src/main.rs @@ -62,7 +62,7 @@ fn main() -> Result<(), anyhow::Error> { let client = Client::production(cx); let http_client = FakeHttpClient::with_200_response(); let (_, rx) = watch::channel(None); - let node = NodeRuntime::new(http_client, None, rx, None); + let node = NodeRuntime::new(http_client, None, rx); let user_store = cx.new(|cx| UserStore::new(client.clone(), cx)); let registry = Arc::new(LanguageRegistry::new(cx.background_executor().clone())); let fs = Arc::new(RealFs::new(None, cx.background_executor().clone())); diff --git a/crates/proto/proto/worktree.proto b/crates/proto/proto/worktree.proto index 315aeb311e1e4284970dffa17bee4b0142373e92..5873cfc10c1c6af24520705c27781b916dfda3d0 100644 --- a/crates/proto/proto/worktree.proto +++ b/crates/proto/proto/worktree.proto @@ -166,14 +166,16 @@ message TrustWorktrees { message PathTrust { oneof content { - uint64 workspace = 1; uint64 worktree_id = 2; string abs_path = 3; } + + reserved 1; } message RestrictWorktrees { uint64 project_id = 1; - bool restrict_workspace = 2; repeated uint64 worktree_ids = 3; + + reserved 2; } diff --git a/crates/remote_server/src/headless_project.rs b/crates/remote_server/src/headless_project.rs index 89d26d35c77e076e1e618669acb5e54dc8afdcca..c83cc6aa34402a082fe104d64a8cb47f460704b8 100644 --- a/crates/remote_server/src/headless_project.rs +++ b/crates/remote_server/src/headless_project.rs @@ -642,16 +642,13 @@ impl HeadlessProject { .update(|cx| TrustedWorktrees::try_get_global(cx))? .context("missing trusted worktrees")?; trusted_worktrees.update(&mut cx, |trusted_worktrees, cx| { - let mut restricted_paths = envelope + let restricted_paths = envelope .payload .worktree_ids .into_iter() .map(WorktreeId::from_proto) .map(PathTrust::Worktree) .collect::>(); - if envelope.payload.restrict_workspace { - restricted_paths.insert(PathTrust::Workspace); - } trusted_worktrees.restrict(restricted_paths, None, cx); })?; Ok(proto::Ack {}) diff --git a/crates/remote_server/src/unix.rs b/crates/remote_server/src/unix.rs index af603998171e19d4776d47479ff81aa08d26d258..449b8491ece2494dacf8bfb1fa89aeeb8f6a81ac 100644 --- a/crates/remote_server/src/unix.rs +++ b/crates/remote_server/src/unix.rs @@ -36,7 +36,6 @@ use smol::Async; use smol::channel::{Receiver, Sender}; use smol::io::AsyncReadExt; use smol::{net::unix::UnixListener, stream::StreamExt as _}; -use std::pin::Pin; use std::{ env, ffi::OsStr, @@ -453,13 +452,10 @@ pub fn execute_run( ) }; - let trust_task = trusted_worktrees::wait_for_default_workspace_trust("Node runtime", cx) - .map(|trust_task| Box::pin(trust_task) as Pin>); let node_runtime = NodeRuntime::new( http_client.clone(), Some(shell_env_loaded_rx), node_settings_rx, - trust_task, ); let mut languages = LanguageRegistry::new(cx.background_executor().clone()); diff --git a/crates/workspace/src/persistence.rs b/crates/workspace/src/persistence.rs index a992a9e1a20d1346a0c201afd72bb51327f00381..cf5bdf2ab0059f10f2fb44e2069c8c0baf24d72b 100644 --- a/crates/workspace/src/persistence.rs +++ b/crates/workspace/src/persistence.rs @@ -1919,7 +1919,6 @@ impl WorkspaceDb { pub(crate) async fn save_trusted_worktrees( &self, trusted_worktrees: HashMap, HashSet>, - trusted_workspaces: HashSet>, ) -> anyhow::Result<()> { use anyhow::Context as _; use db::sqlez::statement::Statement; @@ -1936,7 +1935,6 @@ impl WorkspaceDb { .into_iter() .map(move |abs_path| (Some(abs_path), host.clone())) }) - .chain(trusted_workspaces.into_iter().map(|host| (None, host))) .collect::>(); let mut first_worktree; let mut last_worktree = 0_usize; @@ -2001,7 +1999,7 @@ VALUES {placeholders};"# let trusted_worktrees = DB.trusted_worktrees()?; Ok(trusted_worktrees .into_iter() - .map(|(abs_path, user_name, host_name)| { + .filter_map(|(abs_path, user_name, host_name)| { let db_host = match (user_name, host_name) { (_, None) => None, (None, Some(host_name)) => Some(RemoteHostLocation { @@ -2014,21 +2012,17 @@ VALUES {placeholders};"# }), }; - match abs_path { - Some(abs_path) => { - if db_host != host { - (db_host, PathTrust::AbsPath(abs_path)) - } else if let Some(worktree_store) = &worktree_store { - find_worktree_in_store(worktree_store.read(cx), &abs_path, cx) - .map(PathTrust::Worktree) - .map(|trusted_worktree| (host.clone(), trusted_worktree)) - .unwrap_or_else(|| (db_host.clone(), PathTrust::AbsPath(abs_path))) - } else { - (db_host, PathTrust::AbsPath(abs_path)) - } - } - None => (db_host, PathTrust::Workspace), - } + let abs_path = abs_path?; + Some(if db_host != host { + (db_host, PathTrust::AbsPath(abs_path)) + } else if let Some(worktree_store) = &worktree_store { + find_worktree_in_store(worktree_store.read(cx), &abs_path, cx) + .map(PathTrust::Worktree) + .map(|trusted_worktree| (host.clone(), trusted_worktree)) + .unwrap_or_else(|| (db_host.clone(), PathTrust::AbsPath(abs_path))) + } else { + (db_host, PathTrust::AbsPath(abs_path)) + }) }) .fold(HashMap::default(), |mut acc, (remote_host, path_trust)| { acc.entry(remote_host) diff --git a/crates/workspace/src/security_modal.rs b/crates/workspace/src/security_modal.rs index 1b5509d4d64e5b1377c9675fb49d2981e8173668..e3b9ab6e72481048d0f78eb07afb72af53810279 100644 --- a/crates/workspace/src/security_modal.rs +++ b/crates/workspace/src/security_modal.rs @@ -23,7 +23,7 @@ use ui::{ use crate::{DismissDecision, ModalView, ToggleWorktreeSecurity}; pub struct SecurityModal { - restricted_paths: HashMap, RestrictedPath>, + restricted_paths: HashMap, home_dir: Option, trust_parents: bool, worktree_store: WeakEntity, @@ -34,7 +34,7 @@ pub struct SecurityModal { #[derive(Debug, PartialEq, Eq)] struct RestrictedPath { - abs_path: Option>, + abs_path: Arc, is_file: bool, host: Option, } @@ -103,13 +103,11 @@ impl Render for SecurityModal { .child(Label::new(header_label)), ) .children(self.restricted_paths.values().map(|restricted_path| { - let abs_path = restricted_path.abs_path.as_ref().and_then(|abs_path| { - if restricted_path.is_file { - abs_path.parent() - } else { - Some(abs_path.as_ref()) - } - }); + let abs_path = if restricted_path.is_file { + restricted_path.abs_path.parent() + } else { + Some(restricted_path.abs_path.as_ref()) + }; let label = match abs_path { Some(abs_path) => match &restricted_path.host { @@ -254,7 +252,7 @@ impl SecurityModal { has_restricted_files |= restricted_path.is_file; !restricted_path.is_file }) - .filter_map(|restricted_path| restricted_path.abs_path.as_ref()?.parent()) + .filter_map(|restricted_path| restricted_path.abs_path.parent()) .collect::>(); match available_parents.len() { 0 => { @@ -289,19 +287,17 @@ impl SecurityModal { let mut paths_to_trust = self .restricted_paths .keys() - .map(|worktree_id| match worktree_id { - Some(worktree_id) => PathTrust::Worktree(*worktree_id), - None => PathTrust::Workspace, - }) + .copied() + .map(PathTrust::Worktree) .collect::>(); if self.trust_parents { paths_to_trust.extend(self.restricted_paths.values().filter_map( |restricted_paths| { if restricted_paths.is_file { - Some(PathTrust::Workspace) + None } else { let parent_abs_path = - restricted_paths.abs_path.as_ref()?.parent()?.to_owned(); + restricted_paths.abs_path.parent()?.to_owned(); Some(PathTrust::AbsPath(parent_abs_path)) } }, @@ -322,42 +318,22 @@ impl SecurityModal { pub fn refresh_restricted_paths(&mut self, cx: &mut Context) { if let Some(trusted_worktrees) = TrustedWorktrees::try_get_global(cx) { if let Some(worktree_store) = self.worktree_store.upgrade() { - let mut new_restricted_worktrees = trusted_worktrees + let new_restricted_worktrees = trusted_worktrees .read(cx) - .restricted_worktrees(worktree_store.read(cx), self.remote_host.clone(), cx) + .restricted_worktrees(worktree_store.read(cx), cx) .into_iter() - .filter_map(|restricted_path| { - let restricted_path = match restricted_path { - Some((worktree_id, abs_path)) => { - let worktree = - worktree_store.read(cx).worktree_for_id(worktree_id, cx)?; - ( - Some(worktree_id), - RestrictedPath { - abs_path: Some(abs_path), - is_file: worktree.read(cx).is_single_file(), - host: self.remote_host.clone(), - }, - ) - } - None => ( - None, - RestrictedPath { - abs_path: None, - is_file: false, - host: self.remote_host.clone(), - }, - ), - }; - Some(restricted_path) + .filter_map(|(worktree_id, abs_path)| { + let worktree = worktree_store.read(cx).worktree_for_id(worktree_id, cx)?; + Some(( + worktree_id, + RestrictedPath { + abs_path, + is_file: worktree.read(cx).is_single_file(), + host: self.remote_host.clone(), + }, + )) }) .collect::>(); - // Do not clutter the UI: - // * trusting regular local worktrees assumes the workspace is trusted either, on the same host. - // * trusting a workspace trusts all single-file worktrees on the same host. - if new_restricted_worktrees.len() > 1 { - new_restricted_worktrees.remove(&None); - } if self.restricted_paths != new_restricted_worktrees { self.trust_parents = false; diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index 9baf2a2d6c2155f0c30221be1308d8296c0b62a0..411450fea7c085dcbae084a368d7379136108b18 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -1233,21 +1233,18 @@ impl Workspace { if let Some(trusted_worktrees) = TrustedWorktrees::try_get_global(cx) { cx.subscribe(&trusted_worktrees, |workspace, worktrees_store, e, cx| { if let TrustedWorktreesEvent::Trusted(..) = e { - let (new_trusted_workspaces, new_trusted_worktrees) = worktrees_store - .update(cx, |worktrees_store, cx| { - worktrees_store.trusted_paths_for_serialization(cx) - }); // Do not persist auto trusted worktrees if !ProjectSettings::get_global(cx).session.trust_all_worktrees { + let new_trusted_worktrees = + worktrees_store.update(cx, |worktrees_store, cx| { + worktrees_store.trusted_paths_for_serialization(cx) + }); let timeout = cx.background_executor().timer(SERIALIZATION_THROTTLE_TIME); workspace._schedule_serialize_worktree_trust = cx.background_spawn(async move { timeout.await; persistence::DB - .save_trusted_worktrees( - new_trusted_worktrees, - new_trusted_workspaces, - ) + .save_trusted_worktrees(new_trusted_worktrees) .await .log_err(); }); diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rs index f527872ad8c90c4db2782fde62dcbe6a5320e4d7..a827e33f00935bb02e4bc9f761d673ab12a32f14 100644 --- a/crates/zed/src/main.rs +++ b/crates/zed/src/main.rs @@ -36,7 +36,6 @@ use std::{ env, io::{self, IsTerminal}, path::{Path, PathBuf}, - pin::Pin, process, sync::{Arc, OnceLock}, time::Instant, @@ -484,14 +483,7 @@ pub fn main() { }) .detach(); - let trust_task = trusted_worktrees::wait_for_default_workspace_trust("Node runtime", cx) - .map(|trust_task| Box::pin(trust_task) as Pin>); - let node_runtime = NodeRuntime::new( - client.http_client(), - Some(shell_env_loaded_rx), - rx, - trust_task, - ); + let node_runtime = NodeRuntime::new(client.http_client(), Some(shell_env_loaded_rx), rx); debug_adapter_extension::init(extension_host_proxy.clone(), cx); languages::init(languages.clone(), fs.clone(), node_runtime.clone(), cx); diff --git a/docs/src/worktree-trust.md b/docs/src/worktree-trust.md index 158851117bfdc4d00746594d74e1e6dae0bb84dc..590f063a75ac5d77e60d50f03af4795d6ec2961f 100644 --- a/docs/src/worktree-trust.md +++ b/docs/src/worktree-trust.md @@ -4,11 +4,11 @@ A worktree in Zed is either a directory or a single file that Zed opens as a sta Zed opens a worktree every time `zed some/path` is invoked, on drag and dropping a file or directory into Zed, on opening user settings.json, etc. Every worktree opened may contain a `.zed/settings.json` file with extra configuration options that may require installing and spawning language servers or MCP servers. -Note that the Zed workspace itself may also perform user-configured MCP server installation and spawning, even if no worktrees are open. +In order to provide users the opportunity to make their own choices according to their unique threat model and risk tolerance, all worktrees will be started in Restricted mode, which prevents download and execution of any related items from `.zed/settings.json`. Until configured to trust the worktree(s), Zed will not perform any related untrusted actions and will wait for user confirmation. This gives users a chance to review and understand any pre-configured settings, MCP servers, or language servers associated with a project. -In order to provide users the opportunity to make their own choices according to their unique threat model and risk tolerance, the workspace and all worktrees will be started in Restricted mode, which prevents download and execution of any related items. Until configured to trust the workspace and/or worktrees, Zed will not perform any untrusted actions and will wait for user confirmation. This gives users a chance to review and understand any pre-configured settings, MCP servers, or language servers associated with a project. +Note that at this point, Zed trusts the tools it installs itself, hence global entities such as global MCP servers, language servers like prettier and copilot are still in installed and started as usual, independent of worktree trust. -If a worktree is not trusted, Zed will indicate this with an exclamation mark icon in the title bar and a message in the Agent panel. Clicking this icon or using `workspace::ToggleWorktreeSecurity` action will bring up the security modal that allows the user to trust the worktree. +If a worktree is not trusted, Zed will indicate this with an exclamation mark icon in the title bar. Clicking this icon or using `workspace::ToggleWorktreeSecurity` action will bring up the security modal that allows the user to trust the worktree. Trusting any worktree will persist this information between restarts. It's possible to clear all trusted worktrees with `workspace::ClearTrustedWorktrees` command. This command will restart Zed, to ensure no untrusted settings, language servers or MCP servers persist. @@ -25,7 +25,7 @@ Restricted Mode prevents: ## Configuring broad worktree trust -By default, Zed won't trust any new worktrees and users will be required to trust each new worktree. Though not recommended, users may elect to trust all worktrees and the current workspace for a given session by configuring the following setting: +By default, Zed won't trust any new worktrees and users will be required to trust each new worktree. Though not recommended, users may elect to trust all worktrees by configuring the following setting: ```json [settings] "session": { @@ -47,20 +47,12 @@ A typical scenario where a directory might be open and a single file is subseque Spawning a language server presents a risk should the language server experience a supply-chain attack; therefore, Zed restricts that by default. Each single file worktree requires a separate trust grant, unless the directory containing it is trusted or all worktrees are trusted. -- "workspace" - -Even an empty Zed workspace with no files or directories open presents a risk if new MCP servers are locally configured by the user without review. For instance, opening an Assistant Panel and creating a new external agent thread might require installing and running new user-configured [Model Context Protocol servers](./ai/mcp.md). By default, zed will restrict a new MCP server until the user elects to trust the local workspace. Users may also disable the entire Agent panel if preferred; see [AI Configuration](./ai/configuration.md) for more details. - -Workspace trust, permitted by trusting Zed with no worktrees open, allows locally configured resources to be downloaded and executed. Workspace trust is per host and also trusts all single file worktrees from the same host in order to permit all local user-configured MCP and language servers to start. - - "directory worktree" If a directory is open in Zed, it's a full worktree which may spawn multiple language servers associated with it or spawn MCP servers if contained in a project settings file.Therefore, each directory worktree requires a separate trust grant unless a parent directory worktree trust is granted (see below). -When a directory worktree is trusted, language and MCP servers are permitted to be downloaded and started, hence we also enable workspace trust for the host in question automatically when this occurs. +When a directory worktree is trusted, language and MCP servers are permitted to be downloaded and started, hence we also enable single file worktree trust for the host in question automatically when this occurs: this helps when opening single files when using language server features in the trusted directory worktree. - "parent directory worktree" To permit trust decisions for multiple directory worktrees at once, it's possible to trust all subdirectories of a given parent directory worktree opened in Zed by checking the appropriate checkbox. This will grant trust to all its subdirectories, including all current and potential directory worktrees. - -This also automatically enables workspace trust to permit the newly trusted resources to download and start. From c56eb46311ade023b21ac69ea33540f396878f19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Raz=20Guzm=C3=A1n=20Macedo?= Date: Wed, 17 Dec 2025 11:32:18 -0600 Subject: [PATCH 453/621] Add davidbarsky to community champion labelers (#45132) --- .github/workflows/community_champion_auto_labeler.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/community_champion_auto_labeler.yml b/.github/workflows/community_champion_auto_labeler.yml index 93f1d5602331bb76fe5d678098ab8c087b1f3d52..d73b38320731e0a2f9a52ff863de5095eddb7b6a 100644 --- a/.github/workflows/community_champion_auto_labeler.yml +++ b/.github/workflows/community_champion_auto_labeler.yml @@ -34,6 +34,7 @@ jobs: CharlesChen0823 chbk cppcoffee + davidbarsky davewa ddoemonn djsauble From 0fe60ec5325bd5dd1810d141096e8b3732d5358b Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Wed, 17 Dec 2025 10:41:43 -0700 Subject: [PATCH 454/621] Trigger auto-fix auto-matically (#44947) This updates our CI workflow to try to run the autofix.yml workflow if any of prettier, cargo fmt, or cargo clippy fail. Release Notes: - N/A --- .github/workflows/autofix_pr.yml | 3 +++ .github/workflows/release.yml | 6 ++++++ .github/workflows/run_tests.yml | 18 +++++++++++++++--- .../xtask/src/tasks/workflows/autofix_pr.rs | 6 ++++++ tooling/xtask/src/tasks/workflows/run_tests.rs | 8 +++++--- tooling/xtask/src/tasks/workflows/steps.rs | 10 ++++++++++ 6 files changed, 45 insertions(+), 6 deletions(-) diff --git a/.github/workflows/autofix_pr.yml b/.github/workflows/autofix_pr.yml index 762b86c446f4592e8fd76c8f5a00cf8cf8ab3f38..1591ba2a9a98b8587814d25858f4e0d78d9f7d34 100644 --- a/.github/workflows/autofix_pr.yml +++ b/.github/workflows/autofix_pr.yml @@ -123,3 +123,6 @@ jobs: GIT_AUTHOR_NAME: Zed Zippy GIT_AUTHOR_EMAIL: 234243425+zed-zippy[bot]@users.noreply.github.com GITHUB_TOKEN: ${{ steps.get-app-token.outputs.token }} +concurrency: + group: ${{ github.workflow }}-${{ inputs.pr_number }} + cancel-in-progress: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7afac285b5a34df2aadd04952400809059e12222..155b38666f4bd73e68e9ea326db9a6862288a1fe 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -74,6 +74,12 @@ jobs: - name: steps::clippy run: ./script/clippy shell: bash -euxo pipefail {0} + - name: steps::trigger_autofix + if: failure() && github.event_name == 'pull_request' && github.actor != 'zed-zippy[bot]' + run: gh workflow run autofix_pr.yml -f pr_number=${{ github.event.pull_request.number }} -f run_clippy=true + shell: bash -euxo pipefail {0} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: steps::cargo_install_nextest uses: taiki-e/install-action@nextest - name: steps::clear_target_dir_if_large diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index 9584d7a0cb70469820bf40d76beb6154f2a53b1e..a9a46b7a797faae793c87601d306a2aea80e6592 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -77,6 +77,15 @@ jobs: - name: ./script/prettier run: ./script/prettier shell: bash -euxo pipefail {0} + - name: steps::cargo_fmt + run: cargo fmt --all -- --check + shell: bash -euxo pipefail {0} + - name: steps::trigger_autofix + if: failure() && github.event_name == 'pull_request' && github.actor != 'zed-zippy[bot]' + run: gh workflow run autofix_pr.yml -f pr_number=${{ github.event.pull_request.number }} -f run_clippy=false + shell: bash -euxo pipefail {0} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: ./script/check-todos run: ./script/check-todos shell: bash -euxo pipefail {0} @@ -87,9 +96,6 @@ jobs: uses: crate-ci/typos@2d0ce569feab1f8752f1dde43cc2f2aa53236e06 with: config: ./typos.toml - - name: steps::cargo_fmt - run: cargo fmt --all -- --check - shell: bash -euxo pipefail {0} timeout-minutes: 60 run_tests_windows: needs: @@ -160,6 +166,12 @@ jobs: - name: steps::clippy run: ./script/clippy shell: bash -euxo pipefail {0} + - name: steps::trigger_autofix + if: failure() && github.event_name == 'pull_request' && github.actor != 'zed-zippy[bot]' + run: gh workflow run autofix_pr.yml -f pr_number=${{ github.event.pull_request.number }} -f run_clippy=true + shell: bash -euxo pipefail {0} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: steps::cargo_install_nextest uses: taiki-e/install-action@nextest - name: steps::clear_target_dir_if_large diff --git a/tooling/xtask/src/tasks/workflows/autofix_pr.rs b/tooling/xtask/src/tasks/workflows/autofix_pr.rs index 44dd0f9ea9b840163767e15b973192e72b57f4a8..f4a8e0e2b09df93cc430f0931c3db3f9e67b07df 100644 --- a/tooling/xtask/src/tasks/workflows/autofix_pr.rs +++ b/tooling/xtask/src/tasks/workflows/autofix_pr.rs @@ -18,6 +18,12 @@ pub fn autofix_pr() -> Workflow { .add_input(pr_number.name, pr_number.input()) .add_input(run_clippy.name, run_clippy.input()), )) + .concurrency( + Concurrency::new(Expression::new(format!( + "${{{{ github.workflow }}}}-{pr_number}" + ))) + .cancel_in_progress(true), + ) .add_job(run_autofix.name.clone(), run_autofix.job) .add_job(commit_changes.name, commit_changes.job) } diff --git a/tooling/xtask/src/tasks/workflows/run_tests.rs b/tooling/xtask/src/tasks/workflows/run_tests.rs index 0bb3e152fb390e044ebac456fd3347707c66f612..13639fd6c4bf33fe090dcb9d5f3cafdf45a36e76 100644 --- a/tooling/xtask/src/tasks/workflows/run_tests.rs +++ b/tooling/xtask/src/tasks/workflows/run_tests.rs @@ -237,10 +237,11 @@ fn check_style() -> NamedJob { .add_step(steps::cache_rust_dependencies_namespace()) .add_step(steps::setup_pnpm()) .add_step(steps::script("./script/prettier")) + .add_step(steps::cargo_fmt()) + .add_step(steps::trigger_autofix(false)) .add_step(steps::script("./script/check-todos")) .add_step(steps::script("./script/check-keymaps")) - .add_step(check_for_typos()) - .add_step(steps::cargo_fmt()), + .add_step(check_for_typos()), ) } @@ -326,7 +327,8 @@ pub(crate) fn run_platform_tests(platform: Platform) -> NamedJob { .add_step(steps::setup_node()) .add_step(steps::clippy(platform)) .when(platform == Platform::Linux, |job| { - job.add_step(steps::cargo_install_nextest()) + job.add_step(steps::trigger_autofix(true)) + .add_step(steps::cargo_install_nextest()) }) .add_step(steps::clear_target_dir_if_large(platform)) .add_step(steps::cargo_nextest(platform)) diff --git a/tooling/xtask/src/tasks/workflows/steps.rs b/tooling/xtask/src/tasks/workflows/steps.rs index 7d55df2db433d6e6eae96a5ae62a0c033689d904..54873c011ce9d1fb7d4e7e0b734695c7c1a30fad 100644 --- a/tooling/xtask/src/tasks/workflows/steps.rs +++ b/tooling/xtask/src/tasks/workflows/steps.rs @@ -344,3 +344,13 @@ pub fn git_checkout(ref_name: &dyn std::fmt::Display) -> Step { "git fetch origin {ref_name} && git checkout {ref_name}" )) } + +pub fn trigger_autofix(run_clippy: bool) -> Step { + named::bash(format!( + "gh workflow run autofix_pr.yml -f pr_number=${{{{ github.event.pull_request.number }}}} -f run_clippy={run_clippy}" + )) + .if_condition(Expression::new( + "failure() && github.event_name == 'pull_request' && github.actor != 'zed-zippy[bot]'", + )) + .add_env(("GITHUB_TOKEN", vars::GITHUB_TOKEN)) +} From b22ccfaff5019ecf00ad33fa0569b77f5ebc09e0 Mon Sep 17 00:00:00 2001 From: Anthony Eid <56899983+Anthony-Eid@users.noreply.github.com> Date: Wed, 17 Dec 2025 13:31:21 -0500 Subject: [PATCH 455/621] gpui: Fix macOS memory leaks (#45051) The below memory leaks were caused by failing to release reference counted resources. I confirmed using instruments that my changes stopped the leaks from occurring. - System prompts - Screen capturing - loading font families There were also two memory leaks I found from some of our dependencies that I made PRs to fix - https://github.com/RustAudio/coreaudio-rs/pull/147 - https://github.com/servo/core-foundation-rs/pull/746 Release Notes: - N/A --- crates/gpui/src/platform/mac/open_type.rs | 5 ++++ .../gpui/src/platform/mac/screen_capture.rs | 14 ++++++++-- crates/gpui/src/platform/mac/text_system.rs | 26 +++++++++++++++++-- crates/gpui/src/platform/mac/window.rs | 1 + 4 files changed, 42 insertions(+), 4 deletions(-) diff --git a/crates/gpui/src/platform/mac/open_type.rs b/crates/gpui/src/platform/mac/open_type.rs index 37a29559fdfbc284ffd1021cc6c2c6ed717ca228..ff501df15f671318548a3959bd6b966f97e051b1 100644 --- a/crates/gpui/src/platform/mac/open_type.rs +++ b/crates/gpui/src/platform/mac/open_type.rs @@ -52,6 +52,11 @@ pub fn apply_features_and_fallbacks( &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks, ); + + for value in &values { + CFRelease(*value as _); + } + let new_descriptor = CTFontDescriptorCreateWithAttributes(attrs); CFRelease(attrs as _); let new_descriptor = CTFontDescriptor::wrap_under_create_rule(new_descriptor); diff --git a/crates/gpui/src/platform/mac/screen_capture.rs b/crates/gpui/src/platform/mac/screen_capture.rs index 2f2c1eae335c8bcb366879661534c46dacfd47b4..4b80a87d32f45540c76790065514f29cc7f93b3f 100644 --- a/crates/gpui/src/platform/mac/screen_capture.rs +++ b/crates/gpui/src/platform/mac/screen_capture.rs @@ -110,13 +110,21 @@ impl ScreenCaptureSource for MacScreenCaptureSource { let _: id = msg_send![configuration, setHeight: meta.resolution.height.0 as i64]; let stream: id = msg_send![stream, initWithFilter:filter configuration:configuration delegate:delegate]; + // Stream contains filter, configuration, and delegate internally so we release them here + // to prevent a memory leak when steam is dropped + let _: () = msg_send![filter, release]; + let _: () = msg_send![configuration, release]; + let _: () = msg_send![delegate, release]; + let (mut tx, rx) = oneshot::channel(); let mut error: id = nil; let _: () = msg_send![stream, addStreamOutput:output type:SCStreamOutputTypeScreen sampleHandlerQueue:0 error:&mut error as *mut id]; if error != nil { let message: id = msg_send![error, localizedDescription]; - tx.send(Err(anyhow!("failed to add stream output {message:?}"))) + let _: () = msg_send![stream, release]; + let _: () = msg_send![output, release]; + tx.send(Err(anyhow!("failed to add stream output {message:?}"))) .ok(); return rx; } @@ -132,8 +140,10 @@ impl ScreenCaptureSource for MacScreenCaptureSource { }; Ok(Box::new(stream) as Box) } else { + let _: () = msg_send![stream, release]; + let _: () = msg_send![output, release]; let message: id = msg_send![error, localizedDescription]; - Err(anyhow!("failed to stop screen capture stream {message:?}")) + Err(anyhow!("failed to start screen capture stream {message:?}")) }; if let Some(tx) = tx.borrow_mut().take() { tx.send(result).ok(); diff --git a/crates/gpui/src/platform/mac/text_system.rs b/crates/gpui/src/platform/mac/text_system.rs index 3faf4e6491e6588bdb1341d5a8845171562fa8a0..8595582f4ad7e078f7cfb0140e249feb0a9740dc 100644 --- a/crates/gpui/src/platform/mac/text_system.rs +++ b/crates/gpui/src/platform/mac/text_system.rs @@ -8,6 +8,7 @@ use anyhow::anyhow; use cocoa::appkit::CGFloat; use collections::HashMap; use core_foundation::{ + array::{CFArray, CFArrayRef}, attributed_string::CFMutableAttributedString, base::{CFRange, TCFType}, number::CFNumber, @@ -21,8 +22,10 @@ use core_graphics::{ }; use core_text::{ font::CTFont, + font_collection::CTFontCollectionRef, font_descriptor::{ - kCTFontSlantTrait, kCTFontSymbolicTrait, kCTFontWeightTrait, kCTFontWidthTrait, + CTFontDescriptor, kCTFontSlantTrait, kCTFontSymbolicTrait, kCTFontWeightTrait, + kCTFontWidthTrait, }, line::CTLine, string_attributes::kCTFontAttributeName, @@ -97,7 +100,26 @@ impl PlatformTextSystem for MacTextSystem { fn all_font_names(&self) -> Vec { let mut names = Vec::new(); let collection = core_text::font_collection::create_for_all_families(); - let Some(descriptors) = collection.get_descriptors() else { + // NOTE: We intentionally avoid using `collection.get_descriptors()` here because + // it has a memory leak bug in core-text v21.0.0. The upstream code uses + // `wrap_under_get_rule` but `CTFontCollectionCreateMatchingFontDescriptors` + // follows the Create Rule (caller owns the result), so it should use + // `wrap_under_create_rule`. We call the function directly with correct memory management. + unsafe extern "C" { + fn CTFontCollectionCreateMatchingFontDescriptors( + collection: CTFontCollectionRef, + ) -> CFArrayRef; + } + let descriptors: Option> = unsafe { + let array_ref = + CTFontCollectionCreateMatchingFontDescriptors(collection.as_concrete_TypeRef()); + if array_ref.is_null() { + None + } else { + Some(CFArray::wrap_under_create_rule(array_ref)) + } + }; + let Some(descriptors) = descriptors else { return names; }; for descriptor in descriptors.into_iter() { diff --git a/crates/gpui/src/platform/mac/window.rs b/crates/gpui/src/platform/mac/window.rs index 19ad1777570da9494148e01161e156748cd9bcfc..14b0113c7cf44fa9574bfcca30b46fb988b5e380 100644 --- a/crates/gpui/src/platform/mac/window.rs +++ b/crates/gpui/src/platform/mac/window.rs @@ -1190,6 +1190,7 @@ impl PlatformWindow for MacWindow { let (done_tx, done_rx) = oneshot::channel(); let done_tx = Cell::new(Some(done_tx)); let block = ConcreteBlock::new(move |answer: NSInteger| { + let _: () = msg_send![alert, release]; if let Some(done_tx) = done_tx.take() { let _ = done_tx.send(answer.try_into().unwrap()); } From 8c7a04c6bf3c26082f0cb0501a3ddf180968dd55 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Wed, 17 Dec 2025 11:41:46 -0700 Subject: [PATCH 456/621] Autotrust new git worktrees (#45138) Follow-up of https://github.com/zed-industries/zed/pull/44887 - Inherit git worktree trust - Tidy up the security modal Release Notes: - N/A --------- Co-authored-by: Kirill Bulatov --- crates/git_ui/src/worktree_picker.rs | 41 ++++++++++++++++++--- crates/workspace/src/security_modal.rs | 51 +++++++++----------------- 2 files changed, 53 insertions(+), 39 deletions(-) diff --git a/crates/git_ui/src/worktree_picker.rs b/crates/git_ui/src/worktree_picker.rs index 875ae55eefae19e24aa26fe75f80d70f8316c82b..fef5e16c80ddd26ae6dd0b2a5c0ad1d8e5b21b2c 100644 --- a/crates/git_ui/src/worktree_picker.rs +++ b/crates/git_ui/src/worktree_picker.rs @@ -1,4 +1,5 @@ use anyhow::Context as _; +use collections::HashSet; use fuzzy::StringMatchCandidate; use git::repository::Worktree as GitWorktree; @@ -9,7 +10,11 @@ use gpui::{ actions, rems, }; use picker::{Picker, PickerDelegate, PickerEditorPosition}; -use project::{DirectoryLister, git_store::Repository}; +use project::{ + DirectoryLister, + git_store::Repository, + trusted_worktrees::{PathTrust, RemoteHostLocation, TrustedWorktrees}, +}; use recent_projects::{RemoteConnectionModal, connect}; use remote::{RemoteConnectionOptions, remote_client::ConnectionIdentifier}; use std::{path::PathBuf, sync::Arc}; @@ -219,7 +224,6 @@ impl WorktreeListDelegate { window: &mut Window, cx: &mut Context>, ) { - let workspace = self.workspace.clone(); let Some(repo) = self.repo.clone() else { return; }; @@ -247,6 +251,7 @@ impl WorktreeListDelegate { let branch = worktree_branch.to_string(); let window_handle = window.window_handle(); + let workspace = self.workspace.clone(); cx.spawn_in(window, async move |_, cx| { let Some(paths) = worktree_path.await? else { return anyhow::Ok(()); @@ -257,8 +262,32 @@ impl WorktreeListDelegate { repo.create_worktree(branch.clone(), path.clone(), commit) })? .await??; - - let final_path = path.join(branch); + let new_worktree_path = path.join(branch); + + workspace.update(cx, |workspace, cx| { + if let Some(trusted_worktrees) = TrustedWorktrees::try_get_global(cx) { + let repo_path = &repo.read(cx).snapshot().work_directory_abs_path; + let project = workspace.project(); + if let Some((parent_worktree, _)) = + project.read(cx).find_worktree(repo_path, cx) + { + trusted_worktrees.update(cx, |trusted_worktrees, cx| { + if trusted_worktrees.can_trust(parent_worktree.read(cx).id(), cx) { + trusted_worktrees.trust( + HashSet::from_iter([PathTrust::AbsPath( + new_worktree_path.clone(), + )]), + project + .read(cx) + .remote_connection_options(cx) + .map(RemoteHostLocation::from), + cx, + ); + } + }); + } + } + })?; let (connection_options, app_state, is_local) = workspace.update(cx, |workspace, cx| { @@ -274,7 +303,7 @@ impl WorktreeListDelegate { .update_in(cx, |workspace, window, cx| { workspace.open_workspace_for_paths( replace_current_window, - vec![final_path], + vec![new_worktree_path], window, cx, ) @@ -283,7 +312,7 @@ impl WorktreeListDelegate { } else if let Some(connection_options) = connection_options { open_remote_worktree( connection_options, - vec![final_path], + vec![new_worktree_path], app_state, window_handle, replace_current_window, diff --git a/crates/workspace/src/security_modal.rs b/crates/workspace/src/security_modal.rs index e3b9ab6e72481048d0f78eb07afb72af53810279..bb1482d7cce2a9849a78a9512598e389a6e5eea0 100644 --- a/crates/workspace/src/security_modal.rs +++ b/crates/workspace/src/security_modal.rs @@ -102,46 +102,31 @@ impl Render for SecurityModal { .child(Icon::new(IconName::Warning).color(Color::Warning)) .child(Label::new(header_label)), ) - .children(self.restricted_paths.values().map(|restricted_path| { + .children(self.restricted_paths.values().filter_map(|restricted_path| { let abs_path = if restricted_path.is_file { restricted_path.abs_path.parent() } else { Some(restricted_path.abs_path.as_ref()) - }; - - let label = match abs_path { - Some(abs_path) => match &restricted_path.host { - Some(remote_host) => match &remote_host.user_name { - Some(user_name) => format!( - "{} ({}@{})", - self.shorten_path(abs_path).display(), - user_name, - remote_host.host_identifier - ), - None => format!( - "{} ({})", - self.shorten_path(abs_path).display(), - remote_host.host_identifier - ), - }, - None => self.shorten_path(abs_path).display().to_string(), - }, - None => match &restricted_path.host { - Some(remote_host) => match &remote_host.user_name { - Some(user_name) => format!( - "Workspace trust ({}@{})", - user_name, remote_host.host_identifier - ), - None => { - format!("Workspace trust ({})", remote_host.host_identifier) - } - }, - None => "Workspace trust".to_string(), + }?; + let label = match &restricted_path.host { + Some(remote_host) => match &remote_host.user_name { + Some(user_name) => format!( + "{} ({}@{})", + self.shorten_path(abs_path).display(), + user_name, + remote_host.host_identifier + ), + None => format!( + "{} ({})", + self.shorten_path(abs_path).display(), + remote_host.host_identifier + ), }, + None => self.shorten_path(abs_path).display().to_string(), }; - h_flex() + Some(h_flex() .pl(IconSize::default().rems() + rems(0.5)) - .child(Label::new(label).color(Color::Muted)) + .child(Label::new(label).color(Color::Muted))) })), ) .child( From 847457df1bf27c1162433434afef53497f07a15b Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Wed, 17 Dec 2025 10:49:39 -0800 Subject: [PATCH 457/621] Fix a bug where switching the disable AI flag would cause a panic (#45050) Also quiet some noisy logs Release Notes: - N/A --- crates/agent/src/history_store.rs | 13 +++++-------- crates/agent_ui/Cargo.toml | 2 +- crates/agent_ui_v2/Cargo.toml | 7 +++++++ crates/search/src/buffer_search.rs | 5 ++++- crates/workspace/src/dock.rs | 14 +++++--------- crates/workspace/src/workspace.rs | 20 ++++++++++++++++---- crates/zed/Cargo.toml | 4 ++++ crates/zed/src/zed.rs | 25 +++++++++++++++++++++++-- 8 files changed, 65 insertions(+), 25 deletions(-) diff --git a/crates/agent/src/history_store.rs b/crates/agent/src/history_store.rs index 5a1b923d139060ed7df679a69d96928d03559c9d..c455f73316e3fc7a641fa8a31ac0ad766a2ae584 100644 --- a/crates/agent/src/history_store.rs +++ b/crates/agent/src/history_store.rs @@ -216,14 +216,10 @@ impl HistoryStore { } pub fn reload(&self, cx: &mut Context) { - let database_future = ThreadsDatabase::connect(cx); + let database_connection = ThreadsDatabase::connect(cx); cx.spawn(async move |this, cx| { - let threads = database_future - .await - .map_err(|err| anyhow!(err))? - .list_threads() - .await?; - + let database = database_connection.await; + let threads = database.map_err(|err| anyhow!(err))?.list_threads().await?; this.update(cx, |this, cx| { if this.recently_opened_entries.len() < MAX_RECENTLY_OPENED_ENTRIES { for thread in threads @@ -344,7 +340,8 @@ impl HistoryStore { fn load_recently_opened_entries(cx: &AsyncApp) -> Task>> { cx.background_spawn(async move { if cfg!(any(feature = "test-support", test)) { - anyhow::bail!("history store does not persist in tests"); + log::warn!("history store does not persist in tests"); + return Ok(VecDeque::new()); } let json = KEY_VALUE_STORE .read_kvp(RECENTLY_OPENED_THREADS_KEY)? diff --git a/crates/agent_ui/Cargo.toml b/crates/agent_ui/Cargo.toml index 38580b4d2c61597718d9fb718a20e52e84222481..8a9633e578a85323f2a289bd83c169a1f5d7f272 100644 --- a/crates/agent_ui/Cargo.toml +++ b/crates/agent_ui/Cargo.toml @@ -13,7 +13,7 @@ path = "src/agent_ui.rs" doctest = false [features] -test-support = ["assistant_text_thread/test-support", "eval_utils", "gpui/test-support", "language/test-support", "reqwest_client", "workspace/test-support"] +test-support = ["assistant_text_thread/test-support", "eval_utils", "gpui/test-support", "language/test-support", "reqwest_client", "workspace/test-support", "agent/test-support"] unit-eval = [] [dependencies] diff --git a/crates/agent_ui_v2/Cargo.toml b/crates/agent_ui_v2/Cargo.toml index f24ef47471cdcfe0910cf36c5e220c5276d5f6ae..2b2cf337adf578432d594ce14f2f58e5911c45fb 100644 --- a/crates/agent_ui_v2/Cargo.toml +++ b/crates/agent_ui_v2/Cargo.toml @@ -12,6 +12,10 @@ workspace = true path = "src/agent_ui_v2.rs" doctest = false +[features] +test-support = ["agent/test-support"] + + [dependencies] agent.workspace = true agent_servers.workspace = true @@ -38,3 +42,6 @@ time_format.workspace = true ui.workspace = true util.workspace = true workspace.workspace = true + +[dev-dependencies] +agent = { workspace = true, features = ["test-support"] } diff --git a/crates/search/src/buffer_search.rs b/crates/search/src/buffer_search.rs index 66641e91a882b0b994e16673e3c65a1d51f27650..12b283ab22937b7952d18d63b1378d2914211f9b 100644 --- a/crates/search/src/buffer_search.rs +++ b/crates/search/src/buffer_search.rs @@ -7,7 +7,6 @@ use crate::{ search_bar::{ActionButtonState, input_base_styles, render_action_button, render_text_input}, }; use any_vec::AnyVec; -use anyhow::Context as _; use collections::HashMap; use editor::{ DisplayPoint, Editor, EditorSettings, MultiBufferOffset, @@ -634,15 +633,19 @@ impl BufferSearchBar { .read(cx) .as_singleton() .expect("query editor should be backed by a singleton buffer"); + query_buffer .read(cx) .set_language_registry(languages.clone()); cx.spawn(async move |buffer_search_bar, cx| { + use anyhow::Context as _; + let regex_language = languages .language_for_name("regex") .await .context("loading regex language")?; + buffer_search_bar .update(cx, |buffer_search_bar, cx| { buffer_search_bar.regex_language = Some(regex_language); diff --git a/crates/workspace/src/dock.rs b/crates/workspace/src/dock.rs index b358cf7b53ff16bae3756499470a2a55211618a8..7f4b09df0f94fa421c399ed9d70163f7cc2ba203 100644 --- a/crates/workspace/src/dock.rs +++ b/crates/workspace/src/dock.rs @@ -1,5 +1,4 @@ use crate::persistence::model::DockData; -use crate::utility_pane::utility_slot_for_dock_position; use crate::{DraggedDock, Event, ModalLayer, Pane}; use crate::{Workspace, status_bar::StatusItemView}; use anyhow::Context as _; @@ -705,7 +704,7 @@ impl Dock { panel: &Entity, window: &mut Window, cx: &mut Context, - ) { + ) -> bool { if let Some(panel_ix) = self .panel_entries .iter() @@ -724,15 +723,12 @@ impl Dock { } } - let slot = utility_slot_for_dock_position(self.position); - if let Some(workspace) = self.workspace.upgrade() { - workspace.update(cx, |workspace, cx| { - workspace.clear_utility_pane_if_provider(slot, Entity::entity_id(panel), cx); - }); - } - self.panel_entries.remove(panel_ix); cx.notify(); + + true + } else { + false } } diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index 411450fea7c085dcbae084a368d7379136108b18..b636414250c0463eca019ad30321b19d67680fd3 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -135,7 +135,9 @@ pub use workspace_settings::{ use zed_actions::{Spawn, feedback::FileBugReport}; use crate::{ - item::ItemBufferKind, notifications::NotificationId, utility_pane::UTILITY_PANE_MIN_WIDTH, + item::ItemBufferKind, + notifications::NotificationId, + utility_pane::{UTILITY_PANE_MIN_WIDTH, utility_slot_for_dock_position}, }; use crate::{ persistence::{ @@ -986,6 +988,7 @@ impl AppState { #[cfg(any(test, feature = "test-support"))] pub fn test(cx: &mut App) -> Arc { + use fs::Fs; use node_runtime::NodeRuntime; use session::Session; use settings::SettingsStore; @@ -996,6 +999,7 @@ impl AppState { } let fs = fs::FakeFs::new(cx.background_executor().clone()); + ::set_global(fs.clone(), cx); let languages = Arc::new(LanguageRegistry::test(cx.background_executor().clone())); let clock = Arc::new(clock::FakeSystemClock::new()); let http_client = http_client::FakeHttpClient::with_404_response(); @@ -1890,10 +1894,18 @@ impl Workspace { window: &mut Window, cx: &mut Context, ) { + let mut found_in_dock = None; for dock in [&self.left_dock, &self.bottom_dock, &self.right_dock] { - dock.update(cx, |dock, cx| { - dock.remove_panel(panel, window, cx); - }) + let found = dock.update(cx, |dock, cx| dock.remove_panel(panel, window, cx)); + + if found { + found_in_dock = Some(dock.clone()); + } + } + if let Some(found_in_dock) = found_in_dock { + let position = found_in_dock.read(cx).position(); + let slot = utility_slot_for_dock_position(position); + self.clear_utility_pane_if_provider(slot, Entity::entity_id(panel), cx); } } diff --git a/crates/zed/Cargo.toml b/crates/zed/Cargo.toml index 955540843489ac21d79042854eb6fcebf5f64318..b5b33850da8da9035276c7752ad72da9bf0b55b9 100644 --- a/crates/zed/Cargo.toml +++ b/crates/zed/Cargo.toml @@ -195,6 +195,10 @@ terminal_view = { workspace = true, features = ["test-support"] } tree-sitter-md.workspace = true tree-sitter-rust.workspace = true workspace = { workspace = true, features = ["test-support"] } +agent_ui = { workspace = true, features = ["test-support"] } +agent_ui_v2 = { workspace = true, features = ["test-support"] } +search = { workspace = true, features = ["test-support"] } + [package.metadata.bundle-dev] icon = ["resources/app-icon-dev@2x.png", "resources/app-icon-dev.png"] diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs index f6218c97c31b98db76a2ae46b3f89876d426ac33..d088df00839814e32a9c246a3486ac5ad5ca4b9e 100644 --- a/crates/zed/src/zed.rs +++ b/crates/zed/src/zed.rs @@ -707,7 +707,6 @@ fn setup_or_teardown_ai_panel( .disable_ai || cfg!(test); let existing_panel = workspace.panel::

(cx); - match (disable_ai, existing_panel) { (false, None) => cx.spawn_in(window, async move |workspace, cx| { let panel = load_panel(workspace.clone(), cx.clone()).await?; @@ -2327,7 +2326,7 @@ mod tests { use project::{Project, ProjectPath}; use semver::Version; use serde_json::json; - use settings::{SettingsStore, watch_config_file}; + use settings::{SaturatingBool, SettingsStore, watch_config_file}; use std::{ path::{Path, PathBuf}, time::Duration, @@ -5171,6 +5170,28 @@ mod tests { ); } + #[gpui::test] + async fn test_disable_ai_crash(cx: &mut gpui::TestAppContext) { + let app_state = init_test(cx); + cx.update(init); + let project = Project::test(app_state.fs.clone(), [], cx).await; + let _window = cx.add_window(|window, cx| Workspace::test_new(project, window, cx)); + + cx.run_until_parked(); + + cx.update(|cx| { + SettingsStore::update_global(cx, |settings_store, cx| { + settings_store.update_user_settings(cx, |settings| { + settings.disable_ai = Some(SaturatingBool(true)); + }); + }); + }); + + cx.run_until_parked(); + + // If this panics, the test has failed + } + #[gpui::test] async fn test_prefer_focused_window(cx: &mut gpui::TestAppContext) { let app_state = init_test(cx); From 83ca2f9e88945df30659e5f76b75b3bac941b294 Mon Sep 17 00:00:00 2001 From: Xipeng Jin <56369076+xipeng-jin@users.noreply.github.com> Date: Wed, 17 Dec 2025 13:53:48 -0500 Subject: [PATCH 458/621] Add Vim-like Which-key Popup menu (#43618) Closes #10910 Follow up work continuing from the last PR https://github.com/zed-industries/zed/pull/42659. Add the UI element for displaying vim like which-key menu. https://github.com/user-attachments/assets/3dc5f0c9-5a2f-459e-a3db-859169aeba26 Release Notes: - Added a which-key like modal with a compact, single-column panel anchored to the bottom-right. You can enable with `{"which_key": {"enabled": true}}` in your settings. --------- Co-authored-by: Conrad Irwin Co-authored-by: Zed Zippy <234243425+zed-zippy[bot]@users.noreply.github.com> --- Cargo.lock | 15 + Cargo.toml | 2 + assets/settings/default.json | 7 + crates/gpui/src/key_dispatch.rs | 11 + crates/gpui/src/keymap.rs | 35 +++ crates/gpui/src/window.rs | 7 + crates/settings/src/settings_content.rs | 16 ++ crates/settings/src/vscode_import.rs | 1 + crates/settings_ui/src/page_data.rs | 43 +++ crates/which_key/Cargo.toml | 23 ++ crates/which_key/LICENSE-GPL | 1 + crates/which_key/src/which_key.rs | 98 +++++++ crates/which_key/src/which_key_modal.rs | 308 +++++++++++++++++++++ crates/which_key/src/which_key_settings.rs | 18 ++ crates/workspace/src/modal_layer.rs | 16 +- crates/zed/Cargo.toml | 1 + crates/zed/src/main.rs | 1 + 17 files changed, 602 insertions(+), 1 deletion(-) create mode 100644 crates/which_key/Cargo.toml create mode 120000 crates/which_key/LICENSE-GPL create mode 100644 crates/which_key/src/which_key.rs create mode 100644 crates/which_key/src/which_key_modal.rs create mode 100644 crates/which_key/src/which_key_settings.rs diff --git a/Cargo.lock b/Cargo.lock index de9cb227c6cfb799099abf446c1bdee61ec85bff..146f0e19741610d3676d7781fa74982ff2e55918 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19120,6 +19120,20 @@ dependencies = [ "winsafe", ] +[[package]] +name = "which_key" +version = "0.1.0" +dependencies = [ + "command_palette", + "gpui", + "serde", + "settings", + "theme", + "ui", + "util", + "workspace", +] + [[package]] name = "whoami" version = "1.6.1" @@ -20730,6 +20744,7 @@ dependencies = [ "watch", "web_search", "web_search_providers", + "which_key", "windows 0.61.3", "winresource", "workspace", diff --git a/Cargo.toml b/Cargo.toml index a8002e207d7ba9d3699832ac76be530e1979ead4..13bb4ceea133e16e8cf89461cd1fe7084d448eae 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -192,6 +192,7 @@ members = [ "crates/vercel", "crates/vim", "crates/vim_mode_setting", + "crates/which_key", "crates/watch", "crates/web_search", "crates/web_search_providers", @@ -415,6 +416,7 @@ util_macros = { path = "crates/util_macros" } vercel = { path = "crates/vercel" } vim = { path = "crates/vim" } vim_mode_setting = { path = "crates/vim_mode_setting" } +which_key = { path = "crates/which_key" } watch = { path = "crates/watch" } web_search = { path = "crates/web_search" } diff --git a/assets/settings/default.json b/assets/settings/default.json index a0e499934428b4bafcbe12b97b2e8fc4747a5f31..a0280b402a0d5c6b71aca296021cc7f43c222521 100644 --- a/assets/settings/default.json +++ b/assets/settings/default.json @@ -2152,6 +2152,13 @@ // The shape can be one of the following: "block", "bar", "underline", "hollow". "cursor_shape": {}, }, + // Which-key popup settings + "which_key": { + // Whether to show the which-key popup when holding down key combinations. + "enabled": false, + // Delay in milliseconds before showing the which-key popup. + "delay_ms": 1000, + }, // The server to connect to. If the environment variable // ZED_SERVER_URL is set, it will override this setting. "server_url": "https://zed.dev", diff --git a/crates/gpui/src/key_dispatch.rs b/crates/gpui/src/key_dispatch.rs index 85aa550fa96ca76e46f8d75ab84e91a7e9ba43cd..1b92b9fe3ffabdbeec4bc7450adc1439e8e223eb 100644 --- a/crates/gpui/src/key_dispatch.rs +++ b/crates/gpui/src/key_dispatch.rs @@ -462,6 +462,17 @@ impl DispatchTree { (bindings, partial, context_stack) } + /// Find the bindings that can follow the current input sequence. + pub fn possible_next_bindings_for_input( + &self, + input: &[Keystroke], + context_stack: &[KeyContext], + ) -> Vec { + self.keymap + .borrow() + .possible_next_bindings_for_input(input, context_stack) + } + /// dispatch_key processes the keystroke /// input should be set to the value of `pending` from the previous call to dispatch_key. /// This returns three instructions to the input handler: diff --git a/crates/gpui/src/keymap.rs b/crates/gpui/src/keymap.rs index 33d956917055942cce365e9069cbb007e202eaf2..d5398ff0447849ca5bfcdbbb5a838af0cbc22836 100644 --- a/crates/gpui/src/keymap.rs +++ b/crates/gpui/src/keymap.rs @@ -215,6 +215,41 @@ impl Keymap { Some(contexts.len()) } } + + /// Find the bindings that can follow the current input sequence. + pub fn possible_next_bindings_for_input( + &self, + input: &[Keystroke], + context_stack: &[KeyContext], + ) -> Vec { + let mut bindings = self + .bindings() + .enumerate() + .rev() + .filter_map(|(ix, binding)| { + let depth = self.binding_enabled(binding, context_stack)?; + let pending = binding.match_keystrokes(input); + match pending { + None => None, + Some(is_pending) => { + if !is_pending || is_no_action(&*binding.action) { + return None; + } + Some((depth, BindingIndex(ix), binding)) + } + } + }) + .collect::>(); + + bindings.sort_by(|(depth_a, ix_a, _), (depth_b, ix_b, _)| { + depth_b.cmp(depth_a).then(ix_b.cmp(ix_a)) + }); + + bindings + .into_iter() + .map(|(_, _, binding)| binding.clone()) + .collect::>() + } } #[cfg(test)] diff --git a/crates/gpui/src/window.rs b/crates/gpui/src/window.rs index dd20f71c22e388e0c739083d45941270ac8eac8e..840f2223fcc4a62b6e522f38b967a3fe4ad3209e 100644 --- a/crates/gpui/src/window.rs +++ b/crates/gpui/src/window.rs @@ -4450,6 +4450,13 @@ impl Window { dispatch_tree.highest_precedence_binding_for_action(action, &context_stack) } + /// Find the bindings that can follow the current input sequence for the current context stack. + pub fn possible_bindings_for_input(&self, input: &[Keystroke]) -> Vec { + self.rendered_frame + .dispatch_tree + .possible_next_bindings_for_input(input, &self.context_stack()) + } + fn context_stack_for_focus_handle( &self, focus_handle: &FocusHandle, diff --git a/crates/settings/src/settings_content.rs b/crates/settings/src/settings_content.rs index 3d7e6b5948b1db4d375814d6969ddabe95fc3e58..a00daaab1b9a93e1ec20b173dd6864849880d55e 100644 --- a/crates/settings/src/settings_content.rs +++ b/crates/settings/src/settings_content.rs @@ -158,6 +158,9 @@ pub struct SettingsContent { /// Default: false pub disable_ai: Option, + /// Settings for the which-key popup. + pub which_key: Option, + /// Settings related to Vim mode in Zed. pub vim: Option, } @@ -976,6 +979,19 @@ pub struct ReplSettingsContent { pub max_columns: Option, } +/// Settings for configuring the which-key popup behaviour. +#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)] +pub struct WhichKeySettingsContent { + /// Whether to show the which-key popup when holding down key combinations + /// + /// Default: false + pub enabled: Option, + /// Delay in milliseconds before showing the which-key popup. + /// + /// Default: 700 + pub delay_ms: Option, +} + #[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)] /// An ExtendingVec in the settings can only accumulate new values. /// diff --git a/crates/settings/src/vscode_import.rs b/crates/settings/src/vscode_import.rs index 587850303f13649fcc4adf8cf4ddbb8dc7181dcb..d77754f611e8eb1746ee9061ce5b5e1dfdbdafdb 100644 --- a/crates/settings/src/vscode_import.rs +++ b/crates/settings/src/vscode_import.rs @@ -215,6 +215,7 @@ impl VsCodeSettings { vim: None, vim_mode: None, workspace: self.workspace_settings_content(), + which_key: None, } } diff --git a/crates/settings_ui/src/page_data.rs b/crates/settings_ui/src/page_data.rs index 1d0603de3184ad9da874b428a94af37d8966e6a2..c8775bad42a9a8bd6aa5e57bafbb817b99619e68 100644 --- a/crates/settings_ui/src/page_data.rs +++ b/crates/settings_ui/src/page_data.rs @@ -1233,6 +1233,49 @@ pub(crate) fn settings_data(cx: &App) -> Vec { } }).collect(), }), + SettingsPageItem::SectionHeader("Which-key Menu"), + SettingsPageItem::SettingItem(SettingItem { + title: "Show Which-key Menu", + description: "Display the which-key menu with matching bindings while a multi-stroke binding is pending.", + field: Box::new(SettingField { + json_path: Some("which_key.enabled"), + pick: |settings_content| { + settings_content + .which_key + .as_ref() + .and_then(|settings| settings.enabled.as_ref()) + }, + write: |settings_content, value| { + settings_content + .which_key + .get_or_insert_default() + .enabled = value; + }, + }), + metadata: None, + files: USER, + }), + SettingsPageItem::SettingItem(SettingItem { + title: "Menu Delay", + description: "Delay in milliseconds before the which-key menu appears.", + field: Box::new(SettingField { + json_path: Some("which_key.delay_ms"), + pick: |settings_content| { + settings_content + .which_key + .as_ref() + .and_then(|settings| settings.delay_ms.as_ref()) + }, + write: |settings_content, value| { + settings_content + .which_key + .get_or_insert_default() + .delay_ms = value; + }, + }), + metadata: None, + files: USER, + }), SettingsPageItem::SectionHeader("Multibuffer"), SettingsPageItem::SettingItem(SettingItem { title: "Double Click In Multibuffer", diff --git a/crates/which_key/Cargo.toml b/crates/which_key/Cargo.toml new file mode 100644 index 0000000000000000000000000000000000000000..f53ba45dd71abc972ce23efb8871f485dfe47207 --- /dev/null +++ b/crates/which_key/Cargo.toml @@ -0,0 +1,23 @@ +[package] +name = "which_key" +version = "0.1.0" +edition.workspace = true +publish.workspace = true +license = "GPL-3.0-or-later" + +[lints] +workspace = true + +[lib] +path = "src/which_key.rs" +doctest = false + +[dependencies] +command_palette.workspace = true +gpui.workspace = true +serde.workspace = true +settings.workspace = true +theme.workspace = true +ui.workspace = true +util.workspace = true +workspace.workspace = true diff --git a/crates/which_key/LICENSE-GPL b/crates/which_key/LICENSE-GPL new file mode 120000 index 0000000000000000000000000000000000000000..89e542f750cd3860a0598eff0dc34b56d7336dc4 --- /dev/null +++ b/crates/which_key/LICENSE-GPL @@ -0,0 +1 @@ +../../LICENSE-GPL \ No newline at end of file diff --git a/crates/which_key/src/which_key.rs b/crates/which_key/src/which_key.rs new file mode 100644 index 0000000000000000000000000000000000000000..70889c100f33020a3ceaa8af1ba8812d5e7d4adb --- /dev/null +++ b/crates/which_key/src/which_key.rs @@ -0,0 +1,98 @@ +//! Which-key support for Zed. + +mod which_key_modal; +mod which_key_settings; + +use gpui::{App, Keystroke}; +use settings::Settings; +use std::{sync::LazyLock, time::Duration}; +use util::ResultExt; +use which_key_modal::WhichKeyModal; +use which_key_settings::WhichKeySettings; +use workspace::Workspace; + +pub fn init(cx: &mut App) { + WhichKeySettings::register(cx); + + cx.observe_new(|_: &mut Workspace, window, cx| { + let Some(window) = window else { + return; + }; + let mut timer = None; + cx.observe_pending_input(window, move |workspace, window, cx| { + if window.pending_input_keystrokes().is_none() { + if let Some(modal) = workspace.active_modal::(cx) { + modal.update(cx, |modal, cx| modal.dismiss(cx)); + }; + timer.take(); + return; + } + + let which_key_settings = WhichKeySettings::get_global(cx); + if !which_key_settings.enabled { + return; + } + + let delay_ms = which_key_settings.delay_ms; + + timer.replace(cx.spawn_in(window, async move |workspace_handle, cx| { + cx.background_executor() + .timer(Duration::from_millis(delay_ms)) + .await; + workspace_handle + .update_in(cx, |workspace, window, cx| { + if workspace.active_modal::(cx).is_some() { + return; + }; + + workspace.toggle_modal(window, cx, |window, cx| { + WhichKeyModal::new(workspace_handle.clone(), window, cx) + }); + }) + .log_err(); + })); + }) + .detach(); + }) + .detach(); +} + +// Hard-coded list of keystrokes to filter out from which-key display +pub static FILTERED_KEYSTROKES: LazyLock>> = LazyLock::new(|| { + [ + // Modifiers on normal vim commands + "g h", + "g j", + "g k", + "g l", + "g $", + "g ^", + // Duplicate keys with "ctrl" held, e.g. "ctrl-w ctrl-a" is duplicate of "ctrl-w a" + "ctrl-w ctrl-a", + "ctrl-w ctrl-c", + "ctrl-w ctrl-h", + "ctrl-w ctrl-j", + "ctrl-w ctrl-k", + "ctrl-w ctrl-l", + "ctrl-w ctrl-n", + "ctrl-w ctrl-o", + "ctrl-w ctrl-p", + "ctrl-w ctrl-q", + "ctrl-w ctrl-s", + "ctrl-w ctrl-v", + "ctrl-w ctrl-w", + "ctrl-w ctrl-]", + "ctrl-w ctrl-shift-w", + "ctrl-w ctrl-g t", + "ctrl-w ctrl-g shift-t", + ] + .iter() + .filter_map(|s| { + let keystrokes: Result, _> = s + .split(' ') + .map(|keystroke_str| Keystroke::parse(keystroke_str)) + .collect(); + keystrokes.ok() + }) + .collect() +}); diff --git a/crates/which_key/src/which_key_modal.rs b/crates/which_key/src/which_key_modal.rs new file mode 100644 index 0000000000000000000000000000000000000000..238431b90a8eafdd0e085a3f109e8f812fbe709b --- /dev/null +++ b/crates/which_key/src/which_key_modal.rs @@ -0,0 +1,308 @@ +//! Modal implementation for the which-key display. + +use gpui::prelude::FluentBuilder; +use gpui::{ + App, Context, DismissEvent, EventEmitter, FocusHandle, Focusable, FontWeight, Keystroke, + ScrollHandle, Subscription, WeakEntity, Window, +}; +use settings::Settings; +use std::collections::HashMap; +use theme::ThemeSettings; +use ui::{ + Divider, DividerColor, DynamicSpacing, LabelSize, WithScrollbar, prelude::*, + text_for_keystrokes, +}; +use workspace::{ModalView, Workspace}; + +use crate::FILTERED_KEYSTROKES; + +pub struct WhichKeyModal { + _workspace: WeakEntity, + focus_handle: FocusHandle, + scroll_handle: ScrollHandle, + bindings: Vec<(SharedString, SharedString)>, + pending_keys: SharedString, + _pending_input_subscription: Subscription, + _focus_out_subscription: Subscription, +} + +impl WhichKeyModal { + pub fn new( + workspace: WeakEntity, + window: &mut Window, + cx: &mut Context, + ) -> Self { + // Keep focus where it currently is + let focus_handle = window.focused(cx).unwrap_or(cx.focus_handle()); + + let handle = cx.weak_entity(); + let mut this = Self { + _workspace: workspace, + focus_handle: focus_handle.clone(), + scroll_handle: ScrollHandle::new(), + bindings: Vec::new(), + pending_keys: SharedString::new_static(""), + _pending_input_subscription: cx.observe_pending_input( + window, + |this: &mut Self, window, cx| { + this.update_pending_keys(window, cx); + }, + ), + _focus_out_subscription: window.on_focus_out(&focus_handle, cx, move |_, _, cx| { + handle.update(cx, |_, cx| cx.emit(DismissEvent)).ok(); + }), + }; + this.update_pending_keys(window, cx); + this + } + + pub fn dismiss(&self, cx: &mut Context) { + cx.emit(DismissEvent) + } + + fn update_pending_keys(&mut self, window: &mut Window, cx: &mut Context) { + let Some(pending_keys) = window.pending_input_keystrokes() else { + cx.emit(DismissEvent); + return; + }; + let bindings = window.possible_bindings_for_input(pending_keys); + + let mut binding_data = bindings + .iter() + .map(|binding| { + // Map to keystrokes + ( + binding + .keystrokes() + .iter() + .map(|k| k.inner().to_owned()) + .collect::>(), + binding.action(), + ) + }) + .filter(|(keystrokes, _action)| { + // Check if this binding matches any filtered keystroke pattern + !FILTERED_KEYSTROKES.iter().any(|filtered| { + keystrokes.len() >= filtered.len() + && keystrokes[..filtered.len()] == filtered[..] + }) + }) + .map(|(keystrokes, action)| { + // Map to remaining keystrokes and action name + let remaining_keystrokes = keystrokes[pending_keys.len()..].to_vec(); + let action_name: SharedString = + command_palette::humanize_action_name(action.name()).into(); + (remaining_keystrokes, action_name) + }) + .collect(); + + binding_data = group_bindings(binding_data); + + // Sort bindings from shortest to longest, with groups last + // Using stable sort to preserve relative order of equal elements + binding_data.sort_by(|(keystrokes_a, action_a), (keystrokes_b, action_b)| { + // Groups (actions starting with "+") should go last + let is_group_a = action_a.starts_with('+'); + let is_group_b = action_b.starts_with('+'); + + // First, separate groups from non-groups + let group_cmp = is_group_a.cmp(&is_group_b); + if group_cmp != std::cmp::Ordering::Equal { + return group_cmp; + } + + // Then sort by keystroke count + let keystroke_cmp = keystrokes_a.len().cmp(&keystrokes_b.len()); + if keystroke_cmp != std::cmp::Ordering::Equal { + return keystroke_cmp; + } + + // Finally sort by text length, then lexicographically for full stability + let text_a = text_for_keystrokes(keystrokes_a, cx); + let text_b = text_for_keystrokes(keystrokes_b, cx); + let text_len_cmp = text_a.len().cmp(&text_b.len()); + if text_len_cmp != std::cmp::Ordering::Equal { + return text_len_cmp; + } + text_a.cmp(&text_b) + }); + binding_data.dedup(); + self.pending_keys = text_for_keystrokes(&pending_keys, cx).into(); + self.bindings = binding_data + .into_iter() + .map(|(keystrokes, action)| (text_for_keystrokes(&keystrokes, cx).into(), action)) + .collect(); + } +} + +impl Render for WhichKeyModal { + fn render(&mut self, window: &mut Window, cx: &mut Context) -> impl IntoElement { + let has_rows = !self.bindings.is_empty(); + let viewport_size = window.viewport_size(); + + let max_panel_width = px((f32::from(viewport_size.width) * 0.5).min(480.0)); + let max_content_height = px(f32::from(viewport_size.height) * 0.4); + + // Push above status bar when visible + let status_height = self + ._workspace + .upgrade() + .and_then(|workspace| { + workspace.read_with(cx, |workspace, cx| { + if workspace.status_bar_visible(cx) { + Some( + DynamicSpacing::Base04.px(cx) * 2.0 + + ThemeSettings::get_global(cx).ui_font_size(cx), + ) + } else { + None + } + }) + }) + .unwrap_or(px(0.)); + + let margin_bottom = px(16.); + let bottom_offset = margin_bottom + status_height; + + // Title section + let title_section = { + let mut column = v_flex().gap(px(0.)).child( + div() + .child( + Label::new(self.pending_keys.clone()) + .size(LabelSize::Default) + .weight(FontWeight::MEDIUM) + .color(Color::Accent), + ) + .mb(px(2.)), + ); + + if has_rows { + column = column.child( + div() + .child(Divider::horizontal().color(DividerColor::BorderFaded)) + .mb(px(2.)), + ); + } + + column + }; + + let content = h_flex() + .items_start() + .id("which-key-content") + .gap(px(8.)) + .overflow_y_scroll() + .track_scroll(&self.scroll_handle) + .h_full() + .max_h(max_content_height) + .child( + // Keystrokes column + v_flex() + .gap(px(4.)) + .flex_shrink_0() + .children(self.bindings.iter().map(|(keystrokes, _)| { + div() + .child( + Label::new(keystrokes.clone()) + .size(LabelSize::Default) + .color(Color::Accent), + ) + .text_align(gpui::TextAlign::Right) + })), + ) + .child( + // Actions column + v_flex() + .gap(px(4.)) + .flex_1() + .min_w_0() + .children(self.bindings.iter().map(|(_, action_name)| { + let is_group = action_name.starts_with('+'); + let label_color = if is_group { + Color::Success + } else { + Color::Default + }; + + div().child( + Label::new(action_name.clone()) + .size(LabelSize::Default) + .color(label_color) + .single_line() + .truncate(), + ) + })), + ); + + div() + .id("which-key-buffer-panel-scroll") + .occlude() + .absolute() + .bottom(bottom_offset) + .right(px(16.)) + .min_w(px(220.)) + .max_w(max_panel_width) + .elevation_3(cx) + .px(px(12.)) + .child(v_flex().child(title_section).when(has_rows, |el| { + el.child( + div() + .max_h(max_content_height) + .child(content) + .vertical_scrollbar_for(&self.scroll_handle, window, cx), + ) + })) + } +} + +impl EventEmitter for WhichKeyModal {} + +impl Focusable for WhichKeyModal { + fn focus_handle(&self, _cx: &App) -> gpui::FocusHandle { + self.focus_handle.clone() + } +} + +impl ModalView for WhichKeyModal { + fn render_bare(&self) -> bool { + true + } +} + +fn group_bindings( + binding_data: Vec<(Vec, SharedString)>, +) -> Vec<(Vec, SharedString)> { + let mut groups: HashMap, Vec<(Vec, SharedString)>> = + HashMap::new(); + + // Group bindings by their first keystroke + for (remaining_keystrokes, action_name) in binding_data { + let first_key = remaining_keystrokes.first().cloned(); + groups + .entry(first_key) + .or_default() + .push((remaining_keystrokes, action_name)); + } + + let mut result = Vec::new(); + + for (first_key, mut group_bindings) in groups { + // Remove duplicates within each group + group_bindings.dedup_by_key(|(keystrokes, _)| keystrokes.clone()); + + if let Some(first_key) = first_key + && group_bindings.len() > 1 + { + // This is a group - create a single entry with just the first keystroke + let first_keystroke = vec![first_key]; + let count = group_bindings.len(); + result.push((first_keystroke, format!("+{} keybinds", count).into())); + } else { + // Not a group or empty keystrokes - add all bindings as-is + result.append(&mut group_bindings); + } + } + + result +} diff --git a/crates/which_key/src/which_key_settings.rs b/crates/which_key/src/which_key_settings.rs new file mode 100644 index 0000000000000000000000000000000000000000..be19ab1521f4793305efca79b7026f79fd9064e2 --- /dev/null +++ b/crates/which_key/src/which_key_settings.rs @@ -0,0 +1,18 @@ +use settings::{RegisterSetting, Settings, SettingsContent, WhichKeySettingsContent}; + +#[derive(Debug, Clone, Copy, RegisterSetting)] +pub struct WhichKeySettings { + pub enabled: bool, + pub delay_ms: u64, +} + +impl Settings for WhichKeySettings { + fn from_settings(content: &SettingsContent) -> Self { + let which_key: &WhichKeySettingsContent = content.which_key.as_ref().unwrap(); + + Self { + enabled: which_key.enabled.unwrap(), + delay_ms: which_key.delay_ms.unwrap(), + } + } +} diff --git a/crates/workspace/src/modal_layer.rs b/crates/workspace/src/modal_layer.rs index 10b24497a28faf68ed0820211f0d8860da558786..db4d85752835299117dba7fc2aeb1833383a390a 100644 --- a/crates/workspace/src/modal_layer.rs +++ b/crates/workspace/src/modal_layer.rs @@ -22,12 +22,17 @@ pub trait ModalView: ManagedView { fn fade_out_background(&self) -> bool { false } + + fn render_bare(&self) -> bool { + false + } } trait ModalViewHandle { fn on_before_dismiss(&mut self, window: &mut Window, cx: &mut App) -> DismissDecision; fn view(&self) -> AnyView; fn fade_out_background(&self, cx: &mut App) -> bool; + fn render_bare(&self, cx: &mut App) -> bool; } impl ModalViewHandle for Entity { @@ -42,6 +47,10 @@ impl ModalViewHandle for Entity { fn fade_out_background(&self, cx: &mut App) -> bool { self.read(cx).fade_out_background() } + + fn render_bare(&self, cx: &mut App) -> bool { + self.read(cx).render_bare() + } } pub struct ActiveModal { @@ -167,9 +176,13 @@ impl ModalLayer { impl Render for ModalLayer { fn render(&mut self, _: &mut Window, cx: &mut Context) -> impl IntoElement { let Some(active_modal) = &self.active_modal else { - return div(); + return div().into_any_element(); }; + if active_modal.modal.render_bare(cx) { + return active_modal.modal.view().into_any_element(); + } + div() .absolute() .size_full() @@ -195,5 +208,6 @@ impl Render for ModalLayer { }), ), ) + .into_any_element() } } diff --git a/crates/zed/Cargo.toml b/crates/zed/Cargo.toml index b5b33850da8da9035276c7752ad72da9bf0b55b9..fd160759f4440e2736d57cea62abb6bdb138ae72 100644 --- a/crates/zed/Cargo.toml +++ b/crates/zed/Cargo.toml @@ -163,6 +163,7 @@ vim_mode_setting.workspace = true watch.workspace = true web_search.workspace = true web_search_providers.workspace = true +which_key.workspace = true workspace.workspace = true zed_actions.workspace = true zed_env_vars.workspace = true diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rs index a827e33f00935bb02e4bc9f761d673ab12a32f14..7008e491c5e2ade35fa96cafbd9d8969c008fa96 100644 --- a/crates/zed/src/main.rs +++ b/crates/zed/src/main.rs @@ -656,6 +656,7 @@ pub fn main() { inspector_ui::init(app_state.clone(), cx); json_schema_store::init(cx); miniprofiler_ui::init(*STARTUP_TIME.get().unwrap(), cx); + which_key::init(cx); cx.observe_global::({ let http = app_state.client.http_client(); From 27c5d39d285e56b6b77d751268690fcfe411d6b4 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Wed, 17 Dec 2025 13:56:15 -0500 Subject: [PATCH 459/621] Add Gemini 3 Flash (#45139) Add support for the new Gemini 3 Flash model Release Notes: - Added support for Gemini 3 Flash model --- crates/google_ai/src/google_ai.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crates/google_ai/src/google_ai.rs b/crates/google_ai/src/google_ai.rs index 3eff860e16f15fae76d8f9cb2523d2b91b611125..b6bba48c4b04608b502932787cfcdcd429276b5b 100644 --- a/crates/google_ai/src/google_ai.rs +++ b/crates/google_ai/src/google_ai.rs @@ -512,6 +512,8 @@ pub enum Model { Gemini25Pro, #[serde(rename = "gemini-3-pro-preview")] Gemini3Pro, + #[serde(rename = "gemini-3-flash-preview")] + Gemini3Flash, #[serde(rename = "custom")] Custom { name: String, @@ -534,6 +536,7 @@ impl Model { Self::Gemini25Flash => "gemini-2.5-flash", Self::Gemini25Pro => "gemini-2.5-pro", Self::Gemini3Pro => "gemini-3-pro-preview", + Self::Gemini3Flash => "gemini-3-flash-preview", Self::Custom { name, .. } => name, } } @@ -543,6 +546,7 @@ impl Model { Self::Gemini25Flash => "gemini-2.5-flash", Self::Gemini25Pro => "gemini-2.5-pro", Self::Gemini3Pro => "gemini-3-pro-preview", + Self::Gemini3Flash => "gemini-3-flash-preview", Self::Custom { name, .. } => name, } } @@ -553,6 +557,7 @@ impl Model { Self::Gemini25Flash => "Gemini 2.5 Flash", Self::Gemini25Pro => "Gemini 2.5 Pro", Self::Gemini3Pro => "Gemini 3 Pro", + Self::Gemini3Flash => "Gemini 3 Flash", Self::Custom { name, display_name, .. } => display_name.as_ref().unwrap_or(name), @@ -565,6 +570,7 @@ impl Model { Self::Gemini25Flash => 1_048_576, Self::Gemini25Pro => 1_048_576, Self::Gemini3Pro => 1_048_576, + Self::Gemini3Flash => 1_048_576, Self::Custom { max_tokens, .. } => *max_tokens, } } @@ -575,6 +581,7 @@ impl Model { Model::Gemini25Flash => Some(65_536), Model::Gemini25Pro => Some(65_536), Model::Gemini3Pro => Some(65_536), + Model::Gemini3Flash => Some(65_536), Model::Custom { .. } => None, } } @@ -599,6 +606,7 @@ impl Model { budget_tokens: None, } } + Self::Gemini3Flash => GoogleModelMode::Default, Self::Custom { mode, .. } => *mode, } } From fa529b2ad272881aa45c66242ad02934cb22d624 Mon Sep 17 00:00:00 2001 From: "Oleksii (Alexey) Orlenko" Date: Wed, 17 Dec 2025 20:00:37 +0100 Subject: [PATCH 460/621] agent_ui_v2: Fix broken LICENSE-GPL symlink pointing to itself (#45136) Fix broken LICENSE-GPL symlink that was pointing to itself instead of the LICENSE-GPL file in the root of the repo. It caused jujutsu to freak out and made it impossible to work with the repo using it without switching to raw git: ``` Internal error: Failed to check out commit 22d04a82b119882e7aed88fb422430367c4df5f9 Caused by: 1: Failed to validate path /Users/aqrln/git/zed/crates/agent_ui_v2/LICENSE-GPL 2: Too many levels of symbolic links (os error 62) ``` Release Notes: - N/A --- crates/agent_ui_v2/LICENSE-GPL | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/agent_ui_v2/LICENSE-GPL b/crates/agent_ui_v2/LICENSE-GPL index e0f9dbd5d63fef1630c297edc4ceba4790be6f02..89e542f750cd3860a0598eff0dc34b56d7336dc4 120000 --- a/crates/agent_ui_v2/LICENSE-GPL +++ b/crates/agent_ui_v2/LICENSE-GPL @@ -1 +1 @@ -LICENSE-GPL \ No newline at end of file +../../LICENSE-GPL \ No newline at end of file From 73f129a6858098b485ce2321e7141d30da815280 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Coss=C3=ADo?= Date: Wed, 17 Dec 2025 16:40:15 -0300 Subject: [PATCH 461/621] git: New actions for git panel navigation (#43701) I could not find any related issue, but at least I want to use the git panel like this :) Being used to `lazygit`, this PR makes navigation of the git panel more similar to the CLI tool. Instead of selecting -> enter'ing for skimming each file, I just want to move between the files in the git panel and have the diff multibuffer advance to the appropriate file. This also adheres to the behavior of the outline panel, which I like better. If the multibuffer is not active, it behaves same as before (just selecting the file in the panel, nothing else). I did not modify existing `menu::Select*` actions in case anybody still prefers previous behavior. https://github.com/user-attachments/assets/2d1303d4-50c8-4500-ab3b-302eb7d4afda Release Notes: - Improved navigation of the git panel, by advancing the "Uncommitted Changes" multibuffer to the current selected file. To restore the old behavior, you can bind `up` and `down` to `menu::SelectPrevious` and `menu::SelectNext` under the `GitPanel` context in your keymap. Co-authored-by: Cole Miller --- assets/keymaps/default-linux.json | 4 +- assets/keymaps/default-macos.json | 8 +-- assets/keymaps/default-windows.json | 4 +- crates/git_ui/src/git_panel.rs | 80 ++++++++++++++++++++++++----- 4 files changed, 75 insertions(+), 21 deletions(-) diff --git a/assets/keymaps/default-linux.json b/assets/keymaps/default-linux.json index f09ac0a812c3e875618c57da15bcf16e1f983d6e..ec21bc152edf969f57ac341e4b92f78c9e5da11a 100644 --- a/assets/keymaps/default-linux.json +++ b/assets/keymaps/default-linux.json @@ -905,8 +905,8 @@ "bindings": { "left": "git_panel::CollapseSelectedEntry", "right": "git_panel::ExpandSelectedEntry", - "up": "menu::SelectPrevious", - "down": "menu::SelectNext", + "up": "git_panel::PreviousEntry", + "down": "git_panel::NextEntry", "enter": "menu::Confirm", "alt-y": "git::StageFile", "alt-shift-y": "git::UnstageFile", diff --git a/assets/keymaps/default-macos.json b/assets/keymaps/default-macos.json index 1d489771febc770e300b63e265024ffca3d14a90..fd2605a6ad99177c887d6f804ec2ac70724f16f8 100644 --- a/assets/keymaps/default-macos.json +++ b/assets/keymaps/default-macos.json @@ -981,12 +981,12 @@ "context": "GitPanel && ChangesList", "use_key_equivalents": true, "bindings": { + "up": "git_panel::PreviousEntry", + "down": "git_panel::NextEntry", + "cmd-up": "git_panel::FirstEntry", + "cmd-down": "git_panel::LastEntry", "left": "git_panel::CollapseSelectedEntry", "right": "git_panel::ExpandSelectedEntry", - "up": "menu::SelectPrevious", - "down": "menu::SelectNext", - "cmd-up": "menu::SelectFirst", - "cmd-down": "menu::SelectLast", "enter": "menu::Confirm", "cmd-alt-y": "git::ToggleStaged", "space": "git::ToggleStaged", diff --git a/assets/keymaps/default-windows.json b/assets/keymaps/default-windows.json index 9154cc43afb86c287329229c6f0d699f59a82b36..4a700e2c9190a8ae23ed53edaa075703fa07b855 100644 --- a/assets/keymaps/default-windows.json +++ b/assets/keymaps/default-windows.json @@ -908,10 +908,10 @@ "context": "GitPanel && ChangesList", "use_key_equivalents": true, "bindings": { + "up": "git_panel::PreviousEntry", + "down": "git_panel::NextEntry", "left": "git_panel::CollapseSelectedEntry", "right": "git_panel::ExpandSelectedEntry", - "up": "menu::SelectPrevious", - "down": "menu::SelectNext", "enter": "menu::Confirm", "alt-y": "git::StageFile", "shift-alt-y": "git::UnstageFile", diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs index cf73406b3851b46ad1a7d056d6cb335666b9ac65..90c9b92cf882f25f50cebab776fc328a22cda022 100644 --- a/crates/git_ui/src/git_panel.rs +++ b/crates/git_ui/src/git_panel.rs @@ -46,7 +46,7 @@ use language_model::{ ConfiguredModel, LanguageModelRegistry, LanguageModelRequest, LanguageModelRequestMessage, Role, ZED_CLOUD_PROVIDER_ID, }; -use menu::{Confirm, SecondaryConfirm, SelectFirst, SelectLast, SelectNext, SelectPrevious}; +use menu; use multi_buffer::ExcerptInfo; use notifications::status_toast::{StatusToast, ToastIcon}; use panel::{ @@ -93,6 +93,14 @@ actions!( FocusEditor, /// Focuses on the changes list. FocusChanges, + /// Select next git panel menu item, and show it in the diff view + NextEntry, + /// Select previous git panel menu item, and show it in the diff view + PreviousEntry, + /// Select first git panel menu item, and show it in the diff view + FirstEntry, + /// Select last git panel menu item, and show it in the diff view + LastEntry, /// Toggles automatic co-author suggestions. ToggleFillCoAuthors, /// Toggles sorting entries by path vs status. @@ -914,12 +922,12 @@ impl GitPanel { if let GitListEntry::Directory(dir_entry) = entry { if dir_entry.expanded { - self.select_next(&SelectNext, window, cx); + self.select_next(&menu::SelectNext, window, cx); } else { self.toggle_directory(&dir_entry.key, window, cx); } } else { - self.select_next(&SelectNext, window, cx); + self.select_next(&menu::SelectNext, window, cx); } } @@ -937,14 +945,19 @@ impl GitPanel { if dir_entry.expanded { self.toggle_directory(&dir_entry.key, window, cx); } else { - self.select_previous(&SelectPrevious, window, cx); + self.select_previous(&menu::SelectPrevious, window, cx); } } else { - self.select_previous(&SelectPrevious, window, cx); + self.select_previous(&menu::SelectPrevious, window, cx); } } - fn select_first(&mut self, _: &SelectFirst, _window: &mut Window, cx: &mut Context) { + fn select_first( + &mut self, + _: &menu::SelectFirst, + _window: &mut Window, + cx: &mut Context, + ) { let first_entry = match &self.view_mode { GitPanelViewMode::Flat => self .entries @@ -967,7 +980,7 @@ impl GitPanel { fn select_previous( &mut self, - _: &SelectPrevious, + _: &menu::SelectPrevious, _window: &mut Window, cx: &mut Context, ) { @@ -1016,7 +1029,7 @@ impl GitPanel { self.scroll_to_selected_entry(cx); } - fn select_next(&mut self, _: &SelectNext, _window: &mut Window, cx: &mut Context) { + fn select_next(&mut self, _: &menu::SelectNext, _window: &mut Window, cx: &mut Context) { let item_count = self.entries.len(); if item_count == 0 { return; @@ -1054,13 +1067,50 @@ impl GitPanel { self.scroll_to_selected_entry(cx); } - fn select_last(&mut self, _: &SelectLast, _window: &mut Window, cx: &mut Context) { + fn select_last(&mut self, _: &menu::SelectLast, _window: &mut Window, cx: &mut Context) { if self.entries.last().is_some() { self.selected_entry = Some(self.entries.len() - 1); self.scroll_to_selected_entry(cx); } } + /// Show diff view at selected entry, only if the diff view is open + fn move_diff_to_entry(&mut self, window: &mut Window, cx: &mut Context) { + maybe!({ + let workspace = self.workspace.upgrade()?; + + if let Some(project_diff) = workspace.read(cx).item_of_type::(cx) { + let entry = self.entries.get(self.selected_entry?)?.status_entry()?; + + project_diff.update(cx, |project_diff, cx| { + project_diff.move_to_entry(entry.clone(), window, cx); + }); + } + + Some(()) + }); + } + + fn first_entry(&mut self, _: &FirstEntry, window: &mut Window, cx: &mut Context) { + self.select_first(&menu::SelectFirst, window, cx); + self.move_diff_to_entry(window, cx); + } + + fn last_entry(&mut self, _: &LastEntry, window: &mut Window, cx: &mut Context) { + self.select_last(&menu::SelectLast, window, cx); + self.move_diff_to_entry(window, cx); + } + + fn next_entry(&mut self, _: &NextEntry, window: &mut Window, cx: &mut Context) { + self.select_next(&menu::SelectNext, window, cx); + self.move_diff_to_entry(window, cx); + } + + fn previous_entry(&mut self, _: &PreviousEntry, window: &mut Window, cx: &mut Context) { + self.select_previous(&menu::SelectPrevious, window, cx); + self.move_diff_to_entry(window, cx); + } + fn focus_editor(&mut self, _: &FocusEditor, window: &mut Window, cx: &mut Context) { self.commit_editor.update(cx, |editor, cx| { window.focus(&editor.focus_handle(cx), cx); @@ -1074,7 +1124,7 @@ impl GitPanel { .as_ref() .is_some_and(|active_repository| active_repository.read(cx).status_summary().count > 0); if have_entries && self.selected_entry.is_none() { - self.select_first(&SelectFirst, window, cx); + self.select_first(&menu::SelectFirst, window, cx); } } @@ -4726,8 +4776,8 @@ impl GitPanel { git::AddToGitignore.boxed_clone(), ) .separator() - .action("Open Diff", Confirm.boxed_clone()) - .action("Open File", SecondaryConfirm.boxed_clone()) + .action("Open Diff", menu::Confirm.boxed_clone()) + .action("Open File", menu::SecondaryConfirm.boxed_clone()) .separator() .action_disabled_when(is_created, "View File History", Box::new(git::FileHistory)) }); @@ -5390,6 +5440,10 @@ impl Render for GitPanel { .on_action(cx.listener(Self::select_next)) .on_action(cx.listener(Self::select_previous)) .on_action(cx.listener(Self::select_last)) + .on_action(cx.listener(Self::first_entry)) + .on_action(cx.listener(Self::next_entry)) + .on_action(cx.listener(Self::previous_entry)) + .on_action(cx.listener(Self::last_entry)) .on_action(cx.listener(Self::close_panel)) .on_action(cx.listener(Self::open_diff)) .on_action(cx.listener(Self::open_file)) @@ -6855,7 +6909,7 @@ mod tests { // the Project Diff's active path. panel.update_in(cx, |panel, window, cx| { panel.selected_entry = Some(1); - panel.open_diff(&Confirm, window, cx); + panel.open_diff(&menu::Confirm, window, cx); }); cx.run_until_parked(); From e8807e5764e370822fde859200279a7e963e1980 Mon Sep 17 00:00:00 2001 From: Xipeng Jin <56369076+xipeng-jin@users.noreply.github.com> Date: Wed, 17 Dec 2025 14:43:53 -0500 Subject: [PATCH 462/621] git: Fix tree view folders not opening when file inside is selected (#45137) Closes #44715 Release Notes: - Fixed git tree view folders don't open when file inside is selected --- crates/git_ui/src/git_panel.rs | 190 +++++++++++++++++++++++++++++++-- 1 file changed, 184 insertions(+), 6 deletions(-) diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs index 90c9b92cf882f25f50cebab776fc328a22cda022..7216e1fc46e9d1240d23d8bd18202aa0963f846a 100644 --- a/crates/git_ui/src/git_panel.rs +++ b/crates/git_ui/src/git_panel.rs @@ -801,20 +801,63 @@ impl GitPanel { pub fn select_entry_by_path( &mut self, path: ProjectPath, - _: &mut Window, + window: &mut Window, cx: &mut Context, ) { let Some(git_repo) = self.active_repository.as_ref() else { return; }; - let Some(repo_path) = git_repo.read(cx).project_path_to_repo_path(&path, cx) else { - return; + + let (repo_path, section) = { + let repo = git_repo.read(cx); + let Some(repo_path) = repo.project_path_to_repo_path(&path, cx) else { + return; + }; + + let section = repo + .status_for_path(&repo_path) + .map(|status| status.status) + .map(|status| { + if repo.had_conflict_on_last_merge_head_change(&repo_path) { + Section::Conflict + } else if status.is_created() { + Section::New + } else { + Section::Tracked + } + }); + + (repo_path, section) }; + + let mut needs_rebuild = false; + if let (Some(section), Some(tree_state)) = (section, self.view_mode.tree_state_mut()) { + let mut current_dir = repo_path.parent(); + while let Some(dir) = current_dir { + let key = TreeKey { + section, + path: RepoPath::from_rel_path(dir), + }; + + if tree_state.expanded_dirs.get(&key) == Some(&false) { + tree_state.expanded_dirs.insert(key, true); + needs_rebuild = true; + } + + current_dir = dir.parent(); + } + } + + if needs_rebuild { + self.update_visible_entries(window, cx); + } + let Some(ix) = self.entry_by_path(&repo_path) else { return; }; + self.selected_entry = Some(ix); - cx.notify(); + self.scroll_to_selected_entry(cx); } fn serialization_key(workspace: &Workspace) -> Option { @@ -902,9 +945,22 @@ impl GitPanel { } fn scroll_to_selected_entry(&mut self, cx: &mut Context) { - if let Some(selected_entry) = self.selected_entry { + let Some(selected_entry) = self.selected_entry else { + cx.notify(); + return; + }; + + let visible_index = match &self.view_mode { + GitPanelViewMode::Flat => Some(selected_entry), + GitPanelViewMode::Tree(state) => state + .logical_indices + .iter() + .position(|&ix| ix == selected_entry), + }; + + if let Some(visible_index) = visible_index { self.scroll_handle - .scroll_to_item(selected_entry, ScrollStrategy::Center); + .scroll_to_item(visible_index, ScrollStrategy::Center); } cx.notify(); @@ -6925,6 +6981,128 @@ mod tests { }); } + #[gpui::test] + async fn test_tree_view_reveals_collapsed_parent_on_select_entry_by_path( + cx: &mut TestAppContext, + ) { + init_test(cx); + + let fs = FakeFs::new(cx.background_executor.clone()); + fs.insert_tree( + path!("/project"), + json!({ + ".git": {}, + "src": { + "a": { + "foo.rs": "fn foo() {}", + }, + "b": { + "bar.rs": "fn bar() {}", + }, + }, + }), + ) + .await; + + fs.set_status_for_repo( + path!("/project/.git").as_ref(), + &[ + ("src/a/foo.rs", StatusCode::Modified.worktree()), + ("src/b/bar.rs", StatusCode::Modified.worktree()), + ], + ); + + let project = Project::test(fs.clone(), [Path::new(path!("/project"))], cx).await; + let workspace = + cx.add_window(|window, cx| Workspace::test_new(project.clone(), window, cx)); + let cx = &mut VisualTestContext::from_window(*workspace, cx); + + cx.read(|cx| { + project + .read(cx) + .worktrees(cx) + .next() + .unwrap() + .read(cx) + .as_local() + .unwrap() + .scan_complete() + }) + .await; + + cx.executor().run_until_parked(); + + cx.update(|_window, cx| { + SettingsStore::update_global(cx, |store, cx| { + store.update_user_settings(cx, |settings| { + settings.git_panel.get_or_insert_default().tree_view = Some(true); + }) + }); + }); + + let panel = workspace.update(cx, GitPanel::new).unwrap(); + + let handle = cx.update_window_entity(&panel, |panel, _, _| { + std::mem::replace(&mut panel.update_visible_entries_task, Task::ready(())) + }); + cx.executor().advance_clock(2 * UPDATE_DEBOUNCE); + handle.await; + + let src_key = panel.read_with(cx, |panel, _| { + panel + .entries + .iter() + .find_map(|entry| match entry { + GitListEntry::Directory(dir) if dir.key.path == repo_path("src") => { + Some(dir.key.clone()) + } + _ => None, + }) + .expect("src directory should exist in tree view") + }); + + panel.update_in(cx, |panel, window, cx| { + panel.toggle_directory(&src_key, window, cx); + }); + + panel.read_with(cx, |panel, _| { + let state = panel + .view_mode + .tree_state() + .expect("tree view state should exist"); + assert_eq!(state.expanded_dirs.get(&src_key).copied(), Some(false)); + }); + + let worktree_id = + cx.read(|cx| project.read(cx).worktrees(cx).next().unwrap().read(cx).id()); + let project_path = ProjectPath { + worktree_id, + path: RelPath::unix("src/a/foo.rs").unwrap().into_arc(), + }; + + panel.update_in(cx, |panel, window, cx| { + panel.select_entry_by_path(project_path, window, cx); + }); + + panel.read_with(cx, |panel, _| { + let state = panel + .view_mode + .tree_state() + .expect("tree view state should exist"); + assert_eq!(state.expanded_dirs.get(&src_key).copied(), Some(true)); + + let selected_ix = panel.selected_entry.expect("selection should be set"); + assert!(state.logical_indices.contains(&selected_ix)); + + let selected_entry = panel + .entries + .get(selected_ix) + .and_then(|entry| entry.status_entry()) + .expect("selected entry should be a status entry"); + assert_eq!(selected_entry.repo_path, repo_path("src/a/foo.rs")); + }); + } + fn assert_entry_paths(entries: &[GitListEntry], expected_paths: &[Option<&str>]) { assert_eq!(entries.len(), expected_paths.len()); for (entry, expected_path) in entries.iter().zip(expected_paths) { From 81463223d5cc887bac5a8b54f5b7000fd136f5fd Mon Sep 17 00:00:00 2001 From: Ichimura Tomoo Date: Thu, 18 Dec 2025 04:46:17 +0900 Subject: [PATCH 463/621] Support opening and saving files with legacy encodings (#44819) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary Addresses #16965 This PR adds support for **opening and saving** files with legacy encodings (non-UTF-8). Previously, Zed failed to open files encoded in Shift-JIS, EUC-JP, Big5, etc., displaying a "Could not open file" error screen. This PR implements automatic encoding detection upon opening and ensures the original encoding is preserved when saving. ## Implementation Details 1. **Worktree (Loading)**: * Updated `load_file` to use `chardetng` for automatic encoding detection. * Files are decoded to UTF-8 internal strings for editing, while preserving the detected `Encoding` metadata. 2. **Language / Buffer**: * Added an `encoding` field to the `Buffer` struct to store the detected encoding. 3. **Worktree (Saving)**: * Updated `write_file` to accept the stored encoding. * **Performance Optimization**: * **UTF-8 Path**: Uses the existing optimized `fs.save` (streaming chunks directly from Rope), ensuring no performance regression for the vast majority of files. * **Legacy Encoding Path**: Implemented a fallback that converts the Rope to a contiguous `String/Bytes` in memory, re-encodes it to the target format (e.g., Shift-JIS), and writes it to disk. * *Note*: This fallback involves memory allocation, but it is necessary to support legacy encodings without refactoring the `fs` crate's streaming interfaces. ## Changes - `crates/worktree`: - Add dependencies: `encoding_rs`, `chardetng`. - Update `load_file` to detect encoding and decode content. - Update `write_file` to handle re-encoding on save. - `crates/language`: Add `encoding` field and accessors to `Buffer`. - `crates/project`: Pass encoding information between Worktree and Buffer. - `crates/vim`: Update `:w` command to use the new `write_file` signature. ## Verification I validated this manually using a Rust script to generate test files with various encodings. **Results:** * ✅ **Success (Opened & Saved correctly):** * **Japanese:** `Shift-JIS` (CP932), `EUC-JP`, `ISO-2022-JP` * **Chinese:** `Big5` (Traditional), `GBK/GB2312` (Simplified) * **Western/Unicode:** `Windows-1252` (CP1252), `UTF-16LE`, `UTF-16BE` * ⚠️ **limitations (Detection accuracy):** * Some specific encodings like `KOI8-R` or generic `Latin1` (ISO-8859-1) may partially display replacement characters (`?`) depending on the file content length. This is a known limitation of the heuristic detection library (`chardetng`) rather than the saving logic. Release Notes: - Added support for opening and saving files with legacy encodings (Shift-JIS, Big5, etc.) --------- Co-authored-by: CrazyboyQCD <53971641+CrazyboyQCD@users.noreply.github.com> Co-authored-by: Conrad Irwin --- Cargo.lock | 39 ++++-- Cargo.toml | 2 + crates/editor/src/editor_tests.rs | 10 +- crates/language/Cargo.toml | 1 + crates/language/src/buffer.rs | 25 ++++ crates/project/Cargo.toml | 1 + crates/project/src/buffer_store.rs | 10 +- crates/project/src/project.rs | 12 +- crates/vim/src/command.rs | 6 +- crates/worktree/Cargo.toml | 2 + crates/worktree/src/worktree.rs | 104 +++++++++++++- crates/worktree/src/worktree_tests.rs | 191 +++++++++++++++++++++++++- 12 files changed, 373 insertions(+), 30 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 146f0e19741610d3676d7781fa74982ff2e55918..86b551b1895a0fd6747c35c3fcfe3859396665fa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2667,9 +2667,9 @@ dependencies = [ [[package]] name = "cap-fs-ext" -version = "3.4.5" +version = "3.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5528f85b1e134ae811704e41ef80930f56e795923f866813255bc342cc20654" +checksum = "e41cc18551193fe8fa6f15c1e3c799bc5ec9e2cfbfaa8ed46f37013e3e6c173c" dependencies = [ "cap-primitives", "cap-std", @@ -2679,9 +2679,9 @@ dependencies = [ [[package]] name = "cap-net-ext" -version = "3.4.5" +version = "3.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20a158160765c6a7d0d8c072a53d772e4cb243f38b04bfcf6b4939cfbe7482e7" +checksum = "9f83833816c66c986e913b22ac887cec216ea09301802054316fc5301809702c" dependencies = [ "cap-primitives", "cap-std", @@ -2691,9 +2691,9 @@ dependencies = [ [[package]] name = "cap-primitives" -version = "3.4.5" +version = "3.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6cf3aea8a5081171859ef57bc1606b1df6999df4f1110f8eef68b30098d1d3a" +checksum = "0a1e394ed14f39f8bc26f59d4c0c010dbe7f0a1b9bafff451b1f98b67c8af62a" dependencies = [ "ambient-authority", "fs-set-times", @@ -2709,9 +2709,9 @@ dependencies = [ [[package]] name = "cap-rand" -version = "3.4.5" +version = "3.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8144c22e24bbcf26ade86cb6501a0916c46b7e4787abdb0045a467eb1645a1d" +checksum = "0acb89ccf798a28683f00089d0630dfaceec087234eae0d308c05ddeaa941b40" dependencies = [ "ambient-authority", "rand 0.8.5", @@ -2719,9 +2719,9 @@ dependencies = [ [[package]] name = "cap-std" -version = "3.4.5" +version = "3.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6dc3090992a735d23219de5c204927163d922f42f575a0189b005c62d37549a" +checksum = "07c0355ca583dd58f176c3c12489d684163861ede3c9efa6fd8bba314c984189" dependencies = [ "cap-primitives", "io-extras", @@ -2731,9 +2731,9 @@ dependencies = [ [[package]] name = "cap-time-ext" -version = "3.4.5" +version = "3.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "def102506ce40c11710a9b16e614af0cde8e76ae51b1f48c04b8d79f4b671a80" +checksum = "491af520b8770085daa0466978c75db90368c71896523f2464214e38359b1a5b" dependencies = [ "ambient-authority", "cap-primitives", @@ -2896,6 +2896,17 @@ dependencies = [ "util", ] +[[package]] +name = "chardetng" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14b8f0b65b7b08ae3c8187e8d77174de20cb6777864c6b832d8ad365999cf1ea" +dependencies = [ + "cfg-if", + "encoding_rs", + "memchr", +] + [[package]] name = "chrono" version = "0.4.42" @@ -8797,6 +8808,7 @@ dependencies = [ "ctor", "diffy", "ec4rs", + "encoding_rs", "fs", "futures 0.3.31", "fuzzy", @@ -12465,6 +12477,7 @@ dependencies = [ "dap", "dap_adapters", "db", + "encoding_rs", "extension", "fancy-regex", "fs", @@ -20231,8 +20244,10 @@ version = "0.1.0" dependencies = [ "anyhow", "async-lock 2.8.0", + "chardetng", "clock", "collections", + "encoding_rs", "fs", "futures 0.3.31", "fuzzy", diff --git a/Cargo.toml b/Cargo.toml index 13bb4ceea133e16e8cf89461cd1fe7084d448eae..703a34b63af901886e861dba3177e58b19c223f0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -478,6 +478,7 @@ bytes = "1.0" cargo_metadata = "0.19" cargo_toml = "0.21" cfg-if = "1.0.3" +chardetng = "0.1" chrono = { version = "0.4", features = ["serde"] } ciborium = "0.2" circular-buffer = "1.0" @@ -501,6 +502,7 @@ dotenvy = "0.15.0" ec4rs = "1.1" emojis = "0.6.1" env_logger = "0.11" +encoding_rs = "0.8" exec = "0.3.1" fancy-regex = "0.16.0" fork = "0.4.0" diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rs index 1b84197471bd9ad65dc0ac31bf42c6ddc5ee3bf5..48e59f7b7420473054214572a2908215f98ffded 100644 --- a/crates/editor/src/editor_tests.rs +++ b/crates/editor/src/editor_tests.rs @@ -69,7 +69,6 @@ use util::{ use workspace::{ CloseActiveItem, CloseAllItems, CloseOtherItems, MoveItemToPaneInDirection, NavigationEntry, OpenOptions, ViewId, - invalid_item_view::InvalidItemView, item::{FollowEvent, FollowableItem, Item, ItemHandle, SaveOptions}, register_project_item, }; @@ -27667,11 +27666,10 @@ async fn test_non_utf_8_opens(cx: &mut TestAppContext) { }) .await .unwrap(); - - assert_eq!( - handle.to_any_view().entity_type(), - TypeId::of::() - ); + // The test file content `vec![0xff, 0xfe, ...]` starts with a UTF-16 LE BOM. + // Previously, this fell back to `InvalidItemView` because it wasn't valid UTF-8. + // With auto-detection enabled, this is now recognized as UTF-16 and opens in the Editor. + assert_eq!(handle.to_any_view().entity_type(), TypeId::of::()); } #[gpui::test] diff --git a/crates/language/Cargo.toml b/crates/language/Cargo.toml index 3ba93476d2a9fa5371b9d146cfc0c5833a748842..06d41e729bfabbf4f7e050409d2675dd909941d6 100644 --- a/crates/language/Cargo.toml +++ b/crates/language/Cargo.toml @@ -32,6 +32,7 @@ async-trait.workspace = true clock.workspace = true collections.workspace = true ec4rs.workspace = true +encoding_rs.workspace = true fs.workspace = true futures.workspace = true fuzzy.workspace = true diff --git a/crates/language/src/buffer.rs b/crates/language/src/buffer.rs index 39003773f83718c6c61d4cfda55b9528f7c6eb2a..abf4d9b10a761b9c0247145e8ddb0664127756d2 100644 --- a/crates/language/src/buffer.rs +++ b/crates/language/src/buffer.rs @@ -25,6 +25,7 @@ use anyhow::{Context as _, Result}; use clock::Lamport; pub use clock::ReplicaId; use collections::{HashMap, HashSet}; +use encoding_rs::Encoding; use fs::MTime; use futures::channel::oneshot; use gpui::{ @@ -131,6 +132,8 @@ pub struct Buffer { change_bits: Vec>>, _subscriptions: Vec, tree_sitter_data: Arc, + encoding: &'static Encoding, + has_bom: bool, } #[derive(Debug)] @@ -1100,6 +1103,8 @@ impl Buffer { has_conflict: false, change_bits: Default::default(), _subscriptions: Vec::new(), + encoding: encoding_rs::UTF_8, + has_bom: false, } } @@ -1383,6 +1388,26 @@ impl Buffer { self.saved_mtime } + /// Returns the character encoding of the buffer's file. + pub fn encoding(&self) -> &'static Encoding { + self.encoding + } + + /// Sets the character encoding of the buffer. + pub fn set_encoding(&mut self, encoding: &'static Encoding) { + self.encoding = encoding; + } + + /// Returns whether the buffer has a Byte Order Mark. + pub fn has_bom(&self) -> bool { + self.has_bom + } + + /// Sets whether the buffer has a Byte Order Mark. + pub fn set_has_bom(&mut self, has_bom: bool) { + self.has_bom = has_bom; + } + /// Assign a language to the buffer. pub fn set_language_async(&mut self, language: Option>, cx: &mut Context) { self.set_language_(language, cfg!(any(test, feature = "test-support")), cx); diff --git a/crates/project/Cargo.toml b/crates/project/Cargo.toml index f39c368218511b6ddf560dda1198ef5c06bd0a2e..0d264f9e58363f5e8d8e23dff565d512f118a8d1 100644 --- a/crates/project/Cargo.toml +++ b/crates/project/Cargo.toml @@ -40,6 +40,7 @@ clock.workspace = true collections.workspace = true context_server.workspace = true dap.workspace = true +encoding_rs.workspace = true extension.workspace = true fancy-regex.workspace = true fs.workspace = true diff --git a/crates/project/src/buffer_store.rs b/crates/project/src/buffer_store.rs index aea2482c83edb952f3b0dba03a510085c7c4d3f6..22106fa368904d91a5c3da4338e1a79cef7f0fd0 100644 --- a/crates/project/src/buffer_store.rs +++ b/crates/project/src/buffer_store.rs @@ -376,6 +376,8 @@ impl LocalBufferStore { let text = buffer.as_rope().clone(); let line_ending = buffer.line_ending(); + let encoding = buffer.encoding(); + let has_bom = buffer.has_bom(); let version = buffer.version(); let buffer_id = buffer.remote_id(); let file = buffer.file().cloned(); @@ -387,7 +389,7 @@ impl LocalBufferStore { } let save = worktree.update(cx, |worktree, cx| { - worktree.write_file(path, text, line_ending, cx) + worktree.write_file(path, text, line_ending, encoding, has_bom, cx) }); cx.spawn(async move |this, cx| { @@ -630,7 +632,11 @@ impl LocalBufferStore { }) .await; cx.insert_entity(reservation, |_| { - Buffer::build(text_buffer, Some(loaded.file), Capability::ReadWrite) + let mut buffer = + Buffer::build(text_buffer, Some(loaded.file), Capability::ReadWrite); + buffer.set_encoding(loaded.encoding); + buffer.set_has_bom(loaded.has_bom); + buffer })? } Err(error) if is_not_found_error(&error) => cx.new(|cx| { diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index 8b57413b22ac95a16e35a95d70a04b3ae49d4b31..5e31f2a90cf137f1e4d788952832e1eb2ee0ec35 100644 --- a/crates/project/src/project.rs +++ b/crates/project/src/project.rs @@ -65,6 +65,7 @@ use debugger::{ dap_store::{DapStore, DapStoreEvent}, session::Session, }; +use encoding_rs; pub use environment::ProjectEnvironment; #[cfg(test)] use futures::future::join_all; @@ -5461,13 +5462,22 @@ impl Project { .await .context("Failed to load settings file")?; + let has_bom = file.has_bom; + let new_text = cx.read_global::(|store, cx| { store.new_text_for_update(file.text, move |settings| update(settings, cx)) })?; worktree .update(cx, |worktree, cx| { let line_ending = text::LineEnding::detect(&new_text); - worktree.write_file(rel_path.clone(), new_text.into(), line_ending, cx) + worktree.write_file( + rel_path.clone(), + new_text.into(), + line_ending, + encoding_rs::UTF_8, + has_bom, + cx, + ) })? .await .context("Failed to write settings file")?; diff --git a/crates/vim/src/command.rs b/crates/vim/src/command.rs index 5bf0fca041cf274f38c84031e35903c9e339cc24..205097130d152fe255feb02a449956124586d8e6 100644 --- a/crates/vim/src/command.rs +++ b/crates/vim/src/command.rs @@ -330,10 +330,12 @@ pub fn register(editor: &mut Editor, cx: &mut Context) { let Some(range) = range.buffer_range(vim, editor, window, cx).ok() else { return; }; - let Some((line_ending, text, whole_buffer)) = editor.buffer().update(cx, |multi, cx| { + let Some((line_ending, encoding, has_bom, text, whole_buffer)) = editor.buffer().update(cx, |multi, cx| { Some(multi.as_singleton()?.update(cx, |buffer, _| { ( buffer.line_ending(), + buffer.encoding(), + buffer.has_bom(), buffer.as_rope().slice_rows(range.start.0..range.end.0 + 1), range.start.0 == 0 && range.end.0 + 1 >= buffer.row_count(), ) @@ -429,7 +431,7 @@ pub fn register(editor: &mut Editor, cx: &mut Context) { return; }; worktree - .write_file(path.into_arc(), text.clone(), line_ending, cx) + .write_file(path.into_arc(), text.clone(), line_ending, encoding, has_bom, cx) .detach_and_prompt_err("Failed to write lines", window, cx, |_, _, _| None); }); }) diff --git a/crates/worktree/Cargo.toml b/crates/worktree/Cargo.toml index 6d132fbd2cb8c7a1282bffcea6577260a15c4572..e7d3ac34e1886bd76e0a0f5d23ea981b6626909a 100644 --- a/crates/worktree/Cargo.toml +++ b/crates/worktree/Cargo.toml @@ -25,8 +25,10 @@ test-support = [ [dependencies] anyhow.workspace = true async-lock.workspace = true +chardetng.workspace = true clock.workspace = true collections.workspace = true +encoding_rs.workspace = true fs.workspace = true futures.workspace = true fuzzy.workspace = true diff --git a/crates/worktree/src/worktree.rs b/crates/worktree/src/worktree.rs index 6ec19493840da0b9de3eb55ac483488339ec5e8d..7145bccd514fbb5d6093efda765a826162c91260 100644 --- a/crates/worktree/src/worktree.rs +++ b/crates/worktree/src/worktree.rs @@ -5,8 +5,10 @@ mod worktree_tests; use ::ignore::gitignore::{Gitignore, GitignoreBuilder}; use anyhow::{Context as _, Result, anyhow}; +use chardetng::EncodingDetector; use clock::ReplicaId; use collections::{HashMap, HashSet, VecDeque}; +use encoding_rs::Encoding; use fs::{Fs, MTime, PathEvent, RemoveOptions, Watcher, copy_recursive, read_dir_items}; use futures::{ FutureExt as _, Stream, StreamExt, @@ -105,6 +107,8 @@ pub enum CreatedEntry { pub struct LoadedFile { pub file: Arc, pub text: String, + pub encoding: &'static Encoding, + pub has_bom: bool, } pub struct LoadedBinaryFile { @@ -741,10 +745,14 @@ impl Worktree { path: Arc, text: Rope, line_ending: LineEnding, + encoding: &'static Encoding, + has_bom: bool, cx: &Context, ) -> Task>> { match self { - Worktree::Local(this) => this.write_file(path, text, line_ending, cx), + Worktree::Local(this) => { + this.write_file(path, text, line_ending, encoding, has_bom, cx) + } Worktree::Remote(_) => { Task::ready(Err(anyhow!("remote worktree can't yet write files"))) } @@ -1351,7 +1359,9 @@ impl LocalWorktree { anyhow::bail!("File is too large to load"); } } - let text = fs.load(&abs_path).await?; + + let content = fs.load_bytes(&abs_path).await?; + let (text, encoding, has_bom) = decode_byte(content); let worktree = this.upgrade().context("worktree was dropped")?; let file = match entry.await? { @@ -1379,7 +1389,12 @@ impl LocalWorktree { } }; - Ok(LoadedFile { file, text }) + Ok(LoadedFile { + file, + text, + encoding, + has_bom, + }) }) } @@ -1462,6 +1477,8 @@ impl LocalWorktree { path: Arc, text: Rope, line_ending: LineEnding, + encoding: &'static Encoding, + has_bom: bool, cx: &Context, ) -> Task>> { let fs = self.fs.clone(); @@ -1471,7 +1488,49 @@ impl LocalWorktree { let write = cx.background_spawn({ let fs = fs.clone(); let abs_path = abs_path.clone(); - async move { fs.save(&abs_path, &text, line_ending).await } + async move { + let bom_bytes = if has_bom { + if encoding == encoding_rs::UTF_16LE { + vec![0xFF, 0xFE] + } else if encoding == encoding_rs::UTF_16BE { + vec![0xFE, 0xFF] + } else if encoding == encoding_rs::UTF_8 { + vec![0xEF, 0xBB, 0xBF] + } else { + vec![] + } + } else { + vec![] + }; + + // For UTF-8, use the optimized `fs.save` which writes Rope chunks directly to disk + // without allocating a contiguous string. + if encoding == encoding_rs::UTF_8 && !has_bom { + return fs.save(&abs_path, &text, line_ending).await; + } + // For legacy encodings (e.g. Shift-JIS), we fall back to converting the entire Rope + // to a String/Bytes in memory before writing. + // + // Note: This is inefficient for very large files compared to the streaming approach above, + // but supporting streaming writes for arbitrary encodings would require a significant + // refactor of the `fs` crate to expose a Writer interface. + let text_string = text.to_string(); + let normalized_text = match line_ending { + LineEnding::Unix => text_string, + LineEnding::Windows => text_string.replace('\n', "\r\n"), + }; + + let (cow, _, _) = encoding.encode(&normalized_text); + let bytes = if !bom_bytes.is_empty() { + let mut bytes = bom_bytes; + bytes.extend_from_slice(&cow); + bytes.into() + } else { + cow + }; + + fs.write(&abs_path, &bytes).await + } }); cx.spawn(async move |this, cx| { @@ -5782,3 +5841,40 @@ impl fs::Watcher for NullWatcher { Ok(()) } } + +fn decode_byte(bytes: Vec) -> (String, &'static Encoding, bool) { + // check BOM + if let Some((encoding, _bom_len)) = Encoding::for_bom(&bytes) { + let (cow, _) = encoding.decode_with_bom_removal(&bytes); + return (cow.into_owned(), encoding, true); + } + + fn detect_encoding(bytes: Vec) -> (String, &'static Encoding) { + let mut detector = EncodingDetector::new(); + detector.feed(&bytes, true); + + let encoding = detector.guess(None, true); // Use None for TLD hint to ensure neutral detection logic. + + let (cow, _, _) = encoding.decode(&bytes); + (cow.into_owned(), encoding) + } + + match String::from_utf8(bytes) { + Ok(text) => { + // ISO-2022-JP (and other ISO-2022 variants) consists entirely of 7-bit ASCII bytes, + // so it is valid UTF-8. However, it contains escape sequences starting with '\x1b'. + // If we find an escape character, we double-check the encoding to prevent + // displaying raw escape sequences instead of the correct characters. + if text.contains('\x1b') { + let (s, enc) = detect_encoding(text.into_bytes()); + (s, enc, false) + } else { + (text, encoding_rs::UTF_8, false) + } + } + Err(e) => { + let (s, enc) = detect_encoding(e.into_bytes()); + (s, enc, false) + } + } +} diff --git a/crates/worktree/src/worktree_tests.rs b/crates/worktree/src/worktree_tests.rs index 12f2863aab6c4b4376157f3499fa332051a4822f..094a6d52ea4168752578eab06cea511a57e65c10 100644 --- a/crates/worktree/src/worktree_tests.rs +++ b/crates/worktree/src/worktree_tests.rs @@ -1,5 +1,6 @@ use crate::{Entry, EntryKind, Event, PathChange, Worktree, WorktreeModelHandle}; -use anyhow::Result; +use anyhow::{Context as _, Result}; +use encoding_rs; use fs::{FakeFs, Fs, RealFs, RemoveOptions}; use git::{DOT_GIT, GITIGNORE, REPO_EXCLUDE}; use gpui::{AppContext as _, BackgroundExecutor, BorrowAppContext, Context, Task, TestAppContext}; @@ -19,6 +20,7 @@ use std::{ }; use util::{ ResultExt, path, + paths::PathStyle, rel_path::{RelPath, rel_path}, test::TempTree, }; @@ -723,6 +725,8 @@ async fn test_write_file(cx: &mut TestAppContext) { rel_path("tracked-dir/file.txt").into(), "hello".into(), Default::default(), + encoding_rs::UTF_8, + false, cx, ) }) @@ -734,6 +738,8 @@ async fn test_write_file(cx: &mut TestAppContext) { rel_path("ignored-dir/file.txt").into(), "world".into(), Default::default(), + encoding_rs::UTF_8, + false, cx, ) }) @@ -2035,8 +2041,14 @@ fn randomly_mutate_worktree( }) } else { log::info!("overwriting file {:?} ({})", &entry.path, entry.id.0); - let task = - worktree.write_file(entry.path.clone(), "".into(), Default::default(), cx); + let task = worktree.write_file( + entry.path.clone(), + "".into(), + Default::default(), + encoding_rs::UTF_8, + false, + cx, + ); cx.background_spawn(async move { task.await?; Ok(()) @@ -2552,3 +2564,176 @@ fn init_test(cx: &mut gpui::TestAppContext) { cx.set_global(settings_store); }); } + +#[gpui::test] +async fn test_load_file_encoding(cx: &mut TestAppContext) { + init_test(cx); + let test_cases: Vec<(&str, &[u8], &str)> = vec![ + ("utf8.txt", "こんにちは".as_bytes(), "こんにちは"), // "こんにちは" is Japanese "Hello" + ( + "sjis.txt", + &[0x82, 0xb1, 0x82, 0xf1, 0x82, 0xc9, 0x82, 0xbf, 0x82, 0xcd], + "こんにちは", + ), + ( + "eucjp.txt", + &[0xa4, 0xb3, 0xa4, 0xf3, 0xa4, 0xcb, 0xa4, 0xc1, 0xa4, 0xcf], + "こんにちは", + ), + ( + "iso2022jp.txt", + &[ + 0x1b, 0x24, 0x42, 0x24, 0x33, 0x24, 0x73, 0x24, 0x4b, 0x24, 0x41, 0x24, 0x4f, 0x1b, + 0x28, 0x42, + ], + "こんにちは", + ), + // Western Europe (Windows-1252) + // "Café" -> 0xE9 is 'é' in Windows-1252 (it is typically 0xC3 0xA9 in UTF-8) + ("win1252.txt", &[0x43, 0x61, 0x66, 0xe9], "Café"), + // Chinese Simplified (GBK) + // Note: We use a slightly longer string here because short byte sequences can be ambiguous + // in multi-byte encodings. Providing more context helps the heuristic detector guess correctly. + // Text: "今天天气不错" (Today's weather is not bad / nice) + // Bytes: + // 今: BD F1 + // 天: CC EC + // 天: CC EC + // 气: C6 F8 + // 不: B2 BB + // 错: B4 ED + ( + "gbk.txt", + &[ + 0xbd, 0xf1, 0xcc, 0xec, 0xcc, 0xec, 0xc6, 0xf8, 0xb2, 0xbb, 0xb4, 0xed, + ], + "今天天气不错", + ), + ( + "utf16le_bom.txt", + &[ + 0xFF, 0xFE, // BOM + 0x53, 0x30, // こ + 0x93, 0x30, // ん + 0x6B, 0x30, // に + 0x61, 0x30, // ち + 0x6F, 0x30, // は + ], + "こんにちは", + ), + ( + "utf8_bom.txt", + &[ + 0xEF, 0xBB, 0xBF, // UTF-8 BOM + 0xE3, 0x81, 0x93, // こ + 0xE3, 0x82, 0x93, // ん + 0xE3, 0x81, 0xAB, // に + 0xE3, 0x81, 0xA1, // ち + 0xE3, 0x81, 0xAF, // は + ], + "こんにちは", + ), + ]; + + let root_path = if cfg!(windows) { + Path::new("C:\\root") + } else { + Path::new("/root") + }; + + let fs = FakeFs::new(cx.background_executor.clone()); + + let mut files_json = serde_json::Map::new(); + for (name, _, _) in &test_cases { + files_json.insert(name.to_string(), serde_json::Value::String("".to_string())); + } + + for (name, bytes, _) in &test_cases { + let path = root_path.join(name); + fs.write(&path, bytes).await.unwrap(); + } + + let tree = Worktree::local( + root_path, + true, + fs, + Default::default(), + true, + &mut cx.to_async(), + ) + .await + .unwrap(); + + cx.read(|cx| tree.read(cx).as_local().unwrap().scan_complete()) + .await; + + for (name, _, expected) in test_cases { + let loaded = tree + .update(cx, |tree, cx| tree.load_file(rel_path(name), cx)) + .await + .with_context(|| format!("Failed to load {}", name)) + .unwrap(); + + assert_eq!( + loaded.text, expected, + "Encoding mismatch for file: {}", + name + ); + } +} + +#[gpui::test] +async fn test_write_file_encoding(cx: &mut gpui::TestAppContext) { + init_test(cx); + let fs = FakeFs::new(cx.executor()); + let root_path = if cfg!(windows) { + Path::new("C:\\root") + } else { + Path::new("/root") + }; + fs.create_dir(root_path).await.unwrap(); + let file_path = root_path.join("test.txt"); + + fs.insert_file(&file_path, "initial".into()).await; + + let worktree = Worktree::local( + root_path, + true, + fs.clone(), + Default::default(), + true, + &mut cx.to_async(), + ) + .await + .unwrap(); + + let path: Arc = Path::new("test.txt").into(); + let rel_path = RelPath::new(&path, PathStyle::local()).unwrap().into_arc(); + + let text = text::Rope::from("こんにちは"); + + let task = worktree.update(cx, |wt, cx| { + wt.write_file( + rel_path, + text, + text::LineEnding::Unix, + encoding_rs::SHIFT_JIS, + false, + cx, + ) + }); + + task.await.unwrap(); + + let bytes = fs.load_bytes(&file_path).await.unwrap(); + + let expected_bytes = vec![ + 0x82, 0xb1, // こ + 0x82, 0xf1, // ん + 0x82, 0xc9, // に + 0x82, 0xbf, // ち + 0x82, 0xcd, // は + ]; + + assert_eq!(bytes, expected_bytes, "Should be saved as Shift-JIS"); +} From 0d0a08203f37c152243502756b256cd5e3554f2b Mon Sep 17 00:00:00 2001 From: localcc Date: Wed, 17 Dec 2025 20:55:36 +0100 Subject: [PATCH 464/621] Fix windows path canonicalization (#45145) Closes #44962 Release Notes: - N/A --- crates/fs/src/fs.rs | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/crates/fs/src/fs.rs b/crates/fs/src/fs.rs index e6f69a14593a0246ae8ccb4aa4673f4e1f5a1e8e..2cbbf61a21e145464e9dbec01ace3b5510709d0d 100644 --- a/crates/fs/src/fs.rs +++ b/crates/fs/src/fs.rs @@ -434,7 +434,18 @@ impl RealFs { for component in path.components() { match component { std::path::Component::Prefix(_) => { - let canonicalized = std::fs::canonicalize(component)?; + let component = component.as_os_str(); + let canonicalized = if component + .to_str() + .map(|e| e.ends_with("\\")) + .unwrap_or(false) + { + std::fs::canonicalize(component) + } else { + let mut component = component.to_os_string(); + component.push("\\"); + std::fs::canonicalize(component) + }?; let mut strip = PathBuf::new(); for component in canonicalized.components() { @@ -3394,6 +3405,26 @@ mod tests { assert_eq!(content, "Hello"); } + #[gpui::test] + #[cfg(target_os = "windows")] + async fn test_realfs_canonicalize(executor: BackgroundExecutor) { + use util::paths::SanitizedPath; + + let fs = RealFs { + bundled_git_binary_path: None, + executor, + next_job_id: Arc::new(AtomicUsize::new(0)), + job_event_subscribers: Arc::new(Mutex::new(Vec::new())), + }; + let temp_dir = TempDir::new().unwrap(); + let file = temp_dir.path().join("test (1).txt"); + let file = SanitizedPath::new(&file); + std::fs::write(&file, "test").unwrap(); + + let canonicalized = fs.canonicalize(file.as_path()).await; + assert!(canonicalized.is_ok()); + } + #[gpui::test] async fn test_rename(executor: BackgroundExecutor) { let fs = FakeFs::new(executor.clone()); From 9ad059d3be6bec09ae5a042e88dc6f720efd8ba5 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Wed, 17 Dec 2025 21:43:42 +0100 Subject: [PATCH 465/621] copilot: Add support for Next Edit Suggestion (#44486) This PR introduces support for Next Edit Suggestions while doing away with calling legacy endpoints. In the process we've also removed support for cycling completions, as NES will give us a single prediction, for the most part. Closes #30124 Release Notes: - Zed now supports Copilot's [Next Edit Suggestions](https://code.visualstudio.com/blogs/2025/02/12/next-edit-suggestions). --- crates/codestral/src/codestral.rs | 12 +- crates/copilot/src/copilot.rs | 170 +++---- .../src/copilot_edit_prediction_delegate.rs | 417 +++++++----------- crates/copilot/src/request.rs | 100 ++--- .../src/zed_edit_prediction_delegate.rs | 11 +- .../src/edit_prediction_types.rs | 26 -- crates/editor/src/edit_prediction_tests.rs | 18 - crates/editor/src/editor.rs | 56 --- crates/editor/src/element.rs | 2 - crates/language_tools/src/lsp_log_view.rs | 2 +- .../supermaven_edit_prediction_delegate.rs | 11 +- .../zed/src/zed/edit_prediction_registry.rs | 17 - 12 files changed, 259 insertions(+), 583 deletions(-) diff --git a/crates/codestral/src/codestral.rs b/crates/codestral/src/codestral.rs index 9bf0296ac357937cd1ad1470dba9a98864911de9..9cf2fab80b78ba06c6a2523013e2f73934f50052 100644 --- a/crates/codestral/src/codestral.rs +++ b/crates/codestral/src/codestral.rs @@ -1,6 +1,6 @@ use anyhow::{Context as _, Result}; use edit_prediction_context::{EditPredictionExcerpt, EditPredictionExcerptOptions}; -use edit_prediction_types::{Direction, EditPrediction, EditPredictionDelegate}; +use edit_prediction_types::{EditPrediction, EditPredictionDelegate}; use futures::AsyncReadExt; use gpui::{App, Context, Entity, Task}; use http_client::HttpClient; @@ -300,16 +300,6 @@ impl EditPredictionDelegate for CodestralEditPredictionDelegate { })); } - fn cycle( - &mut self, - _buffer: Entity, - _cursor_position: Anchor, - _direction: Direction, - _cx: &mut Context, - ) { - // Codestral doesn't support multiple completions, so cycling does nothing - } - fn accept(&mut self, _cx: &mut Context) { log::debug!("Codestral: Completion accepted"); self.pending_request = None; diff --git a/crates/copilot/src/copilot.rs b/crates/copilot/src/copilot.rs index f248fbdb43ec37b19ca951992df6a7ddbc4f7313..a6963296f5c0ce0395698d2952618123c103ff55 100644 --- a/crates/copilot/src/copilot.rs +++ b/crates/copilot/src/copilot.rs @@ -4,6 +4,7 @@ pub mod copilot_responses; pub mod request; mod sign_in; +use crate::request::NextEditSuggestions; use crate::sign_in::initiate_sign_out; use ::fs::Fs; use anyhow::{Context as _, Result, anyhow}; @@ -18,7 +19,7 @@ use http_client::HttpClient; use language::language_settings::CopilotSettings; use language::{ Anchor, Bias, Buffer, BufferSnapshot, Language, PointUtf16, ToPointUtf16, - language_settings::{EditPredictionProvider, all_language_settings, language_settings}, + language_settings::{EditPredictionProvider, all_language_settings}, point_from_lsp, point_to_lsp, }; use lsp::{LanguageServer, LanguageServerBinary, LanguageServerId, LanguageServerName}; @@ -40,7 +41,7 @@ use std::{ sync::Arc, }; use sum_tree::Dimensions; -use util::{ResultExt, fs::remove_matching, rel_path::RelPath}; +use util::{ResultExt, fs::remove_matching}; use workspace::Workspace; pub use crate::copilot_edit_prediction_delegate::CopilotEditPredictionDelegate; @@ -315,6 +316,15 @@ struct GlobalCopilot(Entity); impl Global for GlobalCopilot {} +/// Copilot's NextEditSuggestion response, with coordinates converted to Anchors. +struct CopilotEditPrediction { + buffer: Entity, + range: Range, + text: String, + command: Option, + snapshot: BufferSnapshot, +} + impl Copilot { pub fn global(cx: &App) -> Option> { cx.try_global::() @@ -873,101 +883,19 @@ impl Copilot { } } - pub fn completions( - &mut self, - buffer: &Entity, - position: T, - cx: &mut Context, - ) -> Task>> - where - T: ToPointUtf16, - { - self.request_completions::(buffer, position, cx) - } - - pub fn completions_cycling( + pub(crate) fn completions( &mut self, buffer: &Entity, - position: T, + position: Anchor, cx: &mut Context, - ) -> Task>> - where - T: ToPointUtf16, - { - self.request_completions::(buffer, position, cx) - } - - pub fn accept_completion( - &mut self, - completion: &Completion, - cx: &mut Context, - ) -> Task> { - let server = match self.server.as_authenticated() { - Ok(server) => server, - Err(error) => return Task::ready(Err(error)), - }; - let request = - server - .lsp - .request::(request::NotifyAcceptedParams { - uuid: completion.uuid.clone(), - }); - cx.background_spawn(async move { - request - .await - .into_response() - .context("copilot: notify accepted")?; - Ok(()) - }) - } - - pub fn discard_completions( - &mut self, - completions: &[Completion], - cx: &mut Context, - ) -> Task> { - let server = match self.server.as_authenticated() { - Ok(server) => server, - Err(_) => return Task::ready(Ok(())), - }; - let request = - server - .lsp - .request::(request::NotifyRejectedParams { - uuids: completions - .iter() - .map(|completion| completion.uuid.clone()) - .collect(), - }); - cx.background_spawn(async move { - request - .await - .into_response() - .context("copilot: notify rejected")?; - Ok(()) - }) - } - - fn request_completions( - &mut self, - buffer: &Entity, - position: T, - cx: &mut Context, - ) -> Task>> - where - R: 'static - + lsp::request::Request< - Params = request::GetCompletionsParams, - Result = request::GetCompletionsResult, - >, - T: ToPointUtf16, - { + ) -> Task>> { self.register_buffer(buffer, cx); let server = match self.server.as_authenticated() { Ok(server) => server, Err(error) => return Task::ready(Err(error)), }; + let buffer_entity = buffer.clone(); let lsp = server.lsp.clone(); let registered_buffer = server .registered_buffers @@ -977,46 +905,31 @@ impl Copilot { let buffer = buffer.read(cx); let uri = registered_buffer.uri.clone(); let position = position.to_point_utf16(buffer); - let settings = language_settings( - buffer.language_at(position).map(|l| l.name()), - buffer.file(), - cx, - ); - let tab_size = settings.tab_size; - let hard_tabs = settings.hard_tabs; - let relative_path = buffer - .file() - .map_or(RelPath::empty().into(), |file| file.path().clone()); cx.background_spawn(async move { let (version, snapshot) = snapshot.await?; let result = lsp - .request::(request::GetCompletionsParams { - doc: request::GetCompletionsDocument { - uri, - tab_size: tab_size.into(), - indent_size: 1, - insert_spaces: !hard_tabs, - relative_path: relative_path.to_proto(), - position: point_to_lsp(position), - version: version.try_into().unwrap(), - }, + .request::(request::NextEditSuggestionsParams { + text_document: lsp::VersionedTextDocumentIdentifier { uri, version }, + position: point_to_lsp(position), }) .await .into_response() .context("copilot: get completions")?; let completions = result - .completions + .edits .into_iter() .map(|completion| { let start = snapshot .clip_point_utf16(point_from_lsp(completion.range.start), Bias::Left); let end = snapshot.clip_point_utf16(point_from_lsp(completion.range.end), Bias::Left); - Completion { - uuid: completion.uuid, + CopilotEditPrediction { + buffer: buffer_entity.clone(), range: snapshot.anchor_before(start)..snapshot.anchor_after(end), text: completion.text, + command: completion.command, + snapshot: snapshot.clone(), } }) .collect(); @@ -1024,6 +937,35 @@ impl Copilot { }) } + pub(crate) fn accept_completion( + &mut self, + completion: &CopilotEditPrediction, + cx: &mut Context, + ) -> Task> { + let server = match self.server.as_authenticated() { + Ok(server) => server, + Err(error) => return Task::ready(Err(error)), + }; + if let Some(command) = &completion.command { + let request = server + .lsp + .request::(lsp::ExecuteCommandParams { + command: command.command.clone(), + arguments: command.arguments.clone().unwrap_or_default(), + ..Default::default() + }); + cx.background_spawn(async move { + request + .await + .into_response() + .context("copilot: notify accepted")?; + Ok(()) + }) + } else { + Task::ready(Ok(())) + } + } + pub fn status(&self) -> Status { match &self.server { CopilotServer::Starting { task } => Status::Starting { task: task.clone() }, @@ -1260,7 +1202,11 @@ async fn get_copilot_lsp(fs: Arc, node_runtime: NodeRuntime) -> anyhow:: mod tests { use super::*; use gpui::TestAppContext; - use util::{path, paths::PathStyle, rel_path::rel_path}; + use util::{ + path, + paths::PathStyle, + rel_path::{RelPath, rel_path}, + }; #[gpui::test(iterations = 10)] async fn test_buffer_management(cx: &mut TestAppContext) { diff --git a/crates/copilot/src/copilot_edit_prediction_delegate.rs b/crates/copilot/src/copilot_edit_prediction_delegate.rs index bbda32e1102f096e96a41cbc59268f597b1629ba..514e135cb4c34f6a1f49687fcd413113f78f9eae 100644 --- a/crates/copilot/src/copilot_edit_prediction_delegate.rs +++ b/crates/copilot/src/copilot_edit_prediction_delegate.rs @@ -1,49 +1,29 @@ -use crate::{Completion, Copilot}; +use crate::{Copilot, CopilotEditPrediction}; use anyhow::Result; -use edit_prediction_types::{Direction, EditPrediction, EditPredictionDelegate}; -use gpui::{App, Context, Entity, EntityId, Task}; -use language::{Buffer, OffsetRangeExt, ToOffset, language_settings::AllLanguageSettings}; -use settings::Settings; -use std::{path::Path, time::Duration}; +use edit_prediction_types::{EditPrediction, EditPredictionDelegate, interpolate_edits}; +use gpui::{App, Context, Entity, Task}; +use language::{Anchor, Buffer, EditPreview, OffsetRangeExt}; +use std::{ops::Range, sync::Arc, time::Duration}; pub const COPILOT_DEBOUNCE_TIMEOUT: Duration = Duration::from_millis(75); pub struct CopilotEditPredictionDelegate { - cycled: bool, - buffer_id: Option, - completions: Vec, - active_completion_index: usize, - file_extension: Option, + completion: Option<(CopilotEditPrediction, EditPreview)>, pending_refresh: Option>>, - pending_cycling_refresh: Option>>, copilot: Entity, } impl CopilotEditPredictionDelegate { pub fn new(copilot: Entity) -> Self { Self { - cycled: false, - buffer_id: None, - completions: Vec::new(), - active_completion_index: 0, - file_extension: None, + completion: None, pending_refresh: None, - pending_cycling_refresh: None, copilot, } } - fn active_completion(&self) -> Option<&Completion> { - self.completions.get(self.active_completion_index) - } - - fn push_completion(&mut self, new_completion: Completion) { - for completion in &self.completions { - if completion.text == new_completion.text && completion.range == new_completion.range { - return; - } - } - self.completions.push(new_completion); + fn active_completion(&self) -> Option<&(CopilotEditPrediction, EditPreview)> { + self.completion.as_ref() } } @@ -64,12 +44,8 @@ impl EditPredictionDelegate for CopilotEditPredictionDelegate { true } - fn supports_jump_to_edit() -> bool { - false - } - fn is_refreshing(&self, _cx: &App) -> bool { - self.pending_refresh.is_some() && self.completions.is_empty() + self.pending_refresh.is_some() && self.completion.is_none() } fn is_enabled( @@ -102,160 +78,96 @@ impl EditPredictionDelegate for CopilotEditPredictionDelegate { })? .await?; - this.update(cx, |this, cx| { - if !completions.is_empty() { - this.cycled = false; + if let Some(mut completion) = completions.into_iter().next() + && let Some(trimmed_completion) = cx + .update(|cx| trim_completion(&completion, cx)) + .ok() + .flatten() + { + let preview = buffer + .update(cx, |this, cx| { + this.preview_edits(Arc::from(std::slice::from_ref(&trimmed_completion)), cx) + })? + .await; + this.update(cx, |this, cx| { this.pending_refresh = None; - this.pending_cycling_refresh = None; - this.completions.clear(); - this.active_completion_index = 0; - this.buffer_id = Some(buffer.entity_id()); - this.file_extension = buffer.read(cx).file().and_then(|file| { - Some( - Path::new(file.file_name(cx)) - .extension()? - .to_str()? - .to_string(), - ) - }); - - for completion in completions { - this.push_completion(completion); - } + completion.range = trimmed_completion.0; + completion.text = trimmed_completion.1.to_string(); + this.completion = Some((completion, preview)); + cx.notify(); - } - })?; + })?; + } Ok(()) })); } - fn cycle( - &mut self, - buffer: Entity, - cursor_position: language::Anchor, - direction: Direction, - cx: &mut Context, - ) { - if self.cycled { - match direction { - Direction::Prev => { - self.active_completion_index = if self.active_completion_index == 0 { - self.completions.len().saturating_sub(1) - } else { - self.active_completion_index - 1 - }; - } - Direction::Next => { - if self.completions.is_empty() { - self.active_completion_index = 0 - } else { - self.active_completion_index = - (self.active_completion_index + 1) % self.completions.len(); - } - } - } - - cx.notify(); - } else { - let copilot = self.copilot.clone(); - self.pending_cycling_refresh = Some(cx.spawn(async move |this, cx| { - let completions = copilot - .update(cx, |copilot, cx| { - copilot.completions_cycling(&buffer, cursor_position, cx) - })? - .await?; - - this.update(cx, |this, cx| { - this.cycled = true; - this.file_extension = buffer.read(cx).file().and_then(|file| { - Some( - Path::new(file.file_name(cx)) - .extension()? - .to_str()? - .to_string(), - ) - }); - for completion in completions { - this.push_completion(completion); - } - this.cycle(buffer, cursor_position, direction, cx); - })?; - - Ok(()) - })); - } - } - fn accept(&mut self, cx: &mut Context) { - if let Some(completion) = self.active_completion() { + if let Some((completion, _)) = self.active_completion() { self.copilot .update(cx, |copilot, cx| copilot.accept_completion(completion, cx)) .detach_and_log_err(cx); } } - fn discard(&mut self, cx: &mut Context) { - let settings = AllLanguageSettings::get_global(cx); - - let copilot_enabled = settings.show_edit_predictions(None, cx); - - if !copilot_enabled { - return; - } - - self.copilot - .update(cx, |copilot, cx| { - copilot.discard_completions(&self.completions, cx) - }) - .detach_and_log_err(cx); - } + fn discard(&mut self, _: &mut Context) {} fn suggest( &mut self, buffer: &Entity, - cursor_position: language::Anchor, + _: language::Anchor, cx: &mut Context, ) -> Option { let buffer_id = buffer.entity_id(); let buffer = buffer.read(cx); - let completion = self.active_completion()?; - if Some(buffer_id) != self.buffer_id + let (completion, edit_preview) = self.active_completion()?; + + if Some(buffer_id) != Some(completion.buffer.entity_id()) || !completion.range.start.is_valid(buffer) || !completion.range.end.is_valid(buffer) { return None; } + let edits = vec![( + completion.range.clone(), + Arc::from(completion.text.as_ref()), + )]; + let edits = interpolate_edits(&completion.snapshot, &buffer.snapshot(), &edits) + .filter(|edits| !edits.is_empty())?; + + Some(EditPrediction::Local { + id: None, + edits, + edit_preview: Some(edit_preview.clone()), + }) + } +} - let mut completion_range = completion.range.to_offset(buffer); - let prefix_len = common_prefix( - buffer.chars_for_range(completion_range.clone()), - completion.text.chars(), - ); - completion_range.start += prefix_len; - let suffix_len = common_prefix( - buffer.reversed_chars_for_range(completion_range.clone()), - completion.text[prefix_len..].chars().rev(), - ); - completion_range.end = completion_range.end.saturating_sub(suffix_len); - - if completion_range.is_empty() - && completion_range.start == cursor_position.to_offset(buffer) - { - let completion_text = &completion.text[prefix_len..completion.text.len() - suffix_len]; - if completion_text.trim().is_empty() { - None - } else { - let position = cursor_position.bias_right(buffer); - Some(EditPrediction::Local { - id: None, - edits: vec![(position..position, completion_text.into())], - edit_preview: None, - }) - } - } else { - None - } +fn trim_completion( + completion: &CopilotEditPrediction, + cx: &mut App, +) -> Option<(Range, Arc)> { + let buffer = completion.buffer.read(cx); + let mut completion_range = completion.range.to_offset(buffer); + let prefix_len = common_prefix( + buffer.chars_for_range(completion_range.clone()), + completion.text.chars(), + ); + completion_range.start += prefix_len; + let suffix_len = common_prefix( + buffer.reversed_chars_for_range(completion_range.clone()), + completion.text[prefix_len..].chars().rev(), + ); + completion_range.end = completion_range.end.saturating_sub(suffix_len); + let completion_text = &completion.text[prefix_len..completion.text.len() - suffix_len]; + if completion_text.trim().is_empty() { + None + } else { + let completion_range = + buffer.anchor_after(completion_range.start)..buffer.anchor_after(completion_range.end); + + Some((completion_range, Arc::from(completion_text))) } } @@ -282,6 +194,7 @@ mod tests { Point, language_settings::{CompletionSettingsContent, LspInsertMode, WordsCompletionMode}, }; + use lsp::Uri; use project::Project; use serde_json::json; use settings::{AllLanguageSettingsContent, SettingsStore}; @@ -337,12 +250,15 @@ mod tests { )); handle_copilot_completion_request( &copilot_lsp, - vec![crate::request::Completion { + vec![crate::request::NextEditSuggestion { text: "one.copilot1".into(), range: lsp::Range::new(lsp::Position::new(0, 0), lsp::Position::new(0, 4)), - ..Default::default() + command: None, + text_document: lsp::VersionedTextDocumentIdentifier { + uri: Uri::from_file_path(path!("/root/dir/file.rs")).unwrap(), + version: 0, + }, }], - vec![], ); executor.advance_clock(COPILOT_DEBOUNCE_TIMEOUT); cx.update_editor(|editor, window, cx| { @@ -383,12 +299,15 @@ mod tests { )); handle_copilot_completion_request( &copilot_lsp, - vec![crate::request::Completion { + vec![crate::request::NextEditSuggestion { text: "one.copilot1".into(), range: lsp::Range::new(lsp::Position::new(0, 0), lsp::Position::new(0, 4)), - ..Default::default() + command: None, + text_document: lsp::VersionedTextDocumentIdentifier { + uri: Uri::from_file_path(path!("/root/dir/file.rs")).unwrap(), + version: 0, + }, }], - vec![], ); executor.advance_clock(COPILOT_DEBOUNCE_TIMEOUT); cx.update_editor(|editor, _, cx| { @@ -412,12 +331,15 @@ mod tests { // After debouncing, new Copilot completions should be requested. handle_copilot_completion_request( &copilot_lsp, - vec![crate::request::Completion { + vec![crate::request::NextEditSuggestion { text: "one.copilot2".into(), range: lsp::Range::new(lsp::Position::new(0, 0), lsp::Position::new(0, 5)), - ..Default::default() + command: None, + text_document: lsp::VersionedTextDocumentIdentifier { + uri: Uri::from_file_path(path!("/root/dir/file.rs")).unwrap(), + version: 0, + }, }], - vec![], ); executor.advance_clock(COPILOT_DEBOUNCE_TIMEOUT); cx.update_editor(|editor, window, cx| { @@ -479,45 +401,6 @@ mod tests { assert_eq!(editor.display_text(cx), "one.cop\ntwo\nthree\n"); assert_eq!(editor.text(cx), "one.cop\ntwo\nthree\n"); }); - - // Reset the editor to verify how suggestions behave when tabbing on leading indentation. - cx.update_editor(|editor, window, cx| { - editor.set_text("fn foo() {\n \n}", window, cx); - editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| { - s.select_ranges([Point::new(1, 2)..Point::new(1, 2)]) - }); - }); - handle_copilot_completion_request( - &copilot_lsp, - vec![crate::request::Completion { - text: " let x = 4;".into(), - range: lsp::Range::new(lsp::Position::new(1, 0), lsp::Position::new(1, 2)), - ..Default::default() - }], - vec![], - ); - - cx.update_editor(|editor, window, cx| { - editor.next_edit_prediction(&Default::default(), window, cx) - }); - executor.advance_clock(COPILOT_DEBOUNCE_TIMEOUT); - cx.update_editor(|editor, window, cx| { - assert!(editor.has_active_edit_prediction()); - assert_eq!(editor.display_text(cx), "fn foo() {\n let x = 4;\n}"); - assert_eq!(editor.text(cx), "fn foo() {\n \n}"); - - // Tabbing inside of leading whitespace inserts indentation without accepting the suggestion. - editor.tab(&Default::default(), window, cx); - assert!(editor.has_active_edit_prediction()); - assert_eq!(editor.text(cx), "fn foo() {\n \n}"); - assert_eq!(editor.display_text(cx), "fn foo() {\n let x = 4;\n}"); - - // Using AcceptEditPrediction again accepts the suggestion. - editor.accept_edit_prediction(&Default::default(), window, cx); - assert!(!editor.has_active_edit_prediction()); - assert_eq!(editor.text(cx), "fn foo() {\n let x = 4;\n}"); - assert_eq!(editor.display_text(cx), "fn foo() {\n let x = 4;\n}"); - }); } #[gpui::test(iterations = 10)] @@ -570,12 +453,15 @@ mod tests { )); handle_copilot_completion_request( &copilot_lsp, - vec![crate::request::Completion { + vec![crate::request::NextEditSuggestion { text: "one.copilot1".into(), range: lsp::Range::new(lsp::Position::new(0, 0), lsp::Position::new(0, 4)), - ..Default::default() + command: None, + text_document: lsp::VersionedTextDocumentIdentifier { + uri: Uri::from_file_path(path!("/root/dir/file.rs")).unwrap(), + version: 0, + }, }], - vec![], ); executor.advance_clock(COPILOT_DEBOUNCE_TIMEOUT); cx.update_editor(|editor, window, cx| { @@ -614,12 +500,15 @@ mod tests { )); handle_copilot_completion_request( &copilot_lsp, - vec![crate::request::Completion { + vec![crate::request::NextEditSuggestion { text: "one.123. copilot\n 456".into(), range: lsp::Range::new(lsp::Position::new(0, 0), lsp::Position::new(0, 4)), - ..Default::default() + command: None, + text_document: lsp::VersionedTextDocumentIdentifier { + uri: Uri::from_file_path(path!("/root/dir/file.rs")).unwrap(), + version: 0, + }, }], - vec![], ); executor.advance_clock(COPILOT_DEBOUNCE_TIMEOUT); cx.update_editor(|editor, window, cx| { @@ -686,15 +575,18 @@ mod tests { handle_copilot_completion_request( &copilot_lsp, - vec![crate::request::Completion { + vec![crate::request::NextEditSuggestion { text: "two.foo()".into(), range: lsp::Range::new(lsp::Position::new(1, 0), lsp::Position::new(1, 2)), - ..Default::default() + command: None, + text_document: lsp::VersionedTextDocumentIdentifier { + uri: Uri::from_file_path(path!("/root/dir/file.rs")).unwrap(), + version: 0, + }, }], - vec![], ); cx.update_editor(|editor, window, cx| { - editor.next_edit_prediction(&Default::default(), window, cx) + editor.show_edit_prediction(&Default::default(), window, cx) }); executor.advance_clock(COPILOT_DEBOUNCE_TIMEOUT); cx.update_editor(|editor, window, cx| { @@ -703,15 +595,22 @@ mod tests { assert_eq!(editor.text(cx), "one\ntw\nthree\n"); editor.backspace(&Default::default(), window, cx); + }); + executor.advance_clock(COPILOT_DEBOUNCE_TIMEOUT); + cx.run_until_parked(); + cx.update_editor(|editor, window, cx| { assert!(editor.has_active_edit_prediction()); assert_eq!(editor.display_text(cx), "one\ntwo.foo()\nthree\n"); assert_eq!(editor.text(cx), "one\nt\nthree\n"); editor.backspace(&Default::default(), window, cx); + }); + executor.advance_clock(COPILOT_DEBOUNCE_TIMEOUT); + cx.run_until_parked(); + cx.update_editor(|editor, window, cx| { assert!(editor.has_active_edit_prediction()); assert_eq!(editor.display_text(cx), "one\ntwo.foo()\nthree\n"); assert_eq!(editor.text(cx), "one\n\nthree\n"); - // Deleting across the original suggestion range invalidates it. editor.backspace(&Default::default(), window, cx); assert!(!editor.has_active_edit_prediction()); @@ -765,19 +664,22 @@ mod tests { handle_copilot_completion_request( &copilot_lsp, - vec![crate::request::Completion { + vec![crate::request::NextEditSuggestion { text: "b = 2 + a".into(), range: lsp::Range::new(lsp::Position::new(1, 0), lsp::Position::new(1, 5)), - ..Default::default() + command: None, + text_document: lsp::VersionedTextDocumentIdentifier { + uri: Uri::from_file_path(path!("/root/dir/file.rs")).unwrap(), + version: 0, + }, }], - vec![], ); _ = editor.update(cx, |editor, window, cx| { // Ensure copilot suggestions are shown for the first excerpt. editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| { s.select_ranges([Point::new(1, 5)..Point::new(1, 5)]) }); - editor.next_edit_prediction(&Default::default(), window, cx); + editor.show_edit_prediction(&Default::default(), window, cx); }); executor.advance_clock(COPILOT_DEBOUNCE_TIMEOUT); _ = editor.update(cx, |editor, _, cx| { @@ -791,12 +693,15 @@ mod tests { handle_copilot_completion_request( &copilot_lsp, - vec![crate::request::Completion { + vec![crate::request::NextEditSuggestion { text: "d = 4 + c".into(), range: lsp::Range::new(lsp::Position::new(1, 0), lsp::Position::new(1, 6)), - ..Default::default() + command: None, + text_document: lsp::VersionedTextDocumentIdentifier { + uri: Uri::from_file_path(path!("/root/dir/file.rs")).unwrap(), + version: 0, + }, }], - vec![], ); _ = editor.update(cx, |editor, window, cx| { // Move to another excerpt, ensuring the suggestion gets cleared. @@ -873,15 +778,18 @@ mod tests { )); handle_copilot_completion_request( &copilot_lsp, - vec![crate::request::Completion { + vec![crate::request::NextEditSuggestion { text: "two.foo()".into(), range: lsp::Range::new(lsp::Position::new(1, 0), lsp::Position::new(1, 2)), - ..Default::default() + command: None, + text_document: lsp::VersionedTextDocumentIdentifier { + uri: Uri::from_file_path(path!("/root/dir/file.rs")).unwrap(), + version: 0, + }, }], - vec![], ); cx.update_editor(|editor, window, cx| { - editor.next_edit_prediction(&Default::default(), window, cx) + editor.show_edit_prediction(&Default::default(), window, cx) }); executor.advance_clock(COPILOT_DEBOUNCE_TIMEOUT); cx.update_editor(|editor, _, cx| { @@ -903,12 +811,15 @@ mod tests { )); handle_copilot_completion_request( &copilot_lsp, - vec![crate::request::Completion { + vec![crate::request::NextEditSuggestion { text: "two.foo()".into(), range: lsp::Range::new(lsp::Position::new(1, 0), lsp::Position::new(1, 3)), - ..Default::default() + command: None, + text_document: lsp::VersionedTextDocumentIdentifier { + uri: Uri::from_file_path(path!("/root/dir/file.rs")).unwrap(), + version: 0, + }, }], - vec![], ); executor.advance_clock(COPILOT_DEBOUNCE_TIMEOUT); cx.update_editor(|editor, _, cx| { @@ -930,12 +841,15 @@ mod tests { )); handle_copilot_completion_request( &copilot_lsp, - vec![crate::request::Completion { + vec![crate::request::NextEditSuggestion { text: "two.foo()".into(), range: lsp::Range::new(lsp::Position::new(1, 0), lsp::Position::new(1, 4)), - ..Default::default() + command: None, + text_document: lsp::VersionedTextDocumentIdentifier { + uri: Uri::from_file_path(path!("/root/dir/file.rs")).unwrap(), + version: 0, + }, }], - vec![], ); executor.advance_clock(COPILOT_DEBOUNCE_TIMEOUT); cx.update_editor(|editor, _, cx| { @@ -1011,16 +925,20 @@ mod tests { .unwrap(); let mut copilot_requests = copilot_lsp - .set_request_handler::( + .set_request_handler::( move |_params, _cx| async move { - Ok(crate::request::GetCompletionsResult { - completions: vec![crate::request::Completion { + Ok(crate::request::NextEditSuggestionsResult { + edits: vec![crate::request::NextEditSuggestion { text: "next line".into(), range: lsp::Range::new( lsp::Position::new(1, 0), lsp::Position::new(1, 0), ), - ..Default::default() + command: None, + text_document: lsp::VersionedTextDocumentIdentifier { + uri: Uri::from_file_path(path!("/root/dir/file.rs")).unwrap(), + version: 0, + }, }], }) }, @@ -1049,23 +967,14 @@ mod tests { fn handle_copilot_completion_request( lsp: &lsp::FakeLanguageServer, - completions: Vec, - completions_cycling: Vec, + completions: Vec, ) { - lsp.set_request_handler::(move |_params, _cx| { - let completions = completions.clone(); - async move { - Ok(crate::request::GetCompletionsResult { - completions: completions.clone(), - }) - } - }); - lsp.set_request_handler::( + lsp.set_request_handler::( move |_params, _cx| { - let completions_cycling = completions_cycling.clone(); + let completions = completions.clone(); async move { - Ok(crate::request::GetCompletionsResult { - completions: completions_cycling.clone(), + Ok(crate::request::NextEditSuggestionsResult { + edits: completions.clone(), }) } }, diff --git a/crates/copilot/src/request.rs b/crates/copilot/src/request.rs index 85d6254dc060824a9b2686e8f53090fccb39980e..2f97fb72a42904b1fefdd3999f680fca12559ecd 100644 --- a/crates/copilot/src/request.rs +++ b/crates/copilot/src/request.rs @@ -1,3 +1,4 @@ +use lsp::VersionedTextDocumentIdentifier; use serde::{Deserialize, Serialize}; pub enum CheckStatus {} @@ -88,72 +89,6 @@ impl lsp::request::Request for SignOut { const METHOD: &'static str = "signOut"; } -pub enum GetCompletions {} - -#[derive(Debug, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] -pub struct GetCompletionsParams { - pub doc: GetCompletionsDocument, -} - -#[derive(Debug, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] -pub struct GetCompletionsDocument { - pub tab_size: u32, - pub indent_size: u32, - pub insert_spaces: bool, - pub uri: lsp::Uri, - pub relative_path: String, - pub position: lsp::Position, - pub version: usize, -} - -#[derive(Debug, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] -pub struct GetCompletionsResult { - pub completions: Vec, -} - -#[derive(Clone, Debug, Default, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] -pub struct Completion { - pub text: String, - pub position: lsp::Position, - pub uuid: String, - pub range: lsp::Range, - pub display_text: String, -} - -impl lsp::request::Request for GetCompletions { - type Params = GetCompletionsParams; - type Result = GetCompletionsResult; - const METHOD: &'static str = "getCompletions"; -} - -pub enum GetCompletionsCycling {} - -impl lsp::request::Request for GetCompletionsCycling { - type Params = GetCompletionsParams; - type Result = GetCompletionsResult; - const METHOD: &'static str = "getCompletionsCycling"; -} - -pub enum LogMessage {} - -#[derive(Debug, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] -pub struct LogMessageParams { - pub level: u8, - pub message: String, - pub metadata_str: String, - pub extra: Vec, -} - -impl lsp::notification::Notification for LogMessage { - type Params = LogMessageParams; - const METHOD: &'static str = "LogMessage"; -} - pub enum StatusNotification {} #[derive(Debug, Serialize, Deserialize)] @@ -223,3 +158,36 @@ impl lsp::request::Request for NotifyRejected { type Result = String; const METHOD: &'static str = "notifyRejected"; } + +#[derive(Debug, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct NextEditSuggestions; + +#[derive(Debug, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct NextEditSuggestionsParams { + pub(crate) text_document: VersionedTextDocumentIdentifier, + pub(crate) position: lsp::Position, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct NextEditSuggestion { + pub text: String, + pub text_document: VersionedTextDocumentIdentifier, + pub range: lsp::Range, + pub command: Option, +} + +#[derive(Debug, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct NextEditSuggestionsResult { + pub edits: Vec, +} + +impl lsp::request::Request for NextEditSuggestions { + type Params = NextEditSuggestionsParams; + type Result = NextEditSuggestionsResult; + + const METHOD: &'static str = "textDocument/copilotInlineEdit"; +} diff --git a/crates/edit_prediction/src/zed_edit_prediction_delegate.rs b/crates/edit_prediction/src/zed_edit_prediction_delegate.rs index 0a87ca661435de4d22e6f258c30ff406f0deecc2..289bcd76daab2b9a4b82db88b86285e6c7aca00d 100644 --- a/crates/edit_prediction/src/zed_edit_prediction_delegate.rs +++ b/crates/edit_prediction/src/zed_edit_prediction_delegate.rs @@ -2,7 +2,7 @@ use std::{cmp, sync::Arc}; use client::{Client, UserStore}; use cloud_llm_client::EditPredictionRejectReason; -use edit_prediction_types::{DataCollectionState, Direction, EditPredictionDelegate}; +use edit_prediction_types::{DataCollectionState, EditPredictionDelegate}; use gpui::{App, Entity, prelude::*}; use language::{Buffer, ToPoint as _}; use project::Project; @@ -139,15 +139,6 @@ impl EditPredictionDelegate for ZedEditPredictionDelegate { }); } - fn cycle( - &mut self, - _buffer: Entity, - _cursor_position: language::Anchor, - _direction: Direction, - _cx: &mut Context, - ) { - } - fn accept(&mut self, cx: &mut Context) { self.store.update(cx, |store, cx| { store.accept_current_prediction(&self.project, cx); diff --git a/crates/edit_prediction_types/src/edit_prediction_types.rs b/crates/edit_prediction_types/src/edit_prediction_types.rs index 945cfea4a168af4470d98ca844f311a79de9800a..5a37aba59923598b20becd91f07633e409b2bdb7 100644 --- a/crates/edit_prediction_types/src/edit_prediction_types.rs +++ b/crates/edit_prediction_types/src/edit_prediction_types.rs @@ -95,13 +95,6 @@ pub trait EditPredictionDelegate: 'static + Sized { debounce: bool, cx: &mut Context, ); - fn cycle( - &mut self, - buffer: Entity, - cursor_position: language::Anchor, - direction: Direction, - cx: &mut Context, - ); fn accept(&mut self, cx: &mut Context); fn discard(&mut self, cx: &mut Context); fn did_show(&mut self, _cx: &mut Context) {} @@ -136,13 +129,6 @@ pub trait EditPredictionDelegateHandle { debounce: bool, cx: &mut App, ); - fn cycle( - &self, - buffer: Entity, - cursor_position: language::Anchor, - direction: Direction, - cx: &mut App, - ); fn did_show(&self, cx: &mut App); fn accept(&self, cx: &mut App); fn discard(&self, cx: &mut App); @@ -215,18 +201,6 @@ where }) } - fn cycle( - &self, - buffer: Entity, - cursor_position: language::Anchor, - direction: Direction, - cx: &mut App, - ) { - self.update(cx, |this, cx| { - this.cycle(buffer, cursor_position, direction, cx) - }) - } - fn accept(&self, cx: &mut App) { self.update(cx, |this, cx| this.accept(cx)) } diff --git a/crates/editor/src/edit_prediction_tests.rs b/crates/editor/src/edit_prediction_tests.rs index bfce1532ce78699e1fb524fd594df1ba83c864a5..b5931cde42a4e2c0e21b2d1f68558879de9750b4 100644 --- a/crates/editor/src/edit_prediction_tests.rs +++ b/crates/editor/src/edit_prediction_tests.rs @@ -485,15 +485,6 @@ impl EditPredictionDelegate for FakeEditPredictionDelegate { ) { } - fn cycle( - &mut self, - _buffer: gpui::Entity, - _cursor_position: language::Anchor, - _direction: edit_prediction_types::Direction, - _cx: &mut gpui::Context, - ) { - } - fn accept(&mut self, _cx: &mut gpui::Context) {} fn discard(&mut self, _cx: &mut gpui::Context) {} @@ -561,15 +552,6 @@ impl EditPredictionDelegate for FakeNonZedEditPredictionDelegate { ) { } - fn cycle( - &mut self, - _buffer: gpui::Entity, - _cursor_position: language::Anchor, - _direction: edit_prediction_types::Direction, - _cx: &mut gpui::Context, - ) { - } - fn accept(&mut self, _cx: &mut gpui::Context) {} fn discard(&mut self, _cx: &mut gpui::Context) {} diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 7da06c3d8de91709cdcea8cbc923918464021079..83051ffb9ea1a5f5754b2af4d1cf42526cfd391e 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -7468,26 +7468,6 @@ impl Editor { .unwrap_or(false) } - fn cycle_edit_prediction( - &mut self, - direction: Direction, - window: &mut Window, - cx: &mut Context, - ) -> Option<()> { - let provider = self.edit_prediction_provider()?; - let cursor = self.selections.newest_anchor().head(); - let (buffer, cursor_buffer_position) = - self.buffer.read(cx).text_anchor_for_position(cursor, cx)?; - if self.edit_predictions_hidden_for_vim_mode || !self.should_show_edit_predictions() { - return None; - } - - provider.cycle(buffer, cursor_buffer_position, direction, cx); - self.update_visible_edit_prediction(window, cx); - - Some(()) - } - pub fn show_edit_prediction( &mut self, _: &ShowEditPrediction, @@ -7525,42 +7505,6 @@ impl Editor { .detach(); } - pub fn next_edit_prediction( - &mut self, - _: &NextEditPrediction, - window: &mut Window, - cx: &mut Context, - ) { - if self.has_active_edit_prediction() { - self.cycle_edit_prediction(Direction::Next, window, cx); - } else { - let is_copilot_disabled = self - .refresh_edit_prediction(false, true, window, cx) - .is_none(); - if is_copilot_disabled { - cx.propagate(); - } - } - } - - pub fn previous_edit_prediction( - &mut self, - _: &PreviousEditPrediction, - window: &mut Window, - cx: &mut Context, - ) { - if self.has_active_edit_prediction() { - self.cycle_edit_prediction(Direction::Prev, window, cx); - } else { - let is_copilot_disabled = self - .refresh_edit_prediction(false, true, window, cx) - .is_none(); - if is_copilot_disabled { - cx.propagate(); - } - } - } - pub fn accept_partial_edit_prediction( &mut self, granularity: EditPredictionGranularity, diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index 85b32324a1c1cc7fb84162fb120e8ef0e4e8b599..9b6115daed700bf391ef6b076100702b99ecaabe 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -594,8 +594,6 @@ impl EditorElement { register_action(editor, window, Editor::show_signature_help); register_action(editor, window, Editor::signature_help_prev); register_action(editor, window, Editor::signature_help_next); - register_action(editor, window, Editor::next_edit_prediction); - register_action(editor, window, Editor::previous_edit_prediction); register_action(editor, window, Editor::show_edit_prediction); register_action(editor, window, Editor::context_menu_first); register_action(editor, window, Editor::context_menu_prev); diff --git a/crates/language_tools/src/lsp_log_view.rs b/crates/language_tools/src/lsp_log_view.rs index 6fc061cd07edd9e22609ba698f27860b1b905765..e34bbb46d35d5a524c08369fcc991dfe81865127 100644 --- a/crates/language_tools/src/lsp_log_view.rs +++ b/crates/language_tools/src/lsp_log_view.rs @@ -125,7 +125,7 @@ pub fn init(on_headless_host: bool, cx: &mut App) { let server_id = server.server_id(); let weak_lsp_store = cx.weak_entity(); log_store.copilot_log_subscription = - Some(server.on_notification::( + Some(server.on_notification::( move |params, cx| { weak_lsp_store .update(cx, |lsp_store, cx| { diff --git a/crates/supermaven/src/supermaven_edit_prediction_delegate.rs b/crates/supermaven/src/supermaven_edit_prediction_delegate.rs index 578bc894f223fd458f510694194aebe633d7a6db..9563a0aa99f1760b5af214be28f25dbf1734c371 100644 --- a/crates/supermaven/src/supermaven_edit_prediction_delegate.rs +++ b/crates/supermaven/src/supermaven_edit_prediction_delegate.rs @@ -1,6 +1,6 @@ use crate::{Supermaven, SupermavenCompletionStateId}; use anyhow::Result; -use edit_prediction_types::{Direction, EditPrediction, EditPredictionDelegate}; +use edit_prediction_types::{EditPrediction, EditPredictionDelegate}; use futures::StreamExt as _; use gpui::{App, Context, Entity, EntityId, Task}; use language::{Anchor, Buffer, BufferSnapshot}; @@ -189,15 +189,6 @@ impl EditPredictionDelegate for SupermavenEditPredictionDelegate { })); } - fn cycle( - &mut self, - _buffer: Entity, - _cursor_position: Anchor, - _direction: Direction, - _cx: &mut Context, - ) { - } - fn accept(&mut self, _cx: &mut Context) { reset_completion_cache(self, _cx); } diff --git a/crates/zed/src/zed/edit_prediction_registry.rs b/crates/zed/src/zed/edit_prediction_registry.rs index 77a1f71596f9cf1d2f4e32137580d0e3648359f5..51327bfc9ab715a1b11aa3c639ffd60b6b0a0ea8 100644 --- a/crates/zed/src/zed/edit_prediction_registry.rs +++ b/crates/zed/src/zed/edit_prediction_registry.rs @@ -145,23 +145,6 @@ fn register_backward_compatible_actions(editor: &mut Editor, cx: &mut Context| { - editor.next_edit_prediction(&Default::default(), window, cx); - }, - )) - .detach(); - editor - .register_action(cx.listener( - |editor, - _: &copilot::PreviousSuggestion, - window: &mut Window, - cx: &mut Context| { - editor.previous_edit_prediction(&Default::default(), window, cx); - }, - )) - .detach(); } fn assign_edit_prediction_provider( From 8aab646aeca1b4698737fbd8d0efa29caf87ee8c Mon Sep 17 00:00:00 2001 From: Dave Waggoner Date: Wed, 17 Dec 2025 12:53:22 -0800 Subject: [PATCH 466/621] terminal: Improve regex hyperlink performance for long lines (#44721) Related to - #44407 This PR further improves performance for regex hyperlink finding by eliminating unnecessary regex matching. Currently, we repeatedly search for matches from the start of the line until the match contains the hovered point. This is only required to support custom regexes which match strings containing spaces, with multiple matches on a single line. This isn't actually a useful scenario, and is no longer supported. This PR changes to only search twice, the first match starting from the start of the line, and the hovered word (space-delimited). The most dramatic improvement is for long lines with many words. In addition to the above changes, this PR: - Adds test for the scenarios from #44407 and #44510 - Simplifies the logic added in #44407 Performance measurements For the scenario from #44407, this improves the perf test's iteration time from 1.22ms to 0.47ms. main: | Branch | Command | Iter/sec | Mean [ms] | SD [ms] | Iterations | Importance (weight) | |:---|:---|---:|---:|---:|---:|---:| | main | terminal_hyperlinks::tests::path::perf::pr_44407_hyperlink_benchmark | 819.64 | 937.60 | 2.20 | 768 | average (50) | | this PR | terminal_hyperlinks::tests::path::perf::pr_44407_hyperlink_benchmark | 2099.79 | 1463.20 | 7.20 | 3072 | average (50) | Release Notes: - terminal: Improve path hyperlink performance for long lines --- crates/terminal/src/terminal_hyperlinks.rs | 238 +++++++++++++++++---- 1 file changed, 195 insertions(+), 43 deletions(-) diff --git a/crates/terminal/src/terminal_hyperlinks.rs b/crates/terminal/src/terminal_hyperlinks.rs index 8ff33895251f707c8bc9a7894bd74b0bb323ae6c..4fe2baa2dc27f3a589efd9b7739262a6fec3fcb4 100644 --- a/crates/terminal/src/terminal_hyperlinks.rs +++ b/crates/terminal/src/terminal_hyperlinks.rs @@ -11,6 +11,7 @@ use alacritty_terminal::{ use log::{info, warn}; use regex::Regex; use std::{ + iter::{once, once_with}, ops::{Index, Range}, time::{Duration, Instant}, }; @@ -232,14 +233,17 @@ fn path_match( (line_end.line.0 - line_start.line.0 + 1) as usize * term.grid().columns(), ); let first_cell = &term.grid()[line_start]; + let mut prev_len = 0; line.push(first_cell.c); - let mut start_offset = 0; + let mut prev_char_is_space = first_cell.c == ' '; let mut hovered_point_byte_offset = None; + let mut hovered_word_start_offset = None; + let mut hovered_word_end_offset = None; - if !first_cell.flags.intersects(WIDE_CHAR_SPACERS) { - start_offset += first_cell.c.len_utf8(); - if line_start == hovered { - hovered_point_byte_offset = Some(0); + if line_start == hovered { + hovered_point_byte_offset = Some(0); + if first_cell.c != ' ' { + hovered_word_start_offset = Some(0); } } @@ -247,27 +251,44 @@ fn path_match( if cell.point > line_end { break; } - let is_spacer = cell.flags.intersects(WIDE_CHAR_SPACERS); - if cell.point == hovered { - debug_assert!(hovered_point_byte_offset.is_none()); - if start_offset > 0 && cell.flags.contains(Flags::WIDE_CHAR_SPACER) { - // If we hovered on a trailing spacer, back up to the end of the previous char's bytes. - start_offset -= 1; + + if !cell.flags.intersects(WIDE_CHAR_SPACERS) { + prev_len = line.len(); + match cell.c { + ' ' | '\t' => { + if hovered_point_byte_offset.is_some() && !prev_char_is_space { + if hovered_word_end_offset.is_none() { + hovered_word_end_offset = Some(line.len()); + } + } + line.push(' '); + prev_char_is_space = true; + } + c @ _ => { + if hovered_point_byte_offset.is_none() && prev_char_is_space { + hovered_word_start_offset = Some(line.len()); + } + line.push(c); + prev_char_is_space = false; + } } - hovered_point_byte_offset = Some(start_offset); - } else if cell.point < hovered && !is_spacer { - start_offset += cell.c.len_utf8(); } - if !is_spacer { - line.push(match cell.c { - '\t' => ' ', - c @ _ => c, - }); + if cell.point == hovered { + debug_assert!(hovered_point_byte_offset.is_none()); + hovered_point_byte_offset = Some(prev_len); } } let line = line.trim_ascii_end(); let hovered_point_byte_offset = hovered_point_byte_offset?; + let hovered_word_range = { + let word_start_offset = hovered_word_start_offset.unwrap_or(0); + (word_start_offset != 0) + .then_some(word_start_offset..hovered_word_end_offset.unwrap_or(line.len())) + }; + if line.len() <= hovered_point_byte_offset { + return None; + } let found_from_range = |path_range: Range, link_range: Range, position: Option<(u32, Option)>| { @@ -313,10 +334,27 @@ fn path_match( for regex in path_hyperlink_regexes { let mut path_found = false; - for captures in regex.captures_iter(&line) { + for (line_start_offset, captures) in once( + regex + .captures_iter(&line) + .next() + .map(|captures| (0, captures)), + ) + .chain(once_with(|| { + if let Some(hovered_word_range) = &hovered_word_range { + regex + .captures_iter(&line[hovered_word_range.clone()]) + .next() + .map(|captures| (hovered_word_range.start, captures)) + } else { + None + } + })) + .flatten() + { path_found = true; let match_range = captures.get(0).unwrap().range(); - let (path_range, line_column) = if let Some(path) = captures.name("path") { + let (mut path_range, line_column) = if let Some(path) = captures.name("path") { let parse = |name: &str| { captures .name(name) @@ -330,10 +368,15 @@ fn path_match( } else { (match_range.clone(), None) }; - let link_range = captures + let mut link_range = captures .name("link") .map_or_else(|| match_range.clone(), |link| link.range()); + path_range.start += line_start_offset; + path_range.end += line_start_offset; + link_range.start += line_start_offset; + link_range.end += line_start_offset; + if !link_range.contains(&hovered_point_byte_offset) { // No match, just skip. continue; @@ -638,9 +681,6 @@ mod tests { test_path!( "‹«🦀 multiple_👉same_line 🦀» 🚣«4» 🏛️«2»›: 🦀 multiple_same_line 🦀 🚣4 🏛️2:" ); - test_path!( - "🦀 multiple_same_line 🦀 🚣4 🏛️2 ‹«🦀 multiple_👉same_line 🦀» 🚣«4» 🏛️«2»›:" - ); // ls output (tab separated) test_path!( @@ -977,7 +1017,7 @@ mod tests { use crate::TerminalSettings; use alacritty_terminal::{ event::VoidListener, - grid::Dimensions, + grid::Scroll, index::{Column, Point as AlacPoint}, term::test::mock_term, term::{Term, search::Match}, @@ -986,14 +1026,20 @@ mod tests { use std::{cell::RefCell, rc::Rc}; use util_macros::perf; - fn build_test_term(line: &str) -> (Term, AlacPoint) { - let content = line.repeat(500); - let term = mock_term(&content); - let point = AlacPoint::new( - term.grid().bottommost_line() - 1, - Column(term.grid().last_column().0 / 2), - ); - + fn build_test_term( + line: &str, + repeat: usize, + hover_offset_column: usize, + ) -> (Term, AlacPoint) { + let content = line.repeat(repeat); + let mut term = mock_term(&content); + term.resize(TermSize { + columns: 1024, + screen_lines: 10, + }); + term.scroll_display(Scroll::Top); + let point = + AlacPoint::new(Line(term.topmost_line().0 + 3), Column(hover_offset_column)); (term, point) } @@ -1002,11 +1048,14 @@ mod tests { const LINE: &str = " Compiling terminal v0.1.0 (/Hyperlinks/Bench/Source/zed-hyperlinks/crates/terminal)\r\n"; thread_local! { static TEST_TERM_AND_POINT: (Term, AlacPoint) = - build_test_term(LINE); + build_test_term(LINE, 500, 50); } TEST_TERM_AND_POINT.with(|(term, point)| { - assert!( - find_from_grid_point_bench(term, *point).is_some(), + assert_eq!( + find_from_grid_point_bench(term, *point) + .map(|(path, ..)| path) + .unwrap_or_default(), + "/Hyperlinks/Bench/Source/zed-hyperlinks/crates/terminal", "Hyperlink should have been found" ); }); @@ -1017,11 +1066,14 @@ mod tests { const LINE: &str = " --> /Hyperlinks/Bench/Source/zed-hyperlinks/crates/terminal/terminal.rs:1000:42\r\n"; thread_local! { static TEST_TERM_AND_POINT: (Term, AlacPoint) = - build_test_term(LINE); + build_test_term(LINE, 500, 50); } TEST_TERM_AND_POINT.with(|(term, point)| { - assert!( - find_from_grid_point_bench(term, *point).is_some(), + assert_eq!( + find_from_grid_point_bench(term, *point) + .map(|(path, ..)| path) + .unwrap_or_default(), + "/Hyperlinks/Bench/Source/zed-hyperlinks/crates/terminal/terminal.rs:1000:42", "Hyperlink should have been found" ); }); @@ -1032,11 +1084,111 @@ mod tests { const LINE: &str = "Cargo.toml experiments notebooks rust-toolchain.toml tooling\r\n"; thread_local! { static TEST_TERM_AND_POINT: (Term, AlacPoint) = - build_test_term(LINE); + build_test_term(LINE, 500, 60); } TEST_TERM_AND_POINT.with(|(term, point)| { - assert!( - find_from_grid_point_bench(term, *point).is_some(), + assert_eq!( + find_from_grid_point_bench(term, *point) + .map(|(path, ..)| path) + .unwrap_or_default(), + "rust-toolchain.toml", + "Hyperlink should have been found" + ); + }); + } + + #[perf] + // https://github.com/zed-industries/zed/pull/44407 + pub fn pr_44407_hyperlink_benchmark() { + const LINE: &str = "-748, 706, 163, 222, -980, 949, 381, -568, 199, 501, 760, -821, 90, -451, 183, 867, -351, -810, -762, -109, 423, 84, 14, -77, -820, -345, 74, -791, 930, -618, -900, 862, -959, 289, -19, 471, -757, 793, 155, -554, 249, 830, 402, 732, -731, -866, -720, -703, -257, -439, 731, 872, -489, 676, -167, 613, -698, 415, -80, -453, -896, 333, -511, 621, -450, 624, -309, -575, 177, 141, 891, -104, -97, -367, -599, -675, 607, -225, -760, 552, -465, 804, 55, 282, 104, -929, -252,\ +-311, 900, 550, 599, -80, 774, 553, 837, -395, 541, 953, 154, -396, -596, -111, -802, -221, -337, -633, -73, -527, -82, -658, -264, 222, 375, 434, 204, -756, -703, 303, 239, -257, -365, -351, 904, 364, -743, -484, 655, -542, 446, 888, 632, -167, -260, 716, 150, 806, 723, 513, -118, -323, -683, 983, -564, 358, -16, -287, 277, -607, 87, 365, -1, 164, 401, 257, 369, -893, 145, -969, 375, -53, 541, -408, -865, 753, 258, 337, -886, 593, -378, -528, 191, 204, 566, -61, -621, 769, 524, -628, 6,\ +249, 896, -785, -776, 321, -681, 604, -740, 886, 426, -480, -983, 23, -247, 125, -666, 913, 842, -460, -797, -483, -58, -565, -587, -206, 197, 715, 764, -97, 457, -149, -226, 261, 194, -390, 431, 180, -778, 829, -657, -668, 397, 859, 152, -178, 677, -18, 687, -247, 96, 466, -572, 478, 622, -143, -25, -471, 265, 335, 957, 152, -951, -647, 670, 57, 152, -115, 206, 87, 629, -798, -125, -725, -31, 844, 398, -876, 44, 963, -211, 518, -8, -103, -999, 948, 823, 149, -803, 769, -236, -683, 527,\ +-108, -36, 18, -437, 687, -305, -526, 972, -965, 276, 420, -259, -379, -142, -747, 600, -578, 197, 673, 890, 324, -931, 755, -765, -422, 785, -369, -110, -505, 532, -208, -438, 713, 110, 853, 996, -360, 823, 289, -699, 629, -661, 560, -329, -323, 439, 571, -537, 644, -84, 25, -536, -161, 112, 169, -922, -537, -734, -423, 37, 451, -149, 408, 18, -672, 206, -784, 444, 593, -241, 502, -259, -798, -352, -658, 712, -675, -734, 627, -620, 64, -554, 999, -537, -160, -641, 464, 894, 29, 322, 566,\ +-510, -749, 982, 204, 967, -261, -986, -136, 251, -598, 995, -831, 891, 22, 761, -783, -415, 125, 470, -919, -97, -668, 85, 205, -175, -550, 502, 652, -468, 798, 775, -216, 89, -433, -24, -621, 877, -126, 951, 809, 782, 156, -618, -841, -463, 19, -723, -904, 550, 263, 991, -758, -114, 446, -731, -623, -634, 462, 48, 851, 333, -846, 480, 892, -966, -910, -436, 317, -711, -341, -294, 124, 238, -214, -281, 467, -950, -342, 913, -90, -388, -573, 740, -883, -451, 493, -500, 863, 930, 127, 530,\ +-810, 540, 541, -664, -951, -227, -420, -476, -581, -534, 549, 253, 984, -985, -84, -521, 538, 484, -440, 371, 784, -306, -850, 530, -133, 251, -799, 446, -170, -243, -674, 769, 646, 778, -680, -714, -442, 804, 901, -774, 69, 307, -293, 755, 443, 224, -918, -771, 723, 40, 132, 568, -847, -47, 844, 69, 986, -293, -459, 313, 155, 331, 69, 280, -637, 569, 104, -119, -988, 252, 857, -590, 810, -891, 484, 566, -934, -587, -290, 566, 587, 489, 870, 280, 454, -252, 613, -701, -278, 195, -198,\ +683, 533, -372, 707, -152, 371, 866, 609, -5, -372, -30, -694, 552, 192, 452, -663, 350, -985, 10, 884, 813, -592, -331, -470, 711, -941, 928, 379, -339, 220, 999, 376, 507, 179, 916, 84, 104, 392, 192, 299, -860, 218, -698, -919, -452, 37, 850, 5, -874, 287, 123, -746, -575, 776, -909, 118, 903, -275, 450, -996, -591, -920, -850, 453, -896, 73, 83, -535, -20, 287, -765, 442, 808, 45, 445, 202, 917, -208, 783, 790, -534, 373, -129, 556, -757, -69, 459, -163, -59, 265, -563, -889, 635,\ +-583, -261, -790, 799, 826, 953, 85, 619, 334, 842, 672, -869, -4, -833, 315, 942, -524, 579, 926, 628, -404, 128, -629, 161, 568, -117, -526, 223, -876, 906, 176, -549, -317, 381, 375, -801, -416, 647, 335, 253, -386, -375, -254, 635, 352, 317, 398, -422, 111, 201, 220, 554, -972, 853, 378, 956, 942, -857, -289, -333, -180, 488, -814, -42, -595, 721, 39, 644, 721, -242, -44, 643, -457, -419, 560, -863, 974, 458, 222, -882, 526, -243, -318, -343, -707, -401, 117, 677, -489, 546, -903,\ +-960, -881, -684, 125, -928, -995, -692, -773, 647, -718, -862, -814, 671, 664, -130, -856, -674, 653, 711, 194, -685, -160, 138, -27, -128, -671, -242, 526, 494, -674, 424, -921, -778, 313, -237, 332, 913, 252, 808, -936, 289, 755, 52, -139, 57, -19, -827, -775, -561, -14, 107, -84, 622, -303, -747, 258, -942, 290, 211, -919, -207, 797, 95, 794, -830, -181, -788, 757, 75, -946, -949, -988, 152, 340, 732, 886, -891, -642, -666, 321, -910, 841, 632, 298, 55, -349, 498, 287, -711, 97, 305,\ +-974, -987, 790, -64, 605, -583, -821, 345, 887, -861, 548, 894, 288, 452, 556, -448, 813, 420, 545, 967, 127, -947, 19, -314, -607, -513, -851, 254, -290, -938, -783, -93, 474, 368, -485, -935, -539, 81, 404, -283, 779, 345, -164, 53, 563, -771, 911, -323, 522, -998, 315, 415, 460, 58, -541, -878, -152, -886, 201, -446, -810, 549, -142, -575, -632, 521, 549, 209, -681, 998, 798, -611, -919, -708, -4, 677, -172, 588, 750, -435, 508, 609, 498, -535, -691, -738, 85, 615, 705, 169, 425,\ +-669, -491, -783, 73, -847, 228, -981, -812, -229, 950, -904, 175, -438, 632, -556, 910, 173, 576, -751, -53, -169, 635, 607, -944, -13, -84, 105, -644, 984, 935, 259, -445, 620, -405, 832, 167, 114, 209, -181, -944, -496, 693, -473, 137, 38, -873, -334, -353, -57, 397, 944, 698, 811, -401, 712, -667, 905, 276, -653, 368, -543, -349, 414, 287, 894, 935, 461, 55, 741, -623, -660, -773, 617, 834, 278, -121, 52, 495, -855, -440, -210, -99, 279, -661, 540, 934, 540, 784, 895, 268, -503, 513,\ +-484, -352, 528, 341, -451, 885, -71, 799, -195, -885, -585, -233, 92, 453, 994, 464, 694, 190, -561, -116, 675, -775, -236, 556, -110, -465, 77, -781, 507, -960, -410, 229, -632, 717, 597, 429, 358, -430, -692, -825, 576, 571, 758, -891, 528, -267, 190, -869, 132, -811, 796, 750, -596, -681, 870, 360, 969, 860, -412, -567, 694, -86, -498, 38, -178, -583, -778, 412, 842, -586, 722, -192, 350, 363, 81, -677, -163, 564, 543, 671, 110, 314, 739, -552, -224, -644, 922, 685, 134, 613, 793,\ +-363, -244, -284, -257, -561, 418, 988, 333, 110, -966, 790, 927, 536, -620, -309, -358, 895, -867, -796, -357, 308, -740, 287, -732, -363, -969, 658, 711, 511, 256, 590, -574, 815, -845, -84, 546, -581, -71, -334, -890, 652, -959, 320, -236, 445, -851, 825, -756, -4, 877, 308, 573, -117, 293, 686, -483, 391, 342, -550, -982, 713, 886, 552, 474, -673, 283, -591, -383, 988, 435, -131, 708, -326, -884, 87, 680, -818, -408, -486, 813, -307, -799, 23, -497, 802, -146, -100, 541, 7, -493, 577,\ +50, -270, 672, 834, 111, -788, 247, 337, 628, -33, -964, -519, 683, 54, -703, 633, -127, -448, 759, -975, 696, 2, -870, -760, 67, 696, 306, 750, 615, 155, -933, -568, 399, 795, 164, -460, 205, 439, -526, -691, 35, -136, -481, -63, 73, -598, 748, 133, 874, -29, 4, -73, 472, 389, 962, 231, -328, 240, 149, 959, 46, -207, 72, -514, -608, 0, -14, 32, 374, -478, -806, 919, -729, -286, 652, 109, 509, -879, -979, -865, 584, -92, -346, -992, 781, 401, 575, 993, -746, -33, 684, -683, 750, -105,\ +-425, -508, -627, 27, 770, -45, 338, 921, -139, -392, -933, 634, 563, 224, -780, 921, 991, 737, 22, 64, 414, -249, -687, 869, 50, 759, -97, 515, 20, -775, -332, 957, 138, -542, -835, 591, -819, 363, -715, -146, -950, -641, -35, -435, -407, -548, -984, 383, -216, -559, 853, 4, -410, -319, -831, -459, -628, -819, -324, 755, 696, -192, 238, -234, -724, -445, 915, 302, -708, 484, 224, -641, 25, -771, 528, -106, -744, -588, 913, -554, -515, -239, -843, -812, -171, 721, 543, -269, 440, 151,\ +996, -723, -557, -522, -280, -514, -593, 208, 715, 404, 353, 270, -483, -785, 318, -313, 798, 638, 764, 748, -929, -827, -318, -56, 389, -546, -958, -398, 463, -700, 461, 311, -787, -488, 877, 456, 166, 535, -995, -189, -715, 244, 40, 484, 212, -329, -351, 638, -69, -446, -292, 801, -822, 490, -486, -185, 790, 370, -340, 401, -656, 584, 561, -749, 269, -19, -294, -111, 975, 874, -73, 851, 231, -331, -684, 460, 765, -654, -76, 10, 733, 520, 521, 416, -958, -202, -186, -167, 175, 343, -50,\ +673, -763, -854, -977, -17, -853, -122, -25, 180, 149, 268, 874, -816, -745, 747, -303, -959, 390, 509, 18, -66, 275, -277, 9, 837, -124, 989, -542, -649, -845, 894, 926, 997, -847, -809, -579, -96, -372, 766, 238, -251, 503, 559, 276, -281, -102, -735, 815, 109, 175, -10, 128, 543, -558, -707, 949, 996, -422, -506, 252, 702, -930, 552, -961, 584, -79, -177, 341, -275, 503, -21, 677, -545, 8, -956, -795, -870, -254, 170, -502, -880, 106, 174, 459, 603, -600, -963, 164, -136, -641, -309,\ +-380, -707, -727, -10, 727, 952, 997, -731, -133, 269, 287, 855, 716, -650, 479, 299, -839, -308, -782, 769, 545, 663, -536, -115, 904, -986, -258, -562, 582, 664, 408, -525, -889, 471, -370, -534, -220, 310, 766, 931, -193, -897, -192, -74, -365, -256, -359, -328, 658, -691, -431, 406, 699, 425, 713, -584, -45, -588, 289, 658, -290, -880, -987, -444, 371, 904, -155, 81, -278, -708, -189, -78, 655, 342, -998, -647, -734, -218, 726, 619, 663, 744, 518, 60, -409, 561, -727, -961, -306,\ +-147, -550, 240, -218, -393, 267, 724, 791, -548, 480, 180, -631, 825, -170, 107, 227, -691, 905, -909, 359, 227, 287, 909, 632, -89, -522, 80, -429, 37, 561, -732, -474, 565, -798, -460, 188, 507, -511, -654, 212, -314, -376, -997, -114, -708, 512, -848, 781, 126, -956, -298, 354, -400, -121, 510, 445, 926, 27, -708, 676, 248, 834, 542, 236, -105, -153, 102, 128, 96, -348, -626, 598, 8, 978, -589, -461, -38, 381, -232, -817, 467, 356, -151, -460, 429, -408, 425, 618, -611, -247, 819,\ +963, -160, 1000, 141, -647, -875, 108, 790, -127, 463, -37, -195, -542, 12, 845, -384, 770, -129, 315, 826, -942, 430, 146, -170, -583, -903, -489, 497, -559, -401, -29, -129, -411, 166, 942, -646, -862, -404, 785, 777, -111, -481, -738, 490, 741, -398, 846, -178, -509, -661, 748, 297, -658, -567, 531, 427, -201, -41, -808, -668, 782, -860, -324, 249, 835, -234, 116, 542, -201, 328, 675, 480, -906, 188, 445, 63, -525, 811, 277, 133, 779, -680, 950, -477, -306, -64, 552, -890, -956, 169,\ +442, 44, -169, -243, -242, 423, -884, -757, -403, 739, -350, 383, 429, 153, -702, -725, 51, 310, 857, -56, 538, 46, -311, 132, -620, -297, -124, 534, 884, -629, -117, 506, -837, -100, -27, -381, -735, 262, 843, 703, 260, -457, 834, 469, 9, 950, 59, 127, -820, 518, 64, -783, 659, -608, -676, 802, 30, 589, 246, -369, 361, 347, 534, -376, 68, 941, 709, 264, 384, 481, 628, 199, -568, -342, -337, 853, -804, -858, -169, -270, 641, -344, 112, 530, -773, -349, -135, -367, -350, -756, -911, 180,\ +-660, 116, -478, -265, -581, 510, 520, -986, 935, 219, 522, 744, 47, -145, 917, 638, 301, 296, 858, -721, 511, -816, 328, 473, 441, 697, -260, -673, -379, 893, 458, 154, 86, 905, 590, 231, -717, -179, 79, 272, -439, -192, 178, -200, 51, 717, -256, -358, -626, -518, -314, -825, -325, 588, 675, -892, -798, 448, -518, 603, -23, 668, -655, 845, -314, 783, -347, -496, 921, 893, -163, -748, -906, 11, -143, -64, 300, 336, 882, 646, 533, 676, -98, -148, -607, -952, -481, -959, -874, 764, 537,\ +736, -347, 646, -843, 966, -916, -718, -391, -648, 740, 755, 919, -608, 388, -655, 68, 201, 675, -855, 7, -503, 881, 760, 669, 831, 721, -564, -445, 217, 331, 970, 521, 486, -254, 25, -259, 336, -831, 252, -995, 908, -412, -240, 123, -478, 366, 264, -504, -843, 632, -288, 896, 301, 423, 185, 318, 380, 457, -450, -162, -313, 673, -963, 570, 433, -548, 107, -39, -142, -98, -884, -3, 599, -486, -926, 923, -82, 686, 290, 99, -382, -789, 16, 495, 570, 284, 474, -504, -201, -178, -1, 592, 52,\ +827, -540, -151, -991, 130, 353, -420, -467, -661, 417, -690, 942, 936, 814, -566, -251, -298, 341, -139, 786, 129, 525, -861, 680, 955, -245, -50, 331, 412, -38, -66, 611, -558, 392, -629, -471, -68, -535, 744, 495, 87, 558, 695, 260, -308, 215, -464, 239, -50, 193, -540, 184, -8, -194, 148, 898, -557, -21, 884, 644, -785, -689, -281, -737, 267, 50, 206, 292, 265, 380, -511, 310, 53, 375, -497, -40, 312, -606, -395, 142, 422, 662, -584, 72, 144, 40, -679, -593, 581, 689, -829, 442, 822,\ +977, -832, -134, -248, -207, 248, 29, 259, 189, 592, -834, -866, 102, 0, 340, 25, -354, -239, 420, -730, -992, -925, -314, 420, 914, 607, -296, -415, -30, 813, 866, 153, -90, 150, -81, 636, -392, -222, -835, 482, -631, -962, -413, -727, 280, 686, -382, 157, -404, -511, -432, 455, 58, 108, -408, 290, -829, -252, 113, 550, -935, 925, 422, 38, 789, 361, 487, -460, -769, -963, -285, 206, -799, -488, -233, 416, 143, -456, 753, 520, 599, 621, -168, 178, -841, 51, 952, 374, 166, -300, -576, 844,\ +-656, 90, 780, 371, 730, -896, -895, -386, -662, 467, -61, 130, -362, -675, -113, 135, -761, -55, 408, 822, 675, -347, 725, 114, 952, -510, -972, 390, -413, -277, -52, 315, -80, 401, -712, 147, -202, 84, 214, -178, 970, -571, -210, 525, -887, -863, 504, 192, 837, -594, 203, -876, -209, 305, -826, 377, 103, -928, -803, -956, 949, -868, -547, 824, -994, 516, 93, -524, -866, -890, -988, -501, 15, -6, 413, -825, 304, -818, -223, 525, 176, 610, 828, 391, 940, 540, -831, 650, 438, 589, 941, 57,\ +523, 126, 221, 860, -282, -262, -226, 764, 743, -640, 390, 384, -434, 608, -983, 566, -446, 618, 456, -176, -278, 215, 871, -180, 444, -931, -200, -781, 404, 881, 780, -782, 517, -739, -548, -811, 201, -95, -249, -228, 491, -299, 700, 964, -550, 108, 334, -653, 245, -293, -552, 350, -685, -415, -818, 216, -194, -255, 295, 249, 408, 351, 287, 379, 682, 231, -693, 902, -902, 574, 937, -708, -402, -460, 827, -268, 791, 343, -780, -150, -738, 920, -430, -88, -361, -588, -727, -47, -297, 662,\ +-840, -637, -635, 916, -857, 938, 132, -553, 391, -522, 640, 626, 690, 833, 867, -555, 577, 226, 686, -44, 0, -965, 651, -1, 909, 595, -646, 740, -821, -648, -962, 927, -193, 159, 490, 594, -189, 707, -884, 759, -278, -160, -566, -340, 19, 862, -440, 445, -598, 341, 664, -311, 309, -159, 19, -672, 705, -646, 976, 247, 686, -830, -27, -667, 81, 399, -423, -567, 945, 38, 51, 740, 621, 204, -199, -908, -593, 424, 250, -561, 695, 9, 520, 878, 120, -109, 42, -375, -635, -711, -687, 383, -278,\ +36, 970, 925, 864, 836, 309, 117, 89, 654, -387, 346, -53, 617, -164, -624, 184, -45, 852, 498, -513, 794, -682, -576, 13, -147, 285, -776, -886, -96, 483, 994, -188, 346, -629, -848, 738, 51, 128, -898, -753, -906, 270, -203, -577, 48, -243, -210, 666, 353, 636, -954, 862, 560, -944, -877, -137, 440, -945, -316, 274, -211, -435, 615, -635, -468, 744, 948, -589, 525, 757, -191, -431, 42, 451, -160, -827, -991, 324, 697, 342, -610, 894, -787, -384, 872, 734, 878, 70, -260, 57, 397, -518,\ +629, -510, -94, 207, 214, -625, 106, -882, -575, 908, -650, 723, -154, 45, 108, -69, -565, 927, -68, -351, 707, -282, 429, -889, -596, 848, 578, -492, 41, -822, -992, 168, -286, -780, 970, 597, -293, -12, 367, 708, -415, 194, -86, -390, 224, 69, -368, -674, 1000, -672, 356, -202, -169, 826, 476, -285, 29, -448, 545, 186, 319, 67, 705, 412, 225, -212, -351, -391, -783, -9, 875, -59, -159, -123, -151, -296, 871, -638, 359, 909, -945, 345, -16, -562, -363, -183, -625, -115, -571, -329, 514,\ +99, 263, 463, -39, 597, -652, -349, 246, 77, -127, -563, -879, -30, 756, 777, -865, 675, -813, -501, 871, -406, -627, 834, -609, -205, -812, 643, -204, 291, -251, -184, -584, -541, 410, -573, -600, 908, -871, -687, 296, -713, -139, -778, -790, 347, -52, -400, 407, -653, 670, 39, -856, 904, 433, 392, 590, -271, -144, -863, 443, 353, 468, -544, 486, -930, 458, -596, -890, 163, 822, 768, 980, -783, -792, 126, 386, 367, -264, 603, -61, 728, 160, -4, -837, 832, 591, 436, 518, 796, -622, -867,\ +-669, -947, 253, 100, -792, 841, 413, 833, -249, -550, 282, -825, 936, -348, 898, -451, -283, 818, -237, 630, 216, -499, -637, -511, 767, -396, 221, 958, -586, -920, 401, -313, -580, -145, -270, 118, 497, 426, -975, 480, -445, -150, -721, -929, 439, -893, 902, 960, -525, -793, 924, 563, 683, -727, -86, 309, 432, -762, -345, 371, -617, 149, -215, -228, 505, 593, -20, -292, 704, -999, 149, -104, 819, -414, -443, 517, -599, -5, 145, -24, -993, -283, 904, 174, -112, -276, -860, 44, -257,\ +-931, -821, -667, 540, 421, 485, 531, 407, 833, 431, -415, 878, 503, -901, 639, -608, 896, 860, 927, 424, 113, -808, -323, 729, 382, -922, 548, -791, -379, 207, 203, 559, 537, 137, 999, -913, -240, 942, 249, 616, 775, -4, 915, 855, -987, -234, -384, 948, -310, -542, 125, -289, -599, 967, -492, -349, -552, 562, -926, 632, -164, 217, -165, -496, 847, 684, -884, 457, -748, -745, -38, 93, 961, 934, 588, 366, -130, 851, -803, -811, -211, 428, 183, -469, 888, 596, -475, -899, -681, 508, 184,\ +921, 863, -610, -416, -119, -966, -686, 210, 733, 715, -889, -925, -434, -566, -455, 596, -514, 983, 755, -194, -802, -313, 91, -541, 808, -834, 243, -377, 256, 966, -402, -773, -308, -605, 266, 866, 118, -425, -531, 498, 666, 813, -267, 830, 69, -869, -496, 735, 28, 488, -645, -493, -689, 170, -940, 532, 844, -658, -617, 408, -200, 764, -665, 568, 342, 621, 908, 471, 280, 859, 709, 898, 81, -547, 406, 514, -595, 43, -824, -696, -746, -429, -59, -263, -813, 233, 279, -125, 687, -418,\ +-530, 409, 614, 803, -407, 78, -676, -39, -887, -141, -292, 270, -343, 400, 907, 588, 668, 899, 973, 103, -101, -11, 397, -16, 165, 705, -410, -585, 316, 391, -346, -336, 957, -118, -538, -441, -845, 121, 591, -359, -188, -362, -208, 27, -925, -157, -495, -177, -580, 9, 531, -752, 94, 107, 820, 769, -500, 852, 617, 145, 355, 34, -463, -265, -709, -111, -855, -405, 560, 470, 3, -177, -164, -249, 450, 662, 841, -689, -509, 987, -33, 769, 234, -2, 203, 780, 744, -895, 497, -432, -406, -264,\ +-71, 124, 778, -897, 495, 127, -76, 52, -768, 205, 464, -992, 801, -83, -806, 545, -316, 146, 772, 786, 289, -936, 145, -30, -722, -455, 270, 444, 427, -482, 383, -861, 36, 630, -404, 83, 864, 743, -351, -846, 315, -837, 357, -195, 450, -715, 227, -942, 740, -519, 476, 716, 713, 169, 492, -112, -49, -931, 866, 95, -725, 198, -50, -17, -660, 356, -142, -781, 53, 431, 720, 143, -416, 446, -497, 490, -96, 157, 239, 487, -337, -224, -445, 813, 92, -22, 603, 424, 952, -632, -367, 898, -927,\ +884, -277, -187, -777, 537, -575, -313, 347, -33, 800, 672, -919, -541, 5, -270, -94, -265, -793, -183, -761, -516, -608, -218, 57, -889, -912, 508, 93, -90, 34, 530, 201, 999, -37, -186, -62, -980, 239, 902, 983, -287, -634, 524, -772, 470, -961, 32, 162, 315, -411, 400, -235, -283, -787, -703, 869, 792, 543, -274, 239, 733, -439, 306, 349, 579, -200, -201, -824, 384, -246, 133, -508, 770, -102, 957, -825, 740, 748, -376, 183, -426, 46, 668, -886, -43, -174, 672, -419, 390, 927, 1000,\ +318, 886, 47, 908, -540, -825, -5, 314, -999, 354, -603, 966, -633, -689, 985, 534, -290, 167, -652, -797, -612, -79, 488, 622, -464, -950, 595, 897, 704, -238, -395, 125, 831, -180, 226, -379, 310, 564, 56, -978, 895, -61, 686, -251, 434, -417, 161, -512, 752, 528, -589, -425, 66, -925, -157, 1000, 96, 256, -239, -784, -882, -464, -909, 663, -177, -678, -441, 669, -564, -201, -121, -743, 187, -107, -768, -682, 355, 161, 411, 984, -954, 166, -842, -755, 267, -709, 372, -699, -272, -850,\ +403, -839, 949, 622, -62, 51, 917, 70, 528, -558, -632, 832, 276, 61, -445, -195, 960, 846, -474, 764, 879, -411, 948, -62, -592, -123, -96, -551, -555, -724, 849, 250, -808, -732, 797, -839, -554, 306, -919, 888, 484, -728, 152, -122, -287, 16, -345, -396, -268, -963, -500, 433, 343, 418, -480, 828, 594, 821, -9, 933, -230, 707, -847, -610, -748, -234, 688, 935, 713, 865, -743, 293, -143, -20, 928, -906, -762, 528, 722, 412, -70, 622, -245, 539, -686, 730, -866, -705, 28, -916, -623,\ +-768, -614, -915, -123, -183, 680, -223, 515, -37, -235, -5, 260, 347, -239, -322, -861, -848, -936, 945, 721, -580, -639, 780, -153, -26, 685, 177, 587, 307, -915, 435, 658, 539, -229, -719, -171, -858, 162, 734, -539, -437, 246, 639, 765, -477, -342, -209, -284, -779, -414, -452, 914, 338, -83, 759, 567, 266, -485, 14, 225, 347, -432, -242, 997, -365, -764, 119, -641, -416, -388, -436, -388, -54, -649, -571, -920, -477, 714, -363, 836, 369, 702, 869, 503, -287, -679, 46, -666, -202,\ +-602, 71, -259, 967, 601, -571, -830, -993, -271, 281, -494, 482, -180, 572, 587, -651, -566, -448, -228, 511, -924, 832, -52, -712, 402, -644, -533, -865, 269, 965, 56, 675, 179, -338, -272, 614, 602, -283, 303, -70, 909, -942, 117, 839, 468, 813, -765, 884, -697, -813, 352, 374, -705, -295, 633, 211, -754, 597, -941, -142, -393, -469, -653, 688, 996, 911, 214, 431, 453, -141, 874, -81, -258, -735, -3, -110, -338, -929, -182, -306, -104, -840, -588, -759, -157, -801, 848, -698, 627, 914,\ +-33, -353, 425, 150, -798, 553, 934, -778, -196, -132, 808, 745, -894, 144, 213, 662, 273, -79, 454, -60, -467, 48, -15, -807, 69, -930, 749, 559, -867, -103, 258, -677, 750, -303, 846, -227, -936, 744, -770, 770, -434, 594, -477, 589, -612, 535, 357, -623, 683, 369, 905, 980, -410, -663, 762, -888, -563, -845, 843, 353, -491, 996, -255, -336, -132, 695, -823, 289, -143, 365, 916, 877, 245, -530, -848, -804, -118, -108, 847, 620, -355, 499, 881, 92, -640, 542, 38, 626, -260, -34, -378,\ +598, 890, 305, -118, 711, -385, 600, -570, 27, -129, -893, 354, 459, 374, 816, 470, 356, 661, 877, 735, -286, -780, 620, 943, -169, -888, 978, 441, -667, -399, 662, 249, 137, 598, -863, -453, 722, -815, -251, -995, -294, -707, 901, 763, 977, 137, 431, -994, 905, 593, 694, 444, -626, -816, 252, 282, 616, 841, 360, -932, 817, -908, 50, 394, -120, -786, -338, 499, -982, -95, -454, 838, -312, 320, -127, -653, 53, 16, 988, -968, -151, -369, -836, 293, -271, 483, 18, 724, -204, -965, 245, 310,\ +987, 552, -835, -912, -861, 254, 560, 124, 145, 798, 178, 476, 138, -311, 151, -907, -886, -592, 728, -43, -489, 873, -422, -439, -489, 375, -703, -459, 338, 418, -25, 332, -454, 730, -604, -800, 37, -172, -197, -568, -563, -332, 228, -182, 994, -123, 444, -567, 98, 78, 0, -504, -150, 88, -936, 199, -651, -776, 192, 46, 526, -727, -991, 534, -659, -738, 256, -894, 965, -76, 816, 435, -418, 800, 838, 67, -733, 570, 112, -514, -416\r\ +"; + thread_local! { + static TEST_TERM_AND_POINT: (Term, AlacPoint) = + build_test_term(&LINE, 5, 50); + } + TEST_TERM_AND_POINT.with(|(term, point)| { + assert_eq!( + find_from_grid_point_bench(term, *point) + .map(|(path, ..)| path) + .unwrap_or_default(), + "392", + "Hyperlink should have been found" + ); + }); + } + + #[perf] + // https://github.com/zed-industries/zed/issues/44510 + pub fn issue_44510_hyperlink_benchmark() { + const LINE: &str = "..............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................\ +..............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................\ +..............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................\ +..............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................\ +..............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................\ +..............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................\ +..............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................\ +..............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................\ +..............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................\ +..............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................\ +..............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................\ +..............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................\ +..............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................\ +..............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................\ +...............................................E.\r\ +"; + thread_local! { + static TEST_TERM_AND_POINT: (Term, AlacPoint) = + build_test_term(&LINE, 5, 50); + } + TEST_TERM_AND_POINT.with(|(term, point)| { + assert_eq!( + find_from_grid_point_bench(term, *point) + .map(|(path, ..)| path) + .unwrap_or_default(), + LINE.trim_end_matches(['.', '\r', '\n']), "Hyperlink should have been found" ); }); From 65f7412a0265552b06ce122655369d6cc7381dd6 Mon Sep 17 00:00:00 2001 From: Michael Benfield Date: Wed, 17 Dec 2025 13:02:03 -0800 Subject: [PATCH 467/621] A couple new inline assistant tests (#45049) Also adjust the code for streaming tool use to always use a rewrite_section; remove insert_here entirely. Release Notes: - N/A Co-authored-by: Max Brunsfeld --- assets/prompts/content_prompt_v2.hbs | 3 - crates/agent_ui/src/buffer_codegen.rs | 96 +++++++++++++++++++++++-- crates/agent_ui/src/inline_assistant.rs | 30 ++++++++ crates/prompt_store/src/prompts.rs | 28 +++----- 4 files changed, 130 insertions(+), 27 deletions(-) diff --git a/assets/prompts/content_prompt_v2.hbs b/assets/prompts/content_prompt_v2.hbs index 87376f49f12f0e27cc61e9f9747d9de6bfde43cb..826aada8c04863c21d756cf99beb64e582ed4906 100644 --- a/assets/prompts/content_prompt_v2.hbs +++ b/assets/prompts/content_prompt_v2.hbs @@ -14,7 +14,6 @@ The section you'll need to rewrite is marked with The context around the relevant section has been truncated (possibly in the middle of a line) for brevity. {{/if}} -{{#if rewrite_section}} And here's the section to rewrite based on that prompt again for reference: @@ -33,8 +32,6 @@ Below are the diagnostic errors visible to the user. If the user requests probl {{/each}} {{/if}} -{{/if}} - Only make changes that are necessary to fulfill the prompt, leave everything else as-is. All surrounding {{content_type}} will be preserved. Start at the indentation level in the original file in the rewritten {{content_type}}. diff --git a/crates/agent_ui/src/buffer_codegen.rs b/crates/agent_ui/src/buffer_codegen.rs index 87ce6d386b38f31a0d7b550aab00bb766ce75010..a296d4d20918fba6eb32bfcf7fcc657f9db2b3ac 100644 --- a/crates/agent_ui/src/buffer_codegen.rs +++ b/crates/agent_ui/src/buffer_codegen.rs @@ -75,6 +75,9 @@ pub struct BufferCodegen { session_id: Uuid, } +pub const REWRITE_SECTION_TOOL_NAME: &str = "rewrite_section"; +pub const FAILURE_MESSAGE_TOOL_NAME: &str = "failure_message"; + impl BufferCodegen { pub fn new( buffer: Entity, @@ -522,12 +525,12 @@ impl CodegenAlternative { let tools = vec![ LanguageModelRequestTool { - name: "rewrite_section".to_string(), + name: REWRITE_SECTION_TOOL_NAME.to_string(), description: "Replaces text in tags with your replacement_text.".to_string(), input_schema: language_model::tool_schema::root_schema_for::(tool_input_format).to_value(), }, LanguageModelRequestTool { - name: "failure_message".to_string(), + name: FAILURE_MESSAGE_TOOL_NAME.to_string(), description: "Use this tool to provide a message to the user when you're unable to complete a task.".to_string(), input_schema: language_model::tool_schema::root_schema_for::(tool_input_format).to_value(), }, @@ -1167,7 +1170,7 @@ impl CodegenAlternative { let process_tool_use = move |tool_use: LanguageModelToolUse| -> Option { let mut chars_read_so_far = chars_read_so_far.lock(); match tool_use.name.as_ref() { - "rewrite_section" => { + REWRITE_SECTION_TOOL_NAME => { let Ok(input) = serde_json::from_value::(tool_use.input) else { @@ -1180,7 +1183,7 @@ impl CodegenAlternative { description: None, }) } - "failure_message" => { + FAILURE_MESSAGE_TOOL_NAME => { let Ok(mut input) = serde_json::from_value::(tool_use.input) else { @@ -1493,7 +1496,10 @@ mod tests { use indoc::indoc; use language::{Buffer, Point}; use language_model::fake_provider::FakeLanguageModel; - use language_model::{LanguageModelRegistry, TokenUsage}; + use language_model::{ + LanguageModelCompletionError, LanguageModelCompletionEvent, LanguageModelRegistry, + LanguageModelToolUse, StopReason, TokenUsage, + }; use languages::rust_lang; use rand::prelude::*; use settings::SettingsStore; @@ -1805,6 +1811,51 @@ mod tests { ); } + // When not streaming tool calls, we strip backticks as part of parsing the model's + // plain text response. This is a regression test for a bug where we stripped + // backticks incorrectly. + #[gpui::test] + async fn test_allows_model_to_output_backticks(cx: &mut TestAppContext) { + init_test(cx); + let text = "- Improved; `cmd+click` behavior. Now requires `cmd` to be pressed before the click starts or it doesn't run. ([#44579](https://github.com/zed-industries/zed/pull/44579); thanks [Zachiah](https://github.com/Zachiah))"; + let buffer = cx.new(|cx| Buffer::local("", cx)); + let buffer = cx.new(|cx| MultiBuffer::singleton(buffer, cx)); + let range = buffer.read_with(cx, |buffer, cx| { + let snapshot = buffer.snapshot(cx); + snapshot.anchor_before(Point::new(0, 0))..snapshot.anchor_after(Point::new(0, 0)) + }); + let prompt_builder = Arc::new(PromptBuilder::new(None).unwrap()); + let codegen = cx.new(|cx| { + CodegenAlternative::new( + buffer.clone(), + range.clone(), + true, + prompt_builder, + Uuid::new_v4(), + cx, + ) + }); + + let events_tx = simulate_tool_based_completion(&codegen, cx); + let chunk_len = text.find('`').unwrap(); + events_tx + .unbounded_send(rewrite_tool_use("tool_1", &text[..chunk_len], false)) + .unwrap(); + events_tx + .unbounded_send(rewrite_tool_use("tool_2", &text, true)) + .unwrap(); + events_tx + .unbounded_send(LanguageModelCompletionEvent::Stop(StopReason::EndTurn)) + .unwrap(); + drop(events_tx); + cx.run_until_parked(); + + assert_eq!( + buffer.read_with(cx, |buffer, cx| buffer.snapshot(cx).text()), + text + ); + } + #[gpui::test] async fn test_strip_invalid_spans_from_codeblock() { assert_chunks("Lorem ipsum dolor", "Lorem ipsum dolor").await; @@ -1870,4 +1921,39 @@ mod tests { }); chunks_tx } + + fn simulate_tool_based_completion( + codegen: &Entity, + cx: &mut TestAppContext, + ) -> mpsc::UnboundedSender { + let (events_tx, events_rx) = mpsc::unbounded(); + let model = Arc::new(FakeLanguageModel::default()); + codegen.update(cx, |codegen, cx| { + let completion_stream = Task::ready(Ok(events_rx.map(Ok).boxed() + as BoxStream< + 'static, + Result, + >)); + codegen.generation = codegen.handle_completion(model, completion_stream, cx); + }); + events_tx + } + + fn rewrite_tool_use( + id: &str, + replacement_text: &str, + is_complete: bool, + ) -> LanguageModelCompletionEvent { + let input = RewriteSectionInput { + replacement_text: replacement_text.into(), + }; + LanguageModelCompletionEvent::ToolUse(LanguageModelToolUse { + id: id.into(), + name: REWRITE_SECTION_TOOL_NAME.into(), + raw_input: serde_json::to_string(&input).unwrap(), + input: serde_json::to_value(&input).unwrap(), + is_input_complete: is_complete, + thought_signature: None, + }) + } } diff --git a/crates/agent_ui/src/inline_assistant.rs b/crates/agent_ui/src/inline_assistant.rs index 052d8598a76d1044c6d97b5378041b5cd12e23b3..671579f9ef018b495b7993279a852595c78d3e02 100644 --- a/crates/agent_ui/src/inline_assistant.rs +++ b/crates/agent_ui/src/inline_assistant.rs @@ -2271,6 +2271,36 @@ pub mod evals { ); } + #[test] + #[cfg_attr(not(feature = "unit-eval"), ignore)] + fn eval_empty_buffer() { + run_eval( + 20, + 1.0, + "Write a Python hello, world program".to_string(), + "ˇ".to_string(), + |output| match output { + InlineAssistantOutput::Success { + full_buffer_text, .. + } => { + if full_buffer_text.is_empty() { + EvalOutput::failed("expected some output".to_string()) + } else { + EvalOutput::passed(format!("Produced {full_buffer_text}")) + } + } + o @ InlineAssistantOutput::Failure { .. } => EvalOutput::failed(format!( + "Assistant output does not match expected output: {:?}", + o + )), + o @ InlineAssistantOutput::Malformed { .. } => EvalOutput::failed(format!( + "Assistant output does not match expected output: {:?}", + o + )), + }, + ); + } + fn run_eval( iterations: usize, expected_pass_ratio: f32, diff --git a/crates/prompt_store/src/prompts.rs b/crates/prompt_store/src/prompts.rs index 674d4869e9825fd700dde3db510fbf68c6b4d5cc..6a845bb8dd394f8a1ff26a8a0e130156a2a158bd 100644 --- a/crates/prompt_store/src/prompts.rs +++ b/crates/prompt_store/src/prompts.rs @@ -112,7 +112,7 @@ pub struct ContentPromptContextV2 { pub language_name: Option, pub is_truncated: bool, pub document_content: String, - pub rewrite_section: Option, + pub rewrite_section: String, pub diagnostic_errors: Vec, } @@ -310,7 +310,6 @@ impl PromptBuilder { }; const MAX_CTX: usize = 50000; - let is_insert = range.is_empty(); let mut is_truncated = false; let before_range = 0..range.start; @@ -335,28 +334,19 @@ impl PromptBuilder { for chunk in buffer.text_for_range(truncated_before) { document_content.push_str(chunk); } - if is_insert { - document_content.push_str(""); - } else { - document_content.push_str("\n"); - for chunk in buffer.text_for_range(range.clone()) { - document_content.push_str(chunk); - } - document_content.push_str("\n"); + + document_content.push_str("\n"); + for chunk in buffer.text_for_range(range.clone()) { + document_content.push_str(chunk); } + document_content.push_str("\n"); + for chunk in buffer.text_for_range(truncated_after) { document_content.push_str(chunk); } - let rewrite_section = if !is_insert { - let mut section = String::new(); - for chunk in buffer.text_for_range(range.clone()) { - section.push_str(chunk); - } - Some(section) - } else { - None - }; + let rewrite_section: String = buffer.text_for_range(range.clone()).collect(); + let diagnostics = buffer.diagnostics_in_range::<_, Point>(range, false); let diagnostic_errors: Vec = diagnostics .map(|entry| { From 52c7447106320442be576f3d55a1410259da8046 Mon Sep 17 00:00:00 2001 From: Cameron Mcloughlin Date: Wed, 17 Dec 2025 21:53:12 +0000 Subject: [PATCH 468/621] gpui: Add Vietnamese chars to `LineWrapper::is_word_char` (#45160) --- crates/gpui/src/text_system/line_wrapper.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/crates/gpui/src/text_system/line_wrapper.rs b/crates/gpui/src/text_system/line_wrapper.rs index 45159313b43c508029f2525234c80c6575d0f695..e4e18671a3d85c2f55abd8f8a61ec80833dabdf5 100644 --- a/crates/gpui/src/text_system/line_wrapper.rs +++ b/crates/gpui/src/text_system/line_wrapper.rs @@ -182,6 +182,11 @@ impl LineWrapper { // Cyrillic for Russian, Ukrainian, etc. // https://en.wikipedia.org/wiki/Cyrillic_script_in_Unicode matches!(c, '\u{0400}'..='\u{04FF}') || + + // Vietnamese (https://vietunicode.sourceforge.net/charset/) + matches!(c, '\u{1E00}'..='\u{1EFF}') || // Latin Extended Additional + matches!(c, '\u{0300}'..='\u{036F}') || // Combining Diacritical Marks + // Some other known special characters that should be treated as word characters, // e.g. `a-b`, `var_name`, `I'm`, '@mention`, `#hashtag`, `100%`, `3.1415`, // `2^3`, `a~b`, `a=1`, `Self::new`, etc. @@ -618,7 +623,12 @@ mod tests { #[track_caller] fn assert_word(word: &str) { for c in word.chars() { - assert!(LineWrapper::is_word_char(c), "assertion failed for '{}'", c); + assert!( + LineWrapper::is_word_char(c), + "assertion failed for '{}' (unicode 0x{:x})", + c, + c as u32 + ); } } @@ -661,6 +671,8 @@ mod tests { assert_word("ƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏ"); // Cyrillic assert_word("АБВГДЕЖЗИЙКЛМНОП"); + // Vietnamese (https://github.com/zed-industries/zed/issues/23245) + assert_word("ThậmchíđếnkhithuachạychúngcònnhẫntâmgiếtnốtsốđôngtùchínhtrịởYênBáivàCaoBằng"); // non-word characters assert_not_word("你好"); From c4f8f2fbf4b68c6f39279fc99ef8ceea74891588 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Thu, 18 Dec 2025 00:22:37 +0200 Subject: [PATCH 469/621] Use less generic globs for JSONC to avoid overmatching (#45162) Otherwise, all *.json files under `zed` directory will be matched as JSONC, e.g `zed/crates/vim/test_data/test_a.json` which is not right. On top, `globset` considers that `zed/crates/vim/test_data/test_a.json` matches `**/zed/*.json` glob (!). Release Notes: - N/A --- assets/settings/default.json | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/assets/settings/default.json b/assets/settings/default.json index a0280b402a0d5c6b71aca296021cc7f43c222521..e7df5ef0bf2d3bc805c79f79811d9929343544ef 100644 --- a/assets/settings/default.json +++ b/assets/settings/default.json @@ -1705,7 +1705,12 @@ // } // "file_types": { - "JSONC": ["**/.zed/**/*.json", "**/zed/**/*.json", "**/Zed/**/*.json", "**/.vscode/**/*.json", "tsconfig*.json"], + "JSONC": [ + "**/.zed/*.json", + "**/.vscode/**/*.json", + "**/{zed,Zed}/{settings,keymap,tasks,debug}.json", + "tsconfig*.json", + ], "Markdown": [".rules", ".cursorrules", ".windsurfrules", ".clinerules"], "Shell Script": [".env.*"], }, From 302a4bbdd0d30286b7688c4f2972e2f99d66999e Mon Sep 17 00:00:00 2001 From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Date: Wed, 17 Dec 2025 19:28:27 -0300 Subject: [PATCH 470/621] git panel: Fix file path truncation and add some UI code clean up (#45161) This PR ensures truncation works for the file paths, which should set up the stage for when the new GPUI `truncation_start` method lands (https://github.com/zed-industries/zed/pull/45122) so that we can use for them. In the process of doing so and figuring it out why it wasn't working as well before, I noticed some opportunities to clean up some UI code: removing unnecessary styles, making the file easier to navigate given all of the different UI conditions, etc. Note: You might notice a subtle label flashing that comes with the label truncation and that's a standalone GPUI bug that's also visible in other surface areas of the app. I don't think it should block these changes here as it's something we should fix on its own... Release Notes: - N/A --- crates/git_ui/src/git_panel.rs | 307 +++++++++++++++------------------ 1 file changed, 135 insertions(+), 172 deletions(-) diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs index 7216e1fc46e9d1240d23d8bd18202aa0963f846a..d392813d7602b19f04e66dd7c892cee40e8e243d 100644 --- a/crates/git_ui/src/git_panel.rs +++ b/crates/git_ui/src/git_panel.rs @@ -35,10 +35,9 @@ use git::{ }; use gpui::{ Action, AsyncApp, AsyncWindowContext, Bounds, ClickEvent, Corner, DismissEvent, Entity, - EventEmitter, FocusHandle, Focusable, KeyContext, ListHorizontalSizingBehavior, - ListSizingBehavior, MouseButton, MouseDownEvent, Point, PromptLevel, ScrollStrategy, - Subscription, Task, UniformListScrollHandle, WeakEntity, actions, anchored, deferred, point, - size, uniform_list, + EventEmitter, FocusHandle, Focusable, KeyContext, MouseButton, MouseDownEvent, Point, + PromptLevel, ScrollStrategy, Subscription, Task, UniformListScrollHandle, WeakEntity, actions, + anchored, deferred, point, size, uniform_list, }; use itertools::Itertools; use language::{Buffer, File}; @@ -212,8 +211,7 @@ const GIT_PANEL_KEY: &str = "GitPanel"; const UPDATE_DEBOUNCE: Duration = Duration::from_millis(50); // TODO: We should revise this part. It seems the indentation width is not aligned with the one in project panel -const TREE_INDENT: f32 = 12.0; -const TREE_INDENT_GUIDE_OFFSET: f32 = 16.0; +const TREE_INDENT: f32 = 16.0; pub fn register(workspace: &mut Workspace) { workspace.register_action(|workspace, _: &ToggleFocus, window, cx| { @@ -4697,7 +4695,10 @@ impl GitPanel { }, ) .with_render_fn(cx.entity(), |_, params, _, _| { - let left_offset = px(TREE_INDENT_GUIDE_OFFSET); + // Magic number to align the tree item is 3 here + // because we're using 12px as the left-side padding + // and 3 makes the alignment work with the bounding box of the icon + let left_offset = px(TREE_INDENT + 3_f32); let indent_size = params.indent_size; let item_height = params.item_height; @@ -4725,10 +4726,6 @@ impl GitPanel { }) .size_full() .flex_grow() - .with_sizing_behavior(ListSizingBehavior::Auto) - .with_horizontal_sizing_behavior( - ListHorizontalSizingBehavior::Unconstrained, - ) .with_width_from_item(self.max_width_item_index) .track_scroll(&self.scroll_handle), ) @@ -4752,7 +4749,7 @@ impl GitPanel { } fn entry_label(&self, label: impl Into, color: Color) -> Label { - Label::new(label.into()).color(color).single_line() + Label::new(label.into()).color(color) } fn list_item_height(&self) -> Rems { @@ -4774,8 +4771,8 @@ impl GitPanel { .h(self.list_item_height()) .w_full() .items_end() - .px(rems(0.75)) // ~12px - .pb(rems(0.3125)) // ~ 5px + .px_3() + .pb_1() .child( Label::new(header.title()) .color(Color::Muted) @@ -4963,113 +4960,68 @@ impl GitPanel { let marked_bg_alpha = 0.12; let state_opacity_step = 0.04; + let info_color = cx.theme().status().info; + let base_bg = match (selected, marked) { - (true, true) => cx - .theme() - .status() - .info - .alpha(selected_bg_alpha + marked_bg_alpha), - (true, false) => cx.theme().status().info.alpha(selected_bg_alpha), - (false, true) => cx.theme().status().info.alpha(marked_bg_alpha), + (true, true) => info_color.alpha(selected_bg_alpha + marked_bg_alpha), + (true, false) => info_color.alpha(selected_bg_alpha), + (false, true) => info_color.alpha(marked_bg_alpha), _ => cx.theme().colors().ghost_element_background, }; - let hover_bg = if selected { - cx.theme() - .status() - .info - .alpha(selected_bg_alpha + state_opacity_step) - } else { - cx.theme().colors().ghost_element_hover - }; - - let active_bg = if selected { - cx.theme() - .status() - .info - .alpha(selected_bg_alpha + state_opacity_step * 2.0) + let (hover_bg, active_bg) = if selected { + ( + info_color.alpha(selected_bg_alpha + state_opacity_step), + info_color.alpha(selected_bg_alpha + state_opacity_step * 2.0), + ) } else { - cx.theme().colors().ghost_element_active + ( + cx.theme().colors().ghost_element_hover, + cx.theme().colors().ghost_element_active, + ) }; - let mut name_row = h_flex() - .items_center() - .gap_1() + let name_row = h_flex() + .min_w_0() .flex_1() - .pl(if tree_view { - px(depth as f32 * TREE_INDENT) - } else { - px(0.) - }) - .child(git_status_icon(status)); - - name_row = if tree_view { - name_row.child( - self.entry_label(display_name, label_color) - .when(status.is_deleted(), Label::strikethrough) - .truncate(), - ) - } else { - name_row.child(h_flex().items_center().flex_1().map(|this| { - self.path_formatted( - this, - entry.parent_dir(path_style), - path_color, - display_name, - label_color, - path_style, - git_path_style, - status.is_deleted(), - ) - })) - }; + .gap_1() + .child(git_status_icon(status)) + .map(|this| { + if tree_view { + this.pl(px(depth as f32 * TREE_INDENT)).child( + self.entry_label(display_name, label_color) + .when(status.is_deleted(), Label::strikethrough) + .truncate(), + ) + } else { + this.child(self.path_formatted( + entry.parent_dir(path_style), + path_color, + display_name, + label_color, + path_style, + git_path_style, + status.is_deleted(), + )) + } + }); h_flex() .id(id) .h(self.list_item_height()) .w_full() + .pl_3() + .pr_1() + .gap_1p5() .border_1() .border_r_2() .when(selected && self.focus_handle.is_focused(window), |el| { el.border_color(cx.theme().colors().panel_focused_border) }) - .px(rems(0.75)) // ~12px - .overflow_hidden() - .flex_none() - .gap_1p5() .bg(base_bg) - .hover(|this| this.bg(hover_bg)) - .active(|this| this.bg(active_bg)) - .on_click({ - cx.listener(move |this, event: &ClickEvent, window, cx| { - this.selected_entry = Some(ix); - cx.notify(); - if event.modifiers().secondary() { - this.open_file(&Default::default(), window, cx) - } else { - this.open_diff(&Default::default(), window, cx); - this.focus_handle.focus(window, cx); - } - }) - }) - .on_mouse_down( - MouseButton::Right, - move |event: &MouseDownEvent, window, cx| { - // why isn't this happening automatically? we are passing MouseButton::Right to `on_mouse_down`? - if event.button != MouseButton::Right { - return; - } - - let Some(this) = handle.upgrade() else { - return; - }; - this.update(cx, |this, cx| { - this.deploy_entry_context_menu(event.position, ix, window, cx); - }); - cx.stop_propagation(); - }, - ) - .child(name_row.overflow_x_hidden()) + .hover(|s| s.bg(hover_bg)) + .active(|s| s.bg(active_bg)) + .child(name_row) .child( div() .id(checkbox_wrapper_id) @@ -5119,6 +5071,35 @@ impl GitPanel { }), ), ) + .on_click({ + cx.listener(move |this, event: &ClickEvent, window, cx| { + this.selected_entry = Some(ix); + cx.notify(); + if event.modifiers().secondary() { + this.open_file(&Default::default(), window, cx) + } else { + this.open_diff(&Default::default(), window, cx); + this.focus_handle.focus(window, cx); + } + }) + }) + .on_mouse_down( + MouseButton::Right, + move |event: &MouseDownEvent, window, cx| { + // why isn't this happening automatically? we are passing MouseButton::Right to `on_mouse_down`? + if event.button != MouseButton::Right { + return; + } + + let Some(this) = handle.upgrade() else { + return; + }; + this.update(cx, |this, cx| { + this.deploy_entry_context_menu(event.position, ix, window, cx); + }); + cx.stop_propagation(); + }, + ) .into_any_element() } @@ -5143,29 +5124,23 @@ impl GitPanel { let selected_bg_alpha = 0.08; let state_opacity_step = 0.04; - let base_bg = if selected { - cx.theme().status().info.alpha(selected_bg_alpha) - } else { - cx.theme().colors().ghost_element_background - }; + let info_color = cx.theme().status().info; + let colors = cx.theme().colors(); - let hover_bg = if selected { - cx.theme() - .status() - .info - .alpha(selected_bg_alpha + state_opacity_step) + let (base_bg, hover_bg, active_bg) = if selected { + ( + info_color.alpha(selected_bg_alpha), + info_color.alpha(selected_bg_alpha + state_opacity_step), + info_color.alpha(selected_bg_alpha + state_opacity_step * 2.0), + ) } else { - cx.theme().colors().ghost_element_hover + ( + colors.ghost_element_background, + colors.ghost_element_hover, + colors.ghost_element_active, + ) }; - let active_bg = if selected { - cx.theme() - .status() - .info - .alpha(selected_bg_alpha + state_opacity_step * 2.0) - } else { - cx.theme().colors().ghost_element_active - }; let folder_icon = if entry.expanded { IconName::FolderOpen } else { @@ -5188,9 +5163,8 @@ impl GitPanel { }; let name_row = h_flex() - .items_center() + .min_w_0() .gap_1() - .flex_1() .pl(px(entry.depth as f32 * TREE_INDENT)) .child( Icon::new(folder_icon) @@ -5202,28 +5176,21 @@ impl GitPanel { h_flex() .id(id) .h(self.list_item_height()) + .min_w_0() .w_full() - .items_center() + .pl_3() + .pr_1() + .gap_1p5() + .justify_between() .border_1() .border_r_2() .when(selected && self.focus_handle.is_focused(window), |el| { el.border_color(cx.theme().colors().panel_focused_border) }) - .px(rems(0.75)) - .overflow_hidden() - .flex_none() - .gap_1p5() .bg(base_bg) - .hover(|this| this.bg(hover_bg)) - .active(|this| this.bg(active_bg)) - .on_click({ - let key = entry.key.clone(); - cx.listener(move |this, _event: &ClickEvent, window, cx| { - this.selected_entry = Some(ix); - this.toggle_directory(&key, window, cx); - }) - }) - .child(name_row.overflow_x_hidden()) + .hover(|s| s.bg(hover_bg)) + .active(|s| s.bg(active_bg)) + .child(name_row) .child( div() .id(checkbox_wrapper_id) @@ -5262,12 +5229,18 @@ impl GitPanel { }), ), ) + .on_click({ + let key = entry.key.clone(); + cx.listener(move |this, _event: &ClickEvent, window, cx| { + this.selected_entry = Some(ix); + this.toggle_directory(&key, window, cx); + }) + }) .into_any_element() } fn path_formatted( &self, - parent: Div, directory: Option, path_color: Color, file_name: String, @@ -5276,41 +5249,31 @@ impl GitPanel { git_path_style: GitPathStyle, strikethrough: bool, ) -> Div { - parent - .when(git_path_style == GitPathStyle::FileNameFirst, |this| { - this.child( - self.entry_label( - match directory.as_ref().is_none_or(|d| d.is_empty()) { - true => file_name.clone(), - false => format!("{file_name} "), - }, - label_color, - ) - .when(strikethrough, Label::strikethrough), - ) - }) - .when_some(directory, |this, dir| { - match ( - !dir.is_empty(), - git_path_style == GitPathStyle::FileNameFirst, - ) { - (true, true) => this.child( - self.entry_label(dir, path_color) - .when(strikethrough, Label::strikethrough), - ), - (true, false) => this.child( - self.entry_label( - format!("{dir}{}", path_style.primary_separator()), - path_color, - ) + let file_name_first = git_path_style == GitPathStyle::FileNameFirst; + let file_path_first = git_path_style == GitPathStyle::FilePathFirst; + + let file_name = format!("{} ", file_name); + + h_flex() + .min_w_0() + .overflow_hidden() + .when(file_path_first, |this| this.flex_row_reverse()) + .child( + div().flex_none().child( + self.entry_label(file_name, label_color) .when(strikethrough, Label::strikethrough), - ), - _ => this, - } - }) - .when(git_path_style == GitPathStyle::FilePathFirst, |this| { + ), + ) + .when_some(directory, |this, dir| { + let path_name = if file_name_first { + dir + } else { + format!("{dir}{}", path_style.primary_separator()) + }; + this.child( - self.entry_label(file_name, label_color) + self.entry_label(path_name, path_color) + .truncate() .when(strikethrough, Label::strikethrough), ) }) From 623e13761b02dd98443a7ada94b6a00ebffc46ee Mon Sep 17 00:00:00 2001 From: LoricAndre <57358788+LoricAndre@users.noreply.github.com> Date: Wed, 17 Dec 2025 23:31:12 +0100 Subject: [PATCH 471/621] git: Unify commit popups (#38749) Closes #26424 Supersedes #35328 Originally, `git::blame` uses its own `ParsedCommitMessage` as the source for the commit information, including the PR section. This changes unifies this with `git::repository` and `git_ui::git_panel` by moving this and some other commit-related structs to `git::commit` instead, and making both `git_ui::blame_ui` and `git_ui::git_panel` pull their information from these structs. Release notes : - (Let's Git Together) Fixed the commit tooltip in the git panel not showing information like avatars. --------- Co-authored-by: Cole Miller Co-authored-by: Zed Zippy <234243425+zed-zippy[bot]@users.noreply.github.com> --- crates/editor/src/editor.rs | 6 +-- crates/editor/src/element.rs | 6 +-- crates/editor/src/git/blame.rs | 82 ++++++----------------------- crates/git/src/blame.rs | 11 +--- crates/git/src/commit.rs | 49 ++++++++++++++++- crates/git_ui/src/blame_ui.rs | 5 +- crates/git_ui/src/commit_tooltip.rs | 2 +- crates/git_ui/src/git_panel.rs | 20 ++++--- crates/project/src/git_store.rs | 5 ++ 9 files changed, 87 insertions(+), 99 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 83051ffb9ea1a5f5754b2af4d1cf42526cfd391e..8560705802264dad55b87dbf21e1f9aa7625edf8 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -73,11 +73,7 @@ pub use multi_buffer::{ pub use split::SplittableEditor; pub use text::Bias; -use ::git::{ - Restore, - blame::{BlameEntry, ParsedCommitMessage}, - status::FileStatus, -}; +use ::git::{Restore, blame::BlameEntry, commit::ParsedCommitMessage, status::FileStatus}; use aho_corasick::{AhoCorasick, AhoCorasickBuilder, BuildError}; use anyhow::{Context as _, Result, anyhow, bail}; use blink_manager::BlinkManager; diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index 9b6115daed700bf391ef6b076100702b99ecaabe..f7b6aa949e74dca9bee73419fa2b87899f9986fd 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -37,11 +37,7 @@ use crate::{ use buffer_diff::{DiffHunkStatus, DiffHunkStatusKind}; use collections::{BTreeMap, HashMap}; use file_icons::FileIcons; -use git::{ - Oid, - blame::{BlameEntry, ParsedCommitMessage}, - status::FileStatus, -}; +use git::{Oid, blame::BlameEntry, commit::ParsedCommitMessage, status::FileStatus}; use gpui::{ Action, Along, AnyElement, App, AppContext, AvailableSpace, Axis as ScrollbarAxis, BorderStyle, Bounds, ClickEvent, ClipboardItem, ContentMask, Context, Corner, Corners, CursorStyle, diff --git a/crates/editor/src/git/blame.rs b/crates/editor/src/git/blame.rs index 031795ff2dbfceb96f950db18101b37fd3cdcf84..d1338c3cbd3540914b23a53410fd5c823e1285c8 100644 --- a/crates/editor/src/git/blame.rs +++ b/crates/editor/src/git/blame.rs @@ -3,9 +3,9 @@ use anyhow::{Context as _, Result}; use collections::HashMap; use git::{ - GitHostingProviderRegistry, GitRemote, Oid, - blame::{Blame, BlameEntry, ParsedCommitMessage}, - parse_git_remote_url, + GitHostingProviderRegistry, Oid, + blame::{Blame, BlameEntry}, + commit::ParsedCommitMessage, }; use gpui::{ AnyElement, App, AppContext as _, Context, Entity, Hsla, ScrollHandle, Subscription, Task, @@ -525,12 +525,7 @@ impl GitBlame { .git_store() .read(cx) .repository_and_path_for_buffer_id(buffer.read(cx).remote_id(), cx) - .and_then(|(repo, _)| { - repo.read(cx) - .remote_upstream_url - .clone() - .or(repo.read(cx).remote_origin_url.clone()) - }); + .and_then(|(repo, _)| repo.read(cx).default_remote_url()); let blame_buffer = project .update(cx, |project, cx| project.blame_buffer(&buffer, None, cx)); Ok(async move { @@ -554,13 +549,19 @@ impl GitBlame { entries, snapshot.max_point().row, ); - let commit_details = parse_commit_messages( - messages, - remote_url, - provider_registry.clone(), - ) - .await; - + let commit_details = messages + .into_iter() + .map(|(oid, message)| { + let parsed_commit_message = + ParsedCommitMessage::parse( + oid.to_string(), + message, + remote_url.as_deref(), + Some(provider_registry.clone()), + ); + (oid, parsed_commit_message) + }) + .collect(); res.push(( id, snapshot, @@ -680,55 +681,6 @@ fn build_blame_entry_sum_tree(entries: Vec, max_row: u32) -> SumTree entries } -async fn parse_commit_messages( - messages: impl IntoIterator, - remote_url: Option, - provider_registry: Arc, -) -> HashMap { - let mut commit_details = HashMap::default(); - - let parsed_remote_url = remote_url - .as_deref() - .and_then(|remote_url| parse_git_remote_url(provider_registry, remote_url)); - - for (oid, message) in messages { - let permalink = if let Some((provider, git_remote)) = parsed_remote_url.as_ref() { - Some(provider.build_commit_permalink( - git_remote, - git::BuildCommitPermalinkParams { - sha: oid.to_string().as_str(), - }, - )) - } else { - None - }; - - let remote = parsed_remote_url - .as_ref() - .map(|(provider, remote)| GitRemote { - host: provider.clone(), - owner: remote.owner.clone().into(), - repo: remote.repo.clone().into(), - }); - - let pull_request = parsed_remote_url - .as_ref() - .and_then(|(provider, remote)| provider.extract_pull_request(remote, &message)); - - commit_details.insert( - oid, - ParsedCommitMessage { - message: message.into(), - permalink, - remote, - pull_request, - }, - ); - } - - commit_details -} - #[cfg(test)] mod tests { use super::*; diff --git a/crates/git/src/blame.rs b/crates/git/src/blame.rs index c3bbeff3f7d15d84b779f2ab92cb89799f63c4e8..d6011de98b8c69837d16bf2a2211fc7632726230 100644 --- a/crates/git/src/blame.rs +++ b/crates/git/src/blame.rs @@ -1,10 +1,9 @@ +use crate::Oid; use crate::commit::get_messages; use crate::repository::RepoPath; -use crate::{GitRemote, Oid}; use anyhow::{Context as _, Result}; use collections::{HashMap, HashSet}; use futures::AsyncWriteExt; -use gpui::SharedString; use serde::{Deserialize, Serialize}; use std::process::Stdio; use std::{ops::Range, path::Path}; @@ -21,14 +20,6 @@ pub struct Blame { pub messages: HashMap, } -#[derive(Clone, Debug, Default)] -pub struct ParsedCommitMessage { - pub message: SharedString, - pub permalink: Option, - pub pull_request: Option, - pub remote: Option, -} - impl Blame { pub async fn for_path( git_binary: &Path, diff --git a/crates/git/src/commit.rs b/crates/git/src/commit.rs index ece1d76b8ae9c9f40f27178da1ef13fe1a78e659..1b450a3dffb9e9956e5b43aa2797ae02f90e731c 100644 --- a/crates/git/src/commit.rs +++ b/crates/git/src/commit.rs @@ -1,7 +1,52 @@ -use crate::{Oid, status::StatusCode}; +use crate::{ + BuildCommitPermalinkParams, GitHostingProviderRegistry, GitRemote, Oid, parse_git_remote_url, + status::StatusCode, +}; use anyhow::{Context as _, Result}; use collections::HashMap; -use std::path::Path; +use gpui::SharedString; +use std::{path::Path, sync::Arc}; + +#[derive(Clone, Debug, Default)] +pub struct ParsedCommitMessage { + pub message: SharedString, + pub permalink: Option, + pub pull_request: Option, + pub remote: Option, +} + +impl ParsedCommitMessage { + pub fn parse( + sha: String, + message: String, + remote_url: Option<&str>, + provider_registry: Option>, + ) -> Self { + if let Some((hosting_provider, remote)) = provider_registry + .and_then(|reg| remote_url.and_then(|url| parse_git_remote_url(reg, url))) + { + let pull_request = hosting_provider.extract_pull_request(&remote, &message); + Self { + message: message.into(), + permalink: Some( + hosting_provider + .build_commit_permalink(&remote, BuildCommitPermalinkParams { sha: &sha }), + ), + pull_request, + remote: Some(GitRemote { + host: hosting_provider, + owner: remote.owner.into(), + repo: remote.repo.into(), + }), + } + } else { + Self { + message: message.into(), + ..Default::default() + } + } + } +} pub async fn get_messages(working_directory: &Path, shas: &[Oid]) -> Result> { if shas.is_empty() { diff --git a/crates/git_ui/src/blame_ui.rs b/crates/git_ui/src/blame_ui.rs index 09ab3229bc5b2b7814b89bbb914472407793a52d..d4d8750a18ee6efbd90a38722043450c6ec61358 100644 --- a/crates/git_ui/src/blame_ui.rs +++ b/crates/git_ui/src/blame_ui.rs @@ -3,10 +3,7 @@ use crate::{ commit_view::CommitView, }; use editor::{BlameRenderer, Editor, hover_markdown_style}; -use git::{ - blame::{BlameEntry, ParsedCommitMessage}, - repository::CommitSummary, -}; +use git::{blame::BlameEntry, commit::ParsedCommitMessage, repository::CommitSummary}; use gpui::{ ClipboardItem, Entity, Hsla, MouseButton, ScrollHandle, Subscription, TextStyle, TextStyleRefinement, UnderlineStyle, WeakEntity, prelude::*, diff --git a/crates/git_ui/src/commit_tooltip.rs b/crates/git_ui/src/commit_tooltip.rs index cf6512b0763e128633cfa65f934d8ed18cd6d022..d18770a704ff31d6dffd705baf44defaaf6d8d4a 100644 --- a/crates/git_ui/src/commit_tooltip.rs +++ b/crates/git_ui/src/commit_tooltip.rs @@ -3,7 +3,7 @@ use editor::hover_markdown_style; use futures::Future; use git::blame::BlameEntry; use git::repository::CommitSummary; -use git::{GitRemote, blame::ParsedCommitMessage}; +use git::{GitRemote, commit::ParsedCommitMessage}; use gpui::{ App, Asset, ClipboardItem, Element, Entity, MouseButton, ParentElement, Render, ScrollHandle, StatefulInteractiveElement, WeakEntity, prelude::*, diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs index d392813d7602b19f04e66dd7c892cee40e8e243d..84c6e9b301d77845f115514eb2a9339fcb813701 100644 --- a/crates/git_ui/src/git_panel.rs +++ b/crates/git_ui/src/git_panel.rs @@ -20,7 +20,7 @@ use editor::{ actions::ExpandAllDiffHunks, }; use futures::StreamExt as _; -use git::blame::ParsedCommitMessage; +use git::commit::ParsedCommitMessage; use git::repository::{ Branch, CommitDetails, CommitOptions, CommitSummary, DiffType, FetchOptions, GitCommitter, PushOptions, Remote, RemoteCommandOutput, ResetMode, Upstream, UpstreamTracking, @@ -30,8 +30,8 @@ use git::stash::GitStash; use git::status::StageStatus; use git::{Amend, Signoff, ToggleStaged, repository::RepoPath, status::FileStatus}; use git::{ - ExpandCommitEditor, RestoreTrackedFiles, StageAll, StashAll, StashApply, StashPop, - TrashUntrackedFiles, UnstageAll, + ExpandCommitEditor, GitHostingProviderRegistry, RestoreTrackedFiles, StageAll, StashAll, + StashApply, StashPop, TrashUntrackedFiles, UnstageAll, }; use gpui::{ Action, AsyncApp, AsyncWindowContext, Bounds, ClickEvent, Corner, DismissEvent, Entity, @@ -5613,6 +5613,7 @@ impl GitPanelMessageTooltip { window: &mut Window, cx: &mut App, ) -> Entity { + let remote_url = repository.read(cx).default_remote_url(); cx.new(|cx| { cx.spawn_in(window, async move |this, cx| { let (details, workspace) = git_panel.update(cx, |git_panel, cx| { @@ -5622,16 +5623,21 @@ impl GitPanelMessageTooltip { ) })?; let details = details.await?; + let provider_registry = cx + .update(|_, app| GitHostingProviderRegistry::default_global(app)) + .ok(); let commit_details = crate::commit_tooltip::CommitDetails { sha: details.sha.clone(), author_name: details.author_name.clone(), author_email: details.author_email.clone(), commit_time: OffsetDateTime::from_unix_timestamp(details.commit_timestamp)?, - message: Some(ParsedCommitMessage { - message: details.message, - ..Default::default() - }), + message: Some(ParsedCommitMessage::parse( + details.sha.to_string(), + details.message.to_string(), + remote_url.as_deref(), + provider_registry, + )), }; this.update(cx, |this: &mut GitPanelMessageTooltip, cx| { diff --git a/crates/project/src/git_store.rs b/crates/project/src/git_store.rs index a414a03320a2defa4c9dbd4b6193a131e761d2c7..6eff10ddba1c986ef8c310084b08d2d398b52c5d 100644 --- a/crates/project/src/git_store.rs +++ b/crates/project/src/git_store.rs @@ -5948,6 +5948,11 @@ impl Repository { self.pending_ops.edit(edits, ()); ids } + pub fn default_remote_url(&self) -> Option { + self.remote_upstream_url + .clone() + .or(self.remote_origin_url.clone()) + } } fn get_permalink_in_rust_registry_src( From f2d29f47906c588c4ae2ba2d7e58e4ec83074b99 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Wed, 17 Dec 2025 15:32:28 -0700 Subject: [PATCH 472/621] Auto-release preview as Zippy (#45163) I think we're not triggering the after-release workflow because of github's loop detection when you use the default GITHUB_TOKEN Closes #ISSUE Release Notes: - N/A --- .github/workflows/autofix_pr.yml | 2 +- .github/workflows/cherry_pick.yml | 2 +- .github/workflows/release.yml | 8 +++++++- tooling/xtask/src/tasks/workflows/autofix_pr.rs | 15 +-------------- .../xtask/src/tasks/workflows/cherry_pick.rs | 17 ++--------------- tooling/xtask/src/tasks/workflows/release.rs | 5 ++++- tooling/xtask/src/tasks/workflows/steps.rs | 13 +++++++++++++ 7 files changed, 29 insertions(+), 33 deletions(-) diff --git a/.github/workflows/autofix_pr.yml b/.github/workflows/autofix_pr.yml index 1591ba2a9a98b8587814d25858f4e0d78d9f7d34..d3688a722aa107efb3dfb95351404f43c9aece65 100644 --- a/.github/workflows/autofix_pr.yml +++ b/.github/workflows/autofix_pr.yml @@ -90,7 +90,7 @@ jobs: runs-on: namespace-profile-2x4-ubuntu-2404 steps: - id: get-app-token - name: autofix_pr::commit_changes::authenticate_as_zippy + name: steps::authenticate_as_zippy uses: actions/create-github-app-token@bef1eaf1c0ac2b148ee2a0a74c65fbe6db0631f1 with: app-id: ${{ secrets.ZED_ZIPPY_APP_ID }} diff --git a/.github/workflows/cherry_pick.yml b/.github/workflows/cherry_pick.yml index bc01aae17e7141a2359b162c3de94c1aec7b765c..d4dee5154f2209521f3e9d183c05c118e8861521 100644 --- a/.github/workflows/cherry_pick.yml +++ b/.github/workflows/cherry_pick.yml @@ -30,7 +30,7 @@ jobs: with: clean: false - id: get-app-token - name: cherry_pick::run_cherry_pick::authenticate_as_zippy + name: steps::authenticate_as_zippy uses: actions/create-github-app-token@bef1eaf1c0ac2b148ee2a0a74c65fbe6db0631f1 with: app-id: ${{ secrets.ZED_ZIPPY_APP_ID }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 155b38666f4bd73e68e9ea326db9a6862288a1fe..8cc63340902fb061c66e5896308f2cad9c31f947 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -478,11 +478,17 @@ jobs: if: startsWith(github.ref, 'refs/tags/v') && endsWith(github.ref, '-pre') && !endsWith(github.ref, '.0-pre') runs-on: namespace-profile-2x4-ubuntu-2404 steps: + - id: get-app-token + name: steps::authenticate_as_zippy + uses: actions/create-github-app-token@bef1eaf1c0ac2b148ee2a0a74c65fbe6db0631f1 + with: + app-id: ${{ secrets.ZED_ZIPPY_APP_ID }} + private-key: ${{ secrets.ZED_ZIPPY_APP_PRIVATE_KEY }} - name: gh release edit "$GITHUB_REF_NAME" --repo=zed-industries/zed --draft=false run: gh release edit "$GITHUB_REF_NAME" --repo=zed-industries/zed --draft=false shell: bash -euxo pipefail {0} env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ steps.get-app-token.outputs.token }} notify_on_failure: needs: - upload_release_assets diff --git a/tooling/xtask/src/tasks/workflows/autofix_pr.rs b/tooling/xtask/src/tasks/workflows/autofix_pr.rs index f4a8e0e2b09df93cc430f0931c3db3f9e67b07df..ab59e735225dfb4f9658960a35a992553642b4c2 100644 --- a/tooling/xtask/src/tasks/workflows/autofix_pr.rs +++ b/tooling/xtask/src/tasks/workflows/autofix_pr.rs @@ -109,19 +109,6 @@ fn run_autofix(pr_number: &WorkflowInput, run_clippy: &WorkflowInput) -> NamedJo } fn commit_changes(pr_number: &WorkflowInput, autofix_job: &NamedJob) -> NamedJob { - fn authenticate_as_zippy() -> (Step, StepOutput) { - let step = named::uses( - "actions", - "create-github-app-token", - "bef1eaf1c0ac2b148ee2a0a74c65fbe6db0631f1", - ) - .add_with(("app-id", vars::ZED_ZIPPY_APP_ID)) - .add_with(("private-key", vars::ZED_ZIPPY_APP_PRIVATE_KEY)) - .id("get-app-token"); - let output = StepOutput::new(&step, "token"); - (step, output) - } - fn checkout_pr(pr_number: &WorkflowInput, token: &StepOutput) -> Step { named::bash(&format!("gh pr checkout {pr_number}")).add_env(("GITHUB_TOKEN", token)) } @@ -148,7 +135,7 @@ fn commit_changes(pr_number: &WorkflowInput, autofix_job: &NamedJob) -> NamedJob .add_env(("GITHUB_TOKEN", token)) } - let (authenticate, token) = authenticate_as_zippy(); + let (authenticate, token) = steps::authenticate_as_zippy(); named::job( Job::default() diff --git a/tooling/xtask/src/tasks/workflows/cherry_pick.rs b/tooling/xtask/src/tasks/workflows/cherry_pick.rs index 105bf74c4194a46ad4ca62991fae3a945eea150d..eaa786837f84ebf4d4f7e1a579db0c7b4dcc5040 100644 --- a/tooling/xtask/src/tasks/workflows/cherry_pick.rs +++ b/tooling/xtask/src/tasks/workflows/cherry_pick.rs @@ -3,7 +3,7 @@ use gh_workflow::*; use crate::tasks::workflows::{ runners, steps::{self, NamedJob, named}, - vars::{self, StepOutput, WorkflowInput}, + vars::{StepOutput, WorkflowInput}, }; pub fn cherry_pick() -> Workflow { @@ -29,19 +29,6 @@ fn run_cherry_pick( commit: &WorkflowInput, channel: &WorkflowInput, ) -> NamedJob { - fn authenticate_as_zippy() -> (Step, StepOutput) { - let step = named::uses( - "actions", - "create-github-app-token", - "bef1eaf1c0ac2b148ee2a0a74c65fbe6db0631f1", - ) // v2 - .add_with(("app-id", vars::ZED_ZIPPY_APP_ID)) - .add_with(("private-key", vars::ZED_ZIPPY_APP_PRIVATE_KEY)) - .id("get-app-token"); - let output = StepOutput::new(&step, "token"); - (step, output) - } - fn cherry_pick( branch: &WorkflowInput, commit: &WorkflowInput, @@ -54,7 +41,7 @@ fn run_cherry_pick( .add_env(("GITHUB_TOKEN", token)) } - let (authenticate, token) = authenticate_as_zippy(); + let (authenticate, token) = steps::authenticate_as_zippy(); named::job( Job::default() diff --git a/tooling/xtask/src/tasks/workflows/release.rs b/tooling/xtask/src/tasks/workflows/release.rs index e06a71340192c036d442d65d9572e52ed2983cae..80fb075f7f6445b1a6a078d9defba2018a406851 100644 --- a/tooling/xtask/src/tasks/workflows/release.rs +++ b/tooling/xtask/src/tasks/workflows/release.rs @@ -97,17 +97,20 @@ pub(crate) fn create_sentry_release() -> Step { } fn auto_release_preview(deps: &[&NamedJob; 1]) -> NamedJob { + let (authenticate, token) = steps::authenticate_as_zippy(); + named::job( dependant_job(deps) .runs_on(runners::LINUX_SMALL) .cond(Expression::new(indoc::indoc!( r#"startsWith(github.ref, 'refs/tags/v') && endsWith(github.ref, '-pre') && !endsWith(github.ref, '.0-pre')"# ))) + .add_step(authenticate) .add_step( steps::script( r#"gh release edit "$GITHUB_REF_NAME" --repo=zed-industries/zed --draft=false"#, ) - .add_env(("GITHUB_TOKEN", vars::GITHUB_TOKEN)), + .add_env(("GITHUB_TOKEN", &token)), ) ) } diff --git a/tooling/xtask/src/tasks/workflows/steps.rs b/tooling/xtask/src/tasks/workflows/steps.rs index 54873c011ce9d1fb7d4e7e0b734695c7c1a30fad..5ff7c0cae3c3740fa89abd84d049f9f76e7d721b 100644 --- a/tooling/xtask/src/tasks/workflows/steps.rs +++ b/tooling/xtask/src/tasks/workflows/steps.rs @@ -354,3 +354,16 @@ pub fn trigger_autofix(run_clippy: bool) -> Step { )) .add_env(("GITHUB_TOKEN", vars::GITHUB_TOKEN)) } + +pub fn authenticate_as_zippy() -> (Step, StepOutput) { + let step = named::uses( + "actions", + "create-github-app-token", + "bef1eaf1c0ac2b148ee2a0a74c65fbe6db0631f1", + ) + .add_with(("app-id", vars::ZED_ZIPPY_APP_ID)) + .add_with(("private-key", vars::ZED_ZIPPY_APP_PRIVATE_KEY)) + .id("get-app-token"); + let output = StepOutput::new(&step, "token"); + (step, output) +} From 25e1e2ecdd131291dcb791d5841ed012cd219040 Mon Sep 17 00:00:00 2001 From: Ben Kunkle Date: Wed, 17 Dec 2025 16:42:18 -0600 Subject: [PATCH 473/621] Don't trigger autosave on focus change in modals (#45166) Closes #28732 Release Notes: - Opening the command palette or other modals no longer triggers auto-save with the `{ "autosave": "on_focus_change" }` setting. This reduces the chance of unwanted format changes when executing actions, and fixes a race condition with `:w` in Vim mode --- crates/workspace/src/item.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/workspace/src/item.rs b/crates/workspace/src/item.rs index 4bde632ce720dad792d19677c60ab62fd51d3637..1570c125fa33135631d8181359ad34bb7802ec5f 100644 --- a/crates/workspace/src/item.rs +++ b/crates/workspace/src/item.rs @@ -886,8 +886,12 @@ impl ItemHandle for Entity { // Only trigger autosave if focus has truly left the item. // If focus is still within the item's hierarchy (e.g., moved to a context menu), // don't trigger autosave to avoid unwanted formatting and cursor jumps. + // Also skip autosave if focus moved to a modal (e.g., command palette), + // since the user is still interacting with the workspace. let focus_handle = item.item_focus_handle(cx); - if !focus_handle.contains_focused(window, cx) { + if !focus_handle.contains_focused(window, cx) + && !workspace.has_active_modal(window, cx) + { Pane::autosave_item(&item, workspace.project.clone(), window, cx) .detach_and_log_err(cx); } From f00cb371f4894ec06e1b72bf253e534a7b96499e Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Wed, 17 Dec 2025 15:42:31 -0700 Subject: [PATCH 474/621] macOS: Bundle placeholder Document.icns so Finder can display Zed file icons (#44833) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Generated by AI. `DocumentTypes.plist` declares `CFBundleTypeIconFile` as `Document` for Zed’s document types, but the macOS bundle did not include `Contents/Resources/Document.icns`, causing Finder to fall back to generic icons. This PR: - Adds `crates/zed/resources/Document.icns` as a placeholder document icon (currently derived from the app icon). - Updates `script/bundle-mac` to copy it into the `.app` at `Contents/Resources/Document.icns` during bundling. - Adds `script/verify-macos-document-icon` for one-command validation. ## How to test (CLI) 1. Build a debug bundle: - `./script/bundle-mac -d aarch64-apple-darwin` 2. Verify the bundle contains the referenced icon: - `./script/verify-macos-document-icon "target/aarch64-apple-darwin/debug/bundle/osx/Zed Dev.app"` ## Optional visual validation in Finder - Pick a file (e.g. `.rs`), Get Info → Open with: Zed Dev → Change All... - Restart Finder: `killall Finder` (or log out/in) @JosephTLyons — would you mind running the steps above and confirming Finder shows Zed’s icon for source files after "Change All" + Finder restart? @danilo-leal — this PR ships a placeholder `Document.icns`. When the real document icon is ready, replace `crates/zed/resources/Document.icns` and the bundling script will include it automatically. Closes #44403. Release Notes: - TODO --------- Co-authored-by: Matt Miller --- crates/zed/resources/Document.icns | Bin 0 -> 1118811 bytes script/bundle-mac | 11 ++++ script/verify-macos-document-icon | 81 +++++++++++++++++++++++++++++ 3 files changed, 92 insertions(+) create mode 100644 crates/zed/resources/Document.icns create mode 100755 script/verify-macos-document-icon diff --git a/crates/zed/resources/Document.icns b/crates/zed/resources/Document.icns new file mode 100644 index 0000000000000000000000000000000000000000..5d0185c81a32c214f213f12243aeab01e32830e1 GIT binary patch literal 1118811 zcmZs>1CS`e(j`2$@7T6&+qP}nwr$(CZF}z6wzc=Y|BF91cDK5!^JG> zFtT+5Kt$5AFk+zpCzSvI0AMWT@$q4y!l3?PWK(AkdrNyp{C^nWf27<$Y5q?|wJ3CXP-P zcDDEov>f#Gv<$zB05JbN0Rn)6fB*pgY6JY?=NA{3|KIzs4gfOX|I-Te|Fi=C-`045 z|GX|lM5KQql6J$i_7LSId_a+w4;3BHUEP!V)0X7GW06=GE#nUyxWAUs)b4;RdP3Vuf_T3}|MH`gfFtUN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FY59OX+R&K+rr!}I-<zLks@ z6lB%2Hg2V9^Q5|ppD+O>ZI*1Q+t)^o6)voy{?mbLYDpEq z=JH?k%nc>yEce2E{u~O9HU$03jAH+}{mR)T-Ga79Hk45!-B(~fOI(n9!F3P!p@CrUt`QY7?>&D~gbr)y?N{IGPLq zL2Qt>gaIzVPe+l9gH4(Km%$H*Y(PSn7D3$_{Yh zcq+sXje3O(`}NyYtGG#QFO%KWUme7)z~uTpC-a>$Pi)Ov;PRP<)JGri1lZPbR$S_I z=5|vXbjxwX8)5XI>VTXPDk`~Ue-@cVi3wg7?WOB;25#Bu+N)7lMYFget~9pQPx2bf za&D|{Q(orgNX@p#+0fh|u-)7zFE?Z&kXWqQjhNPq+Nd>m#27tvuLs+4@$2-(t9c&9 znzRSq6_n*Y|LKOTLwZ3GnK!M^d>Sf|i4+Rebf-@+eFmc$RY=iIqheO|8SuICA0Q?N ALjV8( literal 0 HcmV?d00001 diff --git a/script/bundle-mac b/script/bundle-mac index c6c925f073600336f4aa3114a732609481ade26e..93ea07b162612d27784dbd0eb54598b0aa2252c3 100755 --- a/script/bundle-mac +++ b/script/bundle-mac @@ -106,6 +106,17 @@ mv Cargo.toml.backup Cargo.toml popd echo "Bundled ${app_path}" +# DocumentTypes.plist references CFBundleTypeIconFile "Document", so the bundle must contain Document.icns. +# We use the app icon as a placeholder document icon for now. +document_icon_source="crates/zed/resources/Document.icns" +document_icon_target="${app_path}/Contents/Resources/Document.icns" +if [[ -f "${document_icon_source}" ]]; then + mkdir -p "$(dirname "${document_icon_target}")" + cp "${document_icon_source}" "${document_icon_target}" +else + echo "cargo::warning=Missing ${document_icon_source}; macOS document icons may not appear in Finder." +fi + if [[ -n "${MACOS_CERTIFICATE:-}" && -n "${MACOS_CERTIFICATE_PASSWORD:-}" && -n "${APPLE_NOTARIZATION_KEY:-}" && -n "${APPLE_NOTARIZATION_KEY_ID:-}" && -n "${APPLE_NOTARIZATION_ISSUER_ID:-}" ]]; then can_code_sign=true diff --git a/script/verify-macos-document-icon b/script/verify-macos-document-icon new file mode 100755 index 0000000000000000000000000000000000000000..de2581c9df764ee2019740048381d6d66dc3499d --- /dev/null +++ b/script/verify-macos-document-icon @@ -0,0 +1,81 @@ +#!/usr/bin/env bash +set -euo pipefail + +usage() { + cat <<'USAGE' +Usage: + script/verify-macos-document-icon /path/to/Zed.app + +Verifies that the given macOS app bundle's Info.plist references a document icon +named "Document" and that the corresponding icon file exists in the bundle. + +Specifically checks: + - CFBundleDocumentTypes[*].CFBundleTypeIconFile includes "Document" + - Contents/Resources/Document.icns exists + +Exit codes: + 0 - success + 1 - verification failed + 2 - invalid usage / missing prerequisites +USAGE +} + +fail() { + echo "error: $*" >&2 + exit 1 +} + +if [[ $# -ne 1 ]]; then + usage >&2 + exit 2 +fi + +app_path="$1" + +if [[ ! -d "${app_path}" ]]; then + fail "app bundle not found: ${app_path}" +fi + +info_plist="${app_path}/Contents/Info.plist" +if [[ ! -f "${info_plist}" ]]; then + fail "missing Info.plist: ${info_plist}" +fi + +if ! command -v plutil >/dev/null 2>&1; then + fail "plutil not found (required on macOS to read Info.plist)" +fi + +# Convert to JSON for robust parsing. plutil outputs JSON to stdout in this mode. +info_json="$(plutil -convert json -o - "${info_plist}")" + +# Check that CFBundleDocumentTypes exists and that at least one entry references "Document". +# We use Python for JSON parsing; macOS ships with Python 3 on many setups, but not all. +# If python3 isn't available, fall back to a simpler grep-based check. +has_document_icon_ref="false" +if command -v python3 >/dev/null 2>&1; then + has_document_icon_ref="$(python3 -c "import json,sys; d=json.load(sys.stdin); types=d.get('CFBundleDocumentTypes', []); vals=[t.get('CFBundleTypeIconFile') for t in types if isinstance(t, dict)]; print('true' if 'Document' in vals else 'false')" <<<"${info_json}")" +else + # This is a best-effort fallback. It may produce false negatives if the JSON formatting differs. + if echo "${info_json}" | grep -q '"CFBundleTypeIconFile"[[:space:]]*:[[:space:]]*"Document"'; then + has_document_icon_ref="true" + fi +fi + +if [[ "${has_document_icon_ref}" != "true" ]]; then + echo "Verification failed for: ${app_path}" >&2 + echo "Expected Info.plist to reference CFBundleTypeIconFile \"Document\" in CFBundleDocumentTypes." >&2 + echo "Tip: This bundle may be missing DocumentTypes.plist extensions or may have different icon naming." >&2 + exit 1 +fi + +document_icon_path="${app_path}/Contents/Resources/Document.icns" +if [[ ! -f "${document_icon_path}" ]]; then + echo "Verification failed for: ${app_path}" >&2 + echo "Expected document icon to exist: ${document_icon_path}" >&2 + echo "Tip: The bundle script should copy crates/zed/resources/Document.icns into Contents/Resources/Document.icns." >&2 + exit 1 +fi + +echo "OK: ${app_path}" +echo " - Info.plist references CFBundleTypeIconFile \"Document\"" +echo " - Found ${document_icon_path}" From f9b69aeff0f043810b7b98c6242663db76611341 Mon Sep 17 00:00:00 2001 From: Ben Kunkle Date: Wed, 17 Dec 2025 16:44:25 -0600 Subject: [PATCH 475/621] Fix Wayland platform resize resulting in non-interactive window (#45153) Closes #40361 Release Notes: - Linux(Wayland): Fixed an issue where the settings window would not respond to user interaction until resized --- .../gpui/src/platform/linux/wayland/window.rs | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/crates/gpui/src/platform/linux/wayland/window.rs b/crates/gpui/src/platform/linux/wayland/window.rs index 3334ae28a31927b2150e79fc513855fa699c55ba..8cc47c3c139708c3cc278c6146411a4383cc0004 100644 --- a/crates/gpui/src/platform/linux/wayland/window.rs +++ b/crates/gpui/src/platform/linux/wayland/window.rs @@ -1025,13 +1025,26 @@ impl PlatformWindow for WaylandWindow { fn resize(&mut self, size: Size) { let state = self.borrow(); let state_ptr = self.0.clone(); - let dp_size = size.to_device_pixels(self.scale_factor()); + + // Keep window geometry consistent with configure handling. On Wayland, window geometry is + // surface-local: resizing should not attempt to translate the window; the compositor + // controls placement. We also account for client-side decoration insets and tiling. + let window_geometry = inset_by_tiling( + Bounds { + origin: Point::default(), + size, + }, + state.inset(), + state.tiling, + ) + .map(|v| v.0 as i32) + .map_size(|v| if v <= 0 { 1 } else { v }); state.surface_state.set_geometry( - state.bounds.origin.x.0 as i32, - state.bounds.origin.y.0 as i32, - dp_size.width.0, - dp_size.height.0, + window_geometry.origin.x, + window_geometry.origin.y, + window_geometry.size.width, + window_geometry.size.height, ); state From cec46079fea8577c4b7bb6ad1f0e6f9a63bb7f2c Mon Sep 17 00:00:00 2001 From: Mayank Verma Date: Thu, 18 Dec 2025 04:22:10 +0530 Subject: [PATCH 476/621] git_ui: Preserve newlines in commit messages (#45167) Closes #44982 Release Notes: - Fixed Git panel to preserve newlines in commit messages --- crates/git_ui/src/git_panel.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs index 84c6e9b301d77845f115514eb2a9339fcb813701..4e94a811510ee07707bf729040d41fc8b1eb922c 100644 --- a/crates/git_ui/src/git_panel.rs +++ b/crates/git_ui/src/git_panel.rs @@ -15,6 +15,7 @@ use askpass::AskPassDelegate; use cloud_llm_client::CompletionIntent; use collections::{BTreeMap, HashMap, HashSet}; use db::kvp::KEY_VALUE_STORE; +use editor::RewrapOptions; use editor::{ Direction, Editor, EditorElement, EditorMode, MultiBuffer, MultiBufferOffset, actions::ExpandAllDiffHunks, @@ -2180,7 +2181,13 @@ impl GitPanel { let editor = cx.new(|cx| Editor::for_buffer(buffer, None, window, cx)); let wrapped_message = editor.update(cx, |editor, cx| { editor.select_all(&Default::default(), window, cx); - editor.rewrap(&Default::default(), window, cx); + editor.rewrap_impl( + RewrapOptions { + override_language_settings: false, + preserve_existing_whitespace: true, + }, + cx, + ); editor.text(cx) }); if wrapped_message.trim().is_empty() { From 0c9992c5e9f40bac63b8a11b047b7792b6b23155 Mon Sep 17 00:00:00 2001 From: Kingsword Date: Thu, 18 Dec 2025 07:42:47 +0800 Subject: [PATCH 477/621] terminal: Forward Ctrl+V when clipboard contains images (#42258) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When running Codex CLI, Claude Code, or other TUI agents in Zed’s terminal, pasting images wasn’t supported — Zed treated all clipboard content as plain text and simply pushed it into the PTY, so the agent never saw the image data. This change makes terminal pastes behave like they do in a native terminal: if the clipboard contains an image, Zed now emits a raw Ctrl+V to the PTY so the agent can read the system clipboard itself. Release Notes: - Fixed terminal-launched Codex/Claude sessions by forwarding Ctrl+V for clipboard images so agents can attach them --- crates/terminal_view/src/terminal_view.rs | 28 +++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/crates/terminal_view/src/terminal_view.rs b/crates/terminal_view/src/terminal_view.rs index 54808934ba7b098a695a8b104a048a379966e6f1..e7e60ff4b31dfbdd16b7de8841285d81fc311fc5 100644 --- a/crates/terminal_view/src/terminal_view.rs +++ b/crates/terminal_view/src/terminal_view.rs @@ -8,8 +8,8 @@ mod terminal_slash_command; use assistant_slash_command::SlashCommandRegistry; use editor::{EditorSettings, actions::SelectAll, blink_manager::BlinkManager}; use gpui::{ - Action, AnyElement, App, DismissEvent, Entity, EventEmitter, FocusHandle, Focusable, - KeyContext, KeyDownEvent, Keystroke, MouseButton, MouseDownEvent, Pixels, Render, + Action, AnyElement, App, ClipboardEntry, DismissEvent, Entity, EventEmitter, FocusHandle, + Focusable, KeyContext, KeyDownEvent, Keystroke, MouseButton, MouseDownEvent, Pixels, Render, ScrollWheelEvent, Styled, Subscription, Task, WeakEntity, actions, anchored, deferred, div, }; use persistence::TERMINAL_DB; @@ -687,12 +687,32 @@ impl TerminalView { ///Attempt to paste the clipboard into the terminal fn paste(&mut self, _: &Paste, _: &mut Window, cx: &mut Context) { - if let Some(clipboard_string) = cx.read_from_clipboard().and_then(|item| item.text()) { + let Some(clipboard) = cx.read_from_clipboard() else { + return; + }; + + if clipboard.entries().iter().any(|entry| match entry { + ClipboardEntry::Image(image) => !image.bytes.is_empty(), + _ => false, + }) { + self.forward_ctrl_v(cx); + return; + } + + if let Some(text) = clipboard.text() { self.terminal - .update(cx, |terminal, _cx| terminal.paste(&clipboard_string)); + .update(cx, |terminal, _cx| terminal.paste(&text)); } } + /// Emits a raw Ctrl+V so TUI agents can read the OS clipboard directly + /// and attach images using their native workflows. + fn forward_ctrl_v(&self, cx: &mut Context) { + self.terminal.update(cx, |term, _| { + term.input(vec![0x16]); + }); + } + fn send_text(&mut self, text: &SendText, _: &mut Window, cx: &mut Context) { self.clear_bell(cx); self.terminal.update(cx, |term, _| { From aff93f2f6c10e10d460197e9ac1f4e7d3a841e66 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Wed, 17 Dec 2025 17:05:35 -0700 Subject: [PATCH 478/621] More permissions for autofix (#45170) Release Notes: - N/A --- .github/workflows/release.yml | 17 +++--- .github/workflows/release_nightly.yml | 3 +- .github/workflows/run_tests.yml | 41 ++++++++----- .../xtask/src/tasks/workflows/run_tests.rs | 58 +++++++++++++++++-- tooling/xtask/src/tasks/workflows/steps.rs | 16 ++--- 5 files changed, 92 insertions(+), 43 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8cc63340902fb061c66e5896308f2cad9c31f947..5b2ecf70294ad383944205b300f0d9d1e137b2f6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,7 +26,8 @@ jobs: uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 with: node-version: '20' - - name: steps::clippy + - id: clippy + name: steps::clippy run: ./script/clippy shell: bash -euxo pipefail {0} - name: steps::clear_target_dir_if_large @@ -71,15 +72,10 @@ jobs: uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 with: node-version: '20' - - name: steps::clippy + - id: clippy + name: steps::clippy run: ./script/clippy shell: bash -euxo pipefail {0} - - name: steps::trigger_autofix - if: failure() && github.event_name == 'pull_request' && github.actor != 'zed-zippy[bot]' - run: gh workflow run autofix_pr.yml -f pr_number=${{ github.event.pull_request.number }} -f run_clippy=true - shell: bash -euxo pipefail {0} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: steps::cargo_install_nextest uses: taiki-e/install-action@nextest - name: steps::clear_target_dir_if_large @@ -93,6 +89,8 @@ jobs: run: | rm -rf ./../.cargo shell: bash -euxo pipefail {0} + outputs: + clippy_failed: ${{ steps.clippy.outcome == 'failure' }} timeout-minutes: 60 run_tests_windows: if: (github.repository_owner == 'zed-industries' || github.repository_owner == 'zed-extensions') @@ -111,7 +109,8 @@ jobs: uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 with: node-version: '20' - - name: steps::clippy + - id: clippy + name: steps::clippy run: ./script/clippy.ps1 shell: pwsh - name: steps::clear_target_dir_if_large diff --git a/.github/workflows/release_nightly.yml b/.github/workflows/release_nightly.yml index d76244175accc3e816cbd7d5dc322d2529a0a236..906420ad9b15d50578be7d682c6086cc64c9f6e1 100644 --- a/.github/workflows/release_nightly.yml +++ b/.github/workflows/release_nightly.yml @@ -44,7 +44,8 @@ jobs: uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 with: node-version: '20' - - name: steps::clippy + - id: clippy + name: steps::clippy run: ./script/clippy.ps1 shell: pwsh - name: steps::clear_target_dir_if_large diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index a9a46b7a797faae793c87601d306a2aea80e6592..d18341b4e09a4a48b61d29609a091570b359c30f 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -80,12 +80,6 @@ jobs: - name: steps::cargo_fmt run: cargo fmt --all -- --check shell: bash -euxo pipefail {0} - - name: steps::trigger_autofix - if: failure() && github.event_name == 'pull_request' && github.actor != 'zed-zippy[bot]' - run: gh workflow run autofix_pr.yml -f pr_number=${{ github.event.pull_request.number }} -f run_clippy=false - shell: bash -euxo pipefail {0} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: ./script/check-todos run: ./script/check-todos shell: bash -euxo pipefail {0} @@ -116,7 +110,8 @@ jobs: uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 with: node-version: '20' - - name: steps::clippy + - id: clippy + name: steps::clippy run: ./script/clippy.ps1 shell: pwsh - name: steps::clear_target_dir_if_large @@ -163,15 +158,10 @@ jobs: uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 with: node-version: '20' - - name: steps::clippy + - id: clippy + name: steps::clippy run: ./script/clippy shell: bash -euxo pipefail {0} - - name: steps::trigger_autofix - if: failure() && github.event_name == 'pull_request' && github.actor != 'zed-zippy[bot]' - run: gh workflow run autofix_pr.yml -f pr_number=${{ github.event.pull_request.number }} -f run_clippy=true - shell: bash -euxo pipefail {0} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: steps::cargo_install_nextest uses: taiki-e/install-action@nextest - name: steps::clear_target_dir_if_large @@ -185,6 +175,8 @@ jobs: run: | rm -rf ./../.cargo shell: bash -euxo pipefail {0} + outputs: + clippy_failed: ${{ steps.clippy.outcome == 'failure' }} timeout-minutes: 60 run_tests_mac: needs: @@ -205,7 +197,8 @@ jobs: uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 with: node-version: '20' - - name: steps::clippy + - id: clippy + name: steps::clippy run: ./script/clippy shell: bash -euxo pipefail {0} - name: steps::clear_target_dir_if_large @@ -585,6 +578,24 @@ jobs: exit $EXIT_CODE shell: bash -euxo pipefail {0} + call_autofix: + needs: + - check_style + - run_tests_linux + if: (needs.check_style.result == 'failure' || needs.run_tests_linux.outputs.clippy_failed == 'true') && github.event_name == 'pull_request' && github.actor != 'zed-zippy[bot]' + runs-on: namespace-profile-2x4-ubuntu-2404 + steps: + - id: get-app-token + name: steps::authenticate_as_zippy + uses: actions/create-github-app-token@bef1eaf1c0ac2b148ee2a0a74c65fbe6db0631f1 + with: + app-id: ${{ secrets.ZED_ZIPPY_APP_ID }} + private-key: ${{ secrets.ZED_ZIPPY_APP_PRIVATE_KEY }} + - name: run_tests::call_autofix::dispatch_autofix + run: gh workflow run autofix_pr.yml -f pr_number=${{ github.event.pull_request.number }} -f run_clippy=${{ needs.run_tests_linux.outputs.clippy_failed == 'true' }} + shell: bash -euxo pipefail {0} + env: + GITHUB_TOKEN: ${{ steps.get-app-token.outputs.token }} concurrency: group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.ref_name == 'main' && github.sha || 'anysha' }} cancel-in-progress: true diff --git a/tooling/xtask/src/tasks/workflows/run_tests.rs b/tooling/xtask/src/tasks/workflows/run_tests.rs index 13639fd6c4bf33fe090dcb9d5f3cafdf45a36e76..1bc4b72176ad94c30399bc15a1152b20b200606a 100644 --- a/tooling/xtask/src/tasks/workflows/run_tests.rs +++ b/tooling/xtask/src/tasks/workflows/run_tests.rs @@ -45,11 +45,15 @@ pub(crate) fn run_tests() -> Workflow { &should_run_tests, ]); + let check_style = check_style(); + let run_tests_linux = run_platform_tests(Platform::Linux); + let call_autofix = call_autofix(&check_style, &run_tests_linux); + let mut jobs = vec![ orchestrate, - check_style(), + check_style, should_run_tests.guard(run_platform_tests(Platform::Windows)), - should_run_tests.guard(run_platform_tests(Platform::Linux)), + should_run_tests.guard(run_tests_linux), should_run_tests.guard(run_platform_tests(Platform::Mac)), should_run_tests.guard(doctests()), should_run_tests.guard(check_workspace_binaries()), @@ -106,6 +110,7 @@ pub(crate) fn run_tests() -> Workflow { workflow }) .add_job(tests_pass.name, tests_pass.job) + .add_job(call_autofix.name, call_autofix.job) } // Generates a bash script that checks changed files against regex patterns @@ -238,13 +243,44 @@ fn check_style() -> NamedJob { .add_step(steps::setup_pnpm()) .add_step(steps::script("./script/prettier")) .add_step(steps::cargo_fmt()) - .add_step(steps::trigger_autofix(false)) .add_step(steps::script("./script/check-todos")) .add_step(steps::script("./script/check-keymaps")) .add_step(check_for_typos()), ) } +fn call_autofix(check_style: &NamedJob, run_tests_linux: &NamedJob) -> NamedJob { + fn dispatch_autofix(run_tests_linux_name: &str) -> Step { + let clippy_failed_expr = format!( + "needs.{}.outputs.{} == 'true'", + run_tests_linux_name, CLIPPY_FAILED_OUTPUT + ); + named::bash(format!( + "gh workflow run autofix_pr.yml -f pr_number=${{{{ github.event.pull_request.number }}}} -f run_clippy=${{{{ {} }}}}", + clippy_failed_expr + )) + .add_env(("GITHUB_TOKEN", "${{ steps.get-app-token.outputs.token }}")) + } + + let clippy_failed_expr = format!( + "needs.{}.outputs.{} == 'true'", + run_tests_linux.name, CLIPPY_FAILED_OUTPUT + ); + let (authenticate, _token) = steps::authenticate_as_zippy(); + + let job = Job::default() + .runs_on(runners::LINUX_SMALL) + .cond(Expression::new(format!( + "(needs.{}.result == 'failure' || {}) && github.event_name == 'pull_request' && github.actor != 'zed-zippy[bot]'", + check_style.name, clippy_failed_expr + ))) + .needs(vec![check_style.name.clone(), run_tests_linux.name.clone()]) + .add_step(authenticate) + .add_step(dispatch_autofix(&run_tests_linux.name)); + + named::job(job) +} + fn check_dependencies() -> NamedJob { fn install_cargo_machete() -> Step { named::uses( @@ -305,6 +341,8 @@ fn check_workspace_binaries() -> NamedJob { ) } +pub const CLIPPY_FAILED_OUTPUT: &str = "clippy_failed"; + pub(crate) fn run_platform_tests(platform: Platform) -> NamedJob { let runner = match platform { Platform::Windows => runners::WINDOWS_DEFAULT, @@ -327,12 +365,20 @@ pub(crate) fn run_platform_tests(platform: Platform) -> NamedJob { .add_step(steps::setup_node()) .add_step(steps::clippy(platform)) .when(platform == Platform::Linux, |job| { - job.add_step(steps::trigger_autofix(true)) - .add_step(steps::cargo_install_nextest()) + job.add_step(steps::cargo_install_nextest()) }) .add_step(steps::clear_target_dir_if_large(platform)) .add_step(steps::cargo_nextest(platform)) - .add_step(steps::cleanup_cargo_config(platform)), + .add_step(steps::cleanup_cargo_config(platform)) + .when(platform == Platform::Linux, |job| { + job.outputs([( + CLIPPY_FAILED_OUTPUT.to_owned(), + format!( + "${{{{ steps.{}.outcome == 'failure' }}}}", + steps::CLIPPY_STEP_ID + ), + )]) + }), } } diff --git a/tooling/xtask/src/tasks/workflows/steps.rs b/tooling/xtask/src/tasks/workflows/steps.rs index 5ff7c0cae3c3740fa89abd84d049f9f76e7d721b..3ef7f8fd975d515b061b4ca2e9a37501bfd66e31 100644 --- a/tooling/xtask/src/tasks/workflows/steps.rs +++ b/tooling/xtask/src/tasks/workflows/steps.rs @@ -101,10 +101,12 @@ pub fn clear_target_dir_if_large(platform: Platform) -> Step { } } +pub const CLIPPY_STEP_ID: &str = "clippy"; + pub fn clippy(platform: Platform) -> Step { match platform { - Platform::Windows => named::pwsh("./script/clippy.ps1"), - _ => named::bash("./script/clippy"), + Platform::Windows => named::pwsh("./script/clippy.ps1").id(CLIPPY_STEP_ID), + _ => named::bash("./script/clippy").id(CLIPPY_STEP_ID), } } @@ -345,16 +347,6 @@ pub fn git_checkout(ref_name: &dyn std::fmt::Display) -> Step { )) } -pub fn trigger_autofix(run_clippy: bool) -> Step { - named::bash(format!( - "gh workflow run autofix_pr.yml -f pr_number=${{{{ github.event.pull_request.number }}}} -f run_clippy={run_clippy}" - )) - .if_condition(Expression::new( - "failure() && github.event_name == 'pull_request' && github.actor != 'zed-zippy[bot]'", - )) - .add_env(("GITHUB_TOKEN", vars::GITHUB_TOKEN)) -} - pub fn authenticate_as_zippy() -> (Step, StepOutput) { let step = named::uses( "actions", From 843a35a1a9e7d67a1bdff973faa6c75a811934ca Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 17 Dec 2025 16:25:07 -0800 Subject: [PATCH 479/621] extension api: Make server id types constructible, to ease writing tests (#45174) Currently, extensions cannot have tests that call methods like `label_for_symbol` and `label_for_completion`, because those methods take a `LanguageServerId`, and that type is opaque, and cannot be constructed outside of the `zed_extension_api` crate. This PR makes it possible to construct those types from strings, so that it's more straightforward to write unit tests for these LSP adapter methods. Release Notes: - N/A --- crates/extension_api/src/extension_api.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/crates/extension_api/src/extension_api.rs b/crates/extension_api/src/extension_api.rs index 9418623224289f795fed061acbfc6035a4cc5cdf..acd1cba47b0150b85ddec8baafa8b5f341460a39 100644 --- a/crates/extension_api/src/extension_api.rs +++ b/crates/extension_api/src/extension_api.rs @@ -331,7 +331,6 @@ static mut EXTENSION: Option> = None; pub static ZED_API_VERSION: [u8; 6] = *include_bytes!(concat!(env!("OUT_DIR"), "/version_bytes")); mod wit { - wit_bindgen::generate!({ skip: ["init-extension"], path: "./wit/since_v0.8.0", @@ -524,6 +523,12 @@ impl wit::Guest for Component { #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone)] pub struct LanguageServerId(String); +impl LanguageServerId { + pub fn new(value: String) -> Self { + Self(value) + } +} + impl AsRef for LanguageServerId { fn as_ref(&self) -> &str { &self.0 @@ -540,6 +545,12 @@ impl fmt::Display for LanguageServerId { #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone)] pub struct ContextServerId(String); +impl ContextServerId { + pub fn new(value: String) -> Self { + Self(value) + } +} + impl AsRef for ContextServerId { fn as_ref(&self) -> &str { &self.0 From 9073a2666c953a96f02b82b3539c04709726f7ab Mon Sep 17 00:00:00 2001 From: Cole Miller Date: Wed, 17 Dec 2025 19:28:09 -0500 Subject: [PATCH 480/621] Revert "git: Mark entries as pending when staging a files making the staged highlighting more "optimistic"" (#45175) Reverts zed-industries/zed#43434 This caused a regression because the additional pending hunks don't get cleared. --- crates/project/src/git_store.rs | 81 --------------------------------- 1 file changed, 81 deletions(-) diff --git a/crates/project/src/git_store.rs b/crates/project/src/git_store.rs index 6eff10ddba1c986ef8c310084b08d2d398b52c5d..85ff38ab67f873d8197729de9577075951676597 100644 --- a/crates/project/src/git_store.rs +++ b/crates/project/src/git_store.rs @@ -1672,59 +1672,6 @@ impl GitStore { } } - fn mark_entries_pending_by_project_paths( - &mut self, - project_paths: &[ProjectPath], - stage: bool, - cx: &mut Context, - ) { - let buffer_store = &self.buffer_store; - - for project_path in project_paths { - let Some(buffer) = buffer_store.read(cx).get_by_path(project_path) else { - continue; - }; - - let buffer_id = buffer.read(cx).remote_id(); - let Some(diff_state) = self.diffs.get(&buffer_id) else { - continue; - }; - - diff_state.update(cx, |diff_state, cx| { - let Some(uncommitted_diff) = diff_state.uncommitted_diff() else { - return; - }; - - let buffer_snapshot = buffer.read(cx).text_snapshot(); - let file_exists = buffer - .read(cx) - .file() - .is_some_and(|file| file.disk_state().exists()); - - let all_hunks: Vec<_> = uncommitted_diff - .read(cx) - .hunks_intersecting_range( - text::Anchor::MIN..text::Anchor::MAX, - &buffer_snapshot, - cx, - ) - .collect(); - - if !all_hunks.is_empty() { - uncommitted_diff.update(cx, |diff, cx| { - diff.stage_or_unstage_hunks( - stage, - &all_hunks, - &buffer_snapshot, - file_exists, - cx, - ); - }); - } - }); - } - } - pub fn git_clone( &self, repo: String, @@ -4253,28 +4200,6 @@ impl Repository { save_futures } - fn mark_entries_pending_for_stage( - &self, - entries: &[RepoPath], - stage: bool, - cx: &mut Context, - ) { - let Some(git_store) = self.git_store() else { - return; - }; - - let mut project_paths = Vec::new(); - for repo_path in entries { - if let Some(project_path) = self.repo_path_to_project_path(repo_path, cx) { - project_paths.push(project_path); - } - } - - git_store.update(cx, move |git_store, cx| { - git_store.mark_entries_pending_by_project_paths(&project_paths, stage, cx); - }); - } - pub fn stage_entries( &mut self, entries: Vec, @@ -4283,9 +4208,6 @@ impl Repository { if entries.is_empty() { return Task::ready(Ok(())); } - - self.mark_entries_pending_for_stage(&entries, true, cx); - let id = self.id; let save_tasks = self.save_buffers(&entries, cx); let paths = entries @@ -4351,9 +4273,6 @@ impl Repository { if entries.is_empty() { return Task::ready(Ok(())); } - - self.mark_entries_pending_for_stage(&entries, false, cx); - let id = self.id; let save_tasks = self.save_buffers(&entries, cx); let paths = entries From 07538ff08e04094ceb04e99221474cf5870f3c2c Mon Sep 17 00:00:00 2001 From: Ben Kunkle Date: Wed, 17 Dec 2025 18:32:46 -0600 Subject: [PATCH 481/621] Make sweep and mercury API tokens use `cx.global` instead of `OnceLock` (#45176) Closes #ISSUE Release Notes: - N/A *or* Added/Fixed/Improved ... --- crates/edit_prediction/src/mercury.rs | 19 ++++++++++++------- crates/edit_prediction/src/sweep_ai.rs | 19 ++++++++++++------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/crates/edit_prediction/src/mercury.rs b/crates/edit_prediction/src/mercury.rs index b47bd2ad0374eba33e7b8db726c2fa13c0519465..8186fc5d8c609468be04c117eabac11c6c015efd 100644 --- a/crates/edit_prediction/src/mercury.rs +++ b/crates/edit_prediction/src/mercury.rs @@ -6,7 +6,7 @@ use crate::{ use anyhow::{Context as _, Result}; use futures::AsyncReadExt as _; use gpui::{ - App, AppContext as _, Entity, SharedString, Task, + App, AppContext as _, Entity, Global, SharedString, Task, http_client::{self, AsyncBody, Method}, }; use language::{OffsetRangeExt as _, ToOffset, ToPoint as _}; @@ -300,14 +300,19 @@ pub const MERCURY_CREDENTIALS_URL: SharedString = SharedString::new_static("https://api.inceptionlabs.ai/v1/edit/completions"); pub const MERCURY_CREDENTIALS_USERNAME: &str = "mercury-api-token"; pub static MERCURY_TOKEN_ENV_VAR: std::sync::LazyLock = env_var!("MERCURY_AI_TOKEN"); -pub static MERCURY_API_KEY: std::sync::OnceLock> = std::sync::OnceLock::new(); + +struct GlobalMercuryApiKey(Entity); + +impl Global for GlobalMercuryApiKey {} pub fn mercury_api_token(cx: &mut App) -> Entity { - MERCURY_API_KEY - .get_or_init(|| { - cx.new(|_| ApiKeyState::new(MERCURY_CREDENTIALS_URL, MERCURY_TOKEN_ENV_VAR.clone())) - }) - .clone() + if let Some(global) = cx.try_global::() { + return global.0.clone(); + } + let entity = + cx.new(|_| ApiKeyState::new(MERCURY_CREDENTIALS_URL, MERCURY_TOKEN_ENV_VAR.clone())); + cx.set_global(GlobalMercuryApiKey(entity.clone())); + entity } pub fn load_mercury_api_token(cx: &mut App) -> Task> { diff --git a/crates/edit_prediction/src/sweep_ai.rs b/crates/edit_prediction/src/sweep_ai.rs index 2ed24cd8ef728383ec800acbb2ab7c7b99f07c06..71f28c9213c3440a9267dab7d5a5416dc219f2f3 100644 --- a/crates/edit_prediction/src/sweep_ai.rs +++ b/crates/edit_prediction/src/sweep_ai.rs @@ -1,7 +1,7 @@ use anyhow::Result; use futures::AsyncReadExt as _; use gpui::{ - App, AppContext as _, Entity, SharedString, Task, + App, AppContext as _, Entity, Global, SharedString, Task, http_client::{self, AsyncBody, Method}, }; use language::{Point, ToOffset as _}; @@ -272,14 +272,19 @@ pub const SWEEP_CREDENTIALS_URL: SharedString = SharedString::new_static("https://autocomplete.sweep.dev"); pub const SWEEP_CREDENTIALS_USERNAME: &str = "sweep-api-token"; pub static SWEEP_AI_TOKEN_ENV_VAR: std::sync::LazyLock = env_var!("SWEEP_AI_TOKEN"); -pub static SWEEP_API_KEY: std::sync::OnceLock> = std::sync::OnceLock::new(); + +struct GlobalSweepApiKey(Entity); + +impl Global for GlobalSweepApiKey {} pub fn sweep_api_token(cx: &mut App) -> Entity { - SWEEP_API_KEY - .get_or_init(|| { - cx.new(|_| ApiKeyState::new(SWEEP_CREDENTIALS_URL, SWEEP_AI_TOKEN_ENV_VAR.clone())) - }) - .clone() + if let Some(global) = cx.try_global::() { + return global.0.clone(); + } + let entity = + cx.new(|_| ApiKeyState::new(SWEEP_CREDENTIALS_URL, SWEEP_AI_TOKEN_ENV_VAR.clone())); + cx.set_global(GlobalSweepApiKey(entity.clone())); + entity } pub fn load_sweep_api_token(cx: &mut App) -> Task> { From 05108c50fd1a25714feff391ad719065dd83a589 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torstein=20S=C3=B8rnes?= Date: Thu, 18 Dec 2025 01:34:31 +0100 Subject: [PATCH 482/621] agent_ui: Make tool call raw input visible (#45097) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Screenshot 2025-12-17 at 9  28@2x Release Notes: - agent: Made tool calls' raw input visible in the agent UI. --------- Co-authored-by: Danilo Leal --- crates/acp_thread/src/acp_thread.rs | 9 +++++++++ crates/agent_ui/src/acp/thread_view.rs | 27 ++++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/crates/acp_thread/src/acp_thread.rs b/crates/acp_thread/src/acp_thread.rs index 2ec6347fd4aa088d7ae2cc8f5a7b6cef37d3b202..a994cc8e57e4456ec57092b2257269b104af74c7 100644 --- a/crates/acp_thread/src/acp_thread.rs +++ b/crates/acp_thread/src/acp_thread.rs @@ -192,6 +192,7 @@ pub struct ToolCall { pub locations: Vec, pub resolved_locations: Vec>, pub raw_input: Option, + pub raw_input_markdown: Option>, pub raw_output: Option, } @@ -222,6 +223,11 @@ impl ToolCall { } } + let raw_input_markdown = tool_call + .raw_input + .as_ref() + .and_then(|input| markdown_for_raw_output(input, &language_registry, cx)); + let result = Self { id: tool_call.tool_call_id, label: cx @@ -232,6 +238,7 @@ impl ToolCall { resolved_locations: Vec::default(), status, raw_input: tool_call.raw_input, + raw_input_markdown, raw_output: tool_call.raw_output, }; Ok(result) @@ -307,6 +314,7 @@ impl ToolCall { } if let Some(raw_input) = raw_input { + self.raw_input_markdown = markdown_for_raw_output(&raw_input, &language_registry, cx); self.raw_input = Some(raw_input); } @@ -1355,6 +1363,7 @@ impl AcpThread { locations: Vec::new(), resolved_locations: Vec::new(), raw_input: None, + raw_input_markdown: None, raw_output: None, }; self.push_entry(AgentThreadEntry::ToolCall(failed_tool_call), cx); diff --git a/crates/agent_ui/src/acp/thread_view.rs b/crates/agent_ui/src/acp/thread_view.rs index 9e9af499727ad8478fa5fc1d46dc3b3bf8e20a71..bf2dfa613871f07a3af25953ec54491d9f353c6f 100644 --- a/crates/agent_ui/src/acp/thread_view.rs +++ b/crates/agent_ui/src/acp/thread_view.rs @@ -2440,6 +2440,12 @@ impl AcpThreadView { let is_collapsible = !tool_call.content.is_empty() && !needs_confirmation; let is_open = needs_confirmation || self.expanded_tool_calls.contains(&tool_call.id); + let input_output_header = |label: SharedString| { + Label::new(label) + .size(LabelSize::XSmall) + .color(Color::Muted) + .buffer_font(cx) + }; let tool_output_display = if is_open { @@ -2481,7 +2487,25 @@ impl AcpThreadView { | ToolCallStatus::Completed | ToolCallStatus::Failed | ToolCallStatus::Canceled => v_flex() + .mt_1p5() .w_full() + .child( + v_flex() + .ml(rems(0.4)) + .px_3p5() + .pb_1() + .gap_1() + .border_l_1() + .border_color(self.tool_card_border_color(cx)) + .child(input_output_header("Raw Input".into())) + .children(tool_call.raw_input_markdown.clone().map(|input| { + self.render_markdown( + input, + default_markdown_style(false, false, window, cx), + ) + })) + .child(input_output_header("Output:".into())), + ) .children(tool_call.content.iter().enumerate().map( |(content_ix, content)| { div().child(self.render_tool_call_content( @@ -2580,7 +2604,7 @@ impl AcpThreadView { .gap_px() .when(is_collapsible, |this| { this.child( - Disclosure::new(("expand", entry_ix), is_open) + Disclosure::new(("expand-output", entry_ix), is_open) .opened_icon(IconName::ChevronUp) .closed_icon(IconName::ChevronDown) .visible_on_hover(&card_header_id) @@ -2766,7 +2790,6 @@ impl AcpThreadView { let button_id = SharedString::from(format!("tool_output-{:?}", tool_call_id)); v_flex() - .mt_1p5() .gap_2() .when(!card_layout, |this| { this.ml(rems(0.4)) From 77cdef35966549ee61e101af10d33ece3be40d84 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Wed, 17 Dec 2025 18:04:12 -0700 Subject: [PATCH 483/621] Attempt to fix the autofix auto scheduler (#45178) Release Notes: - N/A --- .github/workflows/extension_tests.yml | 3 +- .github/workflows/release.yml | 7 ++++- .github/workflows/release_nightly.yml | 3 +- .github/workflows/run_tests.yml | 22 +++++++++++--- .../xtask/src/tasks/workflows/run_tests.rs | 29 +++++++++++++++---- tooling/xtask/src/tasks/workflows/steps.rs | 29 ++++++++++++++++++- 6 files changed, 79 insertions(+), 14 deletions(-) diff --git a/.github/workflows/extension_tests.yml b/.github/workflows/extension_tests.yml index 9f0917e388c74cffed8f342f7504bc111e6f5147..7a7fff9b97d694c1b02dd426f5d59301fe2be81e 100644 --- a/.github/workflows/extension_tests.yml +++ b/.github/workflows/extension_tests.yml @@ -61,7 +61,8 @@ jobs: uses: namespacelabs/nscloud-cache-action@v1 with: cache: rust - - name: steps::cargo_fmt + - id: cargo_fmt + name: steps::cargo_fmt run: cargo fmt --all -- --check shell: bash -euxo pipefail {0} - name: extension_tests::run_clippy diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5b2ecf70294ad383944205b300f0d9d1e137b2f6..317d5a8df37a62887ce4ddcdd67c8d77b48d56d6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -76,6 +76,11 @@ jobs: name: steps::clippy run: ./script/clippy shell: bash -euxo pipefail {0} + - id: record_clippy_failure + name: steps::record_clippy_failure + if: always() + run: echo "failed=${{ steps.clippy.outcome == 'failure' }}" >> "$GITHUB_OUTPUT" + shell: bash -euxo pipefail {0} - name: steps::cargo_install_nextest uses: taiki-e/install-action@nextest - name: steps::clear_target_dir_if_large @@ -90,7 +95,7 @@ jobs: rm -rf ./../.cargo shell: bash -euxo pipefail {0} outputs: - clippy_failed: ${{ steps.clippy.outcome == 'failure' }} + clippy_failed: ${{ steps.record_clippy_failure.outputs.failed == 'true' }} timeout-minutes: 60 run_tests_windows: if: (github.repository_owner == 'zed-industries' || github.repository_owner == 'zed-extensions') diff --git a/.github/workflows/release_nightly.yml b/.github/workflows/release_nightly.yml index 906420ad9b15d50578be7d682c6086cc64c9f6e1..b23e4b7518a672c0d586ea5ba437db5cf8f94bb6 100644 --- a/.github/workflows/release_nightly.yml +++ b/.github/workflows/release_nightly.yml @@ -20,7 +20,8 @@ jobs: with: clean: false fetch-depth: 0 - - name: steps::cargo_fmt + - id: cargo_fmt + name: steps::cargo_fmt run: cargo fmt --all -- --check shell: bash -euxo pipefail {0} - name: ./script/clippy diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index d18341b4e09a4a48b61d29609a091570b359c30f..fac3221d63a080fa53b7ba1c5b7249e6a405c73c 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -74,12 +74,19 @@ jobs: uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 with: version: '9' - - name: ./script/prettier + - id: prettier + name: steps::prettier run: ./script/prettier shell: bash -euxo pipefail {0} - - name: steps::cargo_fmt + - id: cargo_fmt + name: steps::cargo_fmt run: cargo fmt --all -- --check shell: bash -euxo pipefail {0} + - id: record_style_failure + name: steps::record_style_failure + if: always() + run: echo "failed=${{ steps.prettier.outcome == 'failure' || steps.cargo_fmt.outcome == 'failure' }}" >> "$GITHUB_OUTPUT" + shell: bash -euxo pipefail {0} - name: ./script/check-todos run: ./script/check-todos shell: bash -euxo pipefail {0} @@ -90,6 +97,8 @@ jobs: uses: crate-ci/typos@2d0ce569feab1f8752f1dde43cc2f2aa53236e06 with: config: ./typos.toml + outputs: + style_failed: ${{ steps.record_style_failure.outputs.failed == 'true' }} timeout-minutes: 60 run_tests_windows: needs: @@ -162,6 +171,11 @@ jobs: name: steps::clippy run: ./script/clippy shell: bash -euxo pipefail {0} + - id: record_clippy_failure + name: steps::record_clippy_failure + if: always() + run: echo "failed=${{ steps.clippy.outcome == 'failure' }}" >> "$GITHUB_OUTPUT" + shell: bash -euxo pipefail {0} - name: steps::cargo_install_nextest uses: taiki-e/install-action@nextest - name: steps::clear_target_dir_if_large @@ -176,7 +190,7 @@ jobs: rm -rf ./../.cargo shell: bash -euxo pipefail {0} outputs: - clippy_failed: ${{ steps.clippy.outcome == 'failure' }} + clippy_failed: ${{ steps.record_clippy_failure.outputs.failed == 'true' }} timeout-minutes: 60 run_tests_mac: needs: @@ -582,7 +596,7 @@ jobs: needs: - check_style - run_tests_linux - if: (needs.check_style.result == 'failure' || needs.run_tests_linux.outputs.clippy_failed == 'true') && github.event_name == 'pull_request' && github.actor != 'zed-zippy[bot]' + if: always() && (needs.check_style.outputs.style_failed == 'true' || needs.run_tests_linux.outputs.clippy_failed == 'true') && github.event_name == 'pull_request' && github.actor != 'zed-zippy[bot]' runs-on: namespace-profile-2x4-ubuntu-2404 steps: - id: get-app-token diff --git a/tooling/xtask/src/tasks/workflows/run_tests.rs b/tooling/xtask/src/tasks/workflows/run_tests.rs index 1bc4b72176ad94c30399bc15a1152b20b200606a..d0caab82b057f21735b7f828c8917a358dd548b2 100644 --- a/tooling/xtask/src/tasks/workflows/run_tests.rs +++ b/tooling/xtask/src/tasks/workflows/run_tests.rs @@ -226,6 +226,8 @@ pub fn tests_pass(jobs: &[NamedJob]) -> NamedJob { named::job(job) } +pub const STYLE_FAILED_OUTPUT: &str = "style_failed"; + fn check_style() -> NamedJob { fn check_for_typos() -> Step { named::uses( @@ -241,11 +243,19 @@ fn check_style() -> NamedJob { .add_step(steps::checkout_repo()) .add_step(steps::cache_rust_dependencies_namespace()) .add_step(steps::setup_pnpm()) - .add_step(steps::script("./script/prettier")) + .add_step(steps::prettier()) .add_step(steps::cargo_fmt()) + .add_step(steps::record_style_failure()) .add_step(steps::script("./script/check-todos")) .add_step(steps::script("./script/check-keymaps")) - .add_step(check_for_typos()), + .add_step(check_for_typos()) + .outputs([( + STYLE_FAILED_OUTPUT.to_owned(), + format!( + "${{{{ steps.{}.outputs.failed == 'true' }}}}", + steps::RECORD_STYLE_FAILURE_STEP_ID + ), + )]), ) } @@ -262,6 +272,10 @@ fn call_autofix(check_style: &NamedJob, run_tests_linux: &NamedJob) -> NamedJob .add_env(("GITHUB_TOKEN", "${{ steps.get-app-token.outputs.token }}")) } + let style_failed_expr = format!( + "needs.{}.outputs.{} == 'true'", + check_style.name, STYLE_FAILED_OUTPUT + ); let clippy_failed_expr = format!( "needs.{}.outputs.{} == 'true'", run_tests_linux.name, CLIPPY_FAILED_OUTPUT @@ -271,8 +285,8 @@ fn call_autofix(check_style: &NamedJob, run_tests_linux: &NamedJob) -> NamedJob let job = Job::default() .runs_on(runners::LINUX_SMALL) .cond(Expression::new(format!( - "(needs.{}.result == 'failure' || {}) && github.event_name == 'pull_request' && github.actor != 'zed-zippy[bot]'", - check_style.name, clippy_failed_expr + "always() && ({} || {}) && github.event_name == 'pull_request' && github.actor != 'zed-zippy[bot]'", + style_failed_expr, clippy_failed_expr ))) .needs(vec![check_style.name.clone(), run_tests_linux.name.clone()]) .add_step(authenticate) @@ -364,6 +378,9 @@ pub(crate) fn run_platform_tests(platform: Platform) -> NamedJob { ) .add_step(steps::setup_node()) .add_step(steps::clippy(platform)) + .when(platform == Platform::Linux, |job| { + job.add_step(steps::record_clippy_failure()) + }) .when(platform == Platform::Linux, |job| { job.add_step(steps::cargo_install_nextest()) }) @@ -374,8 +391,8 @@ pub(crate) fn run_platform_tests(platform: Platform) -> NamedJob { job.outputs([( CLIPPY_FAILED_OUTPUT.to_owned(), format!( - "${{{{ steps.{}.outcome == 'failure' }}}}", - steps::CLIPPY_STEP_ID + "${{{{ steps.{}.outputs.failed == 'true' }}}}", + steps::RECORD_CLIPPY_FAILURE_STEP_ID ), )]) }), diff --git a/tooling/xtask/src/tasks/workflows/steps.rs b/tooling/xtask/src/tasks/workflows/steps.rs index 3ef7f8fd975d515b061b4ca2e9a37501bfd66e31..eaa51dc35205f51e7fe3a56668ed0679e92999f0 100644 --- a/tooling/xtask/src/tasks/workflows/steps.rs +++ b/tooling/xtask/src/tasks/workflows/steps.rs @@ -54,8 +54,25 @@ pub fn setup_sentry() -> Step { .add_with(("token", vars::SENTRY_AUTH_TOKEN)) } +pub const PRETTIER_STEP_ID: &str = "prettier"; +pub const CARGO_FMT_STEP_ID: &str = "cargo_fmt"; +pub const RECORD_STYLE_FAILURE_STEP_ID: &str = "record_style_failure"; + +pub fn prettier() -> Step { + named::bash("./script/prettier").id(PRETTIER_STEP_ID) +} + pub fn cargo_fmt() -> Step { - named::bash("cargo fmt --all -- --check") + named::bash("cargo fmt --all -- --check").id(CARGO_FMT_STEP_ID) +} + +pub fn record_style_failure() -> Step { + named::bash(format!( + "echo \"failed=${{{{ steps.{}.outcome == 'failure' || steps.{}.outcome == 'failure' }}}}\" >> \"$GITHUB_OUTPUT\"", + PRETTIER_STEP_ID, CARGO_FMT_STEP_ID + )) + .id(RECORD_STYLE_FAILURE_STEP_ID) + .if_condition(Expression::new("always()")) } pub fn cargo_install_nextest() -> Step { @@ -102,6 +119,7 @@ pub fn clear_target_dir_if_large(platform: Platform) -> Step { } pub const CLIPPY_STEP_ID: &str = "clippy"; +pub const RECORD_CLIPPY_FAILURE_STEP_ID: &str = "record_clippy_failure"; pub fn clippy(platform: Platform) -> Step { match platform { @@ -110,6 +128,15 @@ pub fn clippy(platform: Platform) -> Step { } } +pub fn record_clippy_failure() -> Step { + named::bash(format!( + "echo \"failed=${{{{ steps.{}.outcome == 'failure' }}}}\" >> \"$GITHUB_OUTPUT\"", + CLIPPY_STEP_ID + )) + .id(RECORD_CLIPPY_FAILURE_STEP_ID) + .if_condition(Expression::new("always()")) +} + pub fn cache_rust_dependencies_namespace() -> Step { named::uses("namespacelabs", "nscloud-cache-action", "v1").add_with(("cache", "rust")) } From ea37057814d00fefae32e4309c1b0e50d1be4295 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Thu, 18 Dec 2025 03:56:12 +0200 Subject: [PATCH 484/621] Restore generic modal closing on mouse click (#45183) Was removed in https://github.com/zed-industries/zed/pull/44887/changes#diff-1de872be76a27a9d574a0b0acec4581797446e60743d23b3e7a5f15088fa7e61 Release Notes: - (Preview only) Fixed certain modals not being dismissed on mouse click outside --- crates/workspace/src/modal_layer.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/workspace/src/modal_layer.rs b/crates/workspace/src/modal_layer.rs index db4d85752835299117dba7fc2aeb1833383a390a..58667e7ffa8ad4fe5a22d293e4fc4aa71015a3bd 100644 --- a/crates/workspace/src/modal_layer.rs +++ b/crates/workspace/src/modal_layer.rs @@ -193,6 +193,12 @@ impl Render for ModalLayer { background.fade_out(0.2); this.bg(background) }) + .on_mouse_down( + MouseButton::Left, + cx.listener(|this, _, window, cx| { + this.hide_modal(window, cx); + }), + ) .child( v_flex() .h(px(0.0)) From 225a2a8a2045abadfa5a5d0eb330afd4244fc93c Mon Sep 17 00:00:00 2001 From: Xiaobo Liu Date: Thu, 18 Dec 2025 10:12:40 +0800 Subject: [PATCH 485/621] google_ai: Refactor token count methods in Google AI (#45184) The change simplifies the `max_token_count` and `max_output_tokens` methods by grouping Gemini models with identical token limits. Release Notes: - N/A --- crates/google_ai/src/google_ai.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/crates/google_ai/src/google_ai.rs b/crates/google_ai/src/google_ai.rs index b6bba48c4b04608b502932787cfcdcd429276b5b..a7d82c584b208cec33075d65a53a74c963ec05b5 100644 --- a/crates/google_ai/src/google_ai.rs +++ b/crates/google_ai/src/google_ai.rs @@ -566,22 +566,22 @@ impl Model { pub fn max_token_count(&self) -> u64 { match self { - Self::Gemini25FlashLite => 1_048_576, - Self::Gemini25Flash => 1_048_576, - Self::Gemini25Pro => 1_048_576, - Self::Gemini3Pro => 1_048_576, - Self::Gemini3Flash => 1_048_576, + Self::Gemini25FlashLite + | Self::Gemini25Flash + | Self::Gemini25Pro + | Self::Gemini3Pro + | Self::Gemini3Flash => 1_048_576, Self::Custom { max_tokens, .. } => *max_tokens, } } pub fn max_output_tokens(&self) -> Option { match self { - Model::Gemini25FlashLite => Some(65_536), - Model::Gemini25Flash => Some(65_536), - Model::Gemini25Pro => Some(65_536), - Model::Gemini3Pro => Some(65_536), - Model::Gemini3Flash => Some(65_536), + Model::Gemini25FlashLite + | Model::Gemini25Flash + | Model::Gemini25Pro + | Model::Gemini3Pro + | Model::Gemini3Flash => Some(65_536), Model::Custom { .. } => None, } } From 184001b33b5ed035d82e52f9de922289e1cd4d61 Mon Sep 17 00:00:00 2001 From: Kunall Banerjee Date: Wed, 17 Dec 2025 21:13:59 -0500 Subject: [PATCH 486/621] docs: Add note about conflicting global macOS shortcut (#45186) This is already noted in our `default-macos.json`, but was never surfaced in our docs for some reason. A user noted their LSP completions were not working because they were not aware of the conflicting global shortcut. Ref: https://github.com/zed-industries/zed/issues/44970#issuecomment-3664118523 Release Notes: - N/A --- docs/src/completions.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/src/completions.md b/docs/src/completions.md index ff96ede7503cd461bbd3d7b4afdedcaa2f36a2e5..7b35ec2d09d91a7ba7dc5ae4b968157e0184227f 100644 --- a/docs/src/completions.md +++ b/docs/src/completions.md @@ -15,6 +15,10 @@ When there is an appropriate language server available, Zed will provide complet You can manually trigger completions with `ctrl-space` or by triggering the `editor::ShowCompletions` action from the command palette. +> Note: Using `ctrl-space` in Zed requires disabling the macOS global shortcut. +> Open **System Settings** > **Keyboard** > **Keyboard Shortcut**s > +> **Input Sources** and uncheck **Select the previous input source**. + For more information, see: - [Configuring Supported Languages](./configuring-languages.md) From 0f7f5401388e0525f2bc6bb666b702edf2dedfe1 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Thu, 18 Dec 2025 04:37:26 +0200 Subject: [PATCH 487/621] Always invalidate tree-sitter data on buffer reparse end (#45187) Also do not eagerly invalidate this data on buffer reparse start Closes https://github.com/zed-industries/zed/issues/45182 Release Notes: - Fixed bracket colorization not applied on initial file open --- crates/language/src/buffer.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/crates/language/src/buffer.rs b/crates/language/src/buffer.rs index abf4d9b10a761b9c0247145e8ddb0664127756d2..b40fdfc97347b9ac2bf1fe0862c102aa017b483e 100644 --- a/crates/language/src/buffer.rs +++ b/crates/language/src/buffer.rs @@ -1697,9 +1697,6 @@ impl Buffer { /// for the same buffer, we only initiate a new parse if we are not already /// parsing in the background. pub fn reparse(&mut self, cx: &mut Context, may_block: bool) { - if self.text.version() != *self.tree_sitter_data.version() { - self.invalidate_tree_sitter_data(self.text.snapshot()); - } if self.reparse.is_some() { return; } @@ -1801,9 +1798,7 @@ impl Buffer { self.syntax_map.lock().did_parse(syntax_snapshot); self.request_autoindent(cx); self.parse_status.0.send(ParseStatus::Idle).unwrap(); - if self.text.version() != *self.tree_sitter_data.version() { - self.invalidate_tree_sitter_data(self.text.snapshot()); - } + self.invalidate_tree_sitter_data(self.text.snapshot()); cx.emit(BufferEvent::Reparsed); cx.notify(); } From cdc5cc348f2d61fdcef8eb69bdde101d5e041156 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Thu, 18 Dec 2025 11:32:35 +0200 Subject: [PATCH 488/621] Return back the eager snapshot update (#45210) Based on https://github.com/zed-industries/zed/pull/45187#discussion_r2630140112 Release Notes: - N/A Co-authored-by: Lukas Wirth --- crates/language/src/buffer.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/language/src/buffer.rs b/crates/language/src/buffer.rs index b40fdfc97347b9ac2bf1fe0862c102aa017b483e..99e0c8d4ebdad709eea0e9ab6dbdf9d889d54ec5 100644 --- a/crates/language/src/buffer.rs +++ b/crates/language/src/buffer.rs @@ -1697,6 +1697,9 @@ impl Buffer { /// for the same buffer, we only initiate a new parse if we are not already /// parsing in the background. pub fn reparse(&mut self, cx: &mut Context, may_block: bool) { + if self.text.version() != *self.tree_sitter_data.version() { + self.invalidate_tree_sitter_data(self.text.snapshot()); + } if self.reparse.is_some() { return; } From df48294caad7dd14600cc0bf27dd1b9e79814539 Mon Sep 17 00:00:00 2001 From: Oleksii Orlenko Date: Thu, 18 Dec 2025 10:48:45 +0100 Subject: [PATCH 489/621] agent_ui: Remove unnecessary Arc allocation (#45172) Follow up to https://github.com/zed-industries/zed/pull/44297. Initial implementation in ce884443f1c38ca8da9edf9fbbb8e7fd579452cb used `Arc` to store the reference to the hash map inside the iterator while keeping the lifetime static. The code was later simplified in 5151b22e2ea37fb457cf4f88b88fe4f315306074 to build the list eagerly but the Arc was forgotten, although it became unnecessary. cc @bennetbo Release Notes: - N/A --- crates/agent_ui/src/acp/model_selector.rs | 30 +++++++++++------------ 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/crates/agent_ui/src/acp/model_selector.rs b/crates/agent_ui/src/acp/model_selector.rs index cff5334a00472fd6f49abcb17897b4ed3c9f590e..f3c07250de3cefc798b97d9ffad444489d153219 100644 --- a/crates/agent_ui/src/acp/model_selector.rs +++ b/crates/agent_ui/src/acp/model_selector.rs @@ -221,7 +221,7 @@ impl PickerDelegate for AcpModelPickerDelegate { cx: &mut Context>, ) -> Task<()> { let favorites = if self.selector.supports_favorites() { - Arc::new(AgentSettings::get_global(cx).favorite_model_ids()) + AgentSettings::get_global(cx).favorite_model_ids() } else { Default::default() }; @@ -242,7 +242,7 @@ impl PickerDelegate for AcpModelPickerDelegate { this.update_in(cx, |this, window, cx| { this.delegate.filtered_entries = - info_list_to_picker_entries(filtered_models, favorites); + info_list_to_picker_entries(filtered_models, &favorites); // Finds the currently selected model in the list let new_index = this .delegate @@ -406,7 +406,7 @@ impl PickerDelegate for AcpModelPickerDelegate { fn info_list_to_picker_entries( model_list: AgentModelList, - favorites: Arc>, + favorites: &HashSet, ) -> Vec { let mut entries = Vec::new(); @@ -572,13 +572,11 @@ mod tests { } } - fn create_favorites(models: Vec<&str>) -> Arc> { - Arc::new( - models - .into_iter() - .map(|m| ModelId::new(m.to_string())) - .collect(), - ) + fn create_favorites(models: Vec<&str>) -> HashSet { + models + .into_iter() + .map(|m| ModelId::new(m.to_string())) + .collect() } fn get_entry_model_ids(entries: &[AcpModelPickerEntry]) -> Vec<&str> { @@ -609,7 +607,7 @@ mod tests { ]); let favorites = create_favorites(vec!["zed/gemini"]); - let entries = info_list_to_picker_entries(models, favorites); + let entries = info_list_to_picker_entries(models, &favorites); assert!(matches!( entries.first(), @@ -625,7 +623,7 @@ mod tests { let models = create_model_list(vec![("zed", vec!["zed/claude", "zed/gemini"])]); let favorites = create_favorites(vec![]); - let entries = info_list_to_picker_entries(models, favorites); + let entries = info_list_to_picker_entries(models, &favorites); assert!(matches!( entries.first(), @@ -641,7 +639,7 @@ mod tests { ]); let favorites = create_favorites(vec!["zed/claude"]); - let entries = info_list_to_picker_entries(models, favorites); + let entries = info_list_to_picker_entries(models, &favorites); for entry in &entries { if let AcpModelPickerEntry::Model(info, is_favorite) = entry { @@ -662,7 +660,7 @@ mod tests { ]); let favorites = create_favorites(vec!["zed/gemini", "openai/gpt-5"]); - let entries = info_list_to_picker_entries(models, favorites); + let entries = info_list_to_picker_entries(models, &favorites); let model_ids = get_entry_model_ids(&entries); assert_eq!(model_ids[0], "zed/gemini"); @@ -683,7 +681,7 @@ mod tests { let favorites = create_favorites(vec!["zed/claude"]); - let entries = info_list_to_picker_entries(models, favorites); + let entries = info_list_to_picker_entries(models, &favorites); let labels = get_entry_labels(&entries); assert_eq!( @@ -723,7 +721,7 @@ mod tests { ]); let favorites = create_favorites(vec!["zed/gemini"]); - let entries = info_list_to_picker_entries(models, favorites); + let entries = info_list_to_picker_entries(models, &favorites); assert!(matches!( entries.first(), From 4b34adedd25c38432650e7bec547cb86e9a61388 Mon Sep 17 00:00:00 2001 From: Guilherme do Amaral Alves Date: Thu, 18 Dec 2025 06:49:32 -0300 Subject: [PATCH 490/621] Update Mistral models context length to their recommended values (#45194) I noticed some of mistral models context lenghts were outdated, they were updated accordingly to mistral documentation. The following models had their context lenght changed: [mistral-large-latest](https://docs.mistral.ai/models/mistral-large-3-25-12) [magistral-medium-latest](https://docs.mistral.ai/models/magistral-medium-1-2-25-09) [magistral-small-latest](https://docs.mistral.ai/models/magistral-small-1-2-25-09) [devstral-medium-latest](https://docs.mistral.ai/models/devstral-2-25-12) [devstral-small-latest](https://docs.mistral.ai/models/devstral-small-2-25-12) --- crates/mistral/src/mistral.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/mistral/src/mistral.rs b/crates/mistral/src/mistral.rs index eca4743d0442b9ca169ac966f78af0112565fcbc..2fa8a2cedaee01daa1452ade35b20c440055b7fc 100644 --- a/crates/mistral/src/mistral.rs +++ b/crates/mistral/src/mistral.rs @@ -155,15 +155,15 @@ impl Model { pub fn max_token_count(&self) -> u64 { match self { Self::CodestralLatest => 256000, - Self::MistralLargeLatest => 131000, + Self::MistralLargeLatest => 256000, Self::MistralMediumLatest => 128000, Self::MistralSmallLatest => 32000, - Self::MagistralMediumLatest => 40000, - Self::MagistralSmallLatest => 40000, + Self::MagistralMediumLatest => 128000, + Self::MagistralSmallLatest => 128000, Self::OpenMistralNemo => 131000, Self::OpenCodestralMamba => 256000, - Self::DevstralMediumLatest => 128000, - Self::DevstralSmallLatest => 262144, + Self::DevstralMediumLatest => 256000, + Self::DevstralSmallLatest => 256000, Self::Pixtral12BLatest => 128000, Self::PixtralLargeLatest => 128000, Self::Custom { max_tokens, .. } => *max_tokens, From f1ca2f9f3177d32d2b07fd5e62e6a8db28c5ddf9 Mon Sep 17 00:00:00 2001 From: MostlyK <135974627+MostlyKIGuess@users.noreply.github.com> Date: Thu, 18 Dec 2025 15:27:21 +0530 Subject: [PATCH 491/621] workspace: Fix new projects opening with default window size (#45204) Previously, when opening a new project (one that was never opened before), the window bounds restoration logic would fall through to GPUI's default window sizing instead of using the last known window bounds. This change consolidates the window bounds restoration logic so that both empty workspaces and new projects use the stored default window bounds, making the behavior consistent: any new window will use the last resized window's size and position. Closes #45092 Release Notes: - Fixed new files and projects opening with default window size instead of the last used window size. --- crates/workspace/src/workspace.rs | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index b636414250c0463eca019ad30321b19d67680fd3..a412b74600158f83d250da021a9f06b627ea98ac 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -1748,26 +1748,18 @@ impl Workspace { window } else { let window_bounds_override = window_bounds_env_override(); - let is_empty_workspace = project_paths.is_empty(); let (window_bounds, display) = if let Some(bounds) = window_bounds_override { (Some(WindowBounds::Windowed(bounds)), None) - } else if let Some(workspace) = serialized_workspace.as_ref() { + } else if let Some(workspace) = serialized_workspace.as_ref() + && let Some(display) = workspace.display + && let Some(bounds) = workspace.window_bounds.as_ref() + { // Reopening an existing workspace - restore its saved bounds - if let (Some(display), Some(bounds)) = - (workspace.display, workspace.window_bounds.as_ref()) - { - (Some(bounds.0), Some(display)) - } else { - (None, None) - } - } else if is_empty_workspace { - // Empty workspace - try to restore the last known no-project window bounds - if let Some((display, bounds)) = persistence::read_default_window_bounds() { - (Some(bounds), Some(display)) - } else { - (None, None) - } + (Some(bounds.0), Some(display)) + } else if let Some((display, bounds)) = persistence::read_default_window_bounds() { + // New or empty workspace - use the last known window bounds + (Some(bounds), Some(display)) } else { // New window - let GPUI's default_bounds() handle cascading (None, None) From b2a0b78ecebf854babb5d3c554c663aa11873953 Mon Sep 17 00:00:00 2001 From: Ben Brandt Date: Thu, 18 Dec 2025 11:25:06 +0100 Subject: [PATCH 492/621] acp: Change default for gemini back to managed version (#45218) It seems we unintentionally changed the default behavior of if we use the gemini on the path in #40663 Changing this back so by default we use a managed version of the CLI so we can better control min versions and the like, but still allow people to override if they need to. Release Notes: - N/A --- crates/project/src/agent_server_store.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/project/src/agent_server_store.rs b/crates/project/src/agent_server_store.rs index 287b25935676e2d5a09e92285a6cc94b81e52e13..1443e4d877d4e288fb379a02fee8a351075d8db8 100644 --- a/crates/project/src/agent_server_store.rs +++ b/crates/project/src/agent_server_store.rs @@ -460,7 +460,7 @@ impl AgentServerStore { .gemini .as_ref() .and_then(|settings| settings.ignore_system_version) - .unwrap_or(false), + .unwrap_or(true), }), ); self.external_agents.insert( From 54f360ace17c25044a569fa43dd633933f2fac8e Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Thu, 18 Dec 2025 12:42:37 +0200 Subject: [PATCH 493/621] Add a test to ensure we invalidate brackets not only on edits (#45219) Follow-up of https://github.com/zed-industries/zed/pull/45187 Release Notes: - N/A --- crates/editor/src/bracket_colorization.rs | 55 +++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/crates/editor/src/bracket_colorization.rs b/crates/editor/src/bracket_colorization.rs index 4879c5e9ce703227d3c03f4d3373512769b1515c..ee7e785ed30a14bce53bb777b67bdf69a9cecd07 100644 --- a/crates/editor/src/bracket_colorization.rs +++ b/crates/editor/src/bracket_colorization.rs @@ -348,6 +348,61 @@ where ); } + #[gpui::test] + async fn test_bracket_colorization_after_language_swap(cx: &mut gpui::TestAppContext) { + init_test(cx, |language_settings| { + language_settings.defaults.colorize_brackets = Some(true); + }); + + let language_registry = Arc::new(language::LanguageRegistry::test(cx.executor())); + language_registry.add(markdown_lang()); + language_registry.add(rust_lang()); + + let mut cx = EditorTestContext::new(cx).await; + cx.update_buffer(|buffer, cx| { + buffer.set_language_registry(language_registry.clone()); + buffer.set_language(Some(markdown_lang()), cx); + }); + + cx.set_state(indoc! {r#" + fn main() { + let v: Vec = vec![]; + } + "#}); + cx.executor().advance_clock(Duration::from_millis(100)); + cx.executor().run_until_parked(); + + assert_eq!( + r#"fn main«1()1» «1{ + let v: Vec = vec!«2[]2»; +}1» + +1 hsla(207.80, 16.20%, 69.19%, 1.00) +2 hsla(29.00, 54.00%, 65.88%, 1.00) +"#, + &bracket_colors_markup(&mut cx), + "Markdown does not colorize <> brackets" + ); + + cx.update_buffer(|buffer, cx| { + buffer.set_language(Some(rust_lang()), cx); + }); + cx.executor().advance_clock(Duration::from_millis(100)); + cx.executor().run_until_parked(); + + assert_eq!( + r#"fn main«1()1» «1{ + let v: Vec«22» = vec!«2[]2»; +}1» + +1 hsla(207.80, 16.20%, 69.19%, 1.00) +2 hsla(29.00, 54.00%, 65.88%, 1.00) +"#, + &bracket_colors_markup(&mut cx), + "After switching to Rust, <> brackets are now colorized" + ); + } + #[gpui::test] async fn test_bracket_colorization_when_editing(cx: &mut gpui::TestAppContext) { init_test(cx, |language_settings| { From 9a69d89f88d459628dac25d1f016e8096b12fb6b Mon Sep 17 00:00:00 2001 From: Ben Brandt Date: Thu, 18 Dec 2025 11:47:36 +0100 Subject: [PATCH 494/621] thread_view: Remove unused acp auth method (#45221) This was from an early iteration and this code path isn't used anymore Release Notes: - N/A --- crates/agent_ui/src/acp/thread_view.rs | 38 -------------------------- 1 file changed, 38 deletions(-) diff --git a/crates/agent_ui/src/acp/thread_view.rs b/crates/agent_ui/src/acp/thread_view.rs index bf2dfa613871f07a3af25953ec54491d9f353c6f..6371c31aecb780d72cc89b22308b7cc631883de2 100644 --- a/crates/agent_ui/src/acp/thread_view.rs +++ b/crates/agent_ui/src/acp/thread_view.rs @@ -1663,44 +1663,6 @@ impl AcpThreadView { }); return; } - } else if method.0.as_ref() == "anthropic-api-key" { - let registry = LanguageModelRegistry::global(cx); - let provider = registry - .read(cx) - .provider(&language_model::ANTHROPIC_PROVIDER_ID) - .unwrap(); - let this = cx.weak_entity(); - let agent = self.agent.clone(); - let connection = connection.clone(); - window.defer(cx, move |window, cx| { - if !provider.is_authenticated(cx) { - Self::handle_auth_required( - this, - AuthRequired { - description: Some("ANTHROPIC_API_KEY must be set".to_owned()), - provider_id: Some(language_model::ANTHROPIC_PROVIDER_ID), - }, - agent, - connection, - window, - cx, - ); - } else { - this.update(cx, |this, cx| { - this.thread_state = Self::initial_state( - agent, - None, - this.workspace.clone(), - this.project.clone(), - true, - window, - cx, - ) - }) - .ok(); - } - }); - return; } else if method.0.as_ref() == "vertex-ai" && std::env::var("GOOGLE_API_KEY").is_err() && (std::env::var("GOOGLE_CLOUD_PROJECT").is_err() From 4f878221333403caac0862560c9df36a680ad14e Mon Sep 17 00:00:00 2001 From: shibang Date: Fri, 19 Dec 2025 00:03:42 +1300 Subject: [PATCH 495/621] gpui: Persist window bounds and display when detaching a workspace session (#45201) Closes #41246 #45092 Release Notes: - N/A **Root Cause**: Empty local workspaces returned `DetachFromSession` from `serialize_workspace_location()`, and the `DetachFromSession` handler only cleared the session_id **without saving window bounds**. **Fix Applied**: Modified the `DetachFromSession` handler to save window bounds via `set_window_open_status()`: ```rust WorkspaceLocation::DetachFromSession => { let window_bounds = SerializedWindowBounds(window.window_bounds()); let display = window.display(cx).and_then(|d| d.uuid().ok()); window.spawn(cx, async move |_| { persistence::DB .set_window_open_status(database_id, window_bounds, display.unwrap_or_default()) .await.log_err(); persistence::DB.set_session_id(database_id, None).await.log_err(); }) } ``` **Recording**: https://github.com/user-attachments/assets/2b6564d4-4e1b-40fe-943b-147296340aa7 --- crates/workspace/src/persistence.rs | 49 +++++++++++++++++++++++++++++ crates/workspace/src/workspace.rs | 24 ++++++++++---- 2 files changed, 67 insertions(+), 6 deletions(-) diff --git a/crates/workspace/src/persistence.rs b/crates/workspace/src/persistence.rs index cf5bdf2ab0059f10f2fb44e2069c8c0baf24d72b..094d03494e726677dc43235d96fc62c076673bf5 100644 --- a/crates/workspace/src/persistence.rs +++ b/crates/workspace/src/persistence.rs @@ -3296,4 +3296,53 @@ mod tests { assert_eq!(workspace.center_group, new_workspace.center_group); } + + #[gpui::test] + async fn test_empty_workspace_window_bounds() { + zlog::init_test(); + + let db = WorkspaceDb::open_test_db("test_empty_workspace_window_bounds").await; + let id = db.next_id().await.unwrap(); + + // Create a workspace with empty paths (empty workspace) + let empty_paths: &[&str] = &[]; + let display_uuid = Uuid::new_v4(); + let window_bounds = SerializedWindowBounds(WindowBounds::Windowed(Bounds { + origin: point(px(100.0), px(200.0)), + size: size(px(800.0), px(600.0)), + })); + + let workspace = SerializedWorkspace { + id, + paths: PathList::new(empty_paths), + location: SerializedWorkspaceLocation::Local, + center_group: Default::default(), + window_bounds: None, + display: None, + docks: Default::default(), + breakpoints: Default::default(), + centered_layout: false, + session_id: None, + window_id: None, + user_toolchains: Default::default(), + }; + + // Save the workspace (this creates the record with empty paths) + db.save_workspace(workspace.clone()).await; + + // Save window bounds separately (as the actual code does via set_window_open_status) + db.set_window_open_status(id, window_bounds, display_uuid) + .await + .unwrap(); + + // Retrieve it using empty paths + let retrieved = db.workspace_for_roots(empty_paths).unwrap(); + + // Verify window bounds were persisted + assert_eq!(retrieved.id, id); + assert!(retrieved.window_bounds.is_some()); + assert_eq!(retrieved.window_bounds.unwrap().0, window_bounds.0); + assert!(retrieved.display.is_some()); + assert_eq!(retrieved.display.unwrap(), display_uuid); + } } diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index a412b74600158f83d250da021a9f06b627ea98ac..0c5c9ffa5d0bfb1f70ce6a861b0209f321222fc0 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -5665,12 +5665,24 @@ impl Workspace { persistence::DB.save_workspace(serialized_workspace).await; }) } - WorkspaceLocation::DetachFromSession => window.spawn(cx, async move |_| { - persistence::DB - .set_session_id(database_id, None) - .await - .log_err(); - }), + WorkspaceLocation::DetachFromSession => { + let window_bounds = SerializedWindowBounds(window.window_bounds()); + let display = window.display(cx).and_then(|d| d.uuid().ok()); + window.spawn(cx, async move |_| { + persistence::DB + .set_window_open_status( + database_id, + window_bounds, + display.unwrap_or_default(), + ) + .await + .log_err(); + persistence::DB + .set_session_id(database_id, None) + .await + .log_err(); + }) + } WorkspaceLocation::None => Task::ready(()), } } From 469da2fd07b6f0f239d6fa4cba9bb3724a3a56b0 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Thu, 18 Dec 2025 12:23:11 +0100 Subject: [PATCH 496/621] gpui: Fix Windows credential lookup returning error instead of `None` when credentials don't exist (#45228) This spams the log with amazon bedrock otherwise Release Notes: - N/A *or* Added/Fixed/Improved ... --- crates/gpui/src/platform/windows/platform.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/gpui/src/platform/windows/platform.rs b/crates/gpui/src/platform/windows/platform.rs index af0cb89ecc94da70cc42c8d4c397aeb2a811d6fb..0e0fdd56c54d56587c09bca14f16dd8e5aef389d 100644 --- a/crates/gpui/src/platform/windows/platform.rs +++ b/crates/gpui/src/platform/windows/platform.rs @@ -659,7 +659,7 @@ impl Platform for WindowsPlatform { if let Err(err) = result { // ERROR_NOT_FOUND means the credential doesn't exist. // Return Ok(None) to match macOS and Linux behavior. - if err.code().0 == ERROR_NOT_FOUND.0 as i32 { + if err.code() == ERROR_NOT_FOUND.to_hresult() { return Ok(None); } return Err(err.into()); From 69fe27f45e123631c6debd36dda28d0ba68f6e0a Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Thu, 18 Dec 2025 13:29:41 +0200 Subject: [PATCH 497/621] Keep tab stop-less snippets in completion list (#45227) Closes https://github.com/zed-industries/zed/issues/45083 cc @agu-z Release Notes: - Fixed certain rust-analyzer snippets not shown --- crates/languages/src/rust.rs | 40 ++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/crates/languages/src/rust.rs b/crates/languages/src/rust.rs index c10f76b079bf093e71b5444934196940e7b26d6c..80bc48908b0894f251d6631b67cb4a19658454bd 100644 --- a/crates/languages/src/rust.rs +++ b/crates/languages/src/rust.rs @@ -355,7 +355,7 @@ impl LspAdapter for RustLspAdapter { | lsp::CompletionTextEdit::Edit(lsp::TextEdit { new_text, .. }), ) = completion.text_edit.as_ref() && let Ok(mut snippet) = snippet::Snippet::parse(new_text) - && !snippet.tabstops.is_empty() + && snippet.tabstops.len() > 1 { label = String::new(); @@ -421,7 +421,9 @@ impl LspAdapter for RustLspAdapter { 0..label.rfind('(').unwrap_or(completion.label.len()), highlight_id, )); - } else if detail_left.is_none() { + } else if detail_left.is_none() + && kind != Some(lsp::CompletionItemKind::SNIPPET) + { return None; } } @@ -1597,6 +1599,40 @@ mod tests { )) ); + // Postfix completion without actual tabstops (only implicit final $0) + // The label should use completion.label so it can be filtered by "ref" + let ref_completion = adapter + .label_for_completion( + &lsp::CompletionItem { + kind: Some(lsp::CompletionItemKind::SNIPPET), + label: "ref".to_string(), + filter_text: Some("ref".to_string()), + label_details: Some(CompletionItemLabelDetails { + detail: None, + description: Some("&expr".to_string()), + }), + detail: Some("&expr".to_string()), + insert_text_format: Some(lsp::InsertTextFormat::SNIPPET), + text_edit: Some(lsp::CompletionTextEdit::Edit(lsp::TextEdit { + range: lsp::Range::default(), + new_text: "&String::new()".to_string(), + })), + ..Default::default() + }, + &language, + ) + .await; + assert!( + ref_completion.is_some(), + "ref postfix completion should have a label" + ); + let ref_label = ref_completion.unwrap(); + let filter_text = &ref_label.text[ref_label.filter_range.clone()]; + assert!( + filter_text.contains("ref"), + "filter range text '{filter_text}' should contain 'ref' for filtering to work", + ); + // Test for correct range calculation with mixed empty and non-empty tabstops.(See https://github.com/zed-industries/zed/issues/44825) let res = adapter .label_for_completion( From bb1198e7d60de7510dcd10c400f5ae205835da5c Mon Sep 17 00:00:00 2001 From: Henry Chu Date: Thu, 18 Dec 2025 19:54:34 +0800 Subject: [PATCH 498/621] languages: Allow using locally installed `ty` for Python (#45193) Release Notes: - Allow using locally installed `ty` for Python --- crates/languages/src/python.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/crates/languages/src/python.rs b/crates/languages/src/python.rs index 77d4be6f49a4928731d39d2154cbe4f0e38024ef..a06b1efe649b93ef56a35c40bd0d35cd1bc7ca9c 100644 --- a/crates/languages/src/python.rs +++ b/crates/languages/src/python.rs @@ -295,6 +295,23 @@ impl LspInstaller for TyLspAdapter { }) } + async fn check_if_user_installed( + &self, + delegate: &dyn LspAdapterDelegate, + _: Option, + _: &AsyncApp, + ) -> Option { + let Some(ty_bin) = delegate.which(Self::SERVER_NAME.as_ref()).await else { + return None; + }; + let env = delegate.shell_env().await; + Some(LanguageServerBinary { + path: ty_bin, + env: Some(env), + arguments: vec!["server".into()], + }) + } + async fn fetch_server_binary( &self, latest_version: Self::BinaryVersion, From 5488a19221aa487d81020fcbb93efcf42b52e6fa Mon Sep 17 00:00:00 2001 From: rabsef-bicrym <52549148+rabsef-bicrym@users.noreply.github.com> Date: Thu, 18 Dec 2025 04:11:14 -0800 Subject: [PATCH 499/621] terminal: Respect RevealStrategy::NoFocus and Never focus settings (#45180) Closes #45179 ## Summary Fixes the focus behavior when creating terminals with `RevealStrategy::NoFocus` or `RevealStrategy::Never`. Previously, terminals would still receive focus if the terminal pane already had focus, contradicting the documented behavior. ## Changes - **`add_terminal_task()`**: Changed focus logic to only focus when `RevealStrategy::Always` - **`add_terminal_shell()`**: Same fix The fix changes: ```rust // Before let focus = pane.has_focus(window, cx) || matches!(reveal_strategy, RevealStrategy::Always); // After let focus = matches!(reveal_strategy, RevealStrategy::Always); ``` ## Impact This affects: - Vim users running `:!command` (uses `NoFocus`) - Debugger terminal spawning (uses `NoFocus`) - Any programmatic terminal creation requesting background behavior Release Notes: - Fixed terminal focus behavior to respect `RevealStrategy::NoFocus` and `RevealStrategy::Never` settings when the terminal pane already has focus. --- crates/terminal_view/src/terminal_panel.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/crates/terminal_view/src/terminal_panel.rs b/crates/terminal_view/src/terminal_panel.rs index 85c6b81f406597e097cabc27408d3df70aad6395..a00e544f97836078ab8d96f2e90d36893cac27ca 100644 --- a/crates/terminal_view/src/terminal_panel.rs +++ b/crates/terminal_view/src/terminal_panel.rs @@ -790,8 +790,7 @@ impl TerminalPanel { } pane.update(cx, |pane, cx| { - let focus = pane.has_focus(window, cx) - || matches!(reveal_strategy, RevealStrategy::Always); + let focus = matches!(reveal_strategy, RevealStrategy::Always); pane.add_item(terminal_view, true, focus, None, window, cx); }); @@ -853,8 +852,7 @@ impl TerminalPanel { } pane.update(cx, |pane, cx| { - let focus = pane.has_focus(window, cx) - || matches!(reveal_strategy, RevealStrategy::Always); + let focus = matches!(reveal_strategy, RevealStrategy::Always); pane.add_item(terminal_view, true, focus, None, window, cx); }); From 0180f3e72ab95cd2be1d96927a67faa616dcd137 Mon Sep 17 00:00:00 2001 From: Ben Brandt Date: Thu, 18 Dec 2025 13:47:34 +0100 Subject: [PATCH 500/621] deepseek: Fix for max output tokens blocking completions (#45236) They count the requested max_output_tokens against the prompt total. Seems like a bug on their end as most other providers don't do this, but now we just default to None for the main models and let the API use its default behavior which works just fine. Closes: #45134 Release Notes: - deepseek: Fix issue with Deepseek API that was causing the token limit to be reached sooner than necessary --- crates/deepseek/src/deepseek.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/deepseek/src/deepseek.rs b/crates/deepseek/src/deepseek.rs index e978aa08048bfa4c7b7b203ce6b405ba8a0a7d0c..636258a5a132ce79cb5d15b1aaa25d6e4d3af643 100644 --- a/crates/deepseek/src/deepseek.rs +++ b/crates/deepseek/src/deepseek.rs @@ -103,8 +103,9 @@ impl Model { pub fn max_output_tokens(&self) -> Option { match self { - Self::Chat => Some(8_192), - Self::Reasoner => Some(64_000), + // Their API treats this max against the context window, which means we hit the limit a lot + // Using the default value of None in the API instead + Self::Chat | Self::Reasoner => None, Self::Custom { max_output_tokens, .. } => *max_output_tokens, From cebbf77491faa05f04e9939450e718405fdad93a Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Thu, 18 Dec 2025 14:05:20 +0100 Subject: [PATCH 501/621] gpui(windows): Fix clicks to inactive windows not dispatching to the clicked window (#45237) Release Notes: - Fixed an issue on windows where clicking buttons on windows in the background would not register as being clicked on that window --- crates/gpui/src/platform/windows/events.rs | 5 +++++ crates/gpui/src/window.rs | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/gpui/src/platform/windows/events.rs b/crates/gpui/src/platform/windows/events.rs index e6fa6006eb95ec45f1634cb72ef63e2f622455a7..f224a1bf3c47dc1a61c5e0216f5d7825cfc72533 100644 --- a/crates/gpui/src/platform/windows/events.rs +++ b/crates/gpui/src/platform/windows/events.rs @@ -40,6 +40,11 @@ impl WindowsWindowInner { lparam: LPARAM, ) -> LRESULT { let handled = match msg { + // eagerly activate the window, so calls to `active_window` will work correctly + WM_MOUSEACTIVATE => { + unsafe { SetActiveWindow(handle).log_err() }; + None + } WM_ACTIVATE => self.handle_activate_msg(wparam), WM_CREATE => self.handle_create_msg(handle), WM_MOVE => self.handle_move_msg(handle, lparam), diff --git a/crates/gpui/src/window.rs b/crates/gpui/src/window.rs index 840f2223fcc4a62b6e522f38b967a3fe4ad3209e..2ccd7edac86bced89048cbe5dbf196d8fbcf95f3 100644 --- a/crates/gpui/src/window.rs +++ b/crates/gpui/src/window.rs @@ -4966,7 +4966,7 @@ impl From> for AnyWindowHandle { } /// A handle to a window with any root view type, which can be downcast to a window with a specific root view type. -#[derive(Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] pub struct AnyWindowHandle { pub(crate) id: WindowId, state_type: TypeId, From abb199c85e466222b00d476b8a837fa4c3b3bee1 Mon Sep 17 00:00:00 2001 From: Ben Brandt Date: Thu, 18 Dec 2025 15:03:11 +0100 Subject: [PATCH 502/621] thread_view: Clearer authentication states (#45230) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #44717 Sometimes, we show the user the agent's auth methods because we got an AuthRequired error. However, there are also several ways a user can choose to re-enter the authentication flow even though they are still logged in. This has caused some confusion with several users, where after logging in, they type /login again to see if anything changed, and they saw an "Authentication Required" warning. So, I made a distinction in the UI if we go to this flow from a concrete error, or if not, made the language less error-like to help avoid confusion. | Before | After | |--------|--------| | Screenshot 2025-12-18 at 10 
54@2x | Screenshot 2025-12-18 at 10 
53@2x | Release Notes: - N/A --------- Co-authored-by: Danilo Leal Co-authored-by: Miguel Raz Guzmán Macedo --- crates/agent_ui/src/acp/thread_view.rs | 277 ++++++++++++------------- crates/ui/src/components/callout.rs | 2 +- 2 files changed, 130 insertions(+), 149 deletions(-) diff --git a/crates/agent_ui/src/acp/thread_view.rs b/crates/agent_ui/src/acp/thread_view.rs index 6371c31aecb780d72cc89b22308b7cc631883de2..fe6a3a3087066946a2973067d4439b63de60bdf0 100644 --- a/crates/agent_ui/src/acp/thread_view.rs +++ b/crates/agent_ui/src/acp/thread_view.rs @@ -34,7 +34,7 @@ use language::Buffer; use language_model::LanguageModelRegistry; use markdown::{HeadingLevelStyles, Markdown, MarkdownElement, MarkdownStyle}; -use project::{Project, ProjectEntryId}; +use project::{AgentServerStore, ExternalAgentServerName, Project, ProjectEntryId}; use prompt_store::{PromptId, PromptStore}; use rope::Point; use settings::{NotifyWhenAgentWaiting, Settings as _, SettingsStore}; @@ -260,6 +260,7 @@ impl ThreadFeedbackState { pub struct AcpThreadView { agent: Rc, + agent_server_store: Entity, workspace: WeakEntity, project: Entity, thread_state: ThreadState, @@ -406,6 +407,7 @@ impl AcpThreadView { Self { agent: agent.clone(), + agent_server_store, workspace: workspace.clone(), project: project.clone(), entry_view_state, @@ -737,7 +739,7 @@ impl AcpThreadView { cx: &mut App, ) { let agent_name = agent.name(); - let (configuration_view, subscription) = if let Some(provider_id) = err.provider_id { + let (configuration_view, subscription) = if let Some(provider_id) = &err.provider_id { let registry = LanguageModelRegistry::global(cx); let sub = window.subscribe(®istry, cx, { @@ -779,7 +781,6 @@ impl AcpThreadView { configuration_view, description: err .description - .clone() .map(|desc| cx.new(|cx| Markdown::new(desc.into(), None, None, cx))), _subscription: subscription, }; @@ -1088,10 +1089,7 @@ impl AcpThreadView { window.defer(cx, |window, cx| { Self::handle_auth_required( this, - AuthRequired { - description: None, - provider_id: None, - }, + AuthRequired::new(), agent, connection, window, @@ -3485,138 +3483,119 @@ impl AcpThreadView { pending_auth_method: Option<&acp::AuthMethodId>, window: &mut Window, cx: &Context, - ) -> Div { - let show_description = - configuration_view.is_none() && description.is_none() && pending_auth_method.is_none(); - + ) -> impl IntoElement { let auth_methods = connection.auth_methods(); - v_flex().flex_1().size_full().justify_end().child( - v_flex() - .p_2() - .pr_3() - .w_full() - .gap_1() - .border_t_1() - .border_color(cx.theme().colors().border) - .bg(cx.theme().status().warning.opacity(0.04)) - .child( - h_flex() - .gap_1p5() - .child( - Icon::new(IconName::Warning) - .color(Color::Warning) - .size(IconSize::Small), - ) - .child(Label::new("Authentication Required").size(LabelSize::Small)), - ) - .children(description.map(|desc| { - div().text_ui(cx).child(self.render_markdown( - desc.clone(), - default_markdown_style(false, false, window, cx), - )) - })) - .children( - configuration_view - .cloned() - .map(|view| div().w_full().child(view)), - ) - .when(show_description, |el| { - el.child( - Label::new(format!( - "You are not currently authenticated with {}.{}", - self.agent.name(), - if auth_methods.len() > 1 { - " Please choose one of the following options:" - } else { - "" - } - )) - .size(LabelSize::Small) - .color(Color::Muted) - .mb_1() - .ml_5(), - ) - }) - .when_some(pending_auth_method, |el, _| { - el.child( - h_flex() - .py_4() - .w_full() - .justify_center() - .gap_1() - .child( - Icon::new(IconName::ArrowCircle) - .size(IconSize::Small) - .color(Color::Muted) - .with_rotate_animation(2), - ) - .child(Label::new("Authenticating…").size(LabelSize::Small)), - ) - }) - .when(!auth_methods.is_empty(), |this| { - this.child( - h_flex() - .justify_end() - .flex_wrap() - .gap_1() - .when(!show_description, |this| { - this.border_t_1() - .mt_1() - .pt_2() - .border_color(cx.theme().colors().border.opacity(0.8)) + let agent_display_name = self + .agent_server_store + .read(cx) + .agent_display_name(&ExternalAgentServerName(self.agent.name())) + .unwrap_or_else(|| self.agent.name()); + + let show_fallback_description = auth_methods.len() > 1 + && configuration_view.is_none() + && description.is_none() + && pending_auth_method.is_none(); + + let auth_buttons = || { + h_flex().justify_end().flex_wrap().gap_1().children( + connection + .auth_methods() + .iter() + .enumerate() + .rev() + .map(|(ix, method)| { + let (method_id, name) = if self.project.read(cx).is_via_remote_server() + && method.id.0.as_ref() == "oauth-personal" + && method.name == "Log in with Google" + { + ("spawn-gemini-cli".into(), "Log in with Gemini CLI".into()) + } else { + (method.id.0.clone(), method.name.clone()) + }; + + let agent_telemetry_id = connection.telemetry_id(); + + Button::new(method_id.clone(), name) + .label_size(LabelSize::Small) + .map(|this| { + if ix == 0 { + this.style(ButtonStyle::Tinted(TintColor::Accent)) + } else { + this.style(ButtonStyle::Outlined) + } }) - .children(connection.auth_methods().iter().enumerate().rev().map( - |(ix, method)| { - let (method_id, name) = if self - .project - .read(cx) - .is_via_remote_server() - && method.id.0.as_ref() == "oauth-personal" - && method.name == "Log in with Google" - { - ("spawn-gemini-cli".into(), "Log in with Gemini CLI".into()) - } else { - (method.id.0.clone(), method.name.clone()) - }; + .when_some(method.description.clone(), |this, description| { + this.tooltip(Tooltip::text(description)) + }) + .on_click({ + cx.listener(move |this, _, window, cx| { + telemetry::event!( + "Authenticate Agent Started", + agent = agent_telemetry_id, + method = method_id + ); - let agent_telemetry_id = connection.telemetry_id(); + this.authenticate( + acp::AuthMethodId::new(method_id.clone()), + window, + cx, + ) + }) + }) + }), + ) + }; - Button::new(method_id.clone(), name) - .label_size(LabelSize::Small) - .map(|this| { - if ix == 0 { - this.style(ButtonStyle::Tinted(TintColor::Warning)) - } else { - this.style(ButtonStyle::Outlined) - } - }) - .when_some( - method.description.clone(), - |this, description| { - this.tooltip(Tooltip::text(description)) - }, - ) - .on_click({ - cx.listener(move |this, _, window, cx| { - telemetry::event!( - "Authenticate Agent Started", - agent = agent_telemetry_id, - method = method_id - ); - - this.authenticate( - acp::AuthMethodId::new(method_id.clone()), - window, - cx, - ) - }) - }) - }, - )), - ) - }), - ) + if pending_auth_method.is_some() { + return Callout::new() + .icon(IconName::Info) + .title(format!("Authenticating to {}…", agent_display_name)) + .actions_slot( + Icon::new(IconName::ArrowCircle) + .size(IconSize::Small) + .color(Color::Muted) + .with_rotate_animation(2) + .into_any_element(), + ) + .into_any_element(); + } + + Callout::new() + .icon(IconName::Info) + .title(format!("Authenticate to {}", agent_display_name)) + .when(auth_methods.len() == 1, |this| { + this.actions_slot(auth_buttons()) + }) + .description_slot( + v_flex() + .text_ui(cx) + .map(|this| { + if show_fallback_description { + this.child( + Label::new("Choose one of the following authentication options:") + .size(LabelSize::Small) + .color(Color::Muted), + ) + } else { + this.children( + configuration_view + .cloned() + .map(|view| div().w_full().child(view)), + ) + .children(description.map(|desc| { + self.render_markdown( + desc.clone(), + default_markdown_style(false, false, window, cx), + ) + })) + } + }) + .when(auth_methods.len() > 1, |this| { + this.gap_1().child(auth_buttons()) + }), + ) + .into_any_element() } fn render_load_error( @@ -5865,10 +5844,6 @@ impl AcpThreadView { }; let connection = thread.read(cx).connection().clone(); - let err = AuthRequired { - description: None, - provider_id: None, - }; this.clear_thread_error(cx); if let Some(message) = this.in_flight_prompt.take() { this.message_editor.update(cx, |editor, cx| { @@ -5877,7 +5852,14 @@ impl AcpThreadView { } let this = cx.weak_entity(); window.defer(cx, |window, cx| { - Self::handle_auth_required(this, err, agent, connection, window, cx); + Self::handle_auth_required( + this, + AuthRequired::new(), + agent, + connection, + window, + cx, + ); }) } })) @@ -5890,14 +5872,10 @@ impl AcpThreadView { }; let connection = thread.read(cx).connection().clone(); - let err = AuthRequired { - description: None, - provider_id: None, - }; self.clear_thread_error(cx); let this = cx.weak_entity(); window.defer(cx, |window, cx| { - Self::handle_auth_required(this, err, agent, connection, window, cx); + Self::handle_auth_required(this, AuthRequired::new(), agent, connection, window, cx); }) } @@ -6000,16 +5978,19 @@ impl Render for AcpThreadView { configuration_view, pending_auth_method, .. - } => self - .render_auth_required_state( + } => v_flex() + .flex_1() + .size_full() + .justify_end() + .child(self.render_auth_required_state( connection, description.as_ref(), configuration_view.as_ref(), pending_auth_method.as_ref(), window, cx, - ) - .into_any(), + )) + .into_any_element(), ThreadState::Loading { .. } => v_flex() .flex_1() .child(self.render_recent_history(cx)) diff --git a/crates/ui/src/components/callout.rs b/crates/ui/src/components/callout.rs index 4eb849d7f640aca78b70645f5f93301281ca6627..de95e5db2bcee2e7acbadf5570de09d9cdedbf4d 100644 --- a/crates/ui/src/components/callout.rs +++ b/crates/ui/src/components/callout.rs @@ -121,7 +121,7 @@ impl RenderOnce for Callout { Severity::Info => ( IconName::Info, Color::Muted, - cx.theme().colors().panel_background.opacity(0.), + cx.theme().status().info_background.opacity(0.1), ), Severity::Success => ( IconName::Check, From 61dd6a8f318556d1e84963ff186ca63e582f9ff7 Mon Sep 17 00:00:00 2001 From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Date: Thu, 18 Dec 2025 11:34:10 -0300 Subject: [PATCH 503/621] agent_ui: Add some fixes to tool calling display (#45252) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Follow up to https://github.com/zed-industries/zed/pull/45097 — not showing raw inputs for edit and terminal calls - Removing the display of empty Markdown if the model outputs it Release Notes: - N/A --------- Co-authored-by: Agus Zubiaga Co-authored-by: Ben Brandt --- crates/agent_ui/src/acp/thread_view.rs | 123 +++++++++++++++---------- 1 file changed, 72 insertions(+), 51 deletions(-) diff --git a/crates/agent_ui/src/acp/thread_view.rs b/crates/agent_ui/src/acp/thread_view.rs index fe6a3a3087066946a2973067d4439b63de60bdf0..ed61141b0ab824b81731953db7b5a32b90d0539b 100644 --- a/crates/agent_ui/src/acp/thread_view.rs +++ b/crates/agent_ui/src/acp/thread_view.rs @@ -2113,6 +2113,7 @@ impl AcpThreadView { chunks, indented: _, }) => { + let mut is_blank = true; let is_last = entry_ix + 1 == total_entries; let style = default_markdown_style(false, false, window, cx); @@ -2122,36 +2123,55 @@ impl AcpThreadView { .children(chunks.iter().enumerate().filter_map( |(chunk_ix, chunk)| match chunk { AssistantMessageChunk::Message { block } => { - block.markdown().map(|md| { - self.render_markdown(md.clone(), style.clone()) - .into_any_element() + block.markdown().and_then(|md| { + let this_is_blank = md.read(cx).source().trim().is_empty(); + is_blank = is_blank && this_is_blank; + if this_is_blank { + return None; + } + + Some( + self.render_markdown(md.clone(), style.clone()) + .into_any_element(), + ) }) } AssistantMessageChunk::Thought { block } => { - block.markdown().map(|md| { - self.render_thinking_block( - entry_ix, - chunk_ix, - md.clone(), - window, - cx, + block.markdown().and_then(|md| { + let this_is_blank = md.read(cx).source().trim().is_empty(); + is_blank = is_blank && this_is_blank; + if this_is_blank { + return None; + } + + Some( + self.render_thinking_block( + entry_ix, + chunk_ix, + md.clone(), + window, + cx, + ) + .into_any_element(), ) - .into_any_element() }) } }, )) .into_any(); - v_flex() - .px_5() - .py_1p5() - .when(is_first_indented, |this| this.pt_0p5()) - .when(is_last, |this| this.pb_4()) - .w_full() - .text_ui(cx) - .child(message_body) - .into_any() + if is_blank { + Empty.into_any() + } else { + v_flex() + .px_5() + .py_1p5() + .when(is_last, |this| this.pb_4()) + .w_full() + .text_ui(cx) + .child(message_body) + .into_any() + } } AgentThreadEntry::ToolCall(tool_call) => { let has_terminals = tool_call.terminals().next().is_some(); @@ -2183,7 +2203,7 @@ impl AcpThreadView { div() .relative() .w_full() - .pl(rems_from_px(20.0)) + .pl_5() .bg(cx.theme().colors().panel_background.opacity(0.2)) .child( div() @@ -2447,25 +2467,25 @@ impl AcpThreadView { | ToolCallStatus::Completed | ToolCallStatus::Failed | ToolCallStatus::Canceled => v_flex() - .mt_1p5() - .w_full() - .child( - v_flex() - .ml(rems(0.4)) - .px_3p5() - .pb_1() - .gap_1() - .border_l_1() - .border_color(self.tool_card_border_color(cx)) - .child(input_output_header("Raw Input".into())) - .children(tool_call.raw_input_markdown.clone().map(|input| { - self.render_markdown( - input, - default_markdown_style(false, false, window, cx), - ) - })) - .child(input_output_header("Output:".into())), - ) + .when(!is_edit && !is_terminal_tool, |this| { + this.mt_1p5().w_full().child( + v_flex() + .ml(rems(0.4)) + .px_3p5() + .pb_1() + .gap_1() + .border_l_1() + .border_color(self.tool_card_border_color(cx)) + .child(input_output_header("Raw Input:".into())) + .children(tool_call.raw_input_markdown.clone().map(|input| { + self.render_markdown( + input, + default_markdown_style(false, false, window, cx), + ) + })) + .child(input_output_header("Output:".into())), + ) + }) .children(tool_call.content.iter().enumerate().map( |(content_ix, content)| { div().child(self.render_tool_call_content( @@ -2751,18 +2771,19 @@ impl AcpThreadView { v_flex() .gap_2() - .when(!card_layout, |this| { - this.ml(rems(0.4)) - .px_3p5() - .border_l_1() - .border_color(self.tool_card_border_color(cx)) - }) - .when(card_layout, |this| { - this.px_2().pb_2().when(context_ix > 0, |this| { - this.border_t_1() - .pt_2() + .map(|this| { + if card_layout { + this.when(context_ix > 0, |this| { + this.pt_2() + .border_t_1() + .border_color(self.tool_card_border_color(cx)) + }) + } else { + this.ml(rems(0.4)) + .px_3p5() + .border_l_1() .border_color(self.tool_card_border_color(cx)) - }) + } }) .text_xs() .text_color(cx.theme().colors().text_muted) From f9462da2f7cdd0bfdb0feb95ae983fe695bb0a86 Mon Sep 17 00:00:00 2001 From: "Ahmed M. Ammar" Date: Thu, 18 Dec 2025 16:34:33 +0200 Subject: [PATCH 504/621] terminal: Fix pane re-entrancy panic when splitting terminal tabs (#45231) ## Summary Fix panic "cannot update workspace::pane::Pane while it is already being updated" when dragging terminal tabs to split the pane. ## Problem When dragging a terminal tab to create a split, the app panics due to re-entrancy: the drop handler calls `terminal_panel.center.split()` synchronously, which invokes `mark_positions()` that tries to update all panes in the group. When the pane being updated is part of the terminal panel's center group, this causes a re-entrancy panic. ## Solution Defer the split operation using `cx.spawn_in()`, similar to how `move_item` was already deferred in the same handler. This ensures the split (and subsequent `mark_positions()` call) runs after the current pane update completes. ## Test plan - Open terminal panel - Create a terminal tab - Drag the terminal tab to split the pane - Verify no panic occurs and split works correctly --- crates/terminal_view/src/terminal_panel.rs | 109 +++++++++++---------- 1 file changed, 56 insertions(+), 53 deletions(-) diff --git a/crates/terminal_view/src/terminal_panel.rs b/crates/terminal_view/src/terminal_panel.rs index a00e544f97836078ab8d96f2e90d36893cac27ca..ed43d94e9d3d7c08c1ff4570e08726310360cd93 100644 --- a/crates/terminal_view/src/terminal_panel.rs +++ b/crates/terminal_view/src/terminal_panel.rs @@ -1169,64 +1169,67 @@ pub fn new_terminal_pane( let source = tab.pane.clone(); let item_id_to_move = item.item_id(); - let Ok(new_split_pane) = pane - .drag_split_direction() - .map(|split_direction| { - drop_closure_terminal_panel.update(cx, |terminal_panel, cx| { - let is_zoomed = if terminal_panel.active_pane == this_pane { - pane.is_zoomed() - } else { - terminal_panel.active_pane.read(cx).is_zoomed() - }; - let new_pane = new_terminal_pane( - workspace.clone(), - project.clone(), - is_zoomed, - window, - cx, - ); - terminal_panel.apply_tab_bar_buttons(&new_pane, cx); - terminal_panel.center.split( - &this_pane, - &new_pane, - split_direction, - cx, - )?; - anyhow::Ok(new_pane) - }) - }) - .transpose() - else { - return ControlFlow::Break(()); + // If no split direction, let the regular pane drop handler take care of it + let Some(split_direction) = pane.drag_split_direction() else { + return ControlFlow::Continue(()); }; - match new_split_pane.transpose() { - // Source pane may be the one currently updated, so defer the move. - Ok(Some(new_pane)) => cx - .spawn_in(window, async move |_, cx| { - cx.update(|window, cx| { - move_item( - &source, + // Gather data synchronously before deferring + let is_zoomed = drop_closure_terminal_panel + .upgrade() + .map(|terminal_panel| { + let terminal_panel = terminal_panel.read(cx); + if terminal_panel.active_pane == this_pane { + pane.is_zoomed() + } else { + terminal_panel.active_pane.read(cx).is_zoomed() + } + }) + .unwrap_or(false); + + let workspace = workspace.clone(); + let terminal_panel = drop_closure_terminal_panel.clone(); + + // Defer the split operation to avoid re-entrancy panic. + // The pane may be the one currently being updated, so we cannot + // call mark_positions (via split) synchronously. + cx.spawn_in(window, async move |_, cx| { + cx.update(|window, cx| { + let Ok(new_pane) = + terminal_panel.update(cx, |terminal_panel, cx| { + let new_pane = new_terminal_pane( + workspace, project, is_zoomed, window, cx, + ); + terminal_panel.apply_tab_bar_buttons(&new_pane, cx); + terminal_panel.center.split( + &this_pane, &new_pane, - item_id_to_move, - new_pane.read(cx).active_item_index(), - true, - window, + split_direction, cx, - ); + )?; + anyhow::Ok(new_pane) }) - .ok(); - }) - .detach(), - // If we drop into existing pane or current pane, - // regular pane drop handler will take care of it, - // using the right tab index for the operation. - Ok(None) => return ControlFlow::Continue(()), - err @ Err(_) => { - err.log_err(); - return ControlFlow::Break(()); - } - }; + else { + return; + }; + + let Some(new_pane) = new_pane.log_err() else { + return; + }; + + move_item( + &source, + &new_pane, + item_id_to_move, + new_pane.read(cx).active_item_index(), + true, + window, + cx, + ); + }) + .ok(); + }) + .detach(); } else if let Some(project_path) = item.project_path(cx) && let Some(entry_path) = project.read(cx).absolute_path(&project_path, cx) { From 7a783a91cccba2a74061c07c25001ca621db81cf Mon Sep 17 00:00:00 2001 From: Ben Brandt Date: Thu, 18 Dec 2025 16:01:20 +0100 Subject: [PATCH 505/621] acp: Update to agent-client-protocol rust sdk v0.9.2 (#45255) Release Notes: - N/A --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 86b551b1895a0fd6747c35c3fcfe3859396665fa..7364a68b2a68fe44a42d24443dd723aa3c87e135 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -226,9 +226,9 @@ dependencies = [ [[package]] name = "agent-client-protocol" -version = "0.9.0" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2ffe7d502c1e451aafc5aff655000f84d09c9af681354ac0012527009b1af13" +checksum = "d3e527d7dfe0f334313d42d1d9318f0a79665f6f21c440d0798f230a77a7ed6c" dependencies = [ "agent-client-protocol-schema", "anyhow", @@ -243,9 +243,9 @@ dependencies = [ [[package]] name = "agent-client-protocol-schema" -version = "0.10.0" +version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8af81cc2d5c3f9c04f73db452efd058333735ba9d51c2cf7ef33c9fee038e7e6" +checksum = "6903a00e8ac822f9bacac59a1932754d7387c72ebb7c9c7439ad021505591da4" dependencies = [ "anyhow", "derive_more 2.0.1", diff --git a/Cargo.toml b/Cargo.toml index 703a34b63af901886e861dba3177e58b19c223f0..825dc79e08978d8ccd03cea93883f698986ee12f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -438,7 +438,7 @@ ztracing_macro = { path = "crates/ztracing_macro" } # External crates # -agent-client-protocol = { version = "=0.9.0", features = ["unstable"] } +agent-client-protocol = { version = "=0.9.2", features = ["unstable"] } aho-corasick = "1.1" alacritty_terminal = "0.25.1-rc1" any_vec = "0.14" From 886de8f54bb8fae99a7c6215802d1714c30d4bb7 Mon Sep 17 00:00:00 2001 From: Bennet Bo Fenner Date: Thu, 18 Dec 2025 16:38:47 +0100 Subject: [PATCH 506/621] agent_ui: Improve UX when pasting code into message editor (#45254) Follow up to #42982 Release Notes: - agent: Allow pasting code without formatting via ctrl/cmd-shift-v. - agent: Fixed an issue where pasting a single line of code would always insert an @mention --- assets/keymaps/default-linux.json | 3 + assets/keymaps/default-macos.json | 3 + assets/keymaps/default-windows.json | 3 + crates/agent_ui/src/acp/message_editor.rs | 243 +++++++++++----------- crates/agent_ui/src/text_thread_editor.rs | 171 ++++++++------- crates/zed_actions/src/lib.rs | 2 + 6 files changed, 234 insertions(+), 191 deletions(-) diff --git a/assets/keymaps/default-linux.json b/assets/keymaps/default-linux.json index ec21bc152edf969f57ac341e4b92f78c9e5da11a..465c7d86aeaff23bdebe65792304ac2963edaaa7 100644 --- a/assets/keymaps/default-linux.json +++ b/assets/keymaps/default-linux.json @@ -227,6 +227,7 @@ "ctrl-g": "search::SelectNextMatch", "ctrl-shift-g": "search::SelectPreviousMatch", "ctrl-k l": "agent::OpenRulesLibrary", + "ctrl-shift-v": "agent::PasteRaw", }, }, { @@ -293,6 +294,7 @@ "shift-ctrl-r": "agent::OpenAgentDiff", "ctrl-shift-y": "agent::KeepAll", "ctrl-shift-n": "agent::RejectAll", + "ctrl-shift-v": "agent::PasteRaw", }, }, { @@ -304,6 +306,7 @@ "shift-ctrl-r": "agent::OpenAgentDiff", "ctrl-shift-y": "agent::KeepAll", "ctrl-shift-n": "agent::RejectAll", + "ctrl-shift-v": "agent::PasteRaw", }, }, { diff --git a/assets/keymaps/default-macos.json b/assets/keymaps/default-macos.json index fd2605a6ad99177c887d6f804ec2ac70724f16f8..7ff00c41d5d6108b2a0b9fa0de85c511fab1f6e0 100644 --- a/assets/keymaps/default-macos.json +++ b/assets/keymaps/default-macos.json @@ -267,6 +267,7 @@ "cmd-shift-g": "search::SelectPreviousMatch", "cmd-k l": "agent::OpenRulesLibrary", "alt-tab": "agent::CycleFavoriteModels", + "cmd-shift-v": "agent::PasteRaw", }, }, { @@ -335,6 +336,7 @@ "shift-ctrl-r": "agent::OpenAgentDiff", "cmd-shift-y": "agent::KeepAll", "cmd-shift-n": "agent::RejectAll", + "cmd-shift-v": "agent::PasteRaw", }, }, { @@ -347,6 +349,7 @@ "shift-ctrl-r": "agent::OpenAgentDiff", "cmd-shift-y": "agent::KeepAll", "cmd-shift-n": "agent::RejectAll", + "cmd-shift-v": "agent::PasteRaw", }, }, { diff --git a/assets/keymaps/default-windows.json b/assets/keymaps/default-windows.json index 4a700e2c9190a8ae23ed53edaa075703fa07b855..445933c950cbc9ef72eb2cca90ab8115471f1e6f 100644 --- a/assets/keymaps/default-windows.json +++ b/assets/keymaps/default-windows.json @@ -227,6 +227,7 @@ "ctrl-g": "search::SelectNextMatch", "ctrl-shift-g": "search::SelectPreviousMatch", "ctrl-k l": "agent::OpenRulesLibrary", + "ctrl-shift-v": "agent::PasteRaw", }, }, { @@ -296,6 +297,7 @@ "ctrl-shift-r": "agent::OpenAgentDiff", "ctrl-shift-y": "agent::KeepAll", "ctrl-shift-n": "agent::RejectAll", + "ctrl-shift-v": "agent::PasteRaw", }, }, { @@ -308,6 +310,7 @@ "ctrl-shift-r": "agent::OpenAgentDiff", "ctrl-shift-y": "agent::KeepAll", "ctrl-shift-n": "agent::RejectAll", + "ctrl-shift-v": "agent::PasteRaw", }, }, { diff --git a/crates/agent_ui/src/acp/message_editor.rs b/crates/agent_ui/src/acp/message_editor.rs index 308230a24c6d2ba7fb0c3995b886e9e924d8e1b7..6bed82accf876aaaba0668d366216c3a965ad8cb 100644 --- a/crates/agent_ui/src/acp/message_editor.rs +++ b/crates/agent_ui/src/acp/message_editor.rs @@ -34,7 +34,7 @@ use theme::ThemeSettings; use ui::prelude::*; use util::{ResultExt, debug_panic}; use workspace::{CollaboratorId, Workspace}; -use zed_actions::agent::Chat; +use zed_actions::agent::{Chat, PasteRaw}; pub struct MessageEditor { mention_set: Entity, @@ -543,6 +543,9 @@ impl MessageEditor { } fn paste(&mut self, _: &Paste, window: &mut Window, cx: &mut Context) { + let Some(workspace) = self.workspace.upgrade() else { + return; + }; let editor_clipboard_selections = cx .read_from_clipboard() .and_then(|item| item.entries().first().cloned()) @@ -553,133 +556,127 @@ impl MessageEditor { _ => None, }); - let has_file_context = editor_clipboard_selections - .as_ref() - .is_some_and(|selections| { - selections - .iter() - .any(|sel| sel.file_path.is_some() && sel.line_range.is_some()) - }); + // Insert creases for pasted clipboard selections that: + // 1. Contain exactly one selection + // 2. Have an associated file path + // 3. Span multiple lines (not single-line selections) + // 4. Belong to a file that exists in the current project + let should_insert_creases = util::maybe!({ + let selections = editor_clipboard_selections.as_ref()?; + if selections.len() > 1 { + return Some(false); + } + let selection = selections.first()?; + let file_path = selection.file_path.as_ref()?; + let line_range = selection.line_range.as_ref()?; - if has_file_context { - if let Some((workspace, selections)) = - self.workspace.upgrade().zip(editor_clipboard_selections) - { - let Some(first_selection) = selections.first() else { - return; - }; - if let Some(file_path) = &first_selection.file_path { - // In case someone pastes selections from another window - // with a different project, we don't want to insert the - // crease (containing the absolute path) since the agent - // cannot access files outside the project. - let is_in_project = workspace - .read(cx) - .project() - .read(cx) - .project_path_for_absolute_path(file_path, cx) - .is_some(); - if !is_in_project { - return; - } - } + if line_range.start() == line_range.end() { + return Some(false); + } - cx.stop_propagation(); - let insertion_target = self - .editor + Some( + workspace .read(cx) - .selections - .newest_anchor() - .start - .text_anchor; - - let project = workspace.read(cx).project().clone(); - for selection in selections { - if let (Some(file_path), Some(line_range)) = - (selection.file_path, selection.line_range) - { - let crease_text = - acp_thread::selection_name(Some(file_path.as_ref()), &line_range); + .project() + .read(cx) + .project_path_for_absolute_path(file_path, cx) + .is_some(), + ) + }) + .unwrap_or(false); - let mention_uri = MentionUri::Selection { - abs_path: Some(file_path.clone()), - line_range: line_range.clone(), - }; + if should_insert_creases && let Some(selections) = editor_clipboard_selections { + cx.stop_propagation(); + let insertion_target = self + .editor + .read(cx) + .selections + .newest_anchor() + .start + .text_anchor; + + let project = workspace.read(cx).project().clone(); + for selection in selections { + if let (Some(file_path), Some(line_range)) = + (selection.file_path, selection.line_range) + { + let crease_text = + acp_thread::selection_name(Some(file_path.as_ref()), &line_range); - let mention_text = mention_uri.as_link().to_string(); - let (excerpt_id, text_anchor, content_len) = - self.editor.update(cx, |editor, cx| { - let buffer = editor.buffer().read(cx); - let snapshot = buffer.snapshot(cx); - let (excerpt_id, _, buffer_snapshot) = - snapshot.as_singleton().unwrap(); - let text_anchor = insertion_target.bias_left(&buffer_snapshot); - - editor.insert(&mention_text, window, cx); - editor.insert(" ", window, cx); - - (*excerpt_id, text_anchor, mention_text.len()) - }); - - let Some((crease_id, tx)) = insert_crease_for_mention( - excerpt_id, - text_anchor, - content_len, - crease_text.into(), - mention_uri.icon_path(cx), - None, - self.editor.clone(), - window, - cx, - ) else { - continue; - }; - drop(tx); - - let mention_task = cx - .spawn({ - let project = project.clone(); - async move |_, cx| { - let project_path = project - .update(cx, |project, cx| { - project.project_path_for_absolute_path(&file_path, cx) - }) - .map_err(|e| e.to_string())? - .ok_or_else(|| "project path not found".to_string())?; - - let buffer = project - .update(cx, |project, cx| { - project.open_buffer(project_path, cx) - }) - .map_err(|e| e.to_string())? - .await - .map_err(|e| e.to_string())?; - - buffer - .update(cx, |buffer, cx| { - let start = Point::new(*line_range.start(), 0) - .min(buffer.max_point()); - let end = Point::new(*line_range.end() + 1, 0) - .min(buffer.max_point()); - let content = - buffer.text_for_range(start..end).collect(); - Mention::Text { - content, - tracked_buffers: vec![cx.entity()], - } - }) - .map_err(|e| e.to_string()) - } - }) - .shared(); + let mention_uri = MentionUri::Selection { + abs_path: Some(file_path.clone()), + line_range: line_range.clone(), + }; + + let mention_text = mention_uri.as_link().to_string(); + let (excerpt_id, text_anchor, content_len) = + self.editor.update(cx, |editor, cx| { + let buffer = editor.buffer().read(cx); + let snapshot = buffer.snapshot(cx); + let (excerpt_id, _, buffer_snapshot) = snapshot.as_singleton().unwrap(); + let text_anchor = insertion_target.bias_left(&buffer_snapshot); + + editor.insert(&mention_text, window, cx); + editor.insert(" ", window, cx); - self.mention_set.update(cx, |mention_set, _cx| { - mention_set.insert_mention(crease_id, mention_uri.clone(), mention_task) + (*excerpt_id, text_anchor, mention_text.len()) }); - } + + let Some((crease_id, tx)) = insert_crease_for_mention( + excerpt_id, + text_anchor, + content_len, + crease_text.into(), + mention_uri.icon_path(cx), + None, + self.editor.clone(), + window, + cx, + ) else { + continue; + }; + drop(tx); + + let mention_task = cx + .spawn({ + let project = project.clone(); + async move |_, cx| { + let project_path = project + .update(cx, |project, cx| { + project.project_path_for_absolute_path(&file_path, cx) + }) + .map_err(|e| e.to_string())? + .ok_or_else(|| "project path not found".to_string())?; + + let buffer = project + .update(cx, |project, cx| project.open_buffer(project_path, cx)) + .map_err(|e| e.to_string())? + .await + .map_err(|e| e.to_string())?; + + buffer + .update(cx, |buffer, cx| { + let start = Point::new(*line_range.start(), 0) + .min(buffer.max_point()); + let end = Point::new(*line_range.end() + 1, 0) + .min(buffer.max_point()); + let content = buffer.text_for_range(start..end).collect(); + Mention::Text { + content, + tracked_buffers: vec![cx.entity()], + } + }) + .map_err(|e| e.to_string()) + } + }) + .shared(); + + self.mention_set.update(cx, |mention_set, _cx| { + mention_set.insert_mention(crease_id, mention_uri.clone(), mention_task) + }); } - return; } + return; } if self.prompt_capabilities.borrow().image @@ -690,6 +687,13 @@ impl MessageEditor { } } + fn paste_raw(&mut self, _: &PasteRaw, window: &mut Window, cx: &mut Context) { + let editor = self.editor.clone(); + window.defer(cx, move |window, cx| { + editor.update(cx, |editor, cx| editor.paste(&Paste, window, cx)); + }); + } + pub fn insert_dragged_files( &mut self, paths: Vec, @@ -967,6 +971,7 @@ impl Render for MessageEditor { .on_action(cx.listener(Self::chat)) .on_action(cx.listener(Self::chat_with_follow)) .on_action(cx.listener(Self::cancel)) + .on_action(cx.listener(Self::paste_raw)) .capture_action(cx.listener(Self::paste)) .flex_1() .child({ diff --git a/crates/agent_ui/src/text_thread_editor.rs b/crates/agent_ui/src/text_thread_editor.rs index b26ee44ce53503f3f9b9e77b27a22c0bc39d6473..16d12cf261d3bbb8eb0b879394fedc1cc96e046c 100644 --- a/crates/agent_ui/src/text_thread_editor.rs +++ b/crates/agent_ui/src/text_thread_editor.rs @@ -71,7 +71,7 @@ use workspace::{ pane, searchable::{SearchEvent, SearchableItem}, }; -use zed_actions::agent::{AddSelectionToThread, ToggleModelSelector}; +use zed_actions::agent::{AddSelectionToThread, PasteRaw, ToggleModelSelector}; use crate::CycleFavoriteModels; @@ -1698,6 +1698,9 @@ impl TextThreadEditor { window: &mut Window, cx: &mut Context, ) { + let Some(workspace) = self.workspace.upgrade() else { + return; + }; let editor_clipboard_selections = cx .read_from_clipboard() .and_then(|item| item.entries().first().cloned()) @@ -1708,84 +1711,101 @@ impl TextThreadEditor { _ => None, }); - let has_file_context = editor_clipboard_selections - .as_ref() - .is_some_and(|selections| { - selections - .iter() - .any(|sel| sel.file_path.is_some() && sel.line_range.is_some()) - }); - - if has_file_context { - if let Some(clipboard_item) = cx.read_from_clipboard() { - if let Some(ClipboardEntry::String(clipboard_text)) = - clipboard_item.entries().first() - { - if let Some(selections) = editor_clipboard_selections { - cx.stop_propagation(); - - let text = clipboard_text.text(); - self.editor.update(cx, |editor, cx| { - let mut current_offset = 0; - let weak_editor = cx.entity().downgrade(); - - for selection in selections { - if let (Some(file_path), Some(line_range)) = - (selection.file_path, selection.line_range) - { - let selected_text = - &text[current_offset..current_offset + selection.len]; - let fence = assistant_slash_commands::codeblock_fence_for_path( - file_path.to_str(), - Some(line_range.clone()), - ); - let formatted_text = format!("{fence}{selected_text}\n```"); - - let insert_point = editor - .selections - .newest::(&editor.display_snapshot(cx)) - .head(); - let start_row = MultiBufferRow(insert_point.row); - - editor.insert(&formatted_text, window, cx); + // Insert creases for pasted clipboard selections that: + // 1. Contain exactly one selection + // 2. Have an associated file path + // 3. Span multiple lines (not single-line selections) + // 4. Belong to a file that exists in the current project + let should_insert_creases = util::maybe!({ + let selections = editor_clipboard_selections.as_ref()?; + if selections.len() > 1 { + return Some(false); + } + let selection = selections.first()?; + let file_path = selection.file_path.as_ref()?; + let line_range = selection.line_range.as_ref()?; - let snapshot = editor.buffer().read(cx).snapshot(cx); - let anchor_before = snapshot.anchor_after(insert_point); - let anchor_after = editor - .selections - .newest_anchor() - .head() - .bias_left(&snapshot); + if line_range.start() == line_range.end() { + return Some(false); + } - editor.insert("\n", window, cx); + Some( + workspace + .read(cx) + .project() + .read(cx) + .project_path_for_absolute_path(file_path, cx) + .is_some(), + ) + }) + .unwrap_or(false); - let crease_text = acp_thread::selection_name( - Some(file_path.as_ref()), - &line_range, - ); + if should_insert_creases && let Some(clipboard_item) = cx.read_from_clipboard() { + if let Some(ClipboardEntry::String(clipboard_text)) = clipboard_item.entries().first() { + if let Some(selections) = editor_clipboard_selections { + cx.stop_propagation(); - let fold_placeholder = quote_selection_fold_placeholder( - crease_text, - weak_editor.clone(), - ); - let crease = Crease::inline( - anchor_before..anchor_after, - fold_placeholder, - render_quote_selection_output_toggle, - |_, _, _, _| Empty.into_any(), - ); - editor.insert_creases(vec![crease], cx); - editor.fold_at(start_row, window, cx); + let text = clipboard_text.text(); + self.editor.update(cx, |editor, cx| { + let mut current_offset = 0; + let weak_editor = cx.entity().downgrade(); - current_offset += selection.len; - if !selection.is_entire_line && current_offset < text.len() { - current_offset += 1; - } + for selection in selections { + if let (Some(file_path), Some(line_range)) = + (selection.file_path, selection.line_range) + { + let selected_text = + &text[current_offset..current_offset + selection.len]; + let fence = assistant_slash_commands::codeblock_fence_for_path( + file_path.to_str(), + Some(line_range.clone()), + ); + let formatted_text = format!("{fence}{selected_text}\n```"); + + let insert_point = editor + .selections + .newest::(&editor.display_snapshot(cx)) + .head(); + let start_row = MultiBufferRow(insert_point.row); + + editor.insert(&formatted_text, window, cx); + + let snapshot = editor.buffer().read(cx).snapshot(cx); + let anchor_before = snapshot.anchor_after(insert_point); + let anchor_after = editor + .selections + .newest_anchor() + .head() + .bias_left(&snapshot); + + editor.insert("\n", window, cx); + + let crease_text = acp_thread::selection_name( + Some(file_path.as_ref()), + &line_range, + ); + + let fold_placeholder = quote_selection_fold_placeholder( + crease_text, + weak_editor.clone(), + ); + let crease = Crease::inline( + anchor_before..anchor_after, + fold_placeholder, + render_quote_selection_output_toggle, + |_, _, _, _| Empty.into_any(), + ); + editor.insert_creases(vec![crease], cx); + editor.fold_at(start_row, window, cx); + + current_offset += selection.len; + if !selection.is_entire_line && current_offset < text.len() { + current_offset += 1; } } - }); - return; - } + } + }); + return; } } } @@ -1944,6 +1964,12 @@ impl TextThreadEditor { } } + fn paste_raw(&mut self, _: &PasteRaw, window: &mut Window, cx: &mut Context) { + self.editor.update(cx, |editor, cx| { + editor.paste(&editor::actions::Paste, window, cx); + }); + } + fn update_image_blocks(&mut self, cx: &mut Context) { self.editor.update(cx, |editor, cx| { let buffer = editor.buffer().read(cx).snapshot(cx); @@ -2627,6 +2653,7 @@ impl Render for TextThreadEditor { .capture_action(cx.listener(TextThreadEditor::copy)) .capture_action(cx.listener(TextThreadEditor::cut)) .capture_action(cx.listener(TextThreadEditor::paste)) + .on_action(cx.listener(TextThreadEditor::paste_raw)) .capture_action(cx.listener(TextThreadEditor::cycle_message_role)) .capture_action(cx.listener(TextThreadEditor::confirm_command)) .on_action(cx.listener(TextThreadEditor::assist)) diff --git a/crates/zed_actions/src/lib.rs b/crates/zed_actions/src/lib.rs index 458ca10ecdf8915eef3ee69c6334b1a14cc0c219..85b6d4d37d06d5f1c229fc852dd5bad117bbd9d7 100644 --- a/crates/zed_actions/src/lib.rs +++ b/crates/zed_actions/src/lib.rs @@ -354,6 +354,8 @@ pub mod agent { ResetAgentZoom, /// Toggles the utility/agent pane open/closed state. ToggleAgentPane, + /// Pastes clipboard content without any formatting. + PasteRaw, ] ); } From bd2b0de231e2f76c963a08f3f98f5932ad1b3f13 Mon Sep 17 00:00:00 2001 From: Alvaro Parker <64918109+AlvaroParker@users.noreply.github.com> Date: Thu, 18 Dec 2025 12:45:06 -0300 Subject: [PATCH 507/621] gpui: Add modal dialog window kind (#40291) Closes #ISSUE A [modal dialog](https://en.wikipedia.org/wiki/Modal_window) window is a window that demands the user's immediate attention and blocks interaction with other parts of the application until it's closed. - On Windows this is done by disabling the parent window when the dialog window is created and re-enabling the parent window when closed. - On Wayland this is done using the [`XdgDialog`](https://wayland.app/protocols/xdg-dialog-v1) protocol, which hints to the compositor that the dialog should be modal. While compositors like GNOME and KDE block parent interaction automatically, the XDG specification does not guarantee this behavior, compositors may deliver events to the parent window unfiltered. Since the specification explicitly requires clients to implement event filtering logic themselves, this PR implements client-side blocking in GPUI to ensure consistent modal behavior across all Wayland compositors, including those like Hyprland that don't block parent interaction. - On X11 this is done by enabling the application window property [`_NET_WM_STATE_MODAL`](https://specifications.freedesktop.org/wm/latest/ar01s05.html#id-1.6.8) state. I'm unable to implement this on MacOS as I lack the experience and the hardware to test it. If anyone is interested on implementing this let me know. |Window|Linux (wayland)| Linux (x11) |MacOS| |-|-|-|-| ||| N/A | | TODO: - [x] Block parent interaction client-side on X11 Release Notes: - Added modal dialog window kind on GPUI --------- Co-authored-by: Jason Lee Co-authored-by: Anthony Eid Co-authored-by: Anthony Eid --- Cargo.lock | 24 ++--- crates/gpui/Cargo.toml | 8 +- crates/gpui/examples/window.rs | 65 +++++++++++++- crates/gpui/src/platform.rs | 4 + .../gpui/src/platform/linux/wayland/client.rs | 79 ++++++++++++++--- .../gpui/src/platform/linux/wayland/window.rs | 83 +++++++++++++++-- crates/gpui/src/platform/linux/x11/client.rs | 53 +++++++++-- crates/gpui/src/platform/linux/x11/window.rs | 88 +++++++++++++++++-- crates/gpui/src/platform/mac/window.rs | 51 +++++++++-- crates/gpui/src/platform/windows/events.rs | 8 ++ crates/gpui/src/platform/windows/window.rs | 28 +++++- 11 files changed, 425 insertions(+), 66 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7364a68b2a68fe44a42d24443dd723aa3c87e135..1ec640d49c2135d35442f0bf23047be7991427eb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -793,7 +793,7 @@ dependencies = [ "url", "wayland-backend", "wayland-client", - "wayland-protocols 0.32.9", + "wayland-protocols", "zbus", ] @@ -7370,7 +7370,7 @@ dependencies = [ "wayland-backend", "wayland-client", "wayland-cursor", - "wayland-protocols 0.31.2", + "wayland-protocols", "wayland-protocols-plasma", "wayland-protocols-wlr", "windows 0.61.3", @@ -18927,18 +18927,6 @@ dependencies = [ "xcursor", ] -[[package]] -name = "wayland-protocols" -version = "0.31.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f81f365b8b4a97f422ac0e8737c438024b5951734506b0e1d775c73030561f4" -dependencies = [ - "bitflags 2.9.4", - "wayland-backend", - "wayland-client", - "wayland-scanner", -] - [[package]] name = "wayland-protocols" version = "0.32.9" @@ -18953,14 +18941,14 @@ dependencies = [ [[package]] name = "wayland-protocols-plasma" -version = "0.2.0" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23803551115ff9ea9bce586860c5c5a971e360825a0309264102a9495a5ff479" +checksum = "a07a14257c077ab3279987c4f8bb987851bf57081b93710381daea94f2c2c032" dependencies = [ "bitflags 2.9.4", "wayland-backend", "wayland-client", - "wayland-protocols 0.31.2", + "wayland-protocols", "wayland-scanner", ] @@ -18973,7 +18961,7 @@ dependencies = [ "bitflags 2.9.4", "wayland-backend", "wayland-client", - "wayland-protocols 0.32.9", + "wayland-protocols", "wayland-scanner", ] diff --git a/crates/gpui/Cargo.toml b/crates/gpui/Cargo.toml index da7e660a0171f38b8dd61de1c9323773ded2589b..40376f476b6d80f6b5170840f295a71acdfebb7d 100644 --- a/crates/gpui/Cargo.toml +++ b/crates/gpui/Cargo.toml @@ -198,14 +198,14 @@ wayland-backend = { version = "0.3.3", features = [ "client_system", "dlopen", ], optional = true } -wayland-client = { version = "0.31.2", optional = true } -wayland-cursor = { version = "0.31.1", optional = true } -wayland-protocols = { version = "0.31.2", features = [ +wayland-client = { version = "0.31.11", optional = true } +wayland-cursor = { version = "0.31.11", optional = true } +wayland-protocols = { version = "0.32.9", features = [ "client", "staging", "unstable", ], optional = true } -wayland-protocols-plasma = { version = "0.2.0", features = [ +wayland-protocols-plasma = { version = "0.3.9", features = [ "client", ], optional = true } wayland-protocols-wlr = { version = "0.3.9", features = [ diff --git a/crates/gpui/examples/window.rs b/crates/gpui/examples/window.rs index 06003c4663ee5711283a85684c25b9f5d8c5b743..3f41f3d55f240e688965ac8248ac3d5b4ef40401 100644 --- a/crates/gpui/examples/window.rs +++ b/crates/gpui/examples/window.rs @@ -5,6 +5,7 @@ use gpui::{ struct SubWindow { custom_titlebar: bool, + is_dialog: bool, } fn button(text: &str, on_click: impl Fn(&mut Window, &mut App) + 'static) -> impl IntoElement { @@ -23,7 +24,10 @@ fn button(text: &str, on_click: impl Fn(&mut Window, &mut App) + 'static) -> imp } impl Render for SubWindow { - fn render(&mut self, _window: &mut Window, _: &mut Context) -> impl IntoElement { + fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { + let window_bounds = + WindowBounds::Windowed(Bounds::centered(None, size(px(250.0), px(200.0)), cx)); + div() .flex() .flex_col() @@ -52,8 +56,28 @@ impl Render for SubWindow { .child( div() .p_8() + .flex() + .flex_col() .gap_2() .child("SubWindow") + .when(self.is_dialog, |div| { + div.child(button("Open Nested Dialog", move |_, cx| { + cx.open_window( + WindowOptions { + window_bounds: Some(window_bounds), + kind: WindowKind::Dialog, + ..Default::default() + }, + |_, cx| { + cx.new(|_| SubWindow { + custom_titlebar: false, + is_dialog: true, + }) + }, + ) + .unwrap(); + })) + }) .child(button("Close", |window, _| { window.remove_window(); })), @@ -86,6 +110,7 @@ impl Render for WindowDemo { |_, cx| { cx.new(|_| SubWindow { custom_titlebar: false, + is_dialog: false, }) }, ) @@ -101,6 +126,39 @@ impl Render for WindowDemo { |_, cx| { cx.new(|_| SubWindow { custom_titlebar: false, + is_dialog: false, + }) + }, + ) + .unwrap(); + })) + .child(button("Floating", move |_, cx| { + cx.open_window( + WindowOptions { + window_bounds: Some(window_bounds), + kind: WindowKind::Floating, + ..Default::default() + }, + |_, cx| { + cx.new(|_| SubWindow { + custom_titlebar: false, + is_dialog: false, + }) + }, + ) + .unwrap(); + })) + .child(button("Dialog", move |_, cx| { + cx.open_window( + WindowOptions { + window_bounds: Some(window_bounds), + kind: WindowKind::Dialog, + ..Default::default() + }, + |_, cx| { + cx.new(|_| SubWindow { + custom_titlebar: false, + is_dialog: true, }) }, ) @@ -116,6 +174,7 @@ impl Render for WindowDemo { |_, cx| { cx.new(|_| SubWindow { custom_titlebar: true, + is_dialog: false, }) }, ) @@ -131,6 +190,7 @@ impl Render for WindowDemo { |_, cx| { cx.new(|_| SubWindow { custom_titlebar: false, + is_dialog: false, }) }, ) @@ -147,6 +207,7 @@ impl Render for WindowDemo { |_, cx| { cx.new(|_| SubWindow { custom_titlebar: false, + is_dialog: false, }) }, ) @@ -162,6 +223,7 @@ impl Render for WindowDemo { |_, cx| { cx.new(|_| SubWindow { custom_titlebar: false, + is_dialog: false, }) }, ) @@ -177,6 +239,7 @@ impl Render for WindowDemo { |_, cx| { cx.new(|_| SubWindow { custom_titlebar: false, + is_dialog: false, }) }, ) diff --git a/crates/gpui/src/platform.rs b/crates/gpui/src/platform.rs index f120e075fea7f9336e2f6e10c51611d8ba03564d..22f4c46921132a7b8badfb7afd4fd38058c638b4 100644 --- a/crates/gpui/src/platform.rs +++ b/crates/gpui/src/platform.rs @@ -1348,6 +1348,10 @@ pub enum WindowKind { /// docks, notifications or wallpapers. #[cfg(all(target_os = "linux", feature = "wayland"))] LayerShell(layer_shell::LayerShellOptions), + + /// A window that appears on top of its parent window and blocks interaction with it + /// until the modal window is closed + Dialog, } /// The appearance of the window, as defined by the operating system. diff --git a/crates/gpui/src/platform/linux/wayland/client.rs b/crates/gpui/src/platform/linux/wayland/client.rs index 0e7bf8fbf8880baf5876027e6e764d7411932577..b6bfbec0679f9413fceef2bb37e7bd304371707e 100644 --- a/crates/gpui/src/platform/linux/wayland/client.rs +++ b/crates/gpui/src/platform/linux/wayland/client.rs @@ -36,12 +36,6 @@ use wayland_client::{ wl_shm_pool, wl_surface, }, }; -use wayland_protocols::wp::cursor_shape::v1::client::{ - wp_cursor_shape_device_v1, wp_cursor_shape_manager_v1, -}; -use wayland_protocols::wp::fractional_scale::v1::client::{ - wp_fractional_scale_manager_v1, wp_fractional_scale_v1, -}; use wayland_protocols::wp::primary_selection::zv1::client::zwp_primary_selection_offer_v1::{ self, ZwpPrimarySelectionOfferV1, }; @@ -61,6 +55,14 @@ use wayland_protocols::xdg::decoration::zv1::client::{ zxdg_decoration_manager_v1, zxdg_toplevel_decoration_v1, }; use wayland_protocols::xdg::shell::client::{xdg_surface, xdg_toplevel, xdg_wm_base}; +use wayland_protocols::{ + wp::cursor_shape::v1::client::{wp_cursor_shape_device_v1, wp_cursor_shape_manager_v1}, + xdg::dialog::v1::client::xdg_wm_dialog_v1::{self, XdgWmDialogV1}, +}; +use wayland_protocols::{ + wp::fractional_scale::v1::client::{wp_fractional_scale_manager_v1, wp_fractional_scale_v1}, + xdg::dialog::v1::client::xdg_dialog_v1::XdgDialogV1, +}; use wayland_protocols_plasma::blur::client::{org_kde_kwin_blur, org_kde_kwin_blur_manager}; use wayland_protocols_wlr::layer_shell::v1::client::{zwlr_layer_shell_v1, zwlr_layer_surface_v1}; use xkbcommon::xkb::ffi::XKB_KEYMAP_FORMAT_TEXT_V1; @@ -122,6 +124,7 @@ pub struct Globals { pub layer_shell: Option, pub blur_manager: Option, pub text_input_manager: Option, + pub dialog: Option, pub executor: ForegroundExecutor, } @@ -132,6 +135,7 @@ impl Globals { qh: QueueHandle, seat: wl_seat::WlSeat, ) -> Self { + let dialog_v = XdgWmDialogV1::interface().version; Globals { activation: globals.bind(&qh, 1..=1, ()).ok(), compositor: globals @@ -160,6 +164,7 @@ impl Globals { layer_shell: globals.bind(&qh, 1..=5, ()).ok(), blur_manager: globals.bind(&qh, 1..=1, ()).ok(), text_input_manager: globals.bind(&qh, 1..=1, ()).ok(), + dialog: globals.bind(&qh, dialog_v..=dialog_v, ()).ok(), executor, qh, } @@ -729,10 +734,7 @@ impl LinuxClient for WaylandClient { ) -> anyhow::Result> { let mut state = self.0.borrow_mut(); - let parent = state - .keyboard_focused_window - .as_ref() - .and_then(|w| w.toplevel()); + let parent = state.keyboard_focused_window.clone(); let (window, surface_id) = WaylandWindow::new( handle, @@ -751,7 +753,12 @@ impl LinuxClient for WaylandClient { fn set_cursor_style(&self, style: CursorStyle) { let mut state = self.0.borrow_mut(); - let need_update = state.cursor_style != Some(style); + let need_update = state.cursor_style != Some(style) + && (state.mouse_focused_window.is_none() + || state + .mouse_focused_window + .as_ref() + .is_some_and(|w| !w.is_blocked())); if need_update { let serial = state.serial_tracker.get(SerialKind::MouseEnter); @@ -1011,7 +1018,7 @@ impl Dispatch for WaylandClientStatePtr { } } -fn get_window( +pub(crate) fn get_window( mut state: &mut RefMut, surface_id: &ObjectId, ) -> Option { @@ -1654,6 +1661,30 @@ impl Dispatch for WaylandClientStatePtr { state.mouse_location = Some(point(px(surface_x as f32), px(surface_y as f32))); if let Some(window) = state.mouse_focused_window.clone() { + if window.is_blocked() { + let default_style = CursorStyle::Arrow; + if state.cursor_style != Some(default_style) { + let serial = state.serial_tracker.get(SerialKind::MouseEnter); + state.cursor_style = Some(default_style); + + if let Some(cursor_shape_device) = &state.cursor_shape_device { + cursor_shape_device.set_shape(serial, default_style.to_shape()); + } else { + // cursor-shape-v1 isn't supported, set the cursor using a surface. + let wl_pointer = state + .wl_pointer + .clone() + .expect("window is focused by pointer"); + let scale = window.primary_output_scale(); + state.cursor.set_icon( + &wl_pointer, + serial, + default_style.to_icon_names(), + scale, + ); + } + } + } if state .keyboard_focused_window .as_ref() @@ -2225,3 +2256,27 @@ impl Dispatch } } } + +impl Dispatch for WaylandClientStatePtr { + fn event( + _: &mut Self, + _: &XdgWmDialogV1, + _: ::Event, + _: &(), + _: &Connection, + _: &QueueHandle, + ) { + } +} + +impl Dispatch for WaylandClientStatePtr { + fn event( + _state: &mut Self, + _proxy: &XdgDialogV1, + _event: ::Event, + _data: &(), + _conn: &Connection, + _qhandle: &QueueHandle, + ) { + } +} diff --git a/crates/gpui/src/platform/linux/wayland/window.rs b/crates/gpui/src/platform/linux/wayland/window.rs index 8cc47c3c139708c3cc278c6146411a4383cc0004..6b4dad3b3917d025a80594b5ece63c26bbadde69 100644 --- a/crates/gpui/src/platform/linux/wayland/window.rs +++ b/crates/gpui/src/platform/linux/wayland/window.rs @@ -7,7 +7,7 @@ use std::{ }; use blade_graphics as gpu; -use collections::HashMap; +use collections::{FxHashSet, HashMap}; use futures::channel::oneshot::Receiver; use raw_window_handle as rwh; @@ -20,7 +20,7 @@ use wayland_protocols::xdg::shell::client::xdg_surface; use wayland_protocols::xdg::shell::client::xdg_toplevel::{self}; use wayland_protocols::{ wp::fractional_scale::v1::client::wp_fractional_scale_v1, - xdg::shell::client::xdg_toplevel::XdgToplevel, + xdg::dialog::v1::client::xdg_dialog_v1::XdgDialogV1, }; use wayland_protocols_plasma::blur::client::org_kde_kwin_blur; use wayland_protocols_wlr::layer_shell::v1::client::zwlr_layer_surface_v1; @@ -29,7 +29,7 @@ use crate::{ AnyWindowHandle, Bounds, Decorations, Globals, GpuSpecs, Modifiers, Output, Pixels, PlatformDisplay, PlatformInput, Point, PromptButton, PromptLevel, RequestFrameOptions, ResizeEdge, Size, Tiling, WaylandClientStatePtr, WindowAppearance, WindowBackgroundAppearance, - WindowBounds, WindowControlArea, WindowControls, WindowDecorations, WindowParams, + WindowBounds, WindowControlArea, WindowControls, WindowDecorations, WindowParams, get_window, layer_shell::LayerShellNotSupportedError, px, size, }; use crate::{ @@ -87,6 +87,8 @@ struct InProgressConfigure { pub struct WaylandWindowState { surface_state: WaylandSurfaceState, acknowledged_first_configure: bool, + parent: Option, + children: FxHashSet, pub surface: wl_surface::WlSurface, app_id: Option, appearance: WindowAppearance, @@ -126,7 +128,7 @@ impl WaylandSurfaceState { surface: &wl_surface::WlSurface, globals: &Globals, params: &WindowParams, - parent: Option, + parent: Option, ) -> anyhow::Result { // For layer_shell windows, create a layer surface instead of an xdg surface if let WindowKind::LayerShell(options) = ¶ms.kind { @@ -178,10 +180,28 @@ impl WaylandSurfaceState { .get_xdg_surface(&surface, &globals.qh, surface.id()); let toplevel = xdg_surface.get_toplevel(&globals.qh, surface.id()); - if params.kind == WindowKind::Floating { - toplevel.set_parent(parent.as_ref()); + let xdg_parent = parent.as_ref().and_then(|w| w.toplevel()); + + if params.kind == WindowKind::Floating || params.kind == WindowKind::Dialog { + toplevel.set_parent(xdg_parent.as_ref()); } + let dialog = if params.kind == WindowKind::Dialog { + let dialog = globals.dialog.as_ref().map(|dialog| { + let xdg_dialog = dialog.get_xdg_dialog(&toplevel, &globals.qh, ()); + xdg_dialog.set_modal(); + xdg_dialog + }); + + if let Some(parent) = parent.as_ref() { + parent.add_child(surface.id()); + } + + dialog + } else { + None + }; + if let Some(size) = params.window_min_size { toplevel.set_min_size(size.width.0 as i32, size.height.0 as i32); } @@ -198,6 +218,7 @@ impl WaylandSurfaceState { xdg_surface, toplevel, decoration, + dialog, })) } } @@ -206,6 +227,7 @@ pub struct WaylandXdgSurfaceState { xdg_surface: xdg_surface::XdgSurface, toplevel: xdg_toplevel::XdgToplevel, decoration: Option, + dialog: Option, } pub struct WaylandLayerSurfaceState { @@ -258,7 +280,13 @@ impl WaylandSurfaceState { xdg_surface, toplevel, decoration: _decoration, + dialog, }) => { + // drop the dialog before toplevel so compositor can explicitly unapply it's effects + if let Some(dialog) = dialog { + dialog.destroy(); + } + // The role object (toplevel) must always be destroyed before the xdg_surface. // See https://wayland.app/protocols/xdg-shell#xdg_surface:request:destroy toplevel.destroy(); @@ -288,6 +316,7 @@ impl WaylandWindowState { globals: Globals, gpu_context: &BladeContext, options: WindowParams, + parent: Option, ) -> anyhow::Result { let renderer = { let raw_window = RawWindow { @@ -319,6 +348,8 @@ impl WaylandWindowState { Ok(Self { surface_state, acknowledged_first_configure: false, + parent, + children: FxHashSet::default(), surface, app_id: None, blur: None, @@ -391,6 +422,10 @@ impl Drop for WaylandWindow { fn drop(&mut self) { let mut state = self.0.state.borrow_mut(); let surface_id = state.surface.id(); + if let Some(parent) = state.parent.as_ref() { + parent.state.borrow_mut().children.remove(&surface_id); + } + let client = state.client.clone(); state.renderer.destroy(); @@ -448,10 +483,10 @@ impl WaylandWindow { client: WaylandClientStatePtr, params: WindowParams, appearance: WindowAppearance, - parent: Option, + parent: Option, ) -> anyhow::Result<(Self, ObjectId)> { let surface = globals.compositor.create_surface(&globals.qh, ()); - let surface_state = WaylandSurfaceState::new(&surface, &globals, ¶ms, parent)?; + let surface_state = WaylandSurfaceState::new(&surface, &globals, ¶ms, parent.clone())?; if let Some(fractional_scale_manager) = globals.fractional_scale_manager.as_ref() { fractional_scale_manager.get_fractional_scale(&surface, &globals.qh, surface.id()); @@ -473,6 +508,7 @@ impl WaylandWindow { globals, gpu_context, params, + parent, )?)), callbacks: Rc::new(RefCell::new(Callbacks::default())), }); @@ -501,6 +537,16 @@ impl WaylandWindowStatePtr { Rc::ptr_eq(&self.state, &other.state) } + pub fn add_child(&self, child: ObjectId) { + let mut state = self.state.borrow_mut(); + state.children.insert(child); + } + + pub fn is_blocked(&self) -> bool { + let state = self.state.borrow(); + !state.children.is_empty() + } + pub fn frame(&self) { let mut state = self.state.borrow_mut(); state.surface.frame(&state.globals.qh, state.surface.id()); @@ -818,6 +864,9 @@ impl WaylandWindowStatePtr { } pub fn handle_ime(&self, ime: ImeInput) { + if self.is_blocked() { + return; + } let mut state = self.state.borrow_mut(); if let Some(mut input_handler) = state.input_handler.take() { drop(state); @@ -894,6 +943,21 @@ impl WaylandWindowStatePtr { } pub fn close(&self) { + let state = self.state.borrow(); + let client = state.client.get_client(); + #[allow(clippy::mutable_key_type)] + let children = state.children.clone(); + drop(state); + + for child in children { + let mut client_state = client.borrow_mut(); + let window = get_window(&mut client_state, &child); + drop(client_state); + + if let Some(child) = window { + child.close(); + } + } let mut callbacks = self.callbacks.borrow_mut(); if let Some(fun) = callbacks.close.take() { fun() @@ -901,6 +965,9 @@ impl WaylandWindowStatePtr { } pub fn handle_input(&self, input: PlatformInput) { + if self.is_blocked() { + return; + } if let Some(ref mut fun) = self.callbacks.borrow_mut().input && !fun(input.clone()).propagate { diff --git a/crates/gpui/src/platform/linux/x11/client.rs b/crates/gpui/src/platform/linux/x11/client.rs index 5e9089b09809a7ec1b8b257427b0a670adc0f123..7feec41d433158325592d566f83a6063f7a7196e 100644 --- a/crates/gpui/src/platform/linux/x11/client.rs +++ b/crates/gpui/src/platform/linux/x11/client.rs @@ -222,7 +222,7 @@ pub struct X11ClientState { pub struct X11ClientStatePtr(pub Weak>); impl X11ClientStatePtr { - fn get_client(&self) -> Option { + pub fn get_client(&self) -> Option { self.0.upgrade().map(X11Client) } @@ -752,7 +752,7 @@ impl X11Client { } } - fn get_window(&self, win: xproto::Window) -> Option { + pub(crate) fn get_window(&self, win: xproto::Window) -> Option { let state = self.0.borrow(); state .windows @@ -789,12 +789,12 @@ impl X11Client { let [atom, arg1, arg2, arg3, arg4] = event.data.as_data32(); let mut state = self.0.borrow_mut(); - if atom == state.atoms.WM_DELETE_WINDOW { + if atom == state.atoms.WM_DELETE_WINDOW && window.should_close() { // window "x" button clicked by user - if window.should_close() { - // Rest of the close logic is handled in drop_window() - window.close(); - } + // Rest of the close logic is handled in drop_window() + drop(state); + window.close(); + state = self.0.borrow_mut(); } else if atom == state.atoms._NET_WM_SYNC_REQUEST { window.state.borrow_mut().last_sync_counter = Some(x11rb::protocol::sync::Int64 { @@ -1216,6 +1216,33 @@ impl X11Client { Event::XinputMotion(event) => { let window = self.get_window(event.event)?; let mut state = self.0.borrow_mut(); + if window.is_blocked() { + // We want to set the cursor to the default arrow + // when the window is blocked + let style = CursorStyle::Arrow; + + let current_style = state + .cursor_styles + .get(&window.x_window) + .unwrap_or(&CursorStyle::Arrow); + if *current_style != style + && let Some(cursor) = state.get_cursor_icon(style) + { + state.cursor_styles.insert(window.x_window, style); + check_reply( + || "Failed to set cursor style", + state.xcb_connection.change_window_attributes( + window.x_window, + &ChangeWindowAttributesAux { + cursor: Some(cursor), + ..Default::default() + }, + ), + ) + .log_err(); + state.xcb_connection.flush().log_err(); + }; + } let pressed_button = pressed_button_from_mask(event.button_mask[0]); let position = point( px(event.event_x as f32 / u16::MAX as f32 / state.scale_factor), @@ -1489,7 +1516,7 @@ impl LinuxClient for X11Client { let parent_window = state .keyboard_focused_window .and_then(|focused_window| state.windows.get(&focused_window)) - .map(|window| window.window.x_window); + .map(|w| w.window.clone()); let x_window = state .xcb_connection .generate_id() @@ -1544,7 +1571,15 @@ impl LinuxClient for X11Client { .cursor_styles .get(&focused_window) .unwrap_or(&CursorStyle::Arrow); - if *current_style == style { + + let window = state + .mouse_focused_window + .and_then(|w| state.windows.get(&w)); + + let should_change = *current_style != style + && (window.is_none() || window.is_some_and(|w| !w.is_blocked())); + + if !should_change { return; } diff --git a/crates/gpui/src/platform/linux/x11/window.rs b/crates/gpui/src/platform/linux/x11/window.rs index fe197a670177689ce776b6b55d439483c43921e0..1986ff6cce6b1930bdc3527eced5f2d5b8f45117 100644 --- a/crates/gpui/src/platform/linux/x11/window.rs +++ b/crates/gpui/src/platform/linux/x11/window.rs @@ -11,6 +11,7 @@ use crate::{ }; use blade_graphics as gpu; +use collections::FxHashSet; use raw_window_handle as rwh; use util::{ResultExt, maybe}; use x11rb::{ @@ -74,6 +75,7 @@ x11rb::atom_manager! { _NET_WM_WINDOW_TYPE, _NET_WM_WINDOW_TYPE_NOTIFICATION, _NET_WM_WINDOW_TYPE_DIALOG, + _NET_WM_STATE_MODAL, _NET_WM_SYNC, _NET_SUPPORTED, _MOTIF_WM_HINTS, @@ -249,6 +251,8 @@ pub struct Callbacks { pub struct X11WindowState { pub destroyed: bool, + parent: Option, + children: FxHashSet, client: X11ClientStatePtr, executor: ForegroundExecutor, atoms: XcbAtoms, @@ -394,7 +398,7 @@ impl X11WindowState { atoms: &XcbAtoms, scale_factor: f32, appearance: WindowAppearance, - parent_window: Option, + parent_window: Option, ) -> anyhow::Result { let x_screen_index = params .display_id @@ -546,8 +550,8 @@ impl X11WindowState { )?; } - if params.kind == WindowKind::Floating { - if let Some(parent_window) = parent_window { + if params.kind == WindowKind::Floating || params.kind == WindowKind::Dialog { + if let Some(parent_window) = parent_window.as_ref().map(|w| w.x_window) { // WM_TRANSIENT_FOR hint indicating the main application window. For floating windows, we set // a parent window (WM_TRANSIENT_FOR) such that the window manager knows where to // place the floating window in relation to the main window. @@ -563,11 +567,23 @@ impl X11WindowState { ), )?; } + } + + let parent = if params.kind == WindowKind::Dialog + && let Some(parent) = parent_window + { + parent.add_child(x_window); + + Some(parent) + } else { + None + }; + if params.kind == WindowKind::Dialog { // _NET_WM_WINDOW_TYPE_DIALOG indicates that this is a dialog (floating) window // https://specifications.freedesktop.org/wm-spec/1.4/ar01s05.html check_reply( - || "X11 ChangeProperty32 setting window type for floating window failed.", + || "X11 ChangeProperty32 setting window type for dialog window failed.", xcb.change_property32( xproto::PropMode::REPLACE, x_window, @@ -576,6 +592,20 @@ impl X11WindowState { &[atoms._NET_WM_WINDOW_TYPE_DIALOG], ), )?; + + // We set the modal state for dialog windows, so that the window manager + // can handle it appropriately (e.g., prevent interaction with the parent window + // while the dialog is open). + check_reply( + || "X11 ChangeProperty32 setting modal state for dialog window failed.", + xcb.change_property32( + xproto::PropMode::REPLACE, + x_window, + atoms._NET_WM_STATE, + xproto::AtomEnum::ATOM, + &[atoms._NET_WM_STATE_MODAL], + ), + )?; } check_reply( @@ -667,6 +697,8 @@ impl X11WindowState { let display = Rc::new(X11Display::new(xcb, scale_factor, x_screen_index)?); Ok(Self { + parent, + children: FxHashSet::default(), client, executor, display, @@ -720,6 +752,11 @@ pub(crate) struct X11Window(pub X11WindowStatePtr); impl Drop for X11Window { fn drop(&mut self) { let mut state = self.0.state.borrow_mut(); + + if let Some(parent) = state.parent.as_ref() { + parent.state.borrow_mut().children.remove(&self.0.x_window); + } + state.renderer.destroy(); let destroy_x_window = maybe!({ @@ -734,8 +771,6 @@ impl Drop for X11Window { .log_err(); if destroy_x_window.is_some() { - // Mark window as destroyed so that we can filter out when X11 events - // for it still come in. state.destroyed = true; let this_ptr = self.0.clone(); @@ -773,7 +808,7 @@ impl X11Window { atoms: &XcbAtoms, scale_factor: f32, appearance: WindowAppearance, - parent_window: Option, + parent_window: Option, ) -> anyhow::Result { let ptr = X11WindowStatePtr { state: Rc::new(RefCell::new(X11WindowState::new( @@ -979,7 +1014,31 @@ impl X11WindowStatePtr { Ok(()) } + pub fn add_child(&self, child: xproto::Window) { + let mut state = self.state.borrow_mut(); + state.children.insert(child); + } + + pub fn is_blocked(&self) -> bool { + let state = self.state.borrow(); + !state.children.is_empty() + } + pub fn close(&self) { + let state = self.state.borrow(); + let client = state.client.clone(); + #[allow(clippy::mutable_key_type)] + let children = state.children.clone(); + drop(state); + + if let Some(client) = client.get_client() { + for child in children { + if let Some(child_window) = client.get_window(child) { + child_window.close(); + } + } + } + let mut callbacks = self.callbacks.borrow_mut(); if let Some(fun) = callbacks.close.take() { fun() @@ -994,6 +1053,9 @@ impl X11WindowStatePtr { } pub fn handle_input(&self, input: PlatformInput) { + if self.is_blocked() { + return; + } if let Some(ref mut fun) = self.callbacks.borrow_mut().input && !fun(input.clone()).propagate { @@ -1016,6 +1078,9 @@ impl X11WindowStatePtr { } pub fn handle_ime_commit(&self, text: String) { + if self.is_blocked() { + return; + } let mut state = self.state.borrow_mut(); if let Some(mut input_handler) = state.input_handler.take() { drop(state); @@ -1026,6 +1091,9 @@ impl X11WindowStatePtr { } pub fn handle_ime_preedit(&self, text: String) { + if self.is_blocked() { + return; + } let mut state = self.state.borrow_mut(); if let Some(mut input_handler) = state.input_handler.take() { drop(state); @@ -1036,6 +1104,9 @@ impl X11WindowStatePtr { } pub fn handle_ime_unmark(&self) { + if self.is_blocked() { + return; + } let mut state = self.state.borrow_mut(); if let Some(mut input_handler) = state.input_handler.take() { drop(state); @@ -1046,6 +1117,9 @@ impl X11WindowStatePtr { } pub fn handle_ime_delete(&self) { + if self.is_blocked() { + return; + } let mut state = self.state.borrow_mut(); if let Some(mut input_handler) = state.input_handler.take() { drop(state); diff --git a/crates/gpui/src/platform/mac/window.rs b/crates/gpui/src/platform/mac/window.rs index 14b0113c7cf44fa9574bfcca30b46fb988b5e380..f843fcd943523dc9a1c228cea1c4dcdf63c76097 100644 --- a/crates/gpui/src/platform/mac/window.rs +++ b/crates/gpui/src/platform/mac/window.rs @@ -62,9 +62,12 @@ static mut BLURRED_VIEW_CLASS: *const Class = ptr::null(); #[allow(non_upper_case_globals)] const NSWindowStyleMaskNonactivatingPanel: NSWindowStyleMask = NSWindowStyleMask::from_bits_retain(1 << 7); +// WindowLevel const value ref: https://docs.rs/core-graphics2/0.4.1/src/core_graphics2/window_level.rs.html #[allow(non_upper_case_globals)] const NSNormalWindowLevel: NSInteger = 0; #[allow(non_upper_case_globals)] +const NSFloatingWindowLevel: NSInteger = 3; +#[allow(non_upper_case_globals)] const NSPopUpWindowLevel: NSInteger = 101; #[allow(non_upper_case_globals)] const NSTrackingMouseEnteredAndExited: NSUInteger = 0x01; @@ -423,6 +426,8 @@ struct MacWindowState { select_previous_tab_callback: Option>, toggle_tab_bar_callback: Option>, activated_least_once: bool, + // The parent window if this window is a sheet (Dialog kind) + sheet_parent: Option, } impl MacWindowState { @@ -622,11 +627,16 @@ impl MacWindow { } let native_window: id = match kind { - WindowKind::Normal | WindowKind::Floating => msg_send![WINDOW_CLASS, alloc], + WindowKind::Normal => { + msg_send![WINDOW_CLASS, alloc] + } WindowKind::PopUp => { style_mask |= NSWindowStyleMaskNonactivatingPanel; msg_send![PANEL_CLASS, alloc] } + WindowKind::Floating | WindowKind::Dialog => { + msg_send![PANEL_CLASS, alloc] + } }; let display = display_id @@ -729,6 +739,7 @@ impl MacWindow { select_previous_tab_callback: None, toggle_tab_bar_callback: None, activated_least_once: false, + sheet_parent: None, }))); (*native_window).set_ivar( @@ -779,9 +790,18 @@ impl MacWindow { content_view.addSubview_(native_view.autorelease()); native_window.makeFirstResponder_(native_view); + let app: id = NSApplication::sharedApplication(nil); + let main_window: id = msg_send![app, mainWindow]; + let mut sheet_parent = None; + match kind { WindowKind::Normal | WindowKind::Floating => { - native_window.setLevel_(NSNormalWindowLevel); + if kind == WindowKind::Floating { + // Let the window float keep above normal windows. + native_window.setLevel_(NSFloatingWindowLevel); + } else { + native_window.setLevel_(NSNormalWindowLevel); + } native_window.setAcceptsMouseMovedEvents_(YES); if let Some(tabbing_identifier) = tabbing_identifier { @@ -816,10 +836,23 @@ impl MacWindow { NSWindowCollectionBehavior::NSWindowCollectionBehaviorFullScreenAuxiliary ); } + WindowKind::Dialog => { + if !main_window.is_null() { + let parent = { + let active_sheet: id = msg_send![main_window, attachedSheet]; + if active_sheet.is_null() { + main_window + } else { + active_sheet + } + }; + let _: () = + msg_send![parent, beginSheet: native_window completionHandler: nil]; + sheet_parent = Some(parent); + } + } } - let app = NSApplication::sharedApplication(nil); - let main_window: id = msg_send![app, mainWindow]; if allows_automatic_window_tabbing && !main_window.is_null() && main_window != native_window @@ -861,7 +894,11 @@ impl MacWindow { // the window position might be incorrect if the main screen (the screen that contains the window that has focus) // is different from the primary screen. NSWindow::setFrameTopLeftPoint_(native_window, window_rect.origin); - window.0.lock().move_traffic_light(); + { + let mut window_state = window.0.lock(); + window_state.move_traffic_light(); + window_state.sheet_parent = sheet_parent; + } pool.drain(); @@ -938,6 +975,7 @@ impl Drop for MacWindow { let mut this = self.0.lock(); this.renderer.destroy(); let window = this.native_window; + let sheet_parent = this.sheet_parent.take(); this.display_link.take(); unsafe { this.native_window.setDelegate_(nil); @@ -946,6 +984,9 @@ impl Drop for MacWindow { this.executor .spawn(async move { unsafe { + if let Some(parent) = sheet_parent { + let _: () = msg_send![parent, endSheet: window]; + } window.close(); window.autorelease(); } diff --git a/crates/gpui/src/platform/windows/events.rs b/crates/gpui/src/platform/windows/events.rs index f224a1bf3c47dc1a61c5e0216f5d7825cfc72533..1f0a4a0d28c2b266fb8588e4ce54251be010a78d 100644 --- a/crates/gpui/src/platform/windows/events.rs +++ b/crates/gpui/src/platform/windows/events.rs @@ -270,6 +270,14 @@ impl WindowsWindowInner { fn handle_destroy_msg(&self, handle: HWND) -> Option { let callback = { self.state.callbacks.close.take() }; + // Re-enable parent window if this was a modal dialog + if let Some(parent_hwnd) = self.parent_hwnd { + unsafe { + let _ = EnableWindow(parent_hwnd, true); + let _ = SetForegroundWindow(parent_hwnd); + } + } + if let Some(callback) = callback { callback(); } diff --git a/crates/gpui/src/platform/windows/window.rs b/crates/gpui/src/platform/windows/window.rs index 7ef92b4150e69424b68e9417dda377aa7f2e9cc0..3fcc29ad7864f8e45d27638bef489ffbf03788b2 100644 --- a/crates/gpui/src/platform/windows/window.rs +++ b/crates/gpui/src/platform/windows/window.rs @@ -83,6 +83,7 @@ pub(crate) struct WindowsWindowInner { pub(crate) validation_number: usize, pub(crate) main_receiver: flume::Receiver, pub(crate) platform_window_handle: HWND, + pub(crate) parent_hwnd: Option, } impl WindowsWindowState { @@ -241,6 +242,7 @@ impl WindowsWindowInner { main_receiver: context.main_receiver.clone(), platform_window_handle: context.platform_window_handle, system_settings: WindowsSystemSettings::new(context.display), + parent_hwnd: context.parent_hwnd, })) } @@ -368,6 +370,7 @@ struct WindowCreateContext { disable_direct_composition: bool, directx_devices: DirectXDevices, invalidate_devices: Arc, + parent_hwnd: Option, } impl WindowsWindow { @@ -390,6 +393,20 @@ impl WindowsWindow { invalidate_devices, } = creation_info; register_window_class(icon); + let parent_hwnd = if params.kind == WindowKind::Dialog { + let parent_window = unsafe { GetActiveWindow() }; + if parent_window.is_invalid() { + None + } else { + // Disable the parent window to make this dialog modal + unsafe { + EnableWindow(parent_window, false).as_bool(); + }; + Some(parent_window) + } + } else { + None + }; let hide_title_bar = params .titlebar .as_ref() @@ -416,8 +433,14 @@ impl WindowsWindow { if params.is_minimizable { dwstyle |= WS_MINIMIZEBOX; } + let dwexstyle = if params.kind == WindowKind::Dialog { + dwstyle |= WS_POPUP | WS_CAPTION; + WS_EX_DLGMODALFRAME + } else { + WS_EX_APPWINDOW + }; - (WS_EX_APPWINDOW, dwstyle) + (dwexstyle, dwstyle) }; if !disable_direct_composition { dwexstyle |= WS_EX_NOREDIRECTIONBITMAP; @@ -449,6 +472,7 @@ impl WindowsWindow { disable_direct_composition, directx_devices, invalidate_devices, + parent_hwnd, }; let creation_result = unsafe { CreateWindowExW( @@ -460,7 +484,7 @@ impl WindowsWindow { CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, - None, + parent_hwnd, None, Some(hinstance.into()), Some(&context as *const _ as *const _), From 2d071b0cb64e8368a4d0f7b4fa4cf0f4cf187fae Mon Sep 17 00:00:00 2001 From: Sean Hagstrom Date: Thu, 18 Dec 2025 07:45:55 -0800 Subject: [PATCH 508/621] editor: Fix git-hunk toggling for adjacent hunks (#43187) Closes #42934 Release Notes: - Fix toggling adjacent git-diff hunks based on the reported behaviour in #42934 --------- Co-authored-by: Jakub Konka --- crates/editor/src/editor_tests.rs | 90 +++++++++++++++++++++++++ crates/multi_buffer/src/multi_buffer.rs | 5 +- 2 files changed, 92 insertions(+), 3 deletions(-) diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rs index 48e59f7b7420473054214572a2908215f98ffded..c0112c5eda406c9cb3b3b9d004d20853b710f6e1 100644 --- a/crates/editor/src/editor_tests.rs +++ b/crates/editor/src/editor_tests.rs @@ -20880,6 +20880,36 @@ async fn test_toggling_adjacent_diff_hunks(cx: &mut TestAppContext) { .to_string(), ); + cx.update_editor(|editor, window, cx| { + editor.move_up(&MoveUp, window, cx); + editor.toggle_selected_diff_hunks(&Default::default(), window, cx); + }); + cx.assert_state_with_diff( + indoc! { " + ˇone + - two + three + five + "} + .to_string(), + ); + + cx.update_editor(|editor, window, cx| { + editor.move_down(&MoveDown, window, cx); + editor.move_down(&MoveDown, window, cx); + editor.toggle_selected_diff_hunks(&Default::default(), window, cx); + }); + cx.assert_state_with_diff( + indoc! { " + one + - two + ˇthree + - four + five + "} + .to_string(), + ); + cx.set_state(indoc! { " one ˇTWO @@ -20919,6 +20949,66 @@ async fn test_toggling_adjacent_diff_hunks(cx: &mut TestAppContext) { ); } +#[gpui::test] +async fn test_toggling_adjacent_diff_hunks_2( + executor: BackgroundExecutor, + cx: &mut TestAppContext, +) { + init_test(cx, |_| {}); + + let mut cx = EditorTestContext::new(cx).await; + + let diff_base = r#" + lineA + lineB + lineC + lineD + "# + .unindent(); + + cx.set_state( + &r#" + ˇlineA1 + lineB + lineD + "# + .unindent(), + ); + cx.set_head_text(&diff_base); + executor.run_until_parked(); + + cx.update_editor(|editor, window, cx| { + editor.toggle_selected_diff_hunks(&ToggleSelectedDiffHunks, window, cx); + }); + executor.run_until_parked(); + cx.assert_state_with_diff( + r#" + - lineA + + ˇlineA1 + lineB + lineD + "# + .unindent(), + ); + + cx.update_editor(|editor, window, cx| { + editor.move_down(&MoveDown, window, cx); + editor.move_right(&MoveRight, window, cx); + editor.toggle_selected_diff_hunks(&ToggleSelectedDiffHunks, window, cx); + }); + executor.run_until_parked(); + cx.assert_state_with_diff( + r#" + - lineA + + lineA1 + lˇineB + - lineC + lineD + "# + .unindent(), + ); +} + #[gpui::test] async fn test_edits_around_expanded_deletion_hunks( executor: BackgroundExecutor, diff --git a/crates/multi_buffer/src/multi_buffer.rs b/crates/multi_buffer/src/multi_buffer.rs index 5b343ecc5791c0f6f5f8a6d734cb79fc8226a8fa..0c0e87b60a7b8950f7461228c929503d516791e0 100644 --- a/crates/multi_buffer/src/multi_buffer.rs +++ b/crates/multi_buffer/src/multi_buffer.rs @@ -2610,9 +2610,8 @@ impl MultiBuffer { for range in ranges { let range = range.to_point(&snapshot); let start = snapshot.point_to_offset(Point::new(range.start.row, 0)); - let end = snapshot.point_to_offset(Point::new(range.end.row + 1, 0)); - let start = start.saturating_sub_usize(1); - let end = snapshot.len().min(end + 1usize); + let end = (snapshot.point_to_offset(Point::new(range.end.row + 1, 0)) + 1usize) + .min(snapshot.len()); cursor.seek(&start, Bias::Right); while let Some(item) = cursor.item() { if *cursor.start() >= end { From 7a62f01ea5b38e8db04fb1bed6fcb02ca01cc2d7 Mon Sep 17 00:00:00 2001 From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Date: Thu, 18 Dec 2025 13:08:46 -0300 Subject: [PATCH 509/621] agent_ui: Use display name for the message editor placeholder (#45264) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Follow up to a regression that happened when we introduced agent servers that made everywhere displaying agent names use the extension name instead of the display name. This has been since fixed in other places and this PR now updates the agent panel's message editor, too: | Before | After | |--------|--------| | Screenshot 2025-12-18 at 12  54
2@2x | Screenshot 2025-12-18 at 12 
54@2x | Release Notes: - N/A --- crates/agent_ui/src/acp/thread_view.rs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/crates/agent_ui/src/acp/thread_view.rs b/crates/agent_ui/src/acp/thread_view.rs index ed61141b0ab824b81731953db7b5a32b90d0539b..8364fd8c0f4d8fd55df8f2e74e990e603029db78 100644 --- a/crates/agent_ui/src/acp/thread_view.rs +++ b/crates/agent_ui/src/acp/thread_view.rs @@ -338,7 +338,13 @@ impl AcpThreadView { let prompt_capabilities = Rc::new(RefCell::new(acp::PromptCapabilities::default())); let available_commands = Rc::new(RefCell::new(vec![])); - let placeholder = placeholder_text(agent.name().as_ref(), false); + let agent_server_store = project.read(cx).agent_server_store().clone(); + let agent_display_name = agent_server_store + .read(cx) + .agent_display_name(&ExternalAgentServerName(agent.name())) + .unwrap_or_else(|| agent.name()); + + let placeholder = placeholder_text(agent_display_name.as_ref(), false); let message_editor = cx.new(|cx| { let mut editor = MessageEditor::new( @@ -377,7 +383,6 @@ impl AcpThreadView { ) }); - let agent_server_store = project.read(cx).agent_server_store().clone(); let subscriptions = [ cx.observe_global_in::(window, Self::agent_ui_font_size_changed), cx.observe_global_in::(window, Self::agent_ui_font_size_changed), @@ -1498,7 +1503,13 @@ impl AcpThreadView { let has_commands = !available_commands.is_empty(); self.available_commands.replace(available_commands); - let new_placeholder = placeholder_text(self.agent.name().as_ref(), has_commands); + let agent_display_name = self + .agent_server_store + .read(cx) + .agent_display_name(&ExternalAgentServerName(self.agent.name())) + .unwrap_or_else(|| self.agent.name()); + + let new_placeholder = placeholder_text(agent_display_name.as_ref(), has_commands); self.message_editor.update(cx, |editor, cx| { editor.set_placeholder_text(&new_placeholder, window, cx); From f937c1931fe382ad08f0d96b529f8a0428166d7c Mon Sep 17 00:00:00 2001 From: Bennet Bo Fenner Date: Thu, 18 Dec 2025 17:21:41 +0100 Subject: [PATCH 510/621] rules_library: Only store built-in prompts when they are customized (#45112) Follow up to #45004 Release Notes: - N/A --- Cargo.lock | 2 + crates/agent/src/agent.rs | 2 +- crates/agent_ui/src/completion_provider.rs | 2 +- crates/git_ui/src/git_panel.rs | 13 +- crates/prompt_store/Cargo.toml | 5 + crates/prompt_store/src/prompt_store.rs | 257 ++++++++++++++++++--- crates/rules_library/src/rules_library.rs | 47 +--- 7 files changed, 249 insertions(+), 79 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1ec640d49c2135d35442f0bf23047be7991427eb..0d83b2b9b912ab112d9b38fd1ef1d5ff21f9049c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -12648,6 +12648,8 @@ dependencies = [ "paths", "rope", "serde", + "strum 0.27.2", + "tempfile", "text", "util", "uuid", diff --git a/crates/agent/src/agent.rs b/crates/agent/src/agent.rs index 5e16f74682ef95a4e990ed5a124a0d6031acfb0e..43ed3b90f3556eb24e45440a7fe0038e7a1b9535 100644 --- a/crates/agent/src/agent.rs +++ b/crates/agent/src/agent.rs @@ -426,7 +426,7 @@ impl NativeAgent { .into_iter() .flat_map(|(contents, prompt_metadata)| match contents { Ok(contents) => Some(UserRulesContext { - uuid: prompt_metadata.id.user_id()?, + uuid: prompt_metadata.id.as_user()?, title: prompt_metadata.title.map(|title| title.to_string()), contents, }), diff --git a/crates/agent_ui/src/completion_provider.rs b/crates/agent_ui/src/completion_provider.rs index 206a2b3282b5471e8d5e8d18788519c3853dca55..a7b955b81ef3a7edccca98f15fa73bb40787a2c9 100644 --- a/crates/agent_ui/src/completion_provider.rs +++ b/crates/agent_ui/src/completion_provider.rs @@ -1586,7 +1586,7 @@ pub(crate) fn search_rules( None } else { Some(RulesContextEntry { - prompt_id: metadata.id.user_id()?, + prompt_id: metadata.id.as_user()?, title: metadata.title?, }) } diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs index 4e94a811510ee07707bf729040d41fc8b1eb922c..0f967e68d1fab829fb37b626c23ecfebe69fb5dd 100644 --- a/crates/git_ui/src/git_panel.rs +++ b/crates/git_ui/src/git_panel.rs @@ -58,7 +58,7 @@ use project::{ git_store::{GitStoreEvent, Repository, RepositoryEvent, RepositoryId, pending_op}, project_settings::{GitPathStyle, ProjectSettings}, }; -use prompt_store::{PromptId, PromptStore, RULES_FILE_NAMES}; +use prompt_store::{BuiltInPrompt, PromptId, PromptStore, RULES_FILE_NAMES}; use serde::{Deserialize, Serialize}; use settings::{Settings, SettingsStore, StatusStyle}; use std::future::Future; @@ -2579,25 +2579,26 @@ impl GitPanel { is_using_legacy_zed_pro: bool, cx: &mut AsyncApp, ) -> String { - const DEFAULT_PROMPT: &str = include_str!("commit_message_prompt.txt"); - // Remove this once we stop supporting legacy Zed Pro // In legacy Zed Pro, Git commit summary generation did not count as a // prompt. If the user changes the prompt, our classification will fail, // meaning that users will be charged for generating commit messages. if is_using_legacy_zed_pro { - return DEFAULT_PROMPT.to_string(); + return BuiltInPrompt::CommitMessage.default_content().to_string(); } let load = async { let store = cx.update(|cx| PromptStore::global(cx)).ok()?.await.ok()?; store - .update(cx, |s, cx| s.load(PromptId::CommitMessage, cx)) + .update(cx, |s, cx| { + s.load(PromptId::BuiltIn(BuiltInPrompt::CommitMessage), cx) + }) .ok()? .await .ok() }; - load.await.unwrap_or_else(|| DEFAULT_PROMPT.to_string()) + load.await + .unwrap_or_else(|| BuiltInPrompt::CommitMessage.default_content().to_string()) } /// Generates a commit message using an LLM. diff --git a/crates/prompt_store/Cargo.toml b/crates/prompt_store/Cargo.toml index 13bacbfad3bf2b5deb4a20af866f37dad47288ff..a7df9d13ee82da62838175029b9bdfd7c9375508 100644 --- a/crates/prompt_store/Cargo.toml +++ b/crates/prompt_store/Cargo.toml @@ -28,6 +28,11 @@ parking_lot.workspace = true paths.workspace = true rope.workspace = true serde.workspace = true +strum.workspace = true text.workspace = true util.workspace = true uuid.workspace = true + +[dev-dependencies] +gpui = { workspace = true, features = ["test-support"] } +tempfile.workspace = true diff --git a/crates/prompt_store/src/prompt_store.rs b/crates/prompt_store/src/prompt_store.rs index 7823f7a6957caf282f4ad7f1d6f884971364518e..2c45410c2aa172c8a4f7118a914cacca69ea7ca8 100644 --- a/crates/prompt_store/src/prompt_store.rs +++ b/crates/prompt_store/src/prompt_store.rs @@ -1,6 +1,6 @@ mod prompts; -use anyhow::{Context as _, Result, anyhow}; +use anyhow::{Result, anyhow}; use chrono::{DateTime, Utc}; use collections::HashMap; use futures::FutureExt as _; @@ -23,6 +23,7 @@ use std::{ path::PathBuf, sync::{Arc, atomic::AtomicBool}, }; +use strum::{EnumIter, IntoEnumIterator as _}; use text::LineEnding; use util::ResultExt; use uuid::Uuid; @@ -51,11 +52,51 @@ pub struct PromptMetadata { pub saved_at: DateTime, } +impl PromptMetadata { + fn builtin(builtin: BuiltInPrompt) -> Self { + Self { + id: PromptId::BuiltIn(builtin), + title: Some(builtin.title().into()), + default: false, + saved_at: DateTime::default(), + } + } +} + +/// Built-in prompts that have default content and can be customized by users. +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize, EnumIter)] +pub enum BuiltInPrompt { + CommitMessage, +} + +impl BuiltInPrompt { + pub fn title(&self) -> &'static str { + match self { + Self::CommitMessage => "Commit message", + } + } + + /// Returns the default content for this built-in prompt. + pub fn default_content(&self) -> &'static str { + match self { + Self::CommitMessage => include_str!("../../git_ui/src/commit_message_prompt.txt"), + } + } +} + +impl std::fmt::Display for BuiltInPrompt { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Self::CommitMessage => write!(f, "Commit message"), + } + } +} + #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] #[serde(tag = "kind")] pub enum PromptId { User { uuid: UserPromptId }, - CommitMessage, + BuiltIn(BuiltInPrompt), } impl PromptId { @@ -63,31 +104,37 @@ impl PromptId { UserPromptId::new().into() } - pub fn user_id(&self) -> Option { + pub fn as_user(&self) -> Option { match self { Self::User { uuid } => Some(*uuid), - _ => None, + Self::BuiltIn { .. } => None, } } - pub fn is_built_in(&self) -> bool { + pub fn as_built_in(&self) -> Option { match self { - Self::User { .. } => false, - Self::CommitMessage => true, + Self::User { .. } => None, + Self::BuiltIn(builtin) => Some(*builtin), } } + pub fn is_built_in(&self) -> bool { + matches!(self, Self::BuiltIn { .. }) + } + pub fn can_edit(&self) -> bool { match self { - Self::User { .. } | Self::CommitMessage => true, + Self::User { .. } => true, + Self::BuiltIn(builtin) => match builtin { + BuiltInPrompt::CommitMessage => true, + }, } } +} - pub fn default_content(&self) -> Option<&'static str> { - match self { - Self::User { .. } => None, - Self::CommitMessage => Some(include_str!("../../git_ui/src/commit_message_prompt.txt")), - } +impl From for PromptId { + fn from(builtin: BuiltInPrompt) -> Self { + PromptId::BuiltIn(builtin) } } @@ -117,7 +164,7 @@ impl std::fmt::Display for PromptId { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { PromptId::User { uuid } => write!(f, "{}", uuid.0), - PromptId::CommitMessage => write!(f, "Commit message"), + PromptId::BuiltIn(builtin) => write!(f, "{}", builtin), } } } @@ -150,6 +197,16 @@ impl MetadataCache { cache.metadata.push(metadata.clone()); cache.metadata_by_id.insert(prompt_id, metadata); } + + // Insert all the built-in prompts that were not customized by the user + for builtin in BuiltInPrompt::iter() { + let builtin_id = PromptId::BuiltIn(builtin); + if !cache.metadata_by_id.contains_key(&builtin_id) { + let metadata = PromptMetadata::builtin(builtin); + cache.metadata.push(metadata.clone()); + cache.metadata_by_id.insert(builtin_id, metadata); + } + } cache.sort(); Ok(cache) } @@ -198,10 +255,6 @@ impl PromptStore { let mut txn = db_env.write_txn()?; let metadata = db_env.create_database(&mut txn, Some("metadata.v2"))?; let bodies = db_env.create_database(&mut txn, Some("bodies.v2"))?; - - metadata.delete(&mut txn, &PromptId::CommitMessage)?; - bodies.delete(&mut txn, &PromptId::CommitMessage)?; - txn.commit()?; Self::upgrade_dbs(&db_env, metadata, bodies).log_err(); @@ -294,7 +347,16 @@ impl PromptStore { let bodies = self.bodies; cx.background_spawn(async move { let txn = env.read_txn()?; - let mut prompt = bodies.get(&txn, &id)?.context("prompt not found")?.into(); + let mut prompt: String = match bodies.get(&txn, &id)? { + Some(body) => body.into(), + None => { + if let Some(built_in) = id.as_built_in() { + built_in.default_content().into() + } else { + anyhow::bail!("prompt not found") + } + } + }; LineEnding::normalize(&mut prompt); Ok(prompt) }) @@ -339,11 +401,6 @@ impl PromptStore { }) } - /// Returns the number of prompts in the store. - pub fn prompt_count(&self) -> usize { - self.metadata_cache.read().metadata.len() - } - pub fn metadata(&self, id: PromptId) -> Option { self.metadata_cache.read().metadata_by_id.get(&id).cloned() } @@ -412,23 +469,38 @@ impl PromptStore { return Task::ready(Err(anyhow!("this prompt cannot be edited"))); } - let prompt_metadata = PromptMetadata { - id, - title, - default, - saved_at: Utc::now(), + let body = body.to_string(); + let is_default_content = id + .as_built_in() + .is_some_and(|builtin| body.trim() == builtin.default_content().trim()); + + let metadata = if let Some(builtin) = id.as_built_in() { + PromptMetadata::builtin(builtin) + } else { + PromptMetadata { + id, + title, + default, + saved_at: Utc::now(), + } }; - self.metadata_cache.write().insert(prompt_metadata.clone()); + + self.metadata_cache.write().insert(metadata.clone()); let db_connection = self.env.clone(); let bodies = self.bodies; - let metadata = self.metadata; + let metadata_db = self.metadata; let task = cx.background_spawn(async move { let mut txn = db_connection.write_txn()?; - metadata.put(&mut txn, &id, &prompt_metadata)?; - bodies.put(&mut txn, &id, &body.to_string())?; + if is_default_content { + metadata_db.delete(&mut txn, &id)?; + bodies.delete(&mut txn, &id)?; + } else { + metadata_db.put(&mut txn, &id, &metadata)?; + bodies.put(&mut txn, &id, &body)?; + } txn.commit()?; @@ -490,3 +562,122 @@ impl PromptStore { pub struct GlobalPromptStore(Shared, Arc>>>); impl Global for GlobalPromptStore {} + +#[cfg(test)] +mod tests { + use super::*; + use gpui::TestAppContext; + + #[gpui::test] + async fn test_built_in_prompt_load_save(cx: &mut TestAppContext) { + cx.executor().allow_parking(); + + let temp_dir = tempfile::tempdir().unwrap(); + let db_path = temp_dir.path().join("prompts-db"); + + let store = cx.update(|cx| PromptStore::new(db_path, cx)).await.unwrap(); + let store = cx.new(|_cx| store); + + let commit_message_id = PromptId::BuiltIn(BuiltInPrompt::CommitMessage); + + let loaded_content = store + .update(cx, |store, cx| store.load(commit_message_id, cx)) + .await + .unwrap(); + + let mut expected_content = BuiltInPrompt::CommitMessage.default_content().to_string(); + LineEnding::normalize(&mut expected_content); + assert_eq!( + loaded_content.trim(), + expected_content.trim(), + "Loading a built-in prompt not in DB should return default content" + ); + + let metadata = store.read_with(cx, |store, _| store.metadata(commit_message_id)); + assert!( + metadata.is_some(), + "Built-in prompt should always have metadata" + ); + assert!( + store.read_with(cx, |store, _| { + store + .metadata_cache + .read() + .metadata_by_id + .contains_key(&commit_message_id) + }), + "Built-in prompt should always be in cache" + ); + + let custom_content = "Custom commit message prompt"; + store + .update(cx, |store, cx| { + store.save( + commit_message_id, + Some("Commit message".into()), + false, + Rope::from(custom_content), + cx, + ) + }) + .await + .unwrap(); + + let loaded_custom = store + .update(cx, |store, cx| store.load(commit_message_id, cx)) + .await + .unwrap(); + assert_eq!( + loaded_custom.trim(), + custom_content.trim(), + "Custom content should be loaded after saving" + ); + + assert!( + store + .read_with(cx, |store, _| store.metadata(commit_message_id)) + .is_some(), + "Built-in prompt should have metadata after customization" + ); + + store + .update(cx, |store, cx| { + store.save( + commit_message_id, + Some("Commit message".into()), + false, + Rope::from(BuiltInPrompt::CommitMessage.default_content()), + cx, + ) + }) + .await + .unwrap(); + + let metadata_after_reset = + store.read_with(cx, |store, _| store.metadata(commit_message_id)); + assert!( + metadata_after_reset.is_some(), + "Built-in prompt should still have metadata after reset" + ); + assert_eq!( + metadata_after_reset + .as_ref() + .and_then(|m| m.title.as_ref().map(|t| t.as_ref())), + Some("Commit message"), + "Built-in prompt should have default title after reset" + ); + + let loaded_after_reset = store + .update(cx, |store, cx| store.load(commit_message_id, cx)) + .await + .unwrap(); + let mut expected_content_after_reset = + BuiltInPrompt::CommitMessage.default_content().to_string(); + LineEnding::normalize(&mut expected_content_after_reset); + assert_eq!( + loaded_after_reset.trim(), + expected_content_after_reset.trim(), + "After saving default content, load should return default" + ); + } +} diff --git a/crates/rules_library/src/rules_library.rs b/crates/rules_library/src/rules_library.rs index 642d6b64f79ed0f52b9cdb7feee900cf87af83cc..fc6af46782f26615aa0f5faeb7062ca03181ab9b 100644 --- a/crates/rules_library/src/rules_library.rs +++ b/crates/rules_library/src/rules_library.rs @@ -3,9 +3,9 @@ use collections::{HashMap, HashSet}; use editor::{CompletionProvider, SelectionEffects}; use editor::{CurrentLineHighlight, Editor, EditorElement, EditorEvent, EditorStyle, actions::Tab}; use gpui::{ - Action, App, Bounds, DEFAULT_ADDITIONAL_WINDOW_SIZE, Entity, EventEmitter, Focusable, - PromptLevel, Subscription, Task, TextStyle, TitlebarOptions, WindowBounds, WindowHandle, - WindowOptions, actions, point, size, transparent_black, + App, Bounds, DEFAULT_ADDITIONAL_WINDOW_SIZE, Entity, EventEmitter, Focusable, PromptLevel, + Subscription, Task, TextStyle, TitlebarOptions, WindowBounds, WindowHandle, WindowOptions, + actions, point, size, transparent_black, }; use language::{Buffer, LanguageRegistry, language_settings::SoftWrap}; use language_model::{ @@ -21,7 +21,7 @@ use std::sync::atomic::AtomicBool; use std::time::Duration; use theme::ThemeSettings; use title_bar::platform_title_bar::PlatformTitleBar; -use ui::{Divider, KeyBinding, ListItem, ListItemSpacing, ListSubHeader, Tooltip, prelude::*}; +use ui::{Divider, ListItem, ListItemSpacing, ListSubHeader, Tooltip, prelude::*}; use util::{ResultExt, TryFutureExt}; use workspace::{Workspace, WorkspaceSettings, client_side_decorations}; use zed_actions::assistant::InlineAssist; @@ -206,13 +206,8 @@ impl PickerDelegate for RulePickerDelegate { self.filtered_entries.len() } - fn no_matches_text(&self, _window: &mut Window, cx: &mut App) -> Option { - let text = if self.store.read(cx).prompt_count() == 0 { - "No rules.".into() - } else { - "No rules found matching your search.".into() - }; - Some(text) + fn no_matches_text(&self, _window: &mut Window, _cx: &mut App) -> Option { + Some("No rules found matching your search.".into()) } fn selected_index(&self) -> usize { @@ -680,13 +675,13 @@ impl RulesLibrary { window: &mut Window, cx: &mut Context, ) { - let Some(default_content) = prompt_id.default_content() else { + let Some(built_in) = prompt_id.as_built_in() else { return; }; if let Some(rule_editor) = self.rule_editors.get(&prompt_id) { rule_editor.body_editor.update(cx, |editor, cx| { - editor.set_text(default_content, window, cx); + editor.set_text(built_in.default_content(), window, cx); }); } } @@ -1428,31 +1423,7 @@ impl Render for RulesLibrary { this.border_t_1().border_color(cx.theme().colors().border) }) .child(self.render_rule_list(cx)) - .map(|el| { - if self.store.read(cx).prompt_count() == 0 { - el.child( - v_flex() - .h_full() - .flex_1() - .items_center() - .justify_center() - .border_l_1() - .border_color(cx.theme().colors().border) - .bg(cx.theme().colors().editor_background) - .child( - Button::new("create-rule", "New Rule") - .style(ButtonStyle::Outlined) - .key_binding(KeyBinding::for_action(&NewRule, cx)) - .on_click(|_, window, cx| { - window - .dispatch_action(NewRule.boxed_clone(), cx) - }), - ), - ) - } else { - el.child(self.render_active_rule(cx)) - } - }), + .child(self.render_active_rule(cx)), ), window, cx, From 2a713c546b80cfc1dcf678953336f3758d1b152b Mon Sep 17 00:00:00 2001 From: tidely <43219534+tidely@users.noreply.github.com> Date: Thu, 18 Dec 2025 18:24:38 +0200 Subject: [PATCH 511/621] gpui: Small tab group performance improvements (#41885) Closes #ISSUE Removes a few eager container clones and iterations. Added a todo to `get_prev_tab_group_window` and `get_next_tab_group_window`. They seem to use `HashMap::keys()` for choosing the previous tab group, however `.keys()` returns an arbitrary order, so I'm not sure if previous actually means anything here. Conrad seems to have worked on this part previously, maybe he has some insights. That can possibly be a follow-up PR, but I'd be willing to work on it here as well since the other changes are so simple. Release Notes: - N/A --- crates/gpui/src/app.rs | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/crates/gpui/src/app.rs b/crates/gpui/src/app.rs index 7bd0daf56a466666b8cf5ae70f6b7cb5597a0d10..75600a9ee1b440a092a89456cbe8fbabe6fdccfa 100644 --- a/crates/gpui/src/app.rs +++ b/crates/gpui/src/app.rs @@ -316,6 +316,7 @@ impl SystemWindowTabController { .find_map(|(group, tabs)| tabs.iter().find(|tab| tab.id == id).map(|_| group)); let current_group = current_group?; + // TODO: `.keys()` returns arbitrary order, what does "next" mean? let mut group_ids: Vec<_> = controller.tab_groups.keys().collect(); let idx = group_ids.iter().position(|g| *g == current_group)?; let next_idx = (idx + 1) % group_ids.len(); @@ -340,6 +341,7 @@ impl SystemWindowTabController { .find_map(|(group, tabs)| tabs.iter().find(|tab| tab.id == id).map(|_| group)); let current_group = current_group?; + // TODO: `.keys()` returns arbitrary order, what does "previous" mean? let mut group_ids: Vec<_> = controller.tab_groups.keys().collect(); let idx = group_ids.iter().position(|g| *g == current_group)?; let prev_idx = if idx == 0 { @@ -361,12 +363,9 @@ impl SystemWindowTabController { /// Get all tabs in the same window. pub fn tabs(&self, id: WindowId) -> Option<&Vec> { - let tab_group = self - .tab_groups - .iter() - .find_map(|(group, tabs)| tabs.iter().find(|tab| tab.id == id).map(|_| *group))?; - - self.tab_groups.get(&tab_group) + self.tab_groups + .values() + .find(|tabs| tabs.iter().any(|tab| tab.id == id)) } /// Initialize the visibility of the system window tab controller. @@ -441,7 +440,7 @@ impl SystemWindowTabController { /// Insert a tab into a tab group. pub fn add_tab(cx: &mut App, id: WindowId, tabs: Vec) { let mut controller = cx.global_mut::(); - let Some(tab) = tabs.clone().into_iter().find(|tab| tab.id == id) else { + let Some(tab) = tabs.iter().find(|tab| tab.id == id).cloned() else { return; }; @@ -504,16 +503,14 @@ impl SystemWindowTabController { return; }; + let initial_tabs_len = initial_tabs.len(); let mut all_tabs = initial_tabs.clone(); - for tabs in controller.tab_groups.values() { - all_tabs.extend( - tabs.iter() - .filter(|tab| !initial_tabs.contains(tab)) - .cloned(), - ); + + for (_, mut tabs) in controller.tab_groups.drain() { + tabs.retain(|tab| !all_tabs[..initial_tabs_len].contains(tab)); + all_tabs.extend(tabs); } - controller.tab_groups.clear(); controller.tab_groups.insert(0, all_tabs); } From a85c508f69491b60b49340229390fdd5be6e42ed Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Thu, 18 Dec 2025 17:26:20 +0100 Subject: [PATCH 512/621] Fix self-referential symbolic link (#45265) Release Notes: - N/A --- crates/eval_utils/LICENSE-GPL | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/eval_utils/LICENSE-GPL b/crates/eval_utils/LICENSE-GPL index e0f9dbd5d63fef1630c297edc4ceba4790be6f02..89e542f750cd3860a0598eff0dc34b56d7336dc4 120000 --- a/crates/eval_utils/LICENSE-GPL +++ b/crates/eval_utils/LICENSE-GPL @@ -1 +1 @@ -LICENSE-GPL \ No newline at end of file +../../LICENSE-GPL \ No newline at end of file From 098adf3bdd9b875b8dcf360888d1aa0068265005 Mon Sep 17 00:00:00 2001 From: Marco Mihai Condrache <52580954+marcocondrache@users.noreply.github.com> Date: Thu, 18 Dec 2025 17:29:25 +0100 Subject: [PATCH 513/621] gpui: Enable direct-to-display optimization for metal (#44334) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When profiling Zed with Instruments, a warning appears indicating that surfaces cannot be pushed directly to the display as they are non-opaque. This happens because the metal layer is currently marked as non-opaque by default, even though the window itself is not transparent. image Metal on macOS can bypass compositing and present frames directly to the display when several conditions are met. One of those conditions is that the backing layer must be declared opaque. Apple’s documentation notes that marking layers as opaque allows the system to avoid unnecessary compositing work, reducing GPU load and improving frame pacing Ref: https://developer.apple.com/documentation/metal/managing-your-game-window-for-metal-in-macos This PR updates the Metal renderer to mark the layer as opaque whenever the window does not use transparency. This makes Zed eligible for macOS’s direct-to-display optimization in scenarios where the system can apply it. Release Notes: - gpui: Mark metal layers opaque for non-transparent windows to allow direct-to-display when supported --------- Signed-off-by: Marco Mihai Condrache <52580954+marcocondrache@users.noreply.github.com> --- crates/gpui/src/platform/mac/metal_renderer.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/crates/gpui/src/platform/mac/metal_renderer.rs b/crates/gpui/src/platform/mac/metal_renderer.rs index 550041a0ccb4cd39bc7a86317d9540e806af2a28..66f54e5ba0c66a508f9db73d5ad8f84cb52d0d69 100644 --- a/crates/gpui/src/platform/mac/metal_renderer.rs +++ b/crates/gpui/src/platform/mac/metal_renderer.rs @@ -46,9 +46,9 @@ pub unsafe fn new_renderer( _native_window: *mut c_void, _native_view: *mut c_void, _bounds: crate::Size, - _transparent: bool, + transparent: bool, ) -> Renderer { - MetalRenderer::new(context) + MetalRenderer::new(context, transparent) } pub(crate) struct InstanceBufferPool { @@ -128,7 +128,7 @@ pub struct PathRasterizationVertex { } impl MetalRenderer { - pub fn new(instance_buffer_pool: Arc>) -> Self { + pub fn new(instance_buffer_pool: Arc>, transparent: bool) -> Self { // Prefer low‐power integrated GPUs on Intel Mac. On Apple // Silicon, there is only ever one GPU, so this is equivalent to // `metal::Device::system_default()`. @@ -152,8 +152,13 @@ impl MetalRenderer { let layer = metal::MetalLayer::new(); layer.set_device(&device); layer.set_pixel_format(MTLPixelFormat::BGRA8Unorm); - layer.set_opaque(false); + // Support direct-to-display rendering if the window is not transparent + // https://developer.apple.com/documentation/metal/managing-your-game-window-for-metal-in-macos + layer.set_opaque(!transparent); layer.set_maximum_drawable_count(3); + // We already present at display sync with the display link + // This allows to use direct-to-display even in window mode + layer.set_display_sync_enabled(false); unsafe { let _: () = msg_send![&*layer, setAllowsNextDrawableTimeout: NO]; let _: () = msg_send![&*layer, setNeedsDisplayOnBoundsChange: YES]; @@ -352,8 +357,8 @@ impl MetalRenderer { } } - pub fn update_transparency(&self, _transparent: bool) { - // todo(mac)? + pub fn update_transparency(&self, transparent: bool) { + self.layer.set_opaque(!transparent); } pub fn destroy(&self) { From e10b9b70efafa8d2ede3175528eaf7f3c44b06b4 Mon Sep 17 00:00:00 2001 From: Leo Date: Fri, 19 Dec 2025 00:45:26 +0800 Subject: [PATCH 514/621] git: Add global git integration enable/disable setting (#43326) Closes #13304 Release Notes: - Add global `git status` and `git diff` on/off in one place instead of control everywhere We can first review to ensure this change meets both `Zed` and user requirements, as well as code rules. Currently, we only support user-level settings. We can wait for this PR: https://github.com/zed-industries/zed/pull/43173 to be merged, then modify it to support both user and project levels. --- assets/settings/default.json | 8 ++ crates/editor/src/editor_settings.rs | 3 +- .../src/outline_panel_settings.rs | 8 +- crates/project/src/project_settings.rs | 23 +++++ .../src/project_panel_settings.rs | 8 +- .../settings/src/settings_content/project.rs | 24 +++++ crates/settings_ui/src/page_data.rs | 96 +++++++++++++++++++ crates/workspace/src/item.rs | 8 +- 8 files changed, 174 insertions(+), 4 deletions(-) diff --git a/assets/settings/default.json b/assets/settings/default.json index e7df5ef0bf2d3bc805c79f79811d9929343544ef..154fe2d6e34e6573e95e7ffedbb46df8bbf10634 100644 --- a/assets/settings/default.json +++ b/assets/settings/default.json @@ -1321,6 +1321,14 @@ "hidden_files": ["**/.*"], // Git gutter behavior configuration. "git": { + // Global switch to enable or disable all git integration features. + // If set to true, disables all git integration features. + // If set to false, individual git integration features below will be independently enabled or disabled. + "disable_git": false, + // Whether to enable git status tracking. + "enable_status": true, + // Whether to enable git diff display. + "enable_diff": true, // Control whether the git gutter is shown. May take 2 values: // 1. Show the gutter // "git_gutter": "tracked_files" diff --git a/crates/editor/src/editor_settings.rs b/crates/editor/src/editor_settings.rs index e1984311d4eb0ba9d989f77a707b22698b00c750..464157202f4821c8f05af479d2eff9f441a961ef 100644 --- a/crates/editor/src/editor_settings.rs +++ b/crates/editor/src/editor_settings.rs @@ -215,7 +215,8 @@ impl Settings for EditorSettings { }, scrollbar: Scrollbar { show: scrollbar.show.map(Into::into).unwrap(), - git_diff: scrollbar.git_diff.unwrap(), + git_diff: scrollbar.git_diff.unwrap() + && content.git.unwrap().enabled.unwrap().is_git_diff_enabled(), selected_text: scrollbar.selected_text.unwrap(), selected_symbol: scrollbar.selected_symbol.unwrap(), search_results: scrollbar.search_results.unwrap(), diff --git a/crates/outline_panel/src/outline_panel_settings.rs b/crates/outline_panel/src/outline_panel_settings.rs index b2b1a6fe685c18853087d3eb04edeef2ceebd89f..bf73aebecc194baca0156c9cdb850ed89627e001 100644 --- a/crates/outline_panel/src/outline_panel_settings.rs +++ b/crates/outline_panel/src/outline_panel_settings.rs @@ -50,7 +50,13 @@ impl Settings for OutlinePanelSettings { dock: panel.dock.unwrap(), file_icons: panel.file_icons.unwrap(), folder_icons: panel.folder_icons.unwrap(), - git_status: panel.git_status.unwrap(), + git_status: panel.git_status.unwrap() + && content + .git + .unwrap() + .enabled + .unwrap() + .is_git_status_enabled(), indent_size: panel.indent_size.unwrap(), indent_guides: IndentGuidesSettings { show: panel.indent_guides.unwrap().show.unwrap(), diff --git a/crates/project/src/project_settings.rs b/crates/project/src/project_settings.rs index 6d95411681d5d350271e7071b752f27d0807f60d..633f2bbd3b40139f6355e109211d665cfd0c1e5f 100644 --- a/crates/project/src/project_settings.rs +++ b/crates/project/src/project_settings.rs @@ -332,6 +332,10 @@ impl GoToDiagnosticSeverityFilter { #[derive(Copy, Clone, Debug)] pub struct GitSettings { + /// Whether or not git integration is enabled. + /// + /// Default: true + pub enabled: GitEnabledSettings, /// Whether or not to show the git gutter. /// /// Default: tracked_files @@ -361,6 +365,18 @@ pub struct GitSettings { pub path_style: GitPathStyle, } +#[derive(Clone, Copy, Debug)] +pub struct GitEnabledSettings { + /// Whether git integration is enabled for showing git status. + /// + /// Default: true + pub status: bool, + /// Whether git integration is enabled for showing diffs. + /// + /// Default: true + pub diff: bool, +} + #[derive(Clone, Copy, Debug, PartialEq, Default)] pub enum GitPathStyle { #[default] @@ -502,7 +518,14 @@ impl Settings for ProjectSettings { let inline_diagnostics = diagnostics.inline.as_ref().unwrap(); let git = content.git.as_ref().unwrap(); + let git_enabled = { + GitEnabledSettings { + status: git.enabled.as_ref().unwrap().is_git_status_enabled(), + diff: git.enabled.as_ref().unwrap().is_git_diff_enabled(), + } + }; let git_settings = GitSettings { + enabled: git_enabled, git_gutter: git.git_gutter.unwrap(), gutter_debounce: git.gutter_debounce.unwrap_or_default(), inline_blame: { diff --git a/crates/project_panel/src/project_panel_settings.rs b/crates/project_panel/src/project_panel_settings.rs index b0316270340203177278edebaececd0d86e39869..5d498da0f9d519bc25d738bcf9368c394bbdabfd 100644 --- a/crates/project_panel/src/project_panel_settings.rs +++ b/crates/project_panel/src/project_panel_settings.rs @@ -92,7 +92,13 @@ impl Settings for ProjectPanelSettings { entry_spacing: project_panel.entry_spacing.unwrap(), file_icons: project_panel.file_icons.unwrap(), folder_icons: project_panel.folder_icons.unwrap(), - git_status: project_panel.git_status.unwrap(), + git_status: project_panel.git_status.unwrap() + && content + .git + .unwrap() + .enabled + .unwrap() + .is_git_status_enabled(), indent_size: project_panel.indent_size.unwrap(), indent_guides: IndentGuidesSettings { show: project_panel.indent_guides.unwrap().show.unwrap(), diff --git a/crates/settings/src/settings_content/project.rs b/crates/settings/src/settings_content/project.rs index a5e15153832c425134e129cba1984b3b5886aa56..8e2d864149c9ecb6ca38ca73ef58205f588dc07b 100644 --- a/crates/settings/src/settings_content/project.rs +++ b/crates/settings/src/settings_content/project.rs @@ -288,6 +288,11 @@ impl std::fmt::Debug for ContextServerCommand { #[with_fallible_options] #[derive(Copy, Clone, Debug, PartialEq, Default, Serialize, Deserialize, JsonSchema, MergeFrom)] pub struct GitSettings { + /// Whether or not to enable git integration. + /// + /// Default: true + #[serde(flatten)] + pub enabled: Option, /// Whether or not to show the git gutter. /// /// Default: tracked_files @@ -317,6 +322,25 @@ pub struct GitSettings { pub path_style: Option, } +#[with_fallible_options] +#[derive(Clone, Copy, Debug, PartialEq, Default, Serialize, Deserialize, JsonSchema, MergeFrom)] +#[serde(rename_all = "snake_case")] +pub struct GitEnabledSettings { + pub disable_git: Option, + pub enable_status: Option, + pub enable_diff: Option, +} + +impl GitEnabledSettings { + pub fn is_git_status_enabled(&self) -> bool { + !self.disable_git.unwrap_or(false) && self.enable_status.unwrap_or(true) + } + + pub fn is_git_diff_enabled(&self) -> bool { + !self.disable_git.unwrap_or(false) && self.enable_diff.unwrap_or(true) + } +} + #[derive( Clone, Copy, diff --git a/crates/settings_ui/src/page_data.rs b/crates/settings_ui/src/page_data.rs index c8775bad42a9a8bd6aa5e57bafbb817b99619e68..ca2e23252a4483b365c7c42cfd086105d757a097 100644 --- a/crates/settings_ui/src/page_data.rs +++ b/crates/settings_ui/src/page_data.rs @@ -5519,6 +5519,102 @@ pub(crate) fn settings_data(cx: &App) -> Vec { SettingsPage { title: "Version Control", items: vec![ + SettingsPageItem::SectionHeader("Git Integration"), + SettingsPageItem::DynamicItem(DynamicItem { + discriminant: SettingItem { + files: USER, + title: "Disable Git Integration", + description: "Disable all Git integration features in Zed.", + field: Box::new(SettingField:: { + json_path: Some("git.disable_git"), + pick: |settings_content| { + settings_content + .git + .as_ref()? + .enabled + .as_ref()? + .disable_git + .as_ref() + }, + write: |settings_content, value| { + settings_content + .git + .get_or_insert_default() + .enabled + .get_or_insert_default() + .disable_git = value; + }, + }), + metadata: None, + }, + pick_discriminant: |settings_content| { + let disabled = settings_content + .git + .as_ref()? + .enabled + .as_ref()? + .disable_git + .unwrap_or(false); + Some(if disabled { 0 } else { 1 }) + }, + fields: vec![ + vec![], + vec![ + SettingItem { + files: USER, + title: "Enable Git Status", + description: "Show Git status information in the editor.", + field: Box::new(SettingField:: { + json_path: Some("git.enable_status"), + pick: |settings_content| { + settings_content + .git + .as_ref()? + .enabled + .as_ref()? + .enable_status + .as_ref() + }, + write: |settings_content, value| { + settings_content + .git + .get_or_insert_default() + .enabled + .get_or_insert_default() + .enable_status = value; + }, + }), + metadata: None, + }, + SettingItem { + files: USER, + title: "Enable Git Diff", + description: "Show Git diff information in the editor.", + field: Box::new(SettingField:: { + json_path: Some("git.enable_diff"), + pick: |settings_content| { + settings_content + .git + .as_ref()? + .enabled + .as_ref()? + .enable_diff + .as_ref() + }, + write: |settings_content, value| { + settings_content + .git + .get_or_insert_default() + .enabled + .get_or_insert_default() + .enable_diff = value; + }, + }), + metadata: None, + }, + ], + ], + }), SettingsPageItem::SectionHeader("Git Gutter"), SettingsPageItem::SettingItem(SettingItem { title: "Visibility", diff --git a/crates/workspace/src/item.rs b/crates/workspace/src/item.rs index 1570c125fa33135631d8181359ad34bb7802ec5f..6e415c23454388bc7931ff9d5e499924d6b8f55d 100644 --- a/crates/workspace/src/item.rs +++ b/crates/workspace/src/item.rs @@ -76,7 +76,13 @@ impl Settings for ItemSettings { fn from_settings(content: &settings::SettingsContent) -> Self { let tabs = content.tabs.as_ref().unwrap(); Self { - git_status: tabs.git_status.unwrap(), + git_status: tabs.git_status.unwrap() + && content + .git + .unwrap() + .enabled + .unwrap() + .is_git_status_enabled(), close_position: tabs.close_position.unwrap(), activate_on_close: tabs.activate_on_close.unwrap(), file_icons: tabs.file_icons.unwrap(), From f58278aaf41d0ae347fe947a9d5b052a89eea9d9 Mon Sep 17 00:00:00 2001 From: Emmanuel Amoah <42612171+emamoah@users.noreply.github.com> Date: Thu, 18 Dec 2025 17:03:46 +0000 Subject: [PATCH 515/621] glossary: Fix grammar and typo (#45267) Fixes grammar and a typo in `Picker` description. Release Notes: - N/A --- docs/src/development/glossary.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/development/glossary.md b/docs/src/development/glossary.md index 34172ec9a590fdae537ff78920e1fadda2c331fa..0e0f984e214fe1a46e0aff790ab5e85bb46a8674 100644 --- a/docs/src/development/glossary.md +++ b/docs/src/development/glossary.md @@ -73,7 +73,7 @@ h_flex() - `Window`: A struct in zed representing a zed window in your desktop environment (see image below). There can be multiple if you have multiple zed instances open. Mostly passed around for rendering. - `Modal`: A UI element that floats on top of the rest of the UI -- `Picker`: A struct representing a list of items in floating on top of the UI (Modal). You can select an item and confirm. What happens on select or confirm is determined by the picker's delegate. (The 'Model' in the image below is a picker.) +- `Picker`: A struct representing a list of items floating on top of the UI (Modal). You can select an item and confirm. What happens on select or confirm is determined by the picker's delegate. (The 'Modal' in the image below is a picker.) - `PickerDelegate`: A trait used to specialize behavior for a `Picker`. The `Picker` stores the `PickerDelegate` in the field delegate. - `Center`: The middle of the zed window, the center is split into multiple `Pane`s. In the codebase this is a field on the `Workspace` struct. (see image below). - `Pane`: An area in the `Center` where we can place items, such as an editor, multi-buffer or terminal (see image below). From 334ca218577b59b0ad55afb28531c66c964c2f89 Mon Sep 17 00:00:00 2001 From: Gaauwe Rombouts Date: Thu, 18 Dec 2025 18:05:53 +0100 Subject: [PATCH 516/621] Truncate code actions with a long label and show full label aside (#45268) Closes #43355 Fixes the issue were code actions with long labels would get cut off without being able to see the full description. We now properly truncate those labels with an ellipsis and show the full description in an aside. Release Notes: - Added ellipsis to truncated code actions and an aside showing the full action description. --- crates/editor/src/code_context_menus.rs | 151 ++++++++++---------- crates/gpui/src/text_system/line_wrapper.rs | 45 ++++-- 2 files changed, 106 insertions(+), 90 deletions(-) diff --git a/crates/editor/src/code_context_menus.rs b/crates/editor/src/code_context_menus.rs index d255effdb72a003014dff0805fa34a23d11c8c81..2336a38fa7767fa6184608066f69d3b0520234ff 100644 --- a/crates/editor/src/code_context_menus.rs +++ b/crates/editor/src/code_context_menus.rs @@ -51,6 +51,8 @@ pub const MENU_ASIDE_MIN_WIDTH: Pixels = px(260.); pub const MENU_ASIDE_MAX_WIDTH: Pixels = px(500.); pub const COMPLETION_MENU_MIN_WIDTH: Pixels = px(280.); pub const COMPLETION_MENU_MAX_WIDTH: Pixels = px(540.); +pub const CODE_ACTION_MENU_MIN_WIDTH: Pixels = px(220.); +pub const CODE_ACTION_MENU_MAX_WIDTH: Pixels = px(540.); // Constants for the markdown cache. The purpose of this cache is to reduce flickering due to // documentation not yet being parsed. @@ -179,7 +181,7 @@ impl CodeContextMenu { ) -> Option { match self { CodeContextMenu::Completions(menu) => menu.render_aside(max_size, window, cx), - CodeContextMenu::CodeActions(_) => None, + CodeContextMenu::CodeActions(menu) => menu.render_aside(max_size, window, cx), } } @@ -1419,26 +1421,6 @@ pub enum CodeActionsItem { } impl CodeActionsItem { - fn as_task(&self) -> Option<&ResolvedTask> { - let Self::Task(_, task) = self else { - return None; - }; - Some(task) - } - - fn as_code_action(&self) -> Option<&CodeAction> { - let Self::CodeAction { action, .. } = self else { - return None; - }; - Some(action) - } - fn as_debug_scenario(&self) -> Option<&DebugScenario> { - let Self::DebugScenario(scenario) = self else { - return None; - }; - Some(scenario) - } - pub fn label(&self) -> String { match self { Self::CodeAction { action, .. } => action.lsp_action.title().to_owned(), @@ -1446,6 +1428,14 @@ impl CodeActionsItem { Self::DebugScenario(scenario) => scenario.label.to_string(), } } + + pub fn menu_label(&self) -> String { + match self { + Self::CodeAction { action, .. } => action.lsp_action.title().replace("\n", ""), + Self::Task(_, task) => task.resolved_label.replace("\n", ""), + Self::DebugScenario(scenario) => format!("debug: {}", scenario.label), + } + } } pub struct CodeActionsMenu { @@ -1555,60 +1545,33 @@ impl CodeActionsMenu { let item_ix = range.start + ix; let selected = item_ix == selected_item; let colors = cx.theme().colors(); - div().min_w(px(220.)).max_w(px(540.)).child( - ListItem::new(item_ix) - .inset(true) - .toggle_state(selected) - .when_some(action.as_code_action(), |this, action| { - this.child( - h_flex() - .overflow_hidden() - .when(is_quick_action_bar, |this| this.text_ui(cx)) - .child( - // TASK: It would be good to make lsp_action.title a SharedString to avoid allocating here. - action.lsp_action.title().replace("\n", ""), - ) - .when(selected, |this| { - this.text_color(colors.text_accent) - }), - ) - }) - .when_some(action.as_task(), |this, task| { - this.child( - h_flex() - .overflow_hidden() - .when(is_quick_action_bar, |this| this.text_ui(cx)) - .child(task.resolved_label.replace("\n", "")) - .when(selected, |this| { - this.text_color(colors.text_accent) - }), - ) - }) - .when_some(action.as_debug_scenario(), |this, scenario| { - this.child( - h_flex() - .overflow_hidden() - .when(is_quick_action_bar, |this| this.text_ui(cx)) - .child("debug: ") - .child(scenario.label.clone()) - .when(selected, |this| { - this.text_color(colors.text_accent) - }), - ) - }) - .on_click(cx.listener(move |editor, _, window, cx| { - cx.stop_propagation(); - if let Some(task) = editor.confirm_code_action( - &ConfirmCodeAction { - item_ix: Some(item_ix), - }, - window, - cx, - ) { - task.detach_and_log_err(cx) - } - })), - ) + + ListItem::new(item_ix) + .inset(true) + .toggle_state(selected) + .overflow_x() + .child( + div() + .min_w(CODE_ACTION_MENU_MIN_WIDTH) + .max_w(CODE_ACTION_MENU_MAX_WIDTH) + .overflow_hidden() + .text_ellipsis() + .when(is_quick_action_bar, |this| this.text_ui(cx)) + .when(selected, |this| this.text_color(colors.text_accent)) + .child(action.menu_label()), + ) + .on_click(cx.listener(move |editor, _, window, cx| { + cx.stop_propagation(); + if let Some(task) = editor.confirm_code_action( + &ConfirmCodeAction { + item_ix: Some(item_ix), + }, + window, + cx, + ) { + task.detach_and_log_err(cx) + } + })) }) .collect() }), @@ -1635,4 +1598,42 @@ impl CodeActionsMenu { Popover::new().child(list).into_any_element() } + + fn render_aside( + &mut self, + max_size: Size, + window: &mut Window, + _cx: &mut Context, + ) -> Option { + let Some(action) = self.actions.get(self.selected_item) else { + return None; + }; + + let label = action.menu_label(); + let text_system = window.text_system(); + let mut line_wrapper = text_system.line_wrapper( + window.text_style().font(), + window.text_style().font_size.to_pixels(window.rem_size()), + ); + let is_truncated = + line_wrapper.should_truncate_line(&label, CODE_ACTION_MENU_MAX_WIDTH, "…"); + + if is_truncated.is_none() { + return None; + } + + Some( + Popover::new() + .child( + div() + .child(label) + .id("code_actions_menu_extended") + .px(MENU_ASIDE_X_PADDING / 2.) + .max_w(max_size.width) + .max_h(max_size.height) + .occlude(), + ) + .into_any_element(), + ) + } } diff --git a/crates/gpui/src/text_system/line_wrapper.rs b/crates/gpui/src/text_system/line_wrapper.rs index e4e18671a3d85c2f55abd8f8a61ec80833dabdf5..95cd55d04443c6b2c351bf8533ccb57d49e8dcd9 100644 --- a/crates/gpui/src/text_system/line_wrapper.rs +++ b/crates/gpui/src/text_system/line_wrapper.rs @@ -128,22 +128,21 @@ impl LineWrapper { }) } - /// Truncate a line of text to the given width with this wrapper's font and font size. - pub fn truncate_line<'a>( + /// Determines if a line should be truncated based on its width. + pub fn should_truncate_line( &mut self, - line: SharedString, + line: &str, truncate_width: Pixels, truncation_suffix: &str, - runs: &'a [TextRun], - ) -> (SharedString, Cow<'a, [TextRun]>) { + ) -> Option { let mut width = px(0.); - let mut suffix_width = truncation_suffix + let suffix_width = truncation_suffix .chars() .map(|c| self.width_for_char(c)) .fold(px(0.0), |a, x| a + x); - let mut char_indices = line.char_indices(); let mut truncate_ix = 0; - for (ix, c) in char_indices { + + for (ix, c) in line.char_indices() { if width + suffix_width < truncate_width { truncate_ix = ix; } @@ -152,16 +151,32 @@ impl LineWrapper { width += char_width; if width.floor() > truncate_width { - let result = - SharedString::from(format!("{}{}", &line[..truncate_ix], truncation_suffix)); - let mut runs = runs.to_vec(); - update_runs_after_truncation(&result, truncation_suffix, &mut runs); - - return (result, Cow::Owned(runs)); + return Some(truncate_ix); } } - (line, Cow::Borrowed(runs)) + None + } + + /// Truncate a line of text to the given width with this wrapper's font and font size. + pub fn truncate_line<'a>( + &mut self, + line: SharedString, + truncate_width: Pixels, + truncation_suffix: &str, + runs: &'a [TextRun], + ) -> (SharedString, Cow<'a, [TextRun]>) { + if let Some(truncate_ix) = + self.should_truncate_line(&line, truncate_width, truncation_suffix) + { + let result = + SharedString::from(format!("{}{}", &line[..truncate_ix], truncation_suffix)); + let mut runs = runs.to_vec(); + update_runs_after_truncation(&result, truncation_suffix, &mut runs); + (result, Cow::Owned(runs)) + } else { + (line, Cow::Borrowed(runs)) + } } /// Any character in this list should be treated as a word character, From 1b6d588413460823a6dcfb53319c25ea2e8a1641 Mon Sep 17 00:00:00 2001 From: Marshall Bowers Date: Thu, 18 Dec 2025 13:42:28 -0500 Subject: [PATCH 517/621] danger: Deny conventional commits in PR titles (#45283) This PR upgrades `danger-plugin-pr-hygiene` to v0.7.0 so that we can have Danger deny conventional commits in PR titles. Release Notes: - N/A --- script/danger/dangerfile.ts | 3 +++ script/danger/package.json | 2 +- script/danger/pnpm-lock.yaml | 10 +++++----- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/script/danger/dangerfile.ts b/script/danger/dangerfile.ts index 88dc5c5e71c640a83315ac5f1b14c216763023fd..7151985021f3fdfb75c01c6e2f8c964fa51d3740 100644 --- a/script/danger/dangerfile.ts +++ b/script/danger/dangerfile.ts @@ -6,6 +6,9 @@ prHygiene({ rules: { // Don't enable this rule just yet, as it can have false positives. useImperativeMood: "off", + noConventionalCommits: { + bannedTypes: ["feat", "fix", "style", "refactor", "perf", "test", "chore", "build", "revert"], + }, }, }); diff --git a/script/danger/package.json b/script/danger/package.json index eaa1035e89c97da8ef2089e97eb638d649ee6877..74862c142468c1297a1d4aad8dcc468b6ddf5798 100644 --- a/script/danger/package.json +++ b/script/danger/package.json @@ -8,6 +8,6 @@ }, "devDependencies": { "danger": "13.0.4", - "danger-plugin-pr-hygiene": "0.6.1" + "danger-plugin-pr-hygiene": "0.7.0" } } diff --git a/script/danger/pnpm-lock.yaml b/script/danger/pnpm-lock.yaml index fd6b3f66acb627d57520e4ca928cc8ce2793b4b9..942d027cc80bf5d81ffa8b5bf739963430e939a3 100644 --- a/script/danger/pnpm-lock.yaml +++ b/script/danger/pnpm-lock.yaml @@ -12,8 +12,8 @@ importers: specifier: 13.0.4 version: 13.0.4 danger-plugin-pr-hygiene: - specifier: 0.6.1 - version: 0.6.1 + specifier: 0.7.0 + version: 0.7.0 packages: @@ -134,8 +134,8 @@ packages: core-js@3.45.1: resolution: {integrity: sha512-L4NPsJlCfZsPeXukyzHFlg/i7IIVwHSItR0wg0FLNqYClJ4MQYTYLbC7EkjKYRLZF2iof2MUgN0EGy7MdQFChg==} - danger-plugin-pr-hygiene@0.6.1: - resolution: {integrity: sha512-nb+iUQvirE3BlKXI1WoOND6sujyGzHar590mJm5tt4RLi65HXFaU5hqONxgDoWFujJNHYnXse9yaZdxnxEi4QA==} + danger-plugin-pr-hygiene@0.7.0: + resolution: {integrity: sha512-YDWhEodP0fg/t9YO3SxufWS9j1Rcxbig+1flTlUlojBDFiKQyVmaj8PIvnJxJItjHWTlNKI9wMSRq5vUql6zyA==} danger@13.0.4: resolution: {integrity: sha512-IAdQ5nSJyIs4zKj6AN35ixt2B0Ce3WZUm3IFe/CMnL/Op7wV7IGg4D348U0EKNaNPP58QgXbdSk9pM+IXP1QXg==} @@ -573,7 +573,7 @@ snapshots: core-js@3.45.1: {} - danger-plugin-pr-hygiene@0.6.1: {} + danger-plugin-pr-hygiene@0.7.0: {} danger@13.0.4: dependencies: From 413f4ea49c993ed531c32a4743c07850dda2f63f Mon Sep 17 00:00:00 2001 From: Peter Tripp Date: Thu, 18 Dec 2025 14:05:14 -0500 Subject: [PATCH 518/621] Redact environment variables from language server spawn errors (#44783) Redact environment variables from zed logs when lsp fails to spawn. Release Notes: - N/A --- crates/project/src/lsp_store.rs | 8 ++++++-- crates/util/src/redact.rs | 34 +++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/crates/project/src/lsp_store.rs b/crates/project/src/lsp_store.rs index 6696ec8c4c280199a55d098ab63a321f126eea5e..5093b6977a1bffe82339ede00d2e6e4b4b14b4c1 100644 --- a/crates/project/src/lsp_store.rs +++ b/crates/project/src/lsp_store.rs @@ -128,6 +128,7 @@ use util::{ ConnectionResult, ResultExt as _, debug_panic, defer, maybe, merge_json_value_into, paths::{PathStyle, SanitizedPath}, post_inc, + redact::redact_command, rel_path::RelPath, }; @@ -577,9 +578,12 @@ impl LocalLspStore { }, }, ); - log::error!("Failed to start language server {server_name:?}: {err:?}"); + log::error!( + "Failed to start language server {server_name:?}: {}", + redact_command(&format!("{err:?}")) + ); if !log.is_empty() { - log::error!("server stderr: {log}"); + log::error!("server stderr: {}", redact_command(&log)); } None } diff --git a/crates/util/src/redact.rs b/crates/util/src/redact.rs index 6b297dfb58bb0b4537d4032d8f9cf4db845f9d78..ad11f7618b1cf57c27e7367845cf66e9d0e6bd0b 100644 --- a/crates/util/src/redact.rs +++ b/crates/util/src/redact.rs @@ -1,3 +1,9 @@ +use std::sync::LazyLock; + +static REDACT_REGEX: LazyLock = LazyLock::new(|| { + regex::Regex::new(r#"([A-Z_][A-Z0-9_]*)=("(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|\S+)"#).unwrap() +}); + /// Whether a given environment variable name should have its value redacted pub fn should_redact(env_var_name: &str) -> bool { const REDACTED_SUFFIXES: &[&str] = &[ @@ -13,3 +19,31 @@ pub fn should_redact(env_var_name: &str) -> bool { .iter() .any(|suffix| env_var_name.ends_with(suffix)) } + +/// Redact a string which could include a command with environment variables +pub fn redact_command(command: &str) -> String { + REDACT_REGEX + .replace_all(command, |caps: ®ex::Captures| { + let var_name = &caps[1]; + let value = &caps[2]; + if should_redact(var_name) { + format!(r#"{}="[REDACTED]""#, var_name) + } else { + format!("{}={}", var_name, value) + } + }) + .to_string() +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_redact_string_with_multiple_env_vars() { + let input = r#"failed to spawn command cd "/code/something" && ANTHROPIC_API_KEY="sk-ant-api03-WOOOO" COMMAND_MODE="unix2003" GEMINI_API_KEY="AIGEMINIFACE" HOME="/Users/foo""#; + let result = redact_command(input); + let expected = r#"failed to spawn command cd "/code/something" && ANTHROPIC_API_KEY="[REDACTED]" COMMAND_MODE="unix2003" GEMINI_API_KEY="[REDACTED]" HOME="/Users/foo""#; + assert_eq!(result, expected); + } +} From d2bbfbb3bf80b322adff20a28e71477455730054 Mon Sep 17 00:00:00 2001 From: Julia Ryan Date: Thu, 18 Dec 2025 11:09:40 -0800 Subject: [PATCH 519/621] lsp: Broadcast our capability for `MessageActionItem`s (#45047) Closes #37902 Release Notes: - Enable LSP Message action items for more language servers. These are interactive prompts, often for things like downloading build inputs for a project. --- crates/lsp/src/lsp.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/lsp/src/lsp.rs b/crates/lsp/src/lsp.rs index 9ff6e245c49d771c162ca55fa98bbd7ca37d7bd0..faa094153d4a26fb1a2b96360f2691989e81aad9 100644 --- a/crates/lsp/src/lsp.rs +++ b/crates/lsp/src/lsp.rs @@ -882,7 +882,9 @@ impl LanguageServer { window: Some(WindowClientCapabilities { work_done_progress: Some(true), show_message: Some(ShowMessageRequestClientCapabilities { - message_action_item: None, + message_action_item: Some(MessageActionItemCapabilities { + additional_properties_support: Some(true), + }), }), ..WindowClientCapabilities::default() }), From af589ff25fa817a58cfffddaf0b5dcfb965dd3f9 Mon Sep 17 00:00:00 2001 From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Date: Thu, 18 Dec 2025 17:49:17 -0300 Subject: [PATCH 520/621] agent_ui: Simplify timestamp display (#45296) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR simplifies how we display thread timestamps in the agent panel's history view. For threads that are older-than-yesterday, we just show how many days ago that thread was had in. Hovering over the thread item shows you both the title and the full date, if needed (time and date). Screenshot 2025-12-18 at 5  24@2x Release Notes: - N/A --- crates/agent_ui/src/acp/thread_history.rs | 24 ++++++++++++++++++++--- crates/agent_ui_v2/src/thread_history.rs | 24 ++++++++++++++++++++--- 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/crates/agent_ui/src/acp/thread_history.rs b/crates/agent_ui/src/acp/thread_history.rs index 1aa89b35d34c8c0543a56014fee7766b6de66eb2..a885e52a05e342dbcd81d28a970560b3047ef9c0 100644 --- a/crates/agent_ui/src/acp/thread_history.rs +++ b/crates/agent_ui/src/acp/thread_history.rs @@ -1,7 +1,7 @@ use crate::acp::AcpThreadView; use crate::{AgentPanel, RemoveHistory, RemoveSelectedThread}; use agent::{HistoryEntry, HistoryStore}; -use chrono::{Datelike as _, Local, NaiveDate, TimeDelta}; +use chrono::{Datelike as _, Local, NaiveDate, TimeDelta, Utc}; use editor::{Editor, EditorEvent}; use fuzzy::StringMatchCandidate; use gpui::{ @@ -402,7 +402,22 @@ impl AcpThreadHistory { let selected = ix == self.selected_index; let hovered = Some(ix) == self.hovered_index; let timestamp = entry.updated_at().timestamp(); - let thread_timestamp = format.format_timestamp(timestamp, self.local_timezone); + + let display_text = match format { + EntryTimeFormat::DateAndTime => { + let entry_time = entry.updated_at(); + let now = Utc::now(); + let duration = now.signed_duration_since(entry_time); + let days = duration.num_days(); + + format!("{}d", days) + } + EntryTimeFormat::TimeOnly => format.format_timestamp(timestamp, self.local_timezone), + }; + + let title = entry.title().clone(); + let full_date = + EntryTimeFormat::DateAndTime.format_timestamp(timestamp, self.local_timezone); h_flex() .w_full() @@ -423,11 +438,14 @@ impl AcpThreadHistory { .truncate(), ) .child( - Label::new(thread_timestamp) + Label::new(display_text) .color(Color::Muted) .size(LabelSize::XSmall), ), ) + .tooltip(move |_, cx| { + Tooltip::with_meta(title.clone(), None, full_date.clone(), cx) + }) .on_hover(cx.listener(move |this, is_hovered, _window, cx| { if *is_hovered { this.hovered_index = Some(ix); diff --git a/crates/agent_ui_v2/src/thread_history.rs b/crates/agent_ui_v2/src/thread_history.rs index 8f6626814902a9489536439e90041437a527e151..0e379a24fc3047e6a686046ea16a94ef25efb52c 100644 --- a/crates/agent_ui_v2/src/thread_history.rs +++ b/crates/agent_ui_v2/src/thread_history.rs @@ -1,5 +1,5 @@ use agent::{HistoryEntry, HistoryStore}; -use chrono::{Datelike as _, Local, NaiveDate, TimeDelta}; +use chrono::{Datelike as _, Local, NaiveDate, TimeDelta, Utc}; use editor::{Editor, EditorEvent}; use fuzzy::StringMatchCandidate; use gpui::{ @@ -411,7 +411,22 @@ impl AcpThreadHistory { let selected = ix == self.selected_index; let hovered = Some(ix) == self.hovered_index; let timestamp = entry.updated_at().timestamp(); - let thread_timestamp = format.format_timestamp(timestamp, self.local_timezone); + + let display_text = match format { + EntryTimeFormat::DateAndTime => { + let entry_time = entry.updated_at(); + let now = Utc::now(); + let duration = now.signed_duration_since(entry_time); + let days = duration.num_days(); + + format!("{}d", days) + } + EntryTimeFormat::TimeOnly => format.format_timestamp(timestamp, self.local_timezone), + }; + + let title = entry.title().clone(); + let full_date = + EntryTimeFormat::DateAndTime.format_timestamp(timestamp, self.local_timezone); h_flex() .w_full() @@ -432,11 +447,14 @@ impl AcpThreadHistory { .truncate(), ) .child( - Label::new(thread_timestamp) + Label::new(display_text) .color(Color::Muted) .size(LabelSize::XSmall), ), ) + .tooltip(move |_, cx| { + Tooltip::with_meta(title.clone(), None, full_date.clone(), cx) + }) .on_hover(cx.listener(move |this, is_hovered, _window, cx| { if *is_hovered { this.hovered_index = Some(ix); From 8516d81e132d969651e453c6423314fac59961e0 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Thu, 18 Dec 2025 16:32:59 -0500 Subject: [PATCH 521/621] Fix display name for Ollama models (#45287) Closes #43646 Release Notes: - Fixed display name for Ollama models --- crates/language_models/src/provider/ollama.rs | 137 ++++++++++++++---- 1 file changed, 110 insertions(+), 27 deletions(-) diff --git a/crates/language_models/src/provider/ollama.rs b/crates/language_models/src/provider/ollama.rs index c5a8bf41711563110cbcb5d81698b7029b04a713..860d635b6ac704c2762023c463432bebae08d4a5 100644 --- a/crates/language_models/src/provider/ollama.rs +++ b/crates/language_models/src/provider/ollama.rs @@ -249,33 +249,7 @@ impl LanguageModelProvider for OllamaLanguageModelProvider { } // Override with available models from settings - for setting_model in &OllamaLanguageModelProvider::settings(cx).available_models { - let setting_base = setting_model.name.split(':').next().unwrap(); - if let Some(model) = models - .values_mut() - .find(|m| m.name.split(':').next().unwrap() == setting_base) - { - model.max_tokens = setting_model.max_tokens; - model.display_name = setting_model.display_name.clone(); - model.keep_alive = setting_model.keep_alive.clone(); - model.supports_tools = setting_model.supports_tools; - model.supports_vision = setting_model.supports_images; - model.supports_thinking = setting_model.supports_thinking; - } else { - models.insert( - setting_model.name.clone(), - ollama::Model { - name: setting_model.name.clone(), - display_name: setting_model.display_name.clone(), - max_tokens: setting_model.max_tokens, - keep_alive: setting_model.keep_alive.clone(), - supports_tools: setting_model.supports_tools, - supports_vision: setting_model.supports_images, - supports_thinking: setting_model.supports_thinking, - }, - ); - } - } + merge_settings_into_models(&mut models, &settings.available_models); let mut models = models .into_values() @@ -921,6 +895,35 @@ impl Render for ConfigurationView { } } +fn merge_settings_into_models( + models: &mut HashMap, + available_models: &[AvailableModel], +) { + for setting_model in available_models { + if let Some(model) = models.get_mut(&setting_model.name) { + model.max_tokens = setting_model.max_tokens; + model.display_name = setting_model.display_name.clone(); + model.keep_alive = setting_model.keep_alive.clone(); + model.supports_tools = setting_model.supports_tools; + model.supports_vision = setting_model.supports_images; + model.supports_thinking = setting_model.supports_thinking; + } else { + models.insert( + setting_model.name.clone(), + ollama::Model { + name: setting_model.name.clone(), + display_name: setting_model.display_name.clone(), + max_tokens: setting_model.max_tokens, + keep_alive: setting_model.keep_alive.clone(), + supports_tools: setting_model.supports_tools, + supports_vision: setting_model.supports_images, + supports_thinking: setting_model.supports_thinking, + }, + ); + } + } +} + fn tool_into_ollama(tool: LanguageModelRequestTool) -> ollama::OllamaTool { ollama::OllamaTool::Function { function: OllamaFunctionTool { @@ -930,3 +933,83 @@ fn tool_into_ollama(tool: LanguageModelRequestTool) -> ollama::OllamaTool { }, } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_merge_settings_preserves_display_names_for_similar_models() { + // Regression test for https://github.com/zed-industries/zed/issues/43646 + // When multiple models share the same base name (e.g., qwen2.5-coder:1.5b and qwen2.5-coder:3b), + // each model should get its own display_name from settings, not a random one. + + let mut models: HashMap = HashMap::new(); + models.insert( + "qwen2.5-coder:1.5b".to_string(), + ollama::Model { + name: "qwen2.5-coder:1.5b".to_string(), + display_name: None, + max_tokens: 4096, + keep_alive: None, + supports_tools: None, + supports_vision: None, + supports_thinking: None, + }, + ); + models.insert( + "qwen2.5-coder:3b".to_string(), + ollama::Model { + name: "qwen2.5-coder:3b".to_string(), + display_name: None, + max_tokens: 4096, + keep_alive: None, + supports_tools: None, + supports_vision: None, + supports_thinking: None, + }, + ); + + let available_models = vec![ + AvailableModel { + name: "qwen2.5-coder:1.5b".to_string(), + display_name: Some("QWEN2.5 Coder 1.5B".to_string()), + max_tokens: 5000, + keep_alive: None, + supports_tools: Some(true), + supports_images: None, + supports_thinking: None, + }, + AvailableModel { + name: "qwen2.5-coder:3b".to_string(), + display_name: Some("QWEN2.5 Coder 3B".to_string()), + max_tokens: 6000, + keep_alive: None, + supports_tools: Some(true), + supports_images: None, + supports_thinking: None, + }, + ]; + + merge_settings_into_models(&mut models, &available_models); + + let model_1_5b = models + .get("qwen2.5-coder:1.5b") + .expect("1.5b model missing"); + let model_3b = models.get("qwen2.5-coder:3b").expect("3b model missing"); + + assert_eq!( + model_1_5b.display_name, + Some("QWEN2.5 Coder 1.5B".to_string()), + "1.5b model should have its own display_name" + ); + assert_eq!(model_1_5b.max_tokens, 5000); + + assert_eq!( + model_3b.display_name, + Some("QWEN2.5 Coder 3B".to_string()), + "3b model should have its own display_name" + ); + assert_eq!(model_3b.max_tokens, 6000); + } +} From ca90b8555dc1ff1315ded1438664cff07338ad8b Mon Sep 17 00:00:00 2001 From: Marshall Bowers Date: Thu, 18 Dec 2025 16:42:28 -0500 Subject: [PATCH 522/621] docs: Remove local collaboration docs (#45301) This PR removes the docs for running Collab locally, as they are outdated and don't reflect the current state of affairs. Release Notes: - N/A --- README.md | 1 - docs/src/SUMMARY.md | 1 - docs/src/development.md | 4 - docs/src/development/linux.md | 4 - docs/src/development/local-collaboration.md | 207 -------------------- docs/src/development/macos.md | 4 - docs/src/development/windows.md | 4 - 7 files changed, 225 deletions(-) delete mode 100644 docs/src/development/local-collaboration.md diff --git a/README.md b/README.md index d3a5fd20526e5eae6826241dce2bb94e8533ecb3..866762c8c9139666993c2e29d9682966106c516b 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,6 @@ Other platforms are not yet available: - [Building Zed for macOS](./docs/src/development/macos.md) - [Building Zed for Linux](./docs/src/development/linux.md) - [Building Zed for Windows](./docs/src/development/windows.md) -- [Running Collaboration Locally](./docs/src/development/local-collaboration.md) ### Contributing diff --git a/docs/src/SUMMARY.md b/docs/src/SUMMARY.md index 1f9c5750ea76b35a2f7f5464b7b6684401108d2b..a82ddac990c4379df03db2b4bdcd8272eb8715e9 100644 --- a/docs/src/SUMMARY.md +++ b/docs/src/SUMMARY.md @@ -177,7 +177,6 @@ - [Linux](./development/linux.md) - [Windows](./development/windows.md) - [FreeBSD](./development/freebsd.md) - - [Local Collaboration](./development/local-collaboration.md) - [Using Debuggers](./development/debuggers.md) - [Performance](./performance.md) - [Glossary](./development/glossary.md) diff --git a/docs/src/development.md b/docs/src/development.md index 31bb245ac42f80c830a0faba405323d1097e3f51..8f341dbb1506d4a6fa6c3ffa21960191ec5ecfcf 100644 --- a/docs/src/development.md +++ b/docs/src/development.md @@ -6,10 +6,6 @@ See the platform-specific instructions for building Zed from source: - [Linux](./development/linux.md) - [Windows](./development/windows.md) -If you'd like to develop collaboration features, additionally see: - -- [Local Collaboration](./development/local-collaboration.md) - ## Keychain access Zed stores secrets in the system keychain. diff --git a/docs/src/development/linux.md b/docs/src/development/linux.md index df3b840fa17a547efd4324f3bdaa119b8ade8738..3269d4b4dd51b224ab2b0cf7cfe15333232d0915 100644 --- a/docs/src/development/linux.md +++ b/docs/src/development/linux.md @@ -16,10 +16,6 @@ Clone down the [Zed repository](https://github.com/zed-industries/zed). If you prefer to install the system libraries manually, you can find the list of required packages in the `script/linux` file. -### Backend Dependencies (optional) {#backend-dependencies} - -If you are looking to develop Zed collaboration features using a local collaboration server, please see: [Local Collaboration](./local-collaboration.md) docs. - ### Linkers {#linker} On Linux, Rust's default linker is [LLVM's `lld`](https://blog.rust-lang.org/2025/09/18/Rust-1.90.0/). Alternative linkers, especially [Wild](https://github.com/davidlattimore/wild) and [Mold](https://github.com/rui314/mold) can significantly improve clean and incremental build time. diff --git a/docs/src/development/local-collaboration.md b/docs/src/development/local-collaboration.md deleted file mode 100644 index 393c6f0bbf797cf9aa86d297633734444bdfb328..0000000000000000000000000000000000000000 --- a/docs/src/development/local-collaboration.md +++ /dev/null @@ -1,207 +0,0 @@ -# Local Collaboration - -1. Ensure you have access to our cloud infrastructure. If you don't have access, you can't collaborate locally at this time. - -2. Make sure you've installed Zed's dependencies for your platform: - -- [macOS](#macos) -- [Linux](#linux) -- [Windows](#backend-windows) - -Note that `collab` can be compiled only with MSVC toolchain on Windows - -3. Clone down our cloud repository and follow the instructions in the cloud README - -4. Setup the local database for your platform: - -- [macOS & Linux](#database-unix) -- [Windows](#database-windows) - -5. Run collab: - -- [macOS & Linux](#run-collab-unix) -- [Windows](#run-collab-windows) - -## Backend Dependencies - -If you are developing collaborative features of Zed, you'll need to install the dependencies of zed's `collab` server: - -- PostgreSQL -- LiveKit -- Foreman - -You can install these dependencies natively or run them under Docker. - -### macOS - -1. Install [Postgres.app](https://postgresapp.com) or [postgresql via homebrew](https://formulae.brew.sh/formula/postgresql@15): - - ```sh - brew install postgresql@15 - ``` - -2. Install [Livekit](https://formulae.brew.sh/formula/livekit) and [Foreman](https://formulae.brew.sh/formula/foreman) - - ```sh - brew install livekit foreman - ``` - -- Follow the steps in the [collab README](https://github.com/zed-industries/zed/blob/main/crates/collab/README.md) to configure the Postgres database for integration tests - -Alternatively, if you have [Docker](https://www.docker.com/) installed you can bring up all the `collab` dependencies using Docker Compose. - -### Linux - -1. Install [Postgres](https://www.postgresql.org/download/linux/) - - ```sh - sudo apt-get install postgresql # Ubuntu/Debian - sudo pacman -S postgresql # Arch Linux - sudo dnf install postgresql postgresql-server # RHEL/Fedora - sudo zypper install postgresql postgresql-server # OpenSUSE - ``` - -2. Install [Livekit](https://github.com/livekit/livekit-cli) - - ```sh - curl -sSL https://get.livekit.io/cli | bash - ``` - -3. Install [Foreman](https://theforeman.org/manuals/3.15/quickstart_guide.html) - -### Windows {#backend-windows} - -> This section is still in development. The instructions are not yet complete. - -- Install [Postgres](https://www.postgresql.org/download/windows/) -- Install [Livekit](https://github.com/livekit/livekit), optionally you can add the `livekit-server` binary to your `PATH`. - -Alternatively, if you have [Docker](https://www.docker.com/) installed you can bring up all the `collab` dependencies using Docker Compose. - -### Docker {#Docker} - -If you have docker or podman available, you can run the backend dependencies inside containers with Docker Compose: - -```sh -docker compose up -d -``` - -## Database setup - -Before you can run the `collab` server locally, you'll need to set up a `zed` Postgres database. - -### On macOS and Linux {#database-unix} - -```sh -script/bootstrap -``` - -This script will set up the `zed` Postgres database, and populate it with some users. It requires internet access, because it fetches some users from the GitHub API. - -The script will seed the database with various content defined by: - -```sh -cat crates/collab/seed.default.json -``` - -To use a different set of admin users, you can create your own version of that json file and export the `SEED_PATH` environment variable. Note that the usernames listed in the admins list currently must correspond to valid GitHub users. - -```json [settings] -{ - "admins": ["admin1", "admin2"], - "channels": ["zed"] -} -``` - -### On Windows {#database-windows} - -```powershell -.\script\bootstrap.ps1 -``` - -## Testing collaborative features locally - -### On macOS and Linux {#run-collab-unix} - -Ensure that Postgres is configured and running, then run Zed's collaboration server and the `livekit` dev server: - -```sh -foreman start -# OR -docker compose up -``` - -Alternatively, if you're not testing voice and screenshare, you can just run `collab` and `cloud`, and not the `livekit` dev server: - -```sh -cargo run -p collab -- serve all -``` - -```sh -cd ../cloud; cargo make dev -``` - -In a new terminal, run two or more instances of Zed. - -```sh -script/zed-local -3 -``` - -This script starts one to four instances of Zed, depending on the `-2`, `-3` or `-4` flags. Each instance will be connected to the local `collab` server, signed in as a different user from `.admins.json` or `.admins.default.json`. - -### On Windows {#run-collab-windows} - -Since `foreman` is not available on Windows, you can run the following commands in separate terminals: - -```powershell -cargo run --package=collab -- serve all -``` - -If you have added the `livekit-server` binary to your `PATH`, you can run: - -```powershell -livekit-server --dev -``` - -Otherwise, - -```powershell -.\path\to\livekit-serve.exe --dev -``` - -You'll also need to start the cloud server: - -```powershell -cd ..\cloud; cargo make dev -``` - -In a new terminal, run two or more instances of Zed. - -```powershell -node .\script\zed-local -2 -``` - -Note that this requires `node.exe` to be in your `PATH`. - -## Running a local collab server - -> [!NOTE] -> Because of recent changes to our authentication system, Zed will not be able to authenticate itself with, and therefore use, a local collab server. - -If you want to run your own version of the zed collaboration service, you can, but note that this is still under development, and there is no support for authentication nor extensions. - -Configuration is done through environment variables. By default it will read the configuration from [`.env.toml`](https://github.com/zed-industries/zed/blob/main/crates/collab/.env.toml) and you should use that as a guide for setting this up. - -By default Zed assumes that the DATABASE_URL is a Postgres database, but you can make it use Sqlite by compiling with `--features sqlite` and using a sqlite DATABASE_URL with `?mode=rwc`. - -To authenticate you must first configure the server by creating a seed.json file that contains at a minimum your github handle. This will be used to create the user on demand. - -```json [settings] -{ - "admins": ["nathansobo"] -} -``` - -By default the collab server will seed the database when first creating it, but if you want to add more users you can explicitly reseed them with `SEED_PATH=./seed.json cargo run -p collab seed` - -Then when running the zed client you must specify two environment variables, `ZED_ADMIN_API_TOKEN` (which should match the value of `API_TOKEN` in .env.toml) and `ZED_IMPERSONATE` (which should match one of the users in your seed.json) diff --git a/docs/src/development/macos.md b/docs/src/development/macos.md index 9c99e5f8da62594c774e109e15f914788f51793d..9e2908dd6e393acd8d3903d86743dcbc4e9ae9eb 100644 --- a/docs/src/development/macos.md +++ b/docs/src/development/macos.md @@ -31,10 +31,6 @@ Clone down the [Zed repository](https://github.com/zed-industries/zed). brew install cmake ``` -### Backend Dependencies (optional) {#backend-dependencies} - -If you are looking to develop Zed collaboration features using a local collaboration server, please see: [Local Collaboration](./local-collaboration.md) docs. - ## Building Zed from Source Once you have the dependencies installed, you can build Zed using [Cargo](https://doc.rust-lang.org/cargo/). diff --git a/docs/src/development/windows.md b/docs/src/development/windows.md index 17382e0bee5b97c2ffc2d74794cf3881a3cb98a1..509f30a05b45175f7e66026aec5b5d433b928e4d 100644 --- a/docs/src/development/windows.md +++ b/docs/src/development/windows.md @@ -66,10 +66,6 @@ The list can be obtained as follows: - Click on `More` in the `Installed` tab - Click on `Export configuration` -### Backend Dependencies (optional) {#backend-dependencies} - -If you are looking to develop Zed collaboration features using a local collaboration server, please see: [Local Collaboration](./local-collaboration.md) docs. - ### Notes You should modify the `pg_hba.conf` file in the `data` directory to use `trust` instead of `scram-sha-256` for the `host` method. Otherwise, the connection will fail with the error `password authentication failed`. The `pg_hba.conf` file typically locates at `C:\Program Files\PostgreSQL\17\data\pg_hba.conf`. After the modification, the file should look like this: From 0d74f982a5928e37d46ac5fc78232339ec85bc91 Mon Sep 17 00:00:00 2001 From: Marshall Bowers Date: Thu, 18 Dec 2025 16:52:34 -0500 Subject: [PATCH 523/621] danger: Upgrade `danger-plugin-pr-hygiene` to v0.7.1 (#45303) This PR upgrades `danger-plugin-pr-hygiene` to v0.7.1. Release Notes: - N/A --- script/danger/package.json | 2 +- script/danger/pnpm-lock.yaml | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/script/danger/package.json b/script/danger/package.json index 74862c142468c1297a1d4aad8dcc468b6ddf5798..be44da6233a1c5ee87f8445e13953031497acfa5 100644 --- a/script/danger/package.json +++ b/script/danger/package.json @@ -8,6 +8,6 @@ }, "devDependencies": { "danger": "13.0.4", - "danger-plugin-pr-hygiene": "0.7.0" + "danger-plugin-pr-hygiene": "0.7.1" } } diff --git a/script/danger/pnpm-lock.yaml b/script/danger/pnpm-lock.yaml index 942d027cc80bf5d81ffa8b5bf739963430e939a3..eea293cfed78fcf43ed926484b2f13b5b9c74843 100644 --- a/script/danger/pnpm-lock.yaml +++ b/script/danger/pnpm-lock.yaml @@ -12,8 +12,8 @@ importers: specifier: 13.0.4 version: 13.0.4 danger-plugin-pr-hygiene: - specifier: 0.7.0 - version: 0.7.0 + specifier: 0.7.1 + version: 0.7.1 packages: @@ -134,8 +134,8 @@ packages: core-js@3.45.1: resolution: {integrity: sha512-L4NPsJlCfZsPeXukyzHFlg/i7IIVwHSItR0wg0FLNqYClJ4MQYTYLbC7EkjKYRLZF2iof2MUgN0EGy7MdQFChg==} - danger-plugin-pr-hygiene@0.7.0: - resolution: {integrity: sha512-YDWhEodP0fg/t9YO3SxufWS9j1Rcxbig+1flTlUlojBDFiKQyVmaj8PIvnJxJItjHWTlNKI9wMSRq5vUql6zyA==} + danger-plugin-pr-hygiene@0.7.1: + resolution: {integrity: sha512-ll070nNaL3OeO2nooYWflPE/CRKLeq8GiH2C68u5zM3gW4gepH89GhVv0sYNNGLx4cYwa1zZ/TuiYYhC49z06Q==} danger@13.0.4: resolution: {integrity: sha512-IAdQ5nSJyIs4zKj6AN35ixt2B0Ce3WZUm3IFe/CMnL/Op7wV7IGg4D348U0EKNaNPP58QgXbdSk9pM+IXP1QXg==} @@ -573,7 +573,7 @@ snapshots: core-js@3.45.1: {} - danger-plugin-pr-hygiene@0.7.0: {} + danger-plugin-pr-hygiene@0.7.1: {} danger@13.0.4: dependencies: From 88f90c12ed1cf689c237661a7a870b57be203149 Mon Sep 17 00:00:00 2001 From: "Joseph T. Lyons" Date: Thu, 18 Dec 2025 16:59:21 -0500 Subject: [PATCH 524/621] Add language server version in a tooltip on language server hover (#45302) I wanted a way to make it easy to figure out which version of a language server Zed is running. Now, you get a tooltip when hovering on a language server in the Language Servers popover. SCR-20251218-ovln This PR also fixes a bug. We had existing code to open a tooltip on these language server entrees and display the language server message, which was never fully wired up for `CustomEntry`s. Now, in this PR, we will show show either version, message, or both, in the documentation aside, depending on what the server has given us. Mostly done with Droid (using GPT-5.2), with manual review and multiple follow ups to guide it into using existing patterns in the codebase, when it did something abnormal. Release Notes: - Added language server version in a tooltip on language server hover --------- Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> --- crates/language_tools/src/lsp_button.rs | 32 ++++++++++- crates/language_tools/src/lsp_log_view.rs | 9 +++ crates/lsp/src/lsp.rs | 8 +++ crates/project/src/lsp_store.rs | 4 ++ crates/ui/src/components/context_menu.rs | 68 ++++++++++++++--------- 5 files changed, 93 insertions(+), 28 deletions(-) diff --git a/crates/language_tools/src/lsp_button.rs b/crates/language_tools/src/lsp_button.rs index 335381c6f79d950498a0f0c1d330cb21c681f32e..7775586bf19539e13adc6b9df6d92914be6b7f21 100644 --- a/crates/language_tools/src/lsp_button.rs +++ b/crates/language_tools/src/lsp_button.rs @@ -127,6 +127,16 @@ impl LanguageServerState { return menu; }; + let server_versions = self + .lsp_store + .update(cx, |lsp_store, _| { + lsp_store + .language_server_statuses() + .map(|(server_id, status)| (server_id, status.server_version.clone())) + .collect::>() + }) + .unwrap_or_default(); + let mut first_button_encountered = false; for item in &self.items { if let LspMenuItem::ToggleServersButton { restart } = item { @@ -254,6 +264,22 @@ impl LanguageServerState { }; let server_name = server_info.name.clone(); + let server_version = server_versions + .get(&server_info.id) + .and_then(|version| version.clone()); + + let tooltip_text = match (&server_version, &message) { + (None, None) => None, + (Some(version), None) => { + Some(SharedString::from(format!("Version: {}", version.as_ref()))) + } + (None, Some(message)) => Some(message.clone()), + (Some(version), Some(message)) => Some(SharedString::from(format!( + "Version: {}\n\n{}", + version.as_ref(), + message.as_ref() + ))), + }; menu = menu.item(ContextMenuItem::custom_entry( move |_, _| { h_flex() @@ -355,11 +381,11 @@ impl LanguageServerState { } } }, - message.map(|server_message| { + tooltip_text.map(|tooltip_text| { DocumentationAside::new( DocumentationSide::Right, - DocumentationEdge::Bottom, - Rc::new(move |_| Label::new(server_message.clone()).into_any_element()), + DocumentationEdge::Top, + Rc::new(move |_| Label::new(tooltip_text.clone()).into_any_element()), ) }), )); diff --git a/crates/language_tools/src/lsp_log_view.rs b/crates/language_tools/src/lsp_log_view.rs index e34bbb46d35d5a524c08369fcc991dfe81865127..2b2575912ae4543d2bf3cbd0c6b667ace7c82e91 100644 --- a/crates/language_tools/src/lsp_log_view.rs +++ b/crates/language_tools/src/lsp_log_view.rs @@ -330,6 +330,8 @@ impl LspLogView { let server_info = format!( "* Server: {NAME} (id {ID}) +* Version: {VERSION} + * Binary: {BINARY} * Registered workspace folders: @@ -340,6 +342,12 @@ impl LspLogView { * Configuration: {CONFIGURATION}", NAME = info.status.name, ID = info.id, + VERSION = info + .status + .server_version + .as_ref() + .map(|version| version.as_ref()) + .unwrap_or("Unknown"), BINARY = info .status .binary @@ -1334,6 +1342,7 @@ impl ServerInfo { capabilities: server.capabilities(), status: LanguageServerStatus { name: server.name(), + server_version: server.version(), pending_work: Default::default(), has_pending_diagnostic_updates: false, progress_tokens: Default::default(), diff --git a/crates/lsp/src/lsp.rs b/crates/lsp/src/lsp.rs index faa094153d4a26fb1a2b96360f2691989e81aad9..36938f62a3048b87dd890ca6e7ca8fc2499689e4 100644 --- a/crates/lsp/src/lsp.rs +++ b/crates/lsp/src/lsp.rs @@ -89,6 +89,7 @@ pub struct LanguageServer { outbound_tx: channel::Sender, notification_tx: channel::Sender, name: LanguageServerName, + version: Option, process_name: Arc, binary: LanguageServerBinary, capabilities: RwLock, @@ -501,6 +502,7 @@ impl LanguageServer { response_handlers, io_handlers, name: server_name, + version: None, process_name: binary .path .file_name() @@ -925,6 +927,7 @@ impl LanguageServer { ) })?; if let Some(info) = response.server_info { + self.version = info.version.map(SharedString::from); self.process_name = info.name.into(); } self.capabilities = RwLock::new(response.capabilities); @@ -1155,6 +1158,11 @@ impl LanguageServer { self.name.clone() } + /// Get the version of the running language server. + pub fn version(&self) -> Option { + self.version.clone() + } + pub fn process_name(&self) -> &str { &self.process_name } diff --git a/crates/project/src/lsp_store.rs b/crates/project/src/lsp_store.rs index 5093b6977a1bffe82339ede00d2e6e4b4b14b4c1..7e8624daad628fd653326647537eb51dad208a02 100644 --- a/crates/project/src/lsp_store.rs +++ b/crates/project/src/lsp_store.rs @@ -3864,6 +3864,7 @@ pub enum LspStoreEvent { #[derive(Clone, Debug, Serialize)] pub struct LanguageServerStatus { pub name: LanguageServerName, + pub server_version: Option, pub pending_work: BTreeMap, pub has_pending_diagnostic_updates: bool, pub progress_tokens: HashSet, @@ -8354,6 +8355,7 @@ impl LspStore { server_id, LanguageServerStatus { name, + server_version: None, pending_work: Default::default(), has_pending_diagnostic_updates: false, progress_tokens: Default::default(), @@ -9389,6 +9391,7 @@ impl LspStore { server_id, LanguageServerStatus { name: server_name.clone(), + server_version: None, pending_work: Default::default(), has_pending_diagnostic_updates: false, progress_tokens: Default::default(), @@ -11419,6 +11422,7 @@ impl LspStore { server_id, LanguageServerStatus { name: language_server.name(), + server_version: language_server.version(), pending_work: Default::default(), has_pending_diagnostic_updates: false, progress_tokens: Default::default(), diff --git a/crates/ui/src/components/context_menu.rs b/crates/ui/src/components/context_menu.rs index 756a2a9364193d6f1cdace8ed8c92cecf401a864..7e5e9032c9d4b0521f972b47d90d24cd502faf7b 100644 --- a/crates/ui/src/components/context_menu.rs +++ b/crates/ui/src/components/context_menu.rs @@ -893,39 +893,57 @@ impl ContextMenu { entry_render, handler, selectable, + documentation_aside, .. } => { let handler = handler.clone(); let menu = cx.entity().downgrade(); let selectable = *selectable; - ListItem::new(ix) - .inset(true) - .toggle_state(if selectable { - Some(ix) == self.selected_index - } else { - false + + div() + .id(("context-menu-child", ix)) + .when_some(documentation_aside.clone(), |this, documentation_aside| { + this.occlude() + .on_hover(cx.listener(move |menu, hovered, _, cx| { + if *hovered { + menu.documentation_aside = Some((ix, documentation_aside.clone())); + } else if matches!(menu.documentation_aside, Some((id, _)) if id == ix) + { + menu.documentation_aside = None; + } + cx.notify(); + })) }) - .selectable(selectable) - .when(selectable, |item| { - item.on_click({ - let context = self.action_context.clone(); - let keep_open_on_confirm = self.keep_open_on_confirm; - move |_, window, cx| { - handler(context.as_ref(), window, cx); - menu.update(cx, |menu, cx| { - menu.clicked = true; - - if keep_open_on_confirm { - menu.rebuild(window, cx); - } else { - cx.emit(DismissEvent); + .child( + ListItem::new(ix) + .inset(true) + .toggle_state(if selectable { + Some(ix) == self.selected_index + } else { + false + }) + .selectable(selectable) + .when(selectable, |item| { + item.on_click({ + let context = self.action_context.clone(); + let keep_open_on_confirm = self.keep_open_on_confirm; + move |_, window, cx| { + handler(context.as_ref(), window, cx); + menu.update(cx, |menu, cx| { + menu.clicked = true; + + if keep_open_on_confirm { + menu.rebuild(window, cx); + } else { + cx.emit(DismissEvent); + } + }) + .ok(); } }) - .ok(); - } - }) - }) - .child(entry_render(window, cx)) + }) + .child(entry_render(window, cx)), + ) .into_any_element() } } From 6055b45ee19ab61ff3b00498872ef6f31e748f37 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Thu, 18 Dec 2025 17:05:04 -0500 Subject: [PATCH 525/621] Add support for provider extensions (but no extensions yet) (#45277) This adds support for provider extensions but doesn't actually add any yet. Release Notes: - N/A --- Cargo.lock | 2 + crates/acp_thread/src/connection.rs | 11 +- crates/agent/src/agent.rs | 15 +- crates/agent_ui/src/acp/model_selector.rs | 8 +- .../src/acp/model_selector_popover.rs | 13 +- crates/agent_ui/src/agent_configuration.rs | 16 +- crates/agent_ui/src/agent_model_selector.rs | 12 +- crates/agent_ui/src/agent_panel.rs | 2 +- crates/agent_ui/src/agent_ui.rs | 3 +- .../agent_ui/src/language_model_selector.rs | 19 +- crates/agent_ui/src/text_thread_editor.rs | 20 +- .../src/ui/model_selector_components.rs | 23 ++- .../src/agent_api_keys_onboarding.rs | 20 +- .../src/agent_panel_onboarding_content.rs | 21 +- crates/extension/src/extension_host_proxy.rs | 48 +++++ crates/extension/src/extension_manifest.rs | 14 ++ .../extension_compilation_benchmark.rs | 1 + .../extension_host/src/capability_granter.rs | 1 + .../src/extension_store_test.rs | 3 + crates/language_model/src/language_model.rs | 21 +- crates/language_model/src/registry.rs | 195 +++++++++++++++++- crates/language_models/Cargo.toml | 2 + crates/language_models/src/extension.rs | 67 ++++++ crates/language_models/src/language_models.rs | 53 +++++ .../language_models/src/provider/anthropic.rs | 6 +- .../language_models/src/provider/bedrock.rs | 6 +- crates/language_models/src/provider/cloud.rs | 6 +- .../src/provider/copilot_chat.rs | 16 +- .../language_models/src/provider/deepseek.rs | 6 +- crates/language_models/src/provider/google.rs | 6 +- .../language_models/src/provider/lmstudio.rs | 6 +- .../language_models/src/provider/mistral.rs | 6 +- crates/language_models/src/provider/ollama.rs | 6 +- .../language_models/src/provider/open_ai.rs | 6 +- .../src/provider/open_ai_compatible.rs | 6 +- .../src/provider/open_router.rs | 6 +- crates/language_models/src/provider/vercel.rs | 6 +- crates/language_models/src/provider/x_ai.rs | 6 +- crates/ui/src/components/icon.rs | 22 +- 39 files changed, 585 insertions(+), 121 deletions(-) create mode 100644 crates/language_models/src/extension.rs diff --git a/Cargo.lock b/Cargo.lock index 0d83b2b9b912ab112d9b38fd1ef1d5ff21f9049c..1bb39f2bdf8c5745b3e5c0e5ad1200be34ec6ab0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8932,6 +8932,8 @@ dependencies = [ "credentials_provider", "deepseek", "editor", + "extension", + "extension_host", "fs", "futures 0.3.31", "google_ai", diff --git a/crates/acp_thread/src/connection.rs b/crates/acp_thread/src/connection.rs index a670ba601159ec323ad2c88695c30bf4aeae4118..598d0428174eb2fc124739a18ddeff1098521cb7 100644 --- a/crates/acp_thread/src/connection.rs +++ b/crates/acp_thread/src/connection.rs @@ -210,12 +210,21 @@ pub trait AgentModelSelector: 'static { } } +/// Icon for a model in the model selector. +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum AgentModelIcon { + /// A built-in icon from Zed's icon set. + Named(IconName), + /// Path to a custom SVG icon file. + Path(SharedString), +} + #[derive(Debug, Clone, PartialEq, Eq)] pub struct AgentModelInfo { pub id: acp::ModelId, pub name: SharedString, pub description: Option, - pub icon: Option, + pub icon: Option, } impl From for AgentModelInfo { diff --git a/crates/agent/src/agent.rs b/crates/agent/src/agent.rs index 43ed3b90f3556eb24e45440a7fe0038e7a1b9535..4baa7f4ea4004d2137b5cddb255346fa91523091 100644 --- a/crates/agent/src/agent.rs +++ b/crates/agent/src/agent.rs @@ -30,7 +30,7 @@ use futures::{StreamExt, future}; use gpui::{ App, AppContext, AsyncApp, Context, Entity, SharedString, Subscription, Task, WeakEntity, }; -use language_model::{LanguageModel, LanguageModelProvider, LanguageModelRegistry}; +use language_model::{IconOrSvg, LanguageModel, LanguageModelProvider, LanguageModelRegistry}; use project::{Project, ProjectItem, ProjectPath, Worktree}; use prompt_store::{ ProjectContext, PromptStore, RULES_FILE_NAMES, RulesFileContext, UserRulesContext, @@ -93,7 +93,7 @@ impl LanguageModels { fn refresh_list(&mut self, cx: &App) { let providers = LanguageModelRegistry::global(cx) .read(cx) - .providers() + .visible_providers() .into_iter() .filter(|provider| provider.is_authenticated(cx)) .collect::>(); @@ -153,7 +153,10 @@ impl LanguageModels { id: Self::model_id(model), name: model.name().0, description: None, - icon: Some(provider.icon()), + icon: Some(match provider.icon() { + IconOrSvg::Svg(path) => acp_thread::AgentModelIcon::Path(path), + IconOrSvg::Icon(name) => acp_thread::AgentModelIcon::Named(name), + }), } } @@ -164,7 +167,7 @@ impl LanguageModels { fn authenticate_all_language_model_providers(cx: &mut App) -> Task<()> { let authenticate_all_providers = LanguageModelRegistry::global(cx) .read(cx) - .providers() + .visible_providers() .iter() .map(|provider| (provider.id(), provider.name(), provider.authenticate(cx))) .collect::>(); @@ -1630,7 +1633,9 @@ mod internal_tests { id: acp::ModelId::new("fake/fake"), name: "Fake".into(), description: None, - icon: Some(ui::IconName::ZedAssistant), + icon: Some(acp_thread::AgentModelIcon::Named( + ui::IconName::ZedAssistant + )), }] )]) ); diff --git a/crates/agent_ui/src/acp/model_selector.rs b/crates/agent_ui/src/acp/model_selector.rs index f3c07250de3cefc798b97d9ffad444489d153219..903d5fe425d99389aae0e2a8028d9a31b986fbb3 100644 --- a/crates/agent_ui/src/acp/model_selector.rs +++ b/crates/agent_ui/src/acp/model_selector.rs @@ -1,6 +1,6 @@ use std::{cmp::Reverse, rc::Rc, sync::Arc}; -use acp_thread::{AgentModelInfo, AgentModelList, AgentModelSelector}; +use acp_thread::{AgentModelIcon, AgentModelInfo, AgentModelList, AgentModelSelector}; use agent_client_protocol::ModelId; use agent_servers::AgentServer; use agent_settings::AgentSettings; @@ -350,7 +350,11 @@ impl PickerDelegate for AcpModelPickerDelegate { }) .child( ModelSelectorListItem::new(ix, model_info.name.clone()) - .when_some(model_info.icon, |this, icon| this.icon(icon)) + .map(|this| match &model_info.icon { + Some(AgentModelIcon::Path(path)) => this.icon_path(path.clone()), + Some(AgentModelIcon::Named(icon)) => this.icon(*icon), + None => this, + }) .is_selected(is_selected) .is_focused(selected) .when(supports_favorites, |this| { diff --git a/crates/agent_ui/src/acp/model_selector_popover.rs b/crates/agent_ui/src/acp/model_selector_popover.rs index d6709081863c9545fba4c6e2304f195e77b013df..a15c01445dd8e9845f6744e795ed90a1ede6c7fc 100644 --- a/crates/agent_ui/src/acp/model_selector_popover.rs +++ b/crates/agent_ui/src/acp/model_selector_popover.rs @@ -1,7 +1,7 @@ use std::rc::Rc; use std::sync::Arc; -use acp_thread::{AgentModelInfo, AgentModelSelector}; +use acp_thread::{AgentModelIcon, AgentModelInfo, AgentModelSelector}; use agent_servers::AgentServer; use agent_settings::AgentSettings; use fs::Fs; @@ -70,7 +70,7 @@ impl Render for AcpModelSelectorPopover { .map(|model| model.name.clone()) .unwrap_or_else(|| SharedString::from("Select a Model")); - let model_icon = model.as_ref().and_then(|model| model.icon); + let model_icon = model.as_ref().and_then(|model| model.icon.clone()); let focus_handle = self.focus_handle.clone(); @@ -125,7 +125,14 @@ impl Render for AcpModelSelectorPopover { ButtonLike::new("active-model") .selected_style(ButtonStyle::Tinted(TintColor::Accent)) .when_some(model_icon, |this, icon| { - this.child(Icon::new(icon).color(color).size(IconSize::XSmall)) + this.child( + match icon { + AgentModelIcon::Path(path) => Icon::from_external_svg(path), + AgentModelIcon::Named(icon_name) => Icon::new(icon_name), + } + .color(color) + .size(IconSize::XSmall), + ) }) .child( Label::new(model_name) diff --git a/crates/agent_ui/src/agent_configuration.rs b/crates/agent_ui/src/agent_configuration.rs index 24f019c605d1b167e62a6e68dfc1f3ed07c73f1c..562976453d963db65f9033536e528000de2b510f 100644 --- a/crates/agent_ui/src/agent_configuration.rs +++ b/crates/agent_ui/src/agent_configuration.rs @@ -22,7 +22,8 @@ use gpui::{ }; use language::LanguageRegistry; use language_model::{ - LanguageModelProvider, LanguageModelProviderId, LanguageModelRegistry, ZED_CLOUD_PROVIDER_ID, + IconOrSvg, LanguageModelProvider, LanguageModelProviderId, LanguageModelRegistry, + ZED_CLOUD_PROVIDER_ID, }; use language_models::AllLanguageModelSettings; use notifications::status_toast::{StatusToast, ToastIcon}; @@ -117,7 +118,7 @@ impl AgentConfiguration { } fn build_provider_configuration_views(&mut self, window: &mut Window, cx: &mut Context) { - let providers = LanguageModelRegistry::read_global(cx).providers(); + let providers = LanguageModelRegistry::read_global(cx).visible_providers(); for provider in providers { self.add_provider_configuration_view(&provider, window, cx); } @@ -261,9 +262,12 @@ impl AgentConfiguration { .w_full() .gap_1p5() .child( - Icon::new(provider.icon()) - .size(IconSize::Small) - .color(Color::Muted), + match provider.icon() { + IconOrSvg::Svg(path) => Icon::from_external_svg(path), + IconOrSvg::Icon(name) => Icon::new(name), + } + .size(IconSize::Small) + .color(Color::Muted), ) .child( h_flex() @@ -416,7 +420,7 @@ impl AgentConfiguration { &mut self, cx: &mut Context, ) -> impl IntoElement { - let providers = LanguageModelRegistry::read_global(cx).providers(); + let providers = LanguageModelRegistry::read_global(cx).visible_providers(); let popover_menu = PopoverMenu::new("add-provider-popover") .trigger( diff --git a/crates/agent_ui/src/agent_model_selector.rs b/crates/agent_ui/src/agent_model_selector.rs index ac57ed575d9d1b6de2c53d3e0e4a91b4bd16ab1a..45cefbf2b9f8d4b1639a9849f2ee2e4468e530b1 100644 --- a/crates/agent_ui/src/agent_model_selector.rs +++ b/crates/agent_ui/src/agent_model_selector.rs @@ -4,6 +4,7 @@ use crate::{ }; use fs::Fs; use gpui::{Entity, FocusHandle, SharedString}; +use language_model::IconOrSvg; use picker::popover_menu::PickerPopoverMenu; use settings::update_settings_file; use std::sync::Arc; @@ -103,7 +104,14 @@ impl Render for AgentModelSelector { self.selector.clone(), ButtonLike::new("active-model") .when_some(provider_icon, |this, icon| { - this.child(Icon::new(icon).color(color).size(IconSize::XSmall)) + this.child( + match icon { + IconOrSvg::Svg(path) => Icon::from_external_svg(path), + IconOrSvg::Icon(name) => Icon::new(name), + } + .color(color) + .size(IconSize::XSmall), + ) }) .selected_style(ButtonStyle::Tinted(TintColor::Accent)) .child( @@ -115,7 +123,7 @@ impl Render for AgentModelSelector { .child( Icon::new(IconName::ChevronDown) .color(color) - .size(IconSize::Small), + .size(IconSize::XSmall), ), move |_window, cx| { Tooltip::for_action_in("Change Model", &ToggleModelSelector, &focus_handle, cx) diff --git a/crates/agent_ui/src/agent_panel.rs b/crates/agent_ui/src/agent_panel.rs index 294cd8b4888950f6ea92d6bea1eba78c3d6d6de2..a050f75120cd73949251c09c8424314e3616c705 100644 --- a/crates/agent_ui/src/agent_panel.rs +++ b/crates/agent_ui/src/agent_panel.rs @@ -2428,7 +2428,7 @@ impl AgentPanel { let history_is_empty = self.history_store.read(cx).is_empty(cx); let has_configured_non_zed_providers = LanguageModelRegistry::read_global(cx) - .providers() + .visible_providers() .iter() .any(|provider| { provider.is_authenticated(cx) diff --git a/crates/agent_ui/src/agent_ui.rs b/crates/agent_ui/src/agent_ui.rs index 02cb7e59948b10274302bd8cd6f74f1accbd30a3..401b506b302d9c2a86a36ddce0fc72df075f4c18 100644 --- a/crates/agent_ui/src/agent_ui.rs +++ b/crates/agent_ui/src/agent_ui.rs @@ -348,7 +348,8 @@ fn init_language_model_settings(cx: &mut App) { |_, event: &language_model::Event, cx| match event { language_model::Event::ProviderStateChanged(_) | language_model::Event::AddedProvider(_) - | language_model::Event::RemovedProvider(_) => { + | language_model::Event::RemovedProvider(_) + | language_model::Event::ProvidersChanged => { update_active_language_model_from_settings(cx); } _ => {} diff --git a/crates/agent_ui/src/language_model_selector.rs b/crates/agent_ui/src/language_model_selector.rs index 77c8c95255908dc54639ad7ac6c55f1e8b8151f0..704e340ace35f33f757ab7708f96ffc940a8eb91 100644 --- a/crates/agent_ui/src/language_model_selector.rs +++ b/crates/agent_ui/src/language_model_selector.rs @@ -7,8 +7,8 @@ use gpui::{ Action, AnyElement, App, BackgroundExecutor, DismissEvent, FocusHandle, Subscription, Task, }; use language_model::{ - AuthenticateError, ConfiguredModel, LanguageModel, LanguageModelId, LanguageModelProvider, - LanguageModelProviderId, LanguageModelRegistry, + AuthenticateError, ConfiguredModel, IconOrSvg, LanguageModel, LanguageModelId, + LanguageModelProvider, LanguageModelProviderId, LanguageModelRegistry, }; use ordered_float::OrderedFloat; use picker::{Picker, PickerDelegate}; @@ -55,7 +55,7 @@ pub fn language_model_selector( fn all_models(cx: &App) -> GroupedModels { let lm_registry = LanguageModelRegistry::global(cx).read(cx); - let providers = lm_registry.providers(); + let providers = lm_registry.visible_providers(); let mut favorites_index = FavoritesIndex::default(); @@ -94,7 +94,7 @@ type FavoritesIndex = HashMap> #[derive(Clone)] struct ModelInfo { model: Arc, - icon: IconName, + icon: IconOrSvg, is_favorite: bool, } @@ -203,7 +203,7 @@ impl LanguageModelPickerDelegate { fn authenticate_all_providers(cx: &mut App) -> Task<()> { let authenticate_all_providers = LanguageModelRegistry::global(cx) .read(cx) - .providers() + .visible_providers() .iter() .map(|provider| (provider.id(), provider.name(), provider.authenticate(cx))) .collect::>(); @@ -474,7 +474,7 @@ impl PickerDelegate for LanguageModelPickerDelegate { let configured_providers = language_model_registry .read(cx) - .providers() + .visible_providers() .into_iter() .filter(|provider| provider.is_authenticated(cx)) .collect::>(); @@ -566,7 +566,10 @@ impl PickerDelegate for LanguageModelPickerDelegate { Some( ModelSelectorListItem::new(ix, model_info.model.name().0) - .icon(model_info.icon) + .map(|this| match &model_info.icon { + IconOrSvg::Icon(icon_name) => this.icon(*icon_name), + IconOrSvg::Svg(icon_path) => this.icon_path(icon_path.clone()), + }) .is_selected(is_selected) .is_focused(selected) .is_favorite(is_favorite) @@ -702,7 +705,7 @@ mod tests { .any(|(fav_provider, fav_name)| *fav_provider == provider && *fav_name == name); ModelInfo { model: Arc::new(TestLanguageModel::new(name, provider)), - icon: IconName::Ai, + icon: IconOrSvg::Icon(IconName::Ai), is_favorite, } }) diff --git a/crates/agent_ui/src/text_thread_editor.rs b/crates/agent_ui/src/text_thread_editor.rs index 16d12cf261d3bbb8eb0b879394fedc1cc96e046c..514f45528427af89eeccf85512abf850a7a1be05 100644 --- a/crates/agent_ui/src/text_thread_editor.rs +++ b/crates/agent_ui/src/text_thread_editor.rs @@ -33,7 +33,8 @@ use language::{ language_settings::{SoftWrap, all_language_settings}, }; use language_model::{ - ConfigurationError, LanguageModelExt, LanguageModelImage, LanguageModelRegistry, Role, + ConfigurationError, IconOrSvg, LanguageModelExt, LanguageModelImage, LanguageModelRegistry, + Role, }; use multi_buffer::MultiBufferRow; use picker::{Picker, popover_menu::PickerPopoverMenu}; @@ -2231,10 +2232,10 @@ impl TextThreadEditor { .default_model() .map(|default| default.provider); - let provider_icon = match active_provider { - Some(provider) => provider.icon(), - None => IconName::Ai, - }; + let provider_icon = active_provider + .as_ref() + .map(|p| p.icon()) + .unwrap_or(IconOrSvg::Icon(IconName::Ai)); let focus_handle = self.editor().focus_handle(cx); @@ -2244,6 +2245,13 @@ impl TextThreadEditor { (Color::Muted, IconName::ChevronDown) }; + let provider_icon_element = match provider_icon { + IconOrSvg::Svg(path) => Icon::from_external_svg(path), + IconOrSvg::Icon(name) => Icon::new(name), + } + .color(color) + .size(IconSize::XSmall); + let tooltip = Tooltip::element({ move |_, cx| { let focus_handle = focus_handle.clone(); @@ -2291,7 +2299,7 @@ impl TextThreadEditor { .child( h_flex() .gap_0p5() - .child(Icon::new(provider_icon).color(color).size(IconSize::XSmall)) + .child(provider_icon_element) .child( Label::new(model_name) .color(color) diff --git a/crates/agent_ui/src/ui/model_selector_components.rs b/crates/agent_ui/src/ui/model_selector_components.rs index 061b4f58288798696b068a091fb392c033906627..beb0c13d761aa9e7e41c2ac4e35a8cfcc7e8d869 100644 --- a/crates/agent_ui/src/ui/model_selector_components.rs +++ b/crates/agent_ui/src/ui/model_selector_components.rs @@ -1,6 +1,11 @@ use gpui::{Action, FocusHandle, prelude::*}; use ui::{ElevationIndex, KeyBinding, ListItem, ListItemSpacing, Tooltip, prelude::*}; +enum ModelIcon { + Name(IconName), + Path(SharedString), +} + #[derive(IntoElement)] pub struct ModelSelectorHeader { title: SharedString, @@ -39,7 +44,7 @@ impl RenderOnce for ModelSelectorHeader { pub struct ModelSelectorListItem { index: usize, title: SharedString, - icon: Option, + icon: Option, is_selected: bool, is_focused: bool, is_favorite: bool, @@ -60,7 +65,12 @@ impl ModelSelectorListItem { } pub fn icon(mut self, icon: IconName) -> Self { - self.icon = Some(icon); + self.icon = Some(ModelIcon::Name(icon)); + self + } + + pub fn icon_path(mut self, path: SharedString) -> Self { + self.icon = Some(ModelIcon::Path(path)); self } @@ -105,9 +115,12 @@ impl RenderOnce for ModelSelectorListItem { .gap_1p5() .when_some(self.icon, |this, icon| { this.child( - Icon::new(icon) - .color(model_icon_color) - .size(IconSize::Small), + match icon { + ModelIcon::Name(icon_name) => Icon::new(icon_name), + ModelIcon::Path(icon_path) => Icon::from_external_svg(icon_path), + } + .color(model_icon_color) + .size(IconSize::Small), ) }) .child(Label::new(self.title).truncate()), diff --git a/crates/ai_onboarding/src/agent_api_keys_onboarding.rs b/crates/ai_onboarding/src/agent_api_keys_onboarding.rs index fadc4222ae44f3dbad862fd9479b89321dbd3016..47197ec2331b97dd4d7561d9f14c91c7f91c9fa0 100644 --- a/crates/ai_onboarding/src/agent_api_keys_onboarding.rs +++ b/crates/ai_onboarding/src/agent_api_keys_onboarding.rs @@ -1,9 +1,9 @@ use gpui::{Action, IntoElement, ParentElement, RenderOnce, point}; -use language_model::{LanguageModelRegistry, ZED_CLOUD_PROVIDER_ID}; +use language_model::{IconOrSvg, LanguageModelRegistry, ZED_CLOUD_PROVIDER_ID}; use ui::{Divider, List, ListBulletItem, prelude::*}; pub struct ApiKeysWithProviders { - configured_providers: Vec<(IconName, SharedString)>, + configured_providers: Vec<(IconOrSvg, SharedString)>, } impl ApiKeysWithProviders { @@ -13,7 +13,8 @@ impl ApiKeysWithProviders { |this: &mut Self, _registry, event: &language_model::Event, cx| match event { language_model::Event::ProviderStateChanged(_) | language_model::Event::AddedProvider(_) - | language_model::Event::RemovedProvider(_) => { + | language_model::Event::RemovedProvider(_) + | language_model::Event::ProvidersChanged => { this.configured_providers = Self::compute_configured_providers(cx) } _ => {} @@ -26,9 +27,9 @@ impl ApiKeysWithProviders { } } - fn compute_configured_providers(cx: &App) -> Vec<(IconName, SharedString)> { + fn compute_configured_providers(cx: &App) -> Vec<(IconOrSvg, SharedString)> { LanguageModelRegistry::read_global(cx) - .providers() + .visible_providers() .iter() .filter(|provider| { provider.is_authenticated(cx) && provider.id() != ZED_CLOUD_PROVIDER_ID @@ -47,7 +48,14 @@ impl Render for ApiKeysWithProviders { .map(|(icon, name)| { h_flex() .gap_1p5() - .child(Icon::new(icon).size(IconSize::XSmall).color(Color::Muted)) + .child( + match icon { + IconOrSvg::Icon(icon_name) => Icon::new(icon_name), + IconOrSvg::Svg(icon_path) => Icon::from_external_svg(icon_path), + } + .size(IconSize::XSmall) + .color(Color::Muted), + ) .child(Label::new(name)) }); div() diff --git a/crates/ai_onboarding/src/agent_panel_onboarding_content.rs b/crates/ai_onboarding/src/agent_panel_onboarding_content.rs index 3c8ffc1663e0660829698b5449a006de5b3c6009..c2756927136449d649996ec3b4b87471114aca38 100644 --- a/crates/ai_onboarding/src/agent_panel_onboarding_content.rs +++ b/crates/ai_onboarding/src/agent_panel_onboarding_content.rs @@ -11,7 +11,7 @@ use crate::{AgentPanelOnboardingCard, ApiKeysWithoutProviders, ZedAiOnboarding}; pub struct AgentPanelOnboarding { user_store: Entity, client: Arc, - configured_providers: Vec<(IconName, SharedString)>, + has_configured_providers: bool, continue_with_zed_ai: Arc, } @@ -27,8 +27,9 @@ impl AgentPanelOnboarding { |this: &mut Self, _registry, event: &language_model::Event, cx| match event { language_model::Event::ProviderStateChanged(_) | language_model::Event::AddedProvider(_) - | language_model::Event::RemovedProvider(_) => { - this.configured_providers = Self::compute_available_providers(cx) + | language_model::Event::RemovedProvider(_) + | language_model::Event::ProvidersChanged => { + this.has_configured_providers = Self::has_configured_providers(cx) } _ => {} }, @@ -38,20 +39,16 @@ impl AgentPanelOnboarding { Self { user_store, client, - configured_providers: Self::compute_available_providers(cx), + has_configured_providers: Self::has_configured_providers(cx), continue_with_zed_ai: Arc::new(continue_with_zed_ai), } } - fn compute_available_providers(cx: &App) -> Vec<(IconName, SharedString)> { + fn has_configured_providers(cx: &App) -> bool { LanguageModelRegistry::read_global(cx) - .providers() + .visible_providers() .iter() - .filter(|provider| { - provider.is_authenticated(cx) && provider.id() != ZED_CLOUD_PROVIDER_ID - }) - .map(|provider| (provider.icon(), provider.name().0)) - .collect() + .any(|provider| provider.is_authenticated(cx) && provider.id() != ZED_CLOUD_PROVIDER_ID) } } @@ -81,7 +78,7 @@ impl Render for AgentPanelOnboarding { }), ) .map(|this| { - if enrolled_in_trial || is_pro_user || !self.configured_providers.is_empty() { + if enrolled_in_trial || is_pro_user || self.has_configured_providers { this } else { this.child(ApiKeysWithoutProviders::new()) diff --git a/crates/extension/src/extension_host_proxy.rs b/crates/extension/src/extension_host_proxy.rs index 6a24e3ba3f496bd0f0b89d61e9125b29ecae0204..b445878389015d4b3b8c3e25a0d103586462fd86 100644 --- a/crates/extension/src/extension_host_proxy.rs +++ b/crates/extension/src/extension_host_proxy.rs @@ -19,6 +19,9 @@ impl Global for GlobalExtensionHostProxy {} /// /// This object implements each of the individual proxy types so that their /// methods can be called directly on it. +/// Registration function for language model providers. +pub type LanguageModelProviderRegistration = Box; + #[derive(Default)] pub struct ExtensionHostProxy { theme_proxy: RwLock>>, @@ -29,6 +32,7 @@ pub struct ExtensionHostProxy { slash_command_proxy: RwLock>>, context_server_proxy: RwLock>>, debug_adapter_provider_proxy: RwLock>>, + language_model_provider_proxy: RwLock>>, } impl ExtensionHostProxy { @@ -54,6 +58,7 @@ impl ExtensionHostProxy { slash_command_proxy: RwLock::default(), context_server_proxy: RwLock::default(), debug_adapter_provider_proxy: RwLock::default(), + language_model_provider_proxy: RwLock::default(), } } @@ -90,6 +95,15 @@ impl ExtensionHostProxy { .write() .replace(Arc::new(proxy)); } + + pub fn register_language_model_provider_proxy( + &self, + proxy: impl ExtensionLanguageModelProviderProxy, + ) { + self.language_model_provider_proxy + .write() + .replace(Arc::new(proxy)); + } } pub trait ExtensionThemeProxy: Send + Sync + 'static { @@ -446,3 +460,37 @@ impl ExtensionDebugAdapterProviderProxy for ExtensionHostProxy { proxy.unregister_debug_locator(locator_name) } } + +pub trait ExtensionLanguageModelProviderProxy: Send + Sync + 'static { + fn register_language_model_provider( + &self, + provider_id: Arc, + register_fn: LanguageModelProviderRegistration, + cx: &mut App, + ); + + fn unregister_language_model_provider(&self, provider_id: Arc, cx: &mut App); +} + +impl ExtensionLanguageModelProviderProxy for ExtensionHostProxy { + fn register_language_model_provider( + &self, + provider_id: Arc, + register_fn: LanguageModelProviderRegistration, + cx: &mut App, + ) { + let Some(proxy) = self.language_model_provider_proxy.read().clone() else { + return; + }; + + proxy.register_language_model_provider(provider_id, register_fn, cx) + } + + fn unregister_language_model_provider(&self, provider_id: Arc, cx: &mut App) { + let Some(proxy) = self.language_model_provider_proxy.read().clone() else { + return; + }; + + proxy.unregister_language_model_provider(provider_id, cx) + } +} diff --git a/crates/extension/src/extension_manifest.rs b/crates/extension/src/extension_manifest.rs index 4ecdd378ca86dbee263e439e13fa4776dab9e316..39b629db30d0d1cee3374dafc317bdeb0f368146 100644 --- a/crates/extension/src/extension_manifest.rs +++ b/crates/extension/src/extension_manifest.rs @@ -93,6 +93,8 @@ pub struct ExtensionManifest { pub debug_adapters: BTreeMap, DebugAdapterManifestEntry>, #[serde(default, skip_serializing_if = "BTreeMap::is_empty")] pub debug_locators: BTreeMap, DebugLocatorManifestEntry>, + #[serde(default, skip_serializing_if = "BTreeMap::is_empty")] + pub language_model_providers: BTreeMap, LanguageModelProviderManifestEntry>, } impl ExtensionManifest { @@ -288,6 +290,16 @@ pub struct DebugAdapterManifestEntry { #[derive(Clone, PartialEq, Eq, Debug, Deserialize, Serialize)] pub struct DebugLocatorManifestEntry {} +/// Manifest entry for a language model provider. +#[derive(Clone, PartialEq, Eq, Debug, Deserialize, Serialize)] +pub struct LanguageModelProviderManifestEntry { + /// Display name for the provider. + pub name: String, + /// Path to an SVG icon file relative to the extension root (e.g., "icons/provider.svg"). + #[serde(default)] + pub icon: Option, +} + impl ExtensionManifest { pub async fn load(fs: Arc, extension_dir: &Path) -> Result { let extension_name = extension_dir @@ -358,6 +370,7 @@ fn manifest_from_old_manifest( capabilities: Vec::new(), debug_adapters: Default::default(), debug_locators: Default::default(), + language_model_providers: Default::default(), } } @@ -391,6 +404,7 @@ mod tests { capabilities: vec![], debug_adapters: Default::default(), debug_locators: Default::default(), + language_model_providers: BTreeMap::default(), } } diff --git a/crates/extension_host/benches/extension_compilation_benchmark.rs b/crates/extension_host/benches/extension_compilation_benchmark.rs index a28f617dc36e5cba3ad36d7ab6477e7a665dd5c4..605b98c67071155d8444639ef7043b9c8901161d 100644 --- a/crates/extension_host/benches/extension_compilation_benchmark.rs +++ b/crates/extension_host/benches/extension_compilation_benchmark.rs @@ -148,6 +148,7 @@ fn manifest() -> ExtensionManifest { )], debug_adapters: Default::default(), debug_locators: Default::default(), + language_model_providers: BTreeMap::default(), } } diff --git a/crates/extension_host/src/capability_granter.rs b/crates/extension_host/src/capability_granter.rs index 9f27b5e480bc3c22faefe67cd49a06af21614096..6278deef0a7d41e40d4444ddbe992f007cd5e53e 100644 --- a/crates/extension_host/src/capability_granter.rs +++ b/crates/extension_host/src/capability_granter.rs @@ -113,6 +113,7 @@ mod tests { capabilities: vec![], debug_adapters: Default::default(), debug_locators: Default::default(), + language_model_providers: BTreeMap::default(), } } diff --git a/crates/extension_host/src/extension_store_test.rs b/crates/extension_host/src/extension_store_test.rs index 54b090347ffad3ffed444827f5cb60c120d25ad7..c17484f26a06b3392cdbcd8f3c1578eb43c7b213 100644 --- a/crates/extension_host/src/extension_store_test.rs +++ b/crates/extension_host/src/extension_store_test.rs @@ -165,6 +165,7 @@ async fn test_extension_store(cx: &mut TestAppContext) { capabilities: Vec::new(), debug_adapters: Default::default(), debug_locators: Default::default(), + language_model_providers: BTreeMap::default(), }), dev: false, }, @@ -196,6 +197,7 @@ async fn test_extension_store(cx: &mut TestAppContext) { capabilities: Vec::new(), debug_adapters: Default::default(), debug_locators: Default::default(), + language_model_providers: BTreeMap::default(), }), dev: false, }, @@ -376,6 +378,7 @@ async fn test_extension_store(cx: &mut TestAppContext) { capabilities: Vec::new(), debug_adapters: Default::default(), debug_locators: Default::default(), + language_model_providers: BTreeMap::default(), }), dev: false, }, diff --git a/crates/language_model/src/language_model.rs b/crates/language_model/src/language_model.rs index 09d44b5b408324936af00a2a5e4f1deb4f351434..56a970404419ec6042c463d26c2844eb0904f829 100644 --- a/crates/language_model/src/language_model.rs +++ b/crates/language_model/src/language_model.rs @@ -797,11 +797,26 @@ pub enum AuthenticateError { Other(#[from] anyhow::Error), } +/// Either a built-in icon name or a path to an external SVG. +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum IconOrSvg { + /// A built-in icon from Zed's icon set. + Icon(IconName), + /// Path to a custom SVG icon file. + Svg(SharedString), +} + +impl Default for IconOrSvg { + fn default() -> Self { + Self::Icon(IconName::ZedAssistant) + } +} + pub trait LanguageModelProvider: 'static { fn id(&self) -> LanguageModelProviderId; fn name(&self) -> LanguageModelProviderName; - fn icon(&self) -> IconName { - IconName::ZedAssistant + fn icon(&self) -> IconOrSvg { + IconOrSvg::default() } fn default_model(&self, cx: &App) -> Option>; fn default_fast_model(&self, cx: &App) -> Option>; @@ -820,7 +835,7 @@ pub trait LanguageModelProvider: 'static { fn reset_credentials(&self, cx: &mut App) -> Task>; } -#[derive(Default, Clone)] +#[derive(Default, Clone, PartialEq, Eq)] pub enum ConfigurationViewTargetAgent { #[default] ZedAgent, diff --git a/crates/language_model/src/registry.rs b/crates/language_model/src/registry.rs index 27b8309810962981d3c0ec78e6e67dfdfba122bf..cf7718f7b102010cc0c8a981a0425583436176b7 100644 --- a/crates/language_model/src/registry.rs +++ b/crates/language_model/src/registry.rs @@ -2,12 +2,16 @@ use crate::{ LanguageModel, LanguageModelId, LanguageModelProvider, LanguageModelProviderId, LanguageModelProviderState, }; -use collections::BTreeMap; +use collections::{BTreeMap, HashSet}; use gpui::{App, Context, Entity, EventEmitter, Global, prelude::*}; use std::{str::FromStr, sync::Arc}; use thiserror::Error; use util::maybe; +/// Function type for checking if a built-in provider should be hidden. +/// Returns Some(extension_id) if the provider should be hidden when that extension is installed. +pub type BuiltinProviderHidingFn = Box Option<&'static str> + Send + Sync>; + pub fn init(cx: &mut App) { let registry = cx.new(|_cx| LanguageModelRegistry::default()); cx.set_global(GlobalLanguageModelRegistry(registry)); @@ -48,6 +52,11 @@ pub struct LanguageModelRegistry { thread_summary_model: Option, providers: BTreeMap>, inline_alternatives: Vec>, + /// Set of installed extension IDs that provide language models. + /// Used to determine which built-in providers should be hidden. + installed_llm_extension_ids: HashSet>, + /// Function to check if a built-in provider should be hidden by an extension. + builtin_provider_hiding_fn: Option, } #[derive(Debug)] @@ -104,6 +113,8 @@ pub enum Event { ProviderStateChanged(LanguageModelProviderId), AddedProvider(LanguageModelProviderId), RemovedProvider(LanguageModelProviderId), + /// Emitted when provider visibility changes due to extension install/uninstall. + ProvidersChanged, } impl EventEmitter for LanguageModelRegistry {} @@ -183,6 +194,60 @@ impl LanguageModelRegistry { providers } + /// Returns providers, filtering out hidden built-in providers. + pub fn visible_providers(&self) -> Vec> { + self.providers() + .into_iter() + .filter(|p| !self.should_hide_provider(&p.id())) + .collect() + } + + /// Sets the function used to check if a built-in provider should be hidden. + pub fn set_builtin_provider_hiding_fn(&mut self, hiding_fn: BuiltinProviderHidingFn) { + self.builtin_provider_hiding_fn = Some(hiding_fn); + } + + /// Called when an extension is installed/loaded. + /// If the extension provides language models, track it so we can hide the corresponding built-in. + pub fn extension_installed(&mut self, extension_id: Arc, cx: &mut Context) { + if self.installed_llm_extension_ids.insert(extension_id) { + cx.emit(Event::ProvidersChanged); + cx.notify(); + } + } + + /// Called when an extension is uninstalled/unloaded. + pub fn extension_uninstalled(&mut self, extension_id: &str, cx: &mut Context) { + if self.installed_llm_extension_ids.remove(extension_id) { + cx.emit(Event::ProvidersChanged); + cx.notify(); + } + } + + /// Sync the set of installed LLM extension IDs. + pub fn sync_installed_llm_extensions( + &mut self, + extension_ids: HashSet>, + cx: &mut Context, + ) { + if extension_ids != self.installed_llm_extension_ids { + self.installed_llm_extension_ids = extension_ids; + cx.emit(Event::ProvidersChanged); + cx.notify(); + } + } + + /// Returns true if a provider should be hidden from the UI. + /// Built-in providers are hidden when their corresponding extension is installed. + pub fn should_hide_provider(&self, provider_id: &LanguageModelProviderId) -> bool { + if let Some(ref hiding_fn) = self.builtin_provider_hiding_fn { + if let Some(extension_id) = hiding_fn(&provider_id.0) { + return self.installed_llm_extension_ids.contains(extension_id); + } + } + false + } + pub fn configuration_error( &self, model: Option, @@ -416,4 +481,132 @@ mod tests { let providers = registry.read(cx).providers(); assert!(providers.is_empty()); } + + #[gpui::test] + fn test_provider_hiding_on_extension_install(cx: &mut App) { + let registry = cx.new(|_| LanguageModelRegistry::default()); + + let provider = Arc::new(FakeLanguageModelProvider::default()); + let provider_id = provider.id(); + + registry.update(cx, |registry, cx| { + registry.register_provider(provider.clone(), cx); + + registry.set_builtin_provider_hiding_fn(Box::new(|id| { + if id == "fake" { + Some("fake-extension") + } else { + None + } + })); + }); + + let visible = registry.read(cx).visible_providers(); + assert_eq!(visible.len(), 1); + assert_eq!(visible[0].id(), provider_id); + + registry.update(cx, |registry, cx| { + registry.extension_installed("fake-extension".into(), cx); + }); + + let visible = registry.read(cx).visible_providers(); + assert!(visible.is_empty()); + + let all = registry.read(cx).providers(); + assert_eq!(all.len(), 1); + } + + #[gpui::test] + fn test_provider_unhiding_on_extension_uninstall(cx: &mut App) { + let registry = cx.new(|_| LanguageModelRegistry::default()); + + let provider = Arc::new(FakeLanguageModelProvider::default()); + let provider_id = provider.id(); + + registry.update(cx, |registry, cx| { + registry.register_provider(provider.clone(), cx); + + registry.set_builtin_provider_hiding_fn(Box::new(|id| { + if id == "fake" { + Some("fake-extension") + } else { + None + } + })); + + registry.extension_installed("fake-extension".into(), cx); + }); + + let visible = registry.read(cx).visible_providers(); + assert!(visible.is_empty()); + + registry.update(cx, |registry, cx| { + registry.extension_uninstalled("fake-extension", cx); + }); + + let visible = registry.read(cx).visible_providers(); + assert_eq!(visible.len(), 1); + assert_eq!(visible[0].id(), provider_id); + } + + #[gpui::test] + fn test_should_hide_provider(cx: &mut App) { + let registry = cx.new(|_| LanguageModelRegistry::default()); + + registry.update(cx, |registry, cx| { + registry.set_builtin_provider_hiding_fn(Box::new(|id| { + if id == "anthropic" { + Some("anthropic") + } else if id == "openai" { + Some("openai") + } else { + None + } + })); + + registry.extension_installed("anthropic".into(), cx); + }); + + let registry_read = registry.read(cx); + + assert!(registry_read.should_hide_provider(&LanguageModelProviderId("anthropic".into()))); + + assert!(!registry_read.should_hide_provider(&LanguageModelProviderId("openai".into()))); + + assert!(!registry_read.should_hide_provider(&LanguageModelProviderId("unknown".into()))); + } + + #[gpui::test] + fn test_sync_installed_llm_extensions(cx: &mut App) { + let registry = cx.new(|_| LanguageModelRegistry::default()); + + let provider = Arc::new(FakeLanguageModelProvider::default()); + + registry.update(cx, |registry, cx| { + registry.register_provider(provider.clone(), cx); + + registry.set_builtin_provider_hiding_fn(Box::new(|id| { + if id == "fake" { + Some("fake-extension") + } else { + None + } + })); + }); + + let mut extension_ids = HashSet::default(); + extension_ids.insert(Arc::from("fake-extension")); + + registry.update(cx, |registry, cx| { + registry.sync_installed_llm_extensions(extension_ids, cx); + }); + + assert!(registry.read(cx).visible_providers().is_empty()); + + registry.update(cx, |registry, cx| { + registry.sync_installed_llm_extensions(HashSet::default(), cx); + }); + + assert_eq!(registry.read(cx).visible_providers().len(), 1); + } } diff --git a/crates/language_models/Cargo.toml b/crates/language_models/Cargo.toml index 5531e698ab7fccae736e800f38b16e35bcd35ac4..1bec5d94d2bb35f91305c6c77a9e85ed8579e1af 100644 --- a/crates/language_models/Cargo.toml +++ b/crates/language_models/Cargo.toml @@ -28,6 +28,8 @@ convert_case.workspace = true copilot.workspace = true credentials_provider.workspace = true deepseek = { workspace = true, features = ["schemars"] } +extension.workspace = true +extension_host.workspace = true fs.workspace = true futures.workspace = true google_ai = { workspace = true, features = ["schemars"] } diff --git a/crates/language_models/src/extension.rs b/crates/language_models/src/extension.rs new file mode 100644 index 0000000000000000000000000000000000000000..e0b46ab5e1d667fb61449a654769ecf7c221e720 --- /dev/null +++ b/crates/language_models/src/extension.rs @@ -0,0 +1,67 @@ +use collections::HashMap; +use extension::{ + ExtensionHostProxy, ExtensionLanguageModelProviderProxy, LanguageModelProviderRegistration, +}; +use gpui::{App, Entity}; +use language_model::{LanguageModelProviderId, LanguageModelRegistry}; +use std::sync::{Arc, LazyLock}; + +/// Maps built-in provider IDs to their corresponding extension IDs. +/// When an extension with this ID is installed, the built-in provider should be hidden. +static BUILTIN_TO_EXTENSION_MAP: LazyLock> = + LazyLock::new(|| { + let mut map = HashMap::default(); + map.insert("anthropic", "anthropic"); + map.insert("openai", "openai"); + map.insert("google", "google-ai"); + map.insert("openrouter", "openrouter"); + map.insert("copilot_chat", "copilot-chat"); + map + }); + +/// Returns the extension ID that should hide the given built-in provider. +pub fn extension_for_builtin_provider(provider_id: &str) -> Option<&'static str> { + BUILTIN_TO_EXTENSION_MAP.get(provider_id).copied() +} + +/// Proxy that registers extension language model providers with the LanguageModelRegistry. +pub struct LanguageModelProviderRegistryProxy { + registry: Entity, +} + +impl LanguageModelProviderRegistryProxy { + pub fn new(registry: Entity) -> Self { + Self { registry } + } +} + +impl ExtensionLanguageModelProviderProxy for LanguageModelProviderRegistryProxy { + fn register_language_model_provider( + &self, + _provider_id: Arc, + register_fn: LanguageModelProviderRegistration, + cx: &mut App, + ) { + register_fn(cx); + } + + fn unregister_language_model_provider(&self, provider_id: Arc, cx: &mut App) { + self.registry.update(cx, |registry, cx| { + registry.unregister_provider(LanguageModelProviderId::from(provider_id), cx); + }); + } +} + +/// Initialize the extension language model provider proxy. +/// This must be called BEFORE extension_host::init to ensure the proxy is available +/// when extensions try to register their language model providers. +pub fn init_proxy(cx: &mut App) { + let proxy = ExtensionHostProxy::default_global(cx); + let registry = LanguageModelRegistry::global(cx); + + registry.update(cx, |registry, _cx| { + registry.set_builtin_provider_hiding_fn(Box::new(extension_for_builtin_provider)); + }); + + proxy.register_language_model_provider_proxy(LanguageModelProviderRegistryProxy::new(registry)); +} diff --git a/crates/language_models/src/language_models.rs b/crates/language_models/src/language_models.rs index 1038f5e233e0a5970b0e8bd969a65f6f0e2a7550..37d4ca5ddd4e5c1e7a0202c88c012d18b018cd4f 100644 --- a/crates/language_models/src/language_models.rs +++ b/crates/language_models/src/language_models.rs @@ -7,9 +7,12 @@ use gpui::{App, Context, Entity}; use language_model::{LanguageModelProviderId, LanguageModelRegistry}; use provider::deepseek::DeepSeekLanguageModelProvider; +pub mod extension; pub mod provider; mod settings; +pub use crate::extension::init_proxy as init_extension_proxy; + use crate::provider::anthropic::AnthropicLanguageModelProvider; use crate::provider::bedrock::BedrockLanguageModelProvider; use crate::provider::cloud::CloudLanguageModelProvider; @@ -31,6 +34,56 @@ pub fn init(user_store: Entity, client: Arc, cx: &mut App) { register_language_model_providers(registry, user_store, client.clone(), cx); }); + // Subscribe to extension store events to track LLM extension installations + if let Some(extension_store) = extension_host::ExtensionStore::try_global(cx) { + cx.subscribe(&extension_store, { + let registry = registry.clone(); + move |extension_store, event, cx| match event { + extension_host::Event::ExtensionInstalled(extension_id) => { + if let Some(manifest) = extension_store + .read(cx) + .extension_manifest_for_id(extension_id) + { + if !manifest.language_model_providers.is_empty() { + registry.update(cx, |registry, cx| { + registry.extension_installed(extension_id.clone(), cx); + }); + } + } + } + extension_host::Event::ExtensionUninstalled(extension_id) => { + registry.update(cx, |registry, cx| { + registry.extension_uninstalled(extension_id, cx); + }); + } + extension_host::Event::ExtensionsUpdated => { + let mut new_ids = HashSet::default(); + for (extension_id, entry) in extension_store.read(cx).installed_extensions() { + if !entry.manifest.language_model_providers.is_empty() { + new_ids.insert(extension_id.clone()); + } + } + registry.update(cx, |registry, cx| { + registry.sync_installed_llm_extensions(new_ids, cx); + }); + } + _ => {} + } + }) + .detach(); + + // Initialize with currently installed extensions + registry.update(cx, |registry, cx| { + let mut initial_ids = HashSet::default(); + for (extension_id, entry) in extension_store.read(cx).installed_extensions() { + if !entry.manifest.language_model_providers.is_empty() { + initial_ids.insert(extension_id.clone()); + } + } + registry.sync_installed_llm_extensions(initial_ids, cx); + }); + } + let mut openai_compatible_providers = AllLanguageModelSettings::get_global(cx) .openai_compatible .keys() diff --git a/crates/language_models/src/provider/anthropic.rs b/crates/language_models/src/provider/anthropic.rs index d8c972399c33922386bfba4236e1369d03d338dc..598834f85c496cd54ddd956089715cac64420202 100644 --- a/crates/language_models/src/provider/anthropic.rs +++ b/crates/language_models/src/provider/anthropic.rs @@ -8,7 +8,7 @@ use futures::{FutureExt, Stream, StreamExt, future, future::BoxFuture, stream::B use gpui::{AnyView, App, AsyncApp, Context, Entity, Task}; use http_client::HttpClient; use language_model::{ - ApiKeyState, AuthenticateError, ConfigurationViewTargetAgent, EnvVar, LanguageModel, + ApiKeyState, AuthenticateError, ConfigurationViewTargetAgent, EnvVar, IconOrSvg, LanguageModel, LanguageModelCacheConfiguration, LanguageModelCompletionError, LanguageModelCompletionEvent, LanguageModelId, LanguageModelName, LanguageModelProvider, LanguageModelProviderId, LanguageModelProviderName, LanguageModelProviderState, LanguageModelRequest, @@ -125,8 +125,8 @@ impl LanguageModelProvider for AnthropicLanguageModelProvider { PROVIDER_NAME } - fn icon(&self) -> IconName { - IconName::AiAnthropic + fn icon(&self) -> IconOrSvg { + IconOrSvg::Icon(IconName::AiAnthropic) } fn default_model(&self, _cx: &App) -> Option> { diff --git a/crates/language_models/src/provider/bedrock.rs b/crates/language_models/src/provider/bedrock.rs index 286f9ec1a4bf67c22868cf83e00e7b46e0737ba8..62237fbf376a0739fd2518bda44f51149b3457df 100644 --- a/crates/language_models/src/provider/bedrock.rs +++ b/crates/language_models/src/provider/bedrock.rs @@ -30,7 +30,7 @@ use gpui::{ use gpui_tokio::Tokio; use http_client::HttpClient; use language_model::{ - AuthenticateError, EnvVar, LanguageModel, LanguageModelCacheConfiguration, + AuthenticateError, EnvVar, IconOrSvg, LanguageModel, LanguageModelCacheConfiguration, LanguageModelCompletionError, LanguageModelCompletionEvent, LanguageModelId, LanguageModelName, LanguageModelProvider, LanguageModelProviderId, LanguageModelProviderName, LanguageModelProviderState, LanguageModelRequest, LanguageModelToolChoice, @@ -426,8 +426,8 @@ impl LanguageModelProvider for BedrockLanguageModelProvider { PROVIDER_NAME } - fn icon(&self) -> IconName { - IconName::AiBedrock + fn icon(&self) -> IconOrSvg { + IconOrSvg::Icon(IconName::AiBedrock) } fn default_model(&self, _cx: &App) -> Option> { diff --git a/crates/language_models/src/provider/cloud.rs b/crates/language_models/src/provider/cloud.rs index def1cef84d3166d08dcc7638ca5a29cabbd149c5..65a42740eb9a8aff830d7544ed5aa972c6697d88 100644 --- a/crates/language_models/src/provider/cloud.rs +++ b/crates/language_models/src/provider/cloud.rs @@ -19,7 +19,7 @@ use gpui::{AnyElement, AnyView, App, AsyncApp, Context, Entity, Subscription, Ta use http_client::http::{HeaderMap, HeaderValue}; use http_client::{AsyncBody, HttpClient, HttpRequestExt, Method, Response, StatusCode}; use language_model::{ - AuthenticateError, LanguageModel, LanguageModelCacheConfiguration, + AuthenticateError, IconOrSvg, LanguageModel, LanguageModelCacheConfiguration, LanguageModelCompletionError, LanguageModelCompletionEvent, LanguageModelId, LanguageModelName, LanguageModelProvider, LanguageModelProviderId, LanguageModelProviderName, LanguageModelProviderState, LanguageModelRequest, LanguageModelToolChoice, @@ -304,8 +304,8 @@ impl LanguageModelProvider for CloudLanguageModelProvider { PROVIDER_NAME } - fn icon(&self) -> IconName { - IconName::AiZed + fn icon(&self) -> IconOrSvg { + IconOrSvg::Icon(IconName::AiZed) } fn default_model(&self, cx: &App) -> Option> { diff --git a/crates/language_models/src/provider/copilot_chat.rs b/crates/language_models/src/provider/copilot_chat.rs index 70198b337e467e1618192e781d3e3be305fea9c5..68eaab1dbed33a8d983de6a919b75dc809410a70 100644 --- a/crates/language_models/src/provider/copilot_chat.rs +++ b/crates/language_models/src/provider/copilot_chat.rs @@ -18,12 +18,12 @@ use gpui::{AnyView, App, AsyncApp, Entity, Subscription, Task}; use http_client::StatusCode; use language::language_settings::all_language_settings; use language_model::{ - AuthenticateError, LanguageModel, LanguageModelCompletionError, LanguageModelCompletionEvent, - LanguageModelId, LanguageModelName, LanguageModelProvider, LanguageModelProviderId, - LanguageModelProviderName, LanguageModelProviderState, LanguageModelRequest, - LanguageModelRequestMessage, LanguageModelToolChoice, LanguageModelToolResultContent, - LanguageModelToolSchemaFormat, LanguageModelToolUse, MessageContent, RateLimiter, Role, - StopReason, TokenUsage, + AuthenticateError, IconOrSvg, LanguageModel, LanguageModelCompletionError, + LanguageModelCompletionEvent, LanguageModelId, LanguageModelName, LanguageModelProvider, + LanguageModelProviderId, LanguageModelProviderName, LanguageModelProviderState, + LanguageModelRequest, LanguageModelRequestMessage, LanguageModelToolChoice, + LanguageModelToolResultContent, LanguageModelToolSchemaFormat, LanguageModelToolUse, + MessageContent, RateLimiter, Role, StopReason, TokenUsage, }; use settings::SettingsStore; use ui::prelude::*; @@ -104,8 +104,8 @@ impl LanguageModelProvider for CopilotChatLanguageModelProvider { PROVIDER_NAME } - fn icon(&self) -> IconName { - IconName::Copilot + fn icon(&self) -> IconOrSvg { + IconOrSvg::Icon(IconName::Copilot) } fn default_model(&self, cx: &App) -> Option> { diff --git a/crates/language_models/src/provider/deepseek.rs b/crates/language_models/src/provider/deepseek.rs index b00a5d82f5665a5c87c662d1af84fbeb9ac07ebb..b3264b869195aa34d7083cd31992d8c220d20349 100644 --- a/crates/language_models/src/provider/deepseek.rs +++ b/crates/language_models/src/provider/deepseek.rs @@ -7,7 +7,7 @@ use futures::{FutureExt, StreamExt, future, future::BoxFuture, stream::BoxStream use gpui::{AnyView, App, AsyncApp, Context, Entity, SharedString, Task, Window}; use http_client::HttpClient; use language_model::{ - ApiKeyState, AuthenticateError, EnvVar, LanguageModel, LanguageModelCompletionError, + ApiKeyState, AuthenticateError, EnvVar, IconOrSvg, LanguageModel, LanguageModelCompletionError, LanguageModelCompletionEvent, LanguageModelId, LanguageModelName, LanguageModelProvider, LanguageModelProviderId, LanguageModelProviderName, LanguageModelProviderState, LanguageModelRequest, LanguageModelToolChoice, LanguageModelToolResultContent, @@ -127,8 +127,8 @@ impl LanguageModelProvider for DeepSeekLanguageModelProvider { PROVIDER_NAME } - fn icon(&self) -> IconName { - IconName::AiDeepSeek + fn icon(&self) -> IconOrSvg { + IconOrSvg::Icon(IconName::AiDeepSeek) } fn default_model(&self, _cx: &App) -> Option> { diff --git a/crates/language_models/src/provider/google.rs b/crates/language_models/src/provider/google.rs index 989b99061b6d0f4c6680f08616c55946138ae0fe..7d567d60f405c7880cb6494f6d2ff604d7f53ac2 100644 --- a/crates/language_models/src/provider/google.rs +++ b/crates/language_models/src/provider/google.rs @@ -14,7 +14,7 @@ use language_model::{ LanguageModelToolUse, LanguageModelToolUseId, MessageContent, StopReason, }; use language_model::{ - LanguageModel, LanguageModelId, LanguageModelName, LanguageModelProvider, + IconOrSvg, LanguageModel, LanguageModelId, LanguageModelName, LanguageModelProvider, LanguageModelProviderId, LanguageModelProviderName, LanguageModelProviderState, LanguageModelRequest, RateLimiter, Role, }; @@ -164,8 +164,8 @@ impl LanguageModelProvider for GoogleLanguageModelProvider { PROVIDER_NAME } - fn icon(&self) -> IconName { - IconName::AiGoogle + fn icon(&self) -> IconOrSvg { + IconOrSvg::Icon(IconName::AiGoogle) } fn default_model(&self, _cx: &App) -> Option> { diff --git a/crates/language_models/src/provider/lmstudio.rs b/crates/language_models/src/provider/lmstudio.rs index 94f99f10afc8928fb7fbc8526ab46e7dca37a5ce..237b64ac7d0ed728b057f6b553ad2a2a1ebae1db 100644 --- a/crates/language_models/src/provider/lmstudio.rs +++ b/crates/language_models/src/provider/lmstudio.rs @@ -10,7 +10,7 @@ use language_model::{ StopReason, TokenUsage, }; use language_model::{ - LanguageModel, LanguageModelId, LanguageModelName, LanguageModelProvider, + IconOrSvg, LanguageModel, LanguageModelId, LanguageModelName, LanguageModelProvider, LanguageModelProviderId, LanguageModelProviderName, LanguageModelProviderState, LanguageModelRequest, RateLimiter, Role, }; @@ -175,8 +175,8 @@ impl LanguageModelProvider for LmStudioLanguageModelProvider { PROVIDER_NAME } - fn icon(&self) -> IconName { - IconName::AiLmStudio + fn icon(&self) -> IconOrSvg { + IconOrSvg::Icon(IconName::AiLmStudio) } fn default_model(&self, _: &App) -> Option> { diff --git a/crates/language_models/src/provider/mistral.rs b/crates/language_models/src/provider/mistral.rs index 64f3999e3aa96b2611e265a6eaf5df8063332c2a..0b8af405ade8fc00c0d1e2e57ba115560d94a71d 100644 --- a/crates/language_models/src/provider/mistral.rs +++ b/crates/language_models/src/provider/mistral.rs @@ -5,7 +5,7 @@ use futures::{FutureExt, Stream, StreamExt, future, future::BoxFuture, stream::B use gpui::{AnyView, App, AsyncApp, Context, Entity, Global, SharedString, Task, Window}; use http_client::HttpClient; use language_model::{ - ApiKeyState, AuthenticateError, EnvVar, LanguageModel, LanguageModelCompletionError, + ApiKeyState, AuthenticateError, EnvVar, IconOrSvg, LanguageModel, LanguageModelCompletionError, LanguageModelCompletionEvent, LanguageModelId, LanguageModelName, LanguageModelProvider, LanguageModelProviderId, LanguageModelProviderName, LanguageModelProviderState, LanguageModelRequest, LanguageModelToolChoice, LanguageModelToolResultContent, @@ -176,8 +176,8 @@ impl LanguageModelProvider for MistralLanguageModelProvider { PROVIDER_NAME } - fn icon(&self) -> IconName { - IconName::AiMistral + fn icon(&self) -> IconOrSvg { + IconOrSvg::Icon(IconName::AiMistral) } fn default_model(&self, _cx: &App) -> Option> { diff --git a/crates/language_models/src/provider/ollama.rs b/crates/language_models/src/provider/ollama.rs index 860d635b6ac704c2762023c463432bebae08d4a5..f5d8820e710ea6c9f89de6da5a7aae2f204c6470 100644 --- a/crates/language_models/src/provider/ollama.rs +++ b/crates/language_models/src/provider/ollama.rs @@ -5,7 +5,7 @@ use futures::{Stream, TryFutureExt, stream}; use gpui::{AnyView, App, AsyncApp, Context, CursorStyle, Entity, Task}; use http_client::HttpClient; use language_model::{ - ApiKeyState, AuthenticateError, EnvVar, LanguageModel, LanguageModelCompletionError, + ApiKeyState, AuthenticateError, EnvVar, IconOrSvg, LanguageModel, LanguageModelCompletionError, LanguageModelCompletionEvent, LanguageModelId, LanguageModelName, LanguageModelProvider, LanguageModelProviderId, LanguageModelProviderName, LanguageModelProviderState, LanguageModelRequest, LanguageModelRequestTool, LanguageModelToolChoice, LanguageModelToolUse, @@ -221,8 +221,8 @@ impl LanguageModelProvider for OllamaLanguageModelProvider { PROVIDER_NAME } - fn icon(&self) -> IconName { - IconName::AiOllama + fn icon(&self) -> IconOrSvg { + IconOrSvg::Icon(IconName::AiOllama) } fn default_model(&self, _: &App) -> Option> { diff --git a/crates/language_models/src/provider/open_ai.rs b/crates/language_models/src/provider/open_ai.rs index afaffba3e53eb2496f9fae795d69b9e9c9f57249..905d2b37862eebf57c7fb56a540b388338cfd065 100644 --- a/crates/language_models/src/provider/open_ai.rs +++ b/crates/language_models/src/provider/open_ai.rs @@ -5,7 +5,7 @@ use futures::{FutureExt, StreamExt, future, future::BoxFuture}; use gpui::{AnyView, App, AsyncApp, Context, Entity, SharedString, Task, Window}; use http_client::HttpClient; use language_model::{ - ApiKeyState, AuthenticateError, EnvVar, LanguageModel, LanguageModelCompletionError, + ApiKeyState, AuthenticateError, EnvVar, IconOrSvg, LanguageModel, LanguageModelCompletionError, LanguageModelCompletionEvent, LanguageModelId, LanguageModelName, LanguageModelProvider, LanguageModelProviderId, LanguageModelProviderName, LanguageModelProviderState, LanguageModelRequest, LanguageModelToolChoice, LanguageModelToolResultContent, @@ -122,8 +122,8 @@ impl LanguageModelProvider for OpenAiLanguageModelProvider { PROVIDER_NAME } - fn icon(&self) -> IconName { - IconName::AiOpenAi + fn icon(&self) -> IconOrSvg { + IconOrSvg::Icon(IconName::AiOpenAi) } fn default_model(&self, _cx: &App) -> Option> { diff --git a/crates/language_models/src/provider/open_ai_compatible.rs b/crates/language_models/src/provider/open_ai_compatible.rs index e6e7a9984da3d48b9e3c0f9571b8e916359fba03..f95f567739d76670d3cfa7b835bbfaf34ddef92f 100644 --- a/crates/language_models/src/provider/open_ai_compatible.rs +++ b/crates/language_models/src/provider/open_ai_compatible.rs @@ -4,7 +4,7 @@ use futures::{FutureExt, StreamExt, future, future::BoxFuture}; use gpui::{AnyView, App, AsyncApp, Context, Entity, SharedString, Task, Window}; use http_client::HttpClient; use language_model::{ - ApiKeyState, AuthenticateError, EnvVar, LanguageModel, LanguageModelCompletionError, + ApiKeyState, AuthenticateError, EnvVar, IconOrSvg, LanguageModel, LanguageModelCompletionError, LanguageModelCompletionEvent, LanguageModelId, LanguageModelName, LanguageModelProvider, LanguageModelProviderId, LanguageModelProviderName, LanguageModelProviderState, LanguageModelRequest, LanguageModelToolChoice, LanguageModelToolSchemaFormat, RateLimiter, @@ -133,8 +133,8 @@ impl LanguageModelProvider for OpenAiCompatibleLanguageModelProvider { self.name.clone() } - fn icon(&self) -> IconName { - IconName::AiOpenAiCompat + fn icon(&self) -> IconOrSvg { + IconOrSvg::Icon(IconName::AiOpenAiCompat) } fn default_model(&self, cx: &App) -> Option> { diff --git a/crates/language_models/src/provider/open_router.rs b/crates/language_models/src/provider/open_router.rs index ad2e90d9dd5f4ece7e2582a867da50f6962c981c..48d68ddebff7e0c9bbe39dbca696dd2ffcf62605 100644 --- a/crates/language_models/src/provider/open_router.rs +++ b/crates/language_models/src/provider/open_router.rs @@ -4,7 +4,7 @@ use futures::{FutureExt, Stream, StreamExt, future, future::BoxFuture}; use gpui::{AnyView, App, AsyncApp, Context, Entity, SharedString, Task}; use http_client::HttpClient; use language_model::{ - ApiKeyState, AuthenticateError, EnvVar, LanguageModel, LanguageModelCompletionError, + ApiKeyState, AuthenticateError, EnvVar, IconOrSvg, LanguageModel, LanguageModelCompletionError, LanguageModelCompletionEvent, LanguageModelId, LanguageModelName, LanguageModelProvider, LanguageModelProviderId, LanguageModelProviderName, LanguageModelProviderState, LanguageModelRequest, LanguageModelToolChoice, LanguageModelToolResultContent, @@ -180,8 +180,8 @@ impl LanguageModelProvider for OpenRouterLanguageModelProvider { PROVIDER_NAME } - fn icon(&self) -> IconName { - IconName::AiOpenRouter + fn icon(&self) -> IconOrSvg { + IconOrSvg::Icon(IconName::AiOpenRouter) } fn default_model(&self, _cx: &App) -> Option> { diff --git a/crates/language_models/src/provider/vercel.rs b/crates/language_models/src/provider/vercel.rs index 4dfe848df80123dc4c37d27b81f76db359e076f9..e2e692eafff94c56d481dfc2bd96dbfa7adda262 100644 --- a/crates/language_models/src/provider/vercel.rs +++ b/crates/language_models/src/provider/vercel.rs @@ -4,7 +4,7 @@ use futures::{FutureExt, StreamExt, future, future::BoxFuture}; use gpui::{AnyView, App, AsyncApp, Context, Entity, SharedString, Task, Window}; use http_client::HttpClient; use language_model::{ - ApiKeyState, AuthenticateError, EnvVar, LanguageModel, LanguageModelCompletionError, + ApiKeyState, AuthenticateError, EnvVar, IconOrSvg, LanguageModel, LanguageModelCompletionError, LanguageModelCompletionEvent, LanguageModelId, LanguageModelName, LanguageModelProvider, LanguageModelProviderId, LanguageModelProviderName, LanguageModelProviderState, LanguageModelRequest, LanguageModelToolChoice, RateLimiter, Role, env_var, @@ -117,8 +117,8 @@ impl LanguageModelProvider for VercelLanguageModelProvider { PROVIDER_NAME } - fn icon(&self) -> IconName { - IconName::AiVZero + fn icon(&self) -> IconOrSvg { + IconOrSvg::Icon(IconName::AiVZero) } fn default_model(&self, _cx: &App) -> Option> { diff --git a/crates/language_models/src/provider/x_ai.rs b/crates/language_models/src/provider/x_ai.rs index 19c50d71cf4e483b68d48c8b982a975f3091ff46..f0aa0e71a83ae1a201d76a33f63ca0aadc6936a9 100644 --- a/crates/language_models/src/provider/x_ai.rs +++ b/crates/language_models/src/provider/x_ai.rs @@ -4,7 +4,7 @@ use futures::{FutureExt, StreamExt, future, future::BoxFuture}; use gpui::{AnyView, App, AsyncApp, Context, Entity, Task, Window}; use http_client::HttpClient; use language_model::{ - ApiKeyState, AuthenticateError, EnvVar, LanguageModel, LanguageModelCompletionError, + ApiKeyState, AuthenticateError, EnvVar, IconOrSvg, LanguageModel, LanguageModelCompletionError, LanguageModelCompletionEvent, LanguageModelId, LanguageModelName, LanguageModelProvider, LanguageModelProviderId, LanguageModelProviderName, LanguageModelProviderState, LanguageModelRequest, LanguageModelToolChoice, LanguageModelToolSchemaFormat, RateLimiter, @@ -118,8 +118,8 @@ impl LanguageModelProvider for XAiLanguageModelProvider { PROVIDER_NAME } - fn icon(&self) -> IconName { - IconName::AiXAi + fn icon(&self) -> IconOrSvg { + IconOrSvg::Icon(IconName::AiXAi) } fn default_model(&self, _cx: &App) -> Option> { diff --git a/crates/ui/src/components/icon.rs b/crates/ui/src/components/icon.rs index 1c8e36ec18d6184b38eb6772e8f5a13be181ae00..9d2c7ae3b515744125879f4a2c0e0d3e9a4fb841 100644 --- a/crates/ui/src/components/icon.rs +++ b/crates/ui/src/components/icon.rs @@ -126,17 +126,6 @@ enum IconSource { ExternalSvg(SharedString), } -impl IconSource { - fn from_path(path: impl Into) -> Self { - let path = path.into(); - if path.starts_with("icons/") { - Self::Embedded(path) - } else { - Self::External(Arc::from(PathBuf::from(path.as_ref()))) - } - } -} - #[derive(IntoElement, RegisterComponent)] pub struct Icon { source: IconSource, @@ -155,9 +144,18 @@ impl Icon { } } + /// Create an icon from a path. Uses a heuristic to determine if it's embedded or external: + /// - Paths starting with "icons/" are treated as embedded SVGs + /// - Other paths are treated as external raster images (from icon themes) pub fn from_path(path: impl Into) -> Self { + let path = path.into(); + let source = if path.starts_with("icons/") { + IconSource::Embedded(path) + } else { + IconSource::External(Arc::from(PathBuf::from(path.as_ref()))) + }; Self { - source: IconSource::from_path(path), + source, color: Color::default(), size: IconSize::default().rems(), transformation: Transformation::default(), From 6976208e21436e88a4a5a094b440d41c482c5c84 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Thu, 18 Dec 2025 15:23:09 -0700 Subject: [PATCH 526/621] Move autofix stuff to zippy (#45304) Although I wanted to avoid the dependency, it's hard to get github to do what we want. Release Notes: - N/A --- .github/workflows/extension_tests.yml | 3 +- .github/workflows/release.yml | 16 +--- .github/workflows/release_nightly.yml | 6 +- .github/workflows/run_tests.yml | 47 ++---------- .../xtask/src/tasks/workflows/run_tests.rs | 73 +------------------ tooling/xtask/src/tasks/workflows/steps.rs | 33 +-------- 6 files changed, 19 insertions(+), 159 deletions(-) diff --git a/.github/workflows/extension_tests.yml b/.github/workflows/extension_tests.yml index 7a7fff9b97d694c1b02dd426f5d59301fe2be81e..9f0917e388c74cffed8f342f7504bc111e6f5147 100644 --- a/.github/workflows/extension_tests.yml +++ b/.github/workflows/extension_tests.yml @@ -61,8 +61,7 @@ jobs: uses: namespacelabs/nscloud-cache-action@v1 with: cache: rust - - id: cargo_fmt - name: steps::cargo_fmt + - name: steps::cargo_fmt run: cargo fmt --all -- --check shell: bash -euxo pipefail {0} - name: extension_tests::run_clippy diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 317d5a8df37a62887ce4ddcdd67c8d77b48d56d6..ffc2554a55e00a5bdb7bd1ee0bfeebd5667755d5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,8 +26,7 @@ jobs: uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 with: node-version: '20' - - id: clippy - name: steps::clippy + - name: steps::clippy run: ./script/clippy shell: bash -euxo pipefail {0} - name: steps::clear_target_dir_if_large @@ -72,15 +71,9 @@ jobs: uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 with: node-version: '20' - - id: clippy - name: steps::clippy + - name: steps::clippy run: ./script/clippy shell: bash -euxo pipefail {0} - - id: record_clippy_failure - name: steps::record_clippy_failure - if: always() - run: echo "failed=${{ steps.clippy.outcome == 'failure' }}" >> "$GITHUB_OUTPUT" - shell: bash -euxo pipefail {0} - name: steps::cargo_install_nextest uses: taiki-e/install-action@nextest - name: steps::clear_target_dir_if_large @@ -94,8 +87,6 @@ jobs: run: | rm -rf ./../.cargo shell: bash -euxo pipefail {0} - outputs: - clippy_failed: ${{ steps.record_clippy_failure.outputs.failed == 'true' }} timeout-minutes: 60 run_tests_windows: if: (github.repository_owner == 'zed-industries' || github.repository_owner == 'zed-extensions') @@ -114,8 +105,7 @@ jobs: uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 with: node-version: '20' - - id: clippy - name: steps::clippy + - name: steps::clippy run: ./script/clippy.ps1 shell: pwsh - name: steps::clear_target_dir_if_large diff --git a/.github/workflows/release_nightly.yml b/.github/workflows/release_nightly.yml index b23e4b7518a672c0d586ea5ba437db5cf8f94bb6..d76244175accc3e816cbd7d5dc322d2529a0a236 100644 --- a/.github/workflows/release_nightly.yml +++ b/.github/workflows/release_nightly.yml @@ -20,8 +20,7 @@ jobs: with: clean: false fetch-depth: 0 - - id: cargo_fmt - name: steps::cargo_fmt + - name: steps::cargo_fmt run: cargo fmt --all -- --check shell: bash -euxo pipefail {0} - name: ./script/clippy @@ -45,8 +44,7 @@ jobs: uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 with: node-version: '20' - - id: clippy - name: steps::clippy + - name: steps::clippy run: ./script/clippy.ps1 shell: pwsh - name: steps::clear_target_dir_if_large diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index fac3221d63a080fa53b7ba1c5b7249e6a405c73c..256bb2916a56485c06c2ebc4de8724151d622c4f 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -74,19 +74,12 @@ jobs: uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 with: version: '9' - - id: prettier - name: steps::prettier + - name: steps::prettier run: ./script/prettier shell: bash -euxo pipefail {0} - - id: cargo_fmt - name: steps::cargo_fmt + - name: steps::cargo_fmt run: cargo fmt --all -- --check shell: bash -euxo pipefail {0} - - id: record_style_failure - name: steps::record_style_failure - if: always() - run: echo "failed=${{ steps.prettier.outcome == 'failure' || steps.cargo_fmt.outcome == 'failure' }}" >> "$GITHUB_OUTPUT" - shell: bash -euxo pipefail {0} - name: ./script/check-todos run: ./script/check-todos shell: bash -euxo pipefail {0} @@ -97,8 +90,6 @@ jobs: uses: crate-ci/typos@2d0ce569feab1f8752f1dde43cc2f2aa53236e06 with: config: ./typos.toml - outputs: - style_failed: ${{ steps.record_style_failure.outputs.failed == 'true' }} timeout-minutes: 60 run_tests_windows: needs: @@ -119,8 +110,7 @@ jobs: uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 with: node-version: '20' - - id: clippy - name: steps::clippy + - name: steps::clippy run: ./script/clippy.ps1 shell: pwsh - name: steps::clear_target_dir_if_large @@ -167,15 +157,9 @@ jobs: uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 with: node-version: '20' - - id: clippy - name: steps::clippy + - name: steps::clippy run: ./script/clippy shell: bash -euxo pipefail {0} - - id: record_clippy_failure - name: steps::record_clippy_failure - if: always() - run: echo "failed=${{ steps.clippy.outcome == 'failure' }}" >> "$GITHUB_OUTPUT" - shell: bash -euxo pipefail {0} - name: steps::cargo_install_nextest uses: taiki-e/install-action@nextest - name: steps::clear_target_dir_if_large @@ -189,8 +173,6 @@ jobs: run: | rm -rf ./../.cargo shell: bash -euxo pipefail {0} - outputs: - clippy_failed: ${{ steps.record_clippy_failure.outputs.failed == 'true' }} timeout-minutes: 60 run_tests_mac: needs: @@ -211,8 +193,7 @@ jobs: uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 with: node-version: '20' - - id: clippy - name: steps::clippy + - name: steps::clippy run: ./script/clippy shell: bash -euxo pipefail {0} - name: steps::clear_target_dir_if_large @@ -592,24 +573,6 @@ jobs: exit $EXIT_CODE shell: bash -euxo pipefail {0} - call_autofix: - needs: - - check_style - - run_tests_linux - if: always() && (needs.check_style.outputs.style_failed == 'true' || needs.run_tests_linux.outputs.clippy_failed == 'true') && github.event_name == 'pull_request' && github.actor != 'zed-zippy[bot]' - runs-on: namespace-profile-2x4-ubuntu-2404 - steps: - - id: get-app-token - name: steps::authenticate_as_zippy - uses: actions/create-github-app-token@bef1eaf1c0ac2b148ee2a0a74c65fbe6db0631f1 - with: - app-id: ${{ secrets.ZED_ZIPPY_APP_ID }} - private-key: ${{ secrets.ZED_ZIPPY_APP_PRIVATE_KEY }} - - name: run_tests::call_autofix::dispatch_autofix - run: gh workflow run autofix_pr.yml -f pr_number=${{ github.event.pull_request.number }} -f run_clippy=${{ needs.run_tests_linux.outputs.clippy_failed == 'true' }} - shell: bash -euxo pipefail {0} - env: - GITHUB_TOKEN: ${{ steps.get-app-token.outputs.token }} concurrency: group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.ref_name == 'main' && github.sha || 'anysha' }} cancel-in-progress: true diff --git a/tooling/xtask/src/tasks/workflows/run_tests.rs b/tooling/xtask/src/tasks/workflows/run_tests.rs index d0caab82b057f21735b7f828c8917a358dd548b2..f726f48740eb7819fbbd3fed369e5e4e89c526c9 100644 --- a/tooling/xtask/src/tasks/workflows/run_tests.rs +++ b/tooling/xtask/src/tasks/workflows/run_tests.rs @@ -45,15 +45,11 @@ pub(crate) fn run_tests() -> Workflow { &should_run_tests, ]); - let check_style = check_style(); - let run_tests_linux = run_platform_tests(Platform::Linux); - let call_autofix = call_autofix(&check_style, &run_tests_linux); - let mut jobs = vec![ orchestrate, - check_style, + check_style(), should_run_tests.guard(run_platform_tests(Platform::Windows)), - should_run_tests.guard(run_tests_linux), + should_run_tests.guard(run_platform_tests(Platform::Linux)), should_run_tests.guard(run_platform_tests(Platform::Mac)), should_run_tests.guard(doctests()), should_run_tests.guard(check_workspace_binaries()), @@ -110,7 +106,6 @@ pub(crate) fn run_tests() -> Workflow { workflow }) .add_job(tests_pass.name, tests_pass.job) - .add_job(call_autofix.name, call_autofix.job) } // Generates a bash script that checks changed files against regex patterns @@ -226,8 +221,6 @@ pub fn tests_pass(jobs: &[NamedJob]) -> NamedJob { named::job(job) } -pub const STYLE_FAILED_OUTPUT: &str = "style_failed"; - fn check_style() -> NamedJob { fn check_for_typos() -> Step { named::uses( @@ -245,56 +238,12 @@ fn check_style() -> NamedJob { .add_step(steps::setup_pnpm()) .add_step(steps::prettier()) .add_step(steps::cargo_fmt()) - .add_step(steps::record_style_failure()) .add_step(steps::script("./script/check-todos")) .add_step(steps::script("./script/check-keymaps")) - .add_step(check_for_typos()) - .outputs([( - STYLE_FAILED_OUTPUT.to_owned(), - format!( - "${{{{ steps.{}.outputs.failed == 'true' }}}}", - steps::RECORD_STYLE_FAILURE_STEP_ID - ), - )]), + .add_step(check_for_typos()), ) } -fn call_autofix(check_style: &NamedJob, run_tests_linux: &NamedJob) -> NamedJob { - fn dispatch_autofix(run_tests_linux_name: &str) -> Step { - let clippy_failed_expr = format!( - "needs.{}.outputs.{} == 'true'", - run_tests_linux_name, CLIPPY_FAILED_OUTPUT - ); - named::bash(format!( - "gh workflow run autofix_pr.yml -f pr_number=${{{{ github.event.pull_request.number }}}} -f run_clippy=${{{{ {} }}}}", - clippy_failed_expr - )) - .add_env(("GITHUB_TOKEN", "${{ steps.get-app-token.outputs.token }}")) - } - - let style_failed_expr = format!( - "needs.{}.outputs.{} == 'true'", - check_style.name, STYLE_FAILED_OUTPUT - ); - let clippy_failed_expr = format!( - "needs.{}.outputs.{} == 'true'", - run_tests_linux.name, CLIPPY_FAILED_OUTPUT - ); - let (authenticate, _token) = steps::authenticate_as_zippy(); - - let job = Job::default() - .runs_on(runners::LINUX_SMALL) - .cond(Expression::new(format!( - "always() && ({} || {}) && github.event_name == 'pull_request' && github.actor != 'zed-zippy[bot]'", - style_failed_expr, clippy_failed_expr - ))) - .needs(vec![check_style.name.clone(), run_tests_linux.name.clone()]) - .add_step(authenticate) - .add_step(dispatch_autofix(&run_tests_linux.name)); - - named::job(job) -} - fn check_dependencies() -> NamedJob { fn install_cargo_machete() -> Step { named::uses( @@ -355,8 +304,6 @@ fn check_workspace_binaries() -> NamedJob { ) } -pub const CLIPPY_FAILED_OUTPUT: &str = "clippy_failed"; - pub(crate) fn run_platform_tests(platform: Platform) -> NamedJob { let runner = match platform { Platform::Windows => runners::WINDOWS_DEFAULT, @@ -378,24 +325,12 @@ pub(crate) fn run_platform_tests(platform: Platform) -> NamedJob { ) .add_step(steps::setup_node()) .add_step(steps::clippy(platform)) - .when(platform == Platform::Linux, |job| { - job.add_step(steps::record_clippy_failure()) - }) .when(platform == Platform::Linux, |job| { job.add_step(steps::cargo_install_nextest()) }) .add_step(steps::clear_target_dir_if_large(platform)) .add_step(steps::cargo_nextest(platform)) - .add_step(steps::cleanup_cargo_config(platform)) - .when(platform == Platform::Linux, |job| { - job.outputs([( - CLIPPY_FAILED_OUTPUT.to_owned(), - format!( - "${{{{ steps.{}.outputs.failed == 'true' }}}}", - steps::RECORD_CLIPPY_FAILURE_STEP_ID - ), - )]) - }), + .add_step(steps::cleanup_cargo_config(platform)), } } diff --git a/tooling/xtask/src/tasks/workflows/steps.rs b/tooling/xtask/src/tasks/workflows/steps.rs index eaa51dc35205f51e7fe3a56668ed0679e92999f0..a0b071cd6c31654b42adddbba47dd24c60da7df2 100644 --- a/tooling/xtask/src/tasks/workflows/steps.rs +++ b/tooling/xtask/src/tasks/workflows/steps.rs @@ -54,25 +54,12 @@ pub fn setup_sentry() -> Step { .add_with(("token", vars::SENTRY_AUTH_TOKEN)) } -pub const PRETTIER_STEP_ID: &str = "prettier"; -pub const CARGO_FMT_STEP_ID: &str = "cargo_fmt"; -pub const RECORD_STYLE_FAILURE_STEP_ID: &str = "record_style_failure"; - pub fn prettier() -> Step { - named::bash("./script/prettier").id(PRETTIER_STEP_ID) + named::bash("./script/prettier") } pub fn cargo_fmt() -> Step { - named::bash("cargo fmt --all -- --check").id(CARGO_FMT_STEP_ID) -} - -pub fn record_style_failure() -> Step { - named::bash(format!( - "echo \"failed=${{{{ steps.{}.outcome == 'failure' || steps.{}.outcome == 'failure' }}}}\" >> \"$GITHUB_OUTPUT\"", - PRETTIER_STEP_ID, CARGO_FMT_STEP_ID - )) - .id(RECORD_STYLE_FAILURE_STEP_ID) - .if_condition(Expression::new("always()")) + named::bash("cargo fmt --all -- --check") } pub fn cargo_install_nextest() -> Step { @@ -118,25 +105,13 @@ pub fn clear_target_dir_if_large(platform: Platform) -> Step { } } -pub const CLIPPY_STEP_ID: &str = "clippy"; -pub const RECORD_CLIPPY_FAILURE_STEP_ID: &str = "record_clippy_failure"; - pub fn clippy(platform: Platform) -> Step { match platform { - Platform::Windows => named::pwsh("./script/clippy.ps1").id(CLIPPY_STEP_ID), - _ => named::bash("./script/clippy").id(CLIPPY_STEP_ID), + Platform::Windows => named::pwsh("./script/clippy.ps1"), + _ => named::bash("./script/clippy"), } } -pub fn record_clippy_failure() -> Step { - named::bash(format!( - "echo \"failed=${{{{ steps.{}.outcome == 'failure' }}}}\" >> \"$GITHUB_OUTPUT\"", - CLIPPY_STEP_ID - )) - .id(RECORD_CLIPPY_FAILURE_STEP_ID) - .if_condition(Expression::new("always()")) -} - pub fn cache_rust_dependencies_namespace() -> Step { named::uses("namespacelabs", "nscloud-cache-action", "v1").add_with(("cache", "rust")) } From e0ff995e2d5673af67af275187271776b57436d7 Mon Sep 17 00:00:00 2001 From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Date: Thu, 18 Dec 2025 22:18:41 -0300 Subject: [PATCH 527/621] agent ui: Make some UI elements more consistent (#45319) - Both the mode, profile, and model selectors have the option to cycle through its options with a keybinding. In the tooltip that shows it, in some of them the "Cycle Through..." label was at the top, and in others at the bottom. Now it's all at the bottom. - We used different language in different places for "going to a file". The tool call edit card's header said "_Jump_ to File" while the edit files list said "_Go_ to File". Now it's both "Go to File". Release Notes: - N/A --- crates/agent_ui/src/acp/mode_selector.rs | 14 +++++++------- crates/agent_ui/src/acp/thread_view.rs | 2 +- crates/agent_ui/src/profile_selector.rs | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/crates/agent_ui/src/acp/mode_selector.rs b/crates/agent_ui/src/acp/mode_selector.rs index 1f50ce74321d393ba6c7f5083bd889bc3dc2c0e1..22af75a6e96edc4f597819e04e2e84b80ba0417a 100644 --- a/crates/agent_ui/src/acp/mode_selector.rs +++ b/crates/agent_ui/src/acp/mode_selector.rs @@ -188,25 +188,25 @@ impl Render for ModeSelector { .gap_1() .child( h_flex() - .pb_1() .gap_2() .justify_between() - .border_b_1() - .border_color(cx.theme().colors().border_variant) - .child(Label::new("Cycle Through Modes")) + .child(Label::new("Toggle Mode Menu")) .child(KeyBinding::for_action_in( - &CycleModeSelector, + &ToggleProfileSelector, &focus_handle, cx, )), ) .child( h_flex() + .pb_1() .gap_2() .justify_between() - .child(Label::new("Toggle Mode Menu")) + .border_b_1() + .border_color(cx.theme().colors().border_variant) + .child(Label::new("Cycle Through Modes")) .child(KeyBinding::for_action_in( - &ToggleProfileSelector, + &CycleModeSelector, &focus_handle, cx, )), diff --git a/crates/agent_ui/src/acp/thread_view.rs b/crates/agent_ui/src/acp/thread_view.rs index 8364fd8c0f4d8fd55df8f2e74e990e603029db78..32b2de2c0d850676bf7a6a80ee88950d62aa24e0 100644 --- a/crates/agent_ui/src/acp/thread_view.rs +++ b/crates/agent_ui/src/acp/thread_view.rs @@ -2718,7 +2718,7 @@ impl AcpThreadView { ..default_markdown_style(false, true, window, cx) }, )) - .tooltip(Tooltip::text("Jump to File")) + .tooltip(Tooltip::text("Go to File")) .on_click(cx.listener(move |this, _, window, cx| { this.open_tool_call_location(entry_ix, 0, window, cx); })) diff --git a/crates/agent_ui/src/profile_selector.rs b/crates/agent_ui/src/profile_selector.rs index ac08070fcefa92854b51bc8a66d4d388d08e087d..327d2c67e2d5e87e67935ecdfa7fb6cd41acbcb5 100644 --- a/crates/agent_ui/src/profile_selector.rs +++ b/crates/agent_ui/src/profile_selector.rs @@ -191,6 +191,9 @@ impl Render for ProfileSelector { let container = || h_flex().gap_1().justify_between(); v_flex() .gap_1() + .child(container().child(Label::new("Toggle Profile Menu")).child( + KeyBinding::for_action_in(&ToggleProfileSelector, &focus_handle, cx), + )) .child( container() .pb_1() @@ -203,9 +206,6 @@ impl Render for ProfileSelector { cx, )), ) - .child(container().child(Label::new("Toggle Profile Menu")).child( - KeyBinding::for_action_in(&ToggleProfileSelector, &focus_handle, cx), - )) .into_any() } }), From 435d4c5f2415f569d192ee27bf8d6ed5157360f6 Mon Sep 17 00:00:00 2001 From: Ben Kunkle Date: Thu, 18 Dec 2025 20:56:47 -0600 Subject: [PATCH 528/621] vim: Make `vaf` include const for arrow functions in JS/TS/TSX (#45327) Closes #24264 Release Notes: - N/A *or* Added/Fixed/Improved ... --- .../src/test/editor_lsp_test_context.rs | 86 ++++ crates/language/src/buffer_tests.rs | 98 +++++ crates/language/src/syntax_map.rs | 61 ++- .../languages/src/javascript/textobjects.scm | 38 +- crates/languages/src/tsx/textobjects.scm | 38 +- .../languages/src/typescript/textobjects.scm | 39 +- crates/vim/src/object.rs | 386 ++++++++++++++++++ crates/vim/src/visual.rs | 16 +- 8 files changed, 742 insertions(+), 20 deletions(-) diff --git a/crates/editor/src/test/editor_lsp_test_context.rs b/crates/editor/src/test/editor_lsp_test_context.rs index 7c4c0e48d36dbb9f74a1c835c63fa2b91c5681d9..3e7c47c2ac5efeedde51f180bcfcb424aec31c86 100644 --- a/crates/editor/src/test/editor_lsp_test_context.rs +++ b/crates/editor/src/test/editor_lsp_test_context.rs @@ -205,6 +205,49 @@ impl EditorLspTestContext { (_ "{" "}" @end) @indent (_ "(" ")" @end) @indent "#})), + text_objects: Some(Cow::from(indoc! {r#" + (function_declaration + body: (_ + "{" + (_)* @function.inside + "}")) @function.around + + (method_definition + body: (_ + "{" + (_)* @function.inside + "}")) @function.around + + ; Arrow function in variable declaration - capture the full declaration + ([ + (lexical_declaration + (variable_declarator + value: (arrow_function + body: (statement_block + "{" + (_)* @function.inside + "}")))) + (variable_declaration + (variable_declarator + value: (arrow_function + body: (statement_block + "{" + (_)* @function.inside + "}")))) + ]) @function.around + + ([ + (lexical_declaration + (variable_declarator + value: (arrow_function))) + (variable_declaration + (variable_declarator + value: (arrow_function))) + ]) @function.around + + ; Catch-all for arrow functions in other contexts (callbacks, etc.) + ((arrow_function) @function.around (#not-has-parent? @function.around variable_declarator)) + "#})), ..Default::default() }) .expect("Could not parse queries"); @@ -276,6 +319,49 @@ impl EditorLspTestContext { (jsx_opening_element) @start (jsx_closing_element)? @end) @indent "#})), + text_objects: Some(Cow::from(indoc! {r#" + (function_declaration + body: (_ + "{" + (_)* @function.inside + "}")) @function.around + + (method_definition + body: (_ + "{" + (_)* @function.inside + "}")) @function.around + + ; Arrow function in variable declaration - capture the full declaration + ([ + (lexical_declaration + (variable_declarator + value: (arrow_function + body: (statement_block + "{" + (_)* @function.inside + "}")))) + (variable_declaration + (variable_declarator + value: (arrow_function + body: (statement_block + "{" + (_)* @function.inside + "}")))) + ]) @function.around + + ([ + (lexical_declaration + (variable_declarator + value: (arrow_function))) + (variable_declaration + (variable_declarator + value: (arrow_function))) + ]) @function.around + + ; Catch-all for arrow functions in other contexts (callbacks, etc.) + ((arrow_function) @function.around (#not-has-parent? @function.around variable_declarator)) + "#})), ..Default::default() }) .expect("Could not parse queries"); diff --git a/crates/language/src/buffer_tests.rs b/crates/language/src/buffer_tests.rs index 54e2ef4065460547f4a3f86db7d3a3986dff65eb..2c2d93c8239f0f3fcb1de0956de2d3400f13e96b 100644 --- a/crates/language/src/buffer_tests.rs +++ b/crates/language/src/buffer_tests.rs @@ -1141,6 +1141,104 @@ fn test_text_objects(cx: &mut App) { ) } +#[gpui::test] +fn test_text_objects_with_has_parent_predicate(cx: &mut App) { + use std::borrow::Cow; + + // Create a language with a custom text_objects query that uses #has-parent? + // This query only matches closure_expression when it's inside a call_expression + let language = Language::new( + LanguageConfig { + name: "Rust".into(), + matcher: LanguageMatcher { + path_suffixes: vec!["rs".to_string()], + ..Default::default() + }, + ..Default::default() + }, + Some(tree_sitter_rust::LANGUAGE.into()), + ) + .with_queries(LanguageQueries { + text_objects: Some(Cow::from(indoc! {r#" + ; Only match closures that are arguments to function calls + (closure_expression) @function.around + (#has-parent? @function.around arguments) + "#})), + ..Default::default() + }) + .expect("Could not parse queries"); + + let (text, ranges) = marked_text_ranges( + indoc! {r#" + fn main() { + let standalone = |x| x + 1; + let result = foo(|y| y * ˇ2); + }"# + }, + false, + ); + + let buffer = cx.new(|cx| Buffer::local(text.clone(), cx).with_language(Arc::new(language), cx)); + let snapshot = buffer.update(cx, |buffer, _| buffer.snapshot()); + + let matches = snapshot + .text_object_ranges(ranges[0].clone(), TreeSitterOptions::default()) + .map(|(range, text_object)| (&text[range], text_object)) + .collect::>(); + + // Should only match the closure inside foo(), not the standalone closure + assert_eq!(matches, &[("|y| y * 2", TextObject::AroundFunction),]); +} + +#[gpui::test] +fn test_text_objects_with_not_has_parent_predicate(cx: &mut App) { + use std::borrow::Cow; + + // Create a language with a custom text_objects query that uses #not-has-parent? + // This query only matches closure_expression when it's NOT inside a call_expression + let language = Language::new( + LanguageConfig { + name: "Rust".into(), + matcher: LanguageMatcher { + path_suffixes: vec!["rs".to_string()], + ..Default::default() + }, + ..Default::default() + }, + Some(tree_sitter_rust::LANGUAGE.into()), + ) + .with_queries(LanguageQueries { + text_objects: Some(Cow::from(indoc! {r#" + ; Only match closures that are NOT arguments to function calls + (closure_expression) @function.around + (#not-has-parent? @function.around arguments) + "#})), + ..Default::default() + }) + .expect("Could not parse queries"); + + let (text, ranges) = marked_text_ranges( + indoc! {r#" + fn main() { + let standalone = |x| x +ˇ 1; + let result = foo(|y| y * 2); + }"# + }, + false, + ); + + let buffer = cx.new(|cx| Buffer::local(text.clone(), cx).with_language(Arc::new(language), cx)); + let snapshot = buffer.update(cx, |buffer, _| buffer.snapshot()); + + let matches = snapshot + .text_object_ranges(ranges[0].clone(), TreeSitterOptions::default()) + .map(|(range, text_object)| (&text[range], text_object)) + .collect::>(); + + // Should only match the standalone closure, not the one inside foo() + assert_eq!(matches, &[("|x| x + 1", TextObject::AroundFunction),]); +} + #[gpui::test] fn test_enclosing_bracket_ranges(cx: &mut App) { #[track_caller] diff --git a/crates/language/src/syntax_map.rs b/crates/language/src/syntax_map.rs index 77e90c4ca89d0b6e5b8cb0a604175ec9a97e719e..db4ab4f459c35a98752bef1eb5be558084b5c906 100644 --- a/crates/language/src/syntax_map.rs +++ b/crates/language/src/syntax_map.rs @@ -19,7 +19,10 @@ use std::{ use streaming_iterator::StreamingIterator; use sum_tree::{Bias, Dimensions, SeekTarget, SumTree}; use text::{Anchor, BufferSnapshot, OffsetRangeExt, Point, Rope, ToOffset, ToPoint}; -use tree_sitter::{Node, Query, QueryCapture, QueryCaptures, QueryCursor, QueryMatches, Tree}; +use tree_sitter::{ + Node, Query, QueryCapture, QueryCaptures, QueryCursor, QueryMatch, QueryMatches, + QueryPredicateArg, Tree, +}; pub const MAX_BYTES_TO_QUERY: usize = 16 * 1024; @@ -82,6 +85,7 @@ struct SyntaxMapMatchesLayer<'a> { next_captures: Vec>, has_next: bool, matches: QueryMatches<'a, 'a, TextProvider<'a>, &'a [u8]>, + query: &'a Query, grammar_index: usize, _query_cursor: QueryCursorHandle, } @@ -1163,6 +1167,7 @@ impl<'a> SyntaxMapMatches<'a> { depth: layer.depth, grammar_index, matches, + query, next_pattern_index: 0, next_captures: Vec::new(), has_next: false, @@ -1260,13 +1265,20 @@ impl SyntaxMapCapturesLayer<'_> { impl SyntaxMapMatchesLayer<'_> { fn advance(&mut self) { - if let Some(mat) = self.matches.next() { - self.next_captures.clear(); - self.next_captures.extend_from_slice(mat.captures); - self.next_pattern_index = mat.pattern_index; - self.has_next = true; - } else { - self.has_next = false; + loop { + if let Some(mat) = self.matches.next() { + if !satisfies_custom_predicates(self.query, mat) { + continue; + } + self.next_captures.clear(); + self.next_captures.extend_from_slice(mat.captures); + self.next_pattern_index = mat.pattern_index; + self.has_next = true; + return; + } else { + self.has_next = false; + return; + } } } @@ -1295,6 +1307,39 @@ impl<'a> Iterator for SyntaxMapCaptures<'a> { } } +fn satisfies_custom_predicates(query: &Query, mat: &QueryMatch) -> bool { + for predicate in query.general_predicates(mat.pattern_index) { + let satisfied = match predicate.operator.as_ref() { + "has-parent?" => has_parent(&predicate.args, mat), + "not-has-parent?" => !has_parent(&predicate.args, mat), + _ => true, + }; + if !satisfied { + return false; + } + } + true +} + +fn has_parent(args: &[QueryPredicateArg], mat: &QueryMatch) -> bool { + let ( + Some(QueryPredicateArg::Capture(capture_ix)), + Some(QueryPredicateArg::String(parent_kind)), + ) = (args.first(), args.get(1)) + else { + return false; + }; + + let Some(capture) = mat.captures.iter().find(|c| c.index == *capture_ix) else { + return false; + }; + + capture + .node + .parent() + .is_some_and(|p| p.kind() == parent_kind.as_ref()) +} + fn join_ranges( a: impl Iterator>, b: impl Iterator>, diff --git a/crates/languages/src/javascript/textobjects.scm b/crates/languages/src/javascript/textobjects.scm index 1a273ddb5000ba920868272bb4ac31d270095442..eace658e6b9847bcc651deedad2bc27cbfbf6975 100644 --- a/crates/languages/src/javascript/textobjects.scm +++ b/crates/languages/src/javascript/textobjects.scm @@ -18,13 +18,47 @@ (_)* @function.inside "}")) @function.around -(arrow_function +((arrow_function body: (statement_block "{" (_)* @function.inside "}")) @function.around + (#not-has-parent? @function.around variable_declarator)) -(arrow_function) @function.around +; Arrow function in variable declaration - capture the full declaration +([ + (lexical_declaration + (variable_declarator + value: (arrow_function + body: (statement_block + "{" + (_)* @function.inside + "}")))) + (variable_declaration + (variable_declarator + value: (arrow_function + body: (statement_block + "{" + (_)* @function.inside + "}")))) +]) @function.around + +; Arrow function in variable declaration (captures body for expression-bodied arrows) +([ + (lexical_declaration + (variable_declarator + value: (arrow_function + body: (_) @function.inside))) + (variable_declaration + (variable_declarator + value: (arrow_function + body: (_) @function.inside))) +]) @function.around + +; Catch-all for arrow functions in other contexts (callbacks, etc.) +((arrow_function + body: (_) @function.inside) @function.around + (#not-has-parent? @function.around variable_declarator)) (generator_function body: (_ diff --git a/crates/languages/src/tsx/textobjects.scm b/crates/languages/src/tsx/textobjects.scm index 836fed35ba1c1093b84e48a8da19d89177a69944..628a921f3ac9ea04ff59654d72caf73cebbc9071 100644 --- a/crates/languages/src/tsx/textobjects.scm +++ b/crates/languages/src/tsx/textobjects.scm @@ -18,13 +18,47 @@ (_)* @function.inside "}")) @function.around -(arrow_function +((arrow_function body: (statement_block "{" (_)* @function.inside "}")) @function.around + (#not-has-parent? @function.around variable_declarator)) -(arrow_function) @function.around +; Arrow function in variable declaration - capture the full declaration +([ + (lexical_declaration + (variable_declarator + value: (arrow_function + body: (statement_block + "{" + (_)* @function.inside + "}")))) + (variable_declaration + (variable_declarator + value: (arrow_function + body: (statement_block + "{" + (_)* @function.inside + "}")))) +]) @function.around + +; Arrow function in variable declaration (expression body fallback) +([ + (lexical_declaration + (variable_declarator + value: (arrow_function + body: (_) @function.inside))) + (variable_declaration + (variable_declarator + value: (arrow_function + body: (_) @function.inside))) +]) @function.around + +; Catch-all for arrow functions in other contexts (callbacks, etc.) +((arrow_function + body: (_) @function.inside) @function.around + (#not-has-parent? @function.around variable_declarator)) (function_signature) @function.around (generator_function diff --git a/crates/languages/src/typescript/textobjects.scm b/crates/languages/src/typescript/textobjects.scm index 836fed35ba1c1093b84e48a8da19d89177a69944..96289f058cd7b605a8f5b4c8966e3c372022d065 100644 --- a/crates/languages/src/typescript/textobjects.scm +++ b/crates/languages/src/typescript/textobjects.scm @@ -18,13 +18,48 @@ (_)* @function.inside "}")) @function.around -(arrow_function +((arrow_function body: (statement_block "{" (_)* @function.inside "}")) @function.around + (#not-has-parent? @function.around variable_declarator)) -(arrow_function) @function.around +; Arrow function in variable declaration - capture the full declaration +([ + (lexical_declaration + (variable_declarator + value: (arrow_function + body: (statement_block + "{" + (_)* @function.inside + "}")))) + (variable_declaration + (variable_declarator + value: (arrow_function + body: (statement_block + "{" + (_)* @function.inside + "}")))) +]) @function.around + +; Arrow function in variable declaration - capture body as @function.inside +; (for statement blocks, the more specific pattern above captures just the contents) +([ + (lexical_declaration + (variable_declarator + value: (arrow_function + body: (_) @function.inside))) + (variable_declaration + (variable_declarator + value: (arrow_function + body: (_) @function.inside))) +]) @function.around + +; Catch-all for arrow functions in other contexts (callbacks, etc.) +((arrow_function + body: (_) @function.inside) @function.around + (#not-has-parent? @function.around variable_declarator)) (function_signature) @function.around (generator_function diff --git a/crates/vim/src/object.rs b/crates/vim/src/object.rs index 02150332405c6d5ea4d5dd78f477348be968fddf..e9a2f4fc63d31f78a9a7abce8aac785b56eb1fd4 100644 --- a/crates/vim/src/object.rs +++ b/crates/vim/src/object.rs @@ -3407,4 +3407,390 @@ mod test { .assert_eq(" ˇf = (x: unknown) => {"); cx.shared_clipboard().await.assert_eq("const "); } + + #[gpui::test] + async fn test_arrow_function_text_object(cx: &mut gpui::TestAppContext) { + let mut cx = VimTestContext::new_typescript(cx).await; + + cx.set_state( + indoc! {" + const foo = () => { + return ˇ1; + }; + "}, + Mode::Normal, + ); + cx.simulate_keystrokes("v a f"); + cx.assert_state( + indoc! {" + «const foo = () => { + return 1; + };ˇ» + "}, + Mode::VisualLine, + ); + + cx.set_state( + indoc! {" + arr.map(() => { + return ˇ1; + }); + "}, + Mode::Normal, + ); + cx.simulate_keystrokes("v a f"); + cx.assert_state( + indoc! {" + arr.map(«() => { + return 1; + }ˇ»); + "}, + Mode::VisualLine, + ); + + cx.set_state( + indoc! {" + const foo = () => { + return ˇ1; + }; + "}, + Mode::Normal, + ); + cx.simulate_keystrokes("v i f"); + cx.assert_state( + indoc! {" + const foo = () => { + «return 1;ˇ» + }; + "}, + Mode::Visual, + ); + + cx.set_state( + indoc! {" + (() => { + console.log(ˇ1); + })(); + "}, + Mode::Normal, + ); + cx.simulate_keystrokes("v a f"); + cx.assert_state( + indoc! {" + («() => { + console.log(1); + }ˇ»)(); + "}, + Mode::VisualLine, + ); + + cx.set_state( + indoc! {" + const foo = () => { + return ˇ1; + }; + export { foo }; + "}, + Mode::Normal, + ); + cx.simulate_keystrokes("v a f"); + cx.assert_state( + indoc! {" + «const foo = () => { + return 1; + };ˇ» + export { foo }; + "}, + Mode::VisualLine, + ); + + cx.set_state( + indoc! {" + let bar = () => { + return ˇ2; + }; + "}, + Mode::Normal, + ); + cx.simulate_keystrokes("v a f"); + cx.assert_state( + indoc! {" + «let bar = () => { + return 2; + };ˇ» + "}, + Mode::VisualLine, + ); + + cx.set_state( + indoc! {" + var baz = () => { + return ˇ3; + }; + "}, + Mode::Normal, + ); + cx.simulate_keystrokes("v a f"); + cx.assert_state( + indoc! {" + «var baz = () => { + return 3; + };ˇ» + "}, + Mode::VisualLine, + ); + + cx.set_state( + indoc! {" + const add = (a, b) => a + ˇb; + "}, + Mode::Normal, + ); + cx.simulate_keystrokes("v a f"); + cx.assert_state( + indoc! {" + «const add = (a, b) => a + b;ˇ» + "}, + Mode::VisualLine, + ); + + cx.set_state( + indoc! {" + const add = ˇ(a, b) => a + b; + "}, + Mode::Normal, + ); + cx.simulate_keystrokes("v a f"); + cx.assert_state( + indoc! {" + «const add = (a, b) => a + b;ˇ» + "}, + Mode::VisualLine, + ); + + cx.set_state( + indoc! {" + const add = (a, b) => a + bˇ; + "}, + Mode::Normal, + ); + cx.simulate_keystrokes("v a f"); + cx.assert_state( + indoc! {" + «const add = (a, b) => a + b;ˇ» + "}, + Mode::VisualLine, + ); + + cx.set_state( + indoc! {" + const add = (a, b) =ˇ> a + b; + "}, + Mode::Normal, + ); + cx.simulate_keystrokes("v a f"); + cx.assert_state( + indoc! {" + «const add = (a, b) => a + b;ˇ» + "}, + Mode::VisualLine, + ); + } + + #[gpui::test] + async fn test_arrow_function_in_jsx(cx: &mut gpui::TestAppContext) { + let mut cx = VimTestContext::new_tsx(cx).await; + + cx.set_state( + indoc! {r#" + export const MyComponent = () => { + return ( +
+
{ + alert("Hello world!"); + console.log(ˇ"clicked"); + }}>Hello world!
+
+ ); + }; + "#}, + Mode::Normal, + ); + cx.simulate_keystrokes("v a f"); + cx.assert_state( + indoc! {r#" + export const MyComponent = () => { + return ( +
+
{ + alert("Hello world!"); + console.log("clicked"); + }ˇ»}>Hello world!
+
+ ); + }; + "#}, + Mode::VisualLine, + ); + + cx.set_state( + indoc! {r#" + export const MyComponent = () => { + return ( +
+
console.log("clickˇed")}>Hello world!
+
+ ); + }; + "#}, + Mode::Normal, + ); + cx.simulate_keystrokes("v a f"); + cx.assert_state( + indoc! {r#" + export const MyComponent = () => { + return ( +
+
console.log("clicked")ˇ»}>Hello world!
+
+ ); + }; + "#}, + Mode::VisualLine, + ); + + cx.set_state( + indoc! {r#" + export const MyComponent = () => { + return ( +
+
console.log("clicked")}>Hello world!
+
+ ); + }; + "#}, + Mode::Normal, + ); + cx.simulate_keystrokes("v a f"); + cx.assert_state( + indoc! {r#" + export const MyComponent = () => { + return ( +
+
console.log("clicked")ˇ»}>Hello world!
+
+ ); + }; + "#}, + Mode::VisualLine, + ); + + cx.set_state( + indoc! {r#" + export const MyComponent = () => { + return ( +
+
console.log("clicked"ˇ)}>Hello world!
+
+ ); + }; + "#}, + Mode::Normal, + ); + cx.simulate_keystrokes("v a f"); + cx.assert_state( + indoc! {r#" + export const MyComponent = () => { + return ( +
+
console.log("clicked")ˇ»}>Hello world!
+
+ ); + }; + "#}, + Mode::VisualLine, + ); + + cx.set_state( + indoc! {r#" + export const MyComponent = () => { + return ( +
+
console.log("clicked")}>Hello world!
+
+ ); + }; + "#}, + Mode::Normal, + ); + cx.simulate_keystrokes("v a f"); + cx.assert_state( + indoc! {r#" + export const MyComponent = () => { + return ( +
+
console.log("clicked")ˇ»}>Hello world!
+
+ ); + }; + "#}, + Mode::VisualLine, + ); + + cx.set_state( + indoc! {r#" + export const MyComponent = () => { + return ( +
+
{ + console.log("cliˇcked"); + }}>Hello world!
+
+ ); + }; + "#}, + Mode::Normal, + ); + cx.simulate_keystrokes("v a f"); + cx.assert_state( + indoc! {r#" + export const MyComponent = () => { + return ( +
+
{ + console.log("clicked"); + }ˇ»}>Hello world!
+
+ ); + }; + "#}, + Mode::VisualLine, + ); + + cx.set_state( + indoc! {r#" + export const MyComponent = () => { + return ( +
+
fˇoo()}>Hello world!
+
+ ); + }; + "#}, + Mode::Normal, + ); + cx.simulate_keystrokes("v a f"); + cx.assert_state( + indoc! {r#" + export const MyComponent = () => { + return ( +
+
foo()ˇ»}>Hello world!
+
+ ); + }; + "#}, + Mode::VisualLine, + ); + } } diff --git a/crates/vim/src/visual.rs b/crates/vim/src/visual.rs index 3c6f237435e3924a907e059ed1a878641c287e7e..5667190bb7239ee3e534a5556d96452a7c68b1ef 100644 --- a/crates/vim/src/visual.rs +++ b/crates/vim/src/visual.rs @@ -522,12 +522,16 @@ impl Vim { selection.start = original_point.to_display_point(map) } } else { - selection.end = movement::saturating_right( - map, - original_point.to_display_point(map), - ); - if original_point.column > 0 { - selection.reversed = true + let original_display_point = + original_point.to_display_point(map); + if selection.end <= original_display_point { + selection.end = movement::saturating_right( + map, + original_display_point, + ); + if original_point.column > 0 { + selection.reversed = true + } } } } From 3f67c5220d3834817e84c454c29a8f92f2688c1d Mon Sep 17 00:00:00 2001 From: Ben Kunkle Date: Thu, 18 Dec 2025 20:59:05 -0600 Subject: [PATCH 529/621] Remove `zed` dependency from `docs_preprocessor` (#45130) Closes #ISSUE Uses the existing `--dump-all-actions` arg on the Zed binary to generate an asset of all of our actions so that the `docs_preprocessor` can injest it, rather than depending on the Zed crate itself to collect all action names Release Notes: - N/A *or* Added/Fixed/Improved ... --------- Co-authored-by: Zed Zippy <234243425+zed-zippy[bot]@users.noreply.github.com> --- .github/workflows/run_tests.yml | 3 + .gitignore | 1 + Cargo.lock | 3 - crates/docs_preprocessor/Cargo.toml | 5 +- crates/docs_preprocessor/src/main.rs | 88 +++++++++++-------- crates/title_bar/src/application_menu.rs | 20 ++--- crates/zed/Cargo.toml | 4 - crates/zed/src/main.rs | 13 +-- crates/zed/src/zed-main.rs | 8 -- crates/zed/src/zed.rs | 1 - script/generate-action-metadata | 10 +++ .../xtask/src/tasks/workflows/run_tests.rs | 1 + 12 files changed, 83 insertions(+), 74 deletions(-) delete mode 100644 crates/zed/src/zed-main.rs create mode 100755 script/generate-action-metadata diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index 256bb2916a56485c06c2ebc4de8724151d622c4f..47a84574e7c33fb8a40a90c67cd4f7dadb356978 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -353,6 +353,9 @@ jobs: - name: steps::download_wasi_sdk run: ./script/download-wasi-sdk shell: bash -euxo pipefail {0} + - name: ./script/generate-action-metadata + run: ./script/generate-action-metadata + shell: bash -euxo pipefail {0} - name: run_tests::check_docs::install_mdbook uses: peaceiris/actions-mdbook@ee69d230fe19748b7abf22df32acaa93833fad08 with: diff --git a/.gitignore b/.gitignore index 54faaf1374299ee8f97925a95a93b375c349d707..c71417c32bff76af9d4c9c67661556e1625c9d15 100644 --- a/.gitignore +++ b/.gitignore @@ -36,6 +36,7 @@ DerivedData/ Packages xcuserdata/ +crates/docs_preprocessor/actions.json # Don't commit any secrets to the repo. .env diff --git a/Cargo.lock b/Cargo.lock index 1bb39f2bdf8c5745b3e5c0e5ad1200be34ec6ab0..3f7077e721e934cd6cb05af0cdaefef75602b429 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5021,8 +5021,6 @@ name = "docs_preprocessor" version = "0.1.0" dependencies = [ "anyhow", - "command_palette", - "gpui", "mdbook", "regex", "serde", @@ -5031,7 +5029,6 @@ dependencies = [ "task", "theme", "util", - "zed", "zlog", ] diff --git a/crates/docs_preprocessor/Cargo.toml b/crates/docs_preprocessor/Cargo.toml index e71f9ae3f3f6fcff790db27fb1e377f0d1c20e40..07da23899956822f7577118ae85b6338b4cefae7 100644 --- a/crates/docs_preprocessor/Cargo.toml +++ b/crates/docs_preprocessor/Cargo.toml @@ -7,8 +7,6 @@ license = "GPL-3.0-or-later" [dependencies] anyhow.workspace = true -command_palette.workspace = true -gpui.workspace = true # We are specifically pinning this version of mdbook, as later versions introduce issues with double-nested subdirectories. # Ask @maxdeviant about this before bumping. mdbook = "= 0.4.40" @@ -17,7 +15,6 @@ serde.workspace = true serde_json.workspace = true settings.workspace = true util.workspace = true -zed.workspace = true zlog.workspace = true task.workspace = true theme.workspace = true @@ -27,4 +24,4 @@ workspace = true [[bin]] name = "docs_preprocessor" -path = "src/main.rs" +path = "src/main.rs" \ No newline at end of file diff --git a/crates/docs_preprocessor/src/main.rs b/crates/docs_preprocessor/src/main.rs index b614a8251139413f4b316937db1d4e3c0d551df6..d90dcc10db9fbd8d27a968094ea8d733a79b7e80 100644 --- a/crates/docs_preprocessor/src/main.rs +++ b/crates/docs_preprocessor/src/main.rs @@ -22,16 +22,13 @@ static KEYMAP_WINDOWS: LazyLock = LazyLock::new(|| { load_keymap("keymaps/default-windows.json").expect("Failed to load Windows keymap") }); -static ALL_ACTIONS: LazyLock> = LazyLock::new(dump_all_gpui_actions); +static ALL_ACTIONS: LazyLock> = LazyLock::new(load_all_actions); const FRONT_MATTER_COMMENT: &str = ""; fn main() -> Result<()> { zlog::init(); zlog::init_output_stderr(); - // call a zed:: function so everything in `zed` crate is linked and - // all actions in the actual app are registered - zed::stdout_is_a_pty(); let args = std::env::args().skip(1).collect::>(); match args.get(0).map(String::as_str) { @@ -72,8 +69,8 @@ enum PreprocessorError { impl PreprocessorError { fn new_for_not_found_action(action_name: String) -> Self { for action in &*ALL_ACTIONS { - for alias in action.deprecated_aliases { - if alias == &action_name { + for alias in &action.deprecated_aliases { + if alias == action_name.as_str() { return PreprocessorError::DeprecatedActionUsed { used: action_name, should_be: action.name.to_string(), @@ -214,7 +211,7 @@ fn template_and_validate_keybindings(book: &mut Book, errors: &mut HashSet{}
", name); }; format!("{}", &action.human_name) }) @@ -257,11 +256,19 @@ fn template_and_validate_actions(book: &mut Book, errors: &mut HashSet Option<&ActionDef> { ALL_ACTIONS - .binary_search_by(|action| action.name.cmp(name)) + .binary_search_by(|action| action.name.as_str().cmp(name)) .ok() .map(|index| &ALL_ACTIONS[index]) } +fn actions_available() -> bool { + !ALL_ACTIONS.is_empty() +} + +fn is_missing_action(name: &str) -> bool { + actions_available() && find_action_by_name(name).is_none() +} + fn find_binding(os: &str, action: &str) -> Option { let keymap = match os { "macos" => &KEYMAP_MACOS, @@ -384,18 +391,13 @@ fn template_and_validate_json_snippets(book: &mut Book, errors: &mut HashSet
, _>>()
-                            .context("Failed to parse keystroke")?;
+                    for (_keystrokes, action) in section.bindings() {
                         if let Some((action_name, _)) = settings::KeymapFile::parse_action(action)
                             .map_err(|err| anyhow::format_err!(err))
                             .context("Failed to parse action")?
                         {
                             anyhow::ensure!(
-                                find_action_by_name(action_name).is_some(),
+                                !is_missing_action(action_name),
                                 "Action not found: {}",
                                 action_name
                             );
@@ -491,27 +493,35 @@ where
     });
 }
 
-#[derive(Debug, serde::Serialize)]
+#[derive(Debug, serde::Serialize, serde::Deserialize)]
 struct ActionDef {
-    name: &'static str,
+    name: String,
     human_name: String,
-    deprecated_aliases: &'static [&'static str],
-    docs: Option<&'static str>,
+    deprecated_aliases: Vec,
+    #[serde(rename = "documentation")]
+    docs: Option,
 }
 
-fn dump_all_gpui_actions() -> Vec {
-    let mut actions = gpui::generate_list_of_all_registered_actions()
-        .map(|action| ActionDef {
-            name: action.name,
-            human_name: command_palette::humanize_action_name(action.name),
-            deprecated_aliases: action.deprecated_aliases,
-            docs: action.documentation,
-        })
-        .collect::>();
-
-    actions.sort_by_key(|a| a.name);
-
-    actions
+fn load_all_actions() -> Vec {
+    let asset_path = concat!(env!("CARGO_MANIFEST_DIR"), "/actions.json");
+    match std::fs::read_to_string(asset_path) {
+        Ok(content) => {
+            let mut actions: Vec =
+                serde_json::from_str(&content).expect("Failed to parse actions.json");
+            actions.sort_by(|a, b| a.name.cmp(&b.name));
+            actions
+        }
+        Err(err) => {
+            if std::env::var("CI").is_ok() {
+                panic!("actions.json not found at {}: {}", asset_path, err);
+            }
+            eprintln!(
+                "Warning: actions.json not found, action validation will be skipped: {}",
+                err
+            );
+            Vec::new()
+        }
+    }
 }
 
 fn handle_postprocessing() -> Result<()> {
@@ -647,7 +657,7 @@ fn generate_big_table_of_actions() -> String {
     let mut output = String::new();
 
     let mut actions_sorted = actions.iter().collect::>();
-    actions_sorted.sort_by_key(|a| a.name);
+    actions_sorted.sort_by_key(|a| a.name.as_str());
 
     // Start the definition list with custom styling for better spacing
     output.push_str("
\n"); @@ -664,7 +674,7 @@ fn generate_big_table_of_actions() -> String { output.push_str("
\n"); // Add the description, escaping HTML if needed - if let Some(description) = action.docs { + if let Some(description) = action.docs.as_ref() { output.push_str( &description .replace("&", "&") @@ -674,7 +684,7 @@ fn generate_big_table_of_actions() -> String { output.push_str("
\n"); } output.push_str("Keymap Name: "); - output.push_str(action.name); + output.push_str(&action.name); output.push_str("
\n"); if !action.deprecated_aliases.is_empty() { output.push_str("Deprecated Alias(es): "); diff --git a/crates/title_bar/src/application_menu.rs b/crates/title_bar/src/application_menu.rs index 817b73c45ecd2df4a76e9a67f425b2b459c0c026..579e4dadbd590981a4aee15019bbe73e2bb28d5c 100644 --- a/crates/title_bar/src/application_menu.rs +++ b/crates/title_bar/src/application_menu.rs @@ -1,12 +1,7 @@ -use gpui::{Entity, OwnedMenu, OwnedMenuItem}; +use gpui::{Action, Entity, OwnedMenu, OwnedMenuItem, actions}; use settings::Settings; -#[cfg(not(target_os = "macos"))] -use gpui::{Action, actions}; - -#[cfg(not(target_os = "macos"))] use schemars::JsonSchema; -#[cfg(not(target_os = "macos"))] use serde::Deserialize; use smallvec::SmallVec; @@ -14,18 +9,23 @@ use ui::{ContextMenu, PopoverMenu, PopoverMenuHandle, Tooltip, prelude::*}; use crate::title_bar_settings::TitleBarSettings; -#[cfg(not(target_os = "macos"))] actions!( app_menu, [ - /// Navigates to the menu item on the right. + /// Activates the menu on the right in the client-side application menu. + /// + /// Does not apply to platform menu bars (e.g. on macOS). ActivateMenuRight, - /// Navigates to the menu item on the left. + /// Activates the menu on the left in the client-side application menu. + /// + /// Does not apply to platform menu bars (e.g. on macOS). ActivateMenuLeft ] ); -#[cfg(not(target_os = "macos"))] +/// Opens the named menu in the client-side application menu. +/// +/// Does not apply to platform menu bars (e.g. on macOS). #[derive(Clone, Deserialize, JsonSchema, PartialEq, Default, Action)] #[action(namespace = app_menu)] pub struct OpenApplicationMenu(String); diff --git a/crates/zed/Cargo.toml b/crates/zed/Cargo.toml index fd160759f4440e2736d57cea62abb6bdb138ae72..80eca20e00309bb8d22552287a1c39cb9891307d 100644 --- a/crates/zed/Cargo.toml +++ b/crates/zed/Cargo.toml @@ -15,10 +15,6 @@ tracy = ["ztracing/tracy"] [[bin]] name = "zed" -path = "src/zed-main.rs" - -[lib] -name = "zed" path = "src/main.rs" [dependencies] diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rs index 7008e491c5e2ade35fa96cafbd9d8969c008fa96..312d16f0cd674a6dda81176863a859f3b763c2c0 100644 --- a/crates/zed/src/main.rs +++ b/crates/zed/src/main.rs @@ -1,3 +1,6 @@ +// Disable command line from opening on release mode +#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] + mod reliability; mod zed; @@ -163,9 +166,9 @@ fn fail_to_open_window(e: anyhow::Error, _cx: &mut App) { .detach(); } } -pub static STARTUP_TIME: OnceLock = OnceLock::new(); +static STARTUP_TIME: OnceLock = OnceLock::new(); -pub fn main() { +fn main() { STARTUP_TIME.get_or_init(|| Instant::now()); #[cfg(unix)] @@ -1301,7 +1304,7 @@ fn init_paths() -> HashMap> { }) } -pub fn stdout_is_a_pty() -> bool { +fn stdout_is_a_pty() -> bool { std::env::var(FORCE_CLI_MODE_ENV_VAR_NAME).ok().is_none() && io::stdout().is_terminal() } @@ -1547,14 +1550,14 @@ fn dump_all_gpui_actions() { struct ActionDef { name: &'static str, human_name: String, - aliases: &'static [&'static str], + deprecated_aliases: &'static [&'static str], documentation: Option<&'static str>, } let mut actions = gpui::generate_list_of_all_registered_actions() .map(|action| ActionDef { name: action.name, human_name: command_palette::humanize_action_name(action.name), - aliases: action.deprecated_aliases, + deprecated_aliases: action.deprecated_aliases, documentation: action.documentation, }) .collect::>(); diff --git a/crates/zed/src/zed-main.rs b/crates/zed/src/zed-main.rs deleted file mode 100644 index 6c49c197dda01e97828c3662aa09ecf57804dfbc..0000000000000000000000000000000000000000 --- a/crates/zed/src/zed-main.rs +++ /dev/null @@ -1,8 +0,0 @@ -// Disable command line from opening on release mode -#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] - -pub fn main() { - // separated out so that the file containing the main function can be imported by other crates, - // while having all gpui resources that are registered in main (primarily actions) initialized - zed::main(); -} diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs index d088df00839814e32a9c246a3486ac5ad5ca4b9e..3441cb88d96b06dfdbb65a58553d2c58f435d157 100644 --- a/crates/zed/src/zed.rs +++ b/crates/zed/src/zed.rs @@ -4780,7 +4780,6 @@ mod tests { "activity_indicator", "agent", "agents", - #[cfg(not(target_os = "macos"))] "app_menu", "assistant", "assistant2", diff --git a/script/generate-action-metadata b/script/generate-action-metadata new file mode 100755 index 0000000000000000000000000000000000000000..146b1f0d78ef92c47322a70dccf0e9e1f3f530d3 --- /dev/null +++ b/script/generate-action-metadata @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +set -euo pipefail + +cd "$(dirname "$0")/.." + +echo "Generating action metadata..." +cargo run -p zed -- --dump-all-actions > crates/docs_preprocessor/actions.json + +echo "Generated crates/docs_preprocessor/actions.json with $(grep -c '"name":' crates/docs_preprocessor/actions.json) actions" diff --git a/tooling/xtask/src/tasks/workflows/run_tests.rs b/tooling/xtask/src/tasks/workflows/run_tests.rs index f726f48740eb7819fbbd3fed369e5e4e89c526c9..aceb575b647e7ea0b2d8a74da9fbc153767d149d 100644 --- a/tooling/xtask/src/tasks/workflows/run_tests.rs +++ b/tooling/xtask/src/tasks/workflows/run_tests.rs @@ -448,6 +448,7 @@ fn check_docs() -> NamedJob { lychee_link_check("./docs/src/**/*"), // check markdown links ) .map(steps::install_linux_dependencies) + .add_step(steps::script("./script/generate-action-metadata")) .add_step(install_mdbook()) .add_step(build_docs()) .add_step( From 63c4406137916175ab23a2e65978f3bf508d122c Mon Sep 17 00:00:00 2001 From: Alvaro Parker <64918109+AlvaroParker@users.noreply.github.com> Date: Fri, 19 Dec 2025 00:21:46 -0300 Subject: [PATCH 530/621] git: Add git clone open listener (#41669) --- crates/git_ui/src/clone.rs | 155 ++++++++++++++++++++++++++++ crates/git_ui/src/git_panel.rs | 92 ++--------------- crates/git_ui/src/git_ui.rs | 1 + crates/zed/src/main.rs | 39 +++++++ crates/zed/src/zed/open_listener.rs | 102 ++++++++++++++++++ 5 files changed, 304 insertions(+), 85 deletions(-) create mode 100644 crates/git_ui/src/clone.rs diff --git a/crates/git_ui/src/clone.rs b/crates/git_ui/src/clone.rs new file mode 100644 index 0000000000000000000000000000000000000000..a6767d33304d3f20b7a5e78340f62c89ebe3ae58 --- /dev/null +++ b/crates/git_ui/src/clone.rs @@ -0,0 +1,155 @@ +use gpui::{App, Context, WeakEntity, Window}; +use notifications::status_toast::{StatusToast, ToastIcon}; +use std::sync::Arc; +use ui::{Color, IconName, SharedString}; +use util::ResultExt; +use workspace::{self, Workspace}; + +pub fn clone_and_open( + repo_url: SharedString, + workspace: WeakEntity, + window: &mut Window, + cx: &mut App, + on_success: Arc< + dyn Fn(&mut Workspace, &mut Window, &mut Context) + Send + Sync + 'static, + >, +) { + let destination_prompt = cx.prompt_for_paths(gpui::PathPromptOptions { + files: false, + directories: true, + multiple: false, + prompt: Some("Select as Repository Destination".into()), + }); + + window + .spawn(cx, async move |cx| { + let mut paths = destination_prompt.await.ok()?.ok()??; + let mut destination_dir = paths.pop()?; + + let repo_name = repo_url + .split('/') + .next_back() + .map(|name| name.strip_suffix(".git").unwrap_or(name)) + .unwrap_or("repository") + .to_owned(); + + let clone_task = workspace + .update(cx, |workspace, cx| { + let fs = workspace.app_state().fs.clone(); + let destination_dir = destination_dir.clone(); + let repo_url = repo_url.clone(); + cx.spawn(async move |_workspace, _cx| { + fs.git_clone(&repo_url, destination_dir.as_path()).await + }) + }) + .ok()?; + + if let Err(error) = clone_task.await { + workspace + .update(cx, |workspace, cx| { + let toast = StatusToast::new(error.to_string(), cx, |this, _| { + this.icon(ToastIcon::new(IconName::XCircle).color(Color::Error)) + .dismiss_button(true) + }); + workspace.toggle_status_toast(toast, cx); + }) + .log_err(); + return None; + } + + let has_worktrees = workspace + .read_with(cx, |workspace, cx| { + workspace.project().read(cx).worktrees(cx).next().is_some() + }) + .ok()?; + + let prompt_answer = if has_worktrees { + cx.update(|window, cx| { + window.prompt( + gpui::PromptLevel::Info, + &format!("Git Clone: {}", repo_name), + None, + &["Add repo to project", "Open repo in new project"], + cx, + ) + }) + .ok()? + .await + .ok()? + } else { + // Don't ask if project is empty + 0 + }; + + destination_dir.push(&repo_name); + + match prompt_answer { + 0 => { + workspace + .update_in(cx, |workspace, window, cx| { + let create_task = workspace.project().update(cx, |project, cx| { + project.create_worktree(destination_dir.as_path(), true, cx) + }); + + let workspace_weak = cx.weak_entity(); + let on_success = on_success.clone(); + cx.spawn_in(window, async move |_window, cx| { + if create_task.await.log_err().is_some() { + workspace_weak + .update_in(cx, |workspace, window, cx| { + (on_success)(workspace, window, cx); + }) + .ok(); + } + }) + .detach(); + }) + .ok()?; + } + 1 => { + workspace + .update(cx, move |workspace, cx| { + let app_state = workspace.app_state().clone(); + let destination_path = destination_dir.clone(); + let on_success = on_success.clone(); + + workspace::open_new( + Default::default(), + app_state, + cx, + move |workspace, window, cx| { + cx.activate(true); + + let create_task = + workspace.project().update(cx, |project, cx| { + project.create_worktree( + destination_path.as_path(), + true, + cx, + ) + }); + + let workspace_weak = cx.weak_entity(); + cx.spawn_in(window, async move |_window, cx| { + if create_task.await.log_err().is_some() { + workspace_weak + .update_in(cx, |workspace, window, cx| { + (on_success)(workspace, window, cx); + }) + .ok(); + } + }) + .detach(); + }, + ) + .detach(); + }) + .ok(); + } + _ => {} + } + + Some(()) + }) + .detach(); +} diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs index 0f967e68d1fab829fb37b626c23ecfebe69fb5dd..532f9a099a823796706be48ed14cc7da820c5d8b 100644 --- a/crates/git_ui/src/git_panel.rs +++ b/crates/git_ui/src/git_panel.rs @@ -2849,93 +2849,15 @@ impl GitPanel { } pub(crate) fn git_clone(&mut self, repo: String, window: &mut Window, cx: &mut Context) { - let path = cx.prompt_for_paths(gpui::PathPromptOptions { - files: false, - directories: true, - multiple: false, - prompt: Some("Select as Repository Destination".into()), - }); - let workspace = self.workspace.clone(); - cx.spawn_in(window, async move |this, cx| { - let mut paths = path.await.ok()?.ok()??; - let mut path = paths.pop()?; - let repo_name = repo.split("/").last()?.strip_suffix(".git")?.to_owned(); - - let fs = this.read_with(cx, |this, _| this.fs.clone()).ok()?; - - let prompt_answer = match fs.git_clone(&repo, path.as_path()).await { - Ok(_) => cx.update(|window, cx| { - window.prompt( - PromptLevel::Info, - &format!("Git Clone: {}", repo_name), - None, - &["Add repo to project", "Open repo in new project"], - cx, - ) - }), - Err(e) => { - this.update(cx, |this: &mut GitPanel, cx| { - let toast = StatusToast::new(e.to_string(), cx, |this, _| { - this.icon(ToastIcon::new(IconName::XCircle).color(Color::Error)) - .dismiss_button(true) - }); - - this.workspace - .update(cx, |workspace, cx| { - workspace.toggle_status_toast(toast, cx); - }) - .ok(); - }) - .ok()?; - - return None; - } - } - .ok()?; - - path.push(repo_name); - match prompt_answer.await.ok()? { - 0 => { - workspace - .update(cx, |workspace, cx| { - workspace - .project() - .update(cx, |project, cx| { - project.create_worktree(path.as_path(), true, cx) - }) - .detach(); - }) - .ok(); - } - 1 => { - workspace - .update(cx, move |workspace, cx| { - workspace::open_new( - Default::default(), - workspace.app_state().clone(), - cx, - move |workspace, _, cx| { - cx.activate(true); - workspace - .project() - .update(cx, |project, cx| { - project.create_worktree(&path, true, cx) - }) - .detach(); - }, - ) - .detach(); - }) - .ok(); - } - _ => {} - } - - Some(()) - }) - .detach(); + crate::clone::clone_and_open( + repo.into(), + workspace, + window, + cx, + Arc::new(|_workspace: &mut workspace::Workspace, _window, _cx| {}), + ); } pub(crate) fn git_init(&mut self, window: &mut Window, cx: &mut Context) { diff --git a/crates/git_ui/src/git_ui.rs b/crates/git_ui/src/git_ui.rs index 5f50e4ef8029d8f57cd159bc7da68b668b628f48..053c41bf10c5d97f9f5326fd17d6b5bf91297a03 100644 --- a/crates/git_ui/src/git_ui.rs +++ b/crates/git_ui/src/git_ui.rs @@ -10,6 +10,7 @@ use ui::{ }; mod blame_ui; +pub mod clone; use git::{ repository::{Branch, Upstream, UpstreamTracking, UpstreamTrackingStatus}, diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rs index 312d16f0cd674a6dda81176863a859f3b763c2c0..03e02bb0107d736c07eb3fc9626856943f8d80a6 100644 --- a/crates/zed/src/main.rs +++ b/crates/zed/src/main.rs @@ -18,11 +18,13 @@ use extension::ExtensionHostProxy; use fs::{Fs, RealFs}; use futures::{StreamExt, channel::oneshot, future}; use git::GitHostingProviderRegistry; +use git_ui::clone::clone_and_open; use gpui::{App, AppContext, Application, AsyncApp, Focusable as _, QuitMode, UpdateGlobal as _}; use gpui_tokio::Tokio; use language::LanguageRegistry; use onboarding::{FIRST_OPEN, show_onboarding_view}; +use project_panel::ProjectPanel; use prompt_store::PromptBuilder; use remote::RemoteConnectionOptions; use reqwest_client::ReqwestClient; @@ -36,10 +38,12 @@ use release_channel::{AppCommitSha, AppVersion, ReleaseChannel}; use session::{AppSession, Session}; use settings::{BaseKeymap, Settings, SettingsStore, watch_config_file}; use std::{ + cell::RefCell, env, io::{self, IsTerminal}, path::{Path, PathBuf}, process, + rc::Rc, sync::{Arc, OnceLock}, time::Instant, }; @@ -896,6 +900,41 @@ fn handle_open_request(request: OpenRequest, app_state: Arc, cx: &mut }) .detach_and_log_err(cx); } + OpenRequestKind::GitClone { repo_url } => { + workspace::with_active_or_new_workspace(cx, |_workspace, window, cx| { + if window.is_window_active() { + clone_and_open( + repo_url, + cx.weak_entity(), + window, + cx, + Arc::new(|workspace: &mut workspace::Workspace, window, cx| { + workspace.focus_panel::(window, cx); + }), + ); + return; + } + + let subscription = Rc::new(RefCell::new(None)); + subscription.replace(Some(cx.observe_in(&cx.entity(), window, { + let subscription = subscription.clone(); + let repo_url = repo_url; + move |_, workspace_entity, window, cx| { + if window.is_window_active() && subscription.take().is_some() { + clone_and_open( + repo_url.clone(), + workspace_entity.downgrade(), + window, + cx, + Arc::new(|workspace: &mut workspace::Workspace, window, cx| { + workspace.focus_panel::(window, cx); + }), + ); + } + } + }))); + }); + } OpenRequestKind::GitCommit { sha } => { cx.spawn(async move |cx| { let paths_with_position = diff --git a/crates/zed/src/zed/open_listener.rs b/crates/zed/src/zed/open_listener.rs index d61de0a291f3d3e7869225c0e07424cc3523f69b..842f98520133c70f711d84d3f490bec1ec59e16f 100644 --- a/crates/zed/src/zed/open_listener.rs +++ b/crates/zed/src/zed/open_listener.rs @@ -25,6 +25,7 @@ use std::path::{Path, PathBuf}; use std::sync::Arc; use std::thread; use std::time::Duration; +use ui::SharedString; use util::ResultExt; use util::paths::PathWithPosition; use workspace::PathList; @@ -58,6 +59,9 @@ pub enum OpenRequestKind { /// `None` opens settings without navigating to a specific path. setting_path: Option, }, + GitClone { + repo_url: SharedString, + }, GitCommit { sha: String, }, @@ -113,6 +117,8 @@ impl OpenRequest { this.kind = Some(OpenRequestKind::Setting { setting_path: Some(setting_path.to_string()), }); + } else if let Some(clone_path) = url.strip_prefix("zed://git/clone") { + this.parse_git_clone_url(clone_path)? } else if let Some(commit_path) = url.strip_prefix("zed://git/commit/") { this.parse_git_commit_url(commit_path)? } else if url.starts_with("ssh://") { @@ -143,6 +149,26 @@ impl OpenRequest { } } + fn parse_git_clone_url(&mut self, clone_path: &str) -> Result<()> { + // Format: /?repo= or ?repo= + let clone_path = clone_path.strip_prefix('/').unwrap_or(clone_path); + + let query = clone_path + .strip_prefix('?') + .context("invalid git clone url: missing query string")?; + + let repo_url = url::form_urlencoded::parse(query.as_bytes()) + .find_map(|(key, value)| (key == "repo").then_some(value)) + .filter(|s| !s.is_empty()) + .context("invalid git clone url: missing repo query parameter")? + .to_string() + .into(); + + self.kind = Some(OpenRequestKind::GitClone { repo_url }); + + Ok(()) + } + fn parse_git_commit_url(&mut self, commit_path: &str) -> Result<()> { // Format: ?repo= let (sha, query) = commit_path @@ -1087,4 +1113,80 @@ mod tests { assert!(!errored_reuse); } + + #[gpui::test] + fn test_parse_git_clone_url(cx: &mut TestAppContext) { + let _app_state = init_test(cx); + + let request = cx.update(|cx| { + OpenRequest::parse( + RawOpenRequest { + urls: vec![ + "zed://git/clone/?repo=https://github.com/zed-industries/zed.git".into(), + ], + ..Default::default() + }, + cx, + ) + .unwrap() + }); + + match request.kind { + Some(OpenRequestKind::GitClone { repo_url }) => { + assert_eq!(repo_url, "https://github.com/zed-industries/zed.git"); + } + _ => panic!("Expected GitClone kind"), + } + } + + #[gpui::test] + fn test_parse_git_clone_url_without_slash(cx: &mut TestAppContext) { + let _app_state = init_test(cx); + + let request = cx.update(|cx| { + OpenRequest::parse( + RawOpenRequest { + urls: vec![ + "zed://git/clone?repo=https://github.com/zed-industries/zed.git".into(), + ], + ..Default::default() + }, + cx, + ) + .unwrap() + }); + + match request.kind { + Some(OpenRequestKind::GitClone { repo_url }) => { + assert_eq!(repo_url, "https://github.com/zed-industries/zed.git"); + } + _ => panic!("Expected GitClone kind"), + } + } + + #[gpui::test] + fn test_parse_git_clone_url_with_encoding(cx: &mut TestAppContext) { + let _app_state = init_test(cx); + + let request = cx.update(|cx| { + OpenRequest::parse( + RawOpenRequest { + urls: vec![ + "zed://git/clone/?repo=https%3A%2F%2Fgithub.com%2Fzed-industries%2Fzed.git" + .into(), + ], + ..Default::default() + }, + cx, + ) + .unwrap() + }); + + match request.kind { + Some(OpenRequestKind::GitClone { repo_url }) => { + assert_eq!(repo_url, "https://github.com/zed-industries/zed.git"); + } + _ => panic!("Expected GitClone kind"), + } + } } From 05ce34eea4687ce1006df499bbbdff9527a8e41e Mon Sep 17 00:00:00 2001 From: Ben Kunkle Date: Thu, 18 Dec 2025 21:40:27 -0600 Subject: [PATCH 531/621] ci: Fix docs build post #45130 (#45330) Closes #ISSUE Release Notes: - N/A *or* Added/Fixed/Improved ... --- .github/actions/build_docs/action.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/actions/build_docs/action.yml b/.github/actions/build_docs/action.yml index d2e62d5b22ee49c7dcb9b42085a648098fbdb6bb..1ff271f73ff6b800ec3a94615f31c35a7729bb47 100644 --- a/.github/actions/build_docs/action.yml +++ b/.github/actions/build_docs/action.yml @@ -19,6 +19,18 @@ runs: shell: bash -euxo pipefail {0} run: ./script/linux + - name: Install mold linker + shell: bash -euxo pipefail {0} + run: ./script/install-mold + + - name: Download WASI SDK + shell: bash -euxo pipefail {0} + run: ./script/download-wasi-sdk + + - name: Generate action metadata + shell: bash -euxo pipefail {0} + run: ./script/generate-action-metadata + - name: Check for broken links (in MD) uses: lycheeverse/lychee-action@82202e5e9c2f4ef1a55a3d02563e1cb6041e5332 # v2.4.1 with: From 0531035b86a7a035b1b661c62cc9436a2e1b5394 Mon Sep 17 00:00:00 2001 From: Ryan Steil <183886708+ryansteil@users.noreply.github.com> Date: Thu, 18 Dec 2025 22:47:40 -0600 Subject: [PATCH 532/621] docs: Fix link to Anthropic prompt engineering resource (#45329) --- docs/src/ai/rules.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/ai/rules.md b/docs/src/ai/rules.md index 4169920425e66eb41a895deb60da3a198d74df08..972bbc94e82937502739cf585cc8f60dbcda8808 100644 --- a/docs/src/ai/rules.md +++ b/docs/src/ai/rules.md @@ -46,7 +46,7 @@ Having a series of rules files specifically tailored to prompt engineering can a Here are a couple of helpful resources for writing better rules: -- [Anthropic: Prompt Engineering](https://docs.anthropic.com/en/docs/build-with-claude/prompt-engineering/overview) +- [Anthropic: Prompt Engineering](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/overview) - [OpenAI: Prompt Engineering](https://platform.openai.com/docs/guides/prompt-engineering) ### Editing the Default Rules {#default-rules} From e052127e1c31ce6b8286fc931aaee2217b62ada1 Mon Sep 17 00:00:00 2001 From: rabsef-bicrym <52549148+rabsef-bicrym@users.noreply.github.com> Date: Thu, 18 Dec 2025 22:33:59 -0800 Subject: [PATCH 533/621] terminal: Prevent scrollbar arithmetic underflow panic (#45282) ## Summary Fixes arithmetic underflow panics in `terminal_scrollbar.rs` by converting unsafe subtractions to `saturating_sub`. Closes #45281 ## Problem Two locations perform raw subtraction on `usize` values that panic when underflow occurs: - `offset()`: `state.total_lines - state.viewport_lines - state.display_offset` - `set_offset()`: `state.total_lines - state.viewport_lines` This happens when `total_lines < viewport_lines + display_offset`, which can occur during terminal creation, with small window sizes, or when display state becomes stale. ## Solution Replace the two unsafe subtractions with `saturating_sub`, which returns 0 on underflow instead of panicking. Also standardizes the existing `checked_sub().unwrap_or(0)` in `max_offset()` to `saturating_sub` for consistency across the file. ## Changes - N/A --- crates/terminal_view/src/terminal_scrollbar.rs | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/crates/terminal_view/src/terminal_scrollbar.rs b/crates/terminal_view/src/terminal_scrollbar.rs index 871bb602306cccc92b8cffe62c4912c42b7a87e2..82ca0b4097dad1be899879b0241aed50d8e60bfa 100644 --- a/crates/terminal_view/src/terminal_scrollbar.rs +++ b/crates/terminal_view/src/terminal_scrollbar.rs @@ -50,28 +50,24 @@ impl ScrollableHandle for TerminalScrollHandle { let state = self.state.borrow(); size( Pixels::ZERO, - state - .total_lines - .checked_sub(state.viewport_lines) - .unwrap_or(0) as f32 - * state.line_height, + state.total_lines.saturating_sub(state.viewport_lines) as f32 * state.line_height, ) } fn offset(&self) -> Point { let state = self.state.borrow(); - let scroll_offset = state.total_lines - state.viewport_lines - state.display_offset; - Point::new( - Pixels::ZERO, - -(scroll_offset as f32 * self.state.borrow().line_height), - ) + let scroll_offset = state + .total_lines + .saturating_sub(state.viewport_lines) + .saturating_sub(state.display_offset); + Point::new(Pixels::ZERO, -(scroll_offset as f32 * state.line_height)) } fn set_offset(&self, point: Point) { let state = self.state.borrow(); let offset_delta = (point.y / state.line_height).round() as i32; - let max_offset = state.total_lines - state.viewport_lines; + let max_offset = state.total_lines.saturating_sub(state.viewport_lines); let display_offset = (max_offset as i32 + offset_delta).clamp(0, max_offset as i32); self.future_display_offset From e44529ed7ba3da10f796a5d37d494a5ef883e17a Mon Sep 17 00:00:00 2001 From: Mustaque Ahmed Date: Fri, 19 Dec 2025 13:54:30 +0530 Subject: [PATCH 534/621] Hide inline overlays when context menu is open (#45266) Closes #23367 **Summary** - Prevents inline diagnostics, code actions, blame annotations, and hover popovers from overlapping with the right-click context menu by checking for `mouse_context_menu` presence before rendering these UI elements. PS: Same behaviour is present in other editors like VS Code. **Screen recording** https://github.com/user-attachments/assets/8290412b-0f86-4985-8c70-13440686e530 Release Notes: - N/A *or* Added/Fixed/Improved ... --- crates/editor/src/element.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index f7b6aa949e74dca9bee73419fa2b87899f9986fd..4c3b44335bcad10be4303d545a8d2ad505938098 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -5417,6 +5417,12 @@ impl EditorElement { .max(MIN_POPOVER_LINE_HEIGHT * line_height), // Apply minimum height of 4 lines ); + // Don't show hover popovers when context menu is open to avoid overlap + let has_context_menu = self.editor.read(cx).mouse_context_menu.is_some(); + if has_context_menu { + return; + } + let hover_popovers = self.editor.update(cx, |editor, cx| { editor.hover_state.render( snapshot, From 596826f74113d0db2d2f6794ca1c7d2275da5b96 Mon Sep 17 00:00:00 2001 From: Mayank Verma Date: Fri, 19 Dec 2025 14:13:35 +0530 Subject: [PATCH 535/621] editor: Strip trailing newlines from completion documentation (#45342) Closes #45337 Release Notes: - Fixed broken completion menu layout caused by trailing newlines in ty documentation
Before After
before after
--- crates/editor/src/code_context_menus.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/editor/src/code_context_menus.rs b/crates/editor/src/code_context_menus.rs index 2336a38fa7767fa6184608066f69d3b0520234ff..96739defc506414f573e2454dc31f9c32d8e4adf 100644 --- a/crates/editor/src/code_context_menus.rs +++ b/crates/editor/src/code_context_menus.rs @@ -893,7 +893,7 @@ impl CompletionsMenu { None } else { Some( - Label::new(text.clone()) + Label::new(text.trim().to_string()) .ml_4() .size(LabelSize::Small) .color(Color::Muted), From 6d776c3157a33b947406215e298997b7ea159a1a Mon Sep 17 00:00:00 2001 From: prayansh_chhablani <135210710+prayanshchh@users.noreply.github.com> Date: Fri, 19 Dec 2025 14:41:36 +0530 Subject: [PATCH 536/621] project: Sanitize single-line completions from trailing newlines (#44965) Closes #43991 trim documentation string to prevent completion overlap previous [Screencast from 2025-12-16 14-55-58.webm](https://github.com/user-attachments/assets/d7674d82-63b0-4a85-a90f-b5c5091e4a82) after change [Screencast from 2025-12-16 14-50-05.webm](https://github.com/user-attachments/assets/109c22b5-3fff-49c8-a2ec-b1af467d6320) Release Notes: - Fixed an issue where completions in the completion menu would span multiple lines. --- crates/project/src/lsp_store.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/crates/project/src/lsp_store.rs b/crates/project/src/lsp_store.rs index 7e8624daad628fd653326647537eb51dad208a02..5841be02b2db80b2fa15667833b8a3d3eec4ec11 100644 --- a/crates/project/src/lsp_store.rs +++ b/crates/project/src/lsp_store.rs @@ -13776,7 +13776,7 @@ impl From for CompletionDocumentation { match docs { lsp::Documentation::String(text) => { if text.lines().count() <= 1 { - CompletionDocumentation::SingleLine(text.into()) + CompletionDocumentation::SingleLine(text.trim().to_string().into()) } else { CompletionDocumentation::MultiLinePlainText(text.into()) } @@ -14368,4 +14368,22 @@ mod tests { ) ); } + + #[test] + fn test_trailing_newline_in_completion_documentation() { + let doc = lsp::Documentation::String( + "Inappropriate argument value (of correct type).\n".to_string(), + ); + let completion_doc: CompletionDocumentation = doc.into(); + assert!( + matches!(completion_doc, CompletionDocumentation::SingleLine(s) if s == "Inappropriate argument value (of correct type).") + ); + + let doc = lsp::Documentation::String(" some value \n".to_string()); + let completion_doc: CompletionDocumentation = doc.into(); + assert!(matches!( + completion_doc, + CompletionDocumentation::SingleLine(s) if s == "some value" + )); + } } From f2495a6f98524f589b384db91d938c96c3c7819e Mon Sep 17 00:00:00 2001 From: Korbin de Man <113640462+korbindeman@users.noreply.github.com> Date: Fri, 19 Dec 2025 11:12:01 +0100 Subject: [PATCH 537/621] Add Restore File action in project_panel for git modified files (#42490) Co-authored-by: cameron --- Cargo.lock | 1 + crates/project_panel/Cargo.toml | 1 + crates/project_panel/src/project_panel.rs | 115 ++++++++++++++++++++++ 3 files changed, 117 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 3f7077e721e934cd6cb05af0cdaefef75602b429..4beb6c11f427fb86b5586c2833c50b7cd5b9dd01 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -12570,6 +12570,7 @@ dependencies = [ "gpui", "language", "menu", + "notifications", "pretty_assertions", "project", "rayon", diff --git a/crates/project_panel/Cargo.toml b/crates/project_panel/Cargo.toml index 2c47efd0b0e2490bbfd6125069fa5ca1438ffb51..0385c3789e923da95a1eca7a5a469bad00020639 100644 --- a/crates/project_panel/Cargo.toml +++ b/crates/project_panel/Cargo.toml @@ -45,6 +45,7 @@ workspace.workspace = true language.workspace = true zed_actions.workspace = true telemetry.workspace = true +notifications.workspace = true [dev-dependencies] client = { workspace = true, features = ["test-support"] } diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rs index 00aba96ef428eea643e8868e513ab9c3aaa1b910..43f63d90789a65bce54814f3adbc6f1d53235568 100644 --- a/crates/project_panel/src/project_panel.rs +++ b/crates/project_panel/src/project_panel.rs @@ -29,6 +29,7 @@ use gpui::{ }; use language::DiagnosticSeverity; use menu::{Confirm, SelectFirst, SelectLast, SelectNext, SelectPrevious}; +use notifications::status_toast::{StatusToast, ToastIcon}; use project::{ Entry, EntryKind, Fs, GitEntry, GitEntryRef, GitTraversal, Project, ProjectEntryId, ProjectPath, Worktree, WorktreeId, @@ -1140,6 +1141,12 @@ impl ProjectPanel { "Copy Relative Path", Box::new(zed_actions::workspace::CopyRelativePath), ) + .when(!is_dir && self.has_git_changes(entry_id), |menu| { + menu.separator().action( + "Restore File", + Box::new(git::RestoreFile { skip_prompt: false }), + ) + }) .when(has_git_repo, |menu| { menu.separator() .action("View File History", Box::new(git::FileHistory)) @@ -1180,6 +1187,19 @@ impl ProjectPanel { cx.notify(); } + fn has_git_changes(&self, entry_id: ProjectEntryId) -> bool { + for visible in &self.state.visible_entries { + if let Some(git_entry) = visible.entries.iter().find(|e| e.id == entry_id) { + let total_modified = + git_entry.git_summary.index.modified + git_entry.git_summary.worktree.modified; + let total_deleted = + git_entry.git_summary.index.deleted + git_entry.git_summary.worktree.deleted; + return total_modified > 0 || total_deleted > 0; + } + } + false + } + fn is_unfoldable(&self, entry: &Entry, worktree: &Worktree) -> bool { if !entry.is_dir() || self.state.unfolded_dir_ids.contains(&entry.id) { return false; @@ -2041,6 +2061,100 @@ impl ProjectPanel { self.remove(false, action.skip_prompt, window, cx); } + fn restore_file( + &mut self, + action: &git::RestoreFile, + window: &mut Window, + cx: &mut Context, + ) { + maybe!({ + let selection = self.state.selection?; + let project = self.project.read(cx); + + let (_worktree, entry) = self.selected_sub_entry(cx)?; + if entry.is_dir() { + return None; + } + + let project_path = project.path_for_entry(selection.entry_id, cx)?; + + let git_store = project.git_store(); + let (repository, repo_path) = git_store + .read(cx) + .repository_and_path_for_project_path(&project_path, cx)?; + + let snapshot = repository.read(cx).snapshot(); + let status = snapshot.status_for_path(&repo_path)?; + if !status.status.is_modified() && !status.status.is_deleted() { + return None; + } + + let file_name = entry.path.file_name()?.to_string(); + + let answer = if !action.skip_prompt { + let prompt = format!("Discard changes to {}?", file_name); + Some(window.prompt(PromptLevel::Info, &prompt, None, &["Restore", "Cancel"], cx)) + } else { + None + }; + + cx.spawn_in(window, async move |panel, cx| { + if let Some(answer) = answer + && answer.await != Ok(0) + { + return anyhow::Ok(()); + } + + let task = panel.update(cx, |_panel, cx| { + repository.update(cx, |repo, cx| { + repo.checkout_files("HEAD", vec![repo_path], cx) + }) + })?; + + if let Err(e) = task.await { + panel + .update(cx, |panel, cx| { + let message = format!("Failed to restore {}: {}", file_name, e); + let toast = StatusToast::new(message, cx, |this, _| { + this.icon(ToastIcon::new(IconName::XCircle).color(Color::Error)) + .dismiss_button(true) + }); + panel + .workspace + .update(cx, |workspace, cx| { + workspace.toggle_status_toast(toast, cx); + }) + .ok(); + }) + .ok(); + } + + panel + .update(cx, |panel, cx| { + panel.project.update(cx, |project, cx| { + if let Some(buffer_id) = project + .buffer_store() + .read(cx) + .buffer_id_for_project_path(&project_path) + { + if let Some(buffer) = project.buffer_for_id(*buffer_id, cx) { + buffer.update(cx, |buffer, cx| { + let _ = buffer.reload(cx); + }); + } + } + }) + }) + .ok(); + + anyhow::Ok(()) + }) + .detach_and_log_err(cx); + + Some(()) + }); + } + fn remove( &mut self, trash: bool, @@ -5631,6 +5745,7 @@ impl Render for ProjectPanel { .on_action(cx.listener(Self::copy)) .on_action(cx.listener(Self::paste)) .on_action(cx.listener(Self::duplicate)) + .on_action(cx.listener(Self::restore_file)) .when(!project.is_remote(), |el| { el.on_action(cx.listener(Self::trash)) }) From 7ee56e1a18c8bc557aa7f050a516419861f3a32e Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Fri, 19 Dec 2025 11:18:36 +0100 Subject: [PATCH 538/621] chore: Add worktree_benchmarks to cargo workspace (#45344) Idk why it was missing, but Release Notes: - N/A --- Cargo.lock | 10 ++++++++++ Cargo.toml | 1 + crates/worktree_benchmarks/src/main.rs | 4 ++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4beb6c11f427fb86b5586c2833c50b7cd5b9dd01..f9acd6989be8734b6c5b528435fccea62d10f027 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -20265,6 +20265,16 @@ dependencies = [ "zlog", ] +[[package]] +name = "worktree_benchmarks" +version = "0.1.0" +dependencies = [ + "fs", + "gpui", + "settings", + "worktree", +] + [[package]] name = "writeable" version = "0.6.1" diff --git a/Cargo.toml b/Cargo.toml index 825dc79e08978d8ccd03cea93883f698986ee12f..b507e8824484ea670619b5225fef9cfd41c81d4c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -198,6 +198,7 @@ members = [ "crates/web_search_providers", "crates/workspace", "crates/worktree", + "crates/worktree_benchmarks", "crates/x_ai", "crates/zed", "crates/zed_actions", diff --git a/crates/worktree_benchmarks/src/main.rs b/crates/worktree_benchmarks/src/main.rs index 00f268b75fc5f1e7d6033ec46f3718ea39cdccda..c1b76f9e3c483ec6c989cc255a11c5320d4b49f7 100644 --- a/crates/worktree_benchmarks/src/main.rs +++ b/crates/worktree_benchmarks/src/main.rs @@ -5,8 +5,7 @@ use std::{ use fs::RealFs; use gpui::Application; -use settings::Settings; -use worktree::{Worktree, WorktreeSettings}; +use worktree::Worktree; fn main() { let Some(worktree_root_path) = std::env::args().nth(1) else { @@ -27,6 +26,7 @@ fn main() { true, fs, Arc::new(AtomicUsize::new(0)), + true, cx, ) .await From 3104482c6c7c06c02be7d63927487c64695ea290 Mon Sep 17 00:00:00 2001 From: Angelo Verlain <37999241+vixalien@users.noreply.github.com> Date: Fri, 19 Dec 2025 12:34:40 +0200 Subject: [PATCH 539/621] languages: Detect `.bst` files as YAML (#45015) These files are used by the BuildStream build project: https://buildstream.build/index.html Release Notes: - Added recognition for .bst files as yaml. --- crates/languages/src/yaml/config.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/languages/src/yaml/config.toml b/crates/languages/src/yaml/config.toml index 51e8e1224a40904e0dfbb0204eb531e6b2664825..9a07a560b06766ac00dd73b6210023c4cddd491d 100644 --- a/crates/languages/src/yaml/config.toml +++ b/crates/languages/src/yaml/config.toml @@ -1,6 +1,6 @@ name = "YAML" grammar = "yaml" -path_suffixes = ["yml", "yaml", "pixi.lock", "clang-format", "clangd"] +path_suffixes = ["yml", "yaml", "pixi.lock", "clang-format", "clangd", "bst"] line_comments = ["# "] autoclose_before = ",]}" brackets = [ From 1ac170e663339e05457261959bcb0870961d127b Mon Sep 17 00:00:00 2001 From: Lena <241371603+zelenenka@users.noreply.github.com> Date: Fri, 19 Dec 2025 12:46:20 +0100 Subject: [PATCH 540/621] Upgrade stalebot and make testing it easier (#45350) - adjust wording for the upcoming simplified process - upgrade to the github action version that has a fix for configuring issue types the bot should look at - add two inputs for the manual runs of stalebot that help testing it in a safe and controlled manner Release Notes: - N/A --- .../community_close_stale_issues.yml | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/.github/workflows/community_close_stale_issues.yml b/.github/workflows/community_close_stale_issues.yml index 14c1a0a08338ee513a8269094b41ee404beef726..113e5ed131d1443c5481ff2966fac6a234561a20 100644 --- a/.github/workflows/community_close_stale_issues.yml +++ b/.github/workflows/community_close_stale_issues.yml @@ -3,27 +3,38 @@ on: schedule: - cron: "0 8 31 DEC *" workflow_dispatch: + inputs: + debug-only: + description: "Run in dry-run mode (no changes made)" + type: boolean + default: false + operations-per-run: + description: "Max number of issues to process (default: 1000)" + type: number + default: 1000 jobs: stale: if: github.repository_owner == 'zed-industries' runs-on: ubuntu-latest steps: - - uses: actions/stale@5bef64f19d7facfb25b37b414482c7164d639639 # v9 + - uses: actions/stale@997185467fa4f803885201cee163a9f38240193d # v10 with: repo-token: ${{ secrets.GITHUB_TOKEN }} stale-issue-message: > - Hi there! 👋 - - We're working to clean up our issue tracker by closing older bugs that might not be relevant anymore. If you are able to reproduce this issue in the latest version of Zed, please let us know by commenting on this issue, and it will be kept open. If you can't reproduce it, feel free to close the issue yourself. Otherwise, it will close automatically in 14 days. + Hi there! + Zed development moves fast and a significant number of bugs become outdated. + If you can reproduce this bug on the latest stable Zed, please let us know by leaving a comment with the Zed version. + If the bug doesn't appear for you anymore, feel free to close the issue yourself; otherwise, the bot will close it in a couple of weeks. Thanks for your help! - close-issue-message: "This issue was closed due to inactivity. If you're still experiencing this problem, please open a new issue with a link to this issue." + close-issue-message: "This issue was closed due to inactivity. If you're still experiencing this problem, please leave a comment with your Zed version so that we can reopen the issue." days-before-stale: 60 days-before-close: 14 only-issue-types: "Bug,Crash" - operations-per-run: 1000 + operations-per-run: ${{ inputs.operations-per-run || 1000 }} ascending: true enable-statistics: true + debug-only: ${{ inputs.debug-only }} stale-issue-label: "stale" exempt-issue-labels: "never stale" From 95ae388c0ce8ae4a0b8d149ace3ecba1ea417491 Mon Sep 17 00:00:00 2001 From: Agus Zubiaga Date: Fri, 19 Dec 2025 09:19:04 -0300 Subject: [PATCH 541/621] Fix title bar spacing when building on the macOS Tahoe SDK (#45351) The size and spacing around the traffic light buttons changes after macOS SDK 26. Our official builds aren't using this SDK yet, but dev builds sometimes are and the official will in the future.
Before After
CleanShot 2025-12-19 at 08 58 53@2x CleanShot 2025-12-19 at 08 57 02@2x
CleanShot 2025-12-19 at 08 59 40@2x CleanShot 2025-12-19 at 09 01 17@2x
Release Notes: - N/A --- crates/title_bar/build.rs | 28 +++++++++ .../title_bar/src/platforms/platform_mac.rs | 14 +++-- crates/title_bar/src/title_bar.rs | 58 ++++++++++--------- 3 files changed, 68 insertions(+), 32 deletions(-) create mode 100644 crates/title_bar/build.rs diff --git a/crates/title_bar/build.rs b/crates/title_bar/build.rs new file mode 100644 index 0000000000000000000000000000000000000000..ef70268ad3127baf113824348cb3e8685392a52b --- /dev/null +++ b/crates/title_bar/build.rs @@ -0,0 +1,28 @@ +#![allow(clippy::disallowed_methods, reason = "build scripts are exempt")] + +fn main() { + println!("cargo::rustc-check-cfg=cfg(macos_sdk_26)"); + + #[cfg(target_os = "macos")] + { + use std::process::Command; + + let output = Command::new("xcrun") + .args(["--sdk", "macosx", "--show-sdk-version"]) + .output() + .unwrap(); + + let sdk_version = String::from_utf8(output.stdout).unwrap(); + let major_version: Option = sdk_version + .trim() + .split('.') + .next() + .and_then(|v| v.parse().ok()); + + if let Some(major) = major_version + && major >= 26 + { + println!("cargo:rustc-cfg=macos_sdk_26"); + } + } +} diff --git a/crates/title_bar/src/platforms/platform_mac.rs b/crates/title_bar/src/platforms/platform_mac.rs index c7becde6c1af48bf37e06c0d2dcf991ad3c9f19f..5e8e4e5087054e59f66527915ae97e352a9ff525 100644 --- a/crates/title_bar/src/platforms/platform_mac.rs +++ b/crates/title_bar/src/platforms/platform_mac.rs @@ -1,6 +1,10 @@ -/// Use pixels here instead of a rem-based size because the macOS traffic -/// lights are a static size, and don't scale with the rest of the UI. -/// -/// Magic number: There is one extra pixel of padding on the left side due to -/// the 1px border around the window on macOS apps. +// Use pixels here instead of a rem-based size because the macOS traffic +// lights are a static size, and don't scale with the rest of the UI. +// +// Magic number: There is one extra pixel of padding on the left side due to +// the 1px border around the window on macOS apps. +#[cfg(macos_sdk_26)] +pub const TRAFFIC_LIGHT_PADDING: f32 = 78.; + +#[cfg(not(macos_sdk_26))] pub const TRAFFIC_LIGHT_PADDING: f32 = 71.; diff --git a/crates/title_bar/src/title_bar.rs b/crates/title_bar/src/title_bar.rs index 23572677919509d859a141cb09cce8f5822697ef..d7759b0df8019eed2ad59b73bcaffaa3ffcfb866 100644 --- a/crates/title_bar/src/title_bar.rs +++ b/crates/title_bar/src/title_bar.rs @@ -447,34 +447,38 @@ impl TitleBar { return None; } - Some( - Button::new("restricted_mode_trigger", "Restricted Mode") - .style(ButtonStyle::Tinted(TintColor::Warning)) - .label_size(LabelSize::Small) - .color(Color::Warning) - .icon(IconName::Warning) - .icon_color(Color::Warning) - .icon_size(IconSize::Small) - .icon_position(IconPosition::Start) - .tooltip(|_, cx| { - Tooltip::with_meta( - "You're in Restricted Mode", - Some(&ToggleWorktreeSecurity), - "Mark this project as trusted and unlock all features", - cx, - ) - }) - .on_click({ - cx.listener(move |this, _, window, cx| { - this.workspace - .update(cx, |workspace, cx| { - workspace.show_worktree_trust_security_modal(true, window, cx) - }) - .log_err(); - }) + let button = Button::new("restricted_mode_trigger", "Restricted Mode") + .style(ButtonStyle::Tinted(TintColor::Warning)) + .label_size(LabelSize::Small) + .color(Color::Warning) + .icon(IconName::Warning) + .icon_color(Color::Warning) + .icon_size(IconSize::Small) + .icon_position(IconPosition::Start) + .tooltip(|_, cx| { + Tooltip::with_meta( + "You're in Restricted Mode", + Some(&ToggleWorktreeSecurity), + "Mark this project as trusted and unlock all features", + cx, + ) + }) + .on_click({ + cx.listener(move |this, _, window, cx| { + this.workspace + .update(cx, |workspace, cx| { + workspace.show_worktree_trust_security_modal(true, window, cx) + }) + .log_err(); }) - .into_any_element(), - ) + }); + + if cfg!(macos_sdk_26) { + // Make up for Tahoe's traffic light buttons having less spacing around them + Some(div().child(button).ml_0p5().into_any_element()) + } else { + Some(button.into_any_element()) + } } pub fn render_project_host(&self, cx: &mut Context) -> Option { From b9aef75f2df4ae8fa1707d348b4d588c3784526b Mon Sep 17 00:00:00 2001 From: Lena <241371603+zelenenka@users.noreply.github.com> Date: Fri, 19 Dec 2025 13:41:03 +0100 Subject: [PATCH 542/621] Turn on the fixed stalebot (#45355) It will run weekly and it promised not to touch issues of the wrong types anymore. Release Notes: - N/A --- .github/workflows/community_close_stale_issues.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/community_close_stale_issues.yml b/.github/workflows/community_close_stale_issues.yml index 113e5ed131d1443c5481ff2966fac6a234561a20..6347b713257f49c02f981774faa0d0359e05e4d3 100644 --- a/.github/workflows/community_close_stale_issues.yml +++ b/.github/workflows/community_close_stale_issues.yml @@ -1,7 +1,7 @@ name: "Close Stale Issues" on: schedule: - - cron: "0 8 31 DEC *" + - cron: "0 2 * * 5" workflow_dispatch: inputs: debug-only: From 1dc5de4592ebf0ec51ba77bbd41c495aee67184e Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Fri, 19 Dec 2025 13:54:30 +0100 Subject: [PATCH 543/621] workspace: Auto-switch git context when focus changed (#45354) Closes #44955 Release Notes: - Fixed workspace incorrectly automatically switching Git repository/branch context in multi-repository projects when repo/branch switched manually from the Git panel. --- crates/workspace/src/workspace.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index 0c5c9ffa5d0bfb1f70ce6a861b0209f321222fc0..139fa88359c574e1565ed778fdfbd5fa1c8f7944 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -4223,7 +4223,7 @@ impl Workspace { cx: &mut Context, ) { self.active_pane = pane.clone(); - self.active_item_path_changed(window, cx); + self.active_item_path_changed(true, window, cx); self.last_active_center_pane = Some(pane.downgrade()); } @@ -4280,7 +4280,7 @@ impl Workspace { } serialize_workspace = *focus_changed || pane != self.active_pane(); if pane == self.active_pane() { - self.active_item_path_changed(window, cx); + self.active_item_path_changed(*focus_changed, window, cx); self.update_active_view_for_followers(window, cx); } else if *local { self.set_active_pane(pane, window, cx); @@ -4296,7 +4296,7 @@ impl Workspace { } pane::Event::ChangeItemTitle => { if *pane == self.active_pane { - self.active_item_path_changed(window, cx); + self.active_item_path_changed(false, window, cx); } serialize_workspace = false; } @@ -4465,7 +4465,7 @@ impl Workspace { cx.notify(); } else { - self.active_item_path_changed(window, cx); + self.active_item_path_changed(true, window, cx); } cx.emit(Event::PaneRemoved); } @@ -4719,14 +4719,19 @@ impl Workspace { self.follower_states.contains_key(&id.into()) } - fn active_item_path_changed(&mut self, window: &mut Window, cx: &mut Context) { + fn active_item_path_changed( + &mut self, + focus_changed: bool, + window: &mut Window, + cx: &mut Context, + ) { cx.emit(Event::ActiveItemChanged); let active_entry = self.active_project_path(cx); self.project.update(cx, |project, cx| { project.set_active_path(active_entry.clone(), cx) }); - if let Some(project_path) = &active_entry { + if focus_changed && let Some(project_path) = &active_entry { let git_store_entity = self.project.read(cx).git_store().clone(); git_store_entity.update(cx, |git_store, cx| { git_store.set_active_repo_for_path(project_path, cx); From 69f6eeaa3ae821c43b7bf0dfc241c2792573b338 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Fri, 19 Dec 2025 14:06:15 +0100 Subject: [PATCH 544/621] toolchains: Fix persistence by not relying on unstable worktree id (#45357) Closes #42268 We've migrated user selections when a given workspace has a single worktree (as then we could determine what the target worktree is). Release Notes: - python: Fixed selected virtual environments not being persisted/deserialized correctly within long-running Zed sessions (where multiple different projects might've been opened). This is a breaking change for users of multi-worktree projects - your selected toolchain for those projects will be reset. Co-authored-by: Dino --- crates/language/src/toolchain.rs | 7 +- crates/project/src/project.rs | 7 +- crates/project/src/toolchain_store.rs | 26 +++++- crates/project/src/x.py | 1 + .../src/active_toolchain.rs | 9 ++- .../src/toolchain_selector.rs | 43 +++++++--- crates/workspace/src/persistence.rs | 81 ++++++++++++++----- crates/workspace/src/workspace.rs | 31 ++++++- 8 files changed, 165 insertions(+), 40 deletions(-) create mode 100644 crates/project/src/x.py diff --git a/crates/language/src/toolchain.rs b/crates/language/src/toolchain.rs index 5717ffb5143e38bce736c354b43febc86e321f32..815ece30a1ed46ae65ec4af2ba64501ff3489718 100644 --- a/crates/language/src/toolchain.rs +++ b/crates/language/src/toolchain.rs @@ -4,7 +4,10 @@ //! which is a set of tools used to interact with the projects written in said language. //! For example, a Python project can have an associated virtual environment; a Rust project can have a toolchain override. -use std::{path::PathBuf, sync::Arc}; +use std::{ + path::{Path, PathBuf}, + sync::Arc, +}; use async_trait::async_trait; use collections::HashMap; @@ -36,7 +39,7 @@ pub struct Toolchain { /// - Only in the subproject they're currently in. #[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd)] pub enum ToolchainScope { - Subproject(WorktreeId, Arc), + Subproject(Arc, Arc), Project, /// Available in all projects on this box. It wouldn't make sense to show suggestions across machines. Global, diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index 5e31f2a90cf137f1e4d788952832e1eb2ee0ec35..25a19788fdb464f5f289ef3bc3513f21743e3a9a 100644 --- a/crates/project/src/project.rs +++ b/crates/project/src/project.rs @@ -1330,7 +1330,12 @@ impl Project { cx.subscribe(&buffer_store, Self::on_buffer_store_event) .detach(); let toolchain_store = cx.new(|cx| { - ToolchainStore::remote(REMOTE_SERVER_PROJECT_ID, remote.read(cx).proto_client(), cx) + ToolchainStore::remote( + REMOTE_SERVER_PROJECT_ID, + worktree_store.clone(), + remote.read(cx).proto_client(), + cx, + ) }); let task_store = cx.new(|cx| { TaskStore::remote( diff --git a/crates/project/src/toolchain_store.rs b/crates/project/src/toolchain_store.rs index 21b74bd784d1d9af12fe43e3fe82051afc103b0d..7afc70827f85e1a1bafcad436409936876fd3b45 100644 --- a/crates/project/src/toolchain_store.rs +++ b/crates/project/src/toolchain_store.rs @@ -32,6 +32,7 @@ use crate::{ pub struct ToolchainStore { mode: ToolchainStoreInner, user_toolchains: BTreeMap>, + worktree_store: Entity, _sub: Subscription, } @@ -66,7 +67,7 @@ impl ToolchainStore { ) -> Self { let entity = cx.new(|_| LocalToolchainStore { languages, - worktree_store, + worktree_store: worktree_store.clone(), project_environment, active_toolchains: Default::default(), manifest_tree, @@ -77,12 +78,18 @@ impl ToolchainStore { }); Self { mode: ToolchainStoreInner::Local(entity), + worktree_store, user_toolchains: Default::default(), _sub, } } - pub(super) fn remote(project_id: u64, client: AnyProtoClient, cx: &mut Context) -> Self { + pub(super) fn remote( + project_id: u64, + worktree_store: Entity, + client: AnyProtoClient, + cx: &mut Context, + ) -> Self { let entity = cx.new(|_| RemoteToolchainStore { client, project_id }); let _sub = cx.subscribe(&entity, |_, _, e: &ToolchainStoreEvent, cx| { cx.emit(e.clone()) @@ -90,6 +97,7 @@ impl ToolchainStore { Self { mode: ToolchainStoreInner::Remote(entity), user_toolchains: Default::default(), + worktree_store, _sub, } } @@ -165,12 +173,22 @@ impl ToolchainStore { language_name: LanguageName, cx: &mut Context, ) -> Task> { + let Some(worktree) = self + .worktree_store + .read(cx) + .worktree_for_id(path.worktree_id, cx) + else { + return Task::ready(None); + }; + let target_root_path = worktree.read_with(cx, |this, _| this.abs_path()); + let user_toolchains = self .user_toolchains .iter() .filter(|(scope, _)| { - if let ToolchainScope::Subproject(worktree_id, relative_path) = scope { - path.worktree_id == *worktree_id && relative_path.starts_with(&path.path) + if let ToolchainScope::Subproject(subproject_root_path, relative_path) = scope { + target_root_path == *subproject_root_path + && relative_path.starts_with(&path.path) } else { true } diff --git a/crates/project/src/x.py b/crates/project/src/x.py new file mode 100644 index 0000000000000000000000000000000000000000..58947a58a41bcc2e2f8c2046b5e1c8c38c0fbbb8 --- /dev/null +++ b/crates/project/src/x.py @@ -0,0 +1 @@ +Gliwice makerspace \ No newline at end of file diff --git a/crates/toolchain_selector/src/active_toolchain.rs b/crates/toolchain_selector/src/active_toolchain.rs index 03c152e3fd3df0c62ab2f5c7e4a4746875ac955a..06f7d1cdf3e27f43bdb5013038b943b9e5193680 100644 --- a/crates/toolchain_selector/src/active_toolchain.rs +++ b/crates/toolchain_selector/src/active_toolchain.rs @@ -198,10 +198,17 @@ impl ActiveToolchain { .or_else(|| toolchains.toolchains.first()) .cloned(); if let Some(toolchain) = &default_choice { + let worktree_root_path = project + .read_with(cx, |this, cx| { + this.worktree_for_id(worktree_id, cx) + .map(|worktree| worktree.read(cx).abs_path()) + }) + .ok() + .flatten()?; workspace::WORKSPACE_DB .set_toolchain( workspace_id, - worktree_id, + worktree_root_path, relative_path.clone(), toolchain.clone(), ) diff --git a/crates/toolchain_selector/src/toolchain_selector.rs b/crates/toolchain_selector/src/toolchain_selector.rs index f7262c248f15f0f68fcd7a903ee01cac6b22d0af..36ef2b960a8abfe684628cea465b68e6eab5e463 100644 --- a/crates/toolchain_selector/src/toolchain_selector.rs +++ b/crates/toolchain_selector/src/toolchain_selector.rs @@ -1,6 +1,7 @@ mod active_toolchain; pub use active_toolchain::ActiveToolchain; +use anyhow::Context as _; use convert_case::Casing as _; use editor::Editor; use file_finder::OpenPathDelegate; @@ -62,6 +63,7 @@ struct AddToolchainState { language_name: LanguageName, root_path: ProjectPath, weak: WeakEntity, + worktree_root_path: Arc, } struct ScopePickerState { @@ -99,12 +101,17 @@ impl AddToolchainState { root_path: ProjectPath, window: &mut Window, cx: &mut Context, - ) -> Entity { + ) -> anyhow::Result> { let weak = cx.weak_entity(); - - cx.new(|cx| { + let worktree_root_path = project + .read(cx) + .worktree_for_id(root_path.worktree_id, cx) + .map(|worktree| worktree.read(cx).abs_path()) + .context("Could not find worktree")?; + Ok(cx.new(|cx| { let (lister, rx) = Self::create_path_browser_delegate(project.clone(), cx); let picker = cx.new(|cx| Picker::uniform_list(lister, window, cx)); + Self { state: AddState::Path { _subscription: cx.subscribe(&picker, |_, _, _: &DismissEvent, cx| { @@ -118,8 +125,9 @@ impl AddToolchainState { language_name, root_path, weak, + worktree_root_path, } - }) + })) } fn create_path_browser_delegate( @@ -237,7 +245,15 @@ impl AddToolchainState { // Suggest a default scope based on the applicability. let scope = if let Some(project_path) = resolved_toolchain_path { if !root_path.path.as_ref().is_empty() && project_path.starts_with(&root_path) { - ToolchainScope::Subproject(root_path.worktree_id, root_path.path) + let worktree_root_path = project + .read_with(cx, |this, cx| { + this.worktree_for_id(root_path.worktree_id, cx) + .map(|worktree| worktree.read(cx).abs_path()) + }) + .ok() + .flatten() + .context("Could not find a worktree with a given worktree ID")?; + ToolchainScope::Subproject(worktree_root_path, root_path.path) } else { ToolchainScope::Project } @@ -400,7 +416,7 @@ impl Render for AddToolchainState { ToolchainScope::Global, ToolchainScope::Project, ToolchainScope::Subproject( - self.root_path.worktree_id, + self.worktree_root_path.clone(), self.root_path.path.clone(), ), ]; @@ -693,7 +709,7 @@ impl ToolchainSelector { cx: &mut Context, ) { if matches!(self.state, State::Search(_)) { - self.state = State::AddToolchain(AddToolchainState::new( + let Ok(state) = AddToolchainState::new( self.project.clone(), self.language_name.clone(), ProjectPath { @@ -702,7 +718,10 @@ impl ToolchainSelector { }, window, cx, - )); + ) else { + return; + }; + self.state = State::AddToolchain(state); self.state.focus_handle(cx).focus(window, cx); cx.notify(); } @@ -899,11 +918,17 @@ impl PickerDelegate for ToolchainSelectorDelegate { { let workspace = self.workspace.clone(); let worktree_id = self.worktree_id; + let worktree_abs_path_root = self.worktree_abs_path_root.clone(); let path = self.relative_path.clone(); let relative_path = self.relative_path.clone(); cx.spawn_in(window, async move |_, cx| { workspace::WORKSPACE_DB - .set_toolchain(workspace_id, worktree_id, relative_path, toolchain.clone()) + .set_toolchain( + workspace_id, + worktree_abs_path_root, + relative_path, + toolchain.clone(), + ) .await .log_err(); workspace diff --git a/crates/workspace/src/persistence.rs b/crates/workspace/src/persistence.rs index 094d03494e726677dc43235d96fc62c076673bf5..8d20339ec952020416e4b8d5846bf44f5f8e9b98 100644 --- a/crates/workspace/src/persistence.rs +++ b/crates/workspace/src/persistence.rs @@ -24,7 +24,6 @@ use project::{ }; use language::{LanguageName, Toolchain, ToolchainScope}; -use project::WorktreeId; use remote::{ DockerConnectionOptions, RemoteConnectionOptions, SshConnectionOptions, WslConnectionOptions, }; @@ -845,6 +844,44 @@ impl Domain for WorkspaceDb { host_name TEXT ) STRICT; ), + sql!(CREATE TABLE toolchains2 ( + workspace_id INTEGER, + worktree_root_path TEXT NOT NULL, + language_name TEXT NOT NULL, + name TEXT NOT NULL, + path TEXT NOT NULL, + raw_json TEXT NOT NULL, + relative_worktree_path TEXT NOT NULL, + PRIMARY KEY (workspace_id, worktree_root_path, language_name, relative_worktree_path)) STRICT; + INSERT OR REPLACE INTO toolchains2 + // The `instr(paths, '\n') = 0` part allows us to find all + // workspaces that have a single worktree, as `\n` is used as a + // separator when serializing the workspace paths, so if no `\n` is + // found, we know we have a single worktree. + SELECT toolchains.workspace_id, paths, language_name, name, path, raw_json, relative_worktree_path FROM toolchains INNER JOIN workspaces ON toolchains.workspace_id = workspaces.workspace_id AND instr(paths, '\n') = 0; + DROP TABLE toolchains; + ALTER TABLE toolchains2 RENAME TO toolchains; + ), + sql!(CREATE TABLE user_toolchains2 ( + remote_connection_id INTEGER, + workspace_id INTEGER NOT NULL, + worktree_root_path TEXT NOT NULL, + relative_worktree_path TEXT NOT NULL, + language_name TEXT NOT NULL, + name TEXT NOT NULL, + path TEXT NOT NULL, + raw_json TEXT NOT NULL, + + PRIMARY KEY (workspace_id, worktree_root_path, relative_worktree_path, language_name, name, path, raw_json)) STRICT; + INSERT OR REPLACE INTO user_toolchains2 + // The `instr(paths, '\n') = 0` part allows us to find all + // workspaces that have a single worktree, as `\n` is used as a + // separator when serializing the workspace paths, so if no `\n` is + // found, we know we have a single worktree. + SELECT user_toolchains.remote_connection_id, user_toolchains.workspace_id, paths, relative_worktree_path, language_name, name, path, raw_json FROM user_toolchains INNER JOIN workspaces ON user_toolchains.workspace_id = workspaces.workspace_id AND instr(paths, '\n') = 0; + DROP TABLE user_toolchains; + ALTER TABLE user_toolchains2 RENAME TO user_toolchains; + ), ]; // Allow recovering from bad migration that was initially shipped to nightly @@ -1030,11 +1067,11 @@ impl WorkspaceDb { workspace_id: WorkspaceId, remote_connection_id: Option, ) -> BTreeMap> { - type RowKind = (WorkspaceId, u64, String, String, String, String, String); + type RowKind = (WorkspaceId, String, String, String, String, String, String); let toolchains: Vec = self .select_bound(sql! { - SELECT workspace_id, worktree_id, relative_worktree_path, + SELECT workspace_id, worktree_root_path, relative_worktree_path, language_name, name, path, raw_json FROM user_toolchains WHERE remote_connection_id IS ?1 AND ( workspace_id IN (0, ?2) @@ -1048,7 +1085,7 @@ impl WorkspaceDb { for ( _workspace_id, - worktree_id, + worktree_root_path, relative_worktree_path, language_name, name, @@ -1058,22 +1095,24 @@ impl WorkspaceDb { { // INTEGER's that are primary keys (like workspace ids, remote connection ids and such) start at 1, so we're safe to let scope = if _workspace_id == WorkspaceId(0) { - debug_assert_eq!(worktree_id, u64::MAX); + debug_assert_eq!(worktree_root_path, String::default()); debug_assert_eq!(relative_worktree_path, String::default()); ToolchainScope::Global } else { debug_assert_eq!(workspace_id, _workspace_id); debug_assert_eq!( - worktree_id == u64::MAX, + worktree_root_path == String::default(), relative_worktree_path == String::default() ); let Some(relative_path) = RelPath::unix(&relative_worktree_path).log_err() else { continue; }; - if worktree_id != u64::MAX && relative_worktree_path != String::default() { + if worktree_root_path != String::default() + && relative_worktree_path != String::default() + { ToolchainScope::Subproject( - WorktreeId::from_usize(worktree_id as usize), + Arc::from(worktree_root_path.as_ref()), relative_path.into(), ) } else { @@ -1159,13 +1198,13 @@ impl WorkspaceDb { for (scope, toolchains) in workspace.user_toolchains { for toolchain in toolchains { - let query = sql!(INSERT OR REPLACE INTO user_toolchains(remote_connection_id, workspace_id, worktree_id, relative_worktree_path, language_name, name, path, raw_json) VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8)); - let (workspace_id, worktree_id, relative_worktree_path) = match scope { - ToolchainScope::Subproject(worktree_id, ref path) => (Some(workspace.id), Some(worktree_id), Some(path.as_unix_str().to_owned())), + let query = sql!(INSERT OR REPLACE INTO user_toolchains(remote_connection_id, workspace_id, worktree_root_path, relative_worktree_path, language_name, name, path, raw_json) VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8)); + let (workspace_id, worktree_root_path, relative_worktree_path) = match scope { + ToolchainScope::Subproject(ref worktree_root_path, ref path) => (Some(workspace.id), Some(worktree_root_path.to_string_lossy().into_owned()), Some(path.as_unix_str().to_owned())), ToolchainScope::Project => (Some(workspace.id), None, None), ToolchainScope::Global => (None, None, None), }; - let args = (remote_connection_id, workspace_id.unwrap_or(WorkspaceId(0)), worktree_id.map_or(usize::MAX,|id| id.to_usize()), relative_worktree_path.unwrap_or_default(), + let args = (remote_connection_id, workspace_id.unwrap_or(WorkspaceId(0)), worktree_root_path.unwrap_or_default(), relative_worktree_path.unwrap_or_default(), toolchain.language_name.as_ref().to_owned(), toolchain.name.to_string(), toolchain.path.to_string(), toolchain.as_json.to_string()); if let Err(err) = conn.exec_bound(query)?(args) { log::error!("{err}"); @@ -1844,24 +1883,24 @@ impl WorkspaceDb { pub(crate) async fn toolchains( &self, workspace_id: WorkspaceId, - ) -> Result)>> { + ) -> Result, Arc)>> { self.write(move |this| { let mut select = this .select_bound(sql!( SELECT - name, path, worktree_id, relative_worktree_path, language_name, raw_json + name, path, worktree_root_path, relative_worktree_path, language_name, raw_json FROM toolchains WHERE workspace_id = ? )) .context("select toolchains")?; - let toolchain: Vec<(String, String, u64, String, String, String)> = + let toolchain: Vec<(String, String, String, String, String, String)> = select(workspace_id)?; Ok(toolchain .into_iter() .filter_map( - |(name, path, worktree_id, relative_worktree_path, language, json)| { + |(name, path, worktree_root_path, relative_worktree_path, language, json)| { Some(( Toolchain { name: name.into(), @@ -1869,7 +1908,7 @@ impl WorkspaceDb { language_name: LanguageName::new(&language), as_json: serde_json::Value::from_str(&json).ok()?, }, - WorktreeId::from_proto(worktree_id), + Arc::from(worktree_root_path.as_ref()), RelPath::from_proto(&relative_worktree_path).log_err()?, )) }, @@ -1882,18 +1921,18 @@ impl WorkspaceDb { pub async fn set_toolchain( &self, workspace_id: WorkspaceId, - worktree_id: WorktreeId, + worktree_root_path: Arc, relative_worktree_path: Arc, toolchain: Toolchain, ) -> Result<()> { log::debug!( - "Setting toolchain for workspace, worktree: {worktree_id:?}, relative path: {relative_worktree_path:?}, toolchain: {}", + "Setting toolchain for workspace, worktree: {worktree_root_path:?}, relative path: {relative_worktree_path:?}, toolchain: {}", toolchain.name ); self.write(move |conn| { let mut insert = conn .exec_bound(sql!( - INSERT INTO toolchains(workspace_id, worktree_id, relative_worktree_path, language_name, name, path, raw_json) VALUES (?, ?, ?, ?, ?, ?, ?) + INSERT INTO toolchains(workspace_id, worktree_root_path, relative_worktree_path, language_name, name, path, raw_json) VALUES (?, ?, ?, ?, ?, ?, ?) ON CONFLICT DO UPDATE SET name = ?5, @@ -1904,7 +1943,7 @@ impl WorkspaceDb { insert(( workspace_id, - worktree_id.to_usize(), + worktree_root_path.to_string_lossy().into_owned(), relative_worktree_path.as_unix_str(), toolchain.language_name.as_ref(), toolchain.name.as_ref(), diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index 139fa88359c574e1565ed778fdfbd5fa1c8f7944..53b0cc0623fa4b3ce7de5f1d8e3fd2262210a09a 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -1697,8 +1697,22 @@ impl Workspace { let toolchains = DB.toolchains(workspace_id).await?; - for (toolchain, worktree_id, path) in toolchains { + for (toolchain, worktree_path, path) in toolchains { let toolchain_path = PathBuf::from(toolchain.path.clone().to_string()); + let Some(worktree_id) = project_handle.read_with(cx, |this, cx| { + this.find_worktree(&worktree_path, cx) + .and_then(|(worktree, rel_path)| { + if rel_path.is_empty() { + Some(worktree.read(cx).id()) + } else { + None + } + }) + })? + else { + // We did not find a worktree with a given path, but that's whatever. + continue; + }; if !app_state.fs.is_file(toolchain_path.as_path()).await { continue; } @@ -8217,9 +8231,22 @@ async fn open_remote_project_inner( cx: &mut AsyncApp, ) -> Result>>> { let toolchains = DB.toolchains(workspace_id).await?; - for (toolchain, worktree_id, path) in toolchains { + for (toolchain, worktree_path, path) in toolchains { project .update(cx, |this, cx| { + let Some(worktree_id) = + this.find_worktree(&worktree_path, cx) + .and_then(|(worktree, rel_path)| { + if rel_path.is_empty() { + Some(worktree.read(cx).id()) + } else { + None + } + }) + else { + return Task::ready(None); + }; + this.activate_toolchain(ProjectPath { worktree_id, path }, toolchain, cx) })? .await; From 62d36b22fd1c497ae586f89f21b7a80ea6d8091a Mon Sep 17 00:00:00 2001 From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Date: Fri, 19 Dec 2025 10:25:19 -0300 Subject: [PATCH 545/621] gpui: Add `text_ellipsis_start` method (#45122) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR is an additive change introducing the `truncate_start` method to labels, which gives us the ability to add an ellipsis at the beginning of the text as opposed to the regular `truncate`. This will be generally used for truncating file paths, where the end is typically more relevant than the beginning, but given it's a general method, there's the possibility to be used anywhere else, too. Screenshot 2025-12-17 at 12  35@2x Release Notes: - N/A --------- Co-authored-by: Lukas Wirth --- crates/editor/src/code_context_menus.rs | 8 +- crates/gpui/src/elements/text.rs | 14 +- crates/gpui/src/style.rs | 8 +- crates/gpui/src/styled.rs | 10 +- crates/gpui/src/text_system/line_wrapper.rs | 228 ++++++++++++++++--- crates/ui/src/components/label/label.rs | 9 +- crates/ui/src/components/label/label_like.rs | 13 +- 7 files changed, 248 insertions(+), 42 deletions(-) diff --git a/crates/editor/src/code_context_menus.rs b/crates/editor/src/code_context_menus.rs index 96739defc506414f573e2454dc31f9c32d8e4adf..e5520be88e34307220126ebafdba6c6371a5db12 100644 --- a/crates/editor/src/code_context_menus.rs +++ b/crates/editor/src/code_context_menus.rs @@ -1615,8 +1615,12 @@ impl CodeActionsMenu { window.text_style().font(), window.text_style().font_size.to_pixels(window.rem_size()), ); - let is_truncated = - line_wrapper.should_truncate_line(&label, CODE_ACTION_MENU_MAX_WIDTH, "…"); + let is_truncated = line_wrapper.should_truncate_line( + &label, + CODE_ACTION_MENU_MAX_WIDTH, + "…", + gpui::TruncateFrom::End, + ); if is_truncated.is_none() { return None; diff --git a/crates/gpui/src/elements/text.rs b/crates/gpui/src/elements/text.rs index 1b1bfd778c7bc746c67551eb31cf70f60b1485ea..942a0a326526431dc65f389e9cff67bac252d571 100644 --- a/crates/gpui/src/elements/text.rs +++ b/crates/gpui/src/elements/text.rs @@ -2,8 +2,8 @@ use crate::{ ActiveTooltip, AnyView, App, Bounds, DispatchPhase, Element, ElementId, GlobalElementId, HighlightStyle, Hitbox, HitboxBehavior, InspectorElementId, IntoElement, LayoutId, MouseDownEvent, MouseMoveEvent, MouseUpEvent, Pixels, Point, SharedString, Size, TextOverflow, - TextRun, TextStyle, TooltipId, WhiteSpace, Window, WrappedLine, WrappedLineLayout, - register_tooltip_mouse_handlers, set_tooltip_on_window, + TextRun, TextStyle, TooltipId, TruncateFrom, WhiteSpace, Window, WrappedLine, + WrappedLineLayout, register_tooltip_mouse_handlers, set_tooltip_on_window, }; use anyhow::Context as _; use itertools::Itertools; @@ -354,7 +354,7 @@ impl TextLayout { None }; - let (truncate_width, truncation_suffix) = + let (truncate_width, truncation_affix, truncate_from) = if let Some(text_overflow) = text_style.text_overflow.clone() { let width = known_dimensions.width.or(match available_space.width { crate::AvailableSpace::Definite(x) => match text_style.line_clamp { @@ -365,10 +365,11 @@ impl TextLayout { }); match text_overflow { - TextOverflow::Truncate(s) => (width, s), + TextOverflow::Truncate(s) => (width, s, TruncateFrom::End), + TextOverflow::TruncateStart(s) => (width, s, TruncateFrom::Start), } } else { - (None, "".into()) + (None, "".into(), TruncateFrom::End) }; if let Some(text_layout) = element_state.0.borrow().as_ref() @@ -383,8 +384,9 @@ impl TextLayout { line_wrapper.truncate_line( text.clone(), truncate_width, - &truncation_suffix, + &truncation_affix, &runs, + truncate_from, ) } else { (text.clone(), Cow::Borrowed(&*runs)) diff --git a/crates/gpui/src/style.rs b/crates/gpui/src/style.rs index 4d6e6f490d81d967692a3e9d8316af75a7a4d306..7481b8001e5752599b90625450d7adb0c66ea2ca 100644 --- a/crates/gpui/src/style.rs +++ b/crates/gpui/src/style.rs @@ -334,9 +334,13 @@ pub enum WhiteSpace { /// How to truncate text that overflows the width of the element #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)] pub enum TextOverflow { - /// Truncate the text when it doesn't fit, and represent this truncation by displaying the - /// provided string. + /// Truncate the text at the end when it doesn't fit, and represent this truncation by + /// displaying the provided string (e.g., "very long te…"). Truncate(SharedString), + /// Truncate the text at the start when it doesn't fit, and represent this truncation by + /// displaying the provided string at the beginning (e.g., "…ong text here"). + /// Typically more adequate for file paths where the end is more important than the beginning. + TruncateStart(SharedString), } /// How to align text within the element diff --git a/crates/gpui/src/styled.rs b/crates/gpui/src/styled.rs index e8088a84d7fc141d0a320988c6399afe2b93ce07..c5eef0d4496edea4d30c665c82dc0a9f00bb83be 100644 --- a/crates/gpui/src/styled.rs +++ b/crates/gpui/src/styled.rs @@ -75,13 +75,21 @@ pub trait Styled: Sized { self } - /// Sets the truncate overflowing text with an ellipsis (…) if needed. + /// Sets the truncate overflowing text with an ellipsis (…) at the end if needed. /// [Docs](https://tailwindcss.com/docs/text-overflow#ellipsis) fn text_ellipsis(mut self) -> Self { self.text_style().text_overflow = Some(TextOverflow::Truncate(ELLIPSIS)); self } + /// Sets the truncate overflowing text with an ellipsis (…) at the start if needed. + /// Typically more adequate for file paths where the end is more important than the beginning. + /// Note: This doesn't exist in Tailwind CSS. + fn text_ellipsis_start(mut self) -> Self { + self.text_style().text_overflow = Some(TextOverflow::TruncateStart(ELLIPSIS)); + self + } + /// Sets the text overflow behavior of the element. fn text_overflow(mut self, overflow: TextOverflow) -> Self { self.text_style().text_overflow = Some(overflow); diff --git a/crates/gpui/src/text_system/line_wrapper.rs b/crates/gpui/src/text_system/line_wrapper.rs index 95cd55d04443c6b2c351bf8533ccb57d49e8dcd9..457316f353a48fa112de1736b2b7eaa2d4c72313 100644 --- a/crates/gpui/src/text_system/line_wrapper.rs +++ b/crates/gpui/src/text_system/line_wrapper.rs @@ -2,6 +2,15 @@ use crate::{FontId, FontRun, Pixels, PlatformTextSystem, SharedString, TextRun, use collections::HashMap; use std::{borrow::Cow, iter, sync::Arc}; +/// Determines whether to truncate text from the start or end. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +pub enum TruncateFrom { + /// Truncate text from the start. + Start, + /// Truncate text from the end. + End, +} + /// The GPUI line wrapper, used to wrap lines of text to a given width. pub struct LineWrapper { platform_text_system: Arc, @@ -129,29 +138,50 @@ impl LineWrapper { } /// Determines if a line should be truncated based on its width. + /// + /// Returns the truncation index in `line`. pub fn should_truncate_line( &mut self, line: &str, truncate_width: Pixels, - truncation_suffix: &str, + truncation_affix: &str, + truncate_from: TruncateFrom, ) -> Option { let mut width = px(0.); - let suffix_width = truncation_suffix + let suffix_width = truncation_affix .chars() .map(|c| self.width_for_char(c)) .fold(px(0.0), |a, x| a + x); let mut truncate_ix = 0; - for (ix, c) in line.char_indices() { - if width + suffix_width < truncate_width { - truncate_ix = ix; + match truncate_from { + TruncateFrom::Start => { + for (ix, c) in line.char_indices().rev() { + if width + suffix_width < truncate_width { + truncate_ix = ix; + } + + let char_width = self.width_for_char(c); + width += char_width; + + if width.floor() > truncate_width { + return Some(truncate_ix); + } + } } + TruncateFrom::End => { + for (ix, c) in line.char_indices() { + if width + suffix_width < truncate_width { + truncate_ix = ix; + } - let char_width = self.width_for_char(c); - width += char_width; + let char_width = self.width_for_char(c); + width += char_width; - if width.floor() > truncate_width { - return Some(truncate_ix); + if width.floor() > truncate_width { + return Some(truncate_ix); + } + } } } @@ -163,16 +193,23 @@ impl LineWrapper { &mut self, line: SharedString, truncate_width: Pixels, - truncation_suffix: &str, + truncation_affix: &str, runs: &'a [TextRun], + truncate_from: TruncateFrom, ) -> (SharedString, Cow<'a, [TextRun]>) { if let Some(truncate_ix) = - self.should_truncate_line(&line, truncate_width, truncation_suffix) + self.should_truncate_line(&line, truncate_width, truncation_affix, truncate_from) { - let result = - SharedString::from(format!("{}{}", &line[..truncate_ix], truncation_suffix)); + let result = match truncate_from { + TruncateFrom::Start => { + SharedString::from(format!("{truncation_affix}{}", &line[truncate_ix + 1..])) + } + TruncateFrom::End => { + SharedString::from(format!("{}{truncation_affix}", &line[..truncate_ix])) + } + }; let mut runs = runs.to_vec(); - update_runs_after_truncation(&result, truncation_suffix, &mut runs); + update_runs_after_truncation(&result, truncation_affix, &mut runs, truncate_from); (result, Cow::Owned(runs)) } else { (line, Cow::Borrowed(runs)) @@ -245,15 +282,35 @@ impl LineWrapper { } } -fn update_runs_after_truncation(result: &str, ellipsis: &str, runs: &mut Vec) { +fn update_runs_after_truncation( + result: &str, + ellipsis: &str, + runs: &mut Vec, + truncate_from: TruncateFrom, +) { let mut truncate_at = result.len() - ellipsis.len(); - for (run_index, run) in runs.iter_mut().enumerate() { - if run.len <= truncate_at { - truncate_at -= run.len; - } else { - run.len = truncate_at + ellipsis.len(); - runs.truncate(run_index + 1); - break; + match truncate_from { + TruncateFrom::Start => { + for (run_index, run) in runs.iter_mut().enumerate().rev() { + if run.len <= truncate_at { + truncate_at -= run.len; + } else { + run.len = truncate_at + ellipsis.len(); + runs.splice(..run_index, std::iter::empty()); + break; + } + } + } + TruncateFrom::End => { + for (run_index, run) in runs.iter_mut().enumerate() { + if run.len <= truncate_at { + truncate_at -= run.len; + } else { + run.len = truncate_at + ellipsis.len(); + runs.truncate(run_index + 1); + break; + } + } } } } @@ -503,7 +560,7 @@ mod tests { } #[test] - fn test_truncate_line() { + fn test_truncate_line_end() { let mut wrapper = build_wrapper(); fn perform_test( @@ -514,8 +571,13 @@ mod tests { ) { let dummy_run_lens = vec![text.len()]; let dummy_runs = generate_test_runs(&dummy_run_lens); - let (result, dummy_runs) = - wrapper.truncate_line(text.into(), px(220.), ellipsis, &dummy_runs); + let (result, dummy_runs) = wrapper.truncate_line( + text.into(), + px(220.), + ellipsis, + &dummy_runs, + TruncateFrom::End, + ); assert_eq!(result, expected); assert_eq!(dummy_runs.first().unwrap().len, result.len()); } @@ -541,7 +603,50 @@ mod tests { } #[test] - fn test_truncate_multiple_runs() { + fn test_truncate_line_start() { + let mut wrapper = build_wrapper(); + + fn perform_test( + wrapper: &mut LineWrapper, + text: &'static str, + expected: &'static str, + ellipsis: &str, + ) { + let dummy_run_lens = vec![text.len()]; + let dummy_runs = generate_test_runs(&dummy_run_lens); + let (result, dummy_runs) = wrapper.truncate_line( + text.into(), + px(220.), + ellipsis, + &dummy_runs, + TruncateFrom::Start, + ); + assert_eq!(result, expected); + assert_eq!(dummy_runs.first().unwrap().len, result.len()); + } + + perform_test( + &mut wrapper, + "aaaa bbbb cccc ddddd eeee fff gg", + "cccc ddddd eeee fff gg", + "", + ); + perform_test( + &mut wrapper, + "aaaa bbbb cccc ddddd eeee fff gg", + "…ccc ddddd eeee fff gg", + "…", + ); + perform_test( + &mut wrapper, + "aaaa bbbb cccc ddddd eeee fff gg", + "......dddd eeee fff gg", + "......", + ); + } + + #[test] + fn test_truncate_multiple_runs_end() { let mut wrapper = build_wrapper(); fn perform_test( @@ -554,7 +659,7 @@ mod tests { ) { let dummy_runs = generate_test_runs(run_lens); let (result, dummy_runs) = - wrapper.truncate_line(text.into(), line_width, "…", &dummy_runs); + wrapper.truncate_line(text.into(), line_width, "…", &dummy_runs, TruncateFrom::End); assert_eq!(result, expected); for (run, result_len) in dummy_runs.iter().zip(result_run_len) { assert_eq!(run.len, *result_len); @@ -600,10 +705,75 @@ mod tests { } #[test] - fn test_update_run_after_truncation() { + fn test_truncate_multiple_runs_start() { + let mut wrapper = build_wrapper(); + + #[track_caller] + fn perform_test( + wrapper: &mut LineWrapper, + text: &'static str, + expected: &str, + run_lens: &[usize], + result_run_len: &[usize], + line_width: Pixels, + ) { + let dummy_runs = generate_test_runs(run_lens); + let (result, dummy_runs) = wrapper.truncate_line( + text.into(), + line_width, + "…", + &dummy_runs, + TruncateFrom::Start, + ); + assert_eq!(result, expected); + for (run, result_len) in dummy_runs.iter().zip(result_run_len) { + assert_eq!(run.len, *result_len); + } + } + // Case 0: Normal + // Text: abcdefghijkl + // Runs: Run0 { len: 12, ... } + // + // Truncate res: …ijkl (truncate_at = 9) + // Run res: Run0 { string: …ijkl, len: 7, ... } + perform_test(&mut wrapper, "abcdefghijkl", "…ijkl", &[12], &[7], px(50.)); + // Case 1: Drop some runs + // Text: abcdefghijkl + // Runs: Run0 { len: 4, ... }, Run1 { len: 4, ... }, Run2 { len: 4, ... } + // + // Truncate res: …ghijkl (truncate_at = 7) + // Runs res: Run0 { string: …gh, len: 5, ... }, Run1 { string: ijkl, len: + // 4, ... } + perform_test( + &mut wrapper, + "abcdefghijkl", + "…ghijkl", + &[4, 4, 4], + &[5, 4], + px(70.), + ); + // Case 2: Truncate at start of some run + // Text: abcdefghijkl + // Runs: Run0 { len: 4, ... }, Run1 { len: 4, ... }, Run2 { len: 4, ... } + // + // Truncate res: abcdefgh… (truncate_at = 3) + // Runs res: Run0 { string: …, len: 3, ... }, Run1 { string: efgh, len: + // 4, ... }, Run2 { string: ijkl, len: 4, ... } + perform_test( + &mut wrapper, + "abcdefghijkl", + "…efghijkl", + &[4, 4, 4], + &[3, 4, 4], + px(90.), + ); + } + + #[test] + fn test_update_run_after_truncation_end() { fn perform_test(result: &str, run_lens: &[usize], result_run_lens: &[usize]) { let mut dummy_runs = generate_test_runs(run_lens); - update_runs_after_truncation(result, "…", &mut dummy_runs); + update_runs_after_truncation(result, "…", &mut dummy_runs, TruncateFrom::End); for (run, result_len) in dummy_runs.iter().zip(result_run_lens) { assert_eq!(run.len, *result_len); } diff --git a/crates/ui/src/components/label/label.rs b/crates/ui/src/components/label/label.rs index 49e2de94a1f86196c10e41879797b02070517e65..d0f50c00336eb971621e2da7bbaf53cf09569caa 100644 --- a/crates/ui/src/components/label/label.rs +++ b/crates/ui/src/components/label/label.rs @@ -56,6 +56,12 @@ impl Label { pub fn set_text(&mut self, text: impl Into) { self.label = text.into(); } + + /// Truncates the label from the start, keeping the end visible. + pub fn truncate_start(mut self) -> Self { + self.base = self.base.truncate_start(); + self + } } // Style methods. @@ -256,7 +262,8 @@ impl Component for Label { "Special Cases", vec![ single_example("Single Line", Label::new("Line 1\nLine 2\nLine 3").single_line().into_any_element()), - single_example("Text Ellipsis", div().max_w_24().child(Label::new("This is a very long file name that should be truncated: very_long_file_name_with_many_words.rs").truncate()).into_any_element()), + single_example("Regular Truncation", div().max_w_24().child(Label::new("This is a very long file name that should be truncated: very_long_file_name_with_many_words.rs").truncate()).into_any_element()), + single_example("Start Truncation", div().max_w_24().child(Label::new("zed/crates/ui/src/components/label/truncate/label/label.rs").truncate_start()).into_any_element()), ], ), ]) diff --git a/crates/ui/src/components/label/label_like.rs b/crates/ui/src/components/label/label_like.rs index 31fb7bfd88f1343ac6145c86f228bdcbd6a22e10..10d54845dabf371b8da6fed5ebbcd2b8d82ea711 100644 --- a/crates/ui/src/components/label/label_like.rs +++ b/crates/ui/src/components/label/label_like.rs @@ -88,6 +88,7 @@ pub struct LabelLike { underline: bool, single_line: bool, truncate: bool, + truncate_start: bool, } impl Default for LabelLike { @@ -113,6 +114,7 @@ impl LabelLike { underline: false, single_line: false, truncate: false, + truncate_start: false, } } } @@ -126,6 +128,12 @@ impl LabelLike { gpui::margin_style_methods!({ visibility: pub }); + + /// Truncates overflowing text with an ellipsis (`…`) at the start if needed. + pub fn truncate_start(mut self) -> Self { + self.truncate_start = true; + self + } } impl LabelCommon for LabelLike { @@ -169,7 +177,7 @@ impl LabelCommon for LabelLike { self } - /// Truncates overflowing text with an ellipsis (`…`) if needed. + /// Truncates overflowing text with an ellipsis (`…`) at the end if needed. fn truncate(mut self) -> Self { self.truncate = true; self @@ -235,6 +243,9 @@ impl RenderOnce for LabelLike { .when(self.truncate, |this| { this.overflow_x_hidden().text_ellipsis() }) + .when(self.truncate_start, |this| { + this.overflow_x_hidden().text_ellipsis_start() + }) .text_color(color) .font_weight( self.weight From 4e0471cf663b88f38246440f5ae06ca4828225d8 Mon Sep 17 00:00:00 2001 From: ozzy <109994179+ddoemonn@users.noreply.github.com> Date: Fri, 19 Dec 2025 16:50:35 +0300 Subject: [PATCH 546/621] git panel: Truncate file paths from the left (#43462) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/user-attachments/assets/758e1ec9-6c34-4e13-b605-cf00c18ca16f Release Notes: - Improved: Git panel now truncates long file paths from the left, showing "…path/filename" when space is limited, keeping filenames always visible. @cole-miller @mattermill --------- Co-authored-by: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Co-authored-by: Danilo Leal --- crates/git_ui/src/git_panel.rs | 2 +- crates/ui/src/components/label/label_like.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs index 532f9a099a823796706be48ed14cc7da820c5d8b..1323ee014f76ebde42b8dff436b2abed851d13f0 100644 --- a/crates/git_ui/src/git_panel.rs +++ b/crates/git_ui/src/git_panel.rs @@ -5203,7 +5203,7 @@ impl GitPanel { this.child( self.entry_label(path_name, path_color) - .truncate() + .truncate_start() .when(strikethrough, Label::strikethrough), ) }) diff --git a/crates/ui/src/components/label/label_like.rs b/crates/ui/src/components/label/label_like.rs index 10d54845dabf371b8da6fed5ebbcd2b8d82ea711..f6e7a1b893d54fff425618d5c604f591144a7385 100644 --- a/crates/ui/src/components/label/label_like.rs +++ b/crates/ui/src/components/label/label_like.rs @@ -56,7 +56,7 @@ pub trait LabelCommon { /// Sets the alpha property of the label, overwriting the alpha value of the color. fn alpha(self, alpha: f32) -> Self; - /// Truncates overflowing text with an ellipsis (`…`) if needed. + /// Truncates overflowing text with an ellipsis (`…`) at the end if needed. fn truncate(self) -> Self; /// Sets the label to render as a single line. From ae44c3c8811472dfb105932eaf4e24a2f2853a4e Mon Sep 17 00:00:00 2001 From: Cole Miller Date: Fri, 19 Dec 2025 09:39:58 -0500 Subject: [PATCH 547/621] Fix extra terminal being created when a task replaces a terminal in the center pane (#45317) Closes https://github.com/zed-industries/zed/issues/21144 Release Notes: - Fixed spawned tasks creating an extra terminal in the dock in some cases. --- crates/terminal_view/src/terminal_panel.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/terminal_view/src/terminal_panel.rs b/crates/terminal_view/src/terminal_panel.rs index ed43d94e9d3d7c08c1ff4570e08726310360cd93..738a0b4502642423377bdf69b49d26250536761f 100644 --- a/crates/terminal_view/src/terminal_panel.rs +++ b/crates/terminal_view/src/terminal_panel.rs @@ -939,7 +939,6 @@ impl TerminalPanel { cx: &mut Context, ) -> Task>> { let reveal = spawn_task.reveal; - let reveal_target = spawn_task.reveal_target; let task_workspace = self.workspace.clone(); cx.spawn_in(window, async move |terminal_panel, cx| { let project = terminal_panel.update(cx, |this, cx| { @@ -955,6 +954,14 @@ impl TerminalPanel { terminal_to_replace.set_terminal(new_terminal.clone(), window, cx); })?; + let reveal_target = terminal_panel.update(cx, |panel, _| { + if panel.center.panes().iter().any(|p| **p == task_pane) { + RevealTarget::Dock + } else { + RevealTarget::Center + } + })?; + match reveal { RevealStrategy::Always => match reveal_target { RevealTarget::Center => { From 7427924405dabda02cca87c24143f2d5f27eb433 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yara=20=F0=9F=8F=B3=EF=B8=8F=E2=80=8D=E2=9A=A7=EF=B8=8F?= Date: Fri, 19 Dec 2025 16:03:35 +0100 Subject: [PATCH 548/621] adjusted scheduler prioritization algorithm (#45367) This fixes a number of issues where zed depends on the order of polling which changed when switching scheduler. We have adjusted the algorithm so it matches the previous order while keeping the prioritization feature. Release Notes: - N/A --- crates/gpui/src/queue.rs | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/crates/gpui/src/queue.rs b/crates/gpui/src/queue.rs index 9e9da710977ee80df1853791918eebe5e7f01096..1ecec183c6c58a86e305343f7bcd1056cda7a581 100644 --- a/crates/gpui/src/queue.rs +++ b/crates/gpui/src/queue.rs @@ -1,4 +1,5 @@ use std::{ + collections::VecDeque, fmt, iter::FusedIterator, sync::{Arc, atomic::AtomicUsize}, @@ -9,9 +10,9 @@ use rand::{Rng, SeedableRng, rngs::SmallRng}; use crate::Priority; struct PriorityQueues { - high_priority: Vec, - medium_priority: Vec, - low_priority: Vec, + high_priority: VecDeque, + medium_priority: VecDeque, + low_priority: VecDeque, } impl PriorityQueues { @@ -42,9 +43,9 @@ impl PriorityQueueState { let mut queues = self.queues.lock(); match priority { Priority::Realtime(_) => unreachable!(), - Priority::High => queues.high_priority.push(item), - Priority::Medium => queues.medium_priority.push(item), - Priority::Low => queues.low_priority.push(item), + Priority::High => queues.high_priority.push_back(item), + Priority::Medium => queues.medium_priority.push_back(item), + Priority::Low => queues.low_priority.push_back(item), }; self.condvar.notify_one(); Ok(()) @@ -141,9 +142,9 @@ impl PriorityQueueReceiver { pub(crate) fn new() -> (PriorityQueueSender, Self) { let state = PriorityQueueState { queues: parking_lot::Mutex::new(PriorityQueues { - high_priority: Vec::new(), - medium_priority: Vec::new(), - low_priority: Vec::new(), + high_priority: VecDeque::new(), + medium_priority: VecDeque::new(), + low_priority: VecDeque::new(), }), condvar: parking_lot::Condvar::new(), receiver_count: AtomicUsize::new(1), @@ -226,7 +227,7 @@ impl PriorityQueueReceiver { if !queues.high_priority.is_empty() { let flip = self.rand.random_ratio(P::High.probability(), mass); if flip { - return Ok(queues.high_priority.pop()); + return Ok(queues.high_priority.pop_front()); } mass -= P::High.probability(); } @@ -234,7 +235,7 @@ impl PriorityQueueReceiver { if !queues.medium_priority.is_empty() { let flip = self.rand.random_ratio(P::Medium.probability(), mass); if flip { - return Ok(queues.medium_priority.pop()); + return Ok(queues.medium_priority.pop_front()); } mass -= P::Medium.probability(); } @@ -242,7 +243,7 @@ impl PriorityQueueReceiver { if !queues.low_priority.is_empty() { let flip = self.rand.random_ratio(P::Low.probability(), mass); if flip { - return Ok(queues.low_priority.pop()); + return Ok(queues.low_priority.pop_front()); } } From b603372f44a60f8ed98ae95b36094582ead47b89 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Fri, 19 Dec 2025 16:06:28 +0100 Subject: [PATCH 549/621] Reduce GPU usage by activating VRR optimization only during high-rate input (#45369) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #29073 This PR reduces unnecessary GPU usage by being more selective about when we present frames to prevent display underclocking (VRR optimization). ## Problem Previously, we would keep presenting frames for 1 second after *any* input event, regardless of whether it triggered a re-render. This caused unnecessary GPU work when the user was idle or during low-frequency interactions. ## Solution 1. **Only track input that triggers re-renders**: We now only record input timestamps when the input actually causes the window to become dirty, rather than on every input event. 2. **Rate-based activation**: The VRR optimization now only activates when input arrives at a high rate (≥ 60fps over the last 100ms). This means casual mouse movements or occasional keystrokes won't trigger continuous frame presentation. 3. **Sustained optimization**: Once high-rate input is detected (e.g., during scrolling or dragging), we sustain frame presentation for 1 second to prevent display underclocking, even if input briefly pauses. ## Implementation Added `InputRateTracker` which: - Tracks input timestamps in a 100ms sliding window - Activates when the window contains ≥ 6 events (60fps × 0.1s) - Extends a `sustain_until` timestamp by 1 second each time high rate is detected Release Notes: - Reduced GPU usage when idle by only presenting frames during bursts of high-frequency input. --- crates/gpui/src/window.rs | 70 +++++++++++++++++++++++++++++++++------ 1 file changed, 59 insertions(+), 11 deletions(-) diff --git a/crates/gpui/src/window.rs b/crates/gpui/src/window.rs index 2ccd7edac86bced89048cbe5dbf196d8fbcf95f3..8df421feb968677be0abbb642a7127871881bcf3 100644 --- a/crates/gpui/src/window.rs +++ b/crates/gpui/src/window.rs @@ -876,7 +876,9 @@ pub struct Window { active: Rc>, hovered: Rc>, pub(crate) needs_present: Rc>, - pub(crate) last_input_timestamp: Rc>, + /// Tracks recent input event timestamps to determine if input is arriving at a high rate. + /// Used to selectively enable VRR optimization only when input rate exceeds 60fps. + pub(crate) input_rate_tracker: Rc>, last_input_modality: InputModality, pub(crate) refreshing: bool, pub(crate) activation_observers: SubscriberSet<(), AnyObserver>, @@ -897,6 +899,51 @@ struct ModifierState { saw_keystroke: bool, } +/// Tracks input event timestamps to determine if input is arriving at a high rate. +/// Used for selective VRR (Variable Refresh Rate) optimization. +#[derive(Clone, Debug)] +pub(crate) struct InputRateTracker { + timestamps: Vec, + window: Duration, + inputs_per_second: u32, + sustain_until: Instant, + sustain_duration: Duration, +} + +impl Default for InputRateTracker { + fn default() -> Self { + Self { + timestamps: Vec::new(), + window: Duration::from_millis(100), + inputs_per_second: 60, + sustain_until: Instant::now(), + sustain_duration: Duration::from_secs(1), + } + } +} + +impl InputRateTracker { + pub fn record_input(&mut self) { + let now = Instant::now(); + self.timestamps.push(now); + self.prune_old_timestamps(now); + + let min_events = self.inputs_per_second as u128 * self.window.as_millis() / 1000; + if self.timestamps.len() as u128 >= min_events { + self.sustain_until = now + self.sustain_duration; + } + } + + pub fn is_high_rate(&self) -> bool { + Instant::now() < self.sustain_until + } + + fn prune_old_timestamps(&mut self, now: Instant) { + self.timestamps + .retain(|&t| now.duration_since(t) <= self.window); + } +} + #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub(crate) enum DrawPhase { None, @@ -1047,7 +1094,7 @@ impl Window { let hovered = Rc::new(Cell::new(platform_window.is_hovered())); let needs_present = Rc::new(Cell::new(false)); let next_frame_callbacks: Rc>> = Default::default(); - let last_input_timestamp = Rc::new(Cell::new(Instant::now())); + let input_rate_tracker = Rc::new(RefCell::new(InputRateTracker::default())); platform_window .request_decorations(window_decorations.unwrap_or(WindowDecorations::Server)); @@ -1075,7 +1122,7 @@ impl Window { let active = active.clone(); let needs_present = needs_present.clone(); let next_frame_callbacks = next_frame_callbacks.clone(); - let last_input_timestamp = last_input_timestamp.clone(); + let input_rate_tracker = input_rate_tracker.clone(); move |request_frame_options| { let next_frame_callbacks = next_frame_callbacks.take(); if !next_frame_callbacks.is_empty() { @@ -1088,12 +1135,12 @@ impl Window { .log_err(); } - // Keep presenting the current scene for 1 extra second since the - // last input to prevent the display from underclocking the refresh rate. + // Keep presenting if input was recently arriving at a high rate (>= 60fps). + // Once high-rate input is detected, we sustain presentation for 1 second + // to prevent display underclocking during active input. let needs_present = request_frame_options.require_presentation || needs_present.get() - || (active.get() - && last_input_timestamp.get().elapsed() < Duration::from_secs(1)); + || (active.get() && input_rate_tracker.borrow_mut().is_high_rate()); if invalidator.is_dirty() || request_frame_options.force_render { measure("frame duration", || { @@ -1101,7 +1148,6 @@ impl Window { .update(&mut cx, |_, window, cx| { let arena_clear_needed = window.draw(cx); window.present(); - // drop the arena elements after present to reduce latency arena_clear_needed.clear(); }) .log_err(); @@ -1299,7 +1345,7 @@ impl Window { active, hovered, needs_present, - last_input_timestamp, + input_rate_tracker, last_input_modality: InputModality::Mouse, refreshing: false, activation_observers: SubscriberSet::new(), @@ -3691,8 +3737,6 @@ impl Window { /// Dispatch a mouse or keyboard event on the window. #[profiling::function] pub fn dispatch_event(&mut self, event: PlatformInput, cx: &mut App) -> DispatchEventResult { - self.last_input_timestamp.set(Instant::now()); - // Track whether this input was keyboard-based for focus-visible styling self.last_input_modality = match &event { PlatformInput::KeyDown(_) | PlatformInput::ModifiersChanged(_) => { @@ -3793,6 +3837,10 @@ impl Window { self.dispatch_key_event(any_key_event, cx); } + if self.invalidator.is_dirty() { + self.input_rate_tracker.borrow_mut().record_input(); + } + DispatchEventResult { propagate: cx.propagate_event, default_prevented: self.default_prevented, From 8001877df2104f86ee236f9c813e2405346e716f Mon Sep 17 00:00:00 2001 From: AidanV <84053180+AidanV@users.noreply.github.com> Date: Fri, 19 Dec 2025 10:31:16 -0500 Subject: [PATCH 550/621] vim: Add `:r[ead] [name]` command (#45332) This adds the following Vim commands: - `:r[ead] [name]` - `:{range}r[ead] [name]` The most important parts of this feature are outlined [here](https://vimhelp.org/insert.txt.html#%3Ar). The only intentional difference between this and Vim is that Vim only allows `:read` (no filename) for buffers with a file attached. I am allowing it for all buffers because I think that could be useful. Release Notes: - vim: Added the [`:r[ead] [name]` Vim command](https://vimhelp.org/insert.txt.html#:read) --------- Co-authored-by: Ben Kunkle --- crates/vim/src/command.rs | 200 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 200 insertions(+) diff --git a/crates/vim/src/command.rs b/crates/vim/src/command.rs index 205097130d152fe255feb02a449956124586d8e6..2228c23f02beb954bdb26b2b36f078249e423d7d 100644 --- a/crates/vim/src/command.rs +++ b/crates/vim/src/command.rs @@ -230,6 +230,14 @@ struct VimEdit { pub filename: String, } +/// Pastes the specified file's contents. +#[derive(Clone, PartialEq, Action)] +#[action(namespace = vim, no_json, no_register)] +struct VimRead { + pub range: Option, + pub filename: String, +} + #[derive(Clone, PartialEq, Action)] #[action(namespace = vim, no_json, no_register)] struct VimNorm { @@ -643,6 +651,107 @@ pub fn register(editor: &mut Editor, cx: &mut Context) { }); }); + Vim::action(editor, cx, |vim, action: &VimRead, window, cx| { + vim.update_editor(cx, |vim, editor, cx| { + let snapshot = editor.buffer().read(cx).snapshot(cx); + let end = if let Some(range) = action.range.clone() { + let Some(multi_range) = range.buffer_range(vim, editor, window, cx).log_err() + else { + return; + }; + + match &range.start { + // inserting text above the first line uses the command ":0r {name}" + Position::Line { row: 0, offset: 0 } if range.end.is_none() => { + snapshot.clip_point(Point::new(0, 0), Bias::Right) + } + _ => snapshot.clip_point(Point::new(multi_range.end.0 + 1, 0), Bias::Right), + } + } else { + let end_row = editor + .selections + .newest::(&editor.display_snapshot(cx)) + .range() + .end + .row; + snapshot.clip_point(Point::new(end_row + 1, 0), Bias::Right) + }; + let is_end_of_file = end == snapshot.max_point(); + let edit_range = snapshot.anchor_before(end)..snapshot.anchor_before(end); + + let mut text = if is_end_of_file { + String::from('\n') + } else { + String::new() + }; + + let mut task = None; + if action.filename.is_empty() { + text.push_str( + &editor + .buffer() + .read(cx) + .as_singleton() + .map(|buffer| buffer.read(cx).text()) + .unwrap_or_default(), + ); + } else { + if let Some(project) = editor.project().cloned() { + project.update(cx, |project, cx| { + let Some(worktree) = project.visible_worktrees(cx).next() else { + return; + }; + let path_style = worktree.read(cx).path_style(); + let Some(path) = + RelPath::new(Path::new(&action.filename), path_style).log_err() + else { + return; + }; + task = + Some(worktree.update(cx, |worktree, cx| worktree.load_file(&path, cx))); + }); + } else { + return; + } + }; + + cx.spawn_in(window, async move |editor, cx| { + if let Some(task) = task { + text.push_str( + &task + .await + .log_err() + .map(|loaded_file| loaded_file.text) + .unwrap_or_default(), + ); + } + + if !text.is_empty() && !is_end_of_file { + text.push('\n'); + } + + let _ = editor.update_in(cx, |editor, window, cx| { + editor.transact(window, cx, |editor, window, cx| { + editor.edit([(edit_range.clone(), text)], cx); + let snapshot = editor.buffer().read(cx).snapshot(cx); + editor.change_selections(Default::default(), window, cx, |s| { + let point = if is_end_of_file { + Point::new( + edit_range.start.to_point(&snapshot).row.saturating_add(1), + 0, + ) + } else { + Point::new(edit_range.start.to_point(&snapshot).row, 0) + }; + s.select_ranges([point..point]); + }) + }); + }); + }) + .detach(); + }); + }); + Vim::action(editor, cx, |vim, action: &VimNorm, window, cx| { let keystrokes = action .command @@ -1338,6 +1447,27 @@ fn generate_commands(_: &App) -> Vec { VimCommand::new(("e", "dit"), editor::actions::ReloadFile) .bang(editor::actions::ReloadFile) .filename(|_, filename| Some(VimEdit { filename }.boxed_clone())), + VimCommand::new( + ("r", "ead"), + VimRead { + range: None, + filename: "".into(), + }, + ) + .filename(|_, filename| { + Some( + VimRead { + range: None, + filename, + } + .boxed_clone(), + ) + }) + .range(|action, range| { + let mut action: VimRead = action.as_any().downcast_ref::().unwrap().clone(); + action.range.replace(range.clone()); + Some(Box::new(action)) + }), VimCommand::new(("sp", "lit"), workspace::SplitHorizontal).filename(|_, filename| { Some( VimSplit { @@ -2575,6 +2705,76 @@ mod test { assert_eq!(fs.load(path).await.unwrap().replace("\r\n", "\n"), "@@\n"); } + #[gpui::test] + async fn test_command_read(cx: &mut TestAppContext) { + let mut cx = VimTestContext::new(cx, true).await; + + let fs = cx.workspace(|workspace, _, cx| workspace.project().read(cx).fs().clone()); + let path = Path::new(path!("/root/dir/other.rs")); + fs.as_fake().insert_file(path, "1\n2\n3".into()).await; + + cx.workspace(|workspace, _, cx| { + assert_active_item(workspace, path!("/root/dir/file.rs"), "", cx); + }); + + // File without trailing newline + cx.set_state("one\ntwo\nthreeˇ", Mode::Normal); + cx.simulate_keystrokes(": r space d i r / o t h e r . r s"); + cx.simulate_keystrokes("enter"); + cx.assert_state("one\ntwo\nthree\nˇ1\n2\n3", Mode::Normal); + + cx.set_state("oneˇ\ntwo\nthree", Mode::Normal); + cx.simulate_keystrokes(": r space d i r / o t h e r . r s"); + cx.simulate_keystrokes("enter"); + cx.assert_state("one\nˇ1\n2\n3\ntwo\nthree", Mode::Normal); + + cx.set_state("one\nˇtwo\nthree", Mode::Normal); + cx.simulate_keystrokes(": 0 r space d i r / o t h e r . r s"); + cx.simulate_keystrokes("enter"); + cx.assert_state("ˇ1\n2\n3\none\ntwo\nthree", Mode::Normal); + + cx.set_state("one\n«ˇtwo\nthree\nfour»\nfive", Mode::Visual); + cx.simulate_keystrokes(": r space d i r / o t h e r . r s"); + cx.simulate_keystrokes("enter"); + cx.run_until_parked(); + cx.assert_state("one\ntwo\nthree\nfour\nˇ1\n2\n3\nfive", Mode::Normal); + + // Empty filename + cx.set_state("oneˇ\ntwo\nthree", Mode::Normal); + cx.simulate_keystrokes(": r"); + cx.simulate_keystrokes("enter"); + cx.assert_state("one\nˇone\ntwo\nthree\ntwo\nthree", Mode::Normal); + + // File with trailing newline + fs.as_fake().insert_file(path, "1\n2\n3\n".into()).await; + cx.set_state("one\ntwo\nthreeˇ", Mode::Normal); + cx.simulate_keystrokes(": r space d i r / o t h e r . r s"); + cx.simulate_keystrokes("enter"); + cx.assert_state("one\ntwo\nthree\nˇ1\n2\n3\n", Mode::Normal); + + cx.set_state("oneˇ\ntwo\nthree", Mode::Normal); + cx.simulate_keystrokes(": r space d i r / o t h e r . r s"); + cx.simulate_keystrokes("enter"); + cx.assert_state("one\nˇ1\n2\n3\n\ntwo\nthree", Mode::Normal); + + cx.set_state("one\n«ˇtwo\nthree\nfour»\nfive", Mode::Visual); + cx.simulate_keystrokes(": r space d i r / o t h e r . r s"); + cx.simulate_keystrokes("enter"); + cx.assert_state("one\ntwo\nthree\nfour\nˇ1\n2\n3\n\nfive", Mode::Normal); + + cx.set_state("«one\ntwo\nthreeˇ»", Mode::Visual); + cx.simulate_keystrokes(": r space d i r / o t h e r . r s"); + cx.simulate_keystrokes("enter"); + cx.assert_state("one\ntwo\nthree\nˇ1\n2\n3\n", Mode::Normal); + + // Empty file + fs.as_fake().insert_file(path, "".into()).await; + cx.set_state("ˇone\ntwo\nthree", Mode::Normal); + cx.simulate_keystrokes(": r space d i r / o t h e r . r s"); + cx.simulate_keystrokes("enter"); + cx.assert_state("one\nˇtwo\nthree", Mode::Normal); + } + #[gpui::test] async fn test_command_quit(cx: &mut TestAppContext) { let mut cx = VimTestContext::new(cx, true).await; From a7d43063d45d616573b26733778fb7af0fbbbf4b Mon Sep 17 00:00:00 2001 From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Date: Fri, 19 Dec 2025 13:01:48 -0300 Subject: [PATCH 551/621] workspace: Make title bar pickers render nearby the trigger when mouse-triggered (#45361) From Zed's title bar, you can click on buttons to open three modal pickers: remote projects, projects, and branches. All of these pickers use the modal layer, which by default, renders them centered on the UI. However, a UX issue we've been bothered by is that when you _click_ to open them, they show up just way too far from where your mouse likely is (nearby the trigger you just clicked). So, this PR introduces a `ModalPlacement` enum to the modal layer, so that we can pick between the "centered" and "anchored" options to render the picker. This way, we can make the pickers use anchored positioning when triggered through a mouse click and use the default centered positioning when triggered through the keybinding. One thing to note is that the anchored positioning here is not as polished as regular popovers/dropdowns, because it simply uses the x and y coordinates of the click to place the picker as opposed to using GPUI's `Corner` enum, thus making them more connected to their triggers. I chose to do it this way for now because it's a simpler and more contained change, given it wouldn't require a tighter connection at the code level between trigger and picker. But maybe we will want to do that in the near future because we can bake in some other related behaviors like automatically hiding the button trigger tooltip if the picker is open and changing its text color to communicate which button triggered the open picker. https://github.com/user-attachments/assets/30d9c26a-24de-4702-8b7d-018b397f77e1 Release Notes: - Improved the UX of title bar modal pickers (remote projects, projects, and branches) by making them open closer to the trigger when triggering them with the mouse. --- crates/title_bar/src/title_bar.rs | 272 +++++++++++++++++----------- crates/workspace/src/modal_layer.rs | 77 ++++++-- crates/workspace/src/workspace.rs | 17 +- 3 files changed, 240 insertions(+), 126 deletions(-) diff --git a/crates/title_bar/src/title_bar.rs b/crates/title_bar/src/title_bar.rs index d7759b0df8019eed2ad59b73bcaffaa3ffcfb866..9b75d35eccafa3c30f23329d9c0ee890ed2b2405 100644 --- a/crates/title_bar/src/title_bar.rs +++ b/crates/title_bar/src/title_bar.rs @@ -166,11 +166,11 @@ impl Render for TitleBar { .when(title_bar_settings.show_project_items, |title_bar| { title_bar .children(self.render_restricted_mode(cx)) - .children(self.render_project_host(cx)) - .child(self.render_project_name(cx)) + .children(self.render_project_host(window, cx)) + .child(self.render_project_name(window, cx)) }) .when(title_bar_settings.show_branch_name, |title_bar| { - title_bar.children(self.render_project_repo(cx)) + title_bar.children(self.render_project_repo(window, cx)) }) }) }) @@ -350,7 +350,14 @@ impl TitleBar { .next() } - fn render_remote_project_connection(&self, cx: &mut Context) -> Option { + fn render_remote_project_connection( + &self, + window: &mut Window, + cx: &mut Context, + ) -> Option { + let workspace = self.workspace.clone(); + let is_picker_open = self.is_picker_open(window, cx); + let options = self.project.read(cx).remote_connection_options(cx)?; let host: SharedString = options.display_name().into(); @@ -395,7 +402,7 @@ impl TitleBar { let meta = SharedString::from(meta); Some( - ButtonLike::new("ssh-server-icon") + ButtonLike::new("remote_project") .child( h_flex() .gap_2() @@ -410,26 +417,35 @@ impl TitleBar { ) .child(Label::new(nickname).size(LabelSize::Small).truncate()), ) - .tooltip(move |_window, cx| { - Tooltip::with_meta( - tooltip_title, - Some(&OpenRemote { - from_existing_connection: false, - create_new_window: false, - }), - meta.clone(), - cx, - ) + .when(!is_picker_open, |this| { + this.tooltip(move |_window, cx| { + Tooltip::with_meta( + tooltip_title, + Some(&OpenRemote { + from_existing_connection: false, + create_new_window: false, + }), + meta.clone(), + cx, + ) + }) }) - .on_click(|_, window, cx| { - window.dispatch_action( - OpenRemote { - from_existing_connection: false, - create_new_window: false, - } - .boxed_clone(), - cx, - ); + .on_click(move |event, window, cx| { + let position = event.position(); + let _ = workspace.update(cx, |this, cx| { + this.set_next_modal_placement(workspace::ModalPlacement::Anchored { + position, + }); + + window.dispatch_action( + OpenRemote { + from_existing_connection: false, + create_new_window: false, + } + .boxed_clone(), + cx, + ); + }); }) .into_any_element(), ) @@ -481,9 +497,13 @@ impl TitleBar { } } - pub fn render_project_host(&self, cx: &mut Context) -> Option { + pub fn render_project_host( + &self, + window: &mut Window, + cx: &mut Context, + ) -> Option { if self.project.read(cx).is_via_remote_server() { - return self.render_remote_project_connection(cx); + return self.render_remote_project_connection(window, cx); } if self.project.read(cx).is_disconnected(cx) { @@ -491,7 +511,6 @@ impl TitleBar { Button::new("disconnected", "Disconnected") .disabled(true) .color(Color::Disabled) - .style(ButtonStyle::Subtle) .label_size(LabelSize::Small) .into_any_element(), ); @@ -504,15 +523,19 @@ impl TitleBar { .read(cx) .participant_indices() .get(&host_user.id)?; + Some( Button::new("project_owner_trigger", host_user.github_login.clone()) .color(Color::Player(participant_index.0)) - .style(ButtonStyle::Subtle) .label_size(LabelSize::Small) - .tooltip(Tooltip::text(format!( - "{} is sharing this project. Click to follow.", - host_user.github_login - ))) + .tooltip(move |_, cx| { + let tooltip_title = format!( + "{} is sharing this project. Click to follow.", + host_user.github_login + ); + + Tooltip::with_meta(tooltip_title, None, "Click to Follow", cx) + }) .on_click({ let host_peer_id = host.peer_id; cx.listener(move |this, _, window, cx| { @@ -527,7 +550,14 @@ impl TitleBar { ) } - pub fn render_project_name(&self, cx: &mut Context) -> impl IntoElement { + pub fn render_project_name( + &self, + window: &mut Window, + cx: &mut Context, + ) -> impl IntoElement { + let workspace = self.workspace.clone(); + let is_picker_open = self.is_picker_open(window, cx); + let name = self.project_name(cx); let is_project_selected = name.is_some(); let name = if let Some(name) = name { @@ -537,19 +567,25 @@ impl TitleBar { }; Button::new("project_name_trigger", name) - .when(!is_project_selected, |b| b.color(Color::Muted)) - .style(ButtonStyle::Subtle) .label_size(LabelSize::Small) - .tooltip(move |_window, cx| { - Tooltip::for_action( - "Recent Projects", - &zed_actions::OpenRecent { - create_new_window: false, - }, - cx, - ) + .when(!is_project_selected, |s| s.color(Color::Muted)) + .when(!is_picker_open, |this| { + this.tooltip(move |_window, cx| { + Tooltip::for_action( + "Recent Projects", + &zed_actions::OpenRecent { + create_new_window: false, + }, + cx, + ) + }) }) - .on_click(cx.listener(move |_, _, window, cx| { + .on_click(move |event, window, cx| { + let position = event.position(); + let _ = workspace.update(cx, |this, _cx| { + this.set_next_modal_placement(workspace::ModalPlacement::Anchored { position }) + }); + window.dispatch_action( OpenRecent { create_new_window: false, @@ -557,84 +593,102 @@ impl TitleBar { .boxed_clone(), cx, ); - })) + }) } - pub fn render_project_repo(&self, cx: &mut Context) -> Option { - let settings = TitleBarSettings::get_global(cx); + pub fn render_project_repo( + &self, + window: &mut Window, + cx: &mut Context, + ) -> Option { let repository = self.project.read(cx).active_repository(cx)?; let repository_count = self.project.read(cx).repositories(cx).len(); let workspace = self.workspace.upgrade()?; - let repo = repository.read(cx); - let branch_name = repo - .branch - .as_ref() - .map(|branch| branch.name()) - .map(|name| util::truncate_and_trailoff(name, MAX_BRANCH_NAME_LENGTH)) - .or_else(|| { - repo.head_commit.as_ref().map(|commit| { - commit - .sha - .chars() - .take(MAX_SHORT_SHA_LENGTH) - .collect::() - }) - })?; - let project_name = self.project_name(cx); - let repo_name = repo - .work_directory_abs_path - .file_name() - .and_then(|name| name.to_str()) - .map(SharedString::new); - let show_repo_name = - repository_count > 1 && repo.branch.is_some() && repo_name != project_name; - let branch_name = if let Some(repo_name) = repo_name.filter(|_| show_repo_name) { - format!("{repo_name}/{branch_name}") - } else { - branch_name + + let (branch_name, icon_info) = { + let repo = repository.read(cx); + let branch_name = repo + .branch + .as_ref() + .map(|branch| branch.name()) + .map(|name| util::truncate_and_trailoff(name, MAX_BRANCH_NAME_LENGTH)) + .or_else(|| { + repo.head_commit.as_ref().map(|commit| { + commit + .sha + .chars() + .take(MAX_SHORT_SHA_LENGTH) + .collect::() + }) + }); + + let branch_name = branch_name?; + + let project_name = self.project_name(cx); + let repo_name = repo + .work_directory_abs_path + .file_name() + .and_then(|name| name.to_str()) + .map(SharedString::new); + let show_repo_name = + repository_count > 1 && repo.branch.is_some() && repo_name != project_name; + let branch_name = if let Some(repo_name) = repo_name.filter(|_| show_repo_name) { + format!("{repo_name}/{branch_name}") + } else { + branch_name + }; + + let status = repo.status_summary(); + let tracked = status.index + status.worktree; + let icon_info = if status.conflict > 0 { + (IconName::Warning, Color::VersionControlConflict) + } else if tracked.modified > 0 { + (IconName::SquareDot, Color::VersionControlModified) + } else if tracked.added > 0 || status.untracked > 0 { + (IconName::SquarePlus, Color::VersionControlAdded) + } else if tracked.deleted > 0 { + (IconName::SquareMinus, Color::VersionControlDeleted) + } else { + (IconName::GitBranch, Color::Muted) + }; + + (branch_name, icon_info) }; + let is_picker_open = self.is_picker_open(window, cx); + let settings = TitleBarSettings::get_global(cx); + Some( Button::new("project_branch_trigger", branch_name) - .color(Color::Muted) - .style(ButtonStyle::Subtle) .label_size(LabelSize::Small) - .tooltip(move |_window, cx| { - Tooltip::with_meta( - "Recent Branches", - Some(&zed_actions::git::Branch), - "Local branches only", - cx, - ) - }) - .on_click(move |_, window, cx| { - let _ = workspace.update(cx, |this, cx| { - window.focus(&this.active_pane().focus_handle(cx), cx); - window.dispatch_action(zed_actions::git::Branch.boxed_clone(), cx); - }); + .color(Color::Muted) + .when(!is_picker_open, |this| { + this.tooltip(move |_window, cx| { + Tooltip::with_meta( + "Recent Branches", + Some(&zed_actions::git::Branch), + "Local branches only", + cx, + ) + }) }) .when(settings.show_branch_icon, |branch_button| { - let (icon, icon_color) = { - let status = repo.status_summary(); - let tracked = status.index + status.worktree; - if status.conflict > 0 { - (IconName::Warning, Color::VersionControlConflict) - } else if tracked.modified > 0 { - (IconName::SquareDot, Color::VersionControlModified) - } else if tracked.added > 0 || status.untracked > 0 { - (IconName::SquarePlus, Color::VersionControlAdded) - } else if tracked.deleted > 0 { - (IconName::SquareMinus, Color::VersionControlDeleted) - } else { - (IconName::GitBranch, Color::Muted) - } - }; - + let (icon, icon_color) = icon_info; branch_button .icon(icon) .icon_position(IconPosition::Start) .icon_color(icon_color) .icon_size(IconSize::Indicator) + }) + .on_click(move |event, window, cx| { + let position = event.position(); + let _ = workspace.update(cx, |this, cx| { + this.set_next_modal_placement(workspace::ModalPlacement::Anchored { + position, + }); + window.focus(&this.active_pane().focus_handle(cx), cx); + window.dispatch_action(zed_actions::git::Branch.boxed_clone(), cx); + }); }), ) } @@ -726,7 +780,7 @@ impl TitleBar { pub fn render_sign_in_button(&mut self, _: &mut Context) -> Button { let client = self.client.clone(); - Button::new("sign_in", "Sign in") + Button::new("sign_in", "Sign In") .label_size(LabelSize::Small) .on_click(move |_, window, cx| { let client = client.clone(); @@ -848,4 +902,10 @@ impl TitleBar { }) .anchor(gpui::Corner::TopRight) } + + fn is_picker_open(&self, window: &mut Window, cx: &mut Context) -> bool { + self.workspace + .update(cx, |workspace, cx| workspace.has_active_modal(window, cx)) + .unwrap_or(false) + } } diff --git a/crates/workspace/src/modal_layer.rs b/crates/workspace/src/modal_layer.rs index 58667e7ffa8ad4fe5a22d293e4fc4aa71015a3bd..4087e1a398ac2b89257fea6b4dce53278d0872a8 100644 --- a/crates/workspace/src/modal_layer.rs +++ b/crates/workspace/src/modal_layer.rs @@ -1,9 +1,18 @@ use gpui::{ AnyView, DismissEvent, Entity, EventEmitter, FocusHandle, Focusable as _, ManagedView, - MouseButton, Subscription, + MouseButton, Pixels, Point, Subscription, }; use ui::prelude::*; +#[derive(Debug, Clone, Copy, Default)] +pub enum ModalPlacement { + #[default] + Centered, + Anchored { + position: Point, + }, +} + #[derive(Debug)] pub enum DismissDecision { Dismiss(bool), @@ -58,6 +67,7 @@ pub struct ActiveModal { _subscriptions: [Subscription; 2], previous_focus_handle: Option, focus_handle: FocusHandle, + placement: ModalPlacement, } pub struct ModalLayer { @@ -87,6 +97,19 @@ impl ModalLayer { where V: ModalView, B: FnOnce(&mut Window, &mut Context) -> V, + { + self.toggle_modal_with_placement(window, cx, ModalPlacement::Centered, build_view); + } + + pub fn toggle_modal_with_placement( + &mut self, + window: &mut Window, + cx: &mut Context, + placement: ModalPlacement, + build_view: B, + ) where + V: ModalView, + B: FnOnce(&mut Window, &mut Context) -> V, { if let Some(active_modal) = &self.active_modal { let is_close = active_modal.modal.view().downcast::().is_ok(); @@ -96,12 +119,17 @@ impl ModalLayer { } } let new_modal = cx.new(|cx| build_view(window, cx)); - self.show_modal(new_modal, window, cx); + self.show_modal(new_modal, placement, window, cx); cx.emit(ModalOpenedEvent); } - fn show_modal(&mut self, new_modal: Entity, window: &mut Window, cx: &mut Context) - where + fn show_modal( + &mut self, + new_modal: Entity, + placement: ModalPlacement, + window: &mut Window, + cx: &mut Context, + ) where V: ModalView, { let focus_handle = cx.focus_handle(); @@ -123,6 +151,7 @@ impl ModalLayer { ], previous_focus_handle: window.focused(cx), focus_handle, + placement, }); cx.defer_in(window, move |_, window, cx| { window.focus(&new_modal.focus_handle(cx), cx); @@ -183,6 +212,30 @@ impl Render for ModalLayer { return active_modal.modal.view().into_any_element(); } + let content = h_flex() + .occlude() + .child(active_modal.modal.view()) + .on_mouse_down(MouseButton::Left, |_, _, cx| { + cx.stop_propagation(); + }); + + let positioned = match active_modal.placement { + ModalPlacement::Centered => v_flex() + .h(px(0.0)) + .top_20() + .items_center() + .track_focus(&active_modal.focus_handle) + .child(content) + .into_any_element(), + ModalPlacement::Anchored { position } => div() + .absolute() + .left(position.x) + .top(position.y - px(20.)) + .track_focus(&active_modal.focus_handle) + .child(content) + .into_any_element(), + }; + div() .absolute() .size_full() @@ -199,21 +252,7 @@ impl Render for ModalLayer { this.hide_modal(window, cx); }), ) - .child( - v_flex() - .h(px(0.0)) - .top_20() - .items_center() - .track_focus(&active_modal.focus_handle) - .child( - h_flex() - .occlude() - .child(active_modal.modal.view()) - .on_mouse_down(MouseButton::Left, |_, _, cx| { - cx.stop_propagation(); - }), - ), - ) + .child(positioned) .into_any_element() } } diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index 53b0cc0623fa4b3ce7de5f1d8e3fd2262210a09a..c88386281e73b243dbddd6cb00c80fb26595409e 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -1204,6 +1204,7 @@ pub struct Workspace { last_open_dock_positions: Vec, removing: bool, utility_panes: UtilityPaneState, + next_modal_placement: Option, } impl EventEmitter for Workspace {} @@ -1620,6 +1621,7 @@ impl Workspace { last_open_dock_positions: Vec::new(), removing: false, utility_panes: UtilityPaneState::default(), + next_modal_placement: None, } } @@ -6326,12 +6328,25 @@ impl Workspace { self.modal_layer.read(cx).active_modal() } + pub fn is_modal_open(&self, cx: &App) -> bool { + self.modal_layer.read(cx).active_modal::().is_some() + } + + pub fn set_next_modal_placement(&mut self, placement: ModalPlacement) { + self.next_modal_placement = Some(placement); + } + + fn take_next_modal_placement(&mut self) -> ModalPlacement { + self.next_modal_placement.take().unwrap_or_default() + } + pub fn toggle_modal(&mut self, window: &mut Window, cx: &mut App, build: B) where B: FnOnce(&mut Window, &mut Context) -> V, { + let placement = self.take_next_modal_placement(); self.modal_layer.update(cx, |modal_layer, cx| { - modal_layer.toggle_modal(window, cx, build) + modal_layer.toggle_modal_with_placement(window, cx, placement, build) }) } From ea34cc5324c12ee44d7128f15f9bc5de42d3f358 Mon Sep 17 00:00:00 2001 From: feeiyu <158308373+feeiyu@users.noreply.github.com> Date: Sat, 20 Dec 2025 00:06:16 +0800 Subject: [PATCH 552/621] Fix terminal doesn't switch to project directory when opening remote project on Windows (#45328) Closes #45253 Release Notes: - Fixed terminal doesn't switch to project directory when opening remote project on Windows --- crates/remote/src/transport/ssh.rs | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/crates/remote/src/transport/ssh.rs b/crates/remote/src/transport/ssh.rs index 6c8eb49c1c2158322a275e064162b53e2f5f3d5e..d13e1c4934947e39b08e05eb32e2787548e621e1 100644 --- a/crates/remote/src/transport/ssh.rs +++ b/crates/remote/src/transport/ssh.rs @@ -32,8 +32,7 @@ use tempfile::TempDir; use util::{ paths::{PathStyle, RemotePathBuf}, rel_path::RelPath, - shell::{Shell, ShellKind}, - shell_builder::ShellBuilder, + shell::ShellKind, }; pub(crate) struct SshRemoteConnection { @@ -1544,8 +1543,6 @@ fn build_command( } else { write!(exec, "{ssh_shell} -l")?; }; - let (command, command_args) = ShellBuilder::new(&Shell::Program(ssh_shell.to_owned()), false) - .build(Some(exec.clone()), &[]); let mut args = Vec::new(); args.extend(ssh_args); @@ -1556,8 +1553,7 @@ fn build_command( } args.push("-t".into()); - args.push(command); - args.extend(command_args); + args.push(exec); Ok(CommandTemplate { program: "ssh".into(), @@ -1597,9 +1593,6 @@ mod tests { "-p", "2222", "-t", - "/bin/fish", - "-i", - "-c", "cd \"$HOME/work\" && exec env INPUT_VA=val remote_program arg1 arg2" ] ); @@ -1632,9 +1625,6 @@ mod tests { "-L", "1:foo:2", "-t", - "/bin/fish", - "-i", - "-c", "cd && exec env INPUT_VA=val /bin/fish -l" ] ); From a7e07010e58bc53bcc8a33adbb0e5e31d251c432 Mon Sep 17 00:00:00 2001 From: "Raduan A." <36044389+0xRaduan@users.noreply.github.com> Date: Fri, 19 Dec 2025 17:14:02 +0100 Subject: [PATCH 553/621] editor: Add automatic markdown list continuation on newline and indent on tab (#42800) Closes #5089 Release notes: - Markdown lists now continue automatically when you press Enter (unordered, ordered, and task lists). This can be configured with `extend_list_on_newline` (default: true). - You can now indent list markers with Tab to quickly create nested lists. This can be configured with `indent_list_on_tab` (default: true). --------- Co-authored-by: Claude Co-authored-by: Smit Barmase --- assets/settings/default.json | 4 + crates/editor/src/editor.rs | 459 +++++++++++--- crates/editor/src/editor_tests.rs | 588 ++++++++++++++++-- crates/language/src/language.rs | 45 ++ crates/language/src/language_settings.rs | 6 + crates/languages/src/markdown/config.toml | 3 + .../settings/src/settings_content/language.rs | 8 + crates/settings/src/vscode_import.rs | 2 + docs/src/configuring-zed.md | 20 + docs/src/languages/markdown.md | 34 + 10 files changed, 1021 insertions(+), 148 deletions(-) diff --git a/assets/settings/default.json b/assets/settings/default.json index 154fe2d6e34e6573e95e7ffedbb46df8bbf10634..746ccb5986d0fd1d5ef11df525303e344a7393d2 100644 --- a/assets/settings/default.json +++ b/assets/settings/default.json @@ -1178,6 +1178,10 @@ "remove_trailing_whitespace_on_save": true, // Whether to start a new line with a comment when a previous line is a comment as well. "extend_comment_on_newline": true, + // Whether to continue markdown lists when pressing enter. + "extend_list_on_newline": true, + // Whether to indent list items when pressing tab after a list marker. + "indent_list_on_tab": true, // Removes any lines containing only whitespace at the end of the file and // ensures just one newline at the end. "ensure_final_newline_on_save": true, diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 8560705802264dad55b87dbf21e1f9aa7625edf8..6e4744335b8e9fba50a6c2c8b241607b0e05d276 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -163,6 +163,7 @@ use project::{ project_settings::{DiagnosticSeverity, GoToDiagnosticSeverityFilter, ProjectSettings}, }; use rand::seq::SliceRandom; +use regex::Regex; use rpc::{ErrorCode, ErrorExt, proto::PeerId}; use scroll::{Autoscroll, OngoingScroll, ScrollAnchor, ScrollManager}; use selections_collection::{MutableSelectionsCollection, SelectionsCollection}; @@ -4787,82 +4788,146 @@ impl Editor { let end = selection.end; let selection_is_empty = start == end; let language_scope = buffer.language_scope_at(start); - let (comment_delimiter, doc_delimiter, newline_formatting) = - if let Some(language) = &language_scope { - let mut newline_formatting = - NewlineFormatting::new(&buffer, start..end, language); - - // Comment extension on newline is allowed only for cursor selections - let comment_delimiter = maybe!({ - if !selection_is_empty { - return None; - } + let (delimiter, newline_config) = if let Some(language) = &language_scope { + let needs_extra_newline = NewlineConfig::insert_extra_newline_brackets( + &buffer, + start..end, + language, + ) + || NewlineConfig::insert_extra_newline_tree_sitter( + &buffer, + start..end, + ); - if !multi_buffer.language_settings(cx).extend_comment_on_newline - { - return None; - } + let mut newline_config = NewlineConfig::Newline { + additional_indent: IndentSize::spaces(0), + extra_line_additional_indent: if needs_extra_newline { + Some(IndentSize::spaces(0)) + } else { + None + }, + prevent_auto_indent: false, + }; - return comment_delimiter_for_newline( - &start_point, - &buffer, - language, - ); - }); + let comment_delimiter = maybe!({ + if !selection_is_empty { + return None; + } - let doc_delimiter = maybe!({ - if !selection_is_empty { - return None; - } + if !multi_buffer.language_settings(cx).extend_comment_on_newline { + return None; + } - if !multi_buffer.language_settings(cx).extend_comment_on_newline - { - return None; - } + return comment_delimiter_for_newline( + &start_point, + &buffer, + language, + ); + }); - return documentation_delimiter_for_newline( - &start_point, - &buffer, - language, - &mut newline_formatting, - ); - }); + let doc_delimiter = maybe!({ + if !selection_is_empty { + return None; + } - (comment_delimiter, doc_delimiter, newline_formatting) - } else { - (None, None, NewlineFormatting::default()) - }; + if !multi_buffer.language_settings(cx).extend_comment_on_newline { + return None; + } - let prevent_auto_indent = doc_delimiter.is_some(); - let delimiter = comment_delimiter.or(doc_delimiter); + return documentation_delimiter_for_newline( + &start_point, + &buffer, + language, + &mut newline_config, + ); + }); - let capacity_for_delimiter = - delimiter.as_deref().map(str::len).unwrap_or_default(); - let mut new_text = String::with_capacity( - 1 + capacity_for_delimiter - + existing_indent.len as usize - + newline_formatting.indent_on_newline.len as usize - + newline_formatting.indent_on_extra_newline.len as usize, - ); - new_text.push('\n'); - new_text.extend(existing_indent.chars()); - new_text.extend(newline_formatting.indent_on_newline.chars()); + let list_delimiter = maybe!({ + if !selection_is_empty { + return None; + } - if let Some(delimiter) = &delimiter { - new_text.push_str(delimiter); - } + if !multi_buffer.language_settings(cx).extend_list_on_newline { + return None; + } - if newline_formatting.insert_extra_newline { - new_text.push('\n'); - new_text.extend(existing_indent.chars()); - new_text.extend(newline_formatting.indent_on_extra_newline.chars()); - } + return list_delimiter_for_newline( + &start_point, + &buffer, + language, + &mut newline_config, + ); + }); + + ( + comment_delimiter.or(doc_delimiter).or(list_delimiter), + newline_config, + ) + } else { + ( + None, + NewlineConfig::Newline { + additional_indent: IndentSize::spaces(0), + extra_line_additional_indent: None, + prevent_auto_indent: false, + }, + ) + }; + + let (edit_start, new_text, prevent_auto_indent) = match &newline_config { + NewlineConfig::ClearCurrentLine => { + let row_start = + buffer.point_to_offset(Point::new(start_point.row, 0)); + (row_start, String::new(), false) + } + NewlineConfig::UnindentCurrentLine { continuation } => { + let row_start = + buffer.point_to_offset(Point::new(start_point.row, 0)); + let tab_size = buffer.language_settings_at(start, cx).tab_size; + let tab_size_indent = IndentSize::spaces(tab_size.get()); + let reduced_indent = + existing_indent.with_delta(Ordering::Less, tab_size_indent); + let mut new_text = String::new(); + new_text.extend(reduced_indent.chars()); + new_text.push_str(continuation); + (row_start, new_text, true) + } + NewlineConfig::Newline { + additional_indent, + extra_line_additional_indent, + prevent_auto_indent, + } => { + let capacity_for_delimiter = + delimiter.as_deref().map(str::len).unwrap_or_default(); + let extra_line_len = extra_line_additional_indent + .map(|i| 1 + existing_indent.len as usize + i.len as usize) + .unwrap_or(0); + let mut new_text = String::with_capacity( + 1 + capacity_for_delimiter + + existing_indent.len as usize + + additional_indent.len as usize + + extra_line_len, + ); + new_text.push('\n'); + new_text.extend(existing_indent.chars()); + new_text.extend(additional_indent.chars()); + if let Some(delimiter) = &delimiter { + new_text.push_str(delimiter); + } + if let Some(extra_indent) = extra_line_additional_indent { + new_text.push('\n'); + new_text.extend(existing_indent.chars()); + new_text.extend(extra_indent.chars()); + } + (start, new_text, *prevent_auto_indent) + } + }; let anchor = buffer.anchor_after(end); let new_selection = selection.map(|_| anchor); ( - ((start..end, new_text), prevent_auto_indent), - (newline_formatting.insert_extra_newline, new_selection), + ((edit_start..end, new_text), prevent_auto_indent), + (newline_config.has_extra_line(), new_selection), ) }) .unzip() @@ -10387,6 +10452,22 @@ impl Editor { } prev_edited_row = selection.end.row; + // If cursor is after a list prefix, make selection non-empty to trigger line indent + if selection.is_empty() { + let cursor = selection.head(); + let settings = buffer.language_settings_at(cursor, cx); + if settings.indent_list_on_tab { + if let Some(language) = snapshot.language_scope_at(Point::new(cursor.row, 0)) { + if is_list_prefix_row(MultiBufferRow(cursor.row), &snapshot, &language) { + row_delta = Self::indent_selection( + buffer, &snapshot, selection, &mut edits, row_delta, cx, + ); + continue; + } + } + } + } + // If the selection is non-empty, then increase the indentation of the selected lines. if !selection.is_empty() { row_delta = @@ -23355,7 +23436,7 @@ fn documentation_delimiter_for_newline( start_point: &Point, buffer: &MultiBufferSnapshot, language: &LanguageScope, - newline_formatting: &mut NewlineFormatting, + newline_config: &mut NewlineConfig, ) -> Option> { let BlockCommentConfig { start: start_tag, @@ -23407,6 +23488,9 @@ fn documentation_delimiter_for_newline( } }; + let mut needs_extra_line = false; + let mut extra_line_additional_indent = IndentSize::spaces(0); + let cursor_is_before_end_tag_if_exists = { let mut char_position = 0u32; let mut end_tag_offset = None; @@ -23424,11 +23508,11 @@ fn documentation_delimiter_for_newline( let cursor_is_before_end_tag = column <= end_tag_offset; if cursor_is_after_start_tag { if cursor_is_before_end_tag { - newline_formatting.insert_extra_newline = true; + needs_extra_line = true; } let cursor_is_at_start_of_end_tag = column == end_tag_offset; if cursor_is_at_start_of_end_tag { - newline_formatting.indent_on_extra_newline.len = *len; + extra_line_additional_indent.len = *len; } } cursor_is_before_end_tag @@ -23440,39 +23524,240 @@ fn documentation_delimiter_for_newline( if (cursor_is_after_start_tag || cursor_is_after_delimiter) && cursor_is_before_end_tag_if_exists { - if cursor_is_after_start_tag { - newline_formatting.indent_on_newline.len = *len; - } + let additional_indent = if cursor_is_after_start_tag { + IndentSize::spaces(*len) + } else { + IndentSize::spaces(0) + }; + + *newline_config = NewlineConfig::Newline { + additional_indent, + extra_line_additional_indent: if needs_extra_line { + Some(extra_line_additional_indent) + } else { + None + }, + prevent_auto_indent: true, + }; Some(delimiter.clone()) } else { None } } -#[derive(Debug, Default)] -struct NewlineFormatting { - insert_extra_newline: bool, - indent_on_newline: IndentSize, - indent_on_extra_newline: IndentSize, +const ORDERED_LIST_MAX_MARKER_LEN: usize = 16; + +fn list_delimiter_for_newline( + start_point: &Point, + buffer: &MultiBufferSnapshot, + language: &LanguageScope, + newline_config: &mut NewlineConfig, +) -> Option> { + let (snapshot, range) = buffer.buffer_line_for_row(MultiBufferRow(start_point.row))?; + + let num_of_whitespaces = snapshot + .chars_for_range(range.clone()) + .take_while(|c| c.is_whitespace()) + .count(); + + let task_list_entries: Vec<_> = language + .task_list() + .into_iter() + .flat_map(|config| { + config + .prefixes + .iter() + .map(|prefix| (prefix.as_ref(), config.continuation.as_ref())) + }) + .collect(); + let unordered_list_entries: Vec<_> = language + .unordered_list() + .iter() + .map(|marker| (marker.as_ref(), marker.as_ref())) + .collect(); + + let all_entries: Vec<_> = task_list_entries + .into_iter() + .chain(unordered_list_entries) + .collect(); + + if let Some(max_prefix_len) = all_entries.iter().map(|(p, _)| p.len()).max() { + let candidate: String = snapshot + .chars_for_range(range.clone()) + .skip(num_of_whitespaces) + .take(max_prefix_len) + .collect(); + + if let Some((prefix, continuation)) = all_entries + .iter() + .filter(|(prefix, _)| candidate.starts_with(*prefix)) + .max_by_key(|(prefix, _)| prefix.len()) + { + let end_of_prefix = num_of_whitespaces + prefix.len(); + let cursor_is_after_prefix = end_of_prefix <= start_point.column as usize; + let has_content_after_marker = snapshot + .chars_for_range(range) + .skip(end_of_prefix) + .any(|c| !c.is_whitespace()); + + if has_content_after_marker && cursor_is_after_prefix { + return Some((*continuation).into()); + } + + if start_point.column as usize == end_of_prefix { + if num_of_whitespaces == 0 { + *newline_config = NewlineConfig::ClearCurrentLine; + } else { + *newline_config = NewlineConfig::UnindentCurrentLine { + continuation: (*continuation).into(), + }; + } + } + + return None; + } + } + + let candidate: String = snapshot + .chars_for_range(range.clone()) + .skip(num_of_whitespaces) + .take(ORDERED_LIST_MAX_MARKER_LEN) + .collect(); + + for ordered_config in language.ordered_list() { + let regex = match Regex::new(&ordered_config.pattern) { + Ok(r) => r, + Err(_) => continue, + }; + + if let Some(captures) = regex.captures(&candidate) { + let full_match = captures.get(0)?; + let marker_len = full_match.len(); + let end_of_prefix = num_of_whitespaces + marker_len; + let cursor_is_after_prefix = end_of_prefix <= start_point.column as usize; + + let has_content_after_marker = snapshot + .chars_for_range(range) + .skip(end_of_prefix) + .any(|c| !c.is_whitespace()); + + if has_content_after_marker && cursor_is_after_prefix { + let number: u32 = captures.get(1)?.as_str().parse().ok()?; + let continuation = ordered_config + .format + .replace("{1}", &(number + 1).to_string()); + return Some(continuation.into()); + } + + if start_point.column as usize == end_of_prefix { + let continuation = ordered_config.format.replace("{1}", "1"); + if num_of_whitespaces == 0 { + *newline_config = NewlineConfig::ClearCurrentLine; + } else { + *newline_config = NewlineConfig::UnindentCurrentLine { + continuation: continuation.into(), + }; + } + } + + return None; + } + } + + None } -impl NewlineFormatting { - fn new( - buffer: &MultiBufferSnapshot, - range: Range, - language: &LanguageScope, - ) -> Self { - Self { - insert_extra_newline: Self::insert_extra_newline_brackets( - buffer, - range.clone(), - language, - ) || Self::insert_extra_newline_tree_sitter(buffer, range), - indent_on_newline: IndentSize::spaces(0), - indent_on_extra_newline: IndentSize::spaces(0), +fn is_list_prefix_row( + row: MultiBufferRow, + buffer: &MultiBufferSnapshot, + language: &LanguageScope, +) -> bool { + let Some((snapshot, range)) = buffer.buffer_line_for_row(row) else { + return false; + }; + + let num_of_whitespaces = snapshot + .chars_for_range(range.clone()) + .take_while(|c| c.is_whitespace()) + .count(); + + let task_list_prefixes: Vec<_> = language + .task_list() + .into_iter() + .flat_map(|config| { + config + .prefixes + .iter() + .map(|p| p.as_ref()) + .collect::>() + }) + .collect(); + let unordered_list_markers: Vec<_> = language + .unordered_list() + .iter() + .map(|marker| marker.as_ref()) + .collect(); + let all_prefixes: Vec<_> = task_list_prefixes + .into_iter() + .chain(unordered_list_markers) + .collect(); + if let Some(max_prefix_len) = all_prefixes.iter().map(|p| p.len()).max() { + let candidate: String = snapshot + .chars_for_range(range.clone()) + .skip(num_of_whitespaces) + .take(max_prefix_len) + .collect(); + if all_prefixes + .iter() + .any(|prefix| candidate.starts_with(*prefix)) + { + return true; } } + let ordered_list_candidate: String = snapshot + .chars_for_range(range) + .skip(num_of_whitespaces) + .take(ORDERED_LIST_MAX_MARKER_LEN) + .collect(); + for ordered_config in language.ordered_list() { + let regex = match Regex::new(&ordered_config.pattern) { + Ok(r) => r, + Err(_) => continue, + }; + if let Some(captures) = regex.captures(&ordered_list_candidate) { + return captures.get(0).is_some(); + } + } + + false +} + +#[derive(Debug)] +enum NewlineConfig { + /// Insert newline with optional additional indent and optional extra blank line + Newline { + additional_indent: IndentSize, + extra_line_additional_indent: Option, + prevent_auto_indent: bool, + }, + /// Clear the current line + ClearCurrentLine, + /// Unindent the current line and add continuation + UnindentCurrentLine { continuation: Arc }, +} + +impl NewlineConfig { + fn has_extra_line(&self) -> bool { + matches!( + self, + Self::Newline { + extra_line_additional_indent: Some(_), + .. + } + ) + } + fn insert_extra_newline_brackets( buffer: &MultiBufferSnapshot, range: Range, diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rs index c0112c5eda406c9cb3b3b9d004d20853b710f6e1..87674d8c507b1c294779b1f9ddba458320fc7671 100644 --- a/crates/editor/src/editor_tests.rs +++ b/crates/editor/src/editor_tests.rs @@ -28021,7 +28021,7 @@ async fn test_markdown_indents(cx: &mut gpui::TestAppContext) { " }); - // Case 2: Test adding new line after nested list preserves indent of previous line + // Case 2: Test adding new line after nested list continues the list with unchecked task cx.set_state(&indoc! {" - [ ] Item 1 - [ ] Item 1.a @@ -28038,32 +28038,12 @@ async fn test_markdown_indents(cx: &mut gpui::TestAppContext) { - [x] Item 2 - [x] Item 2.a - [x] Item 2.b - ˇ" + - [ ] ˇ" }); - // Case 3: Test adding a new nested list item preserves indent - cx.set_state(&indoc! {" - - [ ] Item 1 - - [ ] Item 1.a - - [x] Item 2 - - [x] Item 2.a - - [x] Item 2.b - ˇ" - }); - cx.update_editor(|editor, window, cx| { - editor.handle_input("-", window, cx); - }); - cx.run_until_parked(); - cx.assert_editor_state(indoc! {" - - [ ] Item 1 - - [ ] Item 1.a - - [x] Item 2 - - [x] Item 2.a - - [x] Item 2.b - -ˇ" - }); + // Case 3: Test adding content to continued list item cx.update_editor(|editor, window, cx| { - editor.handle_input(" [x] Item 2.c", window, cx); + editor.handle_input("Item 2.c", window, cx); }); cx.run_until_parked(); cx.assert_editor_state(indoc! {" @@ -28072,10 +28052,10 @@ async fn test_markdown_indents(cx: &mut gpui::TestAppContext) { - [x] Item 2 - [x] Item 2.a - [x] Item 2.b - - [x] Item 2.cˇ" + - [ ] Item 2.cˇ" }); - // Case 4: Test adding new line after nested ordered list preserves indent of previous line + // Case 4: Test adding new line after nested ordered list continues with next number cx.set_state(indoc! {" 1. Item 1 1. Item 1.a @@ -28092,44 +28072,12 @@ async fn test_markdown_indents(cx: &mut gpui::TestAppContext) { 2. Item 2 1. Item 2.a 2. Item 2.b - ˇ" + 3. ˇ" }); - // Case 5: Adding new ordered list item preserves indent - cx.set_state(indoc! {" - 1. Item 1 - 1. Item 1.a - 2. Item 2 - 1. Item 2.a - 2. Item 2.b - ˇ" - }); - cx.update_editor(|editor, window, cx| { - editor.handle_input("3", window, cx); - }); - cx.run_until_parked(); - cx.assert_editor_state(indoc! {" - 1. Item 1 - 1. Item 1.a - 2. Item 2 - 1. Item 2.a - 2. Item 2.b - 3ˇ" - }); - cx.update_editor(|editor, window, cx| { - editor.handle_input(".", window, cx); - }); - cx.run_until_parked(); - cx.assert_editor_state(indoc! {" - 1. Item 1 - 1. Item 1.a - 2. Item 2 - 1. Item 2.a - 2. Item 2.b - 3.ˇ" - }); + // Case 5: Adding content to continued ordered list item cx.update_editor(|editor, window, cx| { - editor.handle_input(" Item 2.c", window, cx); + editor.handle_input("Item 2.c", window, cx); }); cx.run_until_parked(); cx.assert_editor_state(indoc! {" @@ -29497,6 +29445,524 @@ async fn test_find_references_single_case(cx: &mut TestAppContext) { cx.assert_editor_state(after); } +#[gpui::test] +async fn test_newline_task_list_continuation(cx: &mut TestAppContext) { + init_test(cx, |settings| { + settings.defaults.tab_size = Some(2.try_into().unwrap()); + }); + + let markdown_language = languages::language("markdown", tree_sitter_md::LANGUAGE.into()); + let mut cx = EditorTestContext::new(cx).await; + cx.update_buffer(|buffer, cx| buffer.set_language(Some(markdown_language), cx)); + + // Case 1: Adding newline after (whitespace + prefix + any non-whitespace) adds marker + cx.set_state(indoc! {" + - [ ] taskˇ + "}); + cx.update_editor(|e, window, cx| e.newline(&Newline, window, cx)); + cx.wait_for_autoindent_applied().await; + cx.assert_editor_state(indoc! {" + - [ ] task + - [ ] ˇ + "}); + + // Case 2: Works with checked task items too + cx.set_state(indoc! {" + - [x] completed taskˇ + "}); + cx.update_editor(|e, window, cx| e.newline(&Newline, window, cx)); + cx.wait_for_autoindent_applied().await; + cx.assert_editor_state(indoc! {" + - [x] completed task + - [ ] ˇ + "}); + + // Case 3: Cursor position doesn't matter - content after marker is what counts + cx.set_state(indoc! {" + - [ ] taˇsk + "}); + cx.update_editor(|e, window, cx| e.newline(&Newline, window, cx)); + cx.wait_for_autoindent_applied().await; + cx.assert_editor_state(indoc! {" + - [ ] ta + - [ ] ˇsk + "}); + + // Case 4: Adding newline after (whitespace + prefix + some whitespace) does NOT add marker + cx.set_state(indoc! {" + - [ ] ˇ + "}); + cx.update_editor(|e, window, cx| e.newline(&Newline, window, cx)); + cx.wait_for_autoindent_applied().await; + cx.assert_editor_state( + indoc! {" + - [ ]$$ + ˇ + "} + .replace("$", " ") + .as_str(), + ); + + // Case 5: Adding newline with content adds marker preserving indentation + cx.set_state(indoc! {" + - [ ] task + - [ ] indentedˇ + "}); + cx.update_editor(|e, window, cx| e.newline(&Newline, window, cx)); + cx.wait_for_autoindent_applied().await; + cx.assert_editor_state(indoc! {" + - [ ] task + - [ ] indented + - [ ] ˇ + "}); + + // Case 6: Adding newline with cursor right after prefix, unindents + cx.set_state(indoc! {" + - [ ] task + - [ ] sub task + - [ ] ˇ + "}); + cx.update_editor(|e, window, cx| e.newline(&Newline, window, cx)); + cx.wait_for_autoindent_applied().await; + cx.assert_editor_state(indoc! {" + - [ ] task + - [ ] sub task + - [ ] ˇ + "}); + cx.update_editor(|e, window, cx| e.newline(&Newline, window, cx)); + cx.wait_for_autoindent_applied().await; + + // Case 7: Adding newline with cursor right after prefix, removes marker + cx.assert_editor_state(indoc! {" + - [ ] task + - [ ] sub task + - [ ] ˇ + "}); + cx.update_editor(|e, window, cx| e.newline(&Newline, window, cx)); + cx.wait_for_autoindent_applied().await; + cx.assert_editor_state(indoc! {" + - [ ] task + - [ ] sub task + ˇ + "}); + + // Case 8: Cursor before or inside prefix does not add marker + cx.set_state(indoc! {" + ˇ- [ ] task + "}); + cx.update_editor(|e, window, cx| e.newline(&Newline, window, cx)); + cx.wait_for_autoindent_applied().await; + cx.assert_editor_state(indoc! {" + + ˇ- [ ] task + "}); + + cx.set_state(indoc! {" + - [ˇ ] task + "}); + cx.update_editor(|e, window, cx| e.newline(&Newline, window, cx)); + cx.wait_for_autoindent_applied().await; + cx.assert_editor_state(indoc! {" + - [ + ˇ + ] task + "}); +} + +#[gpui::test] +async fn test_newline_unordered_list_continuation(cx: &mut TestAppContext) { + init_test(cx, |settings| { + settings.defaults.tab_size = Some(2.try_into().unwrap()); + }); + + let markdown_language = languages::language("markdown", tree_sitter_md::LANGUAGE.into()); + let mut cx = EditorTestContext::new(cx).await; + cx.update_buffer(|buffer, cx| buffer.set_language(Some(markdown_language), cx)); + + // Case 1: Adding newline after (whitespace + marker + any non-whitespace) adds marker + cx.set_state(indoc! {" + - itemˇ + "}); + cx.update_editor(|e, window, cx| e.newline(&Newline, window, cx)); + cx.wait_for_autoindent_applied().await; + cx.assert_editor_state(indoc! {" + - item + - ˇ + "}); + + // Case 2: Works with different markers + cx.set_state(indoc! {" + * starred itemˇ + "}); + cx.update_editor(|e, window, cx| e.newline(&Newline, window, cx)); + cx.wait_for_autoindent_applied().await; + cx.assert_editor_state(indoc! {" + * starred item + * ˇ + "}); + + cx.set_state(indoc! {" + + plus itemˇ + "}); + cx.update_editor(|e, window, cx| e.newline(&Newline, window, cx)); + cx.wait_for_autoindent_applied().await; + cx.assert_editor_state(indoc! {" + + plus item + + ˇ + "}); + + // Case 3: Cursor position doesn't matter - content after marker is what counts + cx.set_state(indoc! {" + - itˇem + "}); + cx.update_editor(|e, window, cx| e.newline(&Newline, window, cx)); + cx.wait_for_autoindent_applied().await; + cx.assert_editor_state(indoc! {" + - it + - ˇem + "}); + + // Case 4: Adding newline after (whitespace + marker + some whitespace) does NOT add marker + cx.set_state(indoc! {" + - ˇ + "}); + cx.update_editor(|e, window, cx| e.newline(&Newline, window, cx)); + cx.wait_for_autoindent_applied().await; + cx.assert_editor_state( + indoc! {" + - $ + ˇ + "} + .replace("$", " ") + .as_str(), + ); + + // Case 5: Adding newline with content adds marker preserving indentation + cx.set_state(indoc! {" + - item + - indentedˇ + "}); + cx.update_editor(|e, window, cx| e.newline(&Newline, window, cx)); + cx.wait_for_autoindent_applied().await; + cx.assert_editor_state(indoc! {" + - item + - indented + - ˇ + "}); + + // Case 6: Adding newline with cursor right after marker, unindents + cx.set_state(indoc! {" + - item + - sub item + - ˇ + "}); + cx.update_editor(|e, window, cx| e.newline(&Newline, window, cx)); + cx.wait_for_autoindent_applied().await; + cx.assert_editor_state(indoc! {" + - item + - sub item + - ˇ + "}); + cx.update_editor(|e, window, cx| e.newline(&Newline, window, cx)); + cx.wait_for_autoindent_applied().await; + + // Case 7: Adding newline with cursor right after marker, removes marker + cx.assert_editor_state(indoc! {" + - item + - sub item + - ˇ + "}); + cx.update_editor(|e, window, cx| e.newline(&Newline, window, cx)); + cx.wait_for_autoindent_applied().await; + cx.assert_editor_state(indoc! {" + - item + - sub item + ˇ + "}); + + // Case 8: Cursor before or inside prefix does not add marker + cx.set_state(indoc! {" + ˇ- item + "}); + cx.update_editor(|e, window, cx| e.newline(&Newline, window, cx)); + cx.wait_for_autoindent_applied().await; + cx.assert_editor_state(indoc! {" + + ˇ- item + "}); + + cx.set_state(indoc! {" + -ˇ item + "}); + cx.update_editor(|e, window, cx| e.newline(&Newline, window, cx)); + cx.wait_for_autoindent_applied().await; + cx.assert_editor_state(indoc! {" + - + ˇitem + "}); +} + +#[gpui::test] +async fn test_newline_ordered_list_continuation(cx: &mut TestAppContext) { + init_test(cx, |settings| { + settings.defaults.tab_size = Some(2.try_into().unwrap()); + }); + + let markdown_language = languages::language("markdown", tree_sitter_md::LANGUAGE.into()); + let mut cx = EditorTestContext::new(cx).await; + cx.update_buffer(|buffer, cx| buffer.set_language(Some(markdown_language), cx)); + + // Case 1: Adding newline after (whitespace + marker + any non-whitespace) increments number + cx.set_state(indoc! {" + 1. first itemˇ + "}); + cx.update_editor(|e, window, cx| e.newline(&Newline, window, cx)); + cx.wait_for_autoindent_applied().await; + cx.assert_editor_state(indoc! {" + 1. first item + 2. ˇ + "}); + + // Case 2: Works with larger numbers + cx.set_state(indoc! {" + 10. tenth itemˇ + "}); + cx.update_editor(|e, window, cx| e.newline(&Newline, window, cx)); + cx.wait_for_autoindent_applied().await; + cx.assert_editor_state(indoc! {" + 10. tenth item + 11. ˇ + "}); + + // Case 3: Cursor position doesn't matter - content after marker is what counts + cx.set_state(indoc! {" + 1. itˇem + "}); + cx.update_editor(|e, window, cx| e.newline(&Newline, window, cx)); + cx.wait_for_autoindent_applied().await; + cx.assert_editor_state(indoc! {" + 1. it + 2. ˇem + "}); + + // Case 4: Adding newline after (whitespace + marker + some whitespace) does NOT add marker + cx.set_state(indoc! {" + 1. ˇ + "}); + cx.update_editor(|e, window, cx| e.newline(&Newline, window, cx)); + cx.wait_for_autoindent_applied().await; + cx.assert_editor_state( + indoc! {" + 1. $ + ˇ + "} + .replace("$", " ") + .as_str(), + ); + + // Case 5: Adding newline with content adds marker preserving indentation + cx.set_state(indoc! {" + 1. item + 2. indentedˇ + "}); + cx.update_editor(|e, window, cx| e.newline(&Newline, window, cx)); + cx.wait_for_autoindent_applied().await; + cx.assert_editor_state(indoc! {" + 1. item + 2. indented + 3. ˇ + "}); + + // Case 6: Adding newline with cursor right after marker, unindents + cx.set_state(indoc! {" + 1. item + 2. sub item + 3. ˇ + "}); + cx.update_editor(|e, window, cx| e.newline(&Newline, window, cx)); + cx.wait_for_autoindent_applied().await; + cx.assert_editor_state(indoc! {" + 1. item + 2. sub item + 1. ˇ + "}); + cx.update_editor(|e, window, cx| e.newline(&Newline, window, cx)); + cx.wait_for_autoindent_applied().await; + + // Case 7: Adding newline with cursor right after marker, removes marker + cx.assert_editor_state(indoc! {" + 1. item + 2. sub item + 1. ˇ + "}); + cx.update_editor(|e, window, cx| e.newline(&Newline, window, cx)); + cx.wait_for_autoindent_applied().await; + cx.assert_editor_state(indoc! {" + 1. item + 2. sub item + ˇ + "}); + + // Case 8: Cursor before or inside prefix does not add marker + cx.set_state(indoc! {" + ˇ1. item + "}); + cx.update_editor(|e, window, cx| e.newline(&Newline, window, cx)); + cx.wait_for_autoindent_applied().await; + cx.assert_editor_state(indoc! {" + + ˇ1. item + "}); + + cx.set_state(indoc! {" + 1ˇ. item + "}); + cx.update_editor(|e, window, cx| e.newline(&Newline, window, cx)); + cx.wait_for_autoindent_applied().await; + cx.assert_editor_state(indoc! {" + 1 + ˇ. item + "}); +} + +#[gpui::test] +async fn test_newline_should_not_autoindent_ordered_list(cx: &mut TestAppContext) { + init_test(cx, |settings| { + settings.defaults.tab_size = Some(2.try_into().unwrap()); + }); + + let markdown_language = languages::language("markdown", tree_sitter_md::LANGUAGE.into()); + let mut cx = EditorTestContext::new(cx).await; + cx.update_buffer(|buffer, cx| buffer.set_language(Some(markdown_language), cx)); + + // Case 1: Adding newline after (whitespace + marker + any non-whitespace) increments number + cx.set_state(indoc! {" + 1. first item + 1. sub first item + 2. sub second item + 3. ˇ + "}); + cx.update_editor(|e, window, cx| e.newline(&Newline, window, cx)); + cx.wait_for_autoindent_applied().await; + cx.assert_editor_state(indoc! {" + 1. first item + 1. sub first item + 2. sub second item + 1. ˇ + "}); +} + +#[gpui::test] +async fn test_tab_list_indent(cx: &mut TestAppContext) { + init_test(cx, |settings| { + settings.defaults.tab_size = Some(2.try_into().unwrap()); + }); + + let markdown_language = languages::language("markdown", tree_sitter_md::LANGUAGE.into()); + let mut cx = EditorTestContext::new(cx).await; + cx.update_buffer(|buffer, cx| buffer.set_language(Some(markdown_language), cx)); + + // Case 1: Unordered list - cursor after prefix, adds indent before prefix + cx.set_state(indoc! {" + - ˇitem + "}); + cx.update_editor(|e, window, cx| e.tab(&Tab, window, cx)); + cx.wait_for_autoindent_applied().await; + let expected = indoc! {" + $$- ˇitem + "}; + cx.assert_editor_state(expected.replace("$", " ").as_str()); + + // Case 2: Task list - cursor after prefix + cx.set_state(indoc! {" + - [ ] ˇtask + "}); + cx.update_editor(|e, window, cx| e.tab(&Tab, window, cx)); + cx.wait_for_autoindent_applied().await; + let expected = indoc! {" + $$- [ ] ˇtask + "}; + cx.assert_editor_state(expected.replace("$", " ").as_str()); + + // Case 3: Ordered list - cursor after prefix + cx.set_state(indoc! {" + 1. ˇfirst + "}); + cx.update_editor(|e, window, cx| e.tab(&Tab, window, cx)); + cx.wait_for_autoindent_applied().await; + let expected = indoc! {" + $$1. ˇfirst + "}; + cx.assert_editor_state(expected.replace("$", " ").as_str()); + + // Case 4: With existing indentation - adds more indent + let initial = indoc! {" + $$- ˇitem + "}; + cx.set_state(initial.replace("$", " ").as_str()); + cx.update_editor(|e, window, cx| e.tab(&Tab, window, cx)); + cx.wait_for_autoindent_applied().await; + let expected = indoc! {" + $$$$- ˇitem + "}; + cx.assert_editor_state(expected.replace("$", " ").as_str()); + + // Case 5: Empty list item + cx.set_state(indoc! {" + - ˇ + "}); + cx.update_editor(|e, window, cx| e.tab(&Tab, window, cx)); + cx.wait_for_autoindent_applied().await; + let expected = indoc! {" + $$- ˇ + "}; + cx.assert_editor_state(expected.replace("$", " ").as_str()); + + // Case 6: Cursor at end of line with content + cx.set_state(indoc! {" + - itemˇ + "}); + cx.update_editor(|e, window, cx| e.tab(&Tab, window, cx)); + cx.wait_for_autoindent_applied().await; + let expected = indoc! {" + $$- itemˇ + "}; + cx.assert_editor_state(expected.replace("$", " ").as_str()); + + // Case 7: Cursor at start of list item, indents it + cx.set_state(indoc! {" + - item + ˇ - sub item + "}); + cx.update_editor(|e, window, cx| e.tab(&Tab, window, cx)); + cx.wait_for_autoindent_applied().await; + let expected = indoc! {" + - item + ˇ - sub item + "}; + cx.assert_editor_state(expected); + + // Case 8: Cursor at start of list item, moves the cursor when "indent_list_on_tab" is false + cx.update_editor(|_, _, cx| { + SettingsStore::update_global(cx, |store, cx| { + store.update_user_settings(cx, |settings| { + settings.project.all_languages.defaults.indent_list_on_tab = Some(false); + }); + }); + }); + cx.set_state(indoc! {" + - item + ˇ - sub item + "}); + cx.update_editor(|e, window, cx| e.tab(&Tab, window, cx)); + cx.wait_for_autoindent_applied().await; + let expected = indoc! {" + - item + ˇ- sub item + "}; + cx.assert_editor_state(expected); +} + #[gpui::test] async fn test_local_worktree_trust(cx: &mut TestAppContext) { init_test(cx, |_| {}); diff --git a/crates/language/src/language.rs b/crates/language/src/language.rs index a573e3d78a4de03c6ccf382c80bc33eaf0b5690d..290cad4e4497015ef63f79e58a0dacf231168c9f 100644 --- a/crates/language/src/language.rs +++ b/crates/language/src/language.rs @@ -827,6 +827,15 @@ pub struct LanguageConfig { /// Delimiters and configuration for recognizing and formatting documentation comments. #[serde(default, alias = "documentation")] pub documentation_comment: Option, + /// List markers that are inserted unchanged on newline (e.g., `- `, `* `, `+ `). + #[serde(default)] + pub unordered_list: Vec>, + /// Configuration for ordered lists with auto-incrementing numbers on newline (e.g., `1. ` becomes `2. `). + #[serde(default)] + pub ordered_list: Vec, + /// Configuration for task lists where multiple markers map to a single continuation prefix (e.g., `- [x] ` continues as `- [ ] `). + #[serde(default)] + pub task_list: Option, /// A list of additional regex patterns that should be treated as prefixes /// for creating boundaries during rewrapping, ensuring content from one /// prefixed section doesn't merge with another (e.g., markdown list items). @@ -898,6 +907,24 @@ pub struct DecreaseIndentConfig { pub valid_after: Vec, } +/// Configuration for continuing ordered lists with auto-incrementing numbers. +#[derive(Clone, Debug, Deserialize, JsonSchema)] +pub struct OrderedListConfig { + /// A regex pattern with a capture group for the number portion (e.g., `(\\d+)\\. `). + pub pattern: String, + /// A format string where `{1}` is replaced with the incremented number (e.g., `{1}. `). + pub format: String, +} + +/// Configuration for continuing task lists on newline. +#[derive(Clone, Debug, Deserialize, JsonSchema)] +pub struct TaskListConfig { + /// The list markers to match (e.g., `- [ ] `, `- [x] `). + pub prefixes: Vec>, + /// The marker to insert when continuing the list on a new line (e.g., `- [ ] `). + pub continuation: Arc, +} + #[derive(Clone, Debug, Serialize, Deserialize, Default, JsonSchema)] pub struct LanguageMatcher { /// Given a list of `LanguageConfig`'s, the language of a file can be determined based on the path extension matching any of the `path_suffixes`. @@ -1068,6 +1095,9 @@ impl Default for LanguageConfig { line_comments: Default::default(), block_comment: Default::default(), documentation_comment: Default::default(), + unordered_list: Default::default(), + ordered_list: Default::default(), + task_list: Default::default(), rewrap_prefixes: Default::default(), scope_opt_in_language_servers: Default::default(), overrides: Default::default(), @@ -2153,6 +2183,21 @@ impl LanguageScope { self.language.config.documentation_comment.as_ref() } + /// Returns list markers that are inserted unchanged on newline (e.g., `- `, `* `, `+ `). + pub fn unordered_list(&self) -> &[Arc] { + &self.language.config.unordered_list + } + + /// Returns configuration for ordered lists with auto-incrementing numbers (e.g., `1. ` becomes `2. `). + pub fn ordered_list(&self) -> &[OrderedListConfig] { + &self.language.config.ordered_list + } + + /// Returns configuration for task list continuation, if any (e.g., `- [x] ` continues as `- [ ] `). + pub fn task_list(&self) -> Option<&TaskListConfig> { + self.language.config.task_list.as_ref() + } + /// Returns additional regex patterns that act as prefix markers for creating /// boundaries during rewrapping. /// diff --git a/crates/language/src/language_settings.rs b/crates/language/src/language_settings.rs index fccaa545b79c1f24589889df8fcd163fbc5b6c7d..205f2431c6d9deeaa7661b583caa516bdc77ae79 100644 --- a/crates/language/src/language_settings.rs +++ b/crates/language/src/language_settings.rs @@ -122,6 +122,10 @@ pub struct LanguageSettings { pub whitespace_map: WhitespaceMap, /// Whether to start a new line with a comment when a previous line is a comment as well. pub extend_comment_on_newline: bool, + /// Whether to continue markdown lists when pressing enter. + pub extend_list_on_newline: bool, + /// Whether to indent list items when pressing tab after a list marker. + pub indent_list_on_tab: bool, /// Inlay hint related settings. pub inlay_hints: InlayHintSettings, /// Whether to automatically close brackets. @@ -567,6 +571,8 @@ impl settings::Settings for AllLanguageSettings { tab: SharedString::new(whitespace_map.tab.unwrap().to_string()), }, extend_comment_on_newline: settings.extend_comment_on_newline.unwrap(), + extend_list_on_newline: settings.extend_list_on_newline.unwrap(), + indent_list_on_tab: settings.indent_list_on_tab.unwrap(), inlay_hints: InlayHintSettings { enabled: inlay_hints.enabled.unwrap(), show_value_hints: inlay_hints.show_value_hints.unwrap(), diff --git a/crates/languages/src/markdown/config.toml b/crates/languages/src/markdown/config.toml index 84c79d2538a0af470ec16d55fe9cf2d1ae05805b..423a4c008f6e8a64f3c4e883b0d6e2bde65c88ae 100644 --- a/crates/languages/src/markdown/config.toml +++ b/crates/languages/src/markdown/config.toml @@ -20,6 +20,9 @@ rewrap_prefixes = [ ">\\s*", "[-*+]\\s+\\[[\\sx]\\]\\s+" ] +unordered_list = ["- ", "* ", "+ "] +ordered_list = [{ pattern = "(\\d+)\\. ", format = "{1}. " }] +task_list = { prefixes = ["- [ ] ", "- [x] "], continuation = "- [ ] " } auto_indent_on_paste = false auto_indent_using_last_non_empty_line = false diff --git a/crates/settings/src/settings_content/language.rs b/crates/settings/src/settings_content/language.rs index f9c85f18f380a7ad82b0d8bc202fe3763ba3a832..cf8cf7b63589e84a96e6b9d92f23a4488479d1f3 100644 --- a/crates/settings/src/settings_content/language.rs +++ b/crates/settings/src/settings_content/language.rs @@ -363,6 +363,14 @@ pub struct LanguageSettingsContent { /// /// Default: true pub extend_comment_on_newline: Option, + /// Whether to continue markdown lists when pressing enter. + /// + /// Default: true + pub extend_list_on_newline: Option, + /// Whether to indent list items when pressing tab after a list marker. + /// + /// Default: true + pub indent_list_on_tab: Option, /// Inlay hint related settings. pub inlay_hints: Option, /// Whether to automatically type closing characters for you. For example, diff --git a/crates/settings/src/vscode_import.rs b/crates/settings/src/vscode_import.rs index d77754f611e8eb1746ee9061ce5b5e1dfdbdafdb..64343b05fd57c33eb9cfb0d8cb8674971266b464 100644 --- a/crates/settings/src/vscode_import.rs +++ b/crates/settings/src/vscode_import.rs @@ -430,6 +430,8 @@ impl VsCodeSettings { enable_language_server: None, ensure_final_newline_on_save: self.read_bool("files.insertFinalNewline"), extend_comment_on_newline: None, + extend_list_on_newline: None, + indent_list_on_tab: None, format_on_save: self.read_bool("editor.guides.formatOnSave").map(|b| { if b { FormatOnSave::On diff --git a/docs/src/configuring-zed.md b/docs/src/configuring-zed.md index 8a638d9f7857e1a55aaa5589a77110a7b803bbfe..81318aa8885fe883acc394e7fe983d7721dd33a5 100644 --- a/docs/src/configuring-zed.md +++ b/docs/src/configuring-zed.md @@ -1585,6 +1585,26 @@ Positive `integer` value between 1 and 32. Values outside of this range will be `boolean` values +## Extend List On Newline + +- Description: Whether to continue lists when pressing Enter at the end of a list item. Supports unordered, ordered, and task lists. Pressing Enter on an empty list item removes the marker and exits the list. +- Setting: `extend_list_on_newline` +- Default: `true` + +**Options** + +`boolean` values + +## Indent List On Tab + +- Description: Whether to indent list items when pressing Tab on a line containing only a list marker. This enables quick creation of nested lists. +- Setting: `indent_list_on_tab` +- Default: `true` + +**Options** + +`boolean` values + ## Status Bar - Description: Control various elements in the status bar. Note that some items in the status bar have their own settings set elsewhere. diff --git a/docs/src/languages/markdown.md b/docs/src/languages/markdown.md index 36ce734f7cfbcc066bb8026568209738655a6be9..64c9e7070569a23daa5bcb8aa4dace12e0021b03 100644 --- a/docs/src/languages/markdown.md +++ b/docs/src/languages/markdown.md @@ -33,6 +33,40 @@ Zed supports using Prettier to automatically re-format Markdown documents. You c }, ``` +### List Continuation + +Zed automatically continues lists when you press Enter at the end of a list item. Supported list types: + +- Unordered lists (`-`, `*`, or `+` markers) +- Ordered lists (numbers are auto-incremented) +- Task lists (`- [ ]` and `- [x]`) + +Pressing Enter on an empty list item removes the marker and exits the list. + +To disable this behavior: + +```json [settings] + "languages": { + "Markdown": { + "extend_list_on_newline": false + } + }, +``` + +### List Indentation + +Zed indents list items when you press Tab while the cursor is on a line containing only a list marker. This allows you to quickly create nested lists. + +To disable this behavior: + +```json [settings] + "languages": { + "Markdown": { + "indent_list_on_tab": false + } + }, +``` + ### Trailing Whitespace By default Zed will remove trailing whitespace on save. If you rely on invisible trailing whitespace being converted to `
` in Markdown files you can disable this behavior with: From 32600f255aea17ffc4557b39f2fc8c275db3b59a Mon Sep 17 00:00:00 2001 From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Date: Fri, 19 Dec 2025 13:14:31 -0300 Subject: [PATCH 554/621] gpui: Fix truncation flickering (#45373) It's been a little that we've noticed some flickering and other weird resizing behavior with text truncation in Zed: https://github.com/user-attachments/assets/4d5691a3-cd3d-45e0-8b96-74a4e0e273d2 https://github.com/user-attachments/assets/d1d0e587-7676-4da0-8818-f4e50f0e294e Initially, we suspected this could be due to how we calculate the length of a line to insert truncation, which is based first on the length of each individual character, and then second goes through a pass calculating the line length as a whole. This could cause mismatch and culminate in our bug. However, even though that felt like a reasonable suspicion, I realized something rather simple at some point: the `truncate` and `truncate_start` methods in the `Label` didn't use `whitespace_nowrap`. If you take Tailwind as an example, their `truncate` utility class takes `overflow: hidden; text-overflow: ellipsis; white-space: nowrap;`. This pointed out to a potential bug with `whitespace_nowrap` where that was blocking truncation entirely, even though that's technically part of what's necessary to truncate as you don't want text that will be truncated to wrap. Ultimately, what was happening was that the text element was caching its layout based on its `wrap_width` but not considering its `truncate_width`. The truncate width is essentially the new definitive width of the text based on the available space, which was never being computed. So the fix here was to add `truncate_width.is_none()` to the cache validation check, so that it only uses the cached text element size _if the truncation width is untouched_. But if that changes, we need to account for the new width. Then, in the Label component, we added `min_w_0` to allow the label div to shrink below its original size, and finally, we added `whitespace_nowrap()` as the cache check fundamentally fixed that method's problem. In a future PR, we can basically remove the `single_line()` label method because: 1) whenever you want a single label, you most likely want it to truncate, and 2) most instances of `truncate` are already followed by `single_line` in Zed today, so we can cut that part. Result is no flickering with truncated labels! https://github.com/user-attachments/assets/ae17cbde-0de7-42ca-98a4-22fcb452016b Release Notes: - Fixed a bug in GPUI where truncated text would flicker as you resized the container in which the text was in. Co-authored-by: Lukas Wirth --- crates/gpui/src/elements/text.rs | 10 ++++++++-- crates/ui/src/components/label/label_like.rs | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/crates/gpui/src/elements/text.rs b/crates/gpui/src/elements/text.rs index 942a0a326526431dc65f389e9cff67bac252d571..770c1f871432afbecc9ffd4e903dfeddcfcba6ee 100644 --- a/crates/gpui/src/elements/text.rs +++ b/crates/gpui/src/elements/text.rs @@ -372,11 +372,17 @@ impl TextLayout { (None, "".into(), TruncateFrom::End) }; + // Only use cached layout if: + // 1. We have a cached size + // 2. wrap_width matches (or both are None) + // 3. truncate_width is None (if truncate_width is Some, we need to re-layout + // because the previous layout may have been computed without truncation) if let Some(text_layout) = element_state.0.borrow().as_ref() - && text_layout.size.is_some() + && let Some(size) = text_layout.size && (wrap_width.is_none() || wrap_width == text_layout.wrap_width) + && truncate_width.is_none() { - return text_layout.size.unwrap(); + return size; } let mut line_wrapper = cx.text_system().line_wrapper(text_style.font(), font_size); diff --git a/crates/ui/src/components/label/label_like.rs b/crates/ui/src/components/label/label_like.rs index f6e7a1b893d54fff425618d5c604f591144a7385..03fde4083d5e9a8e07f38c830edd5116f14e6d70 100644 --- a/crates/ui/src/components/label/label_like.rs +++ b/crates/ui/src/components/label/label_like.rs @@ -241,10 +241,16 @@ impl RenderOnce for LabelLike { .when(self.strikethrough, |this| this.line_through()) .when(self.single_line, |this| this.whitespace_nowrap()) .when(self.truncate, |this| { - this.overflow_x_hidden().text_ellipsis() + this.min_w_0() + .overflow_x_hidden() + .whitespace_nowrap() + .text_ellipsis() }) .when(self.truncate_start, |this| { - this.overflow_x_hidden().text_ellipsis_start() + this.min_w_0() + .overflow_x_hidden() + .whitespace_nowrap() + .text_ellipsis_start() }) .text_color(color) .font_weight( From e05dcecac40566c0a49b9754934d9030e4e7ad76 Mon Sep 17 00:00:00 2001 From: Ben Kunkle Date: Fri, 19 Dec 2025 10:21:56 -0600 Subject: [PATCH 555/621] Make `pane::CloseAllItems` best effort (#45368) Closes #ISSUE Release Notes: - Fixed an issue where the `pane: close all items` action would give up if you hit "Cancel" on the prompt for what to do with a dirty buffer --- crates/workspace/src/pane.rs | 81 ++++++++++++++++++++++++++----- crates/workspace/src/workspace.rs | 26 ++++++---- 2 files changed, 85 insertions(+), 22 deletions(-) diff --git a/crates/workspace/src/pane.rs b/crates/workspace/src/pane.rs index f6256aee46b9e2b5c29c020e9ee12f6ff510210f..dd17c338a935571f4d0fe9d46b3b10fac9ffe218 100644 --- a/crates/workspace/src/pane.rs +++ b/crates/workspace/src/pane.rs @@ -1846,6 +1846,7 @@ impl Pane { } for item_to_close in items_to_close { + let mut should_close = true; let mut should_save = true; if save_intent == SaveIntent::Close { workspace.update(cx, |workspace, cx| { @@ -1861,7 +1862,7 @@ impl Pane { { Ok(success) => { if !success { - break; + should_close = false; } } Err(err) => { @@ -1880,23 +1881,25 @@ impl Pane { })?; match answer.await { Ok(0) => {} - Ok(1..) | Err(_) => break, + Ok(1..) | Err(_) => should_close = false, } } } } // Remove the item from the pane. - pane.update_in(cx, |pane, window, cx| { - pane.remove_item( - item_to_close.item_id(), - false, - pane.close_pane_if_empty, - window, - cx, - ); - }) - .ok(); + if should_close { + pane.update_in(cx, |pane, window, cx| { + pane.remove_item( + item_to_close.item_id(), + false, + pane.close_pane_if_empty, + window, + cx, + ); + }) + .ok(); + } } pane.update(cx, |_, cx| cx.notify()).ok(); @@ -6614,6 +6617,60 @@ mod tests { cx.simulate_prompt_answer("Discard all"); save.await.unwrap(); assert_item_labels(&pane, [], cx); + + add_labeled_item(&pane, "A", true, cx).update(cx, |item, cx| { + item.project_items + .push(TestProjectItem::new_dirty(1, "A.txt", cx)) + }); + add_labeled_item(&pane, "B", true, cx).update(cx, |item, cx| { + item.project_items + .push(TestProjectItem::new_dirty(2, "B.txt", cx)) + }); + add_labeled_item(&pane, "C", true, cx).update(cx, |item, cx| { + item.project_items + .push(TestProjectItem::new_dirty(3, "C.txt", cx)) + }); + assert_item_labels(&pane, ["A^", "B^", "C*^"], cx); + + let close_task = pane.update_in(cx, |pane, window, cx| { + pane.close_all_items( + &CloseAllItems { + save_intent: None, + close_pinned: false, + }, + window, + cx, + ) + }); + + cx.executor().run_until_parked(); + cx.simulate_prompt_answer("Discard all"); + close_task.await.unwrap(); + assert_item_labels(&pane, [], cx); + + add_labeled_item(&pane, "Clean1", false, cx); + add_labeled_item(&pane, "Dirty", true, cx).update(cx, |item, cx| { + item.project_items + .push(TestProjectItem::new_dirty(1, "Dirty.txt", cx)) + }); + add_labeled_item(&pane, "Clean2", false, cx); + assert_item_labels(&pane, ["Clean1", "Dirty^", "Clean2*"], cx); + + let close_task = pane.update_in(cx, |pane, window, cx| { + pane.close_all_items( + &CloseAllItems { + save_intent: None, + close_pinned: false, + }, + window, + cx, + ) + }); + + cx.executor().run_until_parked(); + cx.simulate_prompt_answer("Cancel"); + close_task.await.unwrap(); + assert_item_labels(&pane, ["Dirty*^"], cx); } #[gpui::test] diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index c88386281e73b243dbddd6cb00c80fb26595409e..fa8e3a3dc2af33054907ea8a8c1ba095a3259207 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -9424,7 +9424,7 @@ mod tests { let right_pane = right_pane.await.unwrap(); cx.focus(&right_pane); - let mut close = right_pane.update_in(cx, |pane, window, cx| { + let close = right_pane.update_in(cx, |pane, window, cx| { pane.close_all_items(&CloseAllItems::default(), window, cx) .unwrap() }); @@ -9436,9 +9436,16 @@ mod tests { assert!(!msg.contains("3.txt")); assert!(!msg.contains("4.txt")); + // With best-effort close, cancelling item 1 keeps it open but items 4 + // and (3,4) still close since their entries exist in left pane. cx.simulate_prompt_answer("Cancel"); close.await; + right_pane.read_with(cx, |pane, _| { + assert_eq!(pane.items_len(), 1); + }); + + // Remove item 3 from left pane, making (2,3) the only item with entry 3. left_pane .update_in(cx, |left_pane, window, cx| { left_pane.close_item_by_id( @@ -9451,26 +9458,25 @@ mod tests { .await .unwrap(); - close = right_pane.update_in(cx, |pane, window, cx| { + let close = left_pane.update_in(cx, |pane, window, cx| { pane.close_all_items(&CloseAllItems::default(), window, cx) .unwrap() }); cx.executor().run_until_parked(); let details = cx.pending_prompt().unwrap().1; - assert!(details.contains("1.txt")); - assert!(!details.contains("2.txt")); + assert!(details.contains("0.txt")); assert!(details.contains("3.txt")); - // ideally this assertion could be made, but today we can only - // save whole items not project items, so the orphaned item 3 causes - // 4 to be saved too. - // assert!(!details.contains("4.txt")); + assert!(details.contains("4.txt")); + // Ideally 2.txt wouldn't appear since entry 2 still exists in item 2. + // But we can only save whole items, so saving (2,3) for entry 3 includes 2. + // assert!(!details.contains("2.txt")); cx.simulate_prompt_answer("Save all"); - cx.executor().run_until_parked(); close.await; - right_pane.read_with(cx, |pane, _| { + + left_pane.read_with(cx, |pane, _| { assert_eq!(pane.items_len(), 0); }); } From d7e41f74fb3e0279b24f190c19b4ccd3680d01b5 Mon Sep 17 00:00:00 2001 From: Agus Zubiaga Date: Fri, 19 Dec 2025 13:31:27 -0300 Subject: [PATCH 556/621] search: Respect macOS' find pasteboard (#45311) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #17467 Release Notes: - On macOS, buffer search now syncs with the system find pasteboard, allowing ⌘E and ⌘G to work seamlessly across Zed and other apps. --- crates/gpui/src/app.rs | 36 +- crates/gpui/src/platform.rs | 12 +- crates/gpui/src/platform/mac.rs | 3 +- .../src/platform/mac/attributed_string.rs | 129 ------ crates/gpui/src/platform/mac/pasteboard.rs | 344 +++++++++++++++ crates/gpui/src/platform/mac/platform.rs | 397 ++---------------- crates/gpui/src/platform/test/platform.rs | 24 +- crates/search/src/buffer_search.rs | 89 +++- 8 files changed, 499 insertions(+), 535 deletions(-) delete mode 100644 crates/gpui/src/platform/mac/attributed_string.rs create mode 100644 crates/gpui/src/platform/mac/pasteboard.rs diff --git a/crates/gpui/src/app.rs b/crates/gpui/src/app.rs index 75600a9ee1b440a092a89456cbe8fbabe6fdccfa..96f815ac0b592600f22b3c9b9686571487ff77a2 100644 --- a/crates/gpui/src/app.rs +++ b/crates/gpui/src/app.rs @@ -1077,11 +1077,9 @@ impl App { self.platform.window_appearance() } - /// Writes data to the primary selection buffer. - /// Only available on Linux. - #[cfg(any(target_os = "linux", target_os = "freebsd"))] - pub fn write_to_primary(&self, item: ClipboardItem) { - self.platform.write_to_primary(item) + /// Reads data from the platform clipboard. + pub fn read_from_clipboard(&self) -> Option { + self.platform.read_from_clipboard() } /// Writes data to the platform clipboard. @@ -1096,9 +1094,31 @@ impl App { self.platform.read_from_primary() } - /// Reads data from the platform clipboard. - pub fn read_from_clipboard(&self) -> Option { - self.platform.read_from_clipboard() + /// Writes data to the primary selection buffer. + /// Only available on Linux. + #[cfg(any(target_os = "linux", target_os = "freebsd"))] + pub fn write_to_primary(&self, item: ClipboardItem) { + self.platform.write_to_primary(item) + } + + /// Reads data from macOS's "Find" pasteboard. + /// + /// Used to share the current search string between apps. + /// + /// https://developer.apple.com/documentation/appkit/nspasteboard/name-swift.struct/find + #[cfg(target_os = "macos")] + pub fn read_from_find_pasteboard(&self) -> Option { + self.platform.read_from_find_pasteboard() + } + + /// Writes data to macOS's "Find" pasteboard. + /// + /// Used to share the current search string between apps. + /// + /// https://developer.apple.com/documentation/appkit/nspasteboard/name-swift.struct/find + #[cfg(target_os = "macos")] + pub fn write_to_find_pasteboard(&self, item: ClipboardItem) { + self.platform.write_to_find_pasteboard(item) } /// Writes credentials to the platform keychain. diff --git a/crates/gpui/src/platform.rs b/crates/gpui/src/platform.rs index 22f4c46921132a7b8badfb7afd4fd38058c638b4..112775890ef6e478f0b2d347bc9c9ae56dac3c73 100644 --- a/crates/gpui/src/platform.rs +++ b/crates/gpui/src/platform.rs @@ -262,12 +262,18 @@ pub(crate) trait Platform: 'static { fn set_cursor_style(&self, style: CursorStyle); fn should_auto_hide_scrollbars(&self) -> bool; - #[cfg(any(target_os = "linux", target_os = "freebsd"))] - fn write_to_primary(&self, item: ClipboardItem); + fn read_from_clipboard(&self) -> Option; fn write_to_clipboard(&self, item: ClipboardItem); + #[cfg(any(target_os = "linux", target_os = "freebsd"))] fn read_from_primary(&self) -> Option; - fn read_from_clipboard(&self) -> Option; + #[cfg(any(target_os = "linux", target_os = "freebsd"))] + fn write_to_primary(&self, item: ClipboardItem); + + #[cfg(target_os = "macos")] + fn read_from_find_pasteboard(&self) -> Option; + #[cfg(target_os = "macos")] + fn write_to_find_pasteboard(&self, item: ClipboardItem); fn write_credentials(&self, url: &str, username: &str, password: &[u8]) -> Task>; fn read_credentials(&self, url: &str) -> Task)>>>; diff --git a/crates/gpui/src/platform/mac.rs b/crates/gpui/src/platform/mac.rs index aa056846e6bc56e53d95c41a44444dbb89a16237..a229ec7dce928597ec73b1f4be50edd1ea3e5114 100644 --- a/crates/gpui/src/platform/mac.rs +++ b/crates/gpui/src/platform/mac.rs @@ -5,6 +5,7 @@ mod display; mod display_link; mod events; mod keyboard; +mod pasteboard; #[cfg(feature = "screen-capture")] mod screen_capture; @@ -21,8 +22,6 @@ use metal_renderer as renderer; #[cfg(feature = "macos-blade")] use crate::platform::blade as renderer; -mod attributed_string; - #[cfg(feature = "font-kit")] mod open_type; diff --git a/crates/gpui/src/platform/mac/attributed_string.rs b/crates/gpui/src/platform/mac/attributed_string.rs deleted file mode 100644 index 42fe1e5bf7a396a4eaa8ade26977a207d43b49b5..0000000000000000000000000000000000000000 --- a/crates/gpui/src/platform/mac/attributed_string.rs +++ /dev/null @@ -1,129 +0,0 @@ -use cocoa::base::id; -use cocoa::foundation::NSRange; -use objc::{class, msg_send, sel, sel_impl}; - -/// The `cocoa` crate does not define NSAttributedString (and related Cocoa classes), -/// which are needed for copying rich text (that is, text intermingled with images) -/// to the clipboard. This adds access to those APIs. -#[allow(non_snake_case)] -pub trait NSAttributedString: Sized { - unsafe fn alloc(_: Self) -> id { - msg_send![class!(NSAttributedString), alloc] - } - - unsafe fn init_attributed_string(self, string: id) -> id; - unsafe fn appendAttributedString_(self, attr_string: id); - unsafe fn RTFDFromRange_documentAttributes_(self, range: NSRange, attrs: id) -> id; - unsafe fn RTFFromRange_documentAttributes_(self, range: NSRange, attrs: id) -> id; - unsafe fn string(self) -> id; -} - -impl NSAttributedString for id { - unsafe fn init_attributed_string(self, string: id) -> id { - msg_send![self, initWithString: string] - } - - unsafe fn appendAttributedString_(self, attr_string: id) { - let _: () = msg_send![self, appendAttributedString: attr_string]; - } - - unsafe fn RTFDFromRange_documentAttributes_(self, range: NSRange, attrs: id) -> id { - msg_send![self, RTFDFromRange: range documentAttributes: attrs] - } - - unsafe fn RTFFromRange_documentAttributes_(self, range: NSRange, attrs: id) -> id { - msg_send![self, RTFFromRange: range documentAttributes: attrs] - } - - unsafe fn string(self) -> id { - msg_send![self, string] - } -} - -pub trait NSMutableAttributedString: NSAttributedString { - unsafe fn alloc(_: Self) -> id { - msg_send![class!(NSMutableAttributedString), alloc] - } -} - -impl NSMutableAttributedString for id {} - -#[cfg(test)] -mod tests { - use crate::platform::mac::ns_string; - - use super::*; - use cocoa::appkit::NSImage; - use cocoa::base::nil; - use cocoa::foundation::NSAutoreleasePool; - #[test] - #[ignore] // This was SIGSEGV-ing on CI but not locally; need to investigate https://github.com/zed-industries/zed/actions/runs/10362363230/job/28684225486?pr=15782#step:4:1348 - fn test_nsattributed_string() { - // TODO move these to parent module once it's actually ready to be used - #[allow(non_snake_case)] - pub trait NSTextAttachment: Sized { - unsafe fn alloc(_: Self) -> id { - msg_send![class!(NSTextAttachment), alloc] - } - } - - impl NSTextAttachment for id {} - - unsafe { - let image: id = { - let img: id = msg_send![class!(NSImage), alloc]; - let img: id = msg_send![img, initWithContentsOfFile: ns_string("test.jpeg")]; - let img: id = msg_send![img, autorelease]; - img - }; - let _size = image.size(); - - let string = ns_string("Test String"); - let attr_string = NSMutableAttributedString::alloc(nil) - .init_attributed_string(string) - .autorelease(); - let hello_string = ns_string("Hello World"); - let hello_attr_string = NSAttributedString::alloc(nil) - .init_attributed_string(hello_string) - .autorelease(); - attr_string.appendAttributedString_(hello_attr_string); - - let attachment: id = msg_send![NSTextAttachment::alloc(nil), autorelease]; - let _: () = msg_send![attachment, setImage: image]; - let image_attr_string = - msg_send![class!(NSAttributedString), attributedStringWithAttachment: attachment]; - attr_string.appendAttributedString_(image_attr_string); - - let another_string = ns_string("Another String"); - let another_attr_string = NSAttributedString::alloc(nil) - .init_attributed_string(another_string) - .autorelease(); - attr_string.appendAttributedString_(another_attr_string); - - let _len: cocoa::foundation::NSUInteger = msg_send![attr_string, length]; - - /////////////////////////////////////////////////// - // pasteboard.clearContents(); - - let rtfd_data = attr_string.RTFDFromRange_documentAttributes_( - NSRange::new(0, msg_send![attr_string, length]), - nil, - ); - assert_ne!(rtfd_data, nil); - // if rtfd_data != nil { - // pasteboard.setData_forType(rtfd_data, NSPasteboardTypeRTFD); - // } - - // let rtf_data = attributed_string.RTFFromRange_documentAttributes_( - // NSRange::new(0, attributed_string.length()), - // nil, - // ); - // if rtf_data != nil { - // pasteboard.setData_forType(rtf_data, NSPasteboardTypeRTF); - // } - - // let plain_text = attributed_string.string(); - // pasteboard.setString_forType(plain_text, NSPasteboardTypeString); - } - } -} diff --git a/crates/gpui/src/platform/mac/pasteboard.rs b/crates/gpui/src/platform/mac/pasteboard.rs new file mode 100644 index 0000000000000000000000000000000000000000..38710951f15b25515d906afc738c5b971b1bb135 --- /dev/null +++ b/crates/gpui/src/platform/mac/pasteboard.rs @@ -0,0 +1,344 @@ +use core::slice; +use std::ffi::c_void; + +use cocoa::{ + appkit::{NSPasteboard, NSPasteboardTypePNG, NSPasteboardTypeString, NSPasteboardTypeTIFF}, + base::{id, nil}, + foundation::NSData, +}; +use objc::{msg_send, runtime::Object, sel, sel_impl}; +use strum::IntoEnumIterator as _; + +use crate::{ + ClipboardEntry, ClipboardItem, ClipboardString, Image, ImageFormat, asset_cache::hash, + platform::mac::ns_string, +}; + +pub struct Pasteboard { + inner: id, + text_hash_type: id, + metadata_type: id, +} + +impl Pasteboard { + pub fn general() -> Self { + unsafe { Self::new(NSPasteboard::generalPasteboard(nil)) } + } + + pub fn find() -> Self { + unsafe { Self::new(NSPasteboard::pasteboardWithName(nil, NSPasteboardNameFind)) } + } + + #[cfg(test)] + pub fn unique() -> Self { + unsafe { Self::new(NSPasteboard::pasteboardWithUniqueName(nil)) } + } + + unsafe fn new(inner: id) -> Self { + Self { + inner, + text_hash_type: unsafe { ns_string("zed-text-hash") }, + metadata_type: unsafe { ns_string("zed-metadata") }, + } + } + + pub fn read(&self) -> Option { + // First, see if it's a string. + unsafe { + let pasteboard_types: id = self.inner.types(); + let string_type: id = ns_string("public.utf8-plain-text"); + + if msg_send![pasteboard_types, containsObject: string_type] { + let data = self.inner.dataForType(string_type); + if data == nil { + return None; + } else if data.bytes().is_null() { + // https://developer.apple.com/documentation/foundation/nsdata/1410616-bytes?language=objc + // "If the length of the NSData object is 0, this property returns nil." + return Some(self.read_string(&[])); + } else { + let bytes = + slice::from_raw_parts(data.bytes() as *mut u8, data.length() as usize); + + return Some(self.read_string(bytes)); + } + } + + // If it wasn't a string, try the various supported image types. + for format in ImageFormat::iter() { + if let Some(item) = self.read_image(format) { + return Some(item); + } + } + } + + // If it wasn't a string or a supported image type, give up. + None + } + + fn read_image(&self, format: ImageFormat) -> Option { + let mut ut_type: UTType = format.into(); + + unsafe { + let types: id = self.inner.types(); + if msg_send![types, containsObject: ut_type.inner()] { + self.data_for_type(ut_type.inner_mut()).map(|bytes| { + let bytes = bytes.to_vec(); + let id = hash(&bytes); + + ClipboardItem { + entries: vec![ClipboardEntry::Image(Image { format, bytes, id })], + } + }) + } else { + None + } + } + } + + fn read_string(&self, text_bytes: &[u8]) -> ClipboardItem { + unsafe { + let text = String::from_utf8_lossy(text_bytes).to_string(); + let metadata = self + .data_for_type(self.text_hash_type) + .and_then(|hash_bytes| { + let hash_bytes = hash_bytes.try_into().ok()?; + let hash = u64::from_be_bytes(hash_bytes); + let metadata = self.data_for_type(self.metadata_type)?; + + if hash == ClipboardString::text_hash(&text) { + String::from_utf8(metadata.to_vec()).ok() + } else { + None + } + }); + + ClipboardItem { + entries: vec![ClipboardEntry::String(ClipboardString { text, metadata })], + } + } + } + + unsafe fn data_for_type(&self, kind: id) -> Option<&[u8]> { + unsafe { + let data = self.inner.dataForType(kind); + if data == nil { + None + } else { + Some(slice::from_raw_parts( + data.bytes() as *mut u8, + data.length() as usize, + )) + } + } + } + + pub fn write(&self, item: ClipboardItem) { + unsafe { + match item.entries.as_slice() { + [] => { + // Writing an empty list of entries just clears the clipboard. + self.inner.clearContents(); + } + [ClipboardEntry::String(string)] => { + self.write_plaintext(string); + } + [ClipboardEntry::Image(image)] => { + self.write_image(image); + } + [ClipboardEntry::ExternalPaths(_)] => {} + _ => { + // Agus NB: We're currently only writing string entries to the clipboard when we have more than one. + // + // This was the existing behavior before I refactored the outer clipboard code: + // https://github.com/zed-industries/zed/blob/65f7412a0265552b06ce122655369d6cc7381dd6/crates/gpui/src/platform/mac/platform.rs#L1060-L1110 + // + // Note how `any_images` is always `false`. We should fix that, but that's orthogonal to the refactor. + + let mut combined = ClipboardString { + text: String::new(), + metadata: None, + }; + + for entry in item.entries { + match entry { + ClipboardEntry::String(text) => { + combined.text.push_str(&text.text()); + if combined.metadata.is_none() { + combined.metadata = text.metadata; + } + } + _ => {} + } + } + + self.write_plaintext(&combined); + } + } + } + } + + fn write_plaintext(&self, string: &ClipboardString) { + unsafe { + self.inner.clearContents(); + + let text_bytes = NSData::dataWithBytes_length_( + nil, + string.text.as_ptr() as *const c_void, + string.text.len() as u64, + ); + self.inner + .setData_forType(text_bytes, NSPasteboardTypeString); + + if let Some(metadata) = string.metadata.as_ref() { + let hash_bytes = ClipboardString::text_hash(&string.text).to_be_bytes(); + let hash_bytes = NSData::dataWithBytes_length_( + nil, + hash_bytes.as_ptr() as *const c_void, + hash_bytes.len() as u64, + ); + self.inner.setData_forType(hash_bytes, self.text_hash_type); + + let metadata_bytes = NSData::dataWithBytes_length_( + nil, + metadata.as_ptr() as *const c_void, + metadata.len() as u64, + ); + self.inner + .setData_forType(metadata_bytes, self.metadata_type); + } + } + } + + unsafe fn write_image(&self, image: &Image) { + unsafe { + self.inner.clearContents(); + + let bytes = NSData::dataWithBytes_length_( + nil, + image.bytes.as_ptr() as *const c_void, + image.bytes.len() as u64, + ); + + self.inner + .setData_forType(bytes, Into::::into(image.format).inner_mut()); + } + } +} + +#[link(name = "AppKit", kind = "framework")] +unsafe extern "C" { + /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardnamefind?language=objc) + pub static NSPasteboardNameFind: id; +} + +impl From for UTType { + fn from(value: ImageFormat) -> Self { + match value { + ImageFormat::Png => Self::png(), + ImageFormat::Jpeg => Self::jpeg(), + ImageFormat::Tiff => Self::tiff(), + ImageFormat::Webp => Self::webp(), + ImageFormat::Gif => Self::gif(), + ImageFormat::Bmp => Self::bmp(), + ImageFormat::Svg => Self::svg(), + ImageFormat::Ico => Self::ico(), + } + } +} + +// See https://developer.apple.com/documentation/uniformtypeidentifiers/uttype-swift.struct/ +pub struct UTType(id); + +impl UTType { + pub fn png() -> Self { + // https://developer.apple.com/documentation/uniformtypeidentifiers/uttype-swift.struct/png + Self(unsafe { NSPasteboardTypePNG }) // This is a rare case where there's a built-in NSPasteboardType + } + + pub fn jpeg() -> Self { + // https://developer.apple.com/documentation/uniformtypeidentifiers/uttype-swift.struct/jpeg + Self(unsafe { ns_string("public.jpeg") }) + } + + pub fn gif() -> Self { + // https://developer.apple.com/documentation/uniformtypeidentifiers/uttype-swift.struct/gif + Self(unsafe { ns_string("com.compuserve.gif") }) + } + + pub fn webp() -> Self { + // https://developer.apple.com/documentation/uniformtypeidentifiers/uttype-swift.struct/webp + Self(unsafe { ns_string("org.webmproject.webp") }) + } + + pub fn bmp() -> Self { + // https://developer.apple.com/documentation/uniformtypeidentifiers/uttype-swift.struct/bmp + Self(unsafe { ns_string("com.microsoft.bmp") }) + } + + pub fn svg() -> Self { + // https://developer.apple.com/documentation/uniformtypeidentifiers/uttype-swift.struct/svg + Self(unsafe { ns_string("public.svg-image") }) + } + + pub fn ico() -> Self { + // https://developer.apple.com/documentation/uniformtypeidentifiers/uttype-swift.struct/ico + Self(unsafe { ns_string("com.microsoft.ico") }) + } + + pub fn tiff() -> Self { + // https://developer.apple.com/documentation/uniformtypeidentifiers/uttype-swift.struct/tiff + Self(unsafe { NSPasteboardTypeTIFF }) // This is a rare case where there's a built-in NSPasteboardType + } + + fn inner(&self) -> *const Object { + self.0 + } + + pub fn inner_mut(&self) -> *mut Object { + self.0 as *mut _ + } +} + +#[cfg(test)] +mod tests { + use cocoa::{appkit::NSPasteboardTypeString, foundation::NSData}; + + use crate::{ClipboardEntry, ClipboardItem, ClipboardString}; + + use super::*; + + #[test] + fn test_string() { + let pasteboard = Pasteboard::unique(); + assert_eq!(pasteboard.read(), None); + + let item = ClipboardItem::new_string("1".to_string()); + pasteboard.write(item.clone()); + assert_eq!(pasteboard.read(), Some(item)); + + let item = ClipboardItem { + entries: vec![ClipboardEntry::String( + ClipboardString::new("2".to_string()).with_json_metadata(vec![3, 4]), + )], + }; + pasteboard.write(item.clone()); + assert_eq!(pasteboard.read(), Some(item)); + + let text_from_other_app = "text from other app"; + unsafe { + let bytes = NSData::dataWithBytes_length_( + nil, + text_from_other_app.as_ptr() as *const c_void, + text_from_other_app.len() as u64, + ); + pasteboard + .inner + .setData_forType(bytes, NSPasteboardTypeString); + } + assert_eq!( + pasteboard.read(), + Some(ClipboardItem::new_string(text_from_other_app.to_string())) + ); + } +} diff --git a/crates/gpui/src/platform/mac/platform.rs b/crates/gpui/src/platform/mac/platform.rs index ee67f465e34bd8109246f68b311e225aa8f9fd0a..9b32c6735bf6215fecc0455defc4237fd25e8cb0 100644 --- a/crates/gpui/src/platform/mac/platform.rs +++ b/crates/gpui/src/platform/mac/platform.rs @@ -1,29 +1,24 @@ use super::{ - BoolExt, MacKeyboardLayout, MacKeyboardMapper, - attributed_string::{NSAttributedString, NSMutableAttributedString}, - events::key_to_native, - ns_string, renderer, + BoolExt, MacKeyboardLayout, MacKeyboardMapper, events::key_to_native, ns_string, renderer, }; use crate::{ - Action, AnyWindowHandle, BackgroundExecutor, ClipboardEntry, ClipboardItem, ClipboardString, - CursorStyle, ForegroundExecutor, Image, ImageFormat, KeyContext, Keymap, MacDispatcher, - MacDisplay, MacWindow, Menu, MenuItem, OsMenu, OwnedMenu, PathPromptOptions, Platform, - PlatformDisplay, PlatformKeyboardLayout, PlatformKeyboardMapper, PlatformTextSystem, - PlatformWindow, Result, SystemMenuType, Task, WindowAppearance, WindowParams, hash, + Action, AnyWindowHandle, BackgroundExecutor, ClipboardItem, CursorStyle, ForegroundExecutor, + KeyContext, Keymap, MacDispatcher, MacDisplay, MacWindow, Menu, MenuItem, OsMenu, OwnedMenu, + PathPromptOptions, Platform, PlatformDisplay, PlatformKeyboardLayout, PlatformKeyboardMapper, + PlatformTextSystem, PlatformWindow, Result, SystemMenuType, Task, WindowAppearance, + WindowParams, platform::mac::pasteboard::Pasteboard, }; use anyhow::{Context as _, anyhow}; use block::ConcreteBlock; use cocoa::{ appkit::{ NSApplication, NSApplicationActivationPolicy::NSApplicationActivationPolicyRegular, - NSEventModifierFlags, NSMenu, NSMenuItem, NSModalResponse, NSOpenPanel, NSPasteboard, - NSPasteboardTypePNG, NSPasteboardTypeRTF, NSPasteboardTypeRTFD, NSPasteboardTypeString, - NSPasteboardTypeTIFF, NSSavePanel, NSVisualEffectState, NSVisualEffectView, NSWindow, + NSEventModifierFlags, NSMenu, NSMenuItem, NSModalResponse, NSOpenPanel, NSSavePanel, + NSVisualEffectState, NSVisualEffectView, NSWindow, }, base::{BOOL, NO, YES, id, nil, selector}, foundation::{ - NSArray, NSAutoreleasePool, NSBundle, NSData, NSInteger, NSProcessInfo, NSRange, NSString, - NSUInteger, NSURL, + NSArray, NSAutoreleasePool, NSBundle, NSInteger, NSProcessInfo, NSString, NSUInteger, NSURL, }, }; use core_foundation::{ @@ -49,7 +44,6 @@ use ptr::null_mut; use semver::Version; use std::{ cell::Cell, - convert::TryInto, ffi::{CStr, OsStr, c_void}, os::{raw::c_char, unix::ffi::OsStrExt}, path::{Path, PathBuf}, @@ -58,7 +52,6 @@ use std::{ slice, str, sync::{Arc, OnceLock}, }; -use strum::IntoEnumIterator; use util::{ ResultExt, command::{new_smol_command, new_std_command}, @@ -164,9 +157,8 @@ pub(crate) struct MacPlatformState { text_system: Arc, renderer_context: renderer::Context, headless: bool, - pasteboard: id, - text_hash_pasteboard_type: id, - metadata_pasteboard_type: id, + general_pasteboard: Pasteboard, + find_pasteboard: Pasteboard, reopen: Option>, on_keyboard_layout_change: Option>, quit: Option>, @@ -206,9 +198,8 @@ impl MacPlatform { background_executor: BackgroundExecutor::new(dispatcher.clone()), foreground_executor: ForegroundExecutor::new(dispatcher), renderer_context: renderer::Context::default(), - pasteboard: unsafe { NSPasteboard::generalPasteboard(nil) }, - text_hash_pasteboard_type: unsafe { ns_string("zed-text-hash") }, - metadata_pasteboard_type: unsafe { ns_string("zed-metadata") }, + general_pasteboard: Pasteboard::general(), + find_pasteboard: Pasteboard::find(), reopen: None, quit: None, menu_command: None, @@ -224,20 +215,6 @@ impl MacPlatform { })) } - unsafe fn read_from_pasteboard(&self, pasteboard: *mut Object, kind: id) -> Option<&[u8]> { - unsafe { - let data = pasteboard.dataForType(kind); - if data == nil { - None - } else { - Some(slice::from_raw_parts( - data.bytes() as *mut u8, - data.length() as usize, - )) - } - } - } - unsafe fn create_menu_bar( &self, menus: &Vec, @@ -1034,119 +1011,24 @@ impl Platform for MacPlatform { } } - fn write_to_clipboard(&self, item: ClipboardItem) { - use crate::ClipboardEntry; - - unsafe { - // We only want to use NSAttributedString if there are multiple entries to write. - if item.entries.len() <= 1 { - match item.entries.first() { - Some(entry) => match entry { - ClipboardEntry::String(string) => { - self.write_plaintext_to_clipboard(string); - } - ClipboardEntry::Image(image) => { - self.write_image_to_clipboard(image); - } - ClipboardEntry::ExternalPaths(_) => {} - }, - None => { - // Writing an empty list of entries just clears the clipboard. - let state = self.0.lock(); - state.pasteboard.clearContents(); - } - } - } else { - let mut any_images = false; - let attributed_string = { - let mut buf = NSMutableAttributedString::alloc(nil) - // TODO can we skip this? Or at least part of it? - .init_attributed_string(ns_string("")) - .autorelease(); - - for entry in item.entries { - if let ClipboardEntry::String(ClipboardString { text, metadata: _ }) = entry - { - let to_append = NSAttributedString::alloc(nil) - .init_attributed_string(ns_string(&text)) - .autorelease(); - - buf.appendAttributedString_(to_append); - } - } - - buf - }; - - let state = self.0.lock(); - state.pasteboard.clearContents(); - - // Only set rich text clipboard types if we actually have 1+ images to include. - if any_images { - let rtfd_data = attributed_string.RTFDFromRange_documentAttributes_( - NSRange::new(0, msg_send![attributed_string, length]), - nil, - ); - if rtfd_data != nil { - state - .pasteboard - .setData_forType(rtfd_data, NSPasteboardTypeRTFD); - } - - let rtf_data = attributed_string.RTFFromRange_documentAttributes_( - NSRange::new(0, attributed_string.length()), - nil, - ); - if rtf_data != nil { - state - .pasteboard - .setData_forType(rtf_data, NSPasteboardTypeRTF); - } - } - - let plain_text = attributed_string.string(); - state - .pasteboard - .setString_forType(plain_text, NSPasteboardTypeString); - } - } - } - fn read_from_clipboard(&self) -> Option { let state = self.0.lock(); - let pasteboard = state.pasteboard; - - // First, see if it's a string. - unsafe { - let types: id = pasteboard.types(); - let string_type: id = ns_string("public.utf8-plain-text"); - - if msg_send![types, containsObject: string_type] { - let data = pasteboard.dataForType(string_type); - if data == nil { - return None; - } else if data.bytes().is_null() { - // https://developer.apple.com/documentation/foundation/nsdata/1410616-bytes?language=objc - // "If the length of the NSData object is 0, this property returns nil." - return Some(self.read_string_from_clipboard(&state, &[])); - } else { - let bytes = - slice::from_raw_parts(data.bytes() as *mut u8, data.length() as usize); + state.general_pasteboard.read() + } - return Some(self.read_string_from_clipboard(&state, bytes)); - } - } + fn write_to_clipboard(&self, item: ClipboardItem) { + let state = self.0.lock(); + state.general_pasteboard.write(item); + } - // If it wasn't a string, try the various supported image types. - for format in ImageFormat::iter() { - if let Some(item) = try_clipboard_image(pasteboard, format) { - return Some(item); - } - } - } + fn read_from_find_pasteboard(&self) -> Option { + let state = self.0.lock(); + state.find_pasteboard.read() + } - // If it wasn't a string or a supported image type, give up. - None + fn write_to_find_pasteboard(&self, item: ClipboardItem) { + let state = self.0.lock(); + state.find_pasteboard.write(item); } fn write_credentials(&self, url: &str, username: &str, password: &[u8]) -> Task> { @@ -1255,116 +1137,6 @@ impl Platform for MacPlatform { } } -impl MacPlatform { - unsafe fn read_string_from_clipboard( - &self, - state: &MacPlatformState, - text_bytes: &[u8], - ) -> ClipboardItem { - unsafe { - let text = String::from_utf8_lossy(text_bytes).to_string(); - let metadata = self - .read_from_pasteboard(state.pasteboard, state.text_hash_pasteboard_type) - .and_then(|hash_bytes| { - let hash_bytes = hash_bytes.try_into().ok()?; - let hash = u64::from_be_bytes(hash_bytes); - let metadata = self - .read_from_pasteboard(state.pasteboard, state.metadata_pasteboard_type)?; - - if hash == ClipboardString::text_hash(&text) { - String::from_utf8(metadata.to_vec()).ok() - } else { - None - } - }); - - ClipboardItem { - entries: vec![ClipboardEntry::String(ClipboardString { text, metadata })], - } - } - } - - unsafe fn write_plaintext_to_clipboard(&self, string: &ClipboardString) { - unsafe { - let state = self.0.lock(); - state.pasteboard.clearContents(); - - let text_bytes = NSData::dataWithBytes_length_( - nil, - string.text.as_ptr() as *const c_void, - string.text.len() as u64, - ); - state - .pasteboard - .setData_forType(text_bytes, NSPasteboardTypeString); - - if let Some(metadata) = string.metadata.as_ref() { - let hash_bytes = ClipboardString::text_hash(&string.text).to_be_bytes(); - let hash_bytes = NSData::dataWithBytes_length_( - nil, - hash_bytes.as_ptr() as *const c_void, - hash_bytes.len() as u64, - ); - state - .pasteboard - .setData_forType(hash_bytes, state.text_hash_pasteboard_type); - - let metadata_bytes = NSData::dataWithBytes_length_( - nil, - metadata.as_ptr() as *const c_void, - metadata.len() as u64, - ); - state - .pasteboard - .setData_forType(metadata_bytes, state.metadata_pasteboard_type); - } - } - } - - unsafe fn write_image_to_clipboard(&self, image: &Image) { - unsafe { - let state = self.0.lock(); - state.pasteboard.clearContents(); - - let bytes = NSData::dataWithBytes_length_( - nil, - image.bytes.as_ptr() as *const c_void, - image.bytes.len() as u64, - ); - - state - .pasteboard - .setData_forType(bytes, Into::::into(image.format).inner_mut()); - } - } -} - -fn try_clipboard_image(pasteboard: id, format: ImageFormat) -> Option { - let mut ut_type: UTType = format.into(); - - unsafe { - let types: id = pasteboard.types(); - if msg_send![types, containsObject: ut_type.inner()] { - let data = pasteboard.dataForType(ut_type.inner_mut()); - if data == nil { - None - } else { - let bytes = Vec::from(slice::from_raw_parts( - data.bytes() as *mut u8, - data.length() as usize, - )); - let id = hash(&bytes); - - Some(ClipboardItem { - entries: vec![ClipboardEntry::Image(Image { format, bytes, id })], - }) - } - } else { - None - } - } -} - unsafe fn path_from_objc(path: id) -> PathBuf { let len = msg_send![path, lengthOfBytesUsingEncoding: NSUTF8StringEncoding]; let bytes = unsafe { path.UTF8String() as *const u8 }; @@ -1605,120 +1377,3 @@ mod security { pub const errSecUserCanceled: OSStatus = -128; pub const errSecItemNotFound: OSStatus = -25300; } - -impl From for UTType { - fn from(value: ImageFormat) -> Self { - match value { - ImageFormat::Png => Self::png(), - ImageFormat::Jpeg => Self::jpeg(), - ImageFormat::Tiff => Self::tiff(), - ImageFormat::Webp => Self::webp(), - ImageFormat::Gif => Self::gif(), - ImageFormat::Bmp => Self::bmp(), - ImageFormat::Svg => Self::svg(), - ImageFormat::Ico => Self::ico(), - } - } -} - -// See https://developer.apple.com/documentation/uniformtypeidentifiers/uttype-swift.struct/ -struct UTType(id); - -impl UTType { - pub fn png() -> Self { - // https://developer.apple.com/documentation/uniformtypeidentifiers/uttype-swift.struct/png - Self(unsafe { NSPasteboardTypePNG }) // This is a rare case where there's a built-in NSPasteboardType - } - - pub fn jpeg() -> Self { - // https://developer.apple.com/documentation/uniformtypeidentifiers/uttype-swift.struct/jpeg - Self(unsafe { ns_string("public.jpeg") }) - } - - pub fn gif() -> Self { - // https://developer.apple.com/documentation/uniformtypeidentifiers/uttype-swift.struct/gif - Self(unsafe { ns_string("com.compuserve.gif") }) - } - - pub fn webp() -> Self { - // https://developer.apple.com/documentation/uniformtypeidentifiers/uttype-swift.struct/webp - Self(unsafe { ns_string("org.webmproject.webp") }) - } - - pub fn bmp() -> Self { - // https://developer.apple.com/documentation/uniformtypeidentifiers/uttype-swift.struct/bmp - Self(unsafe { ns_string("com.microsoft.bmp") }) - } - - pub fn svg() -> Self { - // https://developer.apple.com/documentation/uniformtypeidentifiers/uttype-swift.struct/svg - Self(unsafe { ns_string("public.svg-image") }) - } - - pub fn ico() -> Self { - // https://developer.apple.com/documentation/uniformtypeidentifiers/uttype-swift.struct/ico - Self(unsafe { ns_string("com.microsoft.ico") }) - } - - pub fn tiff() -> Self { - // https://developer.apple.com/documentation/uniformtypeidentifiers/uttype-swift.struct/tiff - Self(unsafe { NSPasteboardTypeTIFF }) // This is a rare case where there's a built-in NSPasteboardType - } - - fn inner(&self) -> *const Object { - self.0 - } - - fn inner_mut(&self) -> *mut Object { - self.0 as *mut _ - } -} - -#[cfg(test)] -mod tests { - use crate::ClipboardItem; - - use super::*; - - #[test] - fn test_clipboard() { - let platform = build_platform(); - assert_eq!(platform.read_from_clipboard(), None); - - let item = ClipboardItem::new_string("1".to_string()); - platform.write_to_clipboard(item.clone()); - assert_eq!(platform.read_from_clipboard(), Some(item)); - - let item = ClipboardItem { - entries: vec![ClipboardEntry::String( - ClipboardString::new("2".to_string()).with_json_metadata(vec![3, 4]), - )], - }; - platform.write_to_clipboard(item.clone()); - assert_eq!(platform.read_from_clipboard(), Some(item)); - - let text_from_other_app = "text from other app"; - unsafe { - let bytes = NSData::dataWithBytes_length_( - nil, - text_from_other_app.as_ptr() as *const c_void, - text_from_other_app.len() as u64, - ); - platform - .0 - .lock() - .pasteboard - .setData_forType(bytes, NSPasteboardTypeString); - } - assert_eq!( - platform.read_from_clipboard(), - Some(ClipboardItem::new_string(text_from_other_app.to_string())) - ); - } - - fn build_platform() -> MacPlatform { - let platform = MacPlatform::new(false); - platform.0.lock().pasteboard = unsafe { NSPasteboard::pasteboardWithUniqueName(nil) }; - platform - } -} diff --git a/crates/gpui/src/platform/test/platform.rs b/crates/gpui/src/platform/test/platform.rs index dfada364667989792325e02f8530e6c91bdf4716..ca9d5e2c3b7d405e40f208f5406f879467eafc5c 100644 --- a/crates/gpui/src/platform/test/platform.rs +++ b/crates/gpui/src/platform/test/platform.rs @@ -32,6 +32,8 @@ pub(crate) struct TestPlatform { current_clipboard_item: Mutex>, #[cfg(any(target_os = "linux", target_os = "freebsd"))] current_primary_item: Mutex>, + #[cfg(target_os = "macos")] + current_find_pasteboard_item: Mutex>, pub(crate) prompts: RefCell, screen_capture_sources: RefCell>, pub opened_url: RefCell>, @@ -117,6 +119,8 @@ impl TestPlatform { current_clipboard_item: Mutex::new(None), #[cfg(any(target_os = "linux", target_os = "freebsd"))] current_primary_item: Mutex::new(None), + #[cfg(target_os = "macos")] + current_find_pasteboard_item: Mutex::new(None), weak: weak.clone(), opened_url: Default::default(), #[cfg(target_os = "windows")] @@ -398,9 +402,8 @@ impl Platform for TestPlatform { false } - #[cfg(any(target_os = "linux", target_os = "freebsd"))] - fn write_to_primary(&self, item: ClipboardItem) { - *self.current_primary_item.lock() = Some(item); + fn read_from_clipboard(&self) -> Option { + self.current_clipboard_item.lock().clone() } fn write_to_clipboard(&self, item: ClipboardItem) { @@ -412,8 +415,19 @@ impl Platform for TestPlatform { self.current_primary_item.lock().clone() } - fn read_from_clipboard(&self) -> Option { - self.current_clipboard_item.lock().clone() + #[cfg(any(target_os = "linux", target_os = "freebsd"))] + fn write_to_primary(&self, item: ClipboardItem) { + *self.current_primary_item.lock() = Some(item); + } + + #[cfg(target_os = "macos")] + fn read_from_find_pasteboard(&self) -> Option { + self.current_find_pasteboard_item.lock().clone() + } + + #[cfg(target_os = "macos")] + fn write_to_find_pasteboard(&self, item: ClipboardItem) { + *self.current_find_pasteboard_item.lock() = Some(item); } fn write_credentials(&self, _url: &str, _username: &str, _password: &[u8]) -> Task> { diff --git a/crates/search/src/buffer_search.rs b/crates/search/src/buffer_search.rs index 12b283ab22937b7952d18d63b1378d2914211f9b..be3331048bc78a91a8d3c5a3637d6bf6ea007e4d 100644 --- a/crates/search/src/buffer_search.rs +++ b/crates/search/src/buffer_search.rs @@ -106,7 +106,10 @@ pub struct BufferSearchBar { replacement_editor_focused: bool, active_searchable_item: Option>, active_match_index: Option, - active_searchable_item_subscription: Option, + #[cfg(target_os = "macos")] + active_searchable_item_subscriptions: Option<[Subscription; 2]>, + #[cfg(not(target_os = "macos"))] + active_searchable_item_subscriptions: Option, active_search: Option>, searchable_items_with_matches: HashMap, AnyVec>, pending_search: Option>, @@ -472,7 +475,7 @@ impl ToolbarItemView for BufferSearchBar { cx: &mut Context, ) -> ToolbarItemLocation { cx.notify(); - self.active_searchable_item_subscription.take(); + self.active_searchable_item_subscriptions.take(); self.active_searchable_item.take(); self.pending_search.take(); @@ -482,18 +485,58 @@ impl ToolbarItemView for BufferSearchBar { { let this = cx.entity().downgrade(); - self.active_searchable_item_subscription = - Some(searchable_item_handle.subscribe_to_search_events( - window, - cx, - Box::new(move |search_event, window, cx| { - if let Some(this) = this.upgrade() { - this.update(cx, |this, cx| { - this.on_active_searchable_item_event(search_event, window, cx) - }); + let search_event_subscription = searchable_item_handle.subscribe_to_search_events( + window, + cx, + Box::new(move |search_event, window, cx| { + if let Some(this) = this.upgrade() { + this.update(cx, |this, cx| { + this.on_active_searchable_item_event(search_event, window, cx) + }); + } + }), + ); + + #[cfg(target_os = "macos")] + { + let item_focus_handle = searchable_item_handle.item_focus_handle(cx); + + self.active_searchable_item_subscriptions = Some([ + search_event_subscription, + cx.on_focus(&item_focus_handle, window, |this, window, cx| { + if this.query_editor_focused || this.replacement_editor_focused { + // no need to read pasteboard since focus came from toolbar + return; } + + cx.defer_in(window, |this, window, cx| { + if let Some(item) = cx.read_from_find_pasteboard() + && let Some(text) = item.text() + { + if this.query(cx) != text { + let search_options = item + .metadata() + .and_then(|m| m.parse().ok()) + .and_then(SearchOptions::from_bits) + .unwrap_or(this.search_options); + + drop(this.search( + &text, + Some(search_options), + true, + window, + cx, + )); + } + } + }); }), - )); + ]); + } + #[cfg(not(target_os = "macos"))] + { + self.active_searchable_item_subscriptions = Some(search_event_subscription); + } let is_project_search = searchable_item_handle.supported_options(cx).find_in_results; self.active_searchable_item = Some(searchable_item_handle); @@ -663,7 +706,7 @@ impl BufferSearchBar { replacement_editor, replacement_editor_focused: false, active_searchable_item: None, - active_searchable_item_subscription: None, + active_searchable_item_subscriptions: None, active_match_index: None, searchable_items_with_matches: Default::default(), default_options: search_options, @@ -904,11 +947,21 @@ impl BufferSearchBar { }); self.set_search_options(options, cx); self.clear_matches(window, cx); + #[cfg(target_os = "macos")] + self.update_find_pasteboard(cx); cx.notify(); } self.update_matches(!updated, add_to_history, window, cx) } + #[cfg(target_os = "macos")] + pub fn update_find_pasteboard(&mut self, cx: &mut App) { + cx.write_to_find_pasteboard(gpui::ClipboardItem::new_string_with_metadata( + self.query(cx), + self.search_options.bits().to_string(), + )); + } + pub fn focus_editor(&mut self, _: &FocusEditor, window: &mut Window, cx: &mut Context) { if let Some(active_editor) = self.active_searchable_item.as_ref() { let handle = active_editor.item_focus_handle(cx); @@ -1098,11 +1151,12 @@ impl BufferSearchBar { cx.spawn_in(window, async move |this, cx| { if search.await.is_ok() { this.update_in(cx, |this, window, cx| { - this.activate_current_match(window, cx) - }) - } else { - Ok(()) + this.activate_current_match(window, cx); + #[cfg(target_os = "macos")] + this.update_find_pasteboard(cx); + })?; } + anyhow::Ok(()) }) .detach_and_log_err(cx); } @@ -1293,6 +1347,7 @@ impl BufferSearchBar { .insert(active_searchable_item.downgrade(), matches); this.update_match_index(window, cx); + if add_to_history { this.search_history .add(&mut this.search_history_cursor, query_text); From 361b8e0ba9b11b68c456d43d03adabf53d7f54f0 Mon Sep 17 00:00:00 2001 From: Julia Ryan Date: Fri, 19 Dec 2025 09:04:15 -0800 Subject: [PATCH 557/621] Fix sticky header scroll offset (#45377) Closes #43319 Release Notes: - Sticky headers no longer obscure the cursor when it moves. --------- Co-authored-by: HactarCE <6060305+HactarCE@users.noreply.github.com> --- crates/editor/src/scroll/autoscroll.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/crates/editor/src/scroll/autoscroll.rs b/crates/editor/src/scroll/autoscroll.rs index 28fd9442193bbec663d3f72eaa805214375dd8ca..fc2ecb9205109532da2b43c97821b5352f27aff2 100644 --- a/crates/editor/src/scroll/autoscroll.rs +++ b/crates/editor/src/scroll/autoscroll.rs @@ -5,7 +5,7 @@ use crate::{ }; use gpui::{Bounds, Context, Pixels, Window}; use language::Point; -use multi_buffer::Anchor; +use multi_buffer::{Anchor, ToPoint}; use std::cmp; #[derive(Debug, PartialEq, Eq, Clone, Copy)] @@ -186,6 +186,19 @@ impl Editor { } } + let style = self.style(cx).clone(); + let sticky_headers = self.sticky_headers(&style, cx).unwrap_or_default(); + let visible_sticky_headers = sticky_headers + .iter() + .filter(|h| { + let buffer_snapshot = display_map.buffer_snapshot(); + let buffer_range = + h.range.start.to_point(buffer_snapshot)..h.range.end.to_point(buffer_snapshot); + + buffer_range.contains(&Point::new(target_top as u32, 0)) + }) + .count(); + let margin = if matches!(self.mode, EditorMode::AutoHeight { .. }) { 0. } else { @@ -218,7 +231,7 @@ impl Editor { let was_autoscrolled = match strategy { AutoscrollStrategy::Fit | AutoscrollStrategy::Newest => { let margin = margin.min(self.scroll_manager.vertical_scroll_margin); - let target_top = (target_top - margin).max(0.0); + let target_top = (target_top - margin - visible_sticky_headers as f64).max(0.0); let target_bottom = target_bottom + margin; let start_row = scroll_position.y; let end_row = start_row + visible_lines; From bfe3c66c3e38b79b7c24f94e0dcf4cf781a6dbd5 Mon Sep 17 00:00:00 2001 From: morgankrey Date: Fri, 19 Dec 2025 11:19:12 -0600 Subject: [PATCH 558/621] docs: Automatic Documentation Github Action using Droid (#45374) Adds a multi-step agentic loop to github actions for opening a once-daily documentation PR that can be merged only be a Zedi Release Notes: - N/A --------- Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> --- .../prompts/docs-automation/phase2-explore.md | 55 +++ .../prompts/docs-automation/phase3-analyze.md | 57 +++ .../prompts/docs-automation/phase4-plan.md | 76 ++++ .../prompts/docs-automation/phase5-apply.md | 67 ++++ .../docs-automation/phase6-summarize.md | 54 +++ .../prompts/docs-automation/phase7-commit.md | 67 ++++ .github/workflows/docs_automation.yml | 256 +++++++++++++ docs/AGENTS.md | 353 ++++++++++++++++++ 8 files changed, 985 insertions(+) create mode 100644 .factory/prompts/docs-automation/phase2-explore.md create mode 100644 .factory/prompts/docs-automation/phase3-analyze.md create mode 100644 .factory/prompts/docs-automation/phase4-plan.md create mode 100644 .factory/prompts/docs-automation/phase5-apply.md create mode 100644 .factory/prompts/docs-automation/phase6-summarize.md create mode 100644 .factory/prompts/docs-automation/phase7-commit.md create mode 100644 .github/workflows/docs_automation.yml create mode 100644 docs/AGENTS.md diff --git a/.factory/prompts/docs-automation/phase2-explore.md b/.factory/prompts/docs-automation/phase2-explore.md new file mode 100644 index 0000000000000000000000000000000000000000..e8f0b1861912f9665d70e42dd02e1bb8a398b01e --- /dev/null +++ b/.factory/prompts/docs-automation/phase2-explore.md @@ -0,0 +1,55 @@ +# Phase 2: Explore Repository + +You are analyzing a codebase to understand its structure before reviewing documentation impact. + +## Objective +Produce a structured overview of the repository to inform subsequent documentation analysis. + +## Instructions + +1. **Identify Primary Languages and Frameworks** + - Scan for Cargo.toml, package.json, or other manifest files + - Note the primary language(s) and key dependencies + +2. **Map Documentation Structure** + - This project uses **mdBook** (https://rust-lang.github.io/mdBook/) + - Documentation is in `docs/src/` + - Table of contents: `docs/src/SUMMARY.md` (mdBook format: https://rust-lang.github.io/mdBook/format/summary.html) + - Style guide: `docs/.rules` + - Agent guidelines: `docs/AGENTS.md` + - Formatting: Prettier (config in `docs/.prettierrc`) + +3. **Identify Build and Tooling** + - Note build systems (cargo, npm, etc.) + - Identify documentation tooling (mdbook, etc.) + +4. **Output Format** +Produce a JSON summary: + +```json +{ + "primary_language": "Rust", + "frameworks": ["GPUI"], + "documentation": { + "system": "mdBook", + "location": "docs/src/", + "toc_file": "docs/src/SUMMARY.md", + "toc_format": "https://rust-lang.github.io/mdBook/format/summary.html", + "style_guide": "docs/.rules", + "agent_guidelines": "docs/AGENTS.md", + "formatter": "prettier", + "formatter_config": "docs/.prettierrc", + "custom_preprocessor": "docs_preprocessor (handles {#kb action::Name} syntax)" + }, + "key_directories": { + "source": "crates/", + "docs": "docs/src/", + "extensions": "extensions/" + } +} +``` + +## Constraints +- Read-only: Do not modify any files +- Focus on structure, not content details +- Complete within 2 minutes diff --git a/.factory/prompts/docs-automation/phase3-analyze.md b/.factory/prompts/docs-automation/phase3-analyze.md new file mode 100644 index 0000000000000000000000000000000000000000..8fc8622434d3be2e6be7997e9773c1b2435202c6 --- /dev/null +++ b/.factory/prompts/docs-automation/phase3-analyze.md @@ -0,0 +1,57 @@ +# Phase 3: Analyze Changes + +You are analyzing code changes to understand their nature and scope. + +## Objective +Produce a clear, neutral summary of what changed in the codebase. + +## Input +You will receive: +- List of changed files from the triggering commit/PR +- Repository structure from Phase 2 + +## Instructions + +1. **Categorize Changed Files** + - Source code (which crates/modules) + - Configuration + - Tests + - Documentation (already existing) + - Other + +2. **Analyze Each Change** + - Review diffs for files likely to impact documentation + - Focus on: public APIs, settings, keybindings, commands, user-visible behavior + +3. **Identify What Did NOT Change** + - Note stable interfaces or behaviors + - Important for avoiding unnecessary documentation updates + +4. **Output Format** +Produce a markdown summary: + +```markdown +## Change Analysis + +### Changed Files Summary +| Category | Files | Impact Level | +| --- | --- | --- | +| Source - [crate] | file1.rs, file2.rs | High/Medium/Low | +| Settings | settings.json | Medium | +| Tests | test_*.rs | None | + +### Behavioral Changes +- **[Feature/Area]**: Description of what changed from user perspective +- **[Feature/Area]**: Description... + +### Unchanged Areas +- [Area]: Confirmed no changes to [specific behavior] + +### Files Requiring Deeper Review +- `path/to/file.rs`: Reason for deeper review +``` + +## Constraints +- Read-only: Do not modify any files +- Neutral tone: Describe what changed, not whether it's good/bad +- Do not propose documentation changes yet diff --git a/.factory/prompts/docs-automation/phase4-plan.md b/.factory/prompts/docs-automation/phase4-plan.md new file mode 100644 index 0000000000000000000000000000000000000000..9e6a15814e7813cbf27afb0413987afa539feaf6 --- /dev/null +++ b/.factory/prompts/docs-automation/phase4-plan.md @@ -0,0 +1,76 @@ +# Phase 4: Plan Documentation Impact + +You are determining whether and how documentation should be updated based on code changes. + +## Objective +Produce a structured documentation plan that will guide Phase 5 execution. + +## Documentation System +This is an **mdBook** site (https://rust-lang.github.io/mdBook/): +- `docs/src/SUMMARY.md` defines book structure per https://rust-lang.github.io/mdBook/format/summary.html +- If adding new pages, they MUST be added to SUMMARY.md +- Use `{#kb action::ActionName}` syntax for keybindings (custom preprocessor expands these) +- Prettier formatting (80 char width) will be applied automatically + +## Input +You will receive: +- Change analysis from Phase 3 +- Repository structure from Phase 2 +- Documentation guidelines from `docs/AGENTS.md` + +## Instructions + +1. **Review AGENTS.md** + - Load and apply all rules from `docs/AGENTS.md` + - Respect scope boundaries (in-scope vs out-of-scope) + +2. **Evaluate Documentation Impact** + For each behavioral change from Phase 3: + - Does existing documentation cover this area? + - Is the documentation now inaccurate or incomplete? + - Classify per AGENTS.md "Change Classification" section + +3. **Identify Specific Updates** + For each required update: + - Exact file path + - Specific section or heading + - Type of change (update existing, add new, deprecate) + - Description of the change + +4. **Flag Uncertainty** + Explicitly mark: + - Assumptions you're making + - Areas where human confirmation is needed + - Ambiguous requirements + +5. **Output Format** +Use the exact format specified in `docs/AGENTS.md` Phase 4 section: + +```markdown +## Documentation Impact Assessment + +### Summary +Brief description of code changes analyzed. + +### Documentation Updates Required: [Yes/No] + +### Planned Changes + +#### 1. [File Path] +- **Section**: [Section name or "New section"] +- **Change Type**: [Update/Add/Deprecate] +- **Reason**: Why this change is needed +- **Description**: What will be added/modified + +### Uncertainty Flags +- [ ] [Description of any assumptions or areas needing confirmation] + +### No Changes Needed +- [List files reviewed but not requiring updates, with brief reason] +``` + +## Constraints +- Read-only: Do not modify any files +- Conservative: When uncertain, flag for human review rather than planning changes +- Scoped: Only plan changes that trace directly to code changes from Phase 3 +- No scope expansion: Do not plan "improvements" unrelated to triggering changes diff --git a/.factory/prompts/docs-automation/phase5-apply.md b/.factory/prompts/docs-automation/phase5-apply.md new file mode 100644 index 0000000000000000000000000000000000000000..9cc63071fccf880443b729baa06f0ddbd769276b --- /dev/null +++ b/.factory/prompts/docs-automation/phase5-apply.md @@ -0,0 +1,67 @@ +# Phase 5: Apply Documentation Plan + +You are executing a pre-approved documentation plan for an **mdBook** documentation site. + +## Objective +Implement exactly the changes specified in the documentation plan from Phase 4. + +## Documentation System +- **mdBook**: https://rust-lang.github.io/mdBook/ +- **SUMMARY.md**: Follows mdBook format (https://rust-lang.github.io/mdBook/format/summary.html) +- **Prettier**: Will be run automatically after this phase (80 char line width) +- **Custom preprocessor**: Use `{#kb action::ActionName}` for keybindings instead of hardcoding + +## Input +You will receive: +- Documentation plan from Phase 4 +- Documentation guidelines from `docs/AGENTS.md` +- Style rules from `docs/.rules` + +## Instructions + +1. **Validate Plan** + - Confirm all planned files are within scope per AGENTS.md + - Verify no out-of-scope files are targeted + +2. **Execute Each Planned Change** + For each item in "Planned Changes": + - Navigate to the specified file + - Locate the specified section + - Apply the described change + - Follow style rules from `docs/.rules` + +3. **Style Compliance** + Every edit must follow `docs/.rules`: + - Second person, present tense + - No hedging words ("simply", "just", "easily") + - Proper keybinding format (`Cmd+Shift+P`) + - Settings Editor first, JSON second + - Correct terminology (folder not directory, etc.) + +4. **Preserve Context** + - Maintain surrounding content structure + - Keep consistent heading levels + - Preserve existing cross-references + +## Constraints +- Execute ONLY changes listed in the plan +- Do not discover new documentation targets +- Do not make stylistic improvements outside planned sections +- Do not expand scope beyond what Phase 4 specified +- If a planned change cannot be applied (file missing, section not found), skip and note it + +## Output +After applying changes, output a summary: + +```markdown +## Applied Changes + +### Successfully Applied +- `path/to/file.md`: [Brief description of change] + +### Skipped (Could Not Apply) +- `path/to/file.md`: [Reason - e.g., "Section not found"] + +### Warnings +- [Any issues encountered during application] +``` diff --git a/.factory/prompts/docs-automation/phase6-summarize.md b/.factory/prompts/docs-automation/phase6-summarize.md new file mode 100644 index 0000000000000000000000000000000000000000..b1480ac9431702539fa2a570c2b456bcdfae46af --- /dev/null +++ b/.factory/prompts/docs-automation/phase6-summarize.md @@ -0,0 +1,54 @@ +# Phase 6: Summarize Changes + +You are generating a summary of documentation updates for PR review. + +## Objective +Create a clear, reviewable summary of all documentation changes made. + +## Input +You will receive: +- Applied changes report from Phase 5 +- Original change analysis from Phase 3 +- Git diff of documentation changes + +## Instructions + +1. **Gather Change Information** + - List all modified documentation files + - Identify the corresponding code changes that triggered each update + +2. **Generate Summary** + Use the format specified in `docs/AGENTS.md` Phase 6 section: + +```markdown +## Documentation Update Summary + +### Changes Made +| File | Change | Related Code | +| --- | --- | --- | +| docs/src/path.md | Brief description | PR #123 or commit SHA | + +### Rationale +Brief explanation of why these updates were made, linking back to the triggering code changes. + +### Review Notes +- Items reviewers should pay special attention to +- Any uncertainty flags from Phase 4 that were addressed +- Assumptions made during documentation +``` + +3. **Add Context for Reviewers** + - Highlight any changes that might be controversial + - Note if any planned changes were skipped and why + - Flag areas where reviewer expertise is especially needed + +## Output Format +The summary should be suitable for: +- PR description body +- Commit message (condensed version) +- Team communication + +## Constraints +- Read-only (documentation changes already applied in Phase 5) +- Factual: Describe what was done, not justify why it's good +- Complete: Account for all changes, including skipped items diff --git a/.factory/prompts/docs-automation/phase7-commit.md b/.factory/prompts/docs-automation/phase7-commit.md new file mode 100644 index 0000000000000000000000000000000000000000..adfd92eec7d3058af3917f2663228b4f6ee5c445 --- /dev/null +++ b/.factory/prompts/docs-automation/phase7-commit.md @@ -0,0 +1,67 @@ +# Phase 7: Commit and Open PR + +You are creating a git branch, committing documentation changes, and opening a PR. + +## Objective +Package documentation updates into a reviewable pull request. + +## Input +You will receive: +- Summary from Phase 6 +- List of modified files + +## Instructions + +1. **Create Branch** + ```sh + git checkout -b docs/auto-update-{date} + ``` + Use format: `docs/auto-update-YYYY-MM-DD` or `docs/auto-update-{short-sha}` + +2. **Stage and Commit** + - Stage only documentation files in `docs/src/` + - Do not stage any other files + + Commit message format: + ``` + docs: auto-update documentation for [brief description] + + [Summary from Phase 6, condensed] + + Triggered by: [commit SHA or PR reference] + + Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> + ``` + +3. **Push Branch** + ```sh + git push -u origin docs/auto-update-{date} + ``` + +4. **Create Pull Request** + Use the Phase 6 summary as the PR body. + + PR Title: `docs: [Brief description of documentation updates]` + + Labels (if available): `documentation`, `automated` + + Base branch: `main` + +## Constraints +- Do NOT auto-merge +- Do NOT request specific reviewers (let CODEOWNERS handle it) +- Do NOT modify files outside `docs/src/` +- If no changes to commit, exit gracefully with message "No documentation changes to commit" + +## Output +```markdown +## PR Created + +- **Branch**: docs/auto-update-{date} +- **PR URL**: https://github.com/zed-industries/zed/pull/XXXX +- **Status**: Ready for review + +### Commit +- SHA: {commit-sha} +- Files: {count} documentation files modified +``` diff --git a/.github/workflows/docs_automation.yml b/.github/workflows/docs_automation.yml new file mode 100644 index 0000000000000000000000000000000000000000..e4aa79c7fc09d6d7735ac82e2315d68b923d5323 --- /dev/null +++ b/.github/workflows/docs_automation.yml @@ -0,0 +1,256 @@ +name: Documentation Automation + +on: + push: + branches: [main] + paths: + - 'crates/**' + - 'extensions/**' + workflow_dispatch: + inputs: + pr_number: + description: 'PR number to analyze (gets full PR diff)' + required: false + type: string + trigger_sha: + description: 'Commit SHA to analyze (ignored if pr_number is set)' + required: false + type: string + +permissions: + contents: write + pull-requests: write + +env: + FACTORY_API_KEY: ${{ secrets.FACTORY_API_KEY }} + DROID_MODEL: claude-opus-4-5 + +jobs: + docs-automation: + runs-on: ubuntu-latest + timeout-minutes: 30 + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Install Droid CLI + run: | + curl -fsSL https://cli.factory.ai/install.sh | bash + echo "${HOME}/.factory/bin" >> "$GITHUB_PATH" + + - name: Setup Node.js (for Prettier) + uses: actions/setup-node@v4 + with: + node-version: '20' + + - name: Install Prettier + run: npm install -g prettier + + - name: Get changed files + id: changed + run: | + if [ -n "${{ inputs.pr_number }}" ]; then + # Get full PR diff + echo "Analyzing PR #${{ inputs.pr_number }}" + echo "source=pr" >> "$GITHUB_OUTPUT" + echo "ref=${{ inputs.pr_number }}" >> "$GITHUB_OUTPUT" + gh pr diff "${{ inputs.pr_number }}" --name-only > /tmp/changed_files.txt + elif [ -n "${{ inputs.trigger_sha }}" ]; then + # Get single commit diff + SHA="${{ inputs.trigger_sha }}" + echo "Analyzing commit $SHA" + echo "source=commit" >> "$GITHUB_OUTPUT" + echo "ref=$SHA" >> "$GITHUB_OUTPUT" + git diff --name-only "${SHA}^" "$SHA" > /tmp/changed_files.txt + else + # Default to current commit + SHA="${{ github.sha }}" + echo "Analyzing commit $SHA" + echo "source=commit" >> "$GITHUB_OUTPUT" + echo "ref=$SHA" >> "$GITHUB_OUTPUT" + git diff --name-only "${SHA}^" "$SHA" > /tmp/changed_files.txt || git diff --name-only HEAD~1 HEAD > /tmp/changed_files.txt + fi + + echo "Changed files:" + cat /tmp/changed_files.txt + env: + GH_TOKEN: ${{ github.token }} + + # Phase 0: Guardrails are loaded via AGENTS.md in each phase + + # Phase 2: Explore Repository (Read-Only) + - name: "Phase 2: Explore Repository" + id: phase2 + run: | + droid exec \ + --model "$DROID_MODEL" \ + --autonomy read-only \ + --prompt-file .factory/prompts/docs-automation/phase2-explore.md \ + --output /tmp/phase2-output.json \ + --format json + echo "Repository exploration complete" + cat /tmp/phase2-output.json + + # Phase 3: Analyze Changes (Read-Only) + - name: "Phase 3: Analyze Changes" + id: phase3 + run: | + CHANGED_FILES=$(tr '\n' ' ' < /tmp/changed_files.txt) + droid exec \ + --model "$DROID_MODEL" \ + --autonomy read-only \ + --prompt-file .factory/prompts/docs-automation/phase3-analyze.md \ + --context "Changed files: $CHANGED_FILES" \ + --context-file /tmp/phase2-output.json \ + --output /tmp/phase3-output.md \ + --format markdown + echo "Change analysis complete" + cat /tmp/phase3-output.md + + # Phase 4: Plan Documentation Impact (Read-Only) + - name: "Phase 4: Plan Documentation Impact" + id: phase4 + run: | + droid exec \ + --model "$DROID_MODEL" \ + --autonomy read-only \ + --prompt-file .factory/prompts/docs-automation/phase4-plan.md \ + --context-file /tmp/phase3-output.md \ + --context-file docs/AGENTS.md \ + --output /tmp/phase4-plan.md \ + --format markdown + echo "Documentation plan complete" + cat /tmp/phase4-plan.md + + # Check if updates are required + if grep -q "Documentation Updates Required: No" /tmp/phase4-plan.md; then + echo "updates_required=false" >> "$GITHUB_OUTPUT" + else + echo "updates_required=true" >> "$GITHUB_OUTPUT" + fi + + # Phase 5: Apply Plan (Write-Enabled) + - name: "Phase 5: Apply Documentation Plan" + id: phase5 + if: steps.phase4.outputs.updates_required == 'true' + run: | + droid exec \ + --model "$DROID_MODEL" \ + --autonomy medium \ + --prompt-file .factory/prompts/docs-automation/phase5-apply.md \ + --context-file /tmp/phase4-plan.md \ + --context-file docs/AGENTS.md \ + --context-file docs/.rules \ + --output /tmp/phase5-report.md \ + --format markdown + echo "Documentation updates applied" + cat /tmp/phase5-report.md + + # Phase 5b: Format with Prettier + - name: "Phase 5b: Format with Prettier" + id: phase5b + if: steps.phase4.outputs.updates_required == 'true' + run: | + echo "Formatting documentation with Prettier..." + cd docs && prettier --write src/ + + echo "Verifying Prettier formatting passes..." + cd docs && prettier --check src/ + + echo "Prettier formatting complete" + + # Phase 6: Summarize Changes + - name: "Phase 6: Summarize Changes" + id: phase6 + if: steps.phase4.outputs.updates_required == 'true' + run: | + # Get git diff of docs + git diff docs/src/ > /tmp/docs-diff.txt || true + + droid exec \ + --model "$DROID_MODEL" \ + --autonomy read-only \ + --prompt-file .factory/prompts/docs-automation/phase6-summarize.md \ + --context-file /tmp/phase5-report.md \ + --context-file /tmp/phase3-output.md \ + --context "Trigger SHA: ${{ steps.changed.outputs.sha }}" \ + --output /tmp/phase6-summary.md \ + --format markdown + echo "Summary generated" + cat /tmp/phase6-summary.md + + # Phase 7: Commit and Open PR + - name: "Phase 7: Create PR" + id: phase7 + if: steps.phase4.outputs.updates_required == 'true' + run: | + # Check if there are actual changes + if git diff --quiet docs/src/; then + echo "No documentation changes detected" + exit 0 + fi + + # Configure git + git config user.name "factory-droid[bot]" + git config user.email "138933559+factory-droid[bot]@users.noreply.github.com" + + # Daily batch branch - one branch per day, multiple commits accumulate + BRANCH_NAME="docs/auto-update-$(date +%Y-%m-%d)" + + # Check if branch already exists on remote + if git ls-remote --exit-code --heads origin "$BRANCH_NAME" > /dev/null 2>&1; then + echo "Branch $BRANCH_NAME exists, checking out and updating..." + git fetch origin "$BRANCH_NAME" + git checkout -B "$BRANCH_NAME" "origin/$BRANCH_NAME" + else + echo "Creating new branch $BRANCH_NAME..." + git checkout -b "$BRANCH_NAME" + fi + + # Stage and commit + git add docs/src/ + SUMMARY=$(head -50 < /tmp/phase6-summary.md) + git commit -m "docs: auto-update documentation + + ${SUMMARY} + + Triggered by: ${{ steps.changed.outputs.source }} ${{ steps.changed.outputs.ref }} + + Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>" + + # Push + git push -u origin "$BRANCH_NAME" + + # Check if PR already exists for this branch + EXISTING_PR=$(gh pr list --head "$BRANCH_NAME" --json number --jq '.[0].number' || echo "") + + if [ -n "$EXISTING_PR" ]; then + echo "PR #$EXISTING_PR already exists for branch $BRANCH_NAME, updated with new commit" + else + # Create new PR + gh pr create \ + --title "docs: automated documentation update ($(date +%Y-%m-%d))" \ + --body-file /tmp/phase6-summary.md \ + --base main || true + echo "PR created on branch: $BRANCH_NAME" + fi + env: + GH_TOKEN: ${{ github.token }} + + # Summary output + - name: "Summary" + if: always() + run: | + echo "## Documentation Automation Summary" >> "$GITHUB_STEP_SUMMARY" + echo "" >> "$GITHUB_STEP_SUMMARY" + + if [ "${{ steps.phase4.outputs.updates_required }}" == "false" ]; then + echo "No documentation updates required for this change." >> "$GITHUB_STEP_SUMMARY" + elif [ -f /tmp/phase6-summary.md ]; then + cat /tmp/phase6-summary.md >> "$GITHUB_STEP_SUMMARY" + else + echo "Workflow completed. Check individual phase outputs for details." >> "$GITHUB_STEP_SUMMARY" + fi diff --git a/docs/AGENTS.md b/docs/AGENTS.md new file mode 100644 index 0000000000000000000000000000000000000000..fdd61ff6aeaf8cd09ae0b017c5199e7033fba964 --- /dev/null +++ b/docs/AGENTS.md @@ -0,0 +1,353 @@ +# Documentation Automation Agent Guidelines + +This file governs automated documentation updates triggered by code changes. All automation phases must comply with these rules. + +## Documentation System + +This documentation uses **mdBook** (https://rust-lang.github.io/mdBook/). + +### Key Files + +- **`docs/src/SUMMARY.md`**: Table of contents following mdBook format (https://rust-lang.github.io/mdBook/format/summary.html) +- **`docs/book.toml`**: mdBook configuration +- **`docs/.prettierrc`**: Prettier config (80 char line width) + +### SUMMARY.md Format + +The `SUMMARY.md` file defines the book structure. Format rules: + +- Chapter titles are links: `[Title](./path/to/file.md)` +- Nesting via indentation (2 spaces per level) +- Separators: `---` for horizontal rules between sections +- Draft chapters: `[Title]()` (empty parens, not yet written) + +Example: + +```markdown +# Section Title + +- [Chapter](./chapter.md) + - [Nested Chapter](./nested.md) + +--- + +# Another Section +``` + +### Custom Preprocessor + +The docs use a custom preprocessor (`docs_preprocessor`) that expands special commands: + +| Syntax | Purpose | Example | +| ----------------------------- | ------------------------------------- | ------------------------------- | +| `{#kb action::ActionName}` | Keybinding for action | `{#kb agent::ToggleFocus}` | +| `{#action agent::ActionName}` | Action reference (renders as command) | `{#action agent::OpenSettings}` | + +**Rules:** + +- Always use preprocessor syntax for keybindings instead of hardcoding +- Action names use `snake_case` in the namespace, `PascalCase` for the action +- Common namespaces: `agent::`, `editor::`, `assistant::`, `vim::` + +### Formatting Requirements + +All documentation must pass **Prettier** formatting: + +```sh +cd docs && npx prettier --check src/ +``` + +Before any documentation change is considered complete: + +1. Run Prettier to format: `cd docs && npx prettier --write src/` +2. Verify it passes: `cd docs && npx prettier --check src/` + +Prettier config: 80 character line width (`docs/.prettierrc`) + +### Section Anchors + +Use `{#anchor-id}` syntax for linkable section headers: + +```markdown +## Getting Started {#getting-started} + +### Custom Models {#anthropic-custom-models} +``` + +Anchor IDs should be: + +- Lowercase with hyphens +- Unique within the page +- Descriptive (can include parent context like `anthropic-custom-models`) + +### Code Block Annotations + +Use annotations after the language identifier to indicate file context: + +```markdown +\`\`\`json [settings] +{ +"agent": { ... } +} +\`\`\` + +\`\`\`json [keymap] +[ +{ "bindings": { ... } } +] +\`\`\` +``` + +Valid annotations: `[settings]` (for settings.json), `[keymap]` (for keymap.json) + +### Blockquote Formatting + +Use bold labels for callouts: + +```markdown +> **Note:** Important information the user should know. + +> **Tip:** Helpful advice that saves time or improves workflow. + +> **Warn:** Caution about potential issues or gotchas. +``` + +### Image References + +Images are hosted externally. Reference format: + +```markdown +![Alt text description](https://zed.dev/img/path/to/image.webp) +``` + +### Cross-Linking + +- Relative links for same-directory: `[Agent Panel](./agent-panel.md)` +- With anchors: `[Custom Models](./llm-providers.md#anthropic-custom-models)` +- Parent directory: `[Telemetry](../telemetry.md)` + +## Scope + +### In-Scope Documentation + +- All Markdown files in `docs/src/` +- `docs/src/SUMMARY.md` (mdBook table of contents) +- Language-specific docs in `docs/src/languages/` +- Feature docs (AI, extensions, configuration, etc.) + +### Out-of-Scope (Do Not Modify) + +- `CHANGELOG.md`, `CONTRIBUTING.md`, `README.md` at repo root +- Inline code comments and rustdoc +- `CLAUDE.md`, `GEMINI.md`, or other AI instruction files +- Build configuration (`book.toml`, theme files, `docs_preprocessor`) +- Any file outside `docs/src/` + +## Page Structure Patterns + +### Standard Page Layout + +Most documentation pages follow this structure: + +1. **Title** (H1) - Single sentence or phrase +2. **Overview/Introduction** - 1-3 paragraphs explaining what this is +3. **Getting Started** `{#getting-started}` - Prerequisites and first steps +4. **Main Content** - Feature details, organized by topic +5. **Advanced/Configuration** - Power user options +6. **See Also** (optional) - Related documentation links + +### Settings Documentation Pattern + +When documenting settings: + +1. Show the Settings Editor (UI) approach first +2. Then show JSON as "Or add this to your settings.json:" +3. Always show complete, valid JSON with surrounding structure: + +```json [settings] +{ + "agent": { + "default_model": { + "provider": "anthropic", + "model": "claude-sonnet-4" + } + } +} +``` + +### Provider/Feature Documentation Pattern + +For each provider or distinct feature: + +1. H3 heading with anchor: `### Provider Name {#provider-name}` +2. Brief description (1-2 sentences) +3. Setup steps (numbered list) +4. Configuration example (JSON code block) +5. Custom models section if applicable: `#### Custom Models {#provider-custom-models}` + +## Style Rules + +Inherit all conventions from `docs/.rules`. Key points: + +### Voice + +- Second person ("you"), present tense +- Direct and concise—no hedging ("simply", "just", "easily") +- Honest about limitations; no promotional language + +### Formatting + +- Keybindings: backticks with `+` for simultaneous keys (`Cmd+Shift+P`) +- Show both macOS and Linux/Windows variants when they differ +- Use `sh` code blocks for terminal commands +- Settings: show Settings Editor UI first, JSON as secondary + +### Terminology + +| Use | Instead of | +| --------------- | -------------------------------------- | +| folder | directory | +| project | workspace | +| Settings Editor | settings UI | +| command palette | command bar | +| panel | sidebar (be specific: "Project Panel") | + +## Zed-Specific Conventions + +### Recognized Rules Files + +When documenting rules/instructions for AI, note that Zed recognizes these files (in priority order): + +- `.rules` +- `.cursorrules` +- `.windsurfrules` +- `.clinerules` +- `.github/copilot-instructions.md` +- `AGENT.md` +- `AGENTS.md` +- `CLAUDE.md` +- `GEMINI.md` + +### Settings File Locations + +- macOS: `~/.config/zed/settings.json` +- Linux: `~/.config/zed/settings.json` +- Windows: `%AppData%\Zed\settings.json` + +### Keymap File Locations + +- macOS: `~/.config/zed/keymap.json` +- Linux: `~/.config/zed/keymap.json` +- Windows: `%AppData%\Zed\keymap.json` + +## Safety Constraints + +### Must Not + +- Delete existing documentation files +- Remove sections documenting existing functionality +- Change URLs or anchor links without verifying references +- Modify `SUMMARY.md` structure without corresponding content +- Add speculative documentation for unreleased features +- Include internal implementation details not relevant to users + +### Must + +- Preserve existing structure when updating content +- Maintain backward compatibility of documented settings/commands +- Flag uncertainty explicitly rather than guessing +- Link to related documentation when adding new sections + +## Change Classification + +### Requires Documentation Update + +- New user-facing features or commands +- Changed keybindings or default behaviors +- Modified settings schema or options +- Deprecated or removed functionality +- API changes affecting extensions + +### Does Not Require Documentation Update + +- Internal refactoring without behavioral changes +- Performance optimizations (unless user-visible) +- Bug fixes that restore documented behavior +- Test changes +- CI/CD changes + +## Output Format + +### Phase 4 Documentation Plan + +When generating a documentation plan, use this structure: + +```markdown +## Documentation Impact Assessment + +### Summary + +Brief description of code changes analyzed. + +### Documentation Updates Required: [Yes/No] + +### Planned Changes + +#### 1. [File Path] + +- **Section**: [Section name or "New section"] +- **Change Type**: [Update/Add/Deprecate] +- **Reason**: Why this change is needed +- **Description**: What will be added/modified + +#### 2. [File Path] + +... + +### Uncertainty Flags + +- [ ] [Description of any assumptions or areas needing confirmation] + +### No Changes Needed + +- [List files reviewed but not requiring updates, with brief reason] +``` + +### Phase 6 Summary Format + +```markdown +## Documentation Update Summary + +### Changes Made + +| File | Change | Related Code | +| -------------- | ----------------- | ----------------- | +| path/to/doc.md | Brief description | link to PR/commit | + +### Rationale + +Brief explanation of why these updates were made. + +### Review Notes + +Any items reviewers should pay special attention to. +``` + +## Behavioral Guidelines + +### Conservative by Default + +- When uncertain whether to document something, flag it for human review +- Prefer smaller, focused updates over broad rewrites +- Do not "improve" documentation unrelated to the triggering code change + +### Traceability + +- Every documentation change should trace to a specific code change +- Include references to relevant commits, PRs, or issues in summaries + +### Incremental Updates + +- Update existing sections rather than creating parallel documentation +- Maintain consistency with surrounding content +- Follow the established patterns in each documentation area From 4ef5d2c8148e555388668b094e059633c5bc405a Mon Sep 17 00:00:00 2001 From: Andrew Farkas <6060305+HactarCE@users.noreply.github.com> Date: Fri, 19 Dec 2025 12:32:38 -0500 Subject: [PATCH 559/621] Fix relative line numbers in sticky headers (#45164) Closes #42586 This includes a rewrite of `calculate_relative_line_numbers()`. Now it's linear-time with respect to the number of rows displayed, instead of linear time with respect to the number of rows displayed _plus_ the distance to the base row. Release Notes: - Improved performance when using relative line numbers in large files - Fixed relative line numbers not appearing in sticky headers --- crates/editor/src/editor.rs | 66 ++++++++++- crates/editor/src/editor_tests.rs | 127 ++++++++++++++++++++- crates/editor/src/element.rs | 176 ++++++++++++------------------ 3 files changed, 258 insertions(+), 111 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 6e4744335b8e9fba50a6c2c8b241607b0e05d276..d985a4d269f2eaeb3fa6056192095b7913b579b6 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -20475,7 +20475,7 @@ impl Editor { EditorSettings::get_global(cx).gutter.line_numbers } - pub fn relative_line_numbers(&self, cx: &mut App) -> RelativeLineNumbers { + pub fn relative_line_numbers(&self, cx: &App) -> RelativeLineNumbers { match ( self.use_relative_line_numbers, EditorSettings::get_global(cx).relative_line_numbers, @@ -25294,6 +25294,70 @@ impl EditorSnapshot { let digit_count = self.widest_line_number().ilog10() + 1; column_pixels(style, digit_count as usize, window) } + + /// Returns the line delta from `base` to `line` in the multibuffer, ignoring wrapped lines. + /// + /// This is positive if `base` is before `line`. + fn relative_line_delta(&self, base: DisplayRow, line: DisplayRow) -> i64 { + let point = DisplayPoint::new(line, 0).to_point(self); + self.relative_line_delta_to_point(base, point) + } + + /// Returns the line delta from `base` to `point` in the multibuffer, ignoring wrapped lines. + /// + /// This is positive if `base` is before `point`. + pub fn relative_line_delta_to_point(&self, base: DisplayRow, point: Point) -> i64 { + let base_point = DisplayPoint::new(base, 0).to_point(self); + point.row as i64 - base_point.row as i64 + } + + /// Returns the line delta from `base` to `line` in the multibuffer, counting wrapped lines. + /// + /// This is positive if `base` is before `line`. + fn relative_wrapped_line_delta(&self, base: DisplayRow, line: DisplayRow) -> i64 { + let point = DisplayPoint::new(line, 0).to_point(self); + self.relative_wrapped_line_delta_to_point(base, point) + } + + /// Returns the line delta from `base` to `point` in the multibuffer, counting wrapped lines. + /// + /// This is positive if `base` is before `point`. + pub fn relative_wrapped_line_delta_to_point(&self, base: DisplayRow, point: Point) -> i64 { + let base_point = DisplayPoint::new(base, 0).to_point(self); + let wrap_snapshot = self.wrap_snapshot(); + let base_wrap_row = wrap_snapshot.make_wrap_point(base_point, Bias::Left).row(); + let wrap_row = wrap_snapshot.make_wrap_point(point, Bias::Left).row(); + wrap_row.0 as i64 - base_wrap_row.0 as i64 + } + + /// Returns the unsigned relative line number to display for each row in `rows`. + /// + /// Wrapped rows are excluded from the hashmap if `count_relative_lines` is `false`. + pub fn calculate_relative_line_numbers( + &self, + rows: &Range, + relative_to: DisplayRow, + count_wrapped_lines: bool, + ) -> HashMap { + let initial_offset = if count_wrapped_lines { + self.relative_wrapped_line_delta(relative_to, rows.start) + } else { + self.relative_line_delta(relative_to, rows.start) + }; + let display_row_infos = self + .row_infos(rows.start) + .take(rows.len()) + .enumerate() + .map(|(i, row_info)| (DisplayRow(rows.start.0 + i as u32), row_info)); + display_row_infos + .filter(|(_row, row_info)| { + row_info.buffer_row.is_some() + || (count_wrapped_lines && row_info.wrapped_buffer_row.is_some()) + }) + .enumerate() + .map(|(i, (row, _row_info))| (row, (initial_offset + i as i64).unsigned_abs() as u32)) + .collect() + } } pub fn column_pixels(style: &EditorStyle, column: usize, window: &Window) -> Pixels { diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rs index 87674d8c507b1c294779b1f9ddba458320fc7671..613850428a8720ed37efa447a1312c262a05571a 100644 --- a/crates/editor/src/editor_tests.rs +++ b/crates/editor/src/editor_tests.rs @@ -36,7 +36,8 @@ use languages::markdown_lang; use languages::rust_lang; use lsp::CompletionParams; use multi_buffer::{ - IndentGuide, MultiBufferFilterMode, MultiBufferOffset, MultiBufferOffsetUtf16, PathKey, + ExcerptRange, IndentGuide, MultiBuffer, MultiBufferFilterMode, MultiBufferOffset, + MultiBufferOffsetUtf16, PathKey, }; use parking_lot::Mutex; use pretty_assertions::{assert_eq, assert_ne}; @@ -28633,6 +28634,130 @@ async fn test_sticky_scroll(cx: &mut TestAppContext) { assert_eq!(sticky_headers(10.0), vec![]); } +#[gpui::test] +fn test_relative_line_numbers(cx: &mut TestAppContext) { + init_test(cx, |_| {}); + + let buffer_1 = cx.new(|cx| Buffer::local("aaaaaaaaaa\nbbb\n", cx)); + let buffer_2 = cx.new(|cx| Buffer::local("cccccccccc\nddd\n", cx)); + let buffer_3 = cx.new(|cx| Buffer::local("eee\nffffffffff\n", cx)); + + let multibuffer = cx.new(|cx| { + let mut multibuffer = MultiBuffer::new(ReadWrite); + multibuffer.push_excerpts( + buffer_1.clone(), + [ExcerptRange::new(Point::new(0, 0)..Point::new(2, 0))], + cx, + ); + multibuffer.push_excerpts( + buffer_2.clone(), + [ExcerptRange::new(Point::new(0, 0)..Point::new(2, 0))], + cx, + ); + multibuffer.push_excerpts( + buffer_3.clone(), + [ExcerptRange::new(Point::new(0, 0)..Point::new(2, 0))], + cx, + ); + multibuffer + }); + + // wrapped contents of multibuffer: + // aaa + // aaa + // aaa + // a + // bbb + // + // ccc + // ccc + // ccc + // c + // ddd + // + // eee + // fff + // fff + // fff + // f + + let (editor, cx) = cx.add_window_view(|window, cx| build_editor(multibuffer, window, cx)); + editor.update_in(cx, |editor, window, cx| { + editor.set_wrap_width(Some(30.0.into()), cx); // every 3 characters + + // includes trailing newlines. + let expected_line_numbers = [2, 6, 7, 10, 14, 15, 18, 19, 23]; + let expected_wrapped_line_numbers = [ + 2, 3, 4, 5, 6, 7, 10, 11, 12, 13, 14, 15, 18, 19, 20, 21, 22, 23, + ]; + + editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| { + s.select_ranges([ + Point::new(7, 0)..Point::new(7, 1), // second row of `ccc` + ]); + }); + + let snapshot = editor.snapshot(window, cx); + + // these are all 0-indexed + let base_display_row = DisplayRow(11); + let base_row = 3; + let wrapped_base_row = 7; + + // test not counting wrapped lines + let expected_relative_numbers = expected_line_numbers + .into_iter() + .enumerate() + .map(|(i, row)| (DisplayRow(row), i.abs_diff(base_row) as u32)) + .collect_vec(); + let actual_relative_numbers = snapshot + .calculate_relative_line_numbers( + &(DisplayRow(0)..DisplayRow(24)), + base_display_row, + false, + ) + .into_iter() + .sorted() + .collect_vec(); + assert_eq!(expected_relative_numbers, actual_relative_numbers); + // check `calculate_relative_line_numbers()` against `relative_line_delta()` for each line + for (display_row, relative_number) in expected_relative_numbers { + assert_eq!( + relative_number, + snapshot + .relative_line_delta(display_row, base_display_row) + .unsigned_abs() as u32, + ); + } + + // test counting wrapped lines + let expected_wrapped_relative_numbers = expected_wrapped_line_numbers + .into_iter() + .enumerate() + .map(|(i, row)| (DisplayRow(row), i.abs_diff(wrapped_base_row) as u32)) + .collect_vec(); + let actual_relative_numbers = snapshot + .calculate_relative_line_numbers( + &(DisplayRow(0)..DisplayRow(24)), + base_display_row, + true, + ) + .into_iter() + .sorted() + .collect_vec(); + assert_eq!(expected_wrapped_relative_numbers, actual_relative_numbers); + // check `calculate_relative_line_numbers()` against `relative_wrapped_line_delta()` for each line + for (display_row, relative_number) in expected_wrapped_relative_numbers { + assert_eq!( + relative_number, + snapshot + .relative_wrapped_line_delta(display_row, base_display_row) + .unsigned_abs() as u32, + ); + } + }); +} + #[gpui::test] async fn test_scroll_by_clicking_sticky_header(cx: &mut TestAppContext) { init_test(cx, |_| {}); diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index 4c3b44335bcad10be4303d545a8d2ad505938098..b2e355dc5158214eabd07d519649591be8a325a8 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -66,7 +66,7 @@ use project::{ }; use settings::{ GitGutterSetting, GitHunkStyleSetting, IndentGuideBackgroundColoring, IndentGuideColoring, - Settings, + RelativeLineNumbers, Settings, }; use smallvec::{SmallVec, smallvec}; use std::{ @@ -194,8 +194,6 @@ pub struct EditorElement { style: EditorStyle, } -type DisplayRowDelta = u32; - impl EditorElement { pub(crate) const SCROLLBAR_WIDTH: Pixels = px(15.); @@ -3225,64 +3223,6 @@ impl EditorElement { .collect() } - fn calculate_relative_line_numbers( - &self, - snapshot: &EditorSnapshot, - rows: &Range, - relative_to: Option, - count_wrapped_lines: bool, - ) -> HashMap { - let mut relative_rows: HashMap = Default::default(); - let Some(relative_to) = relative_to else { - return relative_rows; - }; - - let start = rows.start.min(relative_to); - let end = rows.end.max(relative_to); - - let buffer_rows = snapshot - .row_infos(start) - .take(1 + end.minus(start) as usize) - .collect::>(); - - let head_idx = relative_to.minus(start); - let mut delta = 1; - let mut i = head_idx + 1; - let should_count_line = |row_info: &RowInfo| { - if count_wrapped_lines { - row_info.buffer_row.is_some() || row_info.wrapped_buffer_row.is_some() - } else { - row_info.buffer_row.is_some() - } - }; - while i < buffer_rows.len() as u32 { - if should_count_line(&buffer_rows[i as usize]) { - if rows.contains(&DisplayRow(i + start.0)) { - relative_rows.insert(DisplayRow(i + start.0), delta); - } - delta += 1; - } - i += 1; - } - delta = 1; - i = head_idx.min(buffer_rows.len().saturating_sub(1) as u32); - while i > 0 && buffer_rows[i as usize].buffer_row.is_none() && !count_wrapped_lines { - i -= 1; - } - - while i > 0 { - i -= 1; - if should_count_line(&buffer_rows[i as usize]) { - if rows.contains(&DisplayRow(i + start.0)) { - relative_rows.insert(DisplayRow(i + start.0), delta); - } - delta += 1; - } - } - - relative_rows - } - fn layout_line_numbers( &self, gutter_hitbox: Option<&Hitbox>, @@ -3292,7 +3232,7 @@ impl EditorElement { rows: Range, buffer_rows: &[RowInfo], active_rows: &BTreeMap, - newest_selection_head: Option, + relative_line_base: Option, snapshot: &EditorSnapshot, window: &mut Window, cx: &mut App, @@ -3304,32 +3244,16 @@ impl EditorElement { return Arc::default(); } - let (newest_selection_head, relative) = self.editor.update(cx, |editor, cx| { - let newest_selection_head = newest_selection_head.unwrap_or_else(|| { - let newest = editor - .selections - .newest::(&editor.display_snapshot(cx)); - SelectionLayout::new( - newest, - editor.selections.line_mode(), - editor.cursor_offset_on_selection, - editor.cursor_shape, - &snapshot.display_snapshot, - true, - true, - None, - ) - .head - }); - let relative = editor.relative_line_numbers(cx); - (newest_selection_head, relative) - }); + let relative = self.editor.read(cx).relative_line_numbers(cx); let relative_line_numbers_enabled = relative.enabled(); - let relative_to = relative_line_numbers_enabled.then(|| newest_selection_head.row()); + let relative_rows = if relative_line_numbers_enabled && let Some(base) = relative_line_base + { + snapshot.calculate_relative_line_numbers(&rows, base, relative.wrapped()) + } else { + Default::default() + }; - let relative_rows = - self.calculate_relative_line_numbers(snapshot, &rows, relative_to, relative.wrapped()); let mut line_number = String::new(); let segments = buffer_rows.iter().enumerate().flat_map(|(ix, row_info)| { let display_row = DisplayRow(rows.start.0 + ix as u32); @@ -4652,6 +4576,8 @@ impl EditorElement { gutter_hitbox: &Hitbox, text_hitbox: &Hitbox, style: &EditorStyle, + relative_line_numbers: RelativeLineNumbers, + relative_to: Option, window: &mut Window, cx: &mut App, ) -> Option { @@ -4681,9 +4607,21 @@ impl EditorElement { ); let line_number = show_line_numbers.then(|| { - let number = (start_point.row + 1).to_string(); + let relative_number = relative_to.and_then(|base| match relative_line_numbers { + RelativeLineNumbers::Disabled => None, + RelativeLineNumbers::Enabled => { + Some(snapshot.relative_line_delta_to_point(base, start_point)) + } + RelativeLineNumbers::Wrapped => { + Some(snapshot.relative_wrapped_line_delta_to_point(base, start_point)) + } + }); + let number = relative_number + .filter(|&delta| delta != 0) + .map(|delta| delta.unsigned_abs() as u32) + .unwrap_or(start_point.row + 1); let color = cx.theme().colors().editor_line_number; - self.shape_line_number(SharedString::from(number), color, window) + self.shape_line_number(SharedString::from(number.to_string()), color, window) }); lines.push(StickyHeaderLine::new( @@ -9436,6 +9374,28 @@ impl Element for EditorElement { window, cx, ); + + // relative rows are based on newest selection, even outside the visible area + let relative_row_base = self.editor.update(cx, |editor, cx| { + if editor.selections.count()==0 { + return None; + } + let newest = editor + .selections + .newest::(&editor.display_snapshot(cx)); + Some(SelectionLayout::new( + newest, + editor.selections.line_mode(), + editor.cursor_offset_on_selection, + editor.cursor_shape, + &snapshot.display_snapshot, + true, + true, + None, + ) + .head.row()) + }); + let mut breakpoint_rows = self.editor.update(cx, |editor, cx| { editor.active_breakpoints(start_row..end_row, window, cx) }); @@ -9453,7 +9413,7 @@ impl Element for EditorElement { start_row..end_row, &row_infos, &active_rows, - newest_selection_head, + relative_row_base, &snapshot, window, cx, @@ -9773,6 +9733,7 @@ impl Element for EditorElement { && is_singleton && EditorSettings::get_global(cx).sticky_scroll.enabled { + let relative = self.editor.read(cx).relative_line_numbers(cx); self.layout_sticky_headers( &snapshot, editor_width, @@ -9784,6 +9745,8 @@ impl Element for EditorElement { &gutter_hitbox, &text_hitbox, &style, + relative, + relative_row_base, window, cx, ) @@ -11631,7 +11594,7 @@ mod tests { } #[gpui::test] - fn test_shape_line_numbers(cx: &mut TestAppContext) { + fn test_layout_line_numbers(cx: &mut TestAppContext) { init_test(cx, |_| {}); let window = cx.add_window(|window, cx| { let buffer = MultiBuffer::build_simple(&sample_text(6, 6, 'a'), cx); @@ -11671,7 +11634,7 @@ mod tests { }) .collect::>(), &BTreeMap::default(), - Some(DisplayPoint::new(DisplayRow(0), 0)), + Some(DisplayRow(0)), &snapshot, window, cx, @@ -11683,10 +11646,9 @@ mod tests { let relative_rows = window .update(cx, |editor, window, cx| { let snapshot = editor.snapshot(window, cx); - element.calculate_relative_line_numbers( - &snapshot, + snapshot.calculate_relative_line_numbers( &(DisplayRow(0)..DisplayRow(6)), - Some(DisplayRow(3)), + DisplayRow(3), false, ) }) @@ -11702,10 +11664,9 @@ mod tests { let relative_rows = window .update(cx, |editor, window, cx| { let snapshot = editor.snapshot(window, cx); - element.calculate_relative_line_numbers( - &snapshot, + snapshot.calculate_relative_line_numbers( &(DisplayRow(3)..DisplayRow(6)), - Some(DisplayRow(1)), + DisplayRow(1), false, ) }) @@ -11719,10 +11680,9 @@ mod tests { let relative_rows = window .update(cx, |editor, window, cx| { let snapshot = editor.snapshot(window, cx); - element.calculate_relative_line_numbers( - &snapshot, + snapshot.calculate_relative_line_numbers( &(DisplayRow(0)..DisplayRow(3)), - Some(DisplayRow(6)), + DisplayRow(6), false, ) }) @@ -11759,7 +11719,7 @@ mod tests { }) .collect::>(), &BTreeMap::default(), - Some(DisplayPoint::new(DisplayRow(0), 0)), + Some(DisplayRow(0)), &snapshot, window, cx, @@ -11774,7 +11734,7 @@ mod tests { } #[gpui::test] - fn test_shape_line_numbers_wrapping(cx: &mut TestAppContext) { + fn test_layout_line_numbers_wrapping(cx: &mut TestAppContext) { init_test(cx, |_| {}); let window = cx.add_window(|window, cx| { let buffer = MultiBuffer::build_simple(&sample_text(6, 6, 'a'), cx); @@ -11819,7 +11779,7 @@ mod tests { }) .collect::>(), &BTreeMap::default(), - Some(DisplayPoint::new(DisplayRow(0), 0)), + Some(DisplayRow(0)), &snapshot, window, cx, @@ -11831,10 +11791,9 @@ mod tests { let relative_rows = window .update(cx, |editor, window, cx| { let snapshot = editor.snapshot(window, cx); - element.calculate_relative_line_numbers( - &snapshot, + snapshot.calculate_relative_line_numbers( &(DisplayRow(0)..DisplayRow(6)), - Some(DisplayRow(3)), + DisplayRow(3), true, ) }) @@ -11871,7 +11830,7 @@ mod tests { }) .collect::>(), &BTreeMap::from_iter([(DisplayRow(0), LineHighlightSpec::default())]), - Some(DisplayPoint::new(DisplayRow(0), 0)), + Some(DisplayRow(0)), &snapshot, window, cx, @@ -11886,10 +11845,9 @@ mod tests { let relative_rows = window .update(cx, |editor, window, cx| { let snapshot = editor.snapshot(window, cx); - element.calculate_relative_line_numbers( - &snapshot, + snapshot.calculate_relative_line_numbers( &(DisplayRow(0)..DisplayRow(6)), - Some(DisplayRow(3)), + DisplayRow(3), true, ) }) From b53f661515af405c339400fda585e2372b96bb1b Mon Sep 17 00:00:00 2001 From: morgankrey Date: Fri, 19 Dec 2025 11:53:39 -0600 Subject: [PATCH 560/621] docs: Fix auto docs GitHub Action (#45383) Small fixes to Droid workflow Release Notes: - N/A --------- Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> --- .github/workflows/docs_automation.yml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docs_automation.yml b/.github/workflows/docs_automation.yml index e4aa79c7fc09d6d7735ac82e2315d68b923d5323..bf0d27ba632e72eb79253c602bf6363bd5fa8e79 100644 --- a/.github/workflows/docs_automation.yml +++ b/.github/workflows/docs_automation.yml @@ -37,9 +37,13 @@ jobs: fetch-depth: 0 - name: Install Droid CLI + id: install-droid run: | curl -fsSL https://cli.factory.ai/install.sh | bash echo "${HOME}/.factory/bin" >> "$GITHUB_PATH" + echo "DROID_BIN=${HOME}/.factory/bin/droid" >> "$GITHUB_ENV" + # Verify installation + "${HOME}/.factory/bin/droid" --version - name: Setup Node.js (for Prettier) uses: actions/setup-node@v4 @@ -85,7 +89,7 @@ jobs: - name: "Phase 2: Explore Repository" id: phase2 run: | - droid exec \ + "$DROID_BIN" exec \ --model "$DROID_MODEL" \ --autonomy read-only \ --prompt-file .factory/prompts/docs-automation/phase2-explore.md \ @@ -99,7 +103,7 @@ jobs: id: phase3 run: | CHANGED_FILES=$(tr '\n' ' ' < /tmp/changed_files.txt) - droid exec \ + "$DROID_BIN" exec \ --model "$DROID_MODEL" \ --autonomy read-only \ --prompt-file .factory/prompts/docs-automation/phase3-analyze.md \ @@ -114,7 +118,7 @@ jobs: - name: "Phase 4: Plan Documentation Impact" id: phase4 run: | - droid exec \ + "$DROID_BIN" exec \ --model "$DROID_MODEL" \ --autonomy read-only \ --prompt-file .factory/prompts/docs-automation/phase4-plan.md \ @@ -137,7 +141,7 @@ jobs: id: phase5 if: steps.phase4.outputs.updates_required == 'true' run: | - droid exec \ + "$DROID_BIN" exec \ --model "$DROID_MODEL" \ --autonomy medium \ --prompt-file .factory/prompts/docs-automation/phase5-apply.md \ @@ -170,7 +174,7 @@ jobs: # Get git diff of docs git diff docs/src/ > /tmp/docs-diff.txt || true - droid exec \ + "$DROID_BIN" exec \ --model "$DROID_MODEL" \ --autonomy read-only \ --prompt-file .factory/prompts/docs-automation/phase6-summarize.md \ From 1edd050baf20cfde8bfc8885d632ab163b302370 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Raz=20Guzm=C3=A1n=20Macedo?= Date: Fri, 19 Dec 2025 12:09:40 -0600 Subject: [PATCH 561/621] Add script/triage_watcher.jl (#45384) Release Notes: - N/A --- script/triage_watcher.jl | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 script/triage_watcher.jl diff --git a/script/triage_watcher.jl b/script/triage_watcher.jl new file mode 100644 index 0000000000000000000000000000000000000000..905d2fdd4eb73c7bcbed304f9d4d94d0d94943f2 --- /dev/null +++ b/script/triage_watcher.jl @@ -0,0 +1,38 @@ +## Triage Watcher v0.1 +# This is a small script to watch for new issues on the Zed repository and open them in a new browser tab interactively. +# +## Installing Julia +# +# You need Julia installed on your system: +# curl -fsSL https://install.julialang.org | sh +# +## Running this script: +# 1. It only works on Macos/Linux +# Open a new Julia repl with `julia` inside the `zed` repo +# 2. Paste the following code +# 3. Whenever you close your computer, just type the Up arrow on the REPL + enter to rerun the loop again to resume +function get_issues() + entries = filter(x -> occursin("state:needs triage", x), split(read(`gh issue list -L 10`, String), '\n')) + top = findfirst.('\t', entries) .- 1 + [entries[i][begin:top[i]] for i in eachindex(entries)] +end + +nums = get_issues(); +while true + new_nums = get_issues() + # Open each new issue in a new browser tab + for issue_num in setdiff(new_nums, nums) + url = "https://github.com/zed-industries/zed/issues/" * issue_num + println("\nOpening $url") + open_tab = `/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome $url` + try + sound_file = "/Users/mrg/Downloads/mario_coin_sound.mp3" + run(`afplay -v 0.02 $sound_file`) + finally + end + run(open_tab) + end + nums = new_nums + print("🧘🏼") + sleep(60) +end From 22916311cd2b7d98d89d1ba72b5a567373472e2d Mon Sep 17 00:00:00 2001 From: morgankrey Date: Fri, 19 Dec 2025 12:12:14 -0600 Subject: [PATCH 562/621] ci: Fix Factory CLI installation URL (#45386) Change from cli.factory.ai/install.sh to app.factory.ai/cli per official Factory documentation. Release Notes: - N/A Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> --- .github/workflows/docs_automation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs_automation.yml b/.github/workflows/docs_automation.yml index bf0d27ba632e72eb79253c602bf6363bd5fa8e79..a59022e6f641fa5a351c29240fc6bdcc560228f5 100644 --- a/.github/workflows/docs_automation.yml +++ b/.github/workflows/docs_automation.yml @@ -39,7 +39,7 @@ jobs: - name: Install Droid CLI id: install-droid run: | - curl -fsSL https://cli.factory.ai/install.sh | bash + curl -fsSL https://app.factory.ai/cli | sh echo "${HOME}/.factory/bin" >> "$GITHUB_PATH" echo "DROID_BIN=${HOME}/.factory/bin/droid" >> "$GITHUB_ENV" # Verify installation From 1bc3fa81543f6159a5f607a9b01c83c2ae5c309a Mon Sep 17 00:00:00 2001 From: Ichimura Tomoo Date: Sat, 20 Dec 2025 03:18:20 +0900 Subject: [PATCH 563/621] Correct UTF-16 saving and add heuristic encoding detection (#45243) This commit fixes an issue where saving UTF-16 files resulted in UTF-8 bytes due to `encoding_rs` default behavior. It also introduces a heuristic to detect BOM-less UTF-16 and binary files. Changes: - Manually implement UTF-16LE/BE encoding during file save to avoid implicit UTF-8 conversion. - Add `analyze_byte_content` to guess UTF-16LE/BE or Binary based on null byte distribution. - Prevent loading binary files as text by returning an error when binary content is detected. Special thanks to @CrazyboyQCD for pointing out the `encoding_rs` behavior and providing the fix, and to @ConradIrwin for the suggestion on the detection heuristic. Closes #14654 Release Notes: - (nightly only) Fixed an issue where saving files with UTF-16 encoding incorrectly wrote them as UTF-8. Also improved detection for binary files and BOM-less UTF-16. --- crates/language/src/buffer.rs | 18 +- crates/worktree/src/worktree.rs | 140 +++++++++--- crates/worktree/src/worktree_tests.rs | 306 +++++++++++++++++--------- 3 files changed, 331 insertions(+), 133 deletions(-) diff --git a/crates/language/src/buffer.rs b/crates/language/src/buffer.rs index 99e0c8d4ebdad709eea0e9ab6dbdf9d889d54ec5..5f46340b41a876443f1d12724450d2d8b30f9b33 100644 --- a/crates/language/src/buffer.rs +++ b/crates/language/src/buffer.rs @@ -1490,19 +1490,23 @@ impl Buffer { let (tx, rx) = futures::channel::oneshot::channel(); let prev_version = self.text.version(); self.reload_task = Some(cx.spawn(async move |this, cx| { - let Some((new_mtime, new_text)) = this.update(cx, |this, cx| { + let Some((new_mtime, load_bytes_task, encoding)) = this.update(cx, |this, cx| { let file = this.file.as_ref()?.as_local()?; - - Some((file.disk_state().mtime(), file.load(cx))) + Some(( + file.disk_state().mtime(), + file.load_bytes(cx), + this.encoding, + )) })? else { return Ok(()); }; - let new_text = new_text.await?; - let diff = this - .update(cx, |this, cx| this.diff(new_text.clone(), cx))? - .await; + let bytes = load_bytes_task.await?; + let (cow, _encoding_used, _has_errors) = encoding.decode(&bytes); + let new_text = cow.into_owned(); + + let diff = this.update(cx, |this, cx| this.diff(new_text, cx))?.await; this.update(cx, |this, cx| { if this.version() == diff.base_version { this.finalize_last_transaction(); diff --git a/crates/worktree/src/worktree.rs b/crates/worktree/src/worktree.rs index 7145bccd514fbb5d6093efda765a826162c91260..f5f632e65d71b683d1a491b1fc9e9a612f5c24a5 100644 --- a/crates/worktree/src/worktree.rs +++ b/crates/worktree/src/worktree.rs @@ -1361,7 +1361,7 @@ impl LocalWorktree { } let content = fs.load_bytes(&abs_path).await?; - let (text, encoding, has_bom) = decode_byte(content); + let (text, encoding, has_bom) = decode_byte(content)?; let worktree = this.upgrade().context("worktree was dropped")?; let file = match entry.await? { @@ -1489,25 +1489,12 @@ impl LocalWorktree { let fs = fs.clone(); let abs_path = abs_path.clone(); async move { - let bom_bytes = if has_bom { - if encoding == encoding_rs::UTF_16LE { - vec![0xFF, 0xFE] - } else if encoding == encoding_rs::UTF_16BE { - vec![0xFE, 0xFF] - } else if encoding == encoding_rs::UTF_8 { - vec![0xEF, 0xBB, 0xBF] - } else { - vec![] - } - } else { - vec![] - }; - // For UTF-8, use the optimized `fs.save` which writes Rope chunks directly to disk // without allocating a contiguous string. if encoding == encoding_rs::UTF_8 && !has_bom { return fs.save(&abs_path, &text, line_ending).await; } + // For legacy encodings (e.g. Shift-JIS), we fall back to converting the entire Rope // to a String/Bytes in memory before writing. // @@ -1520,13 +1507,45 @@ impl LocalWorktree { LineEnding::Windows => text_string.replace('\n', "\r\n"), }; - let (cow, _, _) = encoding.encode(&normalized_text); - let bytes = if !bom_bytes.is_empty() { - let mut bytes = bom_bytes; - bytes.extend_from_slice(&cow); - bytes.into() + // Create the byte vector manually for UTF-16 encodings because encoding_rs encodes to UTF-8 by default (per WHATWG standards), + // which is not what we want for saving files. + let bytes = if encoding == encoding_rs::UTF_16BE { + let mut data = Vec::with_capacity(normalized_text.len() * 2 + 2); + if has_bom { + data.extend_from_slice(&[0xFE, 0xFF]); // BOM + } + let utf16be_bytes = + normalized_text.encode_utf16().flat_map(|u| u.to_be_bytes()); + data.extend(utf16be_bytes); + data.into() + } else if encoding == encoding_rs::UTF_16LE { + let mut data = Vec::with_capacity(normalized_text.len() * 2 + 2); + if has_bom { + data.extend_from_slice(&[0xFF, 0xFE]); // BOM + } + let utf16le_bytes = + normalized_text.encode_utf16().flat_map(|u| u.to_le_bytes()); + data.extend(utf16le_bytes); + data.into() } else { - cow + // For other encodings (Shift-JIS, UTF-8 with BOM, etc.), delegate to encoding_rs. + let bom_bytes = if has_bom { + if encoding == encoding_rs::UTF_8 { + vec![0xEF, 0xBB, 0xBF] + } else { + vec![] + } + } else { + vec![] + }; + let (cow, _, _) = encoding.encode(&normalized_text); + if !bom_bytes.is_empty() { + let mut bytes = bom_bytes; + bytes.extend_from_slice(&cow); + bytes.into() + } else { + cow + } }; fs.write(&abs_path, &bytes).await @@ -5842,11 +5861,28 @@ impl fs::Watcher for NullWatcher { } } -fn decode_byte(bytes: Vec) -> (String, &'static Encoding, bool) { +fn decode_byte(bytes: Vec) -> anyhow::Result<(String, &'static Encoding, bool)> { // check BOM if let Some((encoding, _bom_len)) = Encoding::for_bom(&bytes) { let (cow, _) = encoding.decode_with_bom_removal(&bytes); - return (cow.into_owned(), encoding, true); + return Ok((cow.into_owned(), encoding, true)); + } + + match analyze_byte_content(&bytes) { + ByteContent::Utf16Le => { + let encoding = encoding_rs::UTF_16LE; + let (cow, _, _) = encoding.decode(&bytes); + return Ok((cow.into_owned(), encoding, false)); + } + ByteContent::Utf16Be => { + let encoding = encoding_rs::UTF_16BE; + let (cow, _, _) = encoding.decode(&bytes); + return Ok((cow.into_owned(), encoding, false)); + } + ByteContent::Binary => { + anyhow::bail!("Binary files are not supported"); + } + ByteContent::Unknown => {} } fn detect_encoding(bytes: Vec) -> (String, &'static Encoding) { @@ -5867,14 +5903,66 @@ fn decode_byte(bytes: Vec) -> (String, &'static Encoding, bool) { // displaying raw escape sequences instead of the correct characters. if text.contains('\x1b') { let (s, enc) = detect_encoding(text.into_bytes()); - (s, enc, false) + Ok((s, enc, false)) } else { - (text, encoding_rs::UTF_8, false) + Ok((text, encoding_rs::UTF_8, false)) } } Err(e) => { let (s, enc) = detect_encoding(e.into_bytes()); - (s, enc, false) + Ok((s, enc, false)) } } } + +#[derive(PartialEq)] +enum ByteContent { + Utf16Le, + Utf16Be, + Binary, + Unknown, +} +// Heuristic check using null byte distribution. +// NOTE: This relies on the presence of ASCII characters (which become `0x00` in UTF-16). +// Files consisting purely of non-ASCII characters (like Japanese) may not be detected here +// and will result in `Unknown`. +fn analyze_byte_content(bytes: &[u8]) -> ByteContent { + if bytes.len() < 2 { + return ByteContent::Unknown; + } + + let check_len = bytes.len().min(1024); + let sample = &bytes[..check_len]; + + if !sample.contains(&0) { + return ByteContent::Unknown; + } + + let mut even_nulls = 0; + let mut odd_nulls = 0; + + for (i, &byte) in sample.iter().enumerate() { + if byte == 0 { + if i % 2 == 0 { + even_nulls += 1; + } else { + odd_nulls += 1; + } + } + } + + let total_nulls = even_nulls + odd_nulls; + if total_nulls < check_len / 10 { + return ByteContent::Unknown; + } + + if even_nulls > odd_nulls * 4 { + return ByteContent::Utf16Be; + } + + if odd_nulls > even_nulls * 4 { + return ByteContent::Utf16Le; + } + + ByteContent::Binary +} diff --git a/crates/worktree/src/worktree_tests.rs b/crates/worktree/src/worktree_tests.rs index 094a6d52ea4168752578eab06cea511a57e65c10..45d39710c6ea825aded4d29f447124ee4c2ecb33 100644 --- a/crates/worktree/src/worktree_tests.rs +++ b/crates/worktree/src/worktree_tests.rs @@ -1,5 +1,5 @@ use crate::{Entry, EntryKind, Event, PathChange, Worktree, WorktreeModelHandle}; -use anyhow::{Context as _, Result}; +use anyhow::Result; use encoding_rs; use fs::{FakeFs, Fs, RealFs, RemoveOptions}; use git::{DOT_GIT, GITIGNORE, REPO_EXCLUDE}; @@ -2568,71 +2568,87 @@ fn init_test(cx: &mut gpui::TestAppContext) { #[gpui::test] async fn test_load_file_encoding(cx: &mut TestAppContext) { init_test(cx); - let test_cases: Vec<(&str, &[u8], &str)> = vec![ - ("utf8.txt", "こんにちは".as_bytes(), "こんにちは"), // "こんにちは" is Japanese "Hello" - ( - "sjis.txt", - &[0x82, 0xb1, 0x82, 0xf1, 0x82, 0xc9, 0x82, 0xbf, 0x82, 0xcd], - "こんにちは", - ), - ( - "eucjp.txt", - &[0xa4, 0xb3, 0xa4, 0xf3, 0xa4, 0xcb, 0xa4, 0xc1, 0xa4, 0xcf], - "こんにちは", - ), - ( - "iso2022jp.txt", - &[ + + struct TestCase { + name: &'static str, + bytes: Vec, + expected_text: &'static str, + } + + // --- Success Cases --- + let success_cases = vec![ + TestCase { + name: "utf8.txt", + bytes: "こんにちは".as_bytes().to_vec(), + expected_text: "こんにちは", + }, + TestCase { + name: "sjis.txt", + bytes: vec![0x82, 0xb1, 0x82, 0xf1, 0x82, 0xc9, 0x82, 0xbf, 0x82, 0xcd], + expected_text: "こんにちは", + }, + TestCase { + name: "eucjp.txt", + bytes: vec![0xa4, 0xb3, 0xa4, 0xf3, 0xa4, 0xcb, 0xa4, 0xc1, 0xa4, 0xcf], + expected_text: "こんにちは", + }, + TestCase { + name: "iso2022jp.txt", + bytes: vec![ 0x1b, 0x24, 0x42, 0x24, 0x33, 0x24, 0x73, 0x24, 0x4b, 0x24, 0x41, 0x24, 0x4f, 0x1b, 0x28, 0x42, ], - "こんにちは", - ), - // Western Europe (Windows-1252) - // "Café" -> 0xE9 is 'é' in Windows-1252 (it is typically 0xC3 0xA9 in UTF-8) - ("win1252.txt", &[0x43, 0x61, 0x66, 0xe9], "Café"), - // Chinese Simplified (GBK) - // Note: We use a slightly longer string here because short byte sequences can be ambiguous - // in multi-byte encodings. Providing more context helps the heuristic detector guess correctly. - // Text: "今天天气不错" (Today's weather is not bad / nice) - // Bytes: - // 今: BD F1 - // 天: CC EC - // 天: CC EC - // 气: C6 F8 - // 不: B2 BB - // 错: B4 ED - ( - "gbk.txt", - &[ + expected_text: "こんにちは", + }, + TestCase { + name: "win1252.txt", + bytes: vec![0x43, 0x61, 0x66, 0xe9], + expected_text: "Café", + }, + TestCase { + name: "gbk.txt", + bytes: vec![ 0xbd, 0xf1, 0xcc, 0xec, 0xcc, 0xec, 0xc6, 0xf8, 0xb2, 0xbb, 0xb4, 0xed, ], - "今天天气不错", - ), - ( - "utf16le_bom.txt", - &[ + expected_text: "今天天气不错", + }, + // UTF-16LE with BOM + TestCase { + name: "utf16le_bom.txt", + bytes: vec![ 0xFF, 0xFE, // BOM - 0x53, 0x30, // こ - 0x93, 0x30, // ん - 0x6B, 0x30, // に - 0x61, 0x30, // ち - 0x6F, 0x30, // は + 0x53, 0x30, 0x93, 0x30, 0x6B, 0x30, 0x61, 0x30, 0x6F, 0x30, ], - "こんにちは", - ), - ( - "utf8_bom.txt", - &[ - 0xEF, 0xBB, 0xBF, // UTF-8 BOM - 0xE3, 0x81, 0x93, // こ - 0xE3, 0x82, 0x93, // ん - 0xE3, 0x81, 0xAB, // に - 0xE3, 0x81, 0xA1, // ち - 0xE3, 0x81, 0xAF, // は + expected_text: "こんにちは", + }, + // UTF-16BE with BOM + TestCase { + name: "utf16be_bom.txt", + bytes: vec![ + 0xFE, 0xFF, // BOM + 0x30, 0x53, 0x30, 0x93, 0x30, 0x6B, 0x30, 0x61, 0x30, 0x6F, ], - "こんにちは", - ), + expected_text: "こんにちは", + }, + // UTF-16LE without BOM (ASCII only) + // This relies on the "null byte heuristic" we implemented. + // "ABC" -> 41 00 42 00 43 00 + TestCase { + name: "utf16le_ascii_no_bom.txt", + bytes: vec![0x41, 0x00, 0x42, 0x00, 0x43, 0x00], + expected_text: "ABC", + }, + ]; + + // --- Failure Cases --- + let failure_cases = vec![ + // Binary File (Should be detected by heuristic and return Error) + // Contains random bytes and mixed nulls that don't match UTF-16 patterns + TestCase { + name: "binary.bin", + bytes: vec![0x00, 0xFF, 0x12, 0x00, 0x99, 0x88, 0x77, 0x66, 0x00], + expected_text: "", // Not used + }, ]; let root_path = if cfg!(windows) { @@ -2642,15 +2658,11 @@ async fn test_load_file_encoding(cx: &mut TestAppContext) { }; let fs = FakeFs::new(cx.background_executor.clone()); + fs.create_dir(root_path).await.unwrap(); - let mut files_json = serde_json::Map::new(); - for (name, _, _) in &test_cases { - files_json.insert(name.to_string(), serde_json::Value::String("".to_string())); - } - - for (name, bytes, _) in &test_cases { - let path = root_path.join(name); - fs.write(&path, bytes).await.unwrap(); + for case in success_cases.iter().chain(failure_cases.iter()) { + let path = root_path.join(case.name); + fs.write(&path, &case.bytes).await.unwrap(); } let tree = Worktree::local( @@ -2667,34 +2679,54 @@ async fn test_load_file_encoding(cx: &mut TestAppContext) { cx.read(|cx| tree.read(cx).as_local().unwrap().scan_complete()) .await; - for (name, _, expected) in test_cases { - let loaded = tree - .update(cx, |tree, cx| tree.load_file(rel_path(name), cx)) - .await - .with_context(|| format!("Failed to load {}", name)) - .unwrap(); + let rel_path = |name: &str| { + RelPath::new(&Path::new(name), PathStyle::local()) + .unwrap() + .into_arc() + }; + // Run Success Tests + for case in success_cases { + let loaded = tree + .update(cx, |tree, cx| tree.load_file(&rel_path(case.name), cx)) + .await; + if let Err(e) = &loaded { + panic!("Failed to load success case '{}': {:?}", case.name, e); + } + let loaded = loaded.unwrap(); assert_eq!( - loaded.text, expected, + loaded.text, case.expected_text, "Encoding mismatch for file: {}", - name + case.name ); } + + // Run Failure Tests + for case in failure_cases { + let loaded = tree + .update(cx, |tree, cx| tree.load_file(&rel_path(case.name), cx)) + .await; + assert!( + loaded.is_err(), + "Failure case '{}' unexpectedly succeeded! It should have been detected as binary.", + case.name + ); + let err_msg = loaded.unwrap_err().to_string(); + println!("Got expected error for {}: {}", case.name, err_msg); + } } #[gpui::test] async fn test_write_file_encoding(cx: &mut gpui::TestAppContext) { init_test(cx); let fs = FakeFs::new(cx.executor()); + let root_path = if cfg!(windows) { Path::new("C:\\root") } else { Path::new("/root") }; fs.create_dir(root_path).await.unwrap(); - let file_path = root_path.join("test.txt"); - - fs.insert_file(&file_path, "initial".into()).await; let worktree = Worktree::local( root_path, @@ -2707,33 +2739,107 @@ async fn test_write_file_encoding(cx: &mut gpui::TestAppContext) { .await .unwrap(); - let path: Arc = Path::new("test.txt").into(); - let rel_path = RelPath::new(&path, PathStyle::local()).unwrap().into_arc(); + // Define test case structure + struct TestCase { + name: &'static str, + text: &'static str, + encoding: &'static encoding_rs::Encoding, + has_bom: bool, + expected_bytes: Vec, + } - let text = text::Rope::from("こんにちは"); + let cases = vec![ + // Shift_JIS with Japanese + TestCase { + name: "Shift_JIS with Japanese", + text: "こんにちは", + encoding: encoding_rs::SHIFT_JIS, + has_bom: false, + expected_bytes: vec![0x82, 0xb1, 0x82, 0xf1, 0x82, 0xc9, 0x82, 0xbf, 0x82, 0xcd], + }, + // UTF-8 No BOM + TestCase { + name: "UTF-8 No BOM", + text: "AB", + encoding: encoding_rs::UTF_8, + has_bom: false, + expected_bytes: vec![0x41, 0x42], + }, + // UTF-8 with BOM + TestCase { + name: "UTF-8 with BOM", + text: "AB", + encoding: encoding_rs::UTF_8, + has_bom: true, + expected_bytes: vec![0xEF, 0xBB, 0xBF, 0x41, 0x42], + }, + // UTF-16LE No BOM with Japanese + // NOTE: This passes thanks to the manual encoding fix implemented in `write_file`. + TestCase { + name: "UTF-16LE No BOM with Japanese", + text: "こんにちは", + encoding: encoding_rs::UTF_16LE, + has_bom: false, + expected_bytes: vec![0x53, 0x30, 0x93, 0x30, 0x6b, 0x30, 0x61, 0x30, 0x6f, 0x30], + }, + // UTF-16LE with BOM + TestCase { + name: "UTF-16LE with BOM", + text: "A", + encoding: encoding_rs::UTF_16LE, + has_bom: true, + expected_bytes: vec![0xFF, 0xFE, 0x41, 0x00], + }, + // UTF-16BE No BOM with Japanese + // NOTE: This passes thanks to the manual encoding fix. + TestCase { + name: "UTF-16BE No BOM with Japanese", + text: "こんにちは", + encoding: encoding_rs::UTF_16BE, + has_bom: false, + expected_bytes: vec![0x30, 0x53, 0x30, 0x93, 0x30, 0x6b, 0x30, 0x61, 0x30, 0x6f], + }, + // UTF-16BE with BOM + TestCase { + name: "UTF-16BE with BOM", + text: "A", + encoding: encoding_rs::UTF_16BE, + has_bom: true, + expected_bytes: vec![0xFE, 0xFF, 0x00, 0x41], + }, + ]; - let task = worktree.update(cx, |wt, cx| { - wt.write_file( - rel_path, - text, - text::LineEnding::Unix, - encoding_rs::SHIFT_JIS, - false, - cx, - ) - }); + for (i, case) in cases.into_iter().enumerate() { + let file_name = format!("test_{}.txt", i); + let path: Arc = Path::new(&file_name).into(); + let file_path = root_path.join(&file_name); - task.await.unwrap(); + fs.insert_file(&file_path, "".into()).await; - let bytes = fs.load_bytes(&file_path).await.unwrap(); + let rel_path = RelPath::new(&path, PathStyle::local()).unwrap().into_arc(); + let text = text::Rope::from(case.text); - let expected_bytes = vec![ - 0x82, 0xb1, // こ - 0x82, 0xf1, // ん - 0x82, 0xc9, // に - 0x82, 0xbf, // ち - 0x82, 0xcd, // は - ]; + let task = worktree.update(cx, |wt, cx| { + wt.write_file( + rel_path, + text, + text::LineEnding::Unix, + case.encoding, + case.has_bom, + cx, + ) + }); + + if let Err(e) = task.await { + panic!("Unexpected error in case '{}': {:?}", case.name, e); + } + + let bytes = fs.load_bytes(&file_path).await.unwrap(); - assert_eq!(bytes, expected_bytes, "Should be saved as Shift-JIS"); + assert_eq!( + bytes, case.expected_bytes, + "case '{}' mismatch. Expected {:?}, but got {:?}", + case.name, case.expected_bytes, bytes + ); + } } From e61f9081d44a99f4f04259c7b8efdcd1cc8c0ca7 Mon Sep 17 00:00:00 2001 From: morgankrey Date: Fri, 19 Dec 2025 12:24:23 -0600 Subject: [PATCH 564/621] docs: More droid docs debugging (#45388) Path issues Release Notes: - N/A --------- Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> --- .github/workflows/docs_automation.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docs_automation.yml b/.github/workflows/docs_automation.yml index a59022e6f641fa5a351c29240fc6bdcc560228f5..ba0236fe91d3efe5975777e3df31eedf884e224d 100644 --- a/.github/workflows/docs_automation.yml +++ b/.github/workflows/docs_automation.yml @@ -40,10 +40,10 @@ jobs: id: install-droid run: | curl -fsSL https://app.factory.ai/cli | sh - echo "${HOME}/.factory/bin" >> "$GITHUB_PATH" - echo "DROID_BIN=${HOME}/.factory/bin/droid" >> "$GITHUB_ENV" + echo "${HOME}/.local/bin" >> "$GITHUB_PATH" + echo "DROID_BIN=${HOME}/.local/bin/droid" >> "$GITHUB_ENV" # Verify installation - "${HOME}/.factory/bin/droid" --version + "${HOME}/.local/bin/droid" --version - name: Setup Node.js (for Prettier) uses: actions/setup-node@v4 From 07db88a327baa2904d6c3ed9bc17cda7ff1f0e86 Mon Sep 17 00:00:00 2001 From: Cole Miller Date: Fri, 19 Dec 2025 14:08:49 -0500 Subject: [PATCH 565/621] git: Optimistically stage hunks when staging a file, take 2 (#45278) Relanding #43434 with an improved approach. Release Notes: - N/A --------- Co-authored-by: Ramon <55579979+van-sprundel@users.noreply.github.com> --- crates/buffer_diff/src/buffer_diff.rs | 28 ++++ crates/project/src/git_store.rs | 229 +++++++++++++++++--------- crates/project/src/project_tests.rs | 143 ++++++++++++++++ 3 files changed, 321 insertions(+), 79 deletions(-) diff --git a/crates/buffer_diff/src/buffer_diff.rs b/crates/buffer_diff/src/buffer_diff.rs index 22525096d3cbca456aa114b5acc9b4239b570dda..111b18233b6500de7de4485c8a408eec1e8cb822 100644 --- a/crates/buffer_diff/src/buffer_diff.rs +++ b/crates/buffer_diff/src/buffer_diff.rs @@ -1159,6 +1159,34 @@ impl BufferDiff { new_index_text } + pub fn stage_or_unstage_all_hunks( + &mut self, + stage: bool, + buffer: &text::BufferSnapshot, + file_exists: bool, + cx: &mut Context, + ) { + let hunks = self + .hunks_intersecting_range(Anchor::MIN..Anchor::MAX, buffer, cx) + .collect::>(); + let Some(secondary) = self.secondary_diff.as_ref() else { + return; + }; + self.inner.stage_or_unstage_hunks_impl( + &secondary.read(cx).inner, + stage, + &hunks, + buffer, + file_exists, + ); + if let Some((first, last)) = hunks.first().zip(hunks.last()) { + let changed_range = first.buffer_range.start..last.buffer_range.end; + cx.emit(BufferDiffEvent::DiffChanged { + changed_range: Some(changed_range), + }); + } + } + pub fn range_to_hunk_range( &self, range: Range, diff --git a/crates/project/src/git_store.rs b/crates/project/src/git_store.rs index 85ff38ab67f873d8197729de9577075951676597..d490a2cfdc843a1984bf3f719692af2dcf39aaaa 100644 --- a/crates/project/src/git_store.rs +++ b/crates/project/src/git_store.rs @@ -4205,74 +4205,29 @@ impl Repository { entries: Vec, cx: &mut Context, ) -> Task> { - if entries.is_empty() { - return Task::ready(Ok(())); - } - let id = self.id; - let save_tasks = self.save_buffers(&entries, cx); - let paths = entries - .iter() - .map(|p| p.as_unix_str()) - .collect::>() - .join(" "); - let status = format!("git add {paths}"); - let job_key = GitJobKey::WriteIndex(entries.clone()); - - self.spawn_job_with_tracking( - entries.clone(), - pending_op::GitStatus::Staged, - cx, - async move |this, cx| { - for save_task in save_tasks { - save_task.await?; - } - - this.update(cx, |this, _| { - this.send_keyed_job( - Some(job_key), - Some(status.into()), - move |git_repo, _cx| async move { - match git_repo { - RepositoryState::Local(LocalRepositoryState { - backend, - environment, - .. - }) => backend.stage_paths(entries, environment.clone()).await, - RepositoryState::Remote(RemoteRepositoryState { - project_id, - client, - }) => { - client - .request(proto::Stage { - project_id: project_id.0, - repository_id: id.to_proto(), - paths: entries - .into_iter() - .map(|repo_path| repo_path.to_proto()) - .collect(), - }) - .await - .context("sending stage request")?; - - Ok(()) - } - } - }, - ) - })? - .await? - }, - ) + self.stage_or_unstage_entries(true, entries, cx) } pub fn unstage_entries( &mut self, entries: Vec, cx: &mut Context, + ) -> Task> { + self.stage_or_unstage_entries(false, entries, cx) + } + + fn stage_or_unstage_entries( + &mut self, + stage: bool, + entries: Vec, + cx: &mut Context, ) -> Task> { if entries.is_empty() { return Task::ready(Ok(())); } + let Some(git_store) = self.git_store.upgrade() else { + return Task::ready(Ok(())); + }; let id = self.id; let save_tasks = self.save_buffers(&entries, cx); let paths = entries @@ -4280,48 +4235,164 @@ impl Repository { .map(|p| p.as_unix_str()) .collect::>() .join(" "); - let status = format!("git reset {paths}"); + let status = if stage { + format!("git add {paths}") + } else { + format!("git reset {paths}") + }; let job_key = GitJobKey::WriteIndex(entries.clone()); self.spawn_job_with_tracking( entries.clone(), - pending_op::GitStatus::Unstaged, + if stage { + pending_op::GitStatus::Staged + } else { + pending_op::GitStatus::Unstaged + }, cx, async move |this, cx| { for save_task in save_tasks { save_task.await?; } - this.update(cx, |this, _| { + this.update(cx, |this, cx| { + let weak_this = cx.weak_entity(); this.send_keyed_job( Some(job_key), Some(status.into()), - move |git_repo, _cx| async move { - match git_repo { + move |git_repo, mut cx| async move { + let hunk_staging_operation_counts = weak_this + .update(&mut cx, |this, cx| { + let mut hunk_staging_operation_counts = HashMap::default(); + for path in &entries { + let Some(project_path) = + this.repo_path_to_project_path(path, cx) + else { + continue; + }; + let Some(buffer) = git_store + .read(cx) + .buffer_store + .read(cx) + .get_by_path(&project_path) + else { + continue; + }; + let Some(diff_state) = git_store + .read(cx) + .diffs + .get(&buffer.read(cx).remote_id()) + .cloned() + else { + continue; + }; + let Some(uncommitted_diff) = + diff_state.read(cx).uncommitted_diff.as_ref().and_then( + |uncommitted_diff| uncommitted_diff.upgrade(), + ) + else { + continue; + }; + let buffer_snapshot = buffer.read(cx).text_snapshot(); + let file_exists = buffer + .read(cx) + .file() + .is_some_and(|file| file.disk_state().exists()); + let hunk_staging_operation_count = + diff_state.update(cx, |diff_state, cx| { + uncommitted_diff.update( + cx, + |uncommitted_diff, cx| { + uncommitted_diff + .stage_or_unstage_all_hunks( + stage, + &buffer_snapshot, + file_exists, + cx, + ); + }, + ); + + diff_state.hunk_staging_operation_count += 1; + diff_state.hunk_staging_operation_count + }); + hunk_staging_operation_counts.insert( + diff_state.downgrade(), + hunk_staging_operation_count, + ); + } + hunk_staging_operation_counts + }) + .unwrap_or_default(); + + let result = match git_repo { RepositoryState::Local(LocalRepositoryState { backend, environment, .. - }) => backend.unstage_paths(entries, environment).await, + }) => { + if stage { + backend.stage_paths(entries, environment.clone()).await + } else { + backend.unstage_paths(entries, environment.clone()).await + } + } RepositoryState::Remote(RemoteRepositoryState { project_id, client, }) => { - client - .request(proto::Unstage { - project_id: project_id.0, - repository_id: id.to_proto(), - paths: entries - .into_iter() - .map(|repo_path| repo_path.to_proto()) - .collect(), - }) - .await - .context("sending unstage request")?; - - Ok(()) + if stage { + client + .request(proto::Stage { + project_id: project_id.0, + repository_id: id.to_proto(), + paths: entries + .into_iter() + .map(|repo_path| repo_path.to_proto()) + .collect(), + }) + .await + .context("sending stage request") + .map(|_| ()) + } else { + client + .request(proto::Unstage { + project_id: project_id.0, + repository_id: id.to_proto(), + paths: entries + .into_iter() + .map(|repo_path| repo_path.to_proto()) + .collect(), + }) + .await + .context("sending unstage request") + .map(|_| ()) + } } + }; + + for (diff_state, hunk_staging_operation_count) in + hunk_staging_operation_counts + { + diff_state + .update(&mut cx, |diff_state, cx| { + if result.is_ok() { + diff_state.hunk_staging_operation_count_as_of_write = + hunk_staging_operation_count; + } else if let Some(uncommitted_diff) = + &diff_state.uncommitted_diff + { + uncommitted_diff + .update(cx, |uncommitted_diff, cx| { + uncommitted_diff.clear_pending_hunks(cx); + }) + .ok(); + } + }) + .ok(); } + + result }, ) })? @@ -4347,7 +4418,7 @@ impl Repository { } }) .collect(); - self.stage_entries(to_stage, cx) + self.stage_or_unstage_entries(true, to_stage, cx) } pub fn unstage_all(&mut self, cx: &mut Context) -> Task> { @@ -4367,7 +4438,7 @@ impl Repository { } }) .collect(); - self.unstage_entries(to_unstage, cx) + self.stage_or_unstage_entries(false, to_unstage, cx) } pub fn stash_all(&mut self, cx: &mut Context) -> Task> { diff --git a/crates/project/src/project_tests.rs b/crates/project/src/project_tests.rs index 4cebc72073cfda1bf07f028b1aff9fa7410c527d..921ca16323b300af3a02cc2e7f38b1cc6305615c 100644 --- a/crates/project/src/project_tests.rs +++ b/crates/project/src/project_tests.rs @@ -10922,3 +10922,146 @@ async fn test_git_worktree_remove(cx: &mut gpui::TestAppContext) { }); assert!(active_repo_path.is_none()); } + +#[gpui::test] +async fn test_optimistic_hunks_in_staged_files(cx: &mut gpui::TestAppContext) { + use DiffHunkSecondaryStatus::*; + init_test(cx); + + let committed_contents = r#" + one + two + three + "# + .unindent(); + let file_contents = r#" + one + TWO + three + "# + .unindent(); + + let fs = FakeFs::new(cx.background_executor.clone()); + fs.insert_tree( + path!("/dir"), + json!({ + ".git": {}, + "file.txt": file_contents.clone() + }), + ) + .await; + + fs.set_head_and_index_for_repo( + path!("/dir/.git").as_ref(), + &[("file.txt", committed_contents.clone())], + ); + + let project = Project::test(fs.clone(), [path!("/dir").as_ref()], cx).await; + + let buffer = project + .update(cx, |project, cx| { + project.open_local_buffer(path!("/dir/file.txt"), cx) + }) + .await + .unwrap(); + let snapshot = buffer.read_with(cx, |buffer, _| buffer.snapshot()); + let uncommitted_diff = project + .update(cx, |project, cx| { + project.open_uncommitted_diff(buffer.clone(), cx) + }) + .await + .unwrap(); + + // The hunk is initially unstaged. + uncommitted_diff.read_with(cx, |diff, cx| { + assert_hunks( + diff.hunks(&snapshot, cx), + &snapshot, + &diff.base_text_string().unwrap(), + &[( + 1..2, + "two\n", + "TWO\n", + DiffHunkStatus::modified(HasSecondaryHunk), + )], + ); + }); + + // Get the repository handle. + let repo = project.read_with(cx, |project, cx| { + project.repositories(cx).values().next().unwrap().clone() + }); + + // Stage the file. + let stage_task = repo.update(cx, |repo, cx| { + repo.stage_entries(vec![repo_path("file.txt")], cx) + }); + + // Run a few ticks to let the job start and mark hunks as pending, + // but don't run_until_parked which would complete the entire operation. + for _ in 0..10 { + cx.executor().tick(); + let [hunk]: [_; 1] = uncommitted_diff + .read_with(cx, |diff, cx| diff.hunks(&snapshot, cx).collect::>()) + .try_into() + .unwrap(); + match hunk.secondary_status { + HasSecondaryHunk => {} + SecondaryHunkRemovalPending => break, + NoSecondaryHunk => panic!("hunk was not optimistically staged"), + _ => panic!("unexpected hunk state"), + } + } + uncommitted_diff.read_with(cx, |diff, cx| { + assert_hunks( + diff.hunks(&snapshot, cx), + &snapshot, + &diff.base_text_string().unwrap(), + &[( + 1..2, + "two\n", + "TWO\n", + DiffHunkStatus::modified(SecondaryHunkRemovalPending), + )], + ); + }); + + // Let the staging complete. + stage_task.await.unwrap(); + cx.run_until_parked(); + + // The hunk is now fully staged. + uncommitted_diff.read_with(cx, |diff, cx| { + assert_hunks( + diff.hunks(&snapshot, cx), + &snapshot, + &diff.base_text_string().unwrap(), + &[( + 1..2, + "two\n", + "TWO\n", + DiffHunkStatus::modified(NoSecondaryHunk), + )], + ); + }); + + // Simulate a commit by updating HEAD to match the current file contents. + // The FakeGitRepository's commit method is a no-op, so we need to manually + // update HEAD to simulate the commit completing. + fs.set_head_for_repo( + path!("/dir/.git").as_ref(), + &[("file.txt", file_contents.clone())], + "newhead", + ); + cx.run_until_parked(); + + // After committing, there are no more hunks. + uncommitted_diff.read_with(cx, |diff, cx| { + assert_hunks( + diff.hunks(&snapshot, cx), + &snapshot, + &diff.base_text_string().unwrap(), + &[] as &[(Range, &str, &str, DiffHunkStatus)], + ); + }); +} From bb2f037407289605081f44a8d956b11763d034f0 Mon Sep 17 00:00:00 2001 From: morgankrey Date: Fri, 19 Dec 2025 13:20:05 -0600 Subject: [PATCH 566/621] docs: Droid doesn't know its own commands (#45391) Correctly uses droid commands in auto docs actions Release Notes: - N/A --------- Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> --- .github/workflows/docs_automation.yml | 82 +++++++++++++-------------- 1 file changed, 40 insertions(+), 42 deletions(-) diff --git a/.github/workflows/docs_automation.yml b/.github/workflows/docs_automation.yml index ba0236fe91d3efe5975777e3df31eedf884e224d..4c1551c0a91d243896aceef161d85472e8b07021 100644 --- a/.github/workflows/docs_automation.yml +++ b/.github/workflows/docs_automation.yml @@ -85,71 +85,74 @@ jobs: # Phase 0: Guardrails are loaded via AGENTS.md in each phase - # Phase 2: Explore Repository (Read-Only) + # Phase 2: Explore Repository (Read-Only - default) - name: "Phase 2: Explore Repository" id: phase2 run: | "$DROID_BIN" exec \ - --model "$DROID_MODEL" \ - --autonomy read-only \ - --prompt-file .factory/prompts/docs-automation/phase2-explore.md \ - --output /tmp/phase2-output.json \ - --format json + -m "$DROID_MODEL" \ + -f .factory/prompts/docs-automation/phase2-explore.md \ + > /tmp/phase2-output.txt 2>&1 || true echo "Repository exploration complete" - cat /tmp/phase2-output.json + cat /tmp/phase2-output.txt - # Phase 3: Analyze Changes (Read-Only) + # Phase 3: Analyze Changes (Read-Only - default) - name: "Phase 3: Analyze Changes" id: phase3 run: | CHANGED_FILES=$(tr '\n' ' ' < /tmp/changed_files.txt) + echo "Analyzing changes in: $CHANGED_FILES" + + # Build prompt with context + cat > /tmp/phase3-prompt.md << 'EOF' + $(cat .factory/prompts/docs-automation/phase3-analyze.md) + + ## Context + + ### Changed Files + $CHANGED_FILES + + ### Phase 2 Output + $(cat /tmp/phase2-output.txt) + EOF + "$DROID_BIN" exec \ - --model "$DROID_MODEL" \ - --autonomy read-only \ - --prompt-file .factory/prompts/docs-automation/phase3-analyze.md \ - --context "Changed files: $CHANGED_FILES" \ - --context-file /tmp/phase2-output.json \ - --output /tmp/phase3-output.md \ - --format markdown + -m "$DROID_MODEL" \ + "$(cat .factory/prompts/docs-automation/phase3-analyze.md) + + Changed files: $CHANGED_FILES" \ + > /tmp/phase3-output.md 2>&1 || true echo "Change analysis complete" cat /tmp/phase3-output.md - # Phase 4: Plan Documentation Impact (Read-Only) + # Phase 4: Plan Documentation Impact (Read-Only - default) - name: "Phase 4: Plan Documentation Impact" id: phase4 run: | "$DROID_BIN" exec \ - --model "$DROID_MODEL" \ - --autonomy read-only \ - --prompt-file .factory/prompts/docs-automation/phase4-plan.md \ - --context-file /tmp/phase3-output.md \ - --context-file docs/AGENTS.md \ - --output /tmp/phase4-plan.md \ - --format markdown + -m "$DROID_MODEL" \ + -f .factory/prompts/docs-automation/phase4-plan.md \ + > /tmp/phase4-plan.md 2>&1 || true echo "Documentation plan complete" cat /tmp/phase4-plan.md # Check if updates are required - if grep -q "Documentation Updates Required: No" /tmp/phase4-plan.md; then + if grep -q "NO_UPDATES_REQUIRED" /tmp/phase4-plan.md; then echo "updates_required=false" >> "$GITHUB_OUTPUT" else echo "updates_required=true" >> "$GITHUB_OUTPUT" fi - # Phase 5: Apply Plan (Write-Enabled) + # Phase 5: Apply Plan (Write-Enabled with --auto medium) - name: "Phase 5: Apply Documentation Plan" id: phase5 if: steps.phase4.outputs.updates_required == 'true' run: | "$DROID_BIN" exec \ - --model "$DROID_MODEL" \ - --autonomy medium \ - --prompt-file .factory/prompts/docs-automation/phase5-apply.md \ - --context-file /tmp/phase4-plan.md \ - --context-file docs/AGENTS.md \ - --context-file docs/.rules \ - --output /tmp/phase5-report.md \ - --format markdown + -m "$DROID_MODEL" \ + --auto medium \ + -f .factory/prompts/docs-automation/phase5-apply.md \ + > /tmp/phase5-report.md 2>&1 || true echo "Documentation updates applied" cat /tmp/phase5-report.md @@ -166,7 +169,7 @@ jobs: echo "Prettier formatting complete" - # Phase 6: Summarize Changes + # Phase 6: Summarize Changes (Read-Only - default) - name: "Phase 6: Summarize Changes" id: phase6 if: steps.phase4.outputs.updates_required == 'true' @@ -175,14 +178,9 @@ jobs: git diff docs/src/ > /tmp/docs-diff.txt || true "$DROID_BIN" exec \ - --model "$DROID_MODEL" \ - --autonomy read-only \ - --prompt-file .factory/prompts/docs-automation/phase6-summarize.md \ - --context-file /tmp/phase5-report.md \ - --context-file /tmp/phase3-output.md \ - --context "Trigger SHA: ${{ steps.changed.outputs.sha }}" \ - --output /tmp/phase6-summary.md \ - --format markdown + -m "$DROID_MODEL" \ + -f .factory/prompts/docs-automation/phase6-summarize.md \ + > /tmp/phase6-summary.md 2>&1 || true echo "Summary generated" cat /tmp/phase6-summary.md From 56646e6bc32a1c66eb6972edfe59ad65f64af3a7 Mon Sep 17 00:00:00 2001 From: Michael Benfield Date: Fri, 19 Dec 2025 11:37:57 -0800 Subject: [PATCH 567/621] Inline assistant: Don't scroll up too high (#45171) In the case of large vertical_scroll_margin, we could scroll up such that the assistant was out of view. Now, keep it no lower than the center of the editor. Closes #18058 Release Notes: - N/A --- crates/agent_ui/src/inline_assistant.rs | 28 ++++++++++++------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/crates/agent_ui/src/inline_assistant.rs b/crates/agent_ui/src/inline_assistant.rs index 671579f9ef018b495b7993279a852595c78d3e02..b3c14c5a0ec332f66c300023759db9f09b94dc6f 100644 --- a/crates/agent_ui/src/inline_assistant.rs +++ b/crates/agent_ui/src/inline_assistant.rs @@ -1259,28 +1259,26 @@ impl InlineAssistant { let bottom = top + 1.0; (top, bottom) }); - let mut scroll_target_top = scroll_target_range.0; - let mut scroll_target_bottom = scroll_target_range.1; - - scroll_target_top -= editor.vertical_scroll_margin() as ScrollOffset; - scroll_target_bottom += editor.vertical_scroll_margin() as ScrollOffset; - let height_in_lines = editor.visible_line_count().unwrap_or(0.); + let vertical_scroll_margin = editor.vertical_scroll_margin() as ScrollOffset; + let scroll_target_top = (scroll_target_range.0 - vertical_scroll_margin) + // Don't scroll up too far in the case of a large vertical_scroll_margin. + .max(scroll_target_range.0 - height_in_lines / 2.0); + let scroll_target_bottom = (scroll_target_range.1 + vertical_scroll_margin) + // Don't scroll down past where the top would still be visible. + .min(scroll_target_top + height_in_lines); + let scroll_top = editor.scroll_position(cx).y; let scroll_bottom = scroll_top + height_in_lines; if scroll_target_top < scroll_top { editor.set_scroll_position(point(0., scroll_target_top), window, cx); } else if scroll_target_bottom > scroll_bottom { - if (scroll_target_bottom - scroll_target_top) <= height_in_lines { - editor.set_scroll_position( - point(0., scroll_target_bottom - height_in_lines), - window, - cx, - ); - } else { - editor.set_scroll_position(point(0., scroll_target_top), window, cx); - } + editor.set_scroll_position( + point(0., scroll_target_bottom - height_in_lines), + window, + cx, + ); } }); } From 99224ccc758bbe0735a6ebd4f88e817e9cc8a259 Mon Sep 17 00:00:00 2001 From: morgankrey Date: Fri, 19 Dec 2025 13:43:10 -0600 Subject: [PATCH 568/621] docs: Droid needs a real model (#45393) Droid needs a specific model with a date Release Notes: - N/A --------- Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> --- .github/workflows/docs_automation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs_automation.yml b/.github/workflows/docs_automation.yml index 4c1551c0a91d243896aceef161d85472e8b07021..7fa39168c3cfac8b79273906d2c1110a33df69f7 100644 --- a/.github/workflows/docs_automation.yml +++ b/.github/workflows/docs_automation.yml @@ -23,7 +23,7 @@ permissions: env: FACTORY_API_KEY: ${{ secrets.FACTORY_API_KEY }} - DROID_MODEL: claude-opus-4-5 + DROID_MODEL: claude-opus-4-5-20251101 jobs: docs-automation: From 8e5d33ebc6093c6fd2dbcd4dc3a5e0c35a15ec49 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Fri, 19 Dec 2025 12:59:01 -0700 Subject: [PATCH 569/621] Make prompt store fail-open when DB contains undecodable records (#45312) Release Notes - N/A --------- Co-authored-by: Zed Zippy <234243425+zed-zippy[bot]@users.noreply.github.com> --- crates/prompt_store/src/prompt_store.rs | 91 ++++++++++++++++++++++++- 1 file changed, 89 insertions(+), 2 deletions(-) diff --git a/crates/prompt_store/src/prompt_store.rs b/crates/prompt_store/src/prompt_store.rs index 2c45410c2aa172c8a4f7118a914cacca69ea7ca8..1f63acb1965428cf3dbc6b9b5739e249c13a9c31 100644 --- a/crates/prompt_store/src/prompt_store.rs +++ b/crates/prompt_store/src/prompt_store.rs @@ -193,7 +193,15 @@ impl MetadataCache { ) -> Result { let mut cache = MetadataCache::default(); for result in db.iter(txn)? { - let (prompt_id, metadata) = result?; + // Fail-open: skip records that can't be decoded (e.g. from a different branch) + // rather than failing the entire prompt store initialization. + let Ok((prompt_id, metadata)) = result else { + log::warn!( + "Skipping unreadable prompt record in database: {:?}", + result.err() + ); + continue; + }; cache.metadata.push(metadata.clone()); cache.metadata_by_id.insert(prompt_id, metadata); } @@ -677,7 +685,86 @@ mod tests { assert_eq!( loaded_after_reset.trim(), expected_content_after_reset.trim(), - "After saving default content, load should return default" + "Content should be back to default after saving default content" + ); + } + + /// Test that the prompt store initializes successfully even when the database + /// contains records with incompatible/undecodable PromptId keys (e.g., from + /// a different branch that used a different serialization format). + /// + /// This is a regression test for the "fail-open" behavior: we should skip + /// bad records rather than failing the entire store initialization. + #[gpui::test] + async fn test_prompt_store_handles_incompatible_db_records(cx: &mut TestAppContext) { + cx.executor().allow_parking(); + + let temp_dir = tempfile::tempdir().unwrap(); + let db_path = temp_dir.path().join("prompts-db-with-bad-records"); + std::fs::create_dir_all(&db_path).unwrap(); + + // First, create the DB and write an incompatible record directly. + // We simulate a record written by a different branch that used + // `{"kind":"CommitMessage"}` instead of `{"kind":"BuiltIn", ...}`. + { + let db_env = unsafe { + heed::EnvOpenOptions::new() + .map_size(1024 * 1024 * 1024) + .max_dbs(4) + .open(&db_path) + .unwrap() + }; + + let mut txn = db_env.write_txn().unwrap(); + // Create the metadata.v2 database with raw bytes so we can write + // an incompatible key format. + let metadata_db: Database = db_env + .create_database(&mut txn, Some("metadata.v2")) + .unwrap(); + + // Write an incompatible PromptId key: `{"kind":"CommitMessage"}` + // This is the old/branch format that current code can't decode. + let bad_key = br#"{"kind":"CommitMessage"}"#; + let dummy_metadata = br#"{"id":{"kind":"CommitMessage"},"title":"Bad Record","default":false,"saved_at":"2024-01-01T00:00:00Z"}"#; + metadata_db.put(&mut txn, bad_key, dummy_metadata).unwrap(); + + // Also write a valid record to ensure we can still read good data. + let good_key = br#"{"kind":"User","uuid":"550e8400-e29b-41d4-a716-446655440000"}"#; + let good_metadata = br#"{"id":{"kind":"User","uuid":"550e8400-e29b-41d4-a716-446655440000"},"title":"Good Record","default":false,"saved_at":"2024-01-01T00:00:00Z"}"#; + metadata_db.put(&mut txn, good_key, good_metadata).unwrap(); + + txn.commit().unwrap(); + } + + // Now try to create a PromptStore from this DB. + // With fail-open behavior, this should succeed and skip the bad record. + // Without fail-open, this would return an error. + let store_result = cx.update(|cx| PromptStore::new(db_path, cx)).await; + + assert!( + store_result.is_ok(), + "PromptStore should initialize successfully even with incompatible DB records. \ + Got error: {:?}", + store_result.err() + ); + + let store = cx.new(|_cx| store_result.unwrap()); + + // Verify the good record was loaded. + let good_id = PromptId::User { + uuid: UserPromptId("550e8400-e29b-41d4-a716-446655440000".parse().unwrap()), + }; + let metadata = store.read_with(cx, |store, _| store.metadata(good_id)); + assert!( + metadata.is_some(), + "Valid records should still be loaded after skipping bad ones" + ); + assert_eq!( + metadata + .as_ref() + .and_then(|m| m.title.as_ref().map(|t| t.as_ref())), + Some("Good Record"), + "Valid record should have correct title" ); } } From b091cc4d9a42773e536960ffc0f2393775158bf9 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Fri, 19 Dec 2025 13:04:41 -0700 Subject: [PATCH 570/621] Enforce 5MB per-image limit when converting images for language models (#45313) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Problem When users paste or drag large images into the agent panel, the encoded payload can exceed upstream provider limits (e.g., Anthropic's 5MB per-image limit), causing API errors. ## Solution Enforce a default 5MB limit on encoded PNG bytes in `LanguageModelImage::from_image`: 1. Apply existing Anthropic dimension limits first (1568px max in either dimension) 2. Iteratively downscale by ~15% per pass until the encoded PNG is under 5MB 3. Return `None` if the image can't be shrunk within 8 passes (fail-safe) The limit is enforced at the `LanguageModelImage` conversion layer, which is the choke point for all image ingestion paths (agent panel paste/drag, file mentions, text threads, etc.). ## Future Work The 5MB limit is a conservative default. Provider-specific limits can be introduced later by adding a `from_image_with_constraints` API. ## Testing Added a regression test that: 1. Generates a noisy 4096x4096 PNG (guaranteed >5MB) 2. Converts it via `LanguageModelImage::from_image` 3. Asserts the result is ≤5MB and was actually downscaled --- **Note:** This PR builds on #45312 (prompt store fail-open fix). Please merge that first. cc @rtfeldman --------- Co-authored-by: Zed Zippy <234243425+zed-zippy[bot]@users.noreply.github.com> --- crates/language_model/src/request.rs | 168 ++++++++++++++++++++++----- 1 file changed, 138 insertions(+), 30 deletions(-) diff --git a/crates/language_model/src/request.rs b/crates/language_model/src/request.rs index 5e99cca4f9d6e61672c541cb90a3a1ca7da91203..96ed0907427c305211b1484e17ab61d434781ed6 100644 --- a/crates/language_model/src/request.rs +++ b/crates/language_model/src/request.rs @@ -8,6 +8,7 @@ use gpui::{ App, AppContext as _, DevicePixels, Image, ImageFormat, ObjectFit, SharedString, Size, Task, point, px, size, }; +use image::GenericImageView as _; use image::codecs::png::PngEncoder; use serde::{Deserialize, Serialize}; use util::ResultExt; @@ -80,6 +81,16 @@ impl std::fmt::Debug for LanguageModelImage { /// Anthropic wants uploaded images to be smaller than this in both dimensions. const ANTHROPIC_SIZE_LIMIT: f32 = 1568.; +/// Default per-image hard limit (in bytes) for the encoded image payload we send upstream. +/// +/// NOTE: `LanguageModelImage.source` is base64-encoded PNG bytes (without the `data:` prefix). +/// This limit is enforced on the encoded PNG bytes *before* base64 encoding. +const DEFAULT_IMAGE_MAX_BYTES: usize = 5 * 1024 * 1024; + +/// Conservative cap on how many times we'll attempt to shrink/re-encode an image to fit +/// `DEFAULT_IMAGE_MAX_BYTES`. +const MAX_IMAGE_DOWNSCALE_PASSES: usize = 8; + impl LanguageModelImage { pub fn empty() -> Self { Self { @@ -112,29 +123,62 @@ impl LanguageModelImage { let height = dynamic_image.height(); let image_size = size(DevicePixels(width as i32), DevicePixels(height as i32)); - let base64_image = { - if image_size.width.0 > ANTHROPIC_SIZE_LIMIT as i32 - || image_size.height.0 > ANTHROPIC_SIZE_LIMIT as i32 - { - let new_bounds = ObjectFit::ScaleDown.get_bounds( - gpui::Bounds { - origin: point(px(0.0), px(0.0)), - size: size(px(ANTHROPIC_SIZE_LIMIT), px(ANTHROPIC_SIZE_LIMIT)), - }, - image_size, - ); - let resized_image = dynamic_image.resize( - new_bounds.size.width.into(), - new_bounds.size.height.into(), - image::imageops::FilterType::Triangle, - ); - - encode_as_base64(data, resized_image) - } else { - encode_as_base64(data, dynamic_image) + // First apply any provider-specific dimension constraints we know about (Anthropic). + let mut processed_image = if image_size.width.0 > ANTHROPIC_SIZE_LIMIT as i32 + || image_size.height.0 > ANTHROPIC_SIZE_LIMIT as i32 + { + let new_bounds = ObjectFit::ScaleDown.get_bounds( + gpui::Bounds { + origin: point(px(0.0), px(0.0)), + size: size(px(ANTHROPIC_SIZE_LIMIT), px(ANTHROPIC_SIZE_LIMIT)), + }, + image_size, + ); + dynamic_image.resize( + new_bounds.size.width.into(), + new_bounds.size.height.into(), + image::imageops::FilterType::Triangle, + ) + } else { + dynamic_image + }; + + // Then enforce a default per-image size cap on the encoded PNG bytes. + // + // We always send PNG bytes (either original PNG bytes, or re-encoded PNG) base64'd. + // The upstream provider limit we want to respect is effectively on the binary image + // payload size, so we enforce against the encoded PNG bytes before base64 encoding. + let mut encoded_png = encode_png_bytes(&processed_image).log_err()?; + for _pass in 0..MAX_IMAGE_DOWNSCALE_PASSES { + if encoded_png.len() <= DEFAULT_IMAGE_MAX_BYTES { + break; } + + // Scale down geometrically to converge quickly. We don't know the final PNG size + // as a function of pixels, so we iteratively shrink. + let (w, h) = processed_image.dimensions(); + if w <= 1 || h <= 1 { + break; + } + + // Shrink by ~15% each pass (0.85). This is a compromise between speed and + // preserving image detail. + let new_w = ((w as f32) * 0.85).round().max(1.0) as u32; + let new_h = ((h as f32) * 0.85).round().max(1.0) as u32; + + processed_image = + processed_image.resize(new_w, new_h, image::imageops::FilterType::Triangle); + encoded_png = encode_png_bytes(&processed_image).log_err()?; } - .log_err()?; + + if encoded_png.len() > DEFAULT_IMAGE_MAX_BYTES { + // Still too large after multiple passes; treat as non-convertible for now. + // (Provider-specific handling can be introduced later.) + return None; + } + + // Now base64 encode the PNG bytes. + let base64_image = encode_bytes_as_base64(encoded_png.as_slice()).log_err()?; // SAFETY: The base64 encoder should not produce non-UTF8. let source = unsafe { String::from_utf8_unchecked(base64_image) }; @@ -164,21 +208,20 @@ impl LanguageModelImage { } } -fn encode_as_base64(data: Arc, image: image::DynamicImage) -> Result> { +fn encode_png_bytes(image: &image::DynamicImage) -> Result> { + let mut png = Vec::new(); + image.write_with_encoder(PngEncoder::new(&mut png))?; + Ok(png) +} + +fn encode_bytes_as_base64(bytes: &[u8]) -> Result> { let mut base64_image = Vec::new(); { let mut base64_encoder = EncoderWriter::new( Cursor::new(&mut base64_image), &base64::engine::general_purpose::STANDARD, ); - if data.format() == ImageFormat::Png { - base64_encoder.write_all(data.bytes())?; - } else { - let mut png = Vec::new(); - image.write_with_encoder(PngEncoder::new(&mut png))?; - - base64_encoder.write_all(png.as_slice())?; - } + base64_encoder.write_all(bytes)?; } Ok(base64_image) } @@ -417,6 +460,71 @@ pub struct LanguageModelResponseMessage { #[cfg(test)] mod tests { use super::*; + use base64::Engine as _; + use gpui::TestAppContext; + use image::ImageDecoder as _; + + fn base64_to_png_bytes(base64_png: &str) -> Vec { + base64::engine::general_purpose::STANDARD + .decode(base64_png.as_bytes()) + .expect("base64 should decode") + } + + fn png_dimensions(png_bytes: &[u8]) -> (u32, u32) { + let decoder = + image::codecs::png::PngDecoder::new(Cursor::new(png_bytes)).expect("png should decode"); + decoder.dimensions() + } + + fn make_noisy_png_bytes(width: u32, height: u32) -> Vec { + // Create an RGBA image with per-pixel variance to avoid PNG compressing too well. + let mut img = image::RgbaImage::new(width, height); + for y in 0..height { + for x in 0..width { + let r = ((x ^ y) & 0xFF) as u8; + let g = ((x.wrapping_mul(31) ^ y.wrapping_mul(17)) & 0xFF) as u8; + let b = ((x.wrapping_mul(131) ^ y.wrapping_mul(7)) & 0xFF) as u8; + img.put_pixel(x, y, image::Rgba([r, g, b, 0xFF])); + } + } + + let mut out = Vec::new(); + image::DynamicImage::ImageRgba8(img) + .write_with_encoder(PngEncoder::new(&mut out)) + .expect("png encoding should succeed"); + out + } + + #[gpui::test] + async fn test_from_image_downscales_to_default_5mb_limit(cx: &mut TestAppContext) { + // Pick a size that reliably produces a PNG > 5MB when filled with noise. + // If this fails (image is too small), bump dimensions. + let original_png = make_noisy_png_bytes(4096, 4096); + assert!( + original_png.len() > DEFAULT_IMAGE_MAX_BYTES, + "precondition failed: noisy PNG must exceed DEFAULT_IMAGE_MAX_BYTES" + ); + + let image = gpui::Image::from_bytes(ImageFormat::Png, original_png); + let lm_image = cx + .update(|cx| LanguageModelImage::from_image(Arc::new(image), cx)) + .await + .expect("image conversion should succeed"); + + let encoded_png = base64_to_png_bytes(lm_image.source.as_ref()); + assert!( + encoded_png.len() <= DEFAULT_IMAGE_MAX_BYTES, + "expected encoded PNG <= DEFAULT_IMAGE_MAX_BYTES, got {} bytes", + encoded_png.len() + ); + + // Ensure we actually downscaled in pixels (not just re-encoded). + let (w, h) = png_dimensions(&encoded_png); + assert!( + w < 4096 || h < 4096, + "expected image to be downscaled in at least one dimension; got {w}x{h}" + ); + } #[test] fn test_language_model_tool_result_content_deserialization() { From 71f4dc2481746c850e9a624582b27a6ff1dcae73 Mon Sep 17 00:00:00 2001 From: morgankrey Date: Fri, 19 Dec 2025 14:10:16 -0600 Subject: [PATCH 571/621] docs: Stash local changes before branch checkout in droid auto docs CLI (#45395) Stashes local changes before branch checkout in droid auto docs CLI Release Notes: - N/A --------- Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> --- .github/workflows/docs_automation.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/docs_automation.yml b/.github/workflows/docs_automation.yml index 7fa39168c3cfac8b79273906d2c1110a33df69f7..5b72bc4051f34ae890bc291281f8797312f5d52d 100644 --- a/.github/workflows/docs_automation.yml +++ b/.github/workflows/docs_automation.yml @@ -202,6 +202,9 @@ jobs: # Daily batch branch - one branch per day, multiple commits accumulate BRANCH_NAME="docs/auto-update-$(date +%Y-%m-%d)" + # Stash local changes from phase 5 + git stash push -m "docs-automation-changes" -- docs/src/ + # Check if branch already exists on remote if git ls-remote --exit-code --heads origin "$BRANCH_NAME" > /dev/null 2>&1; then echo "Branch $BRANCH_NAME exists, checking out and updating..." @@ -212,6 +215,9 @@ jobs: git checkout -b "$BRANCH_NAME" fi + # Apply stashed changes + git stash pop || true + # Stage and commit git add docs/src/ SUMMARY=$(head -50 < /tmp/phase6-summary.md) From ff71f4d46d282aaf656ddc7d38324affabe88a89 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Fri, 19 Dec 2025 14:27:44 -0700 Subject: [PATCH 572/621] Run cargo fix as well as cargo clippy --fix (#45394) Release Notes: - N/A --- .github/workflows/autofix_pr.yml | 4 ++++ tooling/xtask/src/tasks/workflows/autofix_pr.rs | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/.github/workflows/autofix_pr.yml b/.github/workflows/autofix_pr.yml index d3688a722aa107efb3dfb95351404f43c9aece65..33da35cb2aec86e19c9c65c399542cf1a1b78943 100644 --- a/.github/workflows/autofix_pr.yml +++ b/.github/workflows/autofix_pr.yml @@ -54,6 +54,10 @@ jobs: - name: autofix_pr::run_autofix::run_cargo_fmt run: cargo fmt --all shell: bash -euxo pipefail {0} + - name: autofix_pr::run_autofix::run_cargo_fix + if: ${{ inputs.run_clippy }} + run: cargo fix --workspace --release --all-targets --all-features --allow-dirty --allow-staged + shell: bash -euxo pipefail {0} - name: autofix_pr::run_autofix::run_clippy_fix if: ${{ inputs.run_clippy }} run: cargo clippy --workspace --release --all-targets --all-features --fix --allow-dirty --allow-staged diff --git a/tooling/xtask/src/tasks/workflows/autofix_pr.rs b/tooling/xtask/src/tasks/workflows/autofix_pr.rs index ab59e735225dfb4f9658960a35a992553642b4c2..231cbb68500145a55506c53306e90dd5b47baeda 100644 --- a/tooling/xtask/src/tasks/workflows/autofix_pr.rs +++ b/tooling/xtask/src/tasks/workflows/autofix_pr.rs @@ -63,6 +63,12 @@ fn run_autofix(pr_number: &WorkflowInput, run_clippy: &WorkflowInput) -> NamedJo named::bash("cargo fmt --all") } + fn run_cargo_fix() -> Step { + named::bash( + "cargo fix --workspace --release --all-targets --all-features --allow-dirty --allow-staged", + ) + } + fn run_clippy_fix() -> Step { named::bash( "cargo clippy --workspace --release --all-targets --all-features --fix --allow-dirty --allow-staged", @@ -101,6 +107,7 @@ fn run_autofix(pr_number: &WorkflowInput, run_clippy: &WorkflowInput) -> NamedJo .add_step(steps::setup_pnpm()) .add_step(run_prettier_fix()) .add_step(run_cargo_fmt()) + .add_step(run_cargo_fix().if_condition(Expression::new(run_clippy.to_string()))) .add_step(run_clippy_fix().if_condition(Expression::new(run_clippy.to_string()))) .add_step(create_patch()) .add_step(upload_patch_artifact()) From 3f4da03d38c7a244f1a9df0cd9e5d67a334a2f55 Mon Sep 17 00:00:00 2001 From: Anthony Eid <56899983+Anthony-Eid@users.noreply.github.com> Date: Fri, 19 Dec 2025 16:48:53 -0500 Subject: [PATCH 573/621] settings ui: Change window kind from floating to normal (#45401) #40291 made floating windows always stay on top, which made the settings ui window always on top of Zed. To maintain the old behavior, this PR changes the setting window to be a normal window. Release Notes: - N/A --- crates/settings_ui/src/settings_ui.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/settings_ui/src/settings_ui.rs b/crates/settings_ui/src/settings_ui.rs index 0ec6d0aee308ce3c20b67a5db9c6a6d9224bf229..a735553f78d487ad4def08a98886f422b113dba4 100644 --- a/crates/settings_ui/src/settings_ui.rs +++ b/crates/settings_ui/src/settings_ui.rs @@ -602,7 +602,7 @@ pub fn open_settings_editor( focus: true, show: true, is_movable: true, - kind: gpui::WindowKind::Floating, + kind: gpui::WindowKind::Normal, window_background: cx.theme().window_background_appearance(), app_id: Some(app_id.to_owned()), window_decorations: Some(window_decorations), From 1c576ccf82a3404bf33ce727458eb922f40697ec Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Fri, 19 Dec 2025 17:04:43 -0500 Subject: [PATCH 574/621] Fix OpenRouter giving errors for some Anthropic models (#45399) Fixes #44032 Release Notes: - Fix OpenRouter giving errors for some Anthropic models --- .../src/provider/open_router.rs | 38 ++++++++++++------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/crates/language_models/src/provider/open_router.rs b/crates/language_models/src/provider/open_router.rs index 48d68ddebff7e0c9bbe39dbca696dd2ffcf62605..3b94947129d760bb0bcc9ea078eb023f138de272 100644 --- a/crates/language_models/src/provider/open_router.rs +++ b/crates/language_models/src/provider/open_router.rs @@ -370,8 +370,8 @@ impl LanguageModel for OpenRouterLanguageModel { LanguageModelCompletionError, >, > { - let request = into_open_router(request, &self.model, self.max_output_tokens()); - let request = self.stream_completion(request, cx); + let openrouter_request = into_open_router(request, &self.model, self.max_output_tokens()); + let request = self.stream_completion(openrouter_request, cx); let future = self.request_limiter.stream(async move { let response = request.await?; Ok(OpenRouterEventMapper::new().map_stream(response)) @@ -385,15 +385,31 @@ pub fn into_open_router( model: &Model, max_output_tokens: Option, ) -> open_router::Request { + // Anthropic models via OpenRouter don't accept reasoning_details being echoed back + // in requests - it's an output-only field for them. However, Gemini models require + // the thought signatures to be echoed back for proper reasoning chain continuity. + // Note: OpenRouter's model API provides an `architecture.tokenizer` field (e.g. "Claude", + // "Gemini") which could replace this ID prefix check, but since this is the only place + // we need this distinction, we're just using this less invasive check instead. + // If we ever have a more formal distionction between the models in the future, + // we should revise this to use that instead. + let is_anthropic_model = model.id().starts_with("anthropic/"); + let mut messages = Vec::new(); for message in request.messages { - let reasoning_details = message.reasoning_details.clone(); + let reasoning_details_for_message = if is_anthropic_model { + None + } else { + message.reasoning_details.clone() + }; + for content in message.content { match content { MessageContent::Text(text) => add_message_content_part( open_router::MessagePart::Text { text }, message.role, &mut messages, + reasoning_details_for_message.clone(), ), MessageContent::Thinking { .. } => {} MessageContent::RedactedThinking(_) => {} @@ -404,6 +420,7 @@ pub fn into_open_router( }, message.role, &mut messages, + reasoning_details_for_message.clone(), ); } MessageContent::ToolUse(tool_use) => { @@ -419,21 +436,15 @@ pub fn into_open_router( }, }; - if let Some(open_router::RequestMessage::Assistant { - tool_calls, - reasoning_details: existing_reasoning, - .. - }) = messages.last_mut() + if let Some(open_router::RequestMessage::Assistant { tool_calls, .. }) = + messages.last_mut() { tool_calls.push(tool_call); - if existing_reasoning.is_none() && reasoning_details.is_some() { - *existing_reasoning = reasoning_details.clone(); - } } else { messages.push(open_router::RequestMessage::Assistant { content: None, tool_calls: vec![tool_call], - reasoning_details: reasoning_details.clone(), + reasoning_details: reasoning_details_for_message.clone(), }); } } @@ -509,6 +520,7 @@ fn add_message_content_part( new_part: open_router::MessagePart, role: Role, messages: &mut Vec, + reasoning_details: Option, ) { match (role, messages.last_mut()) { (Role::User, Some(open_router::RequestMessage::User { content })) @@ -532,7 +544,7 @@ fn add_message_content_part( Role::Assistant => open_router::RequestMessage::Assistant { content: Some(open_router::MessageContent::from(vec![new_part])), tool_calls: Vec::new(), - reasoning_details: None, + reasoning_details, }, Role::System => open_router::RequestMessage::System { content: open_router::MessageContent::from(vec![new_part]), From 895213a94def3adb7b60b3d98c0e055dbc38f86a Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Fri, 19 Dec 2025 23:37:13 +0100 Subject: [PATCH 575/621] Support union declarations in C/C++ textobjects.scm (#45308) Release Notes: - C/C++: Add `union` declarations to the list of text objects --- crates/languages/src/c/textobjects.scm | 6 ++++++ crates/languages/src/cpp/textobjects.scm | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/crates/languages/src/c/textobjects.scm b/crates/languages/src/c/textobjects.scm index 832dd62288b40f7ec9c738a9ded5adc9890a0666..e29f508b701c8ee22eec27af47d899d446e67860 100644 --- a/crates/languages/src/c/textobjects.scm +++ b/crates/languages/src/c/textobjects.scm @@ -23,3 +23,9 @@ "{" [(_) ","?]* @class.inside "}")) @class.around + +(union_specifier + body: (_ + "{" + (_)* @class.inside + "}")) @class.around diff --git a/crates/languages/src/cpp/textobjects.scm b/crates/languages/src/cpp/textobjects.scm index 11a27b8d581dd5d8c7cb580739007dd3df8511f1..027185a0cfab7b71f3dcd6a5d5507445e2778d34 100644 --- a/crates/languages/src/cpp/textobjects.scm +++ b/crates/languages/src/cpp/textobjects.scm @@ -24,6 +24,12 @@ [(_) ","?]* @class.inside "}")) @class.around +(union_specifier + body: (_ + "{" + (_)* @class.inside + "}")) @class.around + (class_specifier body: (_ "{" From 6dfabddbb4c219f7a0ec0b2174d880040d43cf1d Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 19 Dec 2025 15:21:10 -0800 Subject: [PATCH 576/621] Revert "gpui: Enable direct-to-display optimization for metal" (#45405) Reverts zed-industries/zed#44334 From my testing, this PR introduced screen tearing, or some kind of strange visual artifact, when scrolling at medium speed on a large display. Release notes: - N/A --- crates/gpui/src/platform/mac/metal_renderer.rs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/crates/gpui/src/platform/mac/metal_renderer.rs b/crates/gpui/src/platform/mac/metal_renderer.rs index 66f54e5ba0c66a508f9db73d5ad8f84cb52d0d69..550041a0ccb4cd39bc7a86317d9540e806af2a28 100644 --- a/crates/gpui/src/platform/mac/metal_renderer.rs +++ b/crates/gpui/src/platform/mac/metal_renderer.rs @@ -46,9 +46,9 @@ pub unsafe fn new_renderer( _native_window: *mut c_void, _native_view: *mut c_void, _bounds: crate::Size, - transparent: bool, + _transparent: bool, ) -> Renderer { - MetalRenderer::new(context, transparent) + MetalRenderer::new(context) } pub(crate) struct InstanceBufferPool { @@ -128,7 +128,7 @@ pub struct PathRasterizationVertex { } impl MetalRenderer { - pub fn new(instance_buffer_pool: Arc>, transparent: bool) -> Self { + pub fn new(instance_buffer_pool: Arc>) -> Self { // Prefer low‐power integrated GPUs on Intel Mac. On Apple // Silicon, there is only ever one GPU, so this is equivalent to // `metal::Device::system_default()`. @@ -152,13 +152,8 @@ impl MetalRenderer { let layer = metal::MetalLayer::new(); layer.set_device(&device); layer.set_pixel_format(MTLPixelFormat::BGRA8Unorm); - // Support direct-to-display rendering if the window is not transparent - // https://developer.apple.com/documentation/metal/managing-your-game-window-for-metal-in-macos - layer.set_opaque(!transparent); + layer.set_opaque(false); layer.set_maximum_drawable_count(3); - // We already present at display sync with the display link - // This allows to use direct-to-display even in window mode - layer.set_display_sync_enabled(false); unsafe { let _: () = msg_send![&*layer, setAllowsNextDrawableTimeout: NO]; let _: () = msg_send![&*layer, setNeedsDisplayOnBoundsChange: YES]; @@ -357,8 +352,8 @@ impl MetalRenderer { } } - pub fn update_transparency(&self, transparent: bool) { - self.layer.set_opaque(!transparent); + pub fn update_transparency(&self, _transparent: bool) { + // todo(mac)? } pub fn destroy(&self) { From 12dbbdd1d339d6de7be57015f4210127a017f2fe Mon Sep 17 00:00:00 2001 From: Anthony Eid <56899983+Anthony-Eid@users.noreply.github.com> Date: Fri, 19 Dec 2025 18:55:17 -0500 Subject: [PATCH 577/621] git: Fix bug where opening a git blob from historic commit view could fail (#44226) The failure would happen if the current version of the file was open as an editor. This happened because the git blob and current version of the buffer would have the same `ProjectPath`. The fix was adding a new `DiskState::Historic` variant to represent buffers that are past versions of a file (usually a snapshot from version control). Historic buffers don't return a `ProjectPath` because the file isn't real, thus there isn't and shouldn't be a `ProjectPath` to it. (At least with the current way we represent a project path) I also change the display name to use the local OS's path style instead of being hardcoded to Posix, and cleaned up some code too. Release Notes: - N/A --------- Co-authored-by: Cole Miller Co-authored-by: cameron Co-authored-by: xipengjin --- crates/action_log/src/action_log.rs | 8 +- crates/agent_ui/src/agent_diff.rs | 4 +- crates/editor/src/items.rs | 6 +- crates/git_ui/src/commit_view.rs | 54 +----- crates/image_viewer/src/image_viewer.rs | 4 +- crates/language/src/buffer.rs | 15 ++ crates/multi_buffer/src/multi_buffer.rs | 8 +- .../project/src/debugger/breakpoint_store.rs | 4 +- crates/project/src/project.rs | 6 +- crates/proto/proto/worktree.proto | 161 +++++++++--------- crates/worktree/src/worktree.rs | 9 +- 11 files changed, 130 insertions(+), 149 deletions(-) diff --git a/crates/action_log/src/action_log.rs b/crates/action_log/src/action_log.rs index 6eb18a4f12325f0c181928f99b4eb921265dbf9c..994780c40b9bd1cde45bfe6ba26630771a3040c3 100644 --- a/crates/action_log/src/action_log.rs +++ b/crates/action_log/src/action_log.rs @@ -6,7 +6,7 @@ use futures::{FutureExt, StreamExt, channel::mpsc}; use gpui::{ App, AppContext, AsyncApp, Context, Entity, SharedString, Subscription, Task, WeakEntity, }; -use language::{Anchor, Buffer, BufferEvent, DiskState, Point, ToPoint}; +use language::{Anchor, Buffer, BufferEvent, Point, ToPoint}; use project::{Project, ProjectItem, lsp_store::OpenLspBufferHandle}; use std::{cmp, ops::Range, sync::Arc}; use text::{Edit, Patch, Rope}; @@ -150,7 +150,7 @@ impl ActionLog { if buffer .read(cx) .file() - .is_some_and(|file| file.disk_state() == DiskState::Deleted) + .is_some_and(|file| file.disk_state().is_deleted()) { // If the buffer had been edited by a tool, but it got // deleted externally, we want to stop tracking it. @@ -162,7 +162,7 @@ impl ActionLog { if buffer .read(cx) .file() - .is_some_and(|file| file.disk_state() != DiskState::Deleted) + .is_some_and(|file| !file.disk_state().is_deleted()) { // If the buffer had been deleted by a tool, but it got // resurrected externally, we want to clear the edits we @@ -769,7 +769,7 @@ impl ActionLog { tracked.version != buffer.version && buffer .file() - .is_some_and(|file| file.disk_state() != DiskState::Deleted) + .is_some_and(|file| !file.disk_state().is_deleted()) }) .map(|(buffer, _)| buffer) } diff --git a/crates/agent_ui/src/agent_diff.rs b/crates/agent_ui/src/agent_diff.rs index 91d345b7ebb9dae5225626d7a054d0de1882dfe0..8d2bd534cac9b429cc1789e6ae0d5e7cd2f6e617 100644 --- a/crates/agent_ui/src/agent_diff.rs +++ b/crates/agent_ui/src/agent_diff.rs @@ -17,7 +17,7 @@ use gpui::{ Global, SharedString, Subscription, Task, WeakEntity, Window, prelude::*, }; -use language::{Buffer, Capability, DiskState, OffsetRangeExt, Point}; +use language::{Buffer, Capability, OffsetRangeExt, Point}; use multi_buffer::PathKey; use project::{Project, ProjectItem, ProjectPath}; use settings::{Settings, SettingsStore}; @@ -192,7 +192,7 @@ impl AgentDiffPane { && buffer .read(cx) .file() - .is_some_and(|file| file.disk_state() == DiskState::Deleted) + .is_some_and(|file| file.disk_state().is_deleted()) { editor.fold_buffer(snapshot.text.remote_id(), cx) } diff --git a/crates/editor/src/items.rs b/crates/editor/src/items.rs index cfbb7c975c844f08d76a5568f1e02dfe3d7d74f1..34b54795455a9612da04b54f43101f3dcf00efd9 100644 --- a/crates/editor/src/items.rs +++ b/crates/editor/src/items.rs @@ -17,8 +17,8 @@ use gpui::{ ParentElement, Pixels, SharedString, Styled, Task, WeakEntity, Window, point, }; use language::{ - Bias, Buffer, BufferRow, CharKind, CharScopeContext, DiskState, LocalFile, Point, - SelectionGoal, proto::serialize_anchor as serialize_text_anchor, + Bias, Buffer, BufferRow, CharKind, CharScopeContext, LocalFile, Point, SelectionGoal, + proto::serialize_anchor as serialize_text_anchor, }; use lsp::DiagnosticSeverity; use multi_buffer::MultiBufferOffset; @@ -722,7 +722,7 @@ impl Item for Editor { .read(cx) .as_singleton() .and_then(|buffer| buffer.read(cx).file()) - .is_some_and(|file| file.disk_state() == DiskState::Deleted); + .is_some_and(|file| file.disk_state().is_deleted()); h_flex() .gap_2() diff --git a/crates/git_ui/src/commit_view.rs b/crates/git_ui/src/commit_view.rs index 0f5420fec4169f8e3d945dd8bd0987ebbaba8d19..7a4fdc2c73741e5834ac172df28ba5ac023ec20b 100644 --- a/crates/git_ui/src/commit_view.rs +++ b/crates/git_ui/src/commit_view.rs @@ -69,7 +69,7 @@ struct GitBlob { path: RepoPath, worktree_id: WorktreeId, is_deleted: bool, - display_name: Arc, + display_name: String, } const COMMIT_MESSAGE_SORT_PREFIX: u64 = 0; @@ -243,9 +243,8 @@ impl CommitView { .path .file_name() .map(|name| name.to_string()) - .unwrap_or_else(|| file.path.display(PathStyle::Posix).to_string()); - let display_name: Arc = - Arc::from(format!("{short_sha} - {file_name}").into_boxed_str()); + .unwrap_or_else(|| file.path.display(PathStyle::local()).to_string()); + let display_name = format!("{short_sha} - {file_name}"); let file = Arc::new(GitBlob { path: file.path.clone(), @@ -661,15 +660,13 @@ impl language::File for GitBlob { } fn disk_state(&self) -> DiskState { - if self.is_deleted { - DiskState::Deleted - } else { - DiskState::New + DiskState::Historic { + was_deleted: self.is_deleted, } } fn path_style(&self, _: &App) -> PathStyle { - PathStyle::Posix + PathStyle::local() } fn path(&self) -> &Arc { @@ -697,45 +694,6 @@ impl language::File for GitBlob { } } -// No longer needed since metadata buffer is not created -// impl language::File for CommitMetadataFile { -// fn as_local(&self) -> Option<&dyn language::LocalFile> { -// None -// } -// -// fn disk_state(&self) -> DiskState { -// DiskState::New -// } -// -// fn path_style(&self, _: &App) -> PathStyle { -// PathStyle::Posix -// } -// -// fn path(&self) -> &Arc { -// &self.title -// } -// -// fn full_path(&self, _: &App) -> PathBuf { -// self.title.as_std_path().to_path_buf() -// } -// -// fn file_name<'a>(&'a self, _: &'a App) -> &'a str { -// self.title.file_name().unwrap_or("commit") -// } -// -// fn worktree_id(&self, _: &App) -> WorktreeId { -// self.worktree_id -// } -// -// fn to_proto(&self, _cx: &App) -> language::proto::File { -// unimplemented!() -// } -// -// fn is_private(&self) -> bool { -// false -// } -// } - async fn build_buffer( mut text: String, blob: Arc, diff --git a/crates/image_viewer/src/image_viewer.rs b/crates/image_viewer/src/image_viewer.rs index d7c2341723e798b18d559895d6ea478b491eeaf7..4474b2a9bf7d8d4fe117575d9323e7fee8df1eb2 100644 --- a/crates/image_viewer/src/image_viewer.rs +++ b/crates/image_viewer/src/image_viewer.rs @@ -11,7 +11,7 @@ use gpui::{ InteractiveElement, IntoElement, ObjectFit, ParentElement, Render, Styled, Task, WeakEntity, Window, canvas, div, fill, img, opaque_grey, point, size, }; -use language::{DiskState, File as _}; +use language::File as _; use persistence::IMAGE_VIEWER; use project::{ImageItem, Project, ProjectPath, image_store::ImageItemEvent}; use settings::Settings; @@ -195,7 +195,7 @@ impl Item for ImageView { } fn has_deleted_file(&self, cx: &App) -> bool { - self.image_item.read(cx).file.disk_state() == DiskState::Deleted + self.image_item.read(cx).file.disk_state().is_deleted() } fn buffer_kind(&self, _: &App) -> workspace::item::ItemBufferKind { workspace::item::ItemBufferKind::Singleton diff --git a/crates/language/src/buffer.rs b/crates/language/src/buffer.rs index 5f46340b41a876443f1d12724450d2d8b30f9b33..c919aeca15714864e5a54f8b56d3f8517994cb56 100644 --- a/crates/language/src/buffer.rs +++ b/crates/language/src/buffer.rs @@ -427,6 +427,9 @@ pub enum DiskState { Present { mtime: MTime }, /// Deleted file that was previously present. Deleted, + /// An old version of a file that was previously present + /// usually from a version control system. e.g. A git blob + Historic { was_deleted: bool }, } impl DiskState { @@ -436,6 +439,7 @@ impl DiskState { DiskState::New => None, DiskState::Present { mtime } => Some(mtime), DiskState::Deleted => None, + DiskState::Historic { .. } => None, } } @@ -444,6 +448,16 @@ impl DiskState { DiskState::New => false, DiskState::Present { .. } => true, DiskState::Deleted => false, + DiskState::Historic { .. } => false, + } + } + + /// Returns true if this state represents a deleted file. + pub fn is_deleted(&self) -> bool { + match self { + DiskState::Deleted => true, + DiskState::Historic { was_deleted } => *was_deleted, + _ => false, } } } @@ -2274,6 +2288,7 @@ impl Buffer { None => true, }, DiskState::Deleted => false, + DiskState::Historic { .. } => false, } } diff --git a/crates/multi_buffer/src/multi_buffer.rs b/crates/multi_buffer/src/multi_buffer.rs index 0c0e87b60a7b8950f7461228c929503d516791e0..3e96a81b387fabeee77c6790dd66433da99b3985 100644 --- a/crates/multi_buffer/src/multi_buffer.rs +++ b/crates/multi_buffer/src/multi_buffer.rs @@ -19,9 +19,9 @@ use gpui::{App, Context, Entity, EntityId, EventEmitter}; use itertools::Itertools; use language::{ AutoindentMode, BracketMatch, Buffer, BufferChunks, BufferRow, BufferSnapshot, Capability, - CharClassifier, CharKind, CharScopeContext, Chunk, CursorShape, DiagnosticEntryRef, DiskState, - File, IndentGuideSettings, IndentSize, Language, LanguageScope, OffsetRangeExt, OffsetUtf16, - Outline, OutlineItem, Point, PointUtf16, Selection, TextDimension, TextObject, ToOffset as _, + CharClassifier, CharKind, CharScopeContext, Chunk, CursorShape, DiagnosticEntryRef, File, + IndentGuideSettings, IndentSize, Language, LanguageScope, OffsetRangeExt, OffsetUtf16, Outline, + OutlineItem, Point, PointUtf16, Selection, TextDimension, TextObject, ToOffset as _, ToPoint as _, TransactionId, TreeSitterOptions, Unclipped, language_settings::{LanguageSettings, language_settings}, }; @@ -2980,7 +2980,7 @@ impl MultiBuffer { *is_dirty |= buffer.is_dirty(); *has_deleted_file |= buffer .file() - .is_some_and(|file| file.disk_state() == DiskState::Deleted); + .is_some_and(|file| file.disk_state().is_deleted()); *has_conflict |= buffer.has_conflict(); } if edited { diff --git a/crates/project/src/debugger/breakpoint_store.rs b/crates/project/src/debugger/breakpoint_store.rs index 42663ab9852a5dc2e9850d20dd20940c6723d03c..d5a144ee8a83e0064b3afdca123c33e4e8da3e46 100644 --- a/crates/project/src/debugger/breakpoint_store.rs +++ b/crates/project/src/debugger/breakpoint_store.rs @@ -23,7 +23,7 @@ use super::session::ThreadId; mod breakpoints_in_file { use collections::HashMap; - use language::{BufferEvent, DiskState}; + use language::BufferEvent; use super::*; @@ -82,7 +82,7 @@ mod breakpoints_in_file { BufferEvent::FileHandleChanged => { let entity_id = buffer.entity_id(); - if buffer.read(cx).file().is_none_or(|f| f.disk_state() == DiskState::Deleted) { + if buffer.read(cx).file().is_none_or(|f| f.disk_state().is_deleted()) { breakpoint_store.breakpoints.retain(|_, breakpoints_in_file| { breakpoints_in_file.buffer.entity_id() != entity_id }); diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index 25a19788fdb464f5f289ef3bc3513f21743e3a9a..5111bc04fa256f35feae40464e405d3dd926b286 100644 --- a/crates/project/src/project.rs +++ b/crates/project/src/project.rs @@ -83,7 +83,7 @@ use gpui::{ Task, WeakEntity, Window, }; use language::{ - Buffer, BufferEvent, Capability, CodeLabel, CursorShape, Language, LanguageName, + Buffer, BufferEvent, Capability, CodeLabel, CursorShape, DiskState, Language, LanguageName, LanguageRegistry, PointUtf16, ToOffset, ToPointUtf16, Toolchain, ToolchainMetadata, ToolchainScope, Transaction, Unclipped, language_settings::InlayHintKind, proto::split_operations, @@ -5671,7 +5671,9 @@ impl ProjectItem for Buffer { } fn project_path(&self, cx: &App) -> Option { - self.file().map(|file| ProjectPath { + let file = self.file()?; + + (!matches!(file.disk_state(), DiskState::Historic { .. })).then(|| ProjectPath { worktree_id: file.worktree_id(cx), path: file.path().clone(), }) diff --git a/crates/proto/proto/worktree.proto b/crates/proto/proto/worktree.proto index 5873cfc10c1c6af24520705c27781b916dfda3d0..7917962cf16b3f7e042e6584faf9ab7334e8ae3d 100644 --- a/crates/proto/proto/worktree.proto +++ b/crates/proto/proto/worktree.proto @@ -2,161 +2,162 @@ syntax = "proto3"; package zed.messages; message Timestamp { - uint64 seconds = 1; - uint32 nanos = 2; + uint64 seconds = 1; + uint32 nanos = 2; } message File { - uint64 worktree_id = 1; - optional uint64 entry_id = 2; - string path = 3; - Timestamp mtime = 4; - bool is_deleted = 5; + uint64 worktree_id = 1; + optional uint64 entry_id = 2; + string path = 3; + Timestamp mtime = 4; + bool is_deleted = 5; + bool is_historic = 6; } message Entry { - uint64 id = 1; - bool is_dir = 2; - string path = 3; - uint64 inode = 4; - Timestamp mtime = 5; - bool is_ignored = 7; - bool is_external = 8; - reserved 6; - reserved 9; - bool is_fifo = 10; - optional uint64 size = 11; - optional string canonical_path = 12; - bool is_hidden = 13; + uint64 id = 1; + bool is_dir = 2; + string path = 3; + uint64 inode = 4; + Timestamp mtime = 5; + bool is_ignored = 7; + bool is_external = 8; + reserved 6; + reserved 9; + bool is_fifo = 10; + optional uint64 size = 11; + optional string canonical_path = 12; + bool is_hidden = 13; } message AddWorktree { - string path = 1; - uint64 project_id = 2; - bool visible = 3; + string path = 1; + uint64 project_id = 2; + bool visible = 3; } message AddWorktreeResponse { - uint64 worktree_id = 1; - string canonicalized_path = 2; + uint64 worktree_id = 1; + string canonicalized_path = 2; } message RemoveWorktree { - uint64 worktree_id = 1; + uint64 worktree_id = 1; } message GetPathMetadata { - uint64 project_id = 1; - string path = 2; + uint64 project_id = 1; + string path = 2; } message GetPathMetadataResponse { - bool exists = 1; - string path = 2; - bool is_dir = 3; + bool exists = 1; + string path = 2; + bool is_dir = 3; } message WorktreeMetadata { - uint64 id = 1; - string root_name = 2; - bool visible = 3; - string abs_path = 4; + uint64 id = 1; + string root_name = 2; + bool visible = 3; + string abs_path = 4; } message ProjectPath { - uint64 worktree_id = 1; - string path = 2; + uint64 worktree_id = 1; + string path = 2; } message ListRemoteDirectoryConfig { - bool is_dir = 1; + bool is_dir = 1; } message ListRemoteDirectory { - uint64 dev_server_id = 1; - string path = 2; - ListRemoteDirectoryConfig config = 3; + uint64 dev_server_id = 1; + string path = 2; + ListRemoteDirectoryConfig config = 3; } message EntryInfo { - bool is_dir = 1; + bool is_dir = 1; } message ListRemoteDirectoryResponse { - repeated string entries = 1; - repeated EntryInfo entry_info = 2; + repeated string entries = 1; + repeated EntryInfo entry_info = 2; } message CreateProjectEntry { - uint64 project_id = 1; - uint64 worktree_id = 2; - string path = 3; - bool is_directory = 4; - optional bytes content = 5; + uint64 project_id = 1; + uint64 worktree_id = 2; + string path = 3; + bool is_directory = 4; + optional bytes content = 5; } message RenameProjectEntry { - uint64 project_id = 1; - uint64 entry_id = 2; - string new_path = 3; - uint64 new_worktree_id = 4; + uint64 project_id = 1; + uint64 entry_id = 2; + string new_path = 3; + uint64 new_worktree_id = 4; } message CopyProjectEntry { - uint64 project_id = 1; - uint64 entry_id = 2; - string new_path = 3; - uint64 new_worktree_id = 5; - reserved 4; + uint64 project_id = 1; + uint64 entry_id = 2; + string new_path = 3; + uint64 new_worktree_id = 5; + reserved 4; } message DeleteProjectEntry { - uint64 project_id = 1; - uint64 entry_id = 2; - bool use_trash = 3; + uint64 project_id = 1; + uint64 entry_id = 2; + bool use_trash = 3; } message ExpandProjectEntry { - uint64 project_id = 1; - uint64 entry_id = 2; + uint64 project_id = 1; + uint64 entry_id = 2; } message ExpandProjectEntryResponse { - uint64 worktree_scan_id = 1; + uint64 worktree_scan_id = 1; } message ExpandAllForProjectEntry { - uint64 project_id = 1; - uint64 entry_id = 2; + uint64 project_id = 1; + uint64 entry_id = 2; } message ExpandAllForProjectEntryResponse { - uint64 worktree_scan_id = 1; + uint64 worktree_scan_id = 1; } message ProjectEntryResponse { - optional Entry entry = 1; - uint64 worktree_scan_id = 2; + optional Entry entry = 1; + uint64 worktree_scan_id = 2; } message UpdateWorktreeSettings { - uint64 project_id = 1; - uint64 worktree_id = 2; - string path = 3; - optional string content = 4; - optional LocalSettingsKind kind = 5; + uint64 project_id = 1; + uint64 worktree_id = 2; + string path = 3; + optional string content = 4; + optional LocalSettingsKind kind = 5; } enum LocalSettingsKind { - Settings = 0; - Tasks = 1; - Editorconfig = 2; - Debug = 3; + Settings = 0; + Tasks = 1; + Editorconfig = 2; + Debug = 3; } message UpdateUserSettings { - uint64 project_id = 1; - string contents = 2; + uint64 project_id = 1; + string contents = 2; } message TrustWorktrees { diff --git a/crates/worktree/src/worktree.rs b/crates/worktree/src/worktree.rs index f5f632e65d71b683d1a491b1fc9e9a612f5c24a5..ca5500249e95f0b9d3fb25f75393ab5c9ca5be9b 100644 --- a/crates/worktree/src/worktree.rs +++ b/crates/worktree/src/worktree.rs @@ -3235,7 +3235,8 @@ impl language::File for File { entry_id: self.entry_id.map(|id| id.to_proto()), path: self.path.as_ref().to_proto(), mtime: self.disk_state.mtime().map(|time| time.into()), - is_deleted: self.disk_state == DiskState::Deleted, + is_deleted: self.disk_state.is_deleted(), + is_historic: matches!(self.disk_state, DiskState::Historic { .. }), } } @@ -3296,7 +3297,11 @@ impl File { "worktree id does not match file" ); - let disk_state = if proto.is_deleted { + let disk_state = if proto.is_historic { + DiskState::Historic { + was_deleted: proto.is_deleted, + } + } else if proto.is_deleted { DiskState::Deleted } else if let Some(mtime) = proto.mtime.map(&Into::into) { DiskState::Present { mtime } From 5fb220a19adc1c1bc972b1d2513e82d216df27e2 Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Sat, 20 Dec 2025 08:27:41 +0800 Subject: [PATCH 578/621] gpui: Add a Popover example for test deferred (#44473) Release Notes: - N/A image --- crates/gpui/examples/popover.rs | 174 ++++++++++++++++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 crates/gpui/examples/popover.rs diff --git a/crates/gpui/examples/popover.rs b/crates/gpui/examples/popover.rs new file mode 100644 index 0000000000000000000000000000000000000000..9a3d47d06dd0f92d176dd4e81d739403a4870062 --- /dev/null +++ b/crates/gpui/examples/popover.rs @@ -0,0 +1,174 @@ +use gpui::{ + App, Application, Context, Corner, Div, Hsla, Stateful, Window, WindowOptions, anchored, + deferred, div, prelude::*, px, +}; + +/// An example show use deferred to create a floating layers. +struct HelloWorld { + open: bool, + secondary_open: bool, +} + +fn button(id: &'static str) -> Stateful
{ + div() + .id(id) + .bg(gpui::black()) + .text_color(gpui::white()) + .px_3() + .py_1() +} + +fn popover() -> Div { + div() + .flex() + .flex_col() + .items_center() + .justify_center() + .shadow_lg() + .p_3() + .rounded_md() + .bg(gpui::white()) + .text_color(gpui::black()) + .border_1() + .text_sm() + .border_color(gpui::black().opacity(0.1)) +} + +fn line(color: Hsla) -> Div { + div().w(px(480.)).h_2().bg(color.opacity(0.25)) +} + +impl HelloWorld { + fn render_secondary_popover( + &mut self, + _window: &mut Window, + cx: &mut Context, + ) -> impl IntoElement { + button("secondary-btn") + .mt_2() + .child("Child Popover") + .on_click(cx.listener(|this, _, _, cx| { + this.secondary_open = true; + cx.notify(); + })) + .when(self.secondary_open, |this| { + this.child( + // GPUI can't support deferred here yet, + // it was inside another deferred element. + anchored() + .anchor(Corner::TopLeft) + .snap_to_window_with_margin(px(8.)) + .child( + popover() + .child("This is second level Popover") + .bg(gpui::white()) + .border_color(gpui::blue()) + .on_mouse_down_out(cx.listener(|this, _, _, cx| { + this.secondary_open = false; + cx.notify(); + })), + ), + ) + }) + } +} + +impl Render for HelloWorld { + fn render(&mut self, window: &mut Window, cx: &mut Context) -> impl IntoElement { + div() + .flex() + .flex_col() + .gap_3() + .size_full() + .bg(gpui::white()) + .text_color(gpui::black()) + .justify_center() + .items_center() + .child( + div() + .flex() + .flex_row() + .gap_4() + .child( + button("popover0").child("Opened Popover").child( + deferred( + anchored() + .anchor(Corner::TopLeft) + .snap_to_window_with_margin(px(8.)) + .child(popover().w_96().gap_3().child( + "This is a default opened Popover, \ + we can use deferred to render it \ + in a floating layer.", + )), + ) + .priority(0), + ), + ) + .child( + button("popover1") + .child("Open Popover") + .on_click(cx.listener(|this, _, _, cx| { + this.open = true; + cx.notify(); + })) + .when(self.open, |this| { + this.child( + deferred( + anchored() + .anchor(Corner::TopLeft) + .snap_to_window_with_margin(px(8.)) + .child( + popover() + .w_96() + .gap_3() + .child( + "This is first level Popover, \ + we can use deferred to render it \ + in a floating layer.\n\ + Click outside to close.", + ) + .when(!self.secondary_open, |this| { + this.on_mouse_down_out(cx.listener( + |this, _, _, cx| { + this.open = false; + cx.notify(); + }, + )) + }) + // Here we need render popover after the content + // to ensure it will be on top layer. + .child( + self.render_secondary_popover(window, cx), + ), + ), + ) + .priority(1), + ) + }), + ), + ) + .child( + "Here is an example text rendered, \ + to ensure the Popover will float above this contents.", + ) + .children([ + line(gpui::red()), + line(gpui::yellow()), + line(gpui::blue()), + line(gpui::green()), + ]) + } +} + +fn main() { + Application::new().run(|cx: &mut App| { + cx.open_window(WindowOptions::default(), |_, cx| { + cx.new(|_| HelloWorld { + open: false, + secondary_open: false, + }) + }) + .unwrap(); + cx.activate(true); + }); +} From a86b0ab2e026a870ac92ec7764796ba217d1a07d Mon Sep 17 00:00:00 2001 From: Serophots <47299955+Serophots@users.noreply.github.com> Date: Sat, 20 Dec 2025 00:29:26 +0000 Subject: [PATCH 579/621] gpui: Improve the tab stop example by demonstrating tab_group (#44647) I've just enriched the existing tab_stop.rs example for GPUI with a demonstration of tab_group. I don't think tab groups existed when the original example was written. (I didn't understand the behaviour for tab_group from the doccomments and the example was missing, so I think this is a productive PR) Release Notes: - N/A --- crates/gpui/examples/tab_stop.rs | 44 ++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/crates/gpui/examples/tab_stop.rs b/crates/gpui/examples/tab_stop.rs index 4d99da1a07a123e9a18b3c64a90834c31bd76909..efad97236cfc778870db1ee723c92691578860dd 100644 --- a/crates/gpui/examples/tab_stop.rs +++ b/crates/gpui/examples/tab_stop.rs @@ -130,6 +130,50 @@ impl Render for Example { })), ), ) + .child( + div() + .id("group-1") + .tab_index(6) + .tab_group() + .tab_stop(false) + .child( + button("group-1-button-1") + .tab_index(1) + .child("Tab index [6, 1]"), + ) + .child( + button("group-1-button-2") + .tab_index(2) + .child("Tab index [6, 2]"), + ) + .child( + button("group-1-button-3") + .tab_index(3) + .child("Tab index [6, 3]"), + ), + ) + .child( + div() + .id("group-2") + .tab_index(7) + .tab_group() + .tab_stop(false) + .child( + button("group-2-button-1") + .tab_index(1) + .child("Tab index [7, 1]"), + ) + .child( + button("group-2-button-2") + .tab_index(2) + .child("Tab index [7, 2]"), + ) + .child( + button("group-2-button-3") + .tab_index(3) + .child("Tab index [7, 3]"), + ), + ) } } From e5eb26e8d600c1cf4b971ffa2df2344338ba6d48 Mon Sep 17 00:00:00 2001 From: jkugs Date: Fri, 19 Dec 2025 19:29:44 -0500 Subject: [PATCH 580/621] gpui: Reset mouse scroll state on FocusOut to prevent large jumps (#43841) This fixes an X11 scrolling issue where Zed may jump by a large amount due to the scroll valuator state not being reset when the window loses focus. If you Alt-Tab away from Zed, scroll in another application, then return, the first scroll event in Zed applies the entire accumulated delta instead of a single step. The missing FocusOut reset was originally identified in issue #34901. Resetting scroll positions on FocusOut matches the behavior already implemented in the XinputLeave handler and prevents this jump. Closes #34901 Closes #40538 Release Notes: - Fixed an X11 issue where Alt-Tabbing to another application, scrolling, and returning to Zed could cause the next scroll event to jump by a large amount. --- crates/gpui/src/platform/linux/x11/client.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/gpui/src/platform/linux/x11/client.rs b/crates/gpui/src/platform/linux/x11/client.rs index 7feec41d433158325592d566f83a6063f7a7196e..0de5ff02f7d0895da05dfa480bff2e19abff40db 100644 --- a/crates/gpui/src/platform/linux/x11/client.rs +++ b/crates/gpui/src/platform/linux/x11/client.rs @@ -944,6 +944,8 @@ impl X11Client { let window = self.get_window(event.event)?; window.set_active(false); let mut state = self.0.borrow_mut(); + // Set last scroll values to `None` so that a large delta isn't created if scrolling is done outside the window (the valuator is global) + reset_all_pointer_device_scroll_positions(&mut state.pointer_device_states); state.keyboard_focused_window = None; if let Some(compose_state) = state.compose_state.as_mut() { compose_state.reset(); From 1d76539d28ec7dbf0ad7e2af4604b61478d3f822 Mon Sep 17 00:00:00 2001 From: Mayank Verma Date: Sat, 20 Dec 2025 06:03:32 +0530 Subject: [PATCH 581/621] gpui: Fix hover styles not being applied during layout (#43324) Closes #43214 Release Notes: - Fixed GPUI hover styles not being applied during layout Here's the before/after: https://github.com/user-attachments/assets/5b1828bb-234a-493b-a33d-368ca01a773b --- crates/gpui/src/elements/div.rs | 95 ++++++++++++++++++++++++++++----- 1 file changed, 83 insertions(+), 12 deletions(-) diff --git a/crates/gpui/src/elements/div.rs b/crates/gpui/src/elements/div.rs index cf55edefaf70c080e171a8e21b350fd3c6d82f75..547d967620d68c309563af1d2e56d2ab3f194d4f 100644 --- a/crates/gpui/src/elements/div.rs +++ b/crates/gpui/src/elements/div.rs @@ -1730,6 +1730,11 @@ impl Interactivity { let clicked_state = clicked_state.borrow(); self.active = Some(clicked_state.element); } + if self.hover_style.is_some() || self.group_hover_style.is_some() { + element_state + .hover_state + .get_or_insert_with(Default::default); + } if let Some(active_tooltip) = element_state.active_tooltip.as_ref() { if self.tooltip_builder.is_some() { self.tooltip_id = set_tooltip_on_window(active_tooltip, window); @@ -2150,14 +2155,46 @@ impl Interactivity { { let hitbox = hitbox.clone(); let was_hovered = hitbox.is_hovered(window); + let hover_state = self.hover_style.as_ref().and_then(|_| { + element_state + .as_ref() + .and_then(|state| state.hover_state.as_ref()) + .cloned() + }); let current_view = window.current_view(); window.on_mouse_event(move |_: &MouseMoveEvent, phase, window, cx| { let hovered = hitbox.is_hovered(window); if phase == DispatchPhase::Capture && hovered != was_hovered { + if let Some(hover_state) = &hover_state { + hover_state.borrow_mut().element = hovered; + } cx.notify(current_view); } }); } + + if let Some(group_hover) = self.group_hover_style.as_ref() { + if let Some(group_hitbox_id) = GroupHitboxes::get(&group_hover.group, cx) { + let hover_state = element_state + .as_ref() + .and_then(|element| element.hover_state.as_ref()) + .cloned(); + + let was_group_hovered = group_hitbox_id.is_hovered(window); + let current_view = window.current_view(); + + window.on_mouse_event(move |_: &MouseMoveEvent, phase, window, cx| { + let group_hovered = group_hitbox_id.is_hovered(window); + if phase == DispatchPhase::Capture && group_hovered != was_group_hovered { + if let Some(hover_state) = &hover_state { + hover_state.borrow_mut().group = group_hovered; + } + cx.notify(current_view); + } + }); + } + } + let drag_cursor_style = self.base_style.as_ref().mouse_cursor; let mut drag_listener = mem::take(&mut self.drag_listener); @@ -2346,8 +2383,8 @@ impl Interactivity { && hitbox.is_hovered(window); let mut was_hovered = was_hovered.borrow_mut(); - if is_hovered != *was_hovered { - *was_hovered = is_hovered; + if is_hovered != was_hovered.element { + was_hovered.element = is_hovered; drop(was_hovered); hover_listener(&is_hovered, window, cx); @@ -2580,22 +2617,46 @@ impl Interactivity { } } - if let Some(hitbox) = hitbox { - if !cx.has_active_drag() { - if let Some(group_hover) = self.group_hover_style.as_ref() - && let Some(group_hitbox_id) = GroupHitboxes::get(&group_hover.group, cx) - && group_hitbox_id.is_hovered(window) - { + if !cx.has_active_drag() { + if let Some(group_hover) = self.group_hover_style.as_ref() { + let is_group_hovered = + if let Some(group_hitbox_id) = GroupHitboxes::get(&group_hover.group, cx) { + group_hitbox_id.is_hovered(window) + } else if let Some(element_state) = element_state.as_ref() { + element_state + .hover_state + .as_ref() + .map(|state| state.borrow().group) + .unwrap_or(false) + } else { + false + }; + + if is_group_hovered { style.refine(&group_hover.style); } + } - if let Some(hover_style) = self.hover_style.as_ref() - && hitbox.is_hovered(window) - { + if let Some(hover_style) = self.hover_style.as_ref() { + let is_hovered = if let Some(hitbox) = hitbox { + hitbox.is_hovered(window) + } else if let Some(element_state) = element_state.as_ref() { + element_state + .hover_state + .as_ref() + .map(|state| state.borrow().element) + .unwrap_or(false) + } else { + false + }; + + if is_hovered { style.refine(hover_style); } } + } + if let Some(hitbox) = hitbox { if let Some(drag) = cx.active_drag.take() { let mut can_drop = true; if let Some(can_drop_predicate) = &self.can_drop_predicate { @@ -2654,7 +2715,7 @@ impl Interactivity { pub struct InteractiveElementState { pub(crate) focus_handle: Option, pub(crate) clicked_state: Option>>, - pub(crate) hover_state: Option>>, + pub(crate) hover_state: Option>>, pub(crate) pending_mouse_down: Option>>>, pub(crate) scroll_offset: Option>>>, pub(crate) active_tooltip: Option>>>, @@ -2676,6 +2737,16 @@ impl ElementClickedState { } } +/// Whether or not the element or a group that contains it is hovered. +#[derive(Copy, Clone, Default, Eq, PartialEq)] +pub struct ElementHoverState { + /// True if this element's group is hovered, false otherwise + pub group: bool, + + /// True if this element is hovered, false otherwise + pub element: bool, +} + pub(crate) enum ActiveTooltip { /// Currently delaying before showing the tooltip. WaitingForShow { _task: Task<()> }, From 5395197619f612aef59bd80a1108de294cc2aa77 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Fri, 19 Dec 2025 16:34:14 -0800 Subject: [PATCH 582/621] Separate out component_preview crate and add easy-to-use example binaries (#45382) Release Notes: - N/A --- Cargo.lock | 29 +++- Cargo.toml | 2 + crates/component_preview/Cargo.toml | 45 ++++++ crates/component_preview/LICENSE-GPL | 1 + .../examples/component_preview.rs | 18 +++ .../src}/component_preview.rs | 14 +- .../src/component_preview_example.rs | 145 ++++++++++++++++++ .../src}/persistence.rs | 0 crates/zed/Cargo.toml | 2 +- crates/zed/src/main.rs | 2 +- crates/zed/src/zed.rs | 1 - 11 files changed, 248 insertions(+), 11 deletions(-) create mode 100644 crates/component_preview/Cargo.toml create mode 120000 crates/component_preview/LICENSE-GPL create mode 100644 crates/component_preview/examples/component_preview.rs rename crates/{zed/src/zed => component_preview/src}/component_preview.rs (99%) create mode 100644 crates/component_preview/src/component_preview_example.rs rename crates/{zed/src/zed/component_preview => component_preview/src}/persistence.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index f9acd6989be8734b6c5b528435fccea62d10f027..f12d6a3484907a873e0e02d8e7af333c31dd9740 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3525,6 +3525,33 @@ dependencies = [ "theme", ] +[[package]] +name = "component_preview" +version = "0.1.0" +dependencies = [ + "anyhow", + "client", + "collections", + "component", + "db", + "fs", + "gpui", + "language", + "log", + "node_runtime", + "notifications", + "project", + "release_channel", + "reqwest_client", + "session", + "settings", + "theme", + "ui", + "ui_input", + "uuid", + "workspace", +] + [[package]] name = "compression-codecs" version = "0.4.31" @@ -20643,6 +20670,7 @@ dependencies = [ "collections", "command_palette", "component", + "component_preview", "copilot", "crashes", "dap", @@ -20748,7 +20776,6 @@ dependencies = [ "tree-sitter-md", "tree-sitter-rust", "ui", - "ui_input", "ui_prompt", "url", "urlencoding", diff --git a/Cargo.toml b/Cargo.toml index b507e8824484ea670619b5225fef9cfd41c81d4c..54f256abac03c50d5aa0ca0d1c5dd7d433319ddf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -39,6 +39,7 @@ members = [ "crates/command_palette", "crates/command_palette_hooks", "crates/component", + "crates/component_preview", "crates/context_server", "crates/copilot", "crates/crashes", @@ -275,6 +276,7 @@ collections = { path = "crates/collections", version = "0.1.0" } command_palette = { path = "crates/command_palette" } command_palette_hooks = { path = "crates/command_palette_hooks" } component = { path = "crates/component" } +component_preview = { path = "crates/component_preview" } context_server = { path = "crates/context_server" } copilot = { path = "crates/copilot" } crashes = { path = "crates/crashes" } diff --git a/crates/component_preview/Cargo.toml b/crates/component_preview/Cargo.toml new file mode 100644 index 0000000000000000000000000000000000000000..d7ca3bad47d74d86c701007da879ddf092a08b73 --- /dev/null +++ b/crates/component_preview/Cargo.toml @@ -0,0 +1,45 @@ +[package] +name = "component_preview" +version = "0.1.0" +edition.workspace = true +publish.workspace = true +license = "GPL-3.0-or-later" + +[lints] +workspace = true + +[lib] +path = "src/component_preview.rs" + +[features] +default = [] +preview = [] +test-support = ["db/test-support"] + +[dependencies] +anyhow.workspace = true +client.workspace = true +collections.workspace = true +component.workspace = true +db.workspace = true +fs.workspace = true +gpui.workspace = true +language.workspace = true +log.workspace = true +node_runtime.workspace = true +notifications.workspace = true +project.workspace = true +release_channel.workspace = true +reqwest_client.workspace = true +session.workspace = true +settings.workspace = true +theme.workspace = true +ui.workspace = true +ui_input.workspace = true +uuid.workspace = true +workspace.workspace = true + +[[example]] +name = "component_preview" +path = "examples/component_preview.rs" +required-features = ["preview"] diff --git a/crates/component_preview/LICENSE-GPL b/crates/component_preview/LICENSE-GPL new file mode 120000 index 0000000000000000000000000000000000000000..e0f9dbd5d63fef1630c297edc4ceba4790be6f02 --- /dev/null +++ b/crates/component_preview/LICENSE-GPL @@ -0,0 +1 @@ +LICENSE-GPL \ No newline at end of file diff --git a/crates/component_preview/examples/component_preview.rs b/crates/component_preview/examples/component_preview.rs new file mode 100644 index 0000000000000000000000000000000000000000..a49110e91ee76fef8b6f69048153f47493e52097 --- /dev/null +++ b/crates/component_preview/examples/component_preview.rs @@ -0,0 +1,18 @@ +//! Component Preview Example +//! +//! Run with: `cargo run -p component_preview --example component_preview --features="preview"` +//! +//! To use this in other projects, add the following to your `Cargo.toml`: +//! +//! ```toml +//! [dependencies] +//! component_preview = { path = "../component_preview", features = ["preview"] } +//! +//! [[example]] +//! name = "component_preview" +//! path = "examples/component_preview.rs" +//! ``` + +fn main() { + component_preview::run_component_preview(); +} diff --git a/crates/zed/src/zed/component_preview.rs b/crates/component_preview/src/component_preview.rs similarity index 99% rename from crates/zed/src/zed/component_preview.rs rename to crates/component_preview/src/component_preview.rs index e3c7fc8df542448d5b8b290e96405546be7b4b1e..0f4a8d94baf9021f0d6911e693a435ee4ab5e524 100644 --- a/crates/zed/src/zed/component_preview.rs +++ b/crates/component_preview/src/component_preview.rs @@ -1,7 +1,4 @@ -//! # Component Preview -//! -//! A view for exploring Zed components. - +mod component_preview_example; mod persistence; use client::UserStore; @@ -11,18 +8,21 @@ use gpui::{ App, Entity, EventEmitter, FocusHandle, Focusable, Task, WeakEntity, Window, list, prelude::*, }; use gpui::{ListState, ScrollHandle, ScrollStrategy, UniformListScrollHandle}; -use languages::LanguageRegistry; +use language::LanguageRegistry; use notifications::status_toast::{StatusToast, ToastIcon}; use persistence::COMPONENT_PREVIEW_DB; use project::Project; use std::{iter::Iterator, ops::Range, sync::Arc}; use ui::{ButtonLike, Divider, HighlightedLabel, ListItem, ListSubHeader, Tooltip, prelude::*}; use ui_input::InputField; +use workspace::AppState; use workspace::{ - AppState, Item, ItemId, SerializableItem, Workspace, WorkspaceId, delete_unloaded_items, - item::ItemEvent, + Item, ItemId, SerializableItem, Workspace, WorkspaceId, delete_unloaded_items, item::ItemEvent, }; +#[allow(unused_imports)] +pub use component_preview_example::*; + pub fn init(app_state: Arc, cx: &mut App) { workspace::register_serializable_item::(cx); diff --git a/crates/component_preview/src/component_preview_example.rs b/crates/component_preview/src/component_preview_example.rs new file mode 100644 index 0000000000000000000000000000000000000000..a5efd015566a6bafdf333346c33810032ec08284 --- /dev/null +++ b/crates/component_preview/src/component_preview_example.rs @@ -0,0 +1,145 @@ +/// Run the component preview application. +/// +/// This initializes the application with minimal required infrastructure +/// and opens a workspace with the ComponentPreview item. +#[cfg(feature = "preview")] +pub fn run_component_preview() { + use fs::RealFs; + use gpui::{ + AppContext as _, Application, Bounds, KeyBinding, WindowBounds, WindowOptions, actions, + size, + }; + + use client::{Client, UserStore}; + use language::LanguageRegistry; + use node_runtime::NodeRuntime; + use project::Project; + use reqwest_client::ReqwestClient; + use session::{AppSession, Session}; + use std::sync::Arc; + use ui::{App, px}; + use workspace::{AppState, Workspace, WorkspaceStore}; + + use crate::{ComponentPreview, init}; + + actions!(zed, [Quit]); + + fn quit(_: &Quit, cx: &mut App) { + cx.quit(); + } + + Application::new().run(|cx| { + component::init(); + + cx.on_action(quit); + cx.bind_keys([KeyBinding::new("cmd-q", Quit, None)]); + let version = release_channel::AppVersion::load(env!("CARGO_PKG_VERSION"), None, None); + release_channel::init(version, cx); + + let http_client = + ReqwestClient::user_agent("component_preview").expect("Failed to create HTTP client"); + cx.set_http_client(Arc::new(http_client)); + + let fs = Arc::new(RealFs::new(None, cx.background_executor().clone())); + ::set_global(fs.clone(), cx); + + settings::init(cx); + theme::init(theme::LoadThemes::JustBase, cx); + + let languages = Arc::new(LanguageRegistry::new(cx.background_executor().clone())); + let client = Client::production(cx); + client::init(&client, cx); + + let user_store = cx.new(|cx| UserStore::new(client.clone(), cx)); + let workspace_store = cx.new(|cx| WorkspaceStore::new(client.clone(), cx)); + let session_id = uuid::Uuid::new_v4().to_string(); + let session = cx.background_executor().block(Session::new(session_id)); + let session = cx.new(|cx| AppSession::new(session, cx)); + let node_runtime = NodeRuntime::unavailable(); + + let app_state = Arc::new(AppState { + languages, + client, + user_store, + workspace_store, + fs, + build_window_options: |_, _| Default::default(), + node_runtime, + session, + }); + AppState::set_global(Arc::downgrade(&app_state), cx); + + workspace::init(app_state.clone(), cx); + init(app_state.clone(), cx); + + let size = size(px(1200.), px(800.)); + let bounds = Bounds::centered(None, size, cx); + + cx.open_window( + WindowOptions { + window_bounds: Some(WindowBounds::Windowed(bounds)), + ..Default::default() + }, + { + move |window, cx| { + let app_state = app_state; + theme::setup_ui_font(window, cx); + + let project = Project::local( + app_state.client.clone(), + app_state.node_runtime.clone(), + app_state.user_store.clone(), + app_state.languages.clone(), + app_state.fs.clone(), + None, + false, + cx, + ); + + let workspace = cx.new(|cx| { + Workspace::new( + Default::default(), + project.clone(), + app_state.clone(), + window, + cx, + ) + }); + + workspace.update(cx, |workspace, cx| { + let weak_workspace = cx.entity().downgrade(); + let language_registry = app_state.languages.clone(); + let user_store = app_state.user_store.clone(); + + let component_preview = cx.new(|cx| { + ComponentPreview::new( + weak_workspace, + project, + language_registry, + user_store, + None, + None, + window, + cx, + ) + .expect("Failed to create component preview") + }); + + workspace.add_item_to_active_pane( + Box::new(component_preview), + None, + true, + window, + cx, + ); + }); + + workspace + } + }, + ) + .expect("Failed to open component preview window"); + + cx.activate(true); + }); +} diff --git a/crates/zed/src/zed/component_preview/persistence.rs b/crates/component_preview/src/persistence.rs similarity index 100% rename from crates/zed/src/zed/component_preview/persistence.rs rename to crates/component_preview/src/persistence.rs diff --git a/crates/zed/Cargo.toml b/crates/zed/Cargo.toml index 80eca20e00309bb8d22552287a1c39cb9891307d..5c5d35944672a36733d6da50505f8d5bacad74f3 100644 --- a/crates/zed/Cargo.toml +++ b/crates/zed/Cargo.toml @@ -41,6 +41,7 @@ collab_ui.workspace = true collections.workspace = true command_palette.workspace = true component.workspace = true +component_preview.workspace = true copilot.workspace = true crashes.workspace = true dap_adapters.workspace = true @@ -148,7 +149,6 @@ ztracing.workspace = true tracing.workspace = true toolchain_selector.workspace = true ui.workspace = true -ui_input.workspace = true ui_prompt.workspace = true url.workspace = true urlencoding.workspace = true diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rs index 03e02bb0107d736c07eb3fc9626856943f8d80a6..bdf3bf3f950a329e7c1b49f5ce27560b00807a5f 100644 --- a/crates/zed/src/main.rs +++ b/crates/zed/src/main.rs @@ -774,7 +774,7 @@ fn main() { let app_state = app_state.clone(); - crate::zed::component_preview::init(app_state.clone(), cx); + component_preview::init(app_state.clone(), cx); cx.spawn(async move |cx| { while let Some(urls) = open_rx.next().await { diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs index 3441cb88d96b06dfdbb65a58553d2c58f435d157..392a57520d28be021e55cbd890d2eb968370c2f7 100644 --- a/crates/zed/src/zed.rs +++ b/crates/zed/src/zed.rs @@ -1,5 +1,4 @@ mod app_menus; -pub mod component_preview; pub mod edit_prediction_registry; #[cfg(target_os = "macos")] pub(crate) mod mac_only_instance; From 42d5f7e73e8597b26f4457399d4c5afa8fed24b0 Mon Sep 17 00:00:00 2001 From: Lieunoir <33102721+Lieunoir@users.noreply.github.com> Date: Sat, 20 Dec 2025 01:38:45 +0100 Subject: [PATCH 583/621] Set override_redirect for PopUps (#42224) Currently on x11, gpui PopUp windows only rely on the "notification" type in order to indicate that they should spawn as floating window. Several window managers (leftwm in my case, but it also seems to be the case for dwm and ratpoison) do not this property into account thus not spawning them as float. On the other hand, using Floating instead of PopUp do make those windows spawn as floating, as these window manager do take into account the (older) "dialog" type. The [freedekstop documentation](https://specifications.freedesktop.org/wm/1.5/ar01s05.html#id-1.6.7) does seem to suggest that these windows should also have the override redirect property : > This property is typically used on override-redirect windows. Note that this also disables pretty much all interactions with the window manager (such as moving the window, resizing etc...) Release Notes: - Fix popup windows not spawning floating sometime on x11 --- crates/gpui/src/platform/linux/x11/window.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/gpui/src/platform/linux/x11/window.rs b/crates/gpui/src/platform/linux/x11/window.rs index 1986ff6cce6b1930bdc3527eced5f2d5b8f45117..46d1cbd3253618cae5a7df9c27195ea8921954eb 100644 --- a/crates/gpui/src/platform/linux/x11/window.rs +++ b/crates/gpui/src/platform/linux/x11/window.rs @@ -431,6 +431,7 @@ impl X11WindowState { // https://stackoverflow.com/questions/43218127/x11-xlib-xcb-creating-a-window-requires-border-pixel-if-specifying-colormap-wh .border_pixel(visual_set.black_pixel) .colormap(colormap) + .override_redirect((params.kind == WindowKind::PopUp) as u32) .event_mask( xproto::EventMask::EXPOSURE | xproto::EventMask::STRUCTURE_NOTIFY From 58461377ca064a3aadc724cfd0921f3fae5d9d85 Mon Sep 17 00:00:00 2001 From: Marshall Bowers Date: Fri, 19 Dec 2025 20:01:19 -0500 Subject: [PATCH 584/621] ci: Disable automated docs on pushes to `main` (#45416) This PR disables the automated docs on pushes to `main`, as it is currently making CI red. Release Notes: - N/A --- .github/workflows/docs_automation.yml | 54 +++++++++++++-------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/.github/workflows/docs_automation.yml b/.github/workflows/docs_automation.yml index 5b72bc4051f34ae890bc291281f8797312f5d52d..46dcfa56616c24a78f61e075d3e1a7909655b8aa 100644 --- a/.github/workflows/docs_automation.yml +++ b/.github/workflows/docs_automation.yml @@ -1,11 +1,11 @@ name: Documentation Automation on: - push: - branches: [main] - paths: - - 'crates/**' - - 'extensions/**' + # push: + # branches: [main] + # paths: + # - 'crates/**' + # - 'extensions/**' workflow_dispatch: inputs: pr_number: @@ -29,7 +29,7 @@ jobs: docs-automation: runs-on: ubuntu-latest timeout-minutes: 30 - + steps: - name: Checkout repository uses: actions/checkout@v4 @@ -77,7 +77,7 @@ jobs: echo "ref=$SHA" >> "$GITHUB_OUTPUT" git diff --name-only "${SHA}^" "$SHA" > /tmp/changed_files.txt || git diff --name-only HEAD~1 HEAD > /tmp/changed_files.txt fi - + echo "Changed files:" cat /tmp/changed_files.txt env: @@ -102,24 +102,24 @@ jobs: run: | CHANGED_FILES=$(tr '\n' ' ' < /tmp/changed_files.txt) echo "Analyzing changes in: $CHANGED_FILES" - + # Build prompt with context cat > /tmp/phase3-prompt.md << 'EOF' $(cat .factory/prompts/docs-automation/phase3-analyze.md) - + ## Context - + ### Changed Files $CHANGED_FILES - + ### Phase 2 Output $(cat /tmp/phase2-output.txt) EOF - + "$DROID_BIN" exec \ -m "$DROID_MODEL" \ "$(cat .factory/prompts/docs-automation/phase3-analyze.md) - + Changed files: $CHANGED_FILES" \ > /tmp/phase3-output.md 2>&1 || true echo "Change analysis complete" @@ -135,7 +135,7 @@ jobs: > /tmp/phase4-plan.md 2>&1 || true echo "Documentation plan complete" cat /tmp/phase4-plan.md - + # Check if updates are required if grep -q "NO_UPDATES_REQUIRED" /tmp/phase4-plan.md; then echo "updates_required=false" >> "$GITHUB_OUTPUT" @@ -163,10 +163,10 @@ jobs: run: | echo "Formatting documentation with Prettier..." cd docs && prettier --write src/ - + echo "Verifying Prettier formatting passes..." cd docs && prettier --check src/ - + echo "Prettier formatting complete" # Phase 6: Summarize Changes (Read-Only - default) @@ -176,7 +176,7 @@ jobs: run: | # Get git diff of docs git diff docs/src/ > /tmp/docs-diff.txt || true - + "$DROID_BIN" exec \ -m "$DROID_MODEL" \ -f .factory/prompts/docs-automation/phase6-summarize.md \ @@ -194,17 +194,17 @@ jobs: echo "No documentation changes detected" exit 0 fi - + # Configure git git config user.name "factory-droid[bot]" git config user.email "138933559+factory-droid[bot]@users.noreply.github.com" - + # Daily batch branch - one branch per day, multiple commits accumulate BRANCH_NAME="docs/auto-update-$(date +%Y-%m-%d)" - + # Stash local changes from phase 5 git stash push -m "docs-automation-changes" -- docs/src/ - + # Check if branch already exists on remote if git ls-remote --exit-code --heads origin "$BRANCH_NAME" > /dev/null 2>&1; then echo "Branch $BRANCH_NAME exists, checking out and updating..." @@ -214,10 +214,10 @@ jobs: echo "Creating new branch $BRANCH_NAME..." git checkout -b "$BRANCH_NAME" fi - + # Apply stashed changes git stash pop || true - + # Stage and commit git add docs/src/ SUMMARY=$(head -50 < /tmp/phase6-summary.md) @@ -228,13 +228,13 @@ jobs: Triggered by: ${{ steps.changed.outputs.source }} ${{ steps.changed.outputs.ref }} Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>" - + # Push git push -u origin "$BRANCH_NAME" - + # Check if PR already exists for this branch EXISTING_PR=$(gh pr list --head "$BRANCH_NAME" --json number --jq '.[0].number' || echo "") - + if [ -n "$EXISTING_PR" ]; then echo "PR #$EXISTING_PR already exists for branch $BRANCH_NAME, updated with new commit" else @@ -254,7 +254,7 @@ jobs: run: | echo "## Documentation Automation Summary" >> "$GITHUB_STEP_SUMMARY" echo "" >> "$GITHUB_STEP_SUMMARY" - + if [ "${{ steps.phase4.outputs.updates_required }}" == "false" ]; then echo "No documentation updates required for this change." >> "$GITHUB_STEP_SUMMARY" elif [ -f /tmp/phase6-summary.md ]; then From 0facdfa5caedb1cacf92d435697c83dad1e66ea4 Mon Sep 17 00:00:00 2001 From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Date: Fri, 19 Dec 2025 22:37:15 -0300 Subject: [PATCH 585/621] editor: Make `TextAlign::Center` and `TextAlign::Right` work (#45417) Closes https://github.com/zed-industries/zed/issues/43208 This PR essentially unblocks the editable number field. The function that shapes editor lines was hard-coding text alignment to the left, meaning that whatever different alignment we'd pass through `EditorStyles`would be ignored. To solve this, I just added a text align and align width fields to the line paint function and updated all call sites keeping the default configuration. Had to also add an `alignment_offset()` helper to make sure the cursor positioning, the selection background element, and the click-to-focus functionality were kept in-sync with the non-left aligned editor. Then... the big star of the show here is being able to add the `mode` method to the number field, which uses `TextAlign::Center`, thus making it work as we designed it to work. https://github.com/user-attachments/assets/3539c976-d7bf-4d94-8188-a14328f94fbf Next up, is turning the number filed to edit mode where applicable. Release Notes: - Fixed a bug where different text alignment configurations (i.e., center and right-aligned) wouldn't take effect in editors. --- crates/editor/src/element.rs | 106 +++++++++++++++---- crates/gpui/examples/input.rs | 11 +- crates/gpui/src/text_system/line.rs | 12 ++- crates/terminal_view/src/terminal_element.rs | 19 +++- crates/ui_input/src/number_field.rs | 66 ++++++++---- 5 files changed, 164 insertions(+), 50 deletions(-) diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index b2e355dc5158214eabd07d519649591be8a325a8..ae8dd527122f19bdf7566e4dba3a504e6d19261d 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -46,9 +46,9 @@ use gpui::{ KeybindingKeystroke, Length, Modifiers, ModifiersChangedEvent, MouseButton, MouseClickEvent, MouseDownEvent, MouseMoveEvent, MousePressureEvent, MouseUpEvent, PaintQuad, ParentElement, Pixels, PressureStage, ScrollDelta, ScrollHandle, ScrollWheelEvent, ShapedLine, SharedString, - Size, StatefulInteractiveElement, Style, Styled, TextRun, TextStyleRefinement, WeakEntity, - Window, anchored, deferred, div, fill, linear_color_stop, linear_gradient, outline, point, px, - quad, relative, size, solid_background, transparent_black, + Size, StatefulInteractiveElement, Style, Styled, TextAlign, TextRun, TextStyleRefinement, + WeakEntity, Window, anchored, deferred, div, fill, linear_color_stop, linear_gradient, outline, + point, px, quad, relative, size, solid_background, transparent_black, }; use itertools::Itertools; use language::{IndentGuideSettings, language_settings::ShowWhitespaceSetting}; @@ -1695,9 +1695,13 @@ impl EditorElement { [cursor_position.row().minus(visible_display_row_range.start) as usize]; let cursor_column = cursor_position.column() as usize; - let cursor_character_x = cursor_row_layout.x_for_index(cursor_column); - let mut block_width = - cursor_row_layout.x_for_index(cursor_column + 1) - cursor_character_x; + let cursor_character_x = cursor_row_layout.x_for_index(cursor_column) + + cursor_row_layout + .alignment_offset(self.style.text.text_align, text_hitbox.size.width); + let cursor_next_x = cursor_row_layout.x_for_index(cursor_column + 1) + + cursor_row_layout + .alignment_offset(self.style.text.text_align, text_hitbox.size.width); + let mut block_width = cursor_next_x - cursor_character_x; if block_width == Pixels::ZERO { block_width = em_advance; } @@ -6160,10 +6164,25 @@ impl EditorElement { let color = cx.theme().colors().editor_hover_line_number; let line = self.shape_line_number(shaped_line.text.clone(), color, window); - line.paint(hitbox.origin, line_height, window, cx).log_err() + line.paint( + hitbox.origin, + line_height, + TextAlign::Left, + None, + window, + cx, + ) + .log_err() } else { shaped_line - .paint(hitbox.origin, line_height, window, cx) + .paint( + hitbox.origin, + line_height, + TextAlign::Left, + None, + window, + cx, + ) .log_err() }) else { continue; @@ -7252,23 +7271,27 @@ impl EditorElement { .map(|row| { let line_layout = &layout.position_map.line_layouts[row.minus(start_row) as usize]; + let alignment_offset = + line_layout.alignment_offset(layout.text_align, layout.content_width); HighlightedRangeLine { start_x: if row == range.start.row() { layout.content_origin.x + Pixels::from( ScrollPixelOffset::from( - line_layout.x_for_index(range.start.column() as usize), + line_layout.x_for_index(range.start.column() as usize) + + alignment_offset, ) - layout.position_map.scroll_pixel_position.x, ) } else { - layout.content_origin.x + layout.content_origin.x + alignment_offset - Pixels::from(layout.position_map.scroll_pixel_position.x) }, end_x: if row == range.end.row() { layout.content_origin.x + Pixels::from( ScrollPixelOffset::from( - line_layout.x_for_index(range.end.column() as usize), + line_layout.x_for_index(range.end.column() as usize) + + alignment_offset, ) - layout.position_map.scroll_pixel_position.x, ) } else { @@ -7276,6 +7299,7 @@ impl EditorElement { ScrollPixelOffset::from( layout.content_origin.x + line_layout.width + + alignment_offset + line_end_overshoot, ) - layout.position_map.scroll_pixel_position.x, ) @@ -8516,8 +8540,15 @@ impl LineWithInvisibles { for fragment in &self.fragments { match fragment { LineFragment::Text(line) => { - line.paint(fragment_origin, line_height, window, cx) - .log_err(); + line.paint( + fragment_origin, + line_height, + layout.text_align, + Some(layout.content_width), + window, + cx, + ) + .log_err(); fragment_origin.x += line.width; } LineFragment::Element { size, .. } => { @@ -8559,8 +8590,15 @@ impl LineWithInvisibles { for fragment in &self.fragments { match fragment { LineFragment::Text(line) => { - line.paint_background(fragment_origin, line_height, window, cx) - .log_err(); + line.paint_background( + fragment_origin, + line_height, + layout.text_align, + Some(layout.content_width), + window, + cx, + ) + .log_err(); fragment_origin.x += line.width; } LineFragment::Element { size, .. } => { @@ -8609,7 +8647,7 @@ impl LineWithInvisibles { [token_offset, token_end_offset], Box::new(move |window: &mut Window, cx: &mut App| { invisible_symbol - .paint(origin, line_height, window, cx) + .paint(origin, line_height, TextAlign::Left, None, window, cx) .log_err(); }), ) @@ -8770,6 +8808,15 @@ impl LineWithInvisibles { None } + + pub fn alignment_offset(&self, text_align: TextAlign, content_width: Pixels) -> Pixels { + let line_width = self.width; + match text_align { + TextAlign::Left => px(0.0), + TextAlign::Center => (content_width - line_width) / 2.0, + TextAlign::Right => content_width - line_width, + } + } } #[derive(Debug, Clone, Copy, PartialEq, Eq)] @@ -10172,6 +10219,8 @@ impl Element for EditorElement { em_width, em_advance, snapshot, + text_align: self.style.text.text_align, + content_width: text_hitbox.size.width, gutter_hitbox: gutter_hitbox.clone(), text_hitbox: text_hitbox.clone(), inline_blame_bounds: inline_blame_layout @@ -10225,6 +10274,8 @@ impl Element for EditorElement { sticky_buffer_header, sticky_headers, expand_toggles, + text_align: self.style.text.text_align, + content_width: text_hitbox.size.width, } }) }) @@ -10405,6 +10456,8 @@ pub struct EditorLayout { sticky_buffer_header: Option, sticky_headers: Option, document_colors: Option<(DocumentColorsRenderMode, Vec<(Range, Hsla)>)>, + text_align: TextAlign, + content_width: Pixels, } struct StickyHeaders { @@ -10572,7 +10625,9 @@ impl StickyHeaderLine { gutter_origin.x + gutter_width - gutter_right_padding - line_number.width, gutter_origin.y, ); - line_number.paint(origin, line_height, window, cx).log_err(); + line_number + .paint(origin, line_height, TextAlign::Left, None, window, cx) + .log_err(); } } } @@ -11011,6 +11066,8 @@ pub(crate) struct PositionMap { pub visible_row_range: Range, pub line_layouts: Vec, pub snapshot: EditorSnapshot, + pub text_align: TextAlign, + pub content_width: Pixels, pub text_hitbox: Hitbox, pub gutter_hitbox: Hitbox, pub inline_blame_bounds: Option<(Bounds, BufferId, BlameEntry)>, @@ -11076,10 +11133,12 @@ impl PositionMap { .line_layouts .get(row as usize - scroll_position.y as usize) { - if let Some(ix) = line.index_for_x(x) { + let alignment_offset = line.alignment_offset(self.text_align, self.content_width); + let x_relative_to_text = x - alignment_offset; + if let Some(ix) = line.index_for_x(x_relative_to_text) { (ix as u32, px(0.)) } else { - (line.len as u32, px(0.).max(x - line.width)) + (line.len as u32, px(0.).max(x_relative_to_text - line.width)) } } else { (0, x) @@ -11268,7 +11327,14 @@ impl CursorLayout { if let Some(block_text) = &self.block_text { block_text - .paint(self.origin + origin, self.line_height, window, cx) + .paint( + self.origin + origin, + self.line_height, + TextAlign::Left, + None, + window, + cx, + ) .log_err(); } } diff --git a/crates/gpui/examples/input.rs b/crates/gpui/examples/input.rs index 44fae4ffe6bb9e120a8f96c10e0af8f4f8026cdd..aac56bdf1d0b739f28f395e537b171264c78a1e8 100644 --- a/crates/gpui/examples/input.rs +++ b/crates/gpui/examples/input.rs @@ -546,8 +546,15 @@ impl Element for TextElement { window.paint_quad(selection) } let line = prepaint.line.take().unwrap(); - line.paint(bounds.origin, window.line_height(), window, cx) - .unwrap(); + line.paint( + bounds.origin, + window.line_height(), + gpui::TextAlign::Left, + None, + window, + cx, + ) + .unwrap(); if focus_handle.is_focused(window) && let Some(cursor) = prepaint.cursor.take() diff --git a/crates/gpui/src/text_system/line.rs b/crates/gpui/src/text_system/line.rs index 84618eccc43dc3f189d3d49ea22b9d98f5ad9f85..1e71a611c7cef4b22668db8840ea5dac7fa13709 100644 --- a/crates/gpui/src/text_system/line.rs +++ b/crates/gpui/src/text_system/line.rs @@ -64,6 +64,8 @@ impl ShapedLine { &self, origin: Point, line_height: Pixels, + align: TextAlign, + align_width: Option, window: &mut Window, cx: &mut App, ) -> Result<()> { @@ -71,8 +73,8 @@ impl ShapedLine { origin, &self.layout, line_height, - TextAlign::default(), - None, + align, + align_width, &self.decoration_runs, &[], window, @@ -87,6 +89,8 @@ impl ShapedLine { &self, origin: Point, line_height: Pixels, + align: TextAlign, + align_width: Option, window: &mut Window, cx: &mut App, ) -> Result<()> { @@ -94,8 +98,8 @@ impl ShapedLine { origin, &self.layout, line_height, - TextAlign::default(), - None, + align, + align_width, &self.decoration_runs, &[], window, diff --git a/crates/terminal_view/src/terminal_element.rs b/crates/terminal_view/src/terminal_element.rs index b5324b7c6c7e0c467c657b122717fbf17cf9f7b9..c5289a34d6cbc9ecc4ddcdaacb6aaf2ce0831846 100644 --- a/crates/terminal_view/src/terminal_element.rs +++ b/crates/terminal_view/src/terminal_element.rs @@ -151,7 +151,14 @@ impl BatchedTextRun { std::slice::from_ref(&self.style), Some(dimensions.cell_width), ) - .paint(pos, dimensions.line_height, window, cx); + .paint( + pos, + dimensions.line_height, + gpui::TextAlign::Left, + None, + window, + cx, + ); } } @@ -1326,8 +1333,14 @@ impl Element for TerminalElement { }], None ); - shaped_line - .paint(ime_position, layout.dimensions.line_height, window, cx) + shaped_line.paint( + ime_position, + layout.dimensions.line_height, + gpui::TextAlign::Left, + None, + window, + cx, + ) .log_err(); } diff --git a/crates/ui_input/src/number_field.rs b/crates/ui_input/src/number_field.rs index 2d596a2498f445f6a0d18ce48b02bddf20aee8da..389f61c748615da162c04182e855459f62d3d226 100644 --- a/crates/ui_input/src/number_field.rs +++ b/crates/ui_input/src/number_field.rs @@ -5,8 +5,11 @@ use std::{ str::FromStr, }; -use editor::{Editor, EditorStyle}; -use gpui::{ClickEvent, Entity, FocusHandle, Focusable, FontWeight, Modifiers}; +use editor::Editor; +use gpui::{ + ClickEvent, Entity, FocusHandle, Focusable, FontWeight, Modifiers, TextAlign, + TextStyleRefinement, +}; use settings::{CenteredPaddingSettings, CodeFade, DelayMs, InactiveOpacity, MinimumContrast}; use ui::prelude::*; @@ -309,6 +312,11 @@ impl NumberField { self } + pub fn mode(self, mode: NumberFieldMode, cx: &mut App) -> Self { + self.mode.write(cx, mode); + self + } + pub fn on_reset( mut self, on_reset: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static, @@ -451,9 +459,11 @@ impl RenderOnce for NumberField { |window, cx| { let previous_focus_handle = window.focused(cx); let mut editor = Editor::single_line(window, cx); - let mut style = EditorStyle::default(); - style.text.text_align = gpui::TextAlign::Right; - editor.set_style(style, window, cx); + + editor.set_text_style_refinement(TextStyleRefinement { + text_align: Some(TextAlign::Center), + ..Default::default() + }); editor.set_text(format!("{}", self.value), window, cx); cx.on_focus_out(&editor.focus_handle(cx), window, { @@ -555,22 +565,36 @@ impl Component for NumberField { Some( v_flex() .gap_6() - .children(vec![single_example( - "Default Numeric Stepper", - NumberField::new( - "numeric-stepper-component-preview", - *stepper_example.read(cx), - window, - cx, - ) - .on_change({ - let stepper_example = stepper_example.clone(); - move |value, _, cx| stepper_example.write(cx, *value) - }) - .min(1.0) - .max(100.0) - .into_any_element(), - )]) + .children(vec![ + single_example( + "Default Number Field", + NumberField::new("number-field", *stepper_example.read(cx), window, cx) + .on_change({ + let stepper_example = stepper_example.clone(); + move |value, _, cx| stepper_example.write(cx, *value) + }) + .min(1.0) + .max(100.0) + .into_any_element(), + ), + single_example( + "Read-Only Number Field", + NumberField::new( + "editable-number-field", + *stepper_example.read(cx), + window, + cx, + ) + .on_change({ + let stepper_example = stepper_example.clone(); + move |value, _, cx| stepper_example.write(cx, *value) + }) + .min(1.0) + .max(100.0) + .mode(NumberFieldMode::Edit, cx) + .into_any_element(), + ), + ]) .into_any_element(), ) } From 6dad419cd58d858197b14172eb5d7987cb7a1890 Mon Sep 17 00:00:00 2001 From: Hidehiro Anto Date: Fri, 19 Dec 2025 22:51:22 -0700 Subject: [PATCH 586/621] Update version example in remote-development.md (#45427) Updated the version example for maintaining the remote server binary. Release Notes: - N/A --- docs/src/remote-development.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/remote-development.md b/docs/src/remote-development.md index c25d160a17549f6338f25741afd68391cf88d769..e576a7c662d8a7cde900d8234ae0190776272a26 100644 --- a/docs/src/remote-development.md +++ b/docs/src/remote-development.md @@ -216,7 +216,7 @@ Once the master connection is established, Zed will check to see if the remote s If it is not there or the version mismatches, Zed will try to download the latest version. By default, it will download from `https://zed.dev` directly, but if you set: `{"upload_binary_over_ssh":true}` in your settings for that server, it will download the binary to your local machine and then upload it to the remote server. -If you'd like to maintain the server binary yourself you can. You can either download our prebuilt versions from [GitHub](https://github.com/zed-industries/zed/releases), or [build your own](https://zed.dev/docs/development) with `cargo build -p remote_server --release`. If you do this, you must upload it to `~/.zed_server/zed-remote-server-{RELEASE_CHANNEL}-{VERSION}` on the server, for example `~/.zed_server/zed-remote-server-stable-0.181.6`. The version must exactly match the version of Zed itself you are using. +If you'd like to maintain the server binary yourself you can. You can either download our prebuilt versions from [GitHub](https://github.com/zed-industries/zed/releases), or [build your own](https://zed.dev/docs/development) with `cargo build -p remote_server --release`. If you do this, you must upload it to `~/.zed_server/zed-remote-server-{RELEASE_CHANNEL}-{VERSION}` on the server, for example `~/.zed_server/zed-remote-server-stable-0.217.3+stable.105.80433cb239e868271457ac376673a5f75bc4adb1`. The version must exactly match the version of Zed itself you are using. ## Maintaining the SSH connection From 7f0842e3a64d5ad24937b0e74fb6afecd8236970 Mon Sep 17 00:00:00 2001 From: Zachiah Sawyer Date: Fri, 19 Dec 2025 22:00:04 -0800 Subject: [PATCH 587/621] proto: Add `extend` keyword (#45413) Closes #45385 Release Notes: - Add extend keyword to proto --- extensions/proto/languages/proto/highlights.scm | 1 + 1 file changed, 1 insertion(+) diff --git a/extensions/proto/languages/proto/highlights.scm b/extensions/proto/languages/proto/highlights.scm index 5d0a513bee1ca4597c649fbe8e6ca31a00fe9dff..923e00bb1dfca30afcf41a6ab681846d8f20b900 100644 --- a/extensions/proto/languages/proto/highlights.scm +++ b/extensions/proto/languages/proto/highlights.scm @@ -9,6 +9,7 @@ "returns" "message" "enum" + "extend" "oneof" "repeated" "reserved" From 3e8c25f5a9e41a5303d30ff752576201118700d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=B4=80=E1=B4=8D=E1=B4=9B=E1=B4=8F=E1=B4=80=E1=B4=87?= =?UTF-8?q?=CA=80?= Date: Sat, 20 Dec 2025 22:08:56 +0800 Subject: [PATCH 588/621] Remove extra shortcut separator in default mode & model selection tooltips (#45439) Closes #44118 Release Notes: - N/A --- crates/agent_ui/src/ui/hold_for_default.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/agent_ui/src/ui/hold_for_default.rs b/crates/agent_ui/src/ui/hold_for_default.rs index 409e5d59707caa3a6bc62bbf470e33cb150183f5..1972f5de4d38fd5ba47ff91709be6ded302b61ae 100644 --- a/crates/agent_ui/src/ui/hold_for_default.rs +++ b/crates/agent_ui/src/ui/hold_for_default.rs @@ -27,7 +27,7 @@ impl RenderOnce for HoldForDefault { PlatformStyle::platform(), None, Some(TextSize::Default.rems(cx).into()), - true, + false, ))) .child(div().map(|this| { if self.is_default { From a5540a08fb7ea3f6a94934e599eb843a8496d38d Mon Sep 17 00:00:00 2001 From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Date: Sat, 20 Dec 2025 11:15:46 -0300 Subject: [PATCH 589/621] ui: Make the NumberField in edit mode work (#45447) - Make the buttons capable of changing the editor's content (incrementing or decrementing the value) - Make arrow key up and down increment and decrement the editor value - Tried to apply a bit of DRY here by creating some functions that can be reused across the buttons and editor given they all essentially do the same thing (change the value) - Fixed an issue where the editor would not allow focus to move elsewhere, making it impossible to open a dropdown, for example, if your focus was on the number field's editor Release Notes: - N/A --- crates/ui_input/src/number_field.rs | 255 ++++++++++++++++++++-------- 1 file changed, 187 insertions(+), 68 deletions(-) diff --git a/crates/ui_input/src/number_field.rs b/crates/ui_input/src/number_field.rs index 389f61c748615da162c04182e855459f62d3d226..b07cc5d9dc17dc6c761d02222807101d19cecc33 100644 --- a/crates/ui_input/src/number_field.rs +++ b/crates/ui_input/src/number_field.rs @@ -5,10 +5,10 @@ use std::{ str::FromStr, }; -use editor::Editor; +use editor::{Editor, actions::MoveDown, actions::MoveUp}; use gpui::{ ClickEvent, Entity, FocusHandle, Focusable, FontWeight, Modifiers, TextAlign, - TextStyleRefinement, + TextStyleRefinement, WeakEntity, }; use settings::{CenteredPaddingSettings, CodeFade, DelayMs, InactiveOpacity, MinimumContrast}; @@ -238,12 +238,14 @@ impl_numeric_stepper_nonzero_int!(NonZeroU32, u32); impl_numeric_stepper_nonzero_int!(NonZeroU64, u64); impl_numeric_stepper_nonzero_int!(NonZero, usize); -#[derive(RegisterComponent)] -pub struct NumberField { +#[derive(IntoElement, RegisterComponent)] +pub struct NumberField { id: ElementId, value: T, focus_handle: FocusHandle, mode: Entity, + /// Stores a weak reference to the editor when in edit mode, so buttons can update its text + edit_editor: Entity>>, format: Box String>, large_step: T, small_step: T, @@ -259,15 +261,17 @@ impl NumberField { pub fn new(id: impl Into, value: T, window: &mut Window, cx: &mut App) -> Self { let id = id.into(); - let (mode, focus_handle) = window.with_id(id.clone(), |window| { + let (mode, focus_handle, edit_editor) = window.with_id(id.clone(), |window| { let mode = window.use_state(cx, |_, _| NumberFieldMode::default()); let focus_handle = window.use_state(cx, |_, cx| cx.focus_handle()); - (mode, focus_handle) + let edit_editor = window.use_state(cx, |_, _| None); + (mode, focus_handle, edit_editor) }); Self { id, mode, + edit_editor, value, focus_handle: focus_handle.read(cx).clone(), format: Box::new(T::default_format), @@ -336,17 +340,16 @@ impl NumberField { } } -impl IntoElement for NumberField { - type Element = gpui::Component; - - fn into_element(self) -> Self::Element { - gpui::Component::new(self) - } +#[derive(Clone, Copy)] +enum ValueChangeDirection { + Increment, + Decrement, } impl RenderOnce for NumberField { fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement { let mut tab_index = self.tab_index; + let is_edit_mode = matches!(*self.mode.read(cx), NumberFieldMode::Edit); let get_step = { let large_step = self.large_step; @@ -363,6 +366,67 @@ impl RenderOnce for NumberField { } }; + let clamp_value = { + let min = self.min_value; + let max = self.max_value; + move |value: T| -> T { + if value < min { + min + } else if value > max { + max + } else { + value + } + } + }; + + let change_value = { + move |current: T, step: T, direction: ValueChangeDirection| -> T { + let new_value = match direction { + ValueChangeDirection::Increment => current.saturating_add(step), + ValueChangeDirection::Decrement => current.saturating_sub(step), + }; + clamp_value(new_value) + } + }; + + let get_current_value = { + let value = self.value; + let edit_editor = self.edit_editor.clone(); + + Rc::new(move |cx: &App| -> T { + if !is_edit_mode { + return value; + } + edit_editor + .read(cx) + .as_ref() + .and_then(|weak| weak.upgrade()) + .and_then(|editor| editor.read(cx).text(cx).parse::().ok()) + .unwrap_or(value) + }) + }; + + let update_editor_text = { + let edit_editor = self.edit_editor.clone(); + + Rc::new(move |new_value: T, window: &mut Window, cx: &mut App| { + if !is_edit_mode { + return; + } + let Some(editor) = edit_editor + .read(cx) + .as_ref() + .and_then(|weak| weak.upgrade()) + else { + return; + }; + editor.update(cx, |editor, cx| { + editor.set_text(format!("{}", new_value), window, cx); + }); + }) + }; + let bg_color = cx.theme().colors().surface_background; let hover_bg_color = cx.theme().colors().element_hover; @@ -403,13 +467,20 @@ impl RenderOnce for NumberField { h_flex() .map(|decrement| { let decrement_handler = { - let value = self.value; let on_change = self.on_change.clone(); - let min = self.min_value; + let get_current_value = get_current_value.clone(); + let update_editor_text = update_editor_text.clone(); + move |click: &ClickEvent, window: &mut Window, cx: &mut App| { + let current_value = get_current_value(cx); let step = get_step(click.modifiers()); - let new_value = value.saturating_sub(step); - let new_value = if new_value < min { min } else { new_value }; + let new_value = change_value( + current_value, + step, + ValueChangeDirection::Decrement, + ); + + update_editor_text(new_value, window, cx); on_change(&new_value, window, cx); } }; @@ -446,18 +517,10 @@ impl RenderOnce for NumberField { .justify_center() .child(Label::new((self.format)(&self.value))) .into_any_element(), - // Edit mode is disabled until we implement center text alignment for editor - // mode.write(cx, NumberFieldMode::Edit); - // - // When we get to making Edit mode work, we shouldn't even focus the decrement/increment buttons. - // Focus should go instead straight to the editor, avoiding any double-step focus. - // In this world, the buttons become a mouse-only interaction, given users should be able - // to do everything they'd do with the buttons straight in the editor anyway. NumberFieldMode::Edit => h_flex() .flex_1() .child(window.use_state(cx, { |window, cx| { - let previous_focus_handle = window.focused(cx); let mut editor = Editor::single_line(window, cx); editor.set_text_style_refinement(TextStyleRefinement { @@ -466,28 +529,85 @@ impl RenderOnce for NumberField { }); editor.set_text(format!("{}", self.value), window, cx); + + let editor_weak = cx.entity().downgrade(); + + self.edit_editor.update(cx, |state, _| { + *state = Some(editor_weak); + }); + + editor + .register_action::({ + let on_change = self.on_change.clone(); + let editor_handle = cx.entity().downgrade(); + move |_, window, cx| { + let Some(editor) = editor_handle.upgrade() + else { + return; + }; + editor.update(cx, |editor, cx| { + if let Ok(current_value) = + editor.text(cx).parse::() + { + let step = + get_step(window.modifiers()); + let new_value = change_value( + current_value, + step, + ValueChangeDirection::Increment, + ); + editor.set_text( + format!("{}", new_value), + window, + cx, + ); + on_change(&new_value, window, cx); + } + }); + } + }) + .detach(); + + editor + .register_action::({ + let on_change = self.on_change.clone(); + let editor_handle = cx.entity().downgrade(); + move |_, window, cx| { + let Some(editor) = editor_handle.upgrade() + else { + return; + }; + editor.update(cx, |editor, cx| { + if let Ok(current_value) = + editor.text(cx).parse::() + { + let step = + get_step(window.modifiers()); + let new_value = change_value( + current_value, + step, + ValueChangeDirection::Decrement, + ); + editor.set_text( + format!("{}", new_value), + window, + cx, + ); + on_change(&new_value, window, cx); + } + }); + } + }) + .detach(); + cx.on_focus_out(&editor.focus_handle(cx), window, { let mode = self.mode.clone(); - let min = self.min_value; - let max = self.max_value; let on_change = self.on_change.clone(); move |this, _, window, cx| { - if let Ok(new_value) = + if let Ok(parsed_value) = this.text(cx).parse::() { - let new_value = if new_value < min { - min - } else if new_value > max { - max - } else { - new_value - }; - - if let Some(previous) = - previous_focus_handle.as_ref() - { - window.focus(previous, cx); - } + let new_value = clamp_value(parsed_value); on_change(&new_value, window, cx); }; mode.write(cx, NumberFieldMode::Read); @@ -510,13 +630,20 @@ impl RenderOnce for NumberField { ) .map(|increment| { let increment_handler = { - let value = self.value; let on_change = self.on_change.clone(); - let max = self.max_value; + let get_current_value = get_current_value.clone(); + let update_editor_text = update_editor_text.clone(); + move |click: &ClickEvent, window: &mut Window, cx: &mut App| { + let current_value = get_current_value(cx); let step = get_step(click.modifiers()); - let new_value = value.saturating_add(step); - let new_value = if new_value > max { max } else { new_value }; + let new_value = change_value( + current_value, + step, + ValueChangeDirection::Increment, + ); + + update_editor_text(new_value, window, cx); on_change(&new_value, window, cx); } }; @@ -551,48 +678,40 @@ impl Component for NumberField { "Number Field" } - fn sort_name() -> &'static str { - Self::name() - } - fn description() -> Option<&'static str> { Some("A numeric input element with increment and decrement buttons.") } fn preview(window: &mut Window, cx: &mut App) -> Option { - let stepper_example = window.use_state(cx, |_, _| 100.0); + let default_ex = window.use_state(cx, |_, _| 100.0); + let edit_ex = window.use_state(cx, |_, _| 500.0); Some( v_flex() .gap_6() .children(vec![ single_example( - "Default Number Field", - NumberField::new("number-field", *stepper_example.read(cx), window, cx) + "Button-Only Number Field", + NumberField::new("number-field", *default_ex.read(cx), window, cx) .on_change({ - let stepper_example = stepper_example.clone(); - move |value, _, cx| stepper_example.write(cx, *value) + let default_ex = default_ex.clone(); + move |value, _, cx| default_ex.write(cx, *value) }) .min(1.0) .max(100.0) .into_any_element(), ), single_example( - "Read-Only Number Field", - NumberField::new( - "editable-number-field", - *stepper_example.read(cx), - window, - cx, - ) - .on_change({ - let stepper_example = stepper_example.clone(); - move |value, _, cx| stepper_example.write(cx, *value) - }) - .min(1.0) - .max(100.0) - .mode(NumberFieldMode::Edit, cx) - .into_any_element(), + "Editable Number Field", + NumberField::new("editable-number-field", *edit_ex.read(cx), window, cx) + .on_change({ + let edit_ex = edit_ex.clone(); + move |value, _, cx| edit_ex.write(cx, *value) + }) + .min(100.0) + .max(500.0) + .mode(NumberFieldMode::Edit, cx) + .into_any_element(), ), ]) .into_any_element(), From 215ac50bc8645f38db3d62c02dc21c7694c45b7d Mon Sep 17 00:00:00 2001 From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Date: Sat, 20 Dec 2025 13:29:13 -0300 Subject: [PATCH 590/621] agent_ui: Fix markdown block for tool call input and output content (#45454) This PR fixes two issues with regards to markdown codeblocks rendered in tool call input and output content display: - the JSON code snippets weren't properly indented - codeblocks weren't being rendered in unique containers; e.g., if you hovered one scrollbar, all of them would also be hovered, even though horizontal scrolling itself worked properly Here's the end result: https://github.com/user-attachments/assets/3d6daf64-0f88-4a16-a5a0-94998c1ba7e2 Release Notes: - agent: Fix scrollbar and JSON indentation for tool call input/output content's markdown codeblocks. --- crates/acp_thread/src/acp_thread.rs | 5 ++++- crates/agent_ui/src/acp/thread_view.rs | 28 +++++++++++++++----------- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/crates/acp_thread/src/acp_thread.rs b/crates/acp_thread/src/acp_thread.rs index a994cc8e57e4456ec57092b2257269b104af74c7..3fe833cbeade93ffba422198fa6bf21180b26efe 100644 --- a/crates/acp_thread/src/acp_thread.rs +++ b/crates/acp_thread/src/acp_thread.rs @@ -11,6 +11,7 @@ use language::language_settings::FormatOnSave; pub use mention::*; use project::lsp_store::{FormatTrigger, LspFormatTarget}; use serde::{Deserialize, Serialize}; +use serde_json::to_string_pretty; use settings::Settings as _; use task::{Shell, ShellBuilder}; pub use terminal::*; @@ -2422,8 +2423,10 @@ fn markdown_for_raw_output( ) })), value => Some(cx.new(|cx| { + let pretty_json = to_string_pretty(value).unwrap_or_else(|_| value.to_string()); + Markdown::new( - format!("```json\n{}\n```", value).into(), + format!("```json\n{}\n```", pretty_json).into(), Some(language_registry.clone()), None, cx, diff --git a/crates/agent_ui/src/acp/thread_view.rs b/crates/agent_ui/src/acp/thread_view.rs index 32b2de2c0d850676bf7a6a80ee88950d62aa24e0..72d5536ce28641d6a7b830346542beece52bf6e0 100644 --- a/crates/agent_ui/src/acp/thread_view.rs +++ b/crates/agent_ui/src/acp/thread_view.rs @@ -2489,9 +2489,11 @@ impl AcpThreadView { .border_color(self.tool_card_border_color(cx)) .child(input_output_header("Raw Input:".into())) .children(tool_call.raw_input_markdown.clone().map(|input| { - self.render_markdown( - input, - default_markdown_style(false, false, window, cx), + div().id(("tool-call-raw-input-markdown", entry_ix)).child( + self.render_markdown( + input, + default_markdown_style(false, false, window, cx), + ), ) })) .child(input_output_header("Output:".into())), @@ -2499,15 +2501,17 @@ impl AcpThreadView { }) .children(tool_call.content.iter().enumerate().map( |(content_ix, content)| { - div().child(self.render_tool_call_content( - entry_ix, - content, - content_ix, - tool_call, - use_card_layout, - window, - cx, - )) + div().id(("tool-call-output", entry_ix)).child( + self.render_tool_call_content( + entry_ix, + content, + content_ix, + tool_call, + use_card_layout, + window, + cx, + ), + ) }, )) .into_any(), From 32621dc5ded88bde43ee7a463f72f747581435a0 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Sat, 20 Dec 2025 10:42:58 -0700 Subject: [PATCH 591/621] Fix race condition in `update_last_checkpoint` (#44801) Release Notes: - Fixed spurious "no checkpoint" error in agent panel --- ## Summary `update_last_checkpoint` would call `last_user_message()` twice - once at the start to capture the checkpoint, and again in an async closure after the checkpoint comparison completed. If a new user message without a checkpoint was added between these two calls, the second call would find the new message and fail with "no checkpoint". ## Fix Capture the user message ID at the start and use `user_message_mut(&id)` in the async closure to find the specific message. cc @mikayla-maki --- crates/acp_thread/src/acp_thread.rs | 115 ++++++++++++++++++++++------ 1 file changed, 91 insertions(+), 24 deletions(-) diff --git a/crates/acp_thread/src/acp_thread.rs b/crates/acp_thread/src/acp_thread.rs index 3fe833cbeade93ffba422198fa6bf21180b26efe..bebe1cc5fd811d17c14d1f8fc2cf206805f1c955 100644 --- a/crates/acp_thread/src/acp_thread.rs +++ b/crates/acp_thread/src/acp_thread.rs @@ -1993,37 +1993,42 @@ impl AcpThread { fn update_last_checkpoint(&mut self, cx: &mut Context) -> Task> { let git_store = self.project.read(cx).git_store().clone(); - let old_checkpoint = if let Some((_, message)) = self.last_user_message() { - if let Some(checkpoint) = message.checkpoint.as_ref() { - checkpoint.git_checkpoint.clone() - } else { - return Task::ready(Ok(())); - } - } else { + let Some((_, message)) = self.last_user_message() else { + return Task::ready(Ok(())); + }; + let Some(user_message_id) = message.id.clone() else { + return Task::ready(Ok(())); + }; + let Some(checkpoint) = message.checkpoint.as_ref() else { return Task::ready(Ok(())); }; + let old_checkpoint = checkpoint.git_checkpoint.clone(); let new_checkpoint = git_store.update(cx, |git, cx| git.checkpoint(cx)); cx.spawn(async move |this, cx| { - let new_checkpoint = new_checkpoint + let Some(new_checkpoint) = new_checkpoint .await .context("failed to get new checkpoint") - .log_err(); - if let Some(new_checkpoint) = new_checkpoint { - let equal = git_store - .update(cx, |git, cx| { - git.compare_checkpoints(old_checkpoint.clone(), new_checkpoint, cx) - })? - .await - .unwrap_or(true); - this.update(cx, |this, cx| { - let (ix, message) = this.last_user_message().context("no user message")?; - let checkpoint = message.checkpoint.as_mut().context("no checkpoint")?; - checkpoint.show = !equal; - cx.emit(AcpThreadEvent::EntryUpdated(ix)); - anyhow::Ok(()) - })??; - } + .log_err() + else { + return Ok(()); + }; + + let equal = git_store + .update(cx, |git, cx| { + git.compare_checkpoints(old_checkpoint.clone(), new_checkpoint, cx) + })? + .await + .unwrap_or(true); + + this.update(cx, |this, cx| { + if let Some((ix, message)) = this.user_message_mut(&user_message_id) { + if let Some(checkpoint) = message.checkpoint.as_mut() { + checkpoint.show = !equal; + cx.emit(AcpThreadEvent::EntryUpdated(ix)); + } + } + })?; Ok(()) }) @@ -4069,4 +4074,66 @@ mod tests { "Should have exactly 2 terminals (the completed ones from before checkpoint)" ); } + + /// Tests that update_last_checkpoint correctly updates the original message's checkpoint + /// even when a new user message is added while the async checkpoint comparison is in progress. + /// + /// This is a regression test for a bug where update_last_checkpoint would fail with + /// "no checkpoint" if a new user message (without a checkpoint) was added between when + /// update_last_checkpoint started and when its async closure ran. + #[gpui::test] + async fn test_update_last_checkpoint_with_new_message_added(cx: &mut TestAppContext) { + init_test(cx); + + let fs = FakeFs::new(cx.executor()); + fs.insert_tree(path!("/test"), json!({".git": {}, "file.txt": "content"})) + .await; + let project = Project::test(fs.clone(), [Path::new(path!("/test"))], cx).await; + + let handler_done = Arc::new(AtomicBool::new(false)); + let handler_done_clone = handler_done.clone(); + let connection = Rc::new(FakeAgentConnection::new().on_user_message( + move |_, _thread, _cx| { + handler_done_clone.store(true, SeqCst); + async move { Ok(acp::PromptResponse::new(acp::StopReason::EndTurn)) }.boxed_local() + }, + )); + + let thread = cx + .update(|cx| connection.new_thread(project, Path::new(path!("/test")), cx)) + .await + .unwrap(); + + let send_future = thread.update(cx, |thread, cx| thread.send_raw("First message", cx)); + let send_task = cx.background_executor.spawn(send_future); + + // Tick until handler completes, then a few more to let update_last_checkpoint start + while !handler_done.load(SeqCst) { + cx.executor().tick(); + } + for _ in 0..5 { + cx.executor().tick(); + } + + thread.update(cx, |thread, cx| { + thread.push_entry( + AgentThreadEntry::UserMessage(UserMessage { + id: Some(UserMessageId::new()), + content: ContentBlock::Empty, + chunks: vec!["Injected message (no checkpoint)".into()], + checkpoint: None, + }), + cx, + ); + }); + + cx.run_until_parked(); + let result = send_task.await; + + assert!( + result.is_ok(), + "send should succeed even when new message added during update_last_checkpoint: {:?}", + result.err() + ); + } } From 4b56fec971579bab18f365be93d46ba68fd1f091 Mon Sep 17 00:00:00 2001 From: Finn Evers Date: Sat, 20 Dec 2025 21:01:03 +0100 Subject: [PATCH 592/621] acp_thread: Fix broken main build (#45461) Release Notes: - N/A --- crates/acp_thread/src/acp_thread.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/acp_thread/src/acp_thread.rs b/crates/acp_thread/src/acp_thread.rs index bebe1cc5fd811d17c14d1f8fc2cf206805f1c955..80b69b7e010f22fb311d1924ed4d6946ef6a0484 100644 --- a/crates/acp_thread/src/acp_thread.rs +++ b/crates/acp_thread/src/acp_thread.rs @@ -4122,6 +4122,7 @@ mod tests { content: ContentBlock::Empty, chunks: vec!["Injected message (no checkpoint)".into()], checkpoint: None, + indented: false, }), cx, ); From 213cb30445208c8c59f02ccd14bd255d6ab2c11e Mon Sep 17 00:00:00 2001 From: Marco Mihai Condrache <52580954+marcocondrache@users.noreply.github.com> Date: Sun, 21 Dec 2025 10:17:02 +0100 Subject: [PATCH 593/621] gpui: Enable direct-to-display optimization for metal (#45434) Continuing of #44334 I removed disabling of vsync which was causing jitter on some external displays cc: @maxbrunsfeld @Anthony-Eid Release Notes: - Mark metal layers opaque for non-transparent windows to allow direct-to-display when supported Signed-off-by: Marco Mihai Condrache <52580954+marcocondrache@users.noreply.github.com> --- crates/gpui/src/platform/mac/metal_renderer.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/crates/gpui/src/platform/mac/metal_renderer.rs b/crates/gpui/src/platform/mac/metal_renderer.rs index 550041a0ccb4cd39bc7a86317d9540e806af2a28..62a4385cf7d4ce63b78a610f97e5d65a6206ed37 100644 --- a/crates/gpui/src/platform/mac/metal_renderer.rs +++ b/crates/gpui/src/platform/mac/metal_renderer.rs @@ -46,9 +46,9 @@ pub unsafe fn new_renderer( _native_window: *mut c_void, _native_view: *mut c_void, _bounds: crate::Size, - _transparent: bool, + transparent: bool, ) -> Renderer { - MetalRenderer::new(context) + MetalRenderer::new(context, transparent) } pub(crate) struct InstanceBufferPool { @@ -128,7 +128,7 @@ pub struct PathRasterizationVertex { } impl MetalRenderer { - pub fn new(instance_buffer_pool: Arc>) -> Self { + pub fn new(instance_buffer_pool: Arc>, transparent: bool) -> Self { // Prefer low‐power integrated GPUs on Intel Mac. On Apple // Silicon, there is only ever one GPU, so this is equivalent to // `metal::Device::system_default()`. @@ -152,7 +152,9 @@ impl MetalRenderer { let layer = metal::MetalLayer::new(); layer.set_device(&device); layer.set_pixel_format(MTLPixelFormat::BGRA8Unorm); - layer.set_opaque(false); + // Support direct-to-display rendering if the window is not transparent + // https://developer.apple.com/documentation/metal/managing-your-game-window-for-metal-in-macos + layer.set_opaque(!transparent); layer.set_maximum_drawable_count(3); unsafe { let _: () = msg_send![&*layer, setAllowsNextDrawableTimeout: NO]; @@ -352,8 +354,8 @@ impl MetalRenderer { } } - pub fn update_transparency(&self, _transparent: bool) { - // todo(mac)? + pub fn update_transparency(&self, transparent: bool) { + self.layer.set_opaque(!transparent); } pub fn destroy(&self) { From 83449293b67b5b56ba0b02e904649d3eb415ad43 Mon Sep 17 00:00:00 2001 From: Nereuxofficial <37740907+Nereuxofficial@users.noreply.github.com> Date: Sun, 21 Dec 2025 16:29:38 +0100 Subject: [PATCH 594/621] Add autocomplete for initialization_options (#43104) Closes #18287 Release Notes: - Added autocomplete for lsp initialization_options ## Description This MR adds the following code-changes: - `initialization_options_schema` to the `LspAdapter` to get JSON Schema's from the language server - Adds a post-processing step to inject schema request paths into the settings schema in `SettingsStore::json_schema` - Adds an implementation for fetching the schema for rust-analyzer which fetches it from the binary it is provided with - Similarly for ruff image ## Open Questions(Would be nice to get some advice here) - Binary Fetching: - I'm pretty sure the binary fetching is suboptimal. The main problem here was getting access to the delegate but i figured that out eventually in a way that i _hope_ should be fine. - The toolchain and binary options can differ from what the user has configured potentially leading to mismatches in the autocomplete values returned(these are probably rarely changed though). I could not really find a way to fetch these in this context so the provided ones are for now just `default` values. - For the trait API it is just provided a binary, since i wanted to use the potentially cached binary from the CachedLspAdapter. Is that fine our should the arguments be passed to the LspAdapter such that it can potentially download the LSP? - As for those LSPs with JSON schema files in their repositories i can add the files to zed manually e.g. in languages/language/initialization_options_schema.json, which could cause mismatches with the actual binary. Is there a preferred approach for Zed here also with regards to updating them? --- Cargo.lock | 1 + crates/editor/src/editor_tests.rs | 8 +- crates/json_schema_store/Cargo.toml | 1 + .../src/json_schema_store.rs | 150 ++++++--- crates/language/src/language.rs | 8 + crates/languages/src/python.rs | 289 ++++++++++++++++++ crates/languages/src/rust.rs | 180 +++++++++++ crates/languages/src/vtsls.rs | 1 + crates/project/src/lsp_store.rs | 4 +- .../src/lsp_store/json_language_server_ext.rs | 10 +- crates/settings/src/settings.rs | 5 +- .../settings/src/settings_content/project.rs | 15 +- crates/settings/src/settings_store.rs | 81 ++++- crates/zed/src/main.rs | 9 +- 14 files changed, 708 insertions(+), 54 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f12d6a3484907a873e0e02d8e7af333c31dd9740..e71461d72b0894c0049a90d2f65edbd68a477648 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8645,6 +8645,7 @@ dependencies = [ "extension", "gpui", "language", + "lsp", "paths", "project", "schemars", diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rs index 613850428a8720ed37efa447a1312c262a05571a..6d53c59d90a8df5d74d0879e965f7f2643deaefa 100644 --- a/crates/editor/src/editor_tests.rs +++ b/crates/editor/src/editor_tests.rs @@ -18346,7 +18346,7 @@ async fn test_language_server_restart_due_to_settings_change(cx: &mut TestAppCon ); update_test_project_settings(cx, |project_settings| { - project_settings.lsp.insert( + project_settings.lsp.0.insert( "Some other server name".into(), LspSettings { binary: None, @@ -18367,7 +18367,7 @@ async fn test_language_server_restart_due_to_settings_change(cx: &mut TestAppCon ); update_test_project_settings(cx, |project_settings| { - project_settings.lsp.insert( + project_settings.lsp.0.insert( language_server_name.into(), LspSettings { binary: None, @@ -18388,7 +18388,7 @@ async fn test_language_server_restart_due_to_settings_change(cx: &mut TestAppCon ); update_test_project_settings(cx, |project_settings| { - project_settings.lsp.insert( + project_settings.lsp.0.insert( language_server_name.into(), LspSettings { binary: None, @@ -18409,7 +18409,7 @@ async fn test_language_server_restart_due_to_settings_change(cx: &mut TestAppCon ); update_test_project_settings(cx, |project_settings| { - project_settings.lsp.insert( + project_settings.lsp.0.insert( language_server_name.into(), LspSettings { binary: None, diff --git a/crates/json_schema_store/Cargo.toml b/crates/json_schema_store/Cargo.toml index efb1b36e7978805ec9c5a07baf9339f66a9d2f9f..2225b7c5aa68b43d45dacf404c038248ab2c897f 100644 --- a/crates/json_schema_store/Cargo.toml +++ b/crates/json_schema_store/Cargo.toml @@ -20,6 +20,7 @@ dap.workspace = true extension.workspace = true gpui.workspace = true language.workspace = true +lsp.workspace = true paths.workspace = true project.workspace = true schemars.workspace = true diff --git a/crates/json_schema_store/src/json_schema_store.rs b/crates/json_schema_store/src/json_schema_store.rs index 18041545ccd404eef0035b9b50ff8244d212fa0b..a6d07a6ac368ed47c6ecf215efe5560727dadf05 100644 --- a/crates/json_schema_store/src/json_schema_store.rs +++ b/crates/json_schema_store/src/json_schema_store.rs @@ -2,9 +2,11 @@ use std::{str::FromStr, sync::Arc}; use anyhow::{Context as _, Result}; -use gpui::{App, AsyncApp, BorrowAppContext as _, Entity, WeakEntity}; +use gpui::{App, AsyncApp, BorrowAppContext as _, Entity, Task, WeakEntity}; use language::{LanguageRegistry, language_settings::all_language_settings}; -use project::LspStore; +use lsp::LanguageServerBinaryOptions; +use project::{LspStore, lsp_store::LocalLspAdapterDelegate}; +use settings::LSP_SETTINGS_SCHEMA_URL_PREFIX; use util::schemars::{AllowTrailingCommas, DefaultDenyUnknownFields}; // Origin: https://github.com/SchemaStore/schemastore @@ -75,23 +77,28 @@ fn handle_schema_request( lsp_store: Entity, uri: String, cx: &mut AsyncApp, -) -> Result { - let languages = lsp_store.read_with(cx, |lsp_store, _| lsp_store.languages.clone())?; - let schema = resolve_schema_request(&languages, uri, cx)?; - serde_json::to_string(&schema).context("Failed to serialize schema") +) -> Task> { + let languages = lsp_store.read_with(cx, |lsp_store, _| lsp_store.languages.clone()); + cx.spawn(async move |cx| { + let languages = languages?; + let schema = resolve_schema_request(&languages, lsp_store, uri, cx).await?; + serde_json::to_string(&schema).context("Failed to serialize schema") + }) } -pub fn resolve_schema_request( +pub async fn resolve_schema_request( languages: &Arc, + lsp_store: Entity, uri: String, cx: &mut AsyncApp, ) -> Result { let path = uri.strip_prefix("zed://schemas/").context("Invalid URI")?; - resolve_schema_request_inner(languages, path, cx) + resolve_schema_request_inner(languages, lsp_store, path, cx).await } -pub fn resolve_schema_request_inner( +pub async fn resolve_schema_request_inner( languages: &Arc, + lsp_store: Entity, path: &str, cx: &mut AsyncApp, ) -> Result { @@ -99,37 +106,106 @@ pub fn resolve_schema_request_inner( let schema_name = schema_name.unwrap_or(path); let schema = match schema_name { - "settings" => cx.update(|cx| { - let font_names = &cx.text_system().all_font_names(); - let language_names = &languages - .language_names() + "settings" if rest.is_some_and(|r| r.starts_with("lsp/")) => { + let lsp_name = rest + .and_then(|r| { + r.strip_prefix( + LSP_SETTINGS_SCHEMA_URL_PREFIX + .strip_prefix("zed://schemas/settings/") + .unwrap(), + ) + }) + .context("Invalid LSP schema path")?; + + let adapter = languages + .all_lsp_adapters() .into_iter() - .map(|name| name.to_string()) + .find(|adapter| adapter.name().as_ref() as &str == lsp_name) + .with_context(|| format!("LSP adapter not found: {}", lsp_name))?; + + let delegate = cx.update(|inner_cx| { + lsp_store.update(inner_cx, |lsp_store, inner_cx| { + let Some(local) = lsp_store.as_local() else { + return None; + }; + let Some(worktree) = local.worktree_store.read(inner_cx).worktrees().next() else { + return None; + }; + Some(LocalLspAdapterDelegate::from_local_lsp( + local, &worktree, inner_cx, + )) + }) + })?.context("Failed to create adapter delegate - either LSP store is not in local mode or no worktree is available")?; + + let adapter_for_schema = adapter.clone(); + + let binary = adapter + .get_language_server_command( + delegate, + None, + LanguageServerBinaryOptions { + allow_path_lookup: true, + allow_binary_download: false, + pre_release: false, + }, + cx, + ) + .await + .await + .0.with_context(|| format!("Failed to find language server {lsp_name} to generate initialization params schema"))?; + + adapter_for_schema + .adapter + .clone() + .initialization_options_schema(&binary) + .await + .unwrap_or_else(|| { + serde_json::json!({ + "type": "object", + "additionalProperties": true + }) + }) + } + "settings" => { + let lsp_adapter_names = languages + .all_lsp_adapters() + .into_iter() + .map(|adapter| adapter.name().to_string()) .collect::>(); - let mut icon_theme_names = vec![]; - let mut theme_names = vec![]; - if let Some(registry) = theme::ThemeRegistry::try_global(cx) { - icon_theme_names.extend( - registry - .list_icon_themes() - .into_iter() - .map(|icon_theme| icon_theme.name), - ); - theme_names.extend(registry.list_names()); - } - let icon_theme_names = icon_theme_names.as_slice(); - let theme_names = theme_names.as_slice(); - - cx.global::().json_schema( - &settings::SettingsJsonSchemaParams { - language_names, - font_names, - theme_names, - icon_theme_names, - }, - ) - })?, + cx.update(|cx| { + let font_names = &cx.text_system().all_font_names(); + let language_names = &languages + .language_names() + .into_iter() + .map(|name| name.to_string()) + .collect::>(); + + let mut icon_theme_names = vec![]; + let mut theme_names = vec![]; + if let Some(registry) = theme::ThemeRegistry::try_global(cx) { + icon_theme_names.extend( + registry + .list_icon_themes() + .into_iter() + .map(|icon_theme| icon_theme.name), + ); + theme_names.extend(registry.list_names()); + } + let icon_theme_names = icon_theme_names.as_slice(); + let theme_names = theme_names.as_slice(); + + cx.global::().json_schema( + &settings::SettingsJsonSchemaParams { + language_names, + font_names, + theme_names, + icon_theme_names, + lsp_adapter_names: &lsp_adapter_names, + }, + ) + })? + } "keymap" => cx.update(settings::KeymapFile::generate_json_schema_for_registered_actions)?, "action" => { let normalized_action_name = rest.context("No Action name provided")?; diff --git a/crates/language/src/language.rs b/crates/language/src/language.rs index 290cad4e4497015ef63f79e58a0dacf231168c9f..70ddd01d3a3bc4d76b766a73f46cb7a684ac2f91 100644 --- a/crates/language/src/language.rs +++ b/crates/language/src/language.rs @@ -461,6 +461,14 @@ pub trait LspAdapter: 'static + Send + Sync + DynLspInstaller { Ok(None) } + /// Returns the JSON schema of the initialization_options for the language server. + async fn initialization_options_schema( + self: Arc, + _language_server_binary: &LanguageServerBinary, + ) -> Option { + None + } + async fn workspace_configuration( self: Arc, _: &Arc, diff --git a/crates/languages/src/python.rs b/crates/languages/src/python.rs index a06b1efe649b93ef56a35c40bd0d35cd1bc7ca9c..40825e30cbe79c8e2c48772a40804dda60948894 100644 --- a/crates/languages/src/python.rs +++ b/crates/languages/src/python.rs @@ -26,6 +26,7 @@ use settings::Settings; use smol::lock::OnceCell; use std::cmp::{Ordering, Reverse}; use std::env::consts; +use std::process::Stdio; use terminal::terminal_settings::TerminalSettings; use util::command::new_smol_command; use util::fs::{make_file_executable, remove_matching}; @@ -2173,6 +2174,119 @@ pub(crate) struct RuffLspAdapter { fs: Arc, } +impl RuffLspAdapter { + fn convert_ruff_schema(raw_schema: &serde_json::Value) -> serde_json::Value { + let Some(schema_object) = raw_schema.as_object() else { + return raw_schema.clone(); + }; + + let mut root_properties = serde_json::Map::new(); + + for (key, value) in schema_object { + let parts: Vec<&str> = key.split('.').collect(); + + if parts.is_empty() { + continue; + } + + let mut current = &mut root_properties; + + for (i, part) in parts.iter().enumerate() { + let is_last = i == parts.len() - 1; + + if is_last { + let mut schema_entry = serde_json::Map::new(); + + if let Some(doc) = value.get("doc").and_then(|d| d.as_str()) { + schema_entry.insert( + "markdownDescription".to_string(), + serde_json::Value::String(doc.to_string()), + ); + } + + if let Some(default_val) = value.get("default") { + schema_entry.insert("default".to_string(), default_val.clone()); + } + + if let Some(value_type) = value.get("value_type").and_then(|v| v.as_str()) { + if value_type.contains('|') { + let enum_values: Vec = value_type + .split('|') + .map(|s| s.trim().trim_matches('"')) + .filter(|s| !s.is_empty()) + .map(|s| serde_json::Value::String(s.to_string())) + .collect(); + + if !enum_values.is_empty() { + schema_entry + .insert("type".to_string(), serde_json::json!("string")); + schema_entry.insert( + "enum".to_string(), + serde_json::Value::Array(enum_values), + ); + } + } else if value_type.starts_with("list[") { + schema_entry.insert("type".to_string(), serde_json::json!("array")); + if let Some(item_type) = value_type + .strip_prefix("list[") + .and_then(|s| s.strip_suffix(']')) + { + let json_type = match item_type { + "str" => "string", + "int" => "integer", + "bool" => "boolean", + _ => "string", + }; + schema_entry.insert( + "items".to_string(), + serde_json::json!({"type": json_type}), + ); + } + } else if value_type.starts_with("dict[") { + schema_entry.insert("type".to_string(), serde_json::json!("object")); + } else { + let json_type = match value_type { + "bool" => "boolean", + "int" | "usize" => "integer", + "str" => "string", + _ => "string", + }; + schema_entry.insert( + "type".to_string(), + serde_json::Value::String(json_type.to_string()), + ); + } + } + + current.insert(part.to_string(), serde_json::Value::Object(schema_entry)); + } else { + let next_current = current + .entry(part.to_string()) + .or_insert_with(|| { + serde_json::json!({ + "type": "object", + "properties": {} + }) + }) + .as_object_mut() + .expect("should be an object") + .entry("properties") + .or_insert_with(|| serde_json::json!({})) + .as_object_mut() + .expect("properties should be an object"); + + current = next_current; + } + } + } + + serde_json::json!({ + "type": "object", + "properties": root_properties + }) + } +} + #[cfg(target_os = "macos")] impl RuffLspAdapter { const GITHUB_ASSET_KIND: AssetKind = AssetKind::TarGz; @@ -2225,6 +2339,36 @@ impl LspAdapter for RuffLspAdapter { fn name(&self) -> LanguageServerName { Self::SERVER_NAME } + + async fn initialization_options_schema( + self: Arc, + language_server_binary: &LanguageServerBinary, + ) -> Option { + let mut command = util::command::new_smol_command(&language_server_binary.path); + command + .args(&["config", "--output-format", "json"]) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()); + let cmd = command + .spawn() + .map_err(|e| log::debug!("failed to spawn command {command:?}: {e}")) + .ok()?; + let output = cmd + .output() + .await + .map_err(|e| log::debug!("failed to execute command {command:?}: {e}")) + .ok()?; + if !output.status.success() { + return None; + } + + let raw_schema: serde_json::Value = serde_json::from_slice(output.stdout.as_slice()) + .map_err(|e| log::debug!("failed to parse ruff's JSON schema output: {e}")) + .ok()?; + + let converted_schema = Self::convert_ruff_schema(&raw_schema); + Some(converted_schema) + } } impl LspInstaller for RuffLspAdapter { @@ -2568,4 +2712,149 @@ mod tests { ); } } + + #[test] + fn test_convert_ruff_schema() { + use super::RuffLspAdapter; + + let raw_schema = serde_json::json!({ + "line-length": { + "doc": "The line length to use when enforcing long-lines violations", + "default": "88", + "value_type": "int", + "scope": null, + "example": "line-length = 120", + "deprecated": null + }, + "lint.select": { + "doc": "A list of rule codes or prefixes to enable", + "default": "[\"E4\", \"E7\", \"E9\", \"F\"]", + "value_type": "list[RuleSelector]", + "scope": null, + "example": "select = [\"E4\", \"E7\", \"E9\", \"F\", \"B\", \"Q\"]", + "deprecated": null + }, + "lint.isort.case-sensitive": { + "doc": "Sort imports taking into account case sensitivity.", + "default": "false", + "value_type": "bool", + "scope": null, + "example": "case-sensitive = true", + "deprecated": null + }, + "format.quote-style": { + "doc": "Configures the preferred quote character for strings.", + "default": "\"double\"", + "value_type": "\"double\" | \"single\" | \"preserve\"", + "scope": null, + "example": "quote-style = \"single\"", + "deprecated": null + } + }); + + let converted = RuffLspAdapter::convert_ruff_schema(&raw_schema); + + assert!(converted.is_object()); + assert_eq!( + converted.get("type").and_then(|v| v.as_str()), + Some("object") + ); + + let properties = converted + .get("properties") + .expect("should have properties") + .as_object() + .expect("properties should be an object"); + + assert!(properties.contains_key("line-length")); + assert!(properties.contains_key("lint")); + assert!(properties.contains_key("format")); + + let line_length = properties + .get("line-length") + .expect("should have line-length") + .as_object() + .expect("line-length should be an object"); + + assert_eq!( + line_length.get("type").and_then(|v| v.as_str()), + Some("integer") + ); + assert_eq!( + line_length.get("default").and_then(|v| v.as_str()), + Some("88") + ); + + let lint = properties + .get("lint") + .expect("should have lint") + .as_object() + .expect("lint should be an object"); + + let lint_props = lint + .get("properties") + .expect("lint should have properties") + .as_object() + .expect("lint properties should be an object"); + + assert!(lint_props.contains_key("select")); + assert!(lint_props.contains_key("isort")); + + let select = lint_props.get("select").expect("should have select"); + assert_eq!(select.get("type").and_then(|v| v.as_str()), Some("array")); + + let isort = lint_props + .get("isort") + .expect("should have isort") + .as_object() + .expect("isort should be an object"); + + let isort_props = isort + .get("properties") + .expect("isort should have properties") + .as_object() + .expect("isort properties should be an object"); + + let case_sensitive = isort_props + .get("case-sensitive") + .expect("should have case-sensitive"); + + assert_eq!( + case_sensitive.get("type").and_then(|v| v.as_str()), + Some("boolean") + ); + assert!(case_sensitive.get("markdownDescription").is_some()); + + let format = properties + .get("format") + .expect("should have format") + .as_object() + .expect("format should be an object"); + + let format_props = format + .get("properties") + .expect("format should have properties") + .as_object() + .expect("format properties should be an object"); + + let quote_style = format_props + .get("quote-style") + .expect("should have quote-style"); + + assert_eq!( + quote_style.get("type").and_then(|v| v.as_str()), + Some("string") + ); + + let enum_values = quote_style + .get("enum") + .expect("should have enum") + .as_array() + .expect("enum should be an array"); + + assert_eq!(enum_values.len(), 3); + assert!(enum_values.contains(&serde_json::json!("double"))); + assert!(enum_values.contains(&serde_json::json!("single"))); + assert!(enum_values.contains(&serde_json::json!("preserve"))); + } } diff --git a/crates/languages/src/rust.rs b/crates/languages/src/rust.rs index 80bc48908b0894f251d6631b67cb4a19658454bd..d2b890a1dbe3d4137d9819a55a40ee5e19374add 100644 --- a/crates/languages/src/rust.rs +++ b/crates/languages/src/rust.rs @@ -18,6 +18,7 @@ use smol::fs::{self}; use std::cmp::Reverse; use std::fmt::Display; use std::ops::Range; +use std::process::Stdio; use std::{ borrow::Cow, path::{Path, PathBuf}, @@ -66,6 +67,68 @@ enum LibcType { } impl RustLspAdapter { + fn convert_rust_analyzer_schema(raw_schema: &serde_json::Value) -> serde_json::Value { + let Some(schema_array) = raw_schema.as_array() else { + return raw_schema.clone(); + }; + + let mut root_properties = serde_json::Map::new(); + + for item in schema_array { + if let Some(props) = item.get("properties").and_then(|p| p.as_object()) { + for (key, value) in props { + let parts: Vec<&str> = key.split('.').collect(); + + if parts.is_empty() { + continue; + } + + let parts_to_process = if parts.first() == Some(&"rust-analyzer") { + &parts[1..] + } else { + &parts[..] + }; + + if parts_to_process.is_empty() { + continue; + } + + let mut current = &mut root_properties; + + for (i, part) in parts_to_process.iter().enumerate() { + let is_last = i == parts_to_process.len() - 1; + + if is_last { + current.insert(part.to_string(), value.clone()); + } else { + let next_current = current + .entry(part.to_string()) + .or_insert_with(|| { + serde_json::json!({ + "type": "object", + "properties": {} + }) + }) + .as_object_mut() + .expect("should be an object") + .entry("properties") + .or_insert_with(|| serde_json::json!({})) + .as_object_mut() + .expect("properties should be an object"); + + current = next_current; + } + } + } + } + } + + serde_json::json!({ + "type": "object", + "properties": root_properties + }) + } + #[cfg(target_os = "linux")] async fn determine_libc_type() -> LibcType { use futures::pin_mut; @@ -448,6 +511,37 @@ impl LspAdapter for RustLspAdapter { Some(label) } + async fn initialization_options_schema( + self: Arc, + language_server_binary: &LanguageServerBinary, + ) -> Option { + let mut command = util::command::new_smol_command(&language_server_binary.path); + command + .arg("--print-config-schema") + .stdout(Stdio::piped()) + .stderr(Stdio::piped()); + let cmd = command + .spawn() + .map_err(|e| log::debug!("failed to spawn command {command:?}: {e}")) + .ok()?; + let output = cmd + .output() + .await + .map_err(|e| log::debug!("failed to execute command {command:?}: {e}")) + .ok()?; + if !output.status.success() { + return None; + } + + let raw_schema: serde_json::Value = serde_json::from_slice(output.stdout.as_slice()) + .map_err(|e| log::debug!("failed to parse rust-analyzer's JSON schema output: {e}")) + .ok()?; + + // Convert rust-analyzer's array-based schema format to nested JSON Schema + let converted_schema = Self::convert_rust_analyzer_schema(&raw_schema); + Some(converted_schema) + } + async fn label_for_symbol( &self, name: &str, @@ -1912,4 +2006,90 @@ mod tests { ); check([], "/project/src/main.rs", "--"); } + + #[test] + fn test_convert_rust_analyzer_schema() { + let raw_schema = serde_json::json!([ + { + "title": "Assist", + "properties": { + "rust-analyzer.assist.emitMustUse": { + "markdownDescription": "Insert #[must_use] when generating `as_` methods for enum variants.", + "default": false, + "type": "boolean" + } + } + }, + { + "title": "Assist", + "properties": { + "rust-analyzer.assist.expressionFillDefault": { + "markdownDescription": "Placeholder expression to use for missing expressions in assists.", + "default": "todo", + "type": "string" + } + } + }, + { + "title": "Cache Priming", + "properties": { + "rust-analyzer.cachePriming.enable": { + "markdownDescription": "Warm up caches on project load.", + "default": true, + "type": "boolean" + } + } + } + ]); + + let converted = RustLspAdapter::convert_rust_analyzer_schema(&raw_schema); + + assert_eq!( + converted.get("type").and_then(|v| v.as_str()), + Some("object") + ); + + let properties = converted + .pointer("/properties") + .expect("should have properties") + .as_object() + .expect("properties should be object"); + + assert!(properties.contains_key("assist")); + assert!(properties.contains_key("cachePriming")); + assert!(!properties.contains_key("rust-analyzer")); + + let assist_props = properties + .get("assist") + .expect("should have assist") + .pointer("/properties") + .expect("assist should have properties") + .as_object() + .expect("assist properties should be object"); + + assert!(assist_props.contains_key("emitMustUse")); + assert!(assist_props.contains_key("expressionFillDefault")); + + let emit_must_use = assist_props + .get("emitMustUse") + .expect("should have emitMustUse"); + assert_eq!( + emit_must_use.get("type").and_then(|v| v.as_str()), + Some("boolean") + ); + assert_eq!( + emit_must_use.get("default").and_then(|v| v.as_bool()), + Some(false) + ); + + let cache_priming_props = properties + .get("cachePriming") + .expect("should have cachePriming") + .pointer("/properties") + .expect("cachePriming should have properties") + .as_object() + .expect("cachePriming properties should be object"); + + assert!(cache_priming_props.contains_key("enable")); + } } diff --git a/crates/languages/src/vtsls.rs b/crates/languages/src/vtsls.rs index 29b21a7cd80f1f0457e7720d68a6fb37954a02c5..7106929c4ad3845d9aca06e0c5206a5d1de9b02c 100644 --- a/crates/languages/src/vtsls.rs +++ b/crates/languages/src/vtsls.rs @@ -345,6 +345,7 @@ impl LspAdapter for VtslsLspAdapter { let lsp_settings = content .project .lsp + .0 .entry(VTSLS_SERVER_NAME.into()) .or_default(); diff --git a/crates/project/src/lsp_store.rs b/crates/project/src/lsp_store.rs index 5841be02b2db80b2fa15667833b8a3d3eec4ec11..401879ba9d53fb6df58a5346af3784e2b58d31ea 100644 --- a/crates/project/src/lsp_store.rs +++ b/crates/project/src/lsp_store.rs @@ -257,7 +257,7 @@ struct DynamicRegistrations { pub struct LocalLspStore { weak: WeakEntity, - worktree_store: Entity, + pub worktree_store: Entity, toolchain_store: Entity, http_client: Arc, environment: Entity, @@ -13953,7 +13953,7 @@ impl LocalLspAdapterDelegate { }) } - fn from_local_lsp( + pub fn from_local_lsp( local: &LocalLspStore, worktree: &Entity, cx: &mut App, diff --git a/crates/project/src/lsp_store/json_language_server_ext.rs b/crates/project/src/lsp_store/json_language_server_ext.rs index 78df7132734e9bf71bac8df176f92e15eec21361..8d03dde032303210c9de7ec30b8144c0a3cb8c99 100644 --- a/crates/project/src/lsp_store/json_language_server_ext.rs +++ b/crates/project/src/lsp_store/json_language_server_ext.rs @@ -1,5 +1,5 @@ use anyhow::{Context, Result}; -use gpui::{App, AsyncApp, Entity, Global, WeakEntity}; +use gpui::{App, AsyncApp, Entity, Global, Task, WeakEntity}; use lsp::LanguageServer; use crate::LspStore; @@ -22,7 +22,7 @@ impl lsp::request::Request for SchemaContentRequest { const METHOD: &'static str = "vscode/content"; } -type SchemaRequestHandler = fn(Entity, String, &mut AsyncApp) -> Result; +type SchemaRequestHandler = fn(Entity, String, &mut AsyncApp) -> Task>; pub struct SchemaHandlingImpl(SchemaRequestHandler); impl Global for SchemaHandlingImpl {} @@ -72,9 +72,7 @@ pub fn notify_schema_changed(lsp_store: Entity, uri: String, cx: &App) pub fn register_requests(lsp_store: WeakEntity, language_server: &LanguageServer) { language_server .on_request::(move |params, cx| { - let handler = cx.try_read_global::(|handler, _| { - handler.0 - }); + let handler = cx.try_read_global::(|handler, _| handler.0); let mut cx = cx.clone(); let uri = params.clone().pop(); let lsp_store = lsp_store.clone(); @@ -82,7 +80,7 @@ pub fn register_requests(lsp_store: WeakEntity, language_server: &Lang let lsp_store = lsp_store.upgrade().context("LSP store has been dropped")?; let uri = uri.context("No URI")?; let handle_schema_request = handler.context("No schema handler registered")?; - handle_schema_request(lsp_store, uri, &mut cx) + handle_schema_request(lsp_store, uri, &mut cx).await }; async move { zlog::trace!(LOGGER => "Handling schema request for {:?}", ¶ms); diff --git a/crates/settings/src/settings.rs b/crates/settings/src/settings.rs index 5f07ebe52f8997a91653063b5c20ca8e7432acc5..3cf33ec40f442ae02b69a8798efe02607da670c4 100644 --- a/crates/settings/src/settings.rs +++ b/crates/settings/src/settings.rs @@ -33,8 +33,9 @@ pub use serde_helper::*; pub use settings_file::*; pub use settings_json::*; pub use settings_store::{ - InvalidSettingsError, LocalSettingsKind, MigrationStatus, ParseStatus, Settings, SettingsFile, - SettingsJsonSchemaParams, SettingsKey, SettingsLocation, SettingsParseResult, SettingsStore, + InvalidSettingsError, LSP_SETTINGS_SCHEMA_URL_PREFIX, LocalSettingsKind, MigrationStatus, + ParseStatus, Settings, SettingsFile, SettingsJsonSchemaParams, SettingsKey, SettingsLocation, + SettingsParseResult, SettingsStore, }; pub use vscode_import::{VsCodeSettings, VsCodeSettingsSource}; diff --git a/crates/settings/src/settings_content/project.rs b/crates/settings/src/settings_content/project.rs index 8e2d864149c9ecb6ca38ca73ef58205f588dc07b..4855d9835bbbfaf3c383ac09fb70066afcf1bcd7 100644 --- a/crates/settings/src/settings_content/project.rs +++ b/crates/settings/src/settings_content/project.rs @@ -11,6 +11,19 @@ use crate::{ SlashCommandSettings, }; +#[with_fallible_options] +#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)] +pub struct LspSettingsMap(pub HashMap, LspSettings>); + +impl IntoIterator for LspSettingsMap { + type Item = (Arc, LspSettings); + type IntoIter = std::collections::hash_map::IntoIter, LspSettings>; + + fn into_iter(self) -> Self::IntoIter { + self.0.into_iter() + } +} + #[with_fallible_options] #[derive(Debug, PartialEq, Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom)] pub struct ProjectSettingsContent { @@ -29,7 +42,7 @@ pub struct ProjectSettingsContent { /// name to the lsp value. /// Default: null #[serde(default)] - pub lsp: HashMap, LspSettings>, + pub lsp: LspSettingsMap, pub terminal: Option, diff --git a/crates/settings/src/settings_store.rs b/crates/settings/src/settings_store.rs index abd45a141647f6ba13708c549188a22988c78069..a9130a5d14de0c07578a8e70ec3299930689dd0f 100644 --- a/crates/settings/src/settings_store.rs +++ b/crates/settings/src/settings_store.rs @@ -32,7 +32,8 @@ pub type EditorconfigProperties = ec4rs::Properties; use crate::{ ActiveSettingsProfileName, FontFamilyName, IconThemeName, LanguageSettingsContent, - LanguageToSettingsMap, ThemeName, VsCodeSettings, WorktreeId, fallible_options, + LanguageToSettingsMap, LspSettings, LspSettingsMap, ThemeName, VsCodeSettings, WorktreeId, + fallible_options, merge_from::MergeFrom, settings_content::{ ExtensionsSettingsContent, ProjectSettingsContent, SettingsContent, UserSettingsContent, @@ -41,6 +42,8 @@ use crate::{ use settings_json::{infer_json_indent_size, parse_json_with_comments, update_value_in_json_text}; +pub const LSP_SETTINGS_SCHEMA_URL_PREFIX: &str = "zed://schemas/settings/lsp/"; + pub trait SettingsKey: 'static + Send + Sync { /// The name of a key within the JSON file from which this setting should /// be deserialized. If this is `None`, then the setting will be deserialized @@ -256,6 +259,7 @@ pub struct SettingsJsonSchemaParams<'a> { pub font_names: &'a [String], pub theme_names: &'a [SharedString], pub icon_theme_names: &'a [SharedString], + pub lsp_adapter_names: &'a [String], } impl SettingsStore { @@ -1025,6 +1029,14 @@ impl SettingsStore { .subschema_for::() .to_value(); + generator.subschema_for::(); + + let lsp_settings_def = generator + .definitions() + .get("LspSettings") + .expect("LspSettings should be defined") + .clone(); + replace_subschema::(&mut generator, || { json_schema!({ "type": "object", @@ -1063,6 +1075,38 @@ impl SettingsStore { }) }); + replace_subschema::(&mut generator, || { + let mut lsp_properties = serde_json::Map::new(); + + for adapter_name in params.lsp_adapter_names { + let mut base_lsp_settings = lsp_settings_def + .as_object() + .expect("LspSettings should be an object") + .clone(); + + if let Some(properties) = base_lsp_settings.get_mut("properties") { + if let Some(props_obj) = properties.as_object_mut() { + props_obj.insert( + "initialization_options".to_string(), + serde_json::json!({ + "$ref": format!("{LSP_SETTINGS_SCHEMA_URL_PREFIX}{adapter_name}") + }), + ); + } + } + + lsp_properties.insert( + adapter_name.clone(), + serde_json::Value::Object(base_lsp_settings), + ); + } + + json_schema!({ + "type": "object", + "properties": lsp_properties, + }) + }); + generator .root_schema_for::() .to_value() @@ -2304,4 +2348,39 @@ mod tests { ] ) } + + #[gpui::test] + fn test_lsp_settings_schema_generation(cx: &mut App) { + let store = SettingsStore::test(cx); + + let schema = store.json_schema(&SettingsJsonSchemaParams { + language_names: &["Rust".to_string(), "TypeScript".to_string()], + font_names: &["Zed Mono".to_string()], + theme_names: &["One Dark".into()], + icon_theme_names: &["Zed Icons".into()], + lsp_adapter_names: &[ + "rust-analyzer".to_string(), + "typescript-language-server".to_string(), + ], + }); + + let properties = schema + .pointer("/$defs/LspSettingsMap/properties") + .expect("LspSettingsMap should have properties") + .as_object() + .unwrap(); + + assert!(properties.contains_key("rust-analyzer")); + assert!(properties.contains_key("typescript-language-server")); + + let init_options_ref = properties + .get("rust-analyzer") + .unwrap() + .pointer("/properties/initialization_options/$ref") + .expect("initialization_options should have a $ref") + .as_str() + .unwrap(); + + assert_eq!(init_options_ref, "zed://schemas/settings/lsp/rust-analyzer"); + } } diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rs index bdf3bf3f950a329e7c1b49f5ce27560b00807a5f..8c6575780bbc418b4717af8329c51a057eb608d3 100644 --- a/crates/zed/src/main.rs +++ b/crates/zed/src/main.rs @@ -833,12 +833,19 @@ fn handle_open_request(request: OpenRequest, app_state: Arc, cx: &mut cx.spawn_in(window, async move |workspace, cx| { let res = async move { let json = app_state.languages.language_for_name("JSONC").await.ok(); + let lsp_store = workspace.update(cx, |workspace, cx| { + workspace + .project() + .update(cx, |project, _| project.lsp_store()) + })?; let json_schema_content = json_schema_store::resolve_schema_request_inner( &app_state.languages, + lsp_store, &schema_path, cx, - )?; + ) + .await?; let json_schema_content = serde_json::to_string_pretty(&json_schema_content) .context("Failed to serialize JSON Schema as JSON")?; From 0884305e43e65a3ac47b6bea8c46c3a653358c08 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Sun, 21 Dec 2025 17:14:23 +0100 Subject: [PATCH 595/621] gpui(windows): Don't log incorrect errors on `SetActiveWindow` calls (#45493) The function returns the previous focus handle, which may be null if there is no previous focus. Unfortunately that also overlaps with the error return value, so winapi will hand us a error 0 back in those cases which we log ... Release Notes: - N/A *or* Added/Fixed/Improved ... --- crates/gpui/src/platform/windows/events.rs | 2 +- crates/gpui/src/platform/windows/window.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/gpui/src/platform/windows/events.rs b/crates/gpui/src/platform/windows/events.rs index 1f0a4a0d28c2b266fb8588e4ce54251be010a78d..8d44ba274ea7a3eec2714d83bb6dac63fbac370b 100644 --- a/crates/gpui/src/platform/windows/events.rs +++ b/crates/gpui/src/platform/windows/events.rs @@ -42,7 +42,7 @@ impl WindowsWindowInner { let handled = match msg { // eagerly activate the window, so calls to `active_window` will work correctly WM_MOUSEACTIVATE => { - unsafe { SetActiveWindow(handle).log_err() }; + unsafe { SetActiveWindow(handle).ok() }; None } WM_ACTIVATE => self.handle_activate_msg(wparam), diff --git a/crates/gpui/src/platform/windows/window.rs b/crates/gpui/src/platform/windows/window.rs index 3fcc29ad7864f8e45d27638bef489ffbf03788b2..fa804e3d160a370851701ea0a7600103b66356a8 100644 --- a/crates/gpui/src/platform/windows/window.rs +++ b/crates/gpui/src/platform/windows/window.rs @@ -740,8 +740,8 @@ impl PlatformWindow for WindowsWindow { ShowWindowAsync(hwnd, SW_RESTORE).ok().log_err(); } - SetActiveWindow(hwnd).log_err(); - SetFocus(Some(hwnd)).log_err(); + SetActiveWindow(hwnd).ok(); + SetFocus(Some(hwnd)).ok(); } // premium ragebait by windows, this is needed because the window From dc72e1c4ba785c68b370b7c294e6cfeba5b4e536 Mon Sep 17 00:00:00 2001 From: Finn Evers Date: Sun, 21 Dec 2025 22:36:54 +0100 Subject: [PATCH 596/621] collab: Fix capitalization of copilot name alias (#45497) This fixes copilot currently not passing the CLA check. Release Notes: - N/A --- crates/collab/src/api/contributors.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/collab/src/api/contributors.rs b/crates/collab/src/api/contributors.rs index ce318b15295ebe5c777597a6d3c6106e57af8e05..4758adb2d71760a52c9ce5e4f2bc44f7069778fb 100644 --- a/crates/collab/src/api/contributors.rs +++ b/crates/collab/src/api/contributors.rs @@ -113,7 +113,7 @@ impl CopilotSweAgentBot { const USER_ID: i32 = 198982749; /// The alias of the GitHub copilot user. Although https://api.github.com/users/copilot /// yields a 404, GitHub still refers to the copilot bot user as @Copilot in some cases. - const NAME_ALIAS: &'static str = "copilot"; + const NAME_ALIAS: &'static str = "Copilot"; /// Returns the `created_at` timestamp for the Dependabot bot user. fn created_at() -> &'static NaiveDateTime { From 045e154915d2491f0036a2b6220d007be7d8446f Mon Sep 17 00:00:00 2001 From: Mayank Verma Date: Mon, 22 Dec 2025 03:37:30 +0530 Subject: [PATCH 597/621] gpui: Fix hover state getting stuck when rapidly hovering over elements (#45437) Closes #45436 Release Notes: - N/A --------- Co-authored-by: MrSubidubi --- crates/gpui/src/elements/div.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/crates/gpui/src/elements/div.rs b/crates/gpui/src/elements/div.rs index 547d967620d68c309563af1d2e56d2ab3f194d4f..952cef7f58e6628c71b517ff74735b092edc37f7 100644 --- a/crates/gpui/src/elements/div.rs +++ b/crates/gpui/src/elements/div.rs @@ -2154,7 +2154,6 @@ impl Interactivity { || cx.active_drag.is_some() && !self.drag_over_styles.is_empty() { let hitbox = hitbox.clone(); - let was_hovered = hitbox.is_hovered(window); let hover_state = self.hover_style.as_ref().and_then(|_| { element_state .as_ref() @@ -2162,8 +2161,12 @@ impl Interactivity { .cloned() }); let current_view = window.current_view(); + window.on_mouse_event(move |_: &MouseMoveEvent, phase, window, cx| { let hovered = hitbox.is_hovered(window); + let was_hovered = hover_state + .as_ref() + .is_some_and(|state| state.borrow().element); if phase == DispatchPhase::Capture && hovered != was_hovered { if let Some(hover_state) = &hover_state { hover_state.borrow_mut().element = hovered; @@ -2179,12 +2182,13 @@ impl Interactivity { .as_ref() .and_then(|element| element.hover_state.as_ref()) .cloned(); - - let was_group_hovered = group_hitbox_id.is_hovered(window); let current_view = window.current_view(); window.on_mouse_event(move |_: &MouseMoveEvent, phase, window, cx| { let group_hovered = group_hitbox_id.is_hovered(window); + let was_group_hovered = hover_state + .as_ref() + .is_some_and(|state| state.borrow().group); if phase == DispatchPhase::Capture && group_hovered != was_group_hovered { if let Some(hover_state) = &hover_state { hover_state.borrow_mut().group = group_hovered; From 3dc0614dba258cea3929509b906028f2c291b54f Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Mon, 22 Dec 2025 01:07:49 +0200 Subject: [PATCH 598/621] Small worktree trust fixes (#45500) * Abs path trust should transitively trust all single file worktrees on the same host * Init worktree trust on the client side even when devcontainers are run: remote host unconditionally checks trust, hence the client has to keep track of it and respond with approves/declines. Do trust all devcontainers' remote worktrees, as containers are isolated and "safe". Release Notes: - N/A --- crates/project/src/project.rs | 36 ++++++++--- crates/project/src/trusted_worktrees.rs | 86 +++++++++++++++++++++++++ 2 files changed, 112 insertions(+), 10 deletions(-) diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index 5111bc04fa256f35feae40464e405d3dd926b286..fc0779dd1f03729e4812c8cac09a06a6d56d5772 100644 --- a/crates/project/src/project.rs +++ b/crates/project/src/project.rs @@ -1293,17 +1293,33 @@ impl Project { cx.subscribe(&worktree_store, Self::on_worktree_store_event) .detach(); if init_worktree_trust { - match &connection_options { - RemoteConnectionOptions::Wsl(..) | RemoteConnectionOptions::Ssh(..) => { - trusted_worktrees::track_worktree_trust( - worktree_store.clone(), - Some(RemoteHostLocation::from(connection_options)), - None, - Some((remote_proto.clone(), REMOTE_SERVER_PROJECT_ID)), - cx, - ); + let trust_remote_project = match &connection_options { + RemoteConnectionOptions::Ssh(..) | RemoteConnectionOptions::Wsl(..) => false, + RemoteConnectionOptions::Docker(..) => true, + }; + let remote_host = RemoteHostLocation::from(connection_options); + trusted_worktrees::track_worktree_trust( + worktree_store.clone(), + Some(remote_host.clone()), + None, + Some((remote_proto.clone(), REMOTE_SERVER_PROJECT_ID)), + cx, + ); + if trust_remote_project { + if let Some(trusted_worktres) = TrustedWorktrees::try_get_global(cx) { + trusted_worktres.update(cx, |trusted_worktres, cx| { + trusted_worktres.trust( + worktree_store + .read(cx) + .worktrees() + .map(|worktree| worktree.read(cx).id()) + .map(PathTrust::Worktree) + .collect(), + Some(remote_host), + cx, + ); + }) } - RemoteConnectionOptions::Docker(..) => {} } } diff --git a/crates/project/src/trusted_worktrees.rs b/crates/project/src/trusted_worktrees.rs index 0e1a8b4011bf56b150fe99a502eece905dcc9d78..2b7e73d1f23eefd5a568800c86b19f8f509faba7 100644 --- a/crates/project/src/trusted_worktrees.rs +++ b/crates/project/src/trusted_worktrees.rs @@ -337,6 +337,13 @@ impl TrustedWorktreesStore { if restricted_host != remote_host { return true; } + + // When trusting an abs path on the host, we transitively trust all single file worktrees on this host too. + if is_file && !new_trusted_abs_paths.is_empty() { + trusted_paths.insert(PathTrust::Worktree(*restricted_worktree)); + return false; + } + let retain = (!is_file || new_trusted_other_worktrees.is_empty()) && new_trusted_abs_paths.iter().all(|new_trusted_path| { !restricted_worktree_path.starts_with(new_trusted_path) @@ -1045,6 +1052,13 @@ mod tests { "single-file worktree should be restricted initially" ); + let can_trust_directory = + trusted_worktrees.update(cx, |store, cx| store.can_trust(dir_worktree_id, cx)); + assert!( + !can_trust_directory, + "directory worktree should be restricted initially" + ); + trusted_worktrees.update(cx, |store, cx| { store.trust( HashSet::from_iter([PathTrust::Worktree(dir_worktree_id)]), @@ -1064,6 +1078,78 @@ mod tests { ); } + #[gpui::test] + async fn test_parent_path_trust_enables_single_file(cx: &mut TestAppContext) { + init_test(cx); + + let fs = FakeFs::new(cx.executor()); + fs.insert_tree( + path!("/"), + json!({ + "project": { "main.rs": "fn main() {}" }, + "standalone.rs": "fn standalone() {}" + }), + ) + .await; + + let project = Project::test( + fs, + [path!("/project").as_ref(), path!("/standalone.rs").as_ref()], + cx, + ) + .await; + let worktree_store = project.read_with(cx, |project, _| project.worktree_store()); + let (dir_worktree_id, file_worktree_id) = worktree_store.read_with(cx, |store, cx| { + let worktrees: Vec<_> = store.worktrees().collect(); + assert_eq!(worktrees.len(), 2); + let (dir_worktree, file_worktree) = if worktrees[0].read(cx).is_single_file() { + (&worktrees[1], &worktrees[0]) + } else { + (&worktrees[0], &worktrees[1]) + }; + assert!(!dir_worktree.read(cx).is_single_file()); + assert!(file_worktree.read(cx).is_single_file()); + (dir_worktree.read(cx).id(), file_worktree.read(cx).id()) + }); + + let trusted_worktrees = init_trust_global(worktree_store, cx); + + let can_trust_file = + trusted_worktrees.update(cx, |store, cx| store.can_trust(file_worktree_id, cx)); + assert!( + !can_trust_file, + "single-file worktree should be restricted initially" + ); + + let can_trust_directory = + trusted_worktrees.update(cx, |store, cx| store.can_trust(dir_worktree_id, cx)); + assert!( + !can_trust_directory, + "directory worktree should be restricted initially" + ); + + trusted_worktrees.update(cx, |store, cx| { + store.trust( + HashSet::from_iter([PathTrust::AbsPath(PathBuf::from(path!("/project")))]), + None, + cx, + ); + }); + + let can_trust_dir = + trusted_worktrees.update(cx, |store, cx| store.can_trust(dir_worktree_id, cx)); + let can_trust_file_after = + trusted_worktrees.update(cx, |store, cx| store.can_trust(file_worktree_id, cx)); + assert!( + can_trust_dir, + "directory worktree should be trusted after its parent is trusted" + ); + assert!( + can_trust_file_after, + "single-file worktree should be trusted after directory worktree trust via its parent directory trust" + ); + } + #[gpui::test] async fn test_abs_path_trust_covers_multiple_worktrees(cx: &mut TestAppContext) { init_test(cx); From 3b626c8ac1b89ba5b233ae9a9c274489fa94f079 Mon Sep 17 00:00:00 2001 From: Yves Ineichen Date: Mon, 22 Dec 2025 00:50:02 +0100 Subject: [PATCH 599/621] Allow empty splits on panes (#40245) Draft as a base for continuing the discussion in #8008 : adds a `SplitOperation` enum to support bindings like `["pane::SplitLeft", {"operation": "Clear"}]` To be discussed @MrSubidubi and others: - Naming: Generally not happy with names yet and specifically `Empty` is unclear, e.g., what does this mean for terminal panes? Added placeholder code to split without cloning, but unsure what users would expect in this case. - ~~I removed `SplitAndMoveXyz` actions but I guess we should keep them for backwards compatibility?~~ - May have missed details in the move implementation. Will check the code again for opportunities to refactor more code after we agree on the approach. - ~~Tests should go to `crates/collab/src/tests/integration_tests.rs`?~~ Closes #8008 Release Notes: - Add `pane::Split` mode (`{ClonePane,EmptyPane,MovePane}`) to allow creating an empty buffer. --------- Co-authored-by: Finn Evers Co-authored-by: MrSubidubi --- crates/collab/src/tests/integration_tests.rs | 9 +- crates/file_finder/src/file_finder.rs | 11 +- crates/terminal_view/src/terminal_panel.rs | 140 ++++---- crates/vim/src/command.rs | 40 ++- crates/workspace/src/pane.rs | 351 +++++++++++++++---- crates/workspace/src/workspace.rs | 23 +- crates/zed/src/zed.rs | 2 +- crates/zed/src/zed/app_menus.rs | 8 +- 8 files changed, 417 insertions(+), 167 deletions(-) diff --git a/crates/collab/src/tests/integration_tests.rs b/crates/collab/src/tests/integration_tests.rs index 391e7355ea196dfe25d363472918837ea817f450..cbda16d11168397be92274d00beb4cd33332329f 100644 --- a/crates/collab/src/tests/integration_tests.rs +++ b/crates/collab/src/tests/integration_tests.rs @@ -6745,8 +6745,13 @@ async fn test_preview_tabs(cx: &mut TestAppContext) { }); // Split pane to the right - pane.update(cx, |pane, cx| { - pane.split(workspace::SplitDirection::Right, cx); + pane.update_in(cx, |pane, window, cx| { + pane.split( + workspace::SplitDirection::Right, + workspace::SplitMode::default(), + window, + cx, + ); }); cx.run_until_parked(); let right_pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone()); diff --git a/crates/file_finder/src/file_finder.rs b/crates/file_finder/src/file_finder.rs index 73b21bb828a598d5bbc53c0ecf4511988c30bc65..1bfd41fa2709e4c46b5177bee6851d91dc86bccb 100644 --- a/crates/file_finder/src/file_finder.rs +++ b/crates/file_finder/src/file_finder.rs @@ -1760,16 +1760,19 @@ impl PickerDelegate for FileFinderDelegate { menu.context(focus_handle) .action( "Split Left", - pane::SplitLeft.boxed_clone(), + pane::SplitLeft::default().boxed_clone(), ) .action( "Split Right", - pane::SplitRight.boxed_clone(), + pane::SplitRight::default().boxed_clone(), + ) + .action( + "Split Up", + pane::SplitUp::default().boxed_clone(), ) - .action("Split Up", pane::SplitUp.boxed_clone()) .action( "Split Down", - pane::SplitDown.boxed_clone(), + pane::SplitDown::default().boxed_clone(), ) } })) diff --git a/crates/terminal_view/src/terminal_panel.rs b/crates/terminal_view/src/terminal_panel.rs index 738a0b4502642423377bdf69b49d26250536761f..2c8779275ae57b708a3d6303ebc98bd7b9552b91 100644 --- a/crates/terminal_view/src/terminal_panel.rs +++ b/crates/terminal_view/src/terminal_panel.rs @@ -30,8 +30,8 @@ use workspace::{ ActivateNextPane, ActivatePane, ActivatePaneDown, ActivatePaneLeft, ActivatePaneRight, ActivatePaneUp, ActivatePreviousPane, DraggedSelection, DraggedTab, ItemId, MoveItemToPane, MoveItemToPaneInDirection, MovePaneDown, MovePaneLeft, MovePaneRight, MovePaneUp, NewTerminal, - Pane, PaneGroup, SplitDirection, SplitDown, SplitLeft, SplitRight, SplitUp, SwapPaneDown, - SwapPaneLeft, SwapPaneRight, SwapPaneUp, ToggleZoom, Workspace, + Pane, PaneGroup, SplitDirection, SplitDown, SplitLeft, SplitMode, SplitRight, SplitUp, + SwapPaneDown, SwapPaneLeft, SwapPaneRight, SwapPaneUp, ToggleZoom, Workspace, dock::{DockPosition, Panel, PanelEvent, PanelHandle}, item::SerializableItem, move_active_item, move_item, pane, @@ -192,10 +192,10 @@ impl TerminalPanel { split_context.clone(), |menu, split_context| menu.context(split_context), ) - .action("Split Right", SplitRight.boxed_clone()) - .action("Split Left", SplitLeft.boxed_clone()) - .action("Split Up", SplitUp.boxed_clone()) - .action("Split Down", SplitDown.boxed_clone()) + .action("Split Right", SplitRight::default().boxed_clone()) + .action("Split Left", SplitLeft::default().boxed_clone()) + .action("Split Up", SplitUp::default().boxed_clone()) + .action("Split Down", SplitDown::default().boxed_clone()) }) .into() } @@ -380,47 +380,49 @@ impl TerminalPanel { } self.serialize(cx); } - &pane::Event::Split { - direction, - clone_active_item, - } => { - if clone_active_item { - let fut = self.new_pane_with_cloned_active_terminal(window, cx); - let pane = pane.clone(); - cx.spawn_in(window, async move |panel, cx| { - let Some(new_pane) = fut.await else { + &pane::Event::Split { direction, mode } => { + match mode { + SplitMode::ClonePane | SplitMode::EmptyPane => { + let clone = matches!(mode, SplitMode::ClonePane); + let new_pane = self.new_pane_with_active_terminal(clone, window, cx); + let pane = pane.clone(); + cx.spawn_in(window, async move |panel, cx| { + let Some(new_pane) = new_pane.await else { + return; + }; + panel + .update_in(cx, |panel, window, cx| { + panel + .center + .split(&pane, &new_pane, direction, cx) + .log_err(); + window.focus(&new_pane.focus_handle(cx), cx); + }) + .ok(); + }) + .detach(); + } + SplitMode::MovePane => { + let Some(item) = + pane.update(cx, |pane, cx| pane.take_active_item(window, cx)) + else { return; }; - panel - .update_in(cx, |panel, window, cx| { - panel - .center - .split(&pane, &new_pane, direction, cx) - .log_err(); - window.focus(&new_pane.focus_handle(cx), cx); - }) - .ok(); - }) - .detach(); - } else { - let Some(item) = pane.update(cx, |pane, cx| pane.take_active_item(window, cx)) - else { - return; - }; - let Ok(project) = self - .workspace - .update(cx, |workspace, _| workspace.project().clone()) - else { - return; - }; - let new_pane = - new_terminal_pane(self.workspace.clone(), project, false, window, cx); - new_pane.update(cx, |pane, cx| { - pane.add_item(item, true, true, None, window, cx); - }); - self.center.split(&pane, &new_pane, direction, cx).log_err(); - window.focus(&new_pane.focus_handle(cx), cx); - } + let Ok(project) = self + .workspace + .update(cx, |workspace, _| workspace.project().clone()) + else { + return; + }; + let new_pane = + new_terminal_pane(self.workspace.clone(), project, false, window, cx); + new_pane.update(cx, |pane, cx| { + pane.add_item(item, true, true, None, window, cx); + }); + self.center.split(&pane, &new_pane, direction, cx).log_err(); + window.focus(&new_pane.focus_handle(cx), cx); + } + }; } pane::Event::Focus => { self.active_pane = pane.clone(); @@ -433,8 +435,9 @@ impl TerminalPanel { } } - fn new_pane_with_cloned_active_terminal( + fn new_pane_with_active_terminal( &mut self, + clone: bool, window: &mut Window, cx: &mut Context, ) -> Task>> { @@ -446,21 +449,34 @@ impl TerminalPanel { let weak_workspace = self.workspace.clone(); let project = workspace.project().clone(); let active_pane = &self.active_pane; - let terminal_view = active_pane - .read(cx) - .active_item() - .and_then(|item| item.downcast::()); - let working_directory = terminal_view - .as_ref() - .and_then(|terminal_view| { - terminal_view - .read(cx) - .terminal() - .read(cx) - .working_directory() - }) - .or_else(|| default_working_directory(workspace, cx)); - let is_zoomed = active_pane.read(cx).is_zoomed(); + let terminal_view = if clone { + active_pane + .read(cx) + .active_item() + .and_then(|item| item.downcast::()) + } else { + None + }; + let working_directory = if clone { + terminal_view + .as_ref() + .and_then(|terminal_view| { + terminal_view + .read(cx) + .terminal() + .read(cx) + .working_directory() + }) + .or_else(|| default_working_directory(workspace, cx)) + } else { + default_working_directory(workspace, cx) + }; + + let is_zoomed = if clone { + active_pane.read(cx).is_zoomed() + } else { + false + }; cx.spawn_in(window, async move |panel, cx| { let terminal = project .update(cx, |project, cx| match terminal_view { @@ -1482,7 +1498,7 @@ impl Render for TerminalPanel { window.focus(&pane.read(cx).focus_handle(cx), cx); } else { let future = - terminal_panel.new_pane_with_cloned_active_terminal(window, cx); + terminal_panel.new_pane_with_active_terminal(true, window, cx); cx.spawn_in(window, async move |terminal_panel, cx| { if let Some(new_pane) = future.await { _ = terminal_panel.update_in( diff --git a/crates/vim/src/command.rs b/crates/vim/src/command.rs index 2228c23f02beb954bdb26b2b36f078249e423d7d..caa90406c9a2ac70eb81cd7705c8223799e59f18 100644 --- a/crates/vim/src/command.rs +++ b/crates/vim/src/command.rs @@ -1468,24 +1468,28 @@ fn generate_commands(_: &App) -> Vec { action.range.replace(range.clone()); Some(Box::new(action)) }), - VimCommand::new(("sp", "lit"), workspace::SplitHorizontal).filename(|_, filename| { - Some( - VimSplit { - vertical: false, - filename, - } - .boxed_clone(), - ) - }), - VimCommand::new(("vs", "plit"), workspace::SplitVertical).filename(|_, filename| { - Some( - VimSplit { - vertical: true, - filename, - } - .boxed_clone(), - ) - }), + VimCommand::new(("sp", "lit"), workspace::SplitHorizontal::default()).filename( + |_, filename| { + Some( + VimSplit { + vertical: false, + filename, + } + .boxed_clone(), + ) + }, + ), + VimCommand::new(("vs", "plit"), workspace::SplitVertical::default()).filename( + |_, filename| { + Some( + VimSplit { + vertical: true, + filename, + } + .boxed_clone(), + ) + }, + ), VimCommand::new(("tabe", "dit"), workspace::NewFile) .filename(|_action, filename| Some(VimEdit { filename }.boxed_clone())), VimCommand::new(("tabnew", ""), workspace::NewFile) diff --git a/crates/workspace/src/pane.rs b/crates/workspace/src/pane.rs index dd17c338a935571f4d0fe9d46b3b10fac9ffe218..586a6100e40a0edf3728ecb843b8aece08cb36cc 100644 --- a/crates/workspace/src/pane.rs +++ b/crates/workspace/src/pane.rs @@ -197,6 +197,41 @@ pub struct DeploySearch { pub excluded_files: Option, } +#[derive(Clone, Copy, PartialEq, Debug, Deserialize, JsonSchema, Default)] +#[serde(deny_unknown_fields)] +pub enum SplitMode { + /// Clone the current pane. + #[default] + ClonePane, + /// Create an empty new pane. + EmptyPane, + /// Move the item into a new pane. This will map to nop if only one pane exists. + MovePane, +} + +macro_rules! split_structs { + ($($name:ident => $doc:literal),* $(,)?) => { + $( + #[doc = $doc] + #[derive(Clone, PartialEq, Debug, Deserialize, JsonSchema, Default, Action)] + #[action(namespace = pane)] + #[serde(deny_unknown_fields, default)] + pub struct $name { + pub mode: SplitMode, + } + )* + }; +} + +split_structs!( + SplitLeft => "Splits the pane to the left.", + SplitRight => "Splits the pane to the right.", + SplitUp => "Splits the pane upward.", + SplitDown => "Splits the pane downward.", + SplitHorizontal => "Splits the pane horizontally.", + SplitVertical => "Splits the pane vertically." +); + actions!( pane, [ @@ -218,14 +253,6 @@ actions!( JoinAll, /// Reopens the most recently closed item. ReopenClosedItem, - /// Splits the pane to the left, cloning the current item. - SplitLeft, - /// Splits the pane upward, cloning the current item. - SplitUp, - /// Splits the pane to the right, cloning the current item. - SplitRight, - /// Splits the pane downward, cloning the current item. - SplitDown, /// Splits the pane to the left, moving the current item. SplitAndMoveLeft, /// Splits the pane upward, moving the current item. @@ -234,10 +261,6 @@ actions!( SplitAndMoveRight, /// Splits the pane downward, moving the current item. SplitAndMoveDown, - /// Splits the pane horizontally. - SplitHorizontal, - /// Splits the pane vertically. - SplitVertical, /// Swaps the current item with the one to the left. SwapItemLeft, /// Swaps the current item with the one to the right. @@ -279,7 +302,7 @@ pub enum Event { }, Split { direction: SplitDirection, - clone_active_item: bool, + mode: SplitMode, }, ItemPinned, ItemUnpinned, @@ -311,13 +334,10 @@ impl fmt::Debug for Event { .debug_struct("RemovedItem") .field("item", &item.item_id()) .finish(), - Event::Split { - direction, - clone_active_item, - } => f + Event::Split { direction, mode } => f .debug_struct("Split") .field("direction", direction) - .field("clone_active_item", clone_active_item) + .field("mode", mode) .finish(), Event::JoinAll => f.write_str("JoinAll"), Event::JoinIntoNext => f.write_str("JoinIntoNext"), @@ -2295,10 +2315,7 @@ impl Pane { let save_task = if let Some(project_path) = project_path { let (worktree, path) = project_path.await?; let worktree_id = worktree.read_with(cx, |worktree, _| worktree.id())?; - let new_path = ProjectPath { - worktree_id, - path: path, - }; + let new_path = ProjectPath { worktree_id, path }; pane.update_in(cx, |pane, window, cx| { if let Some(item) = pane.item_for_path(new_path.clone(), cx) { @@ -2357,19 +2374,30 @@ impl Pane { } } - pub fn split(&mut self, direction: SplitDirection, cx: &mut Context) { - cx.emit(Event::Split { - direction, - clone_active_item: true, - }); - } - - pub fn split_and_move(&mut self, direction: SplitDirection, cx: &mut Context) { - if self.items.len() > 1 { + pub fn split( + &mut self, + direction: SplitDirection, + mode: SplitMode, + window: &mut Window, + cx: &mut Context, + ) { + if self.items.len() <= 1 && mode == SplitMode::MovePane { + // MovePane with only one pane present behaves like a SplitEmpty in the opposite direction + let active_item = self.active_item(); cx.emit(Event::Split { - direction, - clone_active_item: false, + direction: direction.opposite(), + mode: SplitMode::EmptyPane, }); + // ensure that we focus the moved pane + // in this case we know that the window is the same as the active_item + if let Some(active_item) = active_item { + cx.defer_in(window, move |_, window, cx| { + let focus_handle = active_item.item_focus_handle(cx); + window.focus(&focus_handle, cx); + }); + } + } else { + cx.emit(Event::Split { direction, mode }); } } @@ -3824,16 +3852,17 @@ fn default_render_tab_bar_buttons( .with_handle(pane.split_item_context_menu_handle.clone()) .menu(move |window, cx| { ContextMenu::build(window, cx, |menu, _, _| { + let mode = SplitMode::MovePane; if can_split_move { - menu.action("Split Right", SplitAndMoveRight.boxed_clone()) - .action("Split Left", SplitAndMoveLeft.boxed_clone()) - .action("Split Up", SplitAndMoveUp.boxed_clone()) - .action("Split Down", SplitAndMoveDown.boxed_clone()) + menu.action("Split Right", SplitRight { mode }.boxed_clone()) + .action("Split Left", SplitLeft { mode }.boxed_clone()) + .action("Split Up", SplitUp { mode }.boxed_clone()) + .action("Split Down", SplitDown { mode }.boxed_clone()) } else { - menu.action("Split Right", SplitRight.boxed_clone()) - .action("Split Left", SplitLeft.boxed_clone()) - .action("Split Up", SplitUp.boxed_clone()) - .action("Split Down", SplitDown.boxed_clone()) + menu.action("Split Right", SplitRight::default().boxed_clone()) + .action("Split Left", SplitLeft::default().boxed_clone()) + .action("Split Up", SplitUp::default().boxed_clone()) + .action("Split Down", SplitDown::default().boxed_clone()) } }) .into() @@ -3892,33 +3921,35 @@ impl Render for Pane { .size_full() .flex_none() .overflow_hidden() - .on_action( - cx.listener(|pane, _: &SplitLeft, _, cx| pane.split(SplitDirection::Left, cx)), - ) - .on_action(cx.listener(|pane, _: &SplitUp, _, cx| pane.split(SplitDirection::Up, cx))) - .on_action(cx.listener(|pane, _: &SplitHorizontal, _, cx| { - pane.split(SplitDirection::horizontal(cx), cx) + .on_action(cx.listener(|pane, split: &SplitLeft, window, cx| { + pane.split(SplitDirection::Left, split.mode, window, cx) })) - .on_action(cx.listener(|pane, _: &SplitVertical, _, cx| { - pane.split(SplitDirection::vertical(cx), cx) + .on_action(cx.listener(|pane, split: &SplitUp, window, cx| { + pane.split(SplitDirection::Up, split.mode, window, cx) })) - .on_action( - cx.listener(|pane, _: &SplitRight, _, cx| pane.split(SplitDirection::Right, cx)), - ) - .on_action( - cx.listener(|pane, _: &SplitDown, _, cx| pane.split(SplitDirection::Down, cx)), - ) - .on_action(cx.listener(|pane, _: &SplitAndMoveUp, _, cx| { - pane.split_and_move(SplitDirection::Up, cx) + .on_action(cx.listener(|pane, split: &SplitHorizontal, window, cx| { + pane.split(SplitDirection::horizontal(cx), split.mode, window, cx) + })) + .on_action(cx.listener(|pane, split: &SplitVertical, window, cx| { + pane.split(SplitDirection::vertical(cx), split.mode, window, cx) })) - .on_action(cx.listener(|pane, _: &SplitAndMoveDown, _, cx| { - pane.split_and_move(SplitDirection::Down, cx) + .on_action(cx.listener(|pane, split: &SplitRight, window, cx| { + pane.split(SplitDirection::Right, split.mode, window, cx) })) - .on_action(cx.listener(|pane, _: &SplitAndMoveLeft, _, cx| { - pane.split_and_move(SplitDirection::Left, cx) + .on_action(cx.listener(|pane, split: &SplitDown, window, cx| { + pane.split(SplitDirection::Down, split.mode, window, cx) })) - .on_action(cx.listener(|pane, _: &SplitAndMoveRight, _, cx| { - pane.split_and_move(SplitDirection::Right, cx) + .on_action(cx.listener(|pane, _: &SplitAndMoveUp, window, cx| { + pane.split(SplitDirection::Up, SplitMode::MovePane, window, cx) + })) + .on_action(cx.listener(|pane, _: &SplitAndMoveDown, window, cx| { + pane.split(SplitDirection::Down, SplitMode::MovePane, window, cx) + })) + .on_action(cx.listener(|pane, _: &SplitAndMoveLeft, window, cx| { + pane.split(SplitDirection::Left, SplitMode::MovePane, window, cx) + })) + .on_action(cx.listener(|pane, _: &SplitAndMoveRight, window, cx| { + pane.split(SplitDirection::Right, SplitMode::MovePane, window, cx) })) .on_action(cx.listener(|_, _: &JoinIntoNext, _, cx| { cx.emit(Event::JoinIntoNext); @@ -4443,11 +4474,14 @@ impl Render for DraggedTab { #[cfg(test)] mod tests { - use std::num::NonZero; + use std::{iter::zip, num::NonZero}; use super::*; - use crate::item::test::{TestItem, TestProjectItem}; - use gpui::{TestAppContext, VisualTestContext, size}; + use crate::{ + Member, + item::test::{TestItem, TestProjectItem}, + }; + use gpui::{AppContext, Axis, TestAppContext, VisualTestContext, size}; use project::FakeFs; use settings::SettingsStore; use theme::LoadThemes; @@ -7125,6 +7159,32 @@ mod tests { assert_item_labels(&pane, ["A", "C*", "B"], cx); } + #[gpui::test] + async fn test_split_empty(cx: &mut TestAppContext) { + for split_direction in SplitDirection::all() { + test_single_pane_split(["A"], split_direction, SplitMode::EmptyPane, cx).await; + } + } + + #[gpui::test] + async fn test_split_clone(cx: &mut TestAppContext) { + for split_direction in SplitDirection::all() { + test_single_pane_split(["A"], split_direction, SplitMode::ClonePane, cx).await; + } + } + + #[gpui::test] + async fn test_split_move_right_on_single_pane(cx: &mut TestAppContext) { + test_single_pane_split(["A"], SplitDirection::Right, SplitMode::MovePane, cx).await; + } + + #[gpui::test] + async fn test_split_move(cx: &mut TestAppContext) { + for split_direction in SplitDirection::all() { + test_single_pane_split(["A", "B"], split_direction, SplitMode::MovePane, cx).await; + } + } + fn init_test(cx: &mut TestAppContext) { cx.update(|cx| { let settings_store = SettingsStore::test(cx); @@ -7220,4 +7280,163 @@ mod tests { "pane items do not match expectation" ); } + + // Assert the item label, with the active item label expected active index + #[track_caller] + fn assert_item_labels_active_index( + pane: &Entity, + expected_states: &[&str], + expected_active_idx: usize, + cx: &mut VisualTestContext, + ) { + let actual_states = pane.update(cx, |pane, cx| { + pane.items + .iter() + .enumerate() + .map(|(ix, item)| { + let mut state = item + .to_any_view() + .downcast::() + .unwrap() + .read(cx) + .label + .clone(); + if ix == pane.active_item_index { + assert_eq!(ix, expected_active_idx); + } + if item.is_dirty(cx) { + state.push('^'); + } + if pane.is_tab_pinned(ix) { + state.push('!'); + } + state + }) + .collect::>() + }); + assert_eq!( + actual_states, expected_states, + "pane items do not match expectation" + ); + } + + #[track_caller] + fn assert_pane_ids_on_axis( + workspace: &Entity, + expected_ids: [&EntityId; COUNT], + expected_axis: Axis, + cx: &mut VisualTestContext, + ) { + workspace.read_with(cx, |workspace, _| match &workspace.center.root { + Member::Axis(axis) => { + assert_eq!(axis.axis, expected_axis); + assert_eq!(axis.members.len(), expected_ids.len()); + assert!( + zip(expected_ids, &axis.members).all(|(e, a)| { + if let Member::Pane(p) = a { + p.entity_id() == *e + } else { + false + } + }), + "pane ids do not match expectation: {expected_ids:?} != {actual_ids:?}", + actual_ids = axis.members + ); + } + Member::Pane(_) => panic!("expected axis"), + }); + } + + async fn test_single_pane_split( + pane_labels: [&str; COUNT], + direction: SplitDirection, + operation: SplitMode, + cx: &mut TestAppContext, + ) { + init_test(cx); + let fs = FakeFs::new(cx.executor()); + let project = Project::test(fs, None, cx).await; + let (workspace, cx) = + cx.add_window_view(|window, cx| Workspace::test_new(project, window, cx)); + + let mut pane_before = + workspace.read_with(cx, |workspace, _| workspace.active_pane().clone()); + for label in pane_labels { + add_labeled_item(&pane_before, label, false, cx); + } + pane_before.update_in(cx, |pane, window, cx| { + pane.split(direction, operation, window, cx) + }); + cx.executor().run_until_parked(); + let pane_after = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone()); + + let num_labels = pane_labels.len(); + let last_as_active = format!("{}*", String::from(pane_labels[num_labels - 1])); + + // check labels for all split operations + match operation { + SplitMode::EmptyPane => { + assert_item_labels_active_index(&pane_before, &pane_labels, num_labels - 1, cx); + assert_item_labels(&pane_after, [], cx); + } + SplitMode::ClonePane => { + assert_item_labels_active_index(&pane_before, &pane_labels, num_labels - 1, cx); + assert_item_labels(&pane_after, [&last_as_active], cx); + } + SplitMode::MovePane => { + let head = &pane_labels[..(num_labels - 1)]; + if num_labels == 1 { + // We special-case this behavior and actually execute an empty pane command + // followed by a refocus of the old pane for this case. + pane_before = workspace.read_with(cx, |workspace, _cx| { + workspace + .panes() + .into_iter() + .find(|pane| *pane != &pane_after) + .unwrap() + .clone() + }); + }; + + assert_item_labels_active_index( + &pane_before, + &head, + head.len().saturating_sub(1), + cx, + ); + assert_item_labels(&pane_after, [&last_as_active], cx); + pane_after.update_in(cx, |pane, window, cx| { + window.focused(cx).is_some_and(|focus_handle| { + focus_handle == pane.active_item().unwrap().item_focus_handle(cx) + }) + }); + } + } + + // expected axis depends on split direction + let expected_axis = match direction { + SplitDirection::Right | SplitDirection::Left => Axis::Horizontal, + SplitDirection::Up | SplitDirection::Down => Axis::Vertical, + }; + + // expected ids depends on split direction + let expected_ids = match direction { + SplitDirection::Right | SplitDirection::Down => { + [&pane_before.entity_id(), &pane_after.entity_id()] + } + SplitDirection::Left | SplitDirection::Up => { + [&pane_after.entity_id(), &pane_before.entity_id()] + } + }; + + // check pane axes for all operations + match operation { + SplitMode::EmptyPane | SplitMode::ClonePane => { + assert_pane_ids_on_axis(&workspace, expected_ids, expected_axis, cx); + } + SplitMode::MovePane => { + assert_pane_ids_on_axis(&workspace, expected_ids, expected_axis, cx); + } + } + } } diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index fa8e3a3dc2af33054907ea8a8c1ba095a3259207..eb0debc929e9bc17a5d64a7c650165446d687e4e 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -4262,16 +4262,19 @@ impl Workspace { item: item.boxed_clone(), }); } - pane::Event::Split { - direction, - clone_active_item, - } => { - if *clone_active_item { - self.split_and_clone(pane.clone(), *direction, window, cx) - .detach(); - } else { - self.split_and_move(pane.clone(), *direction, window, cx); - } + pane::Event::Split { direction, mode } => { + match mode { + SplitMode::ClonePane => { + self.split_and_clone(pane.clone(), *direction, window, cx) + .detach(); + } + SplitMode::EmptyPane => { + self.split_pane(pane.clone(), *direction, window, cx); + } + SplitMode::MovePane => { + self.split_and_move(pane.clone(), *direction, window, cx); + } + }; } pane::Event::JoinIntoNext => { self.join_pane_into_next(pane.clone(), window, cx); diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs index 392a57520d28be021e55cbd890d2eb968370c2f7..8c39b308f83a33a1d3408d5fb28c94658ce63c54 100644 --- a/crates/zed/src/zed.rs +++ b/crates/zed/src/zed.rs @@ -3817,7 +3817,7 @@ mod tests { }) .unwrap(); - cx.dispatch_action(window.into(), pane::SplitRight); + cx.dispatch_action(window.into(), pane::SplitRight::default()); let editor_2 = cx.update(|cx| { let pane_2 = workspace.read(cx).active_pane().clone(); assert_ne!(pane_1, pane_2); diff --git a/crates/zed/src/zed/app_menus.rs b/crates/zed/src/zed/app_menus.rs index a7961ac6d4cb663353af1e4e0d1fe66cf43a80a3..7cdeddab790dcc2227d4d91956a6261c5add5259 100644 --- a/crates/zed/src/zed/app_menus.rs +++ b/crates/zed/src/zed/app_menus.rs @@ -32,10 +32,10 @@ pub fn app_menus(cx: &mut App) -> Vec { MenuItem::submenu(Menu { name: "Editor Layout".into(), items: vec![ - MenuItem::action("Split Up", workspace::SplitUp), - MenuItem::action("Split Down", workspace::SplitDown), - MenuItem::action("Split Left", workspace::SplitLeft), - MenuItem::action("Split Right", workspace::SplitRight), + MenuItem::action("Split Up", workspace::SplitUp::default()), + MenuItem::action("Split Down", workspace::SplitDown::default()), + MenuItem::action("Split Left", workspace::SplitLeft::default()), + MenuItem::action("Split Right", workspace::SplitRight::default()), ], }), MenuItem::separator(), From 1469d94683b6f2ef54d7a98dff8e14be1d244061 Mon Sep 17 00:00:00 2001 From: Daeksell Date: Mon, 22 Dec 2025 02:50:54 +0300 Subject: [PATCH 600/621] Fix dock panel button tooltip not dismissed when state changes via keyboard shortcut (#44746) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #44720 Release Notes: - Fixed dock panel button tooltips not being dismissed when toggling panels via keyboard shortcut **Problem:** When hovering over a dock panel button and using a keyboard shortcut to toggle the panel, the tooltip remains visible with stale content. This is inconsistent with mouse click behavior, where the tooltip is dismissed on mouse down. **Solution:** Include the panel's active state in the button's element ID. When the state changes, the element ID changes (e.g., `"DebugPanel"` → `"DebugPanel-active"`), which causes GPUI to discard the old element state including the cached tooltip. **Testing:** Manually verified: 1. Hover over a dock panel button, wait for tooltip 2. Press keyboard shortcut to toggle the panel 3. Tooltip is now dismissed (consistent with mouse click behavior) https://github.com/user-attachments/assets/ed92fb6c-6c22-44e2-87e3-5461d35f7106 --------- Co-authored-by: MrSubidubi --- crates/workspace/src/dock.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/workspace/src/dock.rs b/crates/workspace/src/dock.rs index 7f4b09df0f94fa421c399ed9d70163f7cc2ba203..310ef8133e4a4bac1df42becec2b3d6574279431 100644 --- a/crates/workspace/src/dock.rs +++ b/crates/workspace/src/dock.rs @@ -1037,7 +1037,9 @@ impl Render for PanelButtons { .anchor(menu_anchor) .attach(menu_attach) .trigger(move |is_active, _window, _cx| { - IconButton::new(name, icon) + // Include active state in element ID to invalidate the cached + // tooltip when panel state changes (e.g., via keyboard shortcut) + IconButton::new((name, is_active_button as u64), icon) .icon_size(IconSize::Small) .toggle_state(is_active_button) .on_click({ From 9adb3e1daae129270b7230c95bd3745c0451cfe4 Mon Sep 17 00:00:00 2001 From: morgankrey Date: Sun, 21 Dec 2025 20:31:24 -0600 Subject: [PATCH 601/621] docs: Testing automatic documentation updates locally (2025-12-21) (#45503) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Documentation Update Summary ### Changes Made | File | Change | Related Code | | --- | --- | --- | | `docs/src/ai/edit-prediction.md` | Updated Codestral setup instructions to use Settings Editor path instead of outdated `agent::OpenSettings` action reference | Settings Editor provider configuration flow | ### Rationale The primary documentation update addresses outdated instructions in the Codestral setup section. The original text referenced an `agent::OpenSettings` action that directed users to an "Agent Panel settings view" which no longer reflects the current UI flow. The updated instructions now guide users through the Settings Editor with platform-specific keyboard shortcuts and provide an alternative status bar path. ### Review Notes - **Codestral instructions**: Reviewers should verify the Settings Editor navigation path (`Cmd+,` → search "Edit Predictions" → **Configure Providers**) matches the current Zed UI - **Status bar alternative**: The alternative path via "edit prediction icon in the status bar" should be confirmed as accurate --- ## Update from 2025-12-21 20:25 --- **Source**: [#44914](https://github.com/zed-industries/zed/pull/44914) - settings_ui: Add Edit keybindings button **Author**: @probably-neb Now I have all the context needed to create a comprehensive documentation update summary. ## Documentation Update Summary ### Changes Made | File | Change | Related Code | | --- | --- | --- | | docs/src/ai/agent-panel.md | Added documentation for `agent::PasteRaw` action, explaining automatic @mention formatting for pasted code and how to bypass it | PR #45254 | ### Rationale PR #45254 ("agent_ui: Improve UX when pasting code into message editor") introduced the `agent::PasteRaw` action, which allows users to paste clipboard content without automatic formatting. When users copy multi-line code from an editor buffer and paste it into the Agent panel, Zed now automatically formats it as an @mention with file context. The `PasteRaw` action provides a way to bypass this behavior when raw text is preferred. This documentation update ensures users can discover both: 1. The new automatic @mention formatting behavior 2. The keybinding to bypass it when needed ### Review Notes - The new paragraph was placed in the "Adding Context" section, immediately after the existing note about image pasting support—this maintains logical flow since both relate to pasting behavior - Uses the standard `{#kb agent::PasteRaw}` syntax for keybinding references, consistent with other keybinding documentation in the file - The documentation passed Prettier formatting validation without modifications --- ### Condensed Version (for commit message) ``` docs(agent-panel): Document PasteRaw action for bypassing auto @mention formatting Added explanation that multi-line code pasted from editor buffers is automatically formatted as @mentions, with keybinding to paste raw text. Related: PR #45254 ``` Release Notes: - N/A --------- Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> Co-authored-by: Zed Zippy <234243425+zed-zippy[bot]@users.noreply.github.com> --- docs/src/ai/agent-panel.md | 4 ++++ docs/src/ai/edit-prediction.md | 20 ++++++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/docs/src/ai/agent-panel.md b/docs/src/ai/agent-panel.md index c383862ed631cbfdc42f591d63be09fb1209c8b8..0197bfb3ecc7b4ea245c6ce6963c3b592558a90f 100644 --- a/docs/src/ai/agent-panel.md +++ b/docs/src/ai/agent-panel.md @@ -85,6 +85,8 @@ You can type `@` to mention files, directories, symbols, previous threads, and r Copying images and pasting them in the panel's message editor is also supported. +When you paste multi-line code selections copied from an editor buffer, Zed automatically formats them as @mentions with the file context. To paste content without this automatic formatting, use {#kb agent::PasteRaw} to paste raw text directly. + ### Selection as Context Additionally, you can also select text in a buffer and add it as context by using the {#kb agent::AddSelectionToThread} keybinding, running the {#action agent::AddSelectionToThread} action, or choosing the "Selection" item in the `@` menu. @@ -100,6 +102,8 @@ You can also do this at any time with an ongoing thread via the "Agent Options" After you've configured your LLM providers—either via [a custom API key](./llm-providers.md) or through [Zed's hosted models](./models.md)—you can switch between them by clicking on the model selector on the message editor or by using the {#kb agent::ToggleModelSelector} keybinding. +If you have favorited models configured, you can cycle through them with {#kb agent::CycleFavoriteModels} without opening the model selector. + > The same model can be offered via multiple providers - for example, Claude Sonnet 4 is available via Zed Pro, OpenRouter, Anthropic directly, and more. > Make sure you've selected the correct model **_provider_** for the model you'd like to use, delineated by the logo to the left of the model in the model selector. diff --git a/docs/src/ai/edit-prediction.md b/docs/src/ai/edit-prediction.md index 65a427842cda461806dc79ecf67f3a180afd9763..74a85f566fae43d5696e14192c07ec1ca4f22d27 100644 --- a/docs/src/ai/edit-prediction.md +++ b/docs/src/ai/edit-prediction.md @@ -305,7 +305,7 @@ To use GitHub Copilot as your provider, set this within `settings.json`: } ``` -You should be able to sign-in to GitHub Copilot by clicking on the Copilot icon in the status bar and following the setup instructions. +To sign in to GitHub Copilot, click on the Copilot icon in the status bar. A popup window appears displaying a device code. Click the copy button to copy the code, then click "Connect to GitHub" to open the GitHub verification page in your browser. Paste the code when prompted. The popup window closes automatically after successful authorization. #### Using GitHub Copilot Enterprise @@ -348,10 +348,22 @@ You should be able to sign-in to Supermaven by clicking on the Supermaven icon i ### Codestral {#codestral} -To use Mistral's Codestral as your provider, start by going to the Agent Panel settings view by running the {#action agent::OpenSettings} action. -Look for the Mistral item and add a Codestral API key in the corresponding text input. +<<<<<<< Updated upstream +To use Mistral's Codestral as your provider: +======= +To use Mistral's Codestral as your provider, open the Settings Editor (`Cmd+,` on macOS, `Ctrl+,` on Linux/Windows) and navigate to the Edit Predictions section. Select Codestral as your provider and enter your API key in the corresponding field. -After that, you should be able to switch your provider to it in your `settings.json` file: +> > > > > > > Stashed changes + +1. Open the Settings Editor (`Cmd+,` on macOS, `Ctrl+,` on Linux/Windows) +2. Search for "Edit Predictions" and click **Configure Providers** +3. Find the Codestral section and enter your API key from the + [Codestral dashboard](https://console.mistral.ai/codestral) + +Alternatively, click the edit prediction icon in the status bar and select +**Configure Providers** from the menu. + +After adding your API key, set Codestral as your provider in `settings.json`: ```json [settings] { From 397fcf608341ad9c71f33aac97d213942ccc3860 Mon Sep 17 00:00:00 2001 From: Marshall Bowers Date: Sun, 21 Dec 2025 23:10:26 -0500 Subject: [PATCH 602/621] docs: Fix Edit Prediction docs for Codestral (#45509) This PR fixes the Edit Prediction docs for Codestral after they got mangled in https://github.com/zed-industries/zed/pull/45503. Release Notes: - N/A --- docs/src/ai/edit-prediction.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/docs/src/ai/edit-prediction.md b/docs/src/ai/edit-prediction.md index 74a85f566fae43d5696e14192c07ec1ca4f22d27..afa9a08a41b5946f4bdc97a2b6a0ed97a0167d14 100644 --- a/docs/src/ai/edit-prediction.md +++ b/docs/src/ai/edit-prediction.md @@ -348,12 +348,7 @@ You should be able to sign-in to Supermaven by clicking on the Supermaven icon i ### Codestral {#codestral} -<<<<<<< Updated upstream To use Mistral's Codestral as your provider: -======= -To use Mistral's Codestral as your provider, open the Settings Editor (`Cmd+,` on macOS, `Ctrl+,` on Linux/Windows) and navigate to the Edit Predictions section. Select Codestral as your provider and enter your API key in the corresponding field. - -> > > > > > > Stashed changes 1. Open the Settings Editor (`Cmd+,` on macOS, `Ctrl+,` on Linux/Windows) 2. Search for "Edit Predictions" and click **Configure Providers** From 746b76488c85e70c4159c937c75af64c87275b1f Mon Sep 17 00:00:00 2001 From: Finn Evers Date: Mon, 22 Dec 2025 10:28:11 +0100 Subject: [PATCH 603/621] util: Keep default permissions when extracting Zip with unset permissions (#45515) This ensures that we do not extract files with no permissions (`0o000`), because these would become unusable on the host Release Notes: - N/A --- crates/util/src/archive.rs | 54 +++++++++++++++++++++++++++++++++----- 1 file changed, 48 insertions(+), 6 deletions(-) diff --git a/crates/util/src/archive.rs b/crates/util/src/archive.rs index 5a5dc777722c67d3e5bb96ed7115ccd2a71b8cbe..bd4f01f953c306a06c098f6dad0a87b0a9ae2c5c 100644 --- a/crates/util/src/archive.rs +++ b/crates/util/src/archive.rs @@ -109,7 +109,9 @@ pub async fn extract_seekable_zip( .await .with_context(|| format!("extracting into file {path:?}"))?; - if let Some(perms) = entry.unix_permissions() { + if let Some(perms) = entry.unix_permissions() + && perms != 0o000 + { use std::os::unix::fs::PermissionsExt; let permissions = std::fs::Permissions::from_mode(u32::from(perms)); file.set_permissions(permissions) @@ -132,7 +134,8 @@ mod tests { use super::*; - async fn compress_zip(src_dir: &Path, dst: &Path) -> Result<()> { + #[allow(unused_variables)] + async fn compress_zip(src_dir: &Path, dst: &Path, keep_file_permissions: bool) -> Result<()> { let mut out = smol::fs::File::create(dst).await?; let mut writer = ZipFileWriter::new(&mut out); @@ -155,8 +158,8 @@ mod tests { ZipEntryBuilder::new(filename.into(), async_zip::Compression::Deflate); use std::os::unix::fs::PermissionsExt; let metadata = std::fs::metadata(path)?; - let perms = metadata.permissions().mode() as u16; - builder = builder.unix_permissions(perms); + let perms = keep_file_permissions.then(|| metadata.permissions().mode() as u16); + builder = builder.unix_permissions(perms.unwrap_or_default()); writer.write_entry_whole(builder, &data).await?; } #[cfg(not(unix))] @@ -206,7 +209,9 @@ mod tests { let zip_file = test_dir.path().join("test.zip"); smol::block_on(async { - compress_zip(test_dir.path(), &zip_file).await.unwrap(); + compress_zip(test_dir.path(), &zip_file, true) + .await + .unwrap(); let reader = read_archive(&zip_file).await; let dir = tempfile::tempdir().unwrap(); @@ -237,7 +242,9 @@ mod tests { // Create zip let zip_file = test_dir.path().join("test.zip"); - compress_zip(test_dir.path(), &zip_file).await.unwrap(); + compress_zip(test_dir.path(), &zip_file, true) + .await + .unwrap(); // Extract to new location let extract_dir = tempfile::tempdir().unwrap(); @@ -251,4 +258,39 @@ mod tests { assert_eq!(extracted_perms.mode() & 0o777, 0o755); }); } + + #[cfg(unix)] + #[test] + fn test_extract_zip_sets_default_permissions() { + use std::os::unix::fs::PermissionsExt; + + smol::block_on(async { + let test_dir = tempfile::tempdir().unwrap(); + let executable_path = test_dir.path().join("my_script"); + + // Create an executable file + std::fs::write(&executable_path, "#!/bin/bash\necho 'Hello'").unwrap(); + + // Create zip + let zip_file = test_dir.path().join("test.zip"); + compress_zip(test_dir.path(), &zip_file, false) + .await + .unwrap(); + + // Extract to new location + let extract_dir = tempfile::tempdir().unwrap(); + let reader = read_archive(&zip_file).await; + extract_zip(extract_dir.path(), reader).await.unwrap(); + + // Check permissions are preserved + let extracted_path = extract_dir.path().join("my_script"); + assert!(extracted_path.exists()); + let extracted_perms = std::fs::metadata(&extracted_path).unwrap().permissions(); + assert_eq!( + extracted_perms.mode() & 0o777, + 0o644, + "Expected default set of permissions for unzipped file with no permissions set." + ); + }); + } } From cff3ac6f93f506330034652f0d2389591bfb45a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Fern=C3=A1ndez=20G=C3=B3mez?= Date: Mon, 22 Dec 2025 11:17:26 +0100 Subject: [PATCH 604/621] docs: Fix `download_file` documentation (#45517) Fix a small error in the docs for the extension capabilities Release Notes: - N/A --- docs/src/extensions/capabilities.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/extensions/capabilities.md b/docs/src/extensions/capabilities.md index 4d935a0725a1285065070eccb5112dc636e26a27..9af038497d20aca298515bb87f8e505f9ea03c87 100644 --- a/docs/src/extensions/capabilities.md +++ b/docs/src/extensions/capabilities.md @@ -62,7 +62,7 @@ The `download_file` capability grants extensions the ability to download files u To allow any file to be downloaded: ```toml -{ kind = "download_file", host = "github.com", path = ["**"] } +{ kind = "download_file", host = "*", path = ["**"] } ``` To allow any file to be downloaded from `github.com`: From f9d9721b934ba859928026fc71f74b6c5ff33ab2 Mon Sep 17 00:00:00 2001 From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Date: Mon, 22 Dec 2025 14:06:54 -0300 Subject: [PATCH 605/621] agent_ui: Expand model favoriting feature to external agents (#45528) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR adds the ability to favorite models for external agents—writing to the settings in the `agent_servers` key—as well as a handful of other improvements: - Make the cycling keybinding `alt-enter` work for the inline assistant as well as previous user messages - Better organized the keybinding files removing some outdated agent-related keybinding definitions - Renamed the inline assistant key context to "InlineAssistant" as "PromptEditor" is old and confusing - Made the keybindings to rate an inline assistant response visible in the thumbs up/down button's tooltip - Created a unified component for the model selector tooltip given we had 3 different places creating the same element - Make the "Cycle Favorited Models" row in the tooltip visible only if there is more than one favorite models Release Notes: - agent: External agents also now support the favoriting model feature, which comes with a handy keybinding to cycle through the favorite list. --- assets/keymaps/default-linux.json | 57 ++--- assets/keymaps/default-macos.json | 58 ++---- assets/keymaps/default-windows.json | 58 ++---- assets/keymaps/linux/cursor.json | 2 +- assets/keymaps/macos/cursor.json | 2 +- crates/acp_thread/src/connection.rs | 6 - crates/agent/src/agent.rs | 4 - crates/agent/src/native_agent_server.rs | 36 ++++ crates/agent_servers/src/agent_servers.rs | 30 ++- crates/agent_servers/src/claude.rs | 43 ++++ crates/agent_servers/src/codex.rs | 43 ++++ crates/agent_servers/src/custom.rs | 63 ++++++ crates/agent_servers/src/e2e_tests.rs | 2 + crates/agent_ui/src/acp/model_selector.rs | 197 +++++++++++------- .../src/acp/model_selector_popover.rs | 55 +---- crates/agent_ui/src/acp/thread_view.rs | 62 +++--- crates/agent_ui/src/agent_configuration.rs | 1 + crates/agent_ui/src/agent_model_selector.rs | 22 +- crates/agent_ui/src/favorite_models.rs | 29 +-- crates/agent_ui/src/inline_prompt_editor.rs | 46 ++-- .../agent_ui/src/language_model_selector.rs | 15 +- crates/agent_ui/src/text_thread_editor.rs | 51 ++--- .../src/ui/model_selector_components.rs | 68 +++++- crates/project/src/agent_server_store.rs | 27 +++ crates/settings/src/settings_content/agent.rs | 21 ++ 25 files changed, 612 insertions(+), 386 deletions(-) diff --git a/assets/keymaps/default-linux.json b/assets/keymaps/default-linux.json index 465c7d86aeaff23bdebe65792304ac2963edaaa7..e2a0bd89b54110209777857e8690ab123d92e3bb 100644 --- a/assets/keymaps/default-linux.json +++ b/assets/keymaps/default-linux.json @@ -241,6 +241,7 @@ "ctrl-alt-l": "agent::OpenRulesLibrary", "ctrl-i": "agent::ToggleProfileSelector", "ctrl-alt-/": "agent::ToggleModelSelector", + "alt-tab": "agent::CycleFavoriteModels", "ctrl-shift-j": "agent::ToggleNavigationMenu", "ctrl-alt-i": "agent::ToggleOptionsMenu", "ctrl-alt-shift-n": "agent::ToggleNewThreadMenu", @@ -253,7 +254,6 @@ "ctrl-y": "agent::AllowOnce", "ctrl-alt-y": "agent::AllowAlways", "ctrl-alt-z": "agent::RejectOnce", - "alt-tab": "agent::CycleFavoriteModels", }, }, { @@ -286,31 +286,7 @@ }, }, { - "context": "MessageEditor && !Picker > Editor && !use_modifier_to_send", - "bindings": { - "enter": "agent::Chat", - "ctrl-enter": "agent::ChatWithFollow", - "ctrl-i": "agent::ToggleProfileSelector", - "shift-ctrl-r": "agent::OpenAgentDiff", - "ctrl-shift-y": "agent::KeepAll", - "ctrl-shift-n": "agent::RejectAll", - "ctrl-shift-v": "agent::PasteRaw", - }, - }, - { - "context": "MessageEditor && !Picker > Editor && use_modifier_to_send", - "bindings": { - "ctrl-enter": "agent::Chat", - "enter": "editor::Newline", - "ctrl-i": "agent::ToggleProfileSelector", - "shift-ctrl-r": "agent::OpenAgentDiff", - "ctrl-shift-y": "agent::KeepAll", - "ctrl-shift-n": "agent::RejectAll", - "ctrl-shift-v": "agent::PasteRaw", - }, - }, - { - "context": "EditMessageEditor > Editor", + "context": "AgentFeedbackMessageEditor > Editor", "bindings": { "escape": "menu::Cancel", "enter": "menu::Confirm", @@ -318,17 +294,23 @@ }, }, { - "context": "AgentFeedbackMessageEditor > Editor", + "context": "AcpThread > ModeSelector", "bindings": { - "escape": "menu::Cancel", - "enter": "menu::Confirm", - "alt-enter": "editor::Newline", + "ctrl-enter": "menu::Confirm", }, }, { - "context": "AcpThread > ModeSelector", + "context": "AcpThread > Editor", + "use_key_equivalents": true, "bindings": { - "ctrl-enter": "menu::Confirm", + "ctrl-enter": "agent::ChatWithFollow", + "ctrl-i": "agent::ToggleProfileSelector", + "ctrl-shift-r": "agent::OpenAgentDiff", + "ctrl-shift-y": "agent::KeepAll", + "ctrl-shift-n": "agent::RejectAll", + "ctrl-shift-v": "agent::PasteRaw", + "shift-tab": "agent::CycleModeSelector", + "alt-tab": "agent::CycleFavoriteModels", }, }, { @@ -336,9 +318,6 @@ "use_key_equivalents": true, "bindings": { "enter": "agent::Chat", - "shift-ctrl-r": "agent::OpenAgentDiff", - "ctrl-shift-y": "agent::KeepAll", - "ctrl-shift-n": "agent::RejectAll", }, }, { @@ -346,11 +325,7 @@ "use_key_equivalents": true, "bindings": { "ctrl-enter": "agent::Chat", - "shift-ctrl-r": "agent::OpenAgentDiff", - "ctrl-shift-y": "agent::KeepAll", - "ctrl-shift-n": "agent::RejectAll", - "shift-tab": "agent::CycleModeSelector", - "alt-tab": "agent::CycleFavoriteModels", + "enter": "editor::Newline", }, }, { @@ -817,7 +792,7 @@ }, }, { - "context": "PromptEditor", + "context": "InlineAssistant", "bindings": { "ctrl-[": "agent::CyclePreviousInlineAssist", "ctrl-]": "agent::CycleNextInlineAssist", diff --git a/assets/keymaps/default-macos.json b/assets/keymaps/default-macos.json index 7ff00c41d5d6108b2a0b9fa0de85c511fab1f6e0..2524d98e3778684080775f00a82d0764bfd0361b 100644 --- a/assets/keymaps/default-macos.json +++ b/assets/keymaps/default-macos.json @@ -282,6 +282,7 @@ "cmd-alt-p": "agent::ManageProfiles", "cmd-i": "agent::ToggleProfileSelector", "cmd-alt-/": "agent::ToggleModelSelector", + "alt-tab": "agent::CycleFavoriteModels", "cmd-shift-j": "agent::ToggleNavigationMenu", "cmd-alt-m": "agent::ToggleOptionsMenu", "cmd-alt-shift-n": "agent::ToggleNewThreadMenu", @@ -294,7 +295,6 @@ "cmd-y": "agent::AllowOnce", "cmd-alt-y": "agent::AllowAlways", "cmd-alt-z": "agent::RejectOnce", - "alt-tab": "agent::CycleFavoriteModels", }, }, { @@ -326,41 +326,6 @@ "cmd-alt-t": "agent::NewThread", }, }, - { - "context": "MessageEditor && !Picker > Editor && !use_modifier_to_send", - "use_key_equivalents": true, - "bindings": { - "enter": "agent::Chat", - "cmd-enter": "agent::ChatWithFollow", - "cmd-i": "agent::ToggleProfileSelector", - "shift-ctrl-r": "agent::OpenAgentDiff", - "cmd-shift-y": "agent::KeepAll", - "cmd-shift-n": "agent::RejectAll", - "cmd-shift-v": "agent::PasteRaw", - }, - }, - { - "context": "MessageEditor && !Picker > Editor && use_modifier_to_send", - "use_key_equivalents": true, - "bindings": { - "cmd-enter": "agent::Chat", - "enter": "editor::Newline", - "cmd-i": "agent::ToggleProfileSelector", - "shift-ctrl-r": "agent::OpenAgentDiff", - "cmd-shift-y": "agent::KeepAll", - "cmd-shift-n": "agent::RejectAll", - "cmd-shift-v": "agent::PasteRaw", - }, - }, - { - "context": "EditMessageEditor > Editor", - "use_key_equivalents": true, - "bindings": { - "escape": "menu::Cancel", - "enter": "menu::Confirm", - "alt-enter": "editor::Newline", - }, - }, { "context": "AgentFeedbackMessageEditor > Editor", "use_key_equivalents": true, @@ -383,27 +348,32 @@ }, }, { - "context": "AcpThread > Editor && !use_modifier_to_send", + "context": "AcpThread > Editor", "use_key_equivalents": true, "bindings": { - "enter": "agent::Chat", "shift-ctrl-r": "agent::OpenAgentDiff", "cmd-shift-y": "agent::KeepAll", "cmd-shift-n": "agent::RejectAll", + "cmd-enter": "agent::ChatWithFollow", + "cmd-shift-v": "agent::PasteRaw", + "cmd-i": "agent::ToggleProfileSelector", "shift-tab": "agent::CycleModeSelector", "alt-tab": "agent::CycleFavoriteModels", }, }, + { + "context": "AcpThread > Editor && !use_modifier_to_send", + "use_key_equivalents": true, + "bindings": { + "enter": "agent::Chat", + }, + }, { "context": "AcpThread > Editor && use_modifier_to_send", "use_key_equivalents": true, "bindings": { "cmd-enter": "agent::Chat", - "shift-ctrl-r": "agent::OpenAgentDiff", - "cmd-shift-y": "agent::KeepAll", - "cmd-shift-n": "agent::RejectAll", - "shift-tab": "agent::CycleModeSelector", - "alt-tab": "agent::CycleFavoriteModels", + "enter": "editor::Newline", }, }, { @@ -883,7 +853,7 @@ }, }, { - "context": "PromptEditor", + "context": "InlineAssistant > Editor", "use_key_equivalents": true, "bindings": { "cmd-alt-/": "agent::ToggleModelSelector", diff --git a/assets/keymaps/default-windows.json b/assets/keymaps/default-windows.json index 445933c950cbc9ef72eb2cca90ab8115471f1e6f..039ae408219909006e5d84bb12822444330acd83 100644 --- a/assets/keymaps/default-windows.json +++ b/assets/keymaps/default-windows.json @@ -241,6 +241,7 @@ "shift-alt-l": "agent::OpenRulesLibrary", "shift-alt-p": "agent::ManageProfiles", "ctrl-i": "agent::ToggleProfileSelector", + "alt-tab": "agent::CycleFavoriteModels", "shift-alt-/": "agent::ToggleModelSelector", "shift-alt-j": "agent::ToggleNavigationMenu", "shift-alt-i": "agent::ToggleOptionsMenu", @@ -254,7 +255,6 @@ "shift-alt-a": "agent::AllowOnce", "ctrl-alt-y": "agent::AllowAlways", "shift-alt-z": "agent::RejectOnce", - "alt-tab": "agent::CycleFavoriteModels", }, }, { @@ -287,41 +287,6 @@ "ctrl-alt-t": "agent::NewThread", }, }, - { - "context": "MessageEditor && !Picker > Editor && !use_modifier_to_send", - "use_key_equivalents": true, - "bindings": { - "enter": "agent::Chat", - "ctrl-enter": "agent::ChatWithFollow", - "ctrl-i": "agent::ToggleProfileSelector", - "ctrl-shift-r": "agent::OpenAgentDiff", - "ctrl-shift-y": "agent::KeepAll", - "ctrl-shift-n": "agent::RejectAll", - "ctrl-shift-v": "agent::PasteRaw", - }, - }, - { - "context": "MessageEditor && !Picker > Editor && use_modifier_to_send", - "use_key_equivalents": true, - "bindings": { - "ctrl-enter": "agent::Chat", - "enter": "editor::Newline", - "ctrl-i": "agent::ToggleProfileSelector", - "ctrl-shift-r": "agent::OpenAgentDiff", - "ctrl-shift-y": "agent::KeepAll", - "ctrl-shift-n": "agent::RejectAll", - "ctrl-shift-v": "agent::PasteRaw", - }, - }, - { - "context": "EditMessageEditor > Editor", - "use_key_equivalents": true, - "bindings": { - "escape": "menu::Cancel", - "enter": "menu::Confirm", - "alt-enter": "editor::Newline", - }, - }, { "context": "AgentFeedbackMessageEditor > Editor", "use_key_equivalents": true, @@ -338,27 +303,32 @@ }, }, { - "context": "AcpThread > Editor && !use_modifier_to_send", + "context": "AcpThread > Editor", "use_key_equivalents": true, "bindings": { - "enter": "agent::Chat", + "ctrl-enter": "agent::ChatWithFollow", + "ctrl-i": "agent::ToggleProfileSelector", "ctrl-shift-r": "agent::OpenAgentDiff", "ctrl-shift-y": "agent::KeepAll", "ctrl-shift-n": "agent::RejectAll", + "ctrl-shift-v": "agent::PasteRaw", "shift-tab": "agent::CycleModeSelector", "alt-tab": "agent::CycleFavoriteModels", }, }, + { + "context": "AcpThread > Editor && !use_modifier_to_send", + "use_key_equivalents": true, + "bindings": { + "enter": "agent::Chat", + }, + }, { "context": "AcpThread > Editor && use_modifier_to_send", "use_key_equivalents": true, "bindings": { "ctrl-enter": "agent::Chat", - "ctrl-shift-r": "agent::OpenAgentDiff", - "ctrl-shift-y": "agent::KeepAll", - "ctrl-shift-n": "agent::RejectAll", - "shift-tab": "agent::CycleModeSelector", - "alt-tab": "agent::CycleFavoriteModels", + "enter": "editor::Newline", }, }, { @@ -826,7 +796,7 @@ }, }, { - "context": "PromptEditor", + "context": "InlineAssistant", "use_key_equivalents": true, "bindings": { "ctrl-[": "agent::CyclePreviousInlineAssist", diff --git a/assets/keymaps/linux/cursor.json b/assets/keymaps/linux/cursor.json index 58a7309cf902a3f69f949830cace2200f41fb0fe..e1eeade9db16d178fb2ce0ec4b2ec03f0ac2c221 100644 --- a/assets/keymaps/linux/cursor.json +++ b/assets/keymaps/linux/cursor.json @@ -24,7 +24,7 @@ }, }, { - "context": "InlineAssistEditor", + "context": "InlineAssistant > Editor", "use_key_equivalents": true, "bindings": { "ctrl-shift-backspace": "editor::Cancel", diff --git a/assets/keymaps/macos/cursor.json b/assets/keymaps/macos/cursor.json index 93e259db37ac718d2e0258d83e4de436a0a378fd..2824575a445ad0c870a59cb516441dc6f1421f31 100644 --- a/assets/keymaps/macos/cursor.json +++ b/assets/keymaps/macos/cursor.json @@ -24,7 +24,7 @@ }, }, { - "context": "InlineAssistEditor", + "context": "InlineAssistant > Editor", "use_key_equivalents": true, "bindings": { "cmd-shift-backspace": "editor::Cancel", diff --git a/crates/acp_thread/src/connection.rs b/crates/acp_thread/src/connection.rs index 598d0428174eb2fc124739a18ddeff1098521cb7..fa15a339f7db67a90144b645177f1146c97334b4 100644 --- a/crates/acp_thread/src/connection.rs +++ b/crates/acp_thread/src/connection.rs @@ -202,12 +202,6 @@ pub trait AgentModelSelector: 'static { fn should_render_footer(&self) -> bool { false } - - /// Whether this selector supports the favorites feature. - /// Only the native agent uses the model ID format that maps to settings. - fn supports_favorites(&self) -> bool { - false - } } /// Icon for a model in the model selector. diff --git a/crates/agent/src/agent.rs b/crates/agent/src/agent.rs index 4baa7f4ea4004d2137b5cddb255346fa91523091..612360fe887e11859635844c79ee5cf25515c2a1 100644 --- a/crates/agent/src/agent.rs +++ b/crates/agent/src/agent.rs @@ -1167,10 +1167,6 @@ impl acp_thread::AgentModelSelector for NativeAgentModelSelector { fn should_render_footer(&self) -> bool { true } - - fn supports_favorites(&self) -> bool { - true - } } impl acp_thread::AgentConnection for NativeAgentConnection { diff --git a/crates/agent/src/native_agent_server.rs b/crates/agent/src/native_agent_server.rs index a9ade8141a678329e0dd8dad9808e55eee3c382b..95312fd32536b99059e2ebc6ebd0a9ea522f94be 100644 --- a/crates/agent/src/native_agent_server.rs +++ b/crates/agent/src/native_agent_server.rs @@ -1,10 +1,14 @@ use std::{any::Any, path::Path, rc::Rc, sync::Arc}; +use agent_client_protocol as acp; use agent_servers::{AgentServer, AgentServerDelegate}; +use agent_settings::AgentSettings; use anyhow::Result; +use collections::HashSet; use fs::Fs; use gpui::{App, Entity, SharedString, Task}; use prompt_store::PromptStore; +use settings::{LanguageModelSelection, Settings as _, update_settings_file}; use crate::{HistoryStore, NativeAgent, NativeAgentConnection, templates::Templates}; @@ -71,6 +75,38 @@ impl AgentServer for NativeAgentServer { fn into_any(self: Rc) -> Rc { self } + + fn favorite_model_ids(&self, cx: &mut App) -> HashSet { + AgentSettings::get_global(cx).favorite_model_ids() + } + + fn toggle_favorite_model( + &self, + model_id: acp::ModelId, + should_be_favorite: bool, + fs: Arc, + cx: &App, + ) { + let selection = model_id_to_selection(&model_id); + update_settings_file(fs, cx, move |settings, _| { + let agent = settings.agent.get_or_insert_default(); + if should_be_favorite { + agent.add_favorite_model(selection.clone()); + } else { + agent.remove_favorite_model(&selection); + } + }); + } +} + +/// Convert a ModelId (e.g. "anthropic/claude-3-5-sonnet") to a LanguageModelSelection. +fn model_id_to_selection(model_id: &acp::ModelId) -> LanguageModelSelection { + let id = model_id.0.as_ref(); + let (provider, model) = id.split_once('/').unwrap_or(("", id)); + LanguageModelSelection { + provider: provider.to_owned().into(), + model: model.to_owned(), + } } #[cfg(test)] diff --git a/crates/agent_servers/src/agent_servers.rs b/crates/agent_servers/src/agent_servers.rs index 46e8508e44f07e4fb3d613e30387d5afd3f38423..c6e66688dd6af6748a97dcd4569827fd7fa32493 100644 --- a/crates/agent_servers/src/agent_servers.rs +++ b/crates/agent_servers/src/agent_servers.rs @@ -4,6 +4,8 @@ mod codex; mod custom; mod gemini; +use collections::HashSet; + #[cfg(any(test, feature = "test-support"))] pub mod e2e_tests; @@ -56,9 +58,19 @@ impl AgentServerDelegate { pub trait AgentServer: Send { fn logo(&self) -> ui::IconName; fn name(&self) -> SharedString; + fn connect( + &self, + root_dir: Option<&Path>, + delegate: AgentServerDelegate, + cx: &mut App, + ) -> Task, Option)>>; + + fn into_any(self: Rc) -> Rc; + fn default_mode(&self, _cx: &mut App) -> Option { None } + fn set_default_mode( &self, _mode_id: Option, @@ -79,14 +91,18 @@ pub trait AgentServer: Send { ) { } - fn connect( - &self, - root_dir: Option<&Path>, - delegate: AgentServerDelegate, - cx: &mut App, - ) -> Task, Option)>>; + fn favorite_model_ids(&self, _cx: &mut App) -> HashSet { + HashSet::default() + } - fn into_any(self: Rc) -> Rc; + fn toggle_favorite_model( + &self, + _model_id: agent_client_protocol::ModelId, + _should_be_favorite: bool, + _fs: Arc, + _cx: &App, + ) { + } } impl dyn AgentServer { diff --git a/crates/agent_servers/src/claude.rs b/crates/agent_servers/src/claude.rs index e67ddd5c0698758fdec7c7796b26a1351e9990e5..30ef39af953e66fc983c3d7f189042b6577e84c0 100644 --- a/crates/agent_servers/src/claude.rs +++ b/crates/agent_servers/src/claude.rs @@ -1,4 +1,5 @@ use agent_client_protocol as acp; +use collections::HashSet; use fs::Fs; use settings::{SettingsStore, update_settings_file}; use std::path::Path; @@ -72,6 +73,48 @@ impl AgentServer for ClaudeCode { }); } + fn favorite_model_ids(&self, cx: &mut App) -> HashSet { + let settings = cx.read_global(|settings: &SettingsStore, _| { + settings.get::(None).claude.clone() + }); + + settings + .as_ref() + .map(|s| { + s.favorite_models + .iter() + .map(|id| acp::ModelId::new(id.clone())) + .collect() + }) + .unwrap_or_default() + } + + fn toggle_favorite_model( + &self, + model_id: acp::ModelId, + should_be_favorite: bool, + fs: Arc, + cx: &App, + ) { + update_settings_file(fs, cx, move |settings, _| { + let favorite_models = &mut settings + .agent_servers + .get_or_insert_default() + .claude + .get_or_insert_default() + .favorite_models; + + let model_id_str = model_id.to_string(); + if should_be_favorite { + if !favorite_models.contains(&model_id_str) { + favorite_models.push(model_id_str); + } + } else { + favorite_models.retain(|id| id != &model_id_str); + } + }); + } + fn connect( &self, root_dir: Option<&Path>, diff --git a/crates/agent_servers/src/codex.rs b/crates/agent_servers/src/codex.rs index c2b308e48b7a984b0374272c0059286e933916b3..15dc4688294da979149f331ea52e8163ae5d3093 100644 --- a/crates/agent_servers/src/codex.rs +++ b/crates/agent_servers/src/codex.rs @@ -5,6 +5,7 @@ use std::{any::Any, path::Path}; use acp_thread::AgentConnection; use agent_client_protocol as acp; use anyhow::{Context as _, Result}; +use collections::HashSet; use fs::Fs; use gpui::{App, AppContext as _, SharedString, Task}; use project::agent_server_store::{AllAgentServersSettings, CODEX_NAME}; @@ -73,6 +74,48 @@ impl AgentServer for Codex { }); } + fn favorite_model_ids(&self, cx: &mut App) -> HashSet { + let settings = cx.read_global(|settings: &SettingsStore, _| { + settings.get::(None).codex.clone() + }); + + settings + .as_ref() + .map(|s| { + s.favorite_models + .iter() + .map(|id| acp::ModelId::new(id.clone())) + .collect() + }) + .unwrap_or_default() + } + + fn toggle_favorite_model( + &self, + model_id: acp::ModelId, + should_be_favorite: bool, + fs: Arc, + cx: &App, + ) { + update_settings_file(fs, cx, move |settings, _| { + let favorite_models = &mut settings + .agent_servers + .get_or_insert_default() + .codex + .get_or_insert_default() + .favorite_models; + + let model_id_str = model_id.to_string(); + if should_be_favorite { + if !favorite_models.contains(&model_id_str) { + favorite_models.push(model_id_str); + } + } else { + favorite_models.retain(|id| id != &model_id_str); + } + }); + } + fn connect( &self, root_dir: Option<&Path>, diff --git a/crates/agent_servers/src/custom.rs b/crates/agent_servers/src/custom.rs index 6b981ce8b8198b275e5d9aa05b6fb66431d22e08..f58948190266adeb0e5509d2ec2825a48d503f50 100644 --- a/crates/agent_servers/src/custom.rs +++ b/crates/agent_servers/src/custom.rs @@ -2,6 +2,7 @@ use crate::{AgentServer, AgentServerDelegate, load_proxy_env}; use acp_thread::AgentConnection; use agent_client_protocol as acp; use anyhow::{Context as _, Result}; +use collections::HashSet; use fs::Fs; use gpui::{App, AppContext as _, SharedString, Task}; use project::agent_server_store::{AllAgentServersSettings, ExternalAgentServerName}; @@ -54,6 +55,7 @@ impl AgentServer for CustomAgentServer { .or_insert_with(|| settings::CustomAgentServerSettings::Extension { default_model: None, default_mode: None, + favorite_models: Vec::new(), }); match settings { @@ -90,6 +92,7 @@ impl AgentServer for CustomAgentServer { .or_insert_with(|| settings::CustomAgentServerSettings::Extension { default_model: None, default_mode: None, + favorite_models: Vec::new(), }); match settings { @@ -101,6 +104,66 @@ impl AgentServer for CustomAgentServer { }); } + fn favorite_model_ids(&self, cx: &mut App) -> HashSet { + let settings = cx.read_global(|settings: &SettingsStore, _| { + settings + .get::(None) + .custom + .get(&self.name()) + .cloned() + }); + + settings + .as_ref() + .map(|s| { + s.favorite_models() + .iter() + .map(|id| acp::ModelId::new(id.clone())) + .collect() + }) + .unwrap_or_default() + } + + fn toggle_favorite_model( + &self, + model_id: acp::ModelId, + should_be_favorite: bool, + fs: Arc, + cx: &App, + ) { + let name = self.name(); + update_settings_file(fs, cx, move |settings, _| { + let settings = settings + .agent_servers + .get_or_insert_default() + .custom + .entry(name.clone()) + .or_insert_with(|| settings::CustomAgentServerSettings::Extension { + default_model: None, + default_mode: None, + favorite_models: Vec::new(), + }); + + let favorite_models = match settings { + settings::CustomAgentServerSettings::Custom { + favorite_models, .. + } + | settings::CustomAgentServerSettings::Extension { + favorite_models, .. + } => favorite_models, + }; + + let model_id_str = model_id.to_string(); + if should_be_favorite { + if !favorite_models.contains(&model_id_str) { + favorite_models.push(model_id_str); + } + } else { + favorite_models.retain(|id| id != &model_id_str); + } + }); + } + fn connect( &self, root_dir: Option<&Path>, diff --git a/crates/agent_servers/src/e2e_tests.rs b/crates/agent_servers/src/e2e_tests.rs index 9db7535b5e55d88d6856774c20365bbac46fc81e..975bb7e373c5ddd13df6c6bc951096fced668355 100644 --- a/crates/agent_servers/src/e2e_tests.rs +++ b/crates/agent_servers/src/e2e_tests.rs @@ -460,6 +460,7 @@ pub async fn init_test(cx: &mut TestAppContext) -> Arc { ignore_system_version: None, default_mode: None, default_model: None, + favorite_models: vec![], }), gemini: Some(crate::gemini::tests::local_command().into()), codex: Some(BuiltinAgentServerSettings { @@ -469,6 +470,7 @@ pub async fn init_test(cx: &mut TestAppContext) -> Arc { ignore_system_version: None, default_mode: None, default_model: None, + favorite_models: vec![], }), custom: collections::HashMap::default(), }, diff --git a/crates/agent_ui/src/acp/model_selector.rs b/crates/agent_ui/src/acp/model_selector.rs index 903d5fe425d99389aae0e2a8028d9a31b986fbb3..c8ed636e4fead9f10e4763904e17d36a5eb6bbb6 100644 --- a/crates/agent_ui/src/acp/model_selector.rs +++ b/crates/agent_ui/src/acp/model_selector.rs @@ -3,19 +3,19 @@ use std::{cmp::Reverse, rc::Rc, sync::Arc}; use acp_thread::{AgentModelIcon, AgentModelInfo, AgentModelList, AgentModelSelector}; use agent_client_protocol::ModelId; use agent_servers::AgentServer; -use agent_settings::AgentSettings; use anyhow::Result; use collections::{HashSet, IndexMap}; use fs::Fs; use futures::FutureExt; use fuzzy::{StringMatchCandidate, match_strings}; use gpui::{ - Action, AsyncWindowContext, BackgroundExecutor, DismissEvent, FocusHandle, Task, WeakEntity, + Action, AsyncWindowContext, BackgroundExecutor, DismissEvent, FocusHandle, Subscription, Task, + WeakEntity, }; use itertools::Itertools; use ordered_float::OrderedFloat; use picker::{Picker, PickerDelegate}; -use settings::Settings; +use settings::SettingsStore; use ui::{DocumentationAside, DocumentationEdge, DocumentationSide, IntoElement, prelude::*}; use util::ResultExt; use zed_actions::agent::OpenSettings; @@ -54,7 +54,9 @@ pub struct AcpModelPickerDelegate { selected_index: usize, selected_description: Option<(usize, SharedString, bool)>, selected_model: Option, + favorites: HashSet, _refresh_models_task: Task<()>, + _settings_subscription: Subscription, focus_handle: FocusHandle, } @@ -102,6 +104,19 @@ impl AcpModelPickerDelegate { }) }; + let agent_server_for_subscription = agent_server.clone(); + let settings_subscription = + cx.observe_global_in::(window, move |picker, window, cx| { + // Only refresh if the favorites actually changed to avoid redundant work + // when other settings are modified (e.g., user editing settings.json) + let new_favorites = agent_server_for_subscription.favorite_model_ids(cx); + if new_favorites != picker.delegate.favorites { + picker.delegate.favorites = new_favorites; + picker.refresh(window, cx); + } + }); + let favorites = agent_server.favorite_model_ids(cx); + Self { selector, agent_server, @@ -111,7 +126,9 @@ impl AcpModelPickerDelegate { selected_model: None, selected_index: 0, selected_description: None, + favorites, _refresh_models_task: refresh_models_task, + _settings_subscription: settings_subscription, focus_handle, } } @@ -120,40 +137,37 @@ impl AcpModelPickerDelegate { self.selected_model.as_ref() } - pub fn cycle_favorite_models(&mut self, window: &mut Window, cx: &mut Context>) { - if !self.selector.supports_favorites() { - return; - } - - let favorites = AgentSettings::get_global(cx).favorite_model_ids(); + pub fn favorites_count(&self) -> usize { + self.favorites.len() + } - if favorites.is_empty() { + pub fn cycle_favorite_models(&mut self, window: &mut Window, cx: &mut Context>) { + if self.favorites.is_empty() { return; } - let Some(models) = self.models.clone() else { + let Some(models) = &self.models else { return; }; - let all_models: Vec = match models { - AgentModelList::Flat(list) => list, - AgentModelList::Grouped(index_map) => index_map - .into_values() - .flatten() - .collect::>(), + let all_models: Vec<&AgentModelInfo> = match models { + AgentModelList::Flat(list) => list.iter().collect(), + AgentModelList::Grouped(index_map) => index_map.values().flatten().collect(), }; - let favorite_models = all_models - .iter() - .filter(|model| favorites.contains(&model.id)) + let favorite_models: Vec<_> = all_models + .into_iter() + .filter(|model| self.favorites.contains(&model.id)) .unique_by(|model| &model.id) - .cloned() - .collect::>(); + .collect(); + + if favorite_models.is_empty() { + return; + } - let current_id = self.selected_model.as_ref().map(|m| m.id.clone()); + let current_id = self.selected_model.as_ref().map(|m| &m.id); let current_index_in_favorites = current_id - .as_ref() .and_then(|id| favorite_models.iter().position(|m| &m.id == id)) .unwrap_or(usize::MAX); @@ -220,11 +234,7 @@ impl PickerDelegate for AcpModelPickerDelegate { window: &mut Window, cx: &mut Context>, ) -> Task<()> { - let favorites = if self.selector.supports_favorites() { - AgentSettings::get_global(cx).favorite_model_ids() - } else { - Default::default() - }; + let favorites = self.favorites.clone(); cx.spawn_in(window, async move |this, cx| { let filtered_models = match this @@ -317,21 +327,20 @@ impl PickerDelegate for AcpModelPickerDelegate { let default_model = self.agent_server.default_model(cx); let is_default = default_model.as_ref() == Some(&model_info.id); - let supports_favorites = self.selector.supports_favorites(); - let is_favorite = *is_favorite; let handle_action_click = { let model_id = model_info.id.clone(); let fs = self.fs.clone(); + let agent_server = self.agent_server.clone(); - move |cx: &App| { - crate::favorite_models::toggle_model_id_in_settings( + cx.listener(move |_, _, _, cx| { + agent_server.toggle_favorite_model( model_id.clone(), !is_favorite, fs.clone(), cx, ); - } + }) }; Some( @@ -357,10 +366,8 @@ impl PickerDelegate for AcpModelPickerDelegate { }) .is_selected(is_selected) .is_focused(selected) - .when(supports_favorites, |this| { - this.is_favorite(is_favorite) - .on_toggle_favorite(handle_action_click) - }), + .is_favorite(is_favorite) + .on_toggle_favorite(handle_action_click), ) .into_any_element(), ) @@ -603,6 +610,46 @@ mod tests { .collect() } + #[gpui::test] + async fn test_fuzzy_match(cx: &mut TestAppContext) { + let models = create_model_list(vec![ + ( + "zed", + vec![ + "Claude 3.7 Sonnet", + "Claude 3.7 Sonnet Thinking", + "gpt-4.1", + "gpt-4.1-nano", + ], + ), + ("openai", vec!["gpt-3.5-turbo", "gpt-4.1", "gpt-4.1-nano"]), + ("ollama", vec!["mistral", "deepseek"]), + ]); + + // Results should preserve models order whenever possible. + // In the case below, `zed/gpt-4.1` and `openai/gpt-4.1` have identical + // similarity scores, but `zed/gpt-4.1` was higher in the models list, + // so it should appear first in the results. + let results = fuzzy_search(models.clone(), "41".into(), cx.executor()).await; + assert_models_eq( + results, + vec![ + ("zed", vec!["gpt-4.1", "gpt-4.1-nano"]), + ("openai", vec!["gpt-4.1", "gpt-4.1-nano"]), + ], + ); + + // Fuzzy search + let results = fuzzy_search(models.clone(), "4n".into(), cx.executor()).await; + assert_models_eq( + results, + vec![ + ("zed", vec!["gpt-4.1-nano"]), + ("openai", vec!["gpt-4.1-nano"]), + ], + ); + } + #[gpui::test] fn test_favorites_section_appears_when_favorites_exist(_cx: &mut TestAppContext) { let models = create_model_list(vec![ @@ -739,42 +786,48 @@ mod tests { } #[gpui::test] - async fn test_fuzzy_match(cx: &mut TestAppContext) { - let models = create_model_list(vec![ - ( - "zed", - vec![ - "Claude 3.7 Sonnet", - "Claude 3.7 Sonnet Thinking", - "gpt-4.1", - "gpt-4.1-nano", - ], - ), - ("openai", vec!["gpt-3.5-turbo", "gpt-4.1", "gpt-4.1-nano"]), - ("ollama", vec!["mistral", "deepseek"]), + fn test_favorites_count_returns_correct_count(_cx: &mut TestAppContext) { + let empty_favorites: HashSet = HashSet::default(); + assert_eq!(empty_favorites.len(), 0); + + let one_favorite = create_favorites(vec!["model-a"]); + assert_eq!(one_favorite.len(), 1); + + let multiple_favorites = create_favorites(vec!["model-a", "model-b", "model-c"]); + assert_eq!(multiple_favorites.len(), 3); + + let with_duplicates = create_favorites(vec!["model-a", "model-a", "model-b"]); + assert_eq!(with_duplicates.len(), 2); + } + + #[gpui::test] + fn test_is_favorite_flag_set_correctly_in_entries(_cx: &mut TestAppContext) { + let models = AgentModelList::Flat(vec![ + acp_thread::AgentModelInfo { + id: acp::ModelId::new("favorite-model".to_string()), + name: "Favorite".into(), + description: None, + icon: None, + }, + acp_thread::AgentModelInfo { + id: acp::ModelId::new("regular-model".to_string()), + name: "Regular".into(), + description: None, + icon: None, + }, ]); + let favorites = create_favorites(vec!["favorite-model"]); - // Results should preserve models order whenever possible. - // In the case below, `zed/gpt-4.1` and `openai/gpt-4.1` have identical - // similarity scores, but `zed/gpt-4.1` was higher in the models list, - // so it should appear first in the results. - let results = fuzzy_search(models.clone(), "41".into(), cx.executor()).await; - assert_models_eq( - results, - vec![ - ("zed", vec!["gpt-4.1", "gpt-4.1-nano"]), - ("openai", vec!["gpt-4.1", "gpt-4.1-nano"]), - ], - ); + let entries = info_list_to_picker_entries(models, &favorites); - // Fuzzy search - let results = fuzzy_search(models.clone(), "4n".into(), cx.executor()).await; - assert_models_eq( - results, - vec![ - ("zed", vec!["gpt-4.1-nano"]), - ("openai", vec!["gpt-4.1-nano"]), - ], - ); + for entry in &entries { + if let AcpModelPickerEntry::Model(info, is_favorite) = entry { + if info.id.0.as_ref() == "favorite-model" { + assert!(*is_favorite, "favorite-model should have is_favorite=true"); + } else if info.id.0.as_ref() == "regular-model" { + assert!(!*is_favorite, "regular-model should have is_favorite=false"); + } + } + } } } diff --git a/crates/agent_ui/src/acp/model_selector_popover.rs b/crates/agent_ui/src/acp/model_selector_popover.rs index a15c01445dd8e9845f6744e795ed90a1ede6c7fc..34b77704cc87c963fff16ca9f90959dbe0f6d35f 100644 --- a/crates/agent_ui/src/acp/model_selector_popover.rs +++ b/crates/agent_ui/src/acp/model_selector_popover.rs @@ -2,17 +2,13 @@ use std::rc::Rc; use std::sync::Arc; use acp_thread::{AgentModelIcon, AgentModelInfo, AgentModelSelector}; -use agent_servers::AgentServer; -use agent_settings::AgentSettings; use fs::Fs; use gpui::{Entity, FocusHandle}; use picker::popover_menu::PickerPopoverMenu; -use settings::Settings as _; -use ui::{ButtonLike, KeyBinding, PopoverMenuHandle, TintColor, Tooltip, prelude::*}; -use zed_actions::agent::ToggleModelSelector; +use ui::{ButtonLike, PopoverMenuHandle, TintColor, Tooltip, prelude::*}; -use crate::CycleFavoriteModels; use crate::acp::{AcpModelSelector, model_selector::acp_model_selector}; +use crate::ui::ModelSelectorTooltip; pub struct AcpModelSelectorPopover { selector: Entity, @@ -23,7 +19,7 @@ pub struct AcpModelSelectorPopover { impl AcpModelSelectorPopover { pub(crate) fn new( selector: Rc, - agent_server: Rc, + agent_server: Rc, fs: Arc, menu_handle: PopoverMenuHandle, focus_handle: FocusHandle, @@ -64,7 +60,8 @@ impl AcpModelSelectorPopover { impl Render for AcpModelSelectorPopover { fn render(&mut self, window: &mut Window, cx: &mut Context) -> impl IntoElement { - let model = self.selector.read(cx).delegate.active_model(); + let selector = self.selector.read(cx); + let model = selector.delegate.active_model(); let model_name = model .as_ref() .map(|model| model.name.clone()) @@ -80,43 +77,13 @@ impl Render for AcpModelSelectorPopover { (Color::Muted, IconName::ChevronDown) }; - let tooltip = Tooltip::element({ - move |_, cx| { - let focus_handle = focus_handle.clone(); - let should_show_cycle_row = !AgentSettings::get_global(cx) - .favorite_model_ids() - .is_empty(); + let show_cycle_row = selector.delegate.favorites_count() > 1; - v_flex() - .gap_1() - .child( - h_flex() - .gap_2() - .justify_between() - .child(Label::new("Change Model")) - .child(KeyBinding::for_action_in( - &ToggleModelSelector, - &focus_handle, - cx, - )), - ) - .when(should_show_cycle_row, |this| { - this.child( - h_flex() - .pt_1() - .gap_2() - .border_t_1() - .border_color(cx.theme().colors().border_variant) - .justify_between() - .child(Label::new("Cycle Favorited Models")) - .child(KeyBinding::for_action_in( - &CycleFavoriteModels, - &focus_handle, - cx, - )), - ) - }) - .into_any() + let tooltip = Tooltip::element({ + move |_, _cx| { + ModelSelectorTooltip::new(focus_handle.clone()) + .show_cycle_row(show_cycle_row) + .into_any_element() } }); diff --git a/crates/agent_ui/src/acp/thread_view.rs b/crates/agent_ui/src/acp/thread_view.rs index 72d5536ce28641d6a7b830346542beece52bf6e0..709217fe9f8e532aafa8ac8426473c6c5dacb93d 100644 --- a/crates/agent_ui/src/acp/thread_view.rs +++ b/crates/agent_ui/src/acp/thread_view.rs @@ -4288,37 +4288,6 @@ impl AcpThreadView { v_flex() .on_action(cx.listener(Self::expand_message_editor)) - .on_action(cx.listener(|this, _: &ToggleProfileSelector, window, cx| { - if let Some(profile_selector) = this.profile_selector.as_ref() { - profile_selector.read(cx).menu_handle().toggle(window, cx); - } else if let Some(mode_selector) = this.mode_selector() { - mode_selector.read(cx).menu_handle().toggle(window, cx); - } - })) - .on_action(cx.listener(|this, _: &CycleModeSelector, window, cx| { - if let Some(profile_selector) = this.profile_selector.as_ref() { - profile_selector.update(cx, |profile_selector, cx| { - profile_selector.cycle_profile(cx); - }); - } else if let Some(mode_selector) = this.mode_selector() { - mode_selector.update(cx, |mode_selector, cx| { - mode_selector.cycle_mode(window, cx); - }); - } - })) - .on_action(cx.listener(|this, _: &ToggleModelSelector, window, cx| { - if let Some(model_selector) = this.model_selector.as_ref() { - model_selector - .update(cx, |model_selector, cx| model_selector.toggle(window, cx)); - } - })) - .on_action(cx.listener(|this, _: &CycleFavoriteModels, window, cx| { - if let Some(model_selector) = this.model_selector.as_ref() { - model_selector.update(cx, |model_selector, cx| { - model_selector.cycle_favorite_models(window, cx); - }); - } - })) .p_2() .gap_2() .border_t_1() @@ -6005,6 +5974,37 @@ impl Render for AcpThreadView { .on_action(cx.listener(Self::allow_always)) .on_action(cx.listener(Self::allow_once)) .on_action(cx.listener(Self::reject_once)) + .on_action(cx.listener(|this, _: &ToggleProfileSelector, window, cx| { + if let Some(profile_selector) = this.profile_selector.as_ref() { + profile_selector.read(cx).menu_handle().toggle(window, cx); + } else if let Some(mode_selector) = this.mode_selector() { + mode_selector.read(cx).menu_handle().toggle(window, cx); + } + })) + .on_action(cx.listener(|this, _: &CycleModeSelector, window, cx| { + if let Some(profile_selector) = this.profile_selector.as_ref() { + profile_selector.update(cx, |profile_selector, cx| { + profile_selector.cycle_profile(cx); + }); + } else if let Some(mode_selector) = this.mode_selector() { + mode_selector.update(cx, |mode_selector, cx| { + mode_selector.cycle_mode(window, cx); + }); + } + })) + .on_action(cx.listener(|this, _: &ToggleModelSelector, window, cx| { + if let Some(model_selector) = this.model_selector.as_ref() { + model_selector + .update(cx, |model_selector, cx| model_selector.toggle(window, cx)); + } + })) + .on_action(cx.listener(|this, _: &CycleFavoriteModels, window, cx| { + if let Some(model_selector) = this.model_selector.as_ref() { + model_selector.update(cx, |model_selector, cx| { + model_selector.cycle_favorite_models(window, cx); + }); + } + })) .track_focus(&self.focus_handle) .bg(cx.theme().colors().panel_background) .child(match &self.thread_state { diff --git a/crates/agent_ui/src/agent_configuration.rs b/crates/agent_ui/src/agent_configuration.rs index 562976453d963db65f9033536e528000de2b510f..fb2d50863c002cba0c7b0d63c2a5a4cc73224b4d 100644 --- a/crates/agent_ui/src/agent_configuration.rs +++ b/crates/agent_ui/src/agent_configuration.rs @@ -1370,6 +1370,7 @@ async fn open_new_agent_servers_entry_in_settings_editor( env: Some(HashMap::default()), default_mode: None, default_model: None, + favorite_models: vec![], }, ); } diff --git a/crates/agent_ui/src/agent_model_selector.rs b/crates/agent_ui/src/agent_model_selector.rs index 45cefbf2b9f8d4b1639a9849f2ee2e4468e530b1..caeba3d26d892aefbb879f6a4e0c9dad603e478f 100644 --- a/crates/agent_ui/src/agent_model_selector.rs +++ b/crates/agent_ui/src/agent_model_selector.rs @@ -1,6 +1,7 @@ use crate::{ ModelUsageContext, language_model_selector::{LanguageModelSelector, language_model_selector}, + ui::ModelSelectorTooltip, }; use fs::Fs; use gpui::{Entity, FocusHandle, SharedString}; @@ -9,7 +10,6 @@ use picker::popover_menu::PickerPopoverMenu; use settings::update_settings_file; use std::sync::Arc; use ui::{ButtonLike, PopoverMenuHandle, TintColor, Tooltip, prelude::*}; -use zed_actions::agent::ToggleModelSelector; pub struct AgentModelSelector { selector: Entity, @@ -81,6 +81,12 @@ impl AgentModelSelector { pub fn active_model(&self, cx: &App) -> Option { self.selector.read(cx).delegate.active_model(cx) } + + pub fn cycle_favorite_models(&self, window: &mut Window, cx: &mut Context) { + self.selector.update(cx, |selector, cx| { + selector.delegate.cycle_favorite_models(window, cx); + }); + } } impl Render for AgentModelSelector { @@ -98,8 +104,18 @@ impl Render for AgentModelSelector { Color::Muted }; + let show_cycle_row = self.selector.read(cx).delegate.favorites_count() > 1; + let focus_handle = self.focus_handle.clone(); + let tooltip = Tooltip::element({ + move |_, _cx| { + ModelSelectorTooltip::new(focus_handle.clone()) + .show_cycle_row(show_cycle_row) + .into_any_element() + } + }); + PickerPopoverMenu::new( self.selector.clone(), ButtonLike::new("active-model") @@ -125,9 +141,7 @@ impl Render for AgentModelSelector { .color(color) .size(IconSize::XSmall), ), - move |_window, cx| { - Tooltip::for_action_in("Change Model", &ToggleModelSelector, &focus_handle, cx) - }, + tooltip, gpui::Corner::TopRight, cx, ) diff --git a/crates/agent_ui/src/favorite_models.rs b/crates/agent_ui/src/favorite_models.rs index d8d4db976fc9916973eedd9174925fba75a06b2b..d11bf5dda00d29f6668559348dc1f4abd937571f 100644 --- a/crates/agent_ui/src/favorite_models.rs +++ b/crates/agent_ui/src/favorite_models.rs @@ -1,6 +1,5 @@ use std::sync::Arc; -use agent_client_protocol::ModelId; use fs::Fs; use language_model::LanguageModel; use settings::{LanguageModelSelection, update_settings_file}; @@ -13,20 +12,11 @@ fn language_model_to_selection(model: &Arc) -> LanguageModelS } } -fn model_id_to_selection(model_id: &ModelId) -> LanguageModelSelection { - let id = model_id.0.as_ref(); - let (provider, model) = id.split_once('/').unwrap_or(("", id)); - LanguageModelSelection { - provider: provider.to_owned().into(), - model: model.to_owned(), - } -} - pub fn toggle_in_settings( model: Arc, should_be_favorite: bool, fs: Arc, - cx: &App, + cx: &mut App, ) { let selection = language_model_to_selection(&model); update_settings_file(fs, cx, move |settings, _| { @@ -38,20 +28,3 @@ pub fn toggle_in_settings( } }); } - -pub fn toggle_model_id_in_settings( - model_id: ModelId, - should_be_favorite: bool, - fs: Arc, - cx: &App, -) { - let selection = model_id_to_selection(&model_id); - update_settings_file(fs, cx, move |settings, _| { - let agent = settings.agent.get_or_insert_default(); - if should_be_favorite { - agent.add_favorite_model(selection.clone()); - } else { - agent.remove_favorite_model(&selection); - } - }); -} diff --git a/crates/agent_ui/src/inline_prompt_editor.rs b/crates/agent_ui/src/inline_prompt_editor.rs index 8d96d56ea67cc9366df420b23e2221636d3450fb..3542959dbf146d39d40a5851b6fa9ce00a5014cd 100644 --- a/crates/agent_ui/src/inline_prompt_editor.rs +++ b/crates/agent_ui/src/inline_prompt_editor.rs @@ -40,7 +40,9 @@ use crate::completion_provider::{ use crate::mention_set::paste_images_as_context; use crate::mention_set::{MentionSet, crease_for_mention}; use crate::terminal_codegen::TerminalCodegen; -use crate::{CycleNextInlineAssist, CyclePreviousInlineAssist, ModelUsageContext}; +use crate::{ + CycleFavoriteModels, CycleNextInlineAssist, CyclePreviousInlineAssist, ModelUsageContext, +}; actions!(inline_assistant, [ThumbsUpResult, ThumbsDownResult]); @@ -148,7 +150,7 @@ impl Render for PromptEditor { .into_any_element(); v_flex() - .key_context("PromptEditor") + .key_context("InlineAssistant") .capture_action(cx.listener(Self::paste)) .block_mouse_except_scroll() .size_full() @@ -162,10 +164,6 @@ impl Render for PromptEditor { .bg(cx.theme().colors().editor_background) .child( h_flex() - .on_action(cx.listener(|this, _: &ToggleModelSelector, window, cx| { - this.model_selector - .update(cx, |model_selector, cx| model_selector.toggle(window, cx)); - })) .on_action(cx.listener(Self::confirm)) .on_action(cx.listener(Self::cancel)) .on_action(cx.listener(Self::move_up)) @@ -174,6 +172,15 @@ impl Render for PromptEditor { .on_action(cx.listener(Self::thumbs_down)) .capture_action(cx.listener(Self::cycle_prev)) .capture_action(cx.listener(Self::cycle_next)) + .on_action(cx.listener(|this, _: &ToggleModelSelector, window, cx| { + this.model_selector + .update(cx, |model_selector, cx| model_selector.toggle(window, cx)); + })) + .on_action(cx.listener(|this, _: &CycleFavoriteModels, window, cx| { + this.model_selector.update(cx, |model_selector, cx| { + model_selector.cycle_favorite_models(window, cx); + }); + })) .child( WithRemSize::new(ui_font_size) .h_full() @@ -855,7 +862,7 @@ impl PromptEditor { .map(|this| { if rated { this.disabled(true) - .icon_color(Color::Ignored) + .icon_color(Color::Disabled) .tooltip(move |_, cx| { Tooltip::with_meta( "Good Result", @@ -865,8 +872,15 @@ impl PromptEditor { ) }) } else { - this.icon_color(Color::Muted) - .tooltip(Tooltip::text("Good Result")) + this.icon_color(Color::Muted).tooltip( + move |_, cx| { + Tooltip::for_action( + "Good Result", + &ThumbsUpResult, + cx, + ) + }, + ) } }) .on_click(cx.listener(|this, _, window, cx| { @@ -879,7 +893,7 @@ impl PromptEditor { .map(|this| { if rated { this.disabled(true) - .icon_color(Color::Ignored) + .icon_color(Color::Disabled) .tooltip(move |_, cx| { Tooltip::with_meta( "Bad Result", @@ -889,8 +903,15 @@ impl PromptEditor { ) }) } else { - this.icon_color(Color::Muted) - .tooltip(Tooltip::text("Bad Result")) + this.icon_color(Color::Muted).tooltip( + move |_, cx| { + Tooltip::for_action( + "Bad Result", + &ThumbsDownResult, + cx, + ) + }, + ) } }) .on_click(cx.listener(|this, _, window, cx| { @@ -1088,7 +1109,6 @@ impl PromptEditor { let colors = cx.theme().colors(); div() - .key_context("InlineAssistEditor") .size_full() .p_2() .pl_1() diff --git a/crates/agent_ui/src/language_model_selector.rs b/crates/agent_ui/src/language_model_selector.rs index 704e340ace35f33f757ab7708f96ffc940a8eb91..64b1397b02ca4a7fc9c20fdfc8abf10141712bbb 100644 --- a/crates/agent_ui/src/language_model_selector.rs +++ b/crates/agent_ui/src/language_model_selector.rs @@ -20,14 +20,14 @@ use crate::ui::{ModelSelectorFooter, ModelSelectorHeader, ModelSelectorListItem} type OnModelChanged = Arc, &mut App) + 'static>; type GetActiveModel = Arc Option + 'static>; -type OnToggleFavorite = Arc, bool, &App) + 'static>; +type OnToggleFavorite = Arc, bool, &mut App) + 'static>; pub type LanguageModelSelector = Picker; pub fn language_model_selector( get_active_model: impl Fn(&App) -> Option + 'static, on_model_changed: impl Fn(Arc, &mut App) + 'static, - on_toggle_favorite: impl Fn(Arc, bool, &App) + 'static, + on_toggle_favorite: impl Fn(Arc, bool, &mut App) + 'static, popover_styles: bool, focus_handle: FocusHandle, window: &mut Window, @@ -133,7 +133,7 @@ impl LanguageModelPickerDelegate { fn new( get_active_model: impl Fn(&App) -> Option + 'static, on_model_changed: impl Fn(Arc, &mut App) + 'static, - on_toggle_favorite: impl Fn(Arc, bool, &App) + 'static, + on_toggle_favorite: impl Fn(Arc, bool, &mut App) + 'static, popover_styles: bool, focus_handle: FocusHandle, window: &mut Window, @@ -250,6 +250,10 @@ impl LanguageModelPickerDelegate { (self.get_active_model)(cx) } + pub fn favorites_count(&self) -> usize { + self.all_models.favorites.len() + } + pub fn cycle_favorite_models(&mut self, window: &mut Window, cx: &mut Context>) { if self.all_models.favorites.is_empty() { return; @@ -561,7 +565,10 @@ impl PickerDelegate for LanguageModelPickerDelegate { let handle_action_click = { let model = model_info.model.clone(); let on_toggle_favorite = self.on_toggle_favorite.clone(); - move |cx: &App| on_toggle_favorite(model.clone(), !is_favorite, cx) + cx.listener(move |picker, _, window, cx| { + on_toggle_favorite(model.clone(), !is_favorite, cx); + picker.refresh(window, cx); + }) }; Some( diff --git a/crates/agent_ui/src/text_thread_editor.rs b/crates/agent_ui/src/text_thread_editor.rs index 514f45528427af89eeccf85512abf850a7a1be05..3a790dd354afb9ae21cc49687da08256f167b19d 100644 --- a/crates/agent_ui/src/text_thread_editor.rs +++ b/crates/agent_ui/src/text_thread_editor.rs @@ -1,8 +1,8 @@ use crate::{ language_model_selector::{LanguageModelSelector, language_model_selector}, - ui::BurnModeTooltip, + ui::{BurnModeTooltip, ModelSelectorTooltip}, }; -use agent_settings::{AgentSettings, CompletionMode}; +use agent_settings::CompletionMode; use anyhow::Result; use assistant_slash_command::{SlashCommand, SlashCommandOutputSection, SlashCommandWorkingSet}; use assistant_slash_commands::{DefaultSlashCommand, FileSlashCommand, selections_creases}; @@ -2252,43 +2252,18 @@ impl TextThreadEditor { .color(color) .size(IconSize::XSmall); + let show_cycle_row = self + .language_model_selector + .read(cx) + .delegate + .favorites_count() + > 1; + let tooltip = Tooltip::element({ - move |_, cx| { - let focus_handle = focus_handle.clone(); - let should_show_cycle_row = !AgentSettings::get_global(cx) - .favorite_model_ids() - .is_empty(); - - v_flex() - .gap_1() - .child( - h_flex() - .gap_2() - .justify_between() - .child(Label::new("Change Model")) - .child(KeyBinding::for_action_in( - &ToggleModelSelector, - &focus_handle, - cx, - )), - ) - .when(should_show_cycle_row, |this| { - this.child( - h_flex() - .pt_1() - .gap_2() - .border_t_1() - .border_color(cx.theme().colors().border_variant) - .justify_between() - .child(Label::new("Cycle Favorited Models")) - .child(KeyBinding::for_action_in( - &CycleFavoriteModels, - &focus_handle, - cx, - )), - ) - }) - .into_any() + move |_, _cx| { + ModelSelectorTooltip::new(focus_handle.clone()) + .show_cycle_row(show_cycle_row) + .into_any_element() } }); diff --git a/crates/agent_ui/src/ui/model_selector_components.rs b/crates/agent_ui/src/ui/model_selector_components.rs index beb0c13d761aa9e7e41c2ac4e35a8cfcc7e8d869..de4036b8dec27b735e13a3b4f0de80cfa11111df 100644 --- a/crates/agent_ui/src/ui/model_selector_components.rs +++ b/crates/agent_ui/src/ui/model_selector_components.rs @@ -1,5 +1,8 @@ -use gpui::{Action, FocusHandle, prelude::*}; +use gpui::{Action, ClickEvent, FocusHandle, prelude::*}; use ui::{ElevationIndex, KeyBinding, ListItem, ListItemSpacing, Tooltip, prelude::*}; +use zed_actions::agent::ToggleModelSelector; + +use crate::CycleFavoriteModels; enum ModelIcon { Name(IconName), @@ -48,7 +51,7 @@ pub struct ModelSelectorListItem { is_selected: bool, is_focused: bool, is_favorite: bool, - on_toggle_favorite: Option>, + on_toggle_favorite: Option>, } impl ModelSelectorListItem { @@ -89,7 +92,10 @@ impl ModelSelectorListItem { self } - pub fn on_toggle_favorite(mut self, handler: impl Fn(&App) + 'static) -> Self { + pub fn on_toggle_favorite( + mut self, + handler: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static, + ) -> Self { self.on_toggle_favorite = Some(Box::new(handler)); self } @@ -141,7 +147,7 @@ impl RenderOnce for ModelSelectorListItem { .icon_color(color) .icon_size(IconSize::Small) .tooltip(Tooltip::text(tooltip)) - .on_click(move |_, _, cx| (handle_click)(cx)), + .on_click(move |event, window, cx| (handle_click)(event, window, cx)), ) } })) @@ -187,3 +193,57 @@ impl RenderOnce for ModelSelectorFooter { ) } } + +#[derive(IntoElement)] +pub struct ModelSelectorTooltip { + focus_handle: FocusHandle, + show_cycle_row: bool, +} + +impl ModelSelectorTooltip { + pub fn new(focus_handle: FocusHandle) -> Self { + Self { + focus_handle, + show_cycle_row: true, + } + } + + pub fn show_cycle_row(mut self, show: bool) -> Self { + self.show_cycle_row = show; + self + } +} + +impl RenderOnce for ModelSelectorTooltip { + fn render(self, _window: &mut Window, cx: &mut App) -> impl IntoElement { + v_flex() + .gap_1() + .child( + h_flex() + .gap_2() + .justify_between() + .child(Label::new("Change Model")) + .child(KeyBinding::for_action_in( + &ToggleModelSelector, + &self.focus_handle, + cx, + )), + ) + .when(self.show_cycle_row, |this| { + this.child( + h_flex() + .pt_1() + .gap_2() + .border_t_1() + .border_color(cx.theme().colors().border_variant) + .justify_between() + .child(Label::new("Cycle Favorited Models")) + .child(KeyBinding::for_action_in( + &CycleFavoriteModels, + &self.focus_handle, + cx, + )), + ) + }) + } +} diff --git a/crates/project/src/agent_server_store.rs b/crates/project/src/agent_server_store.rs index 1443e4d877d4e288fb379a02fee8a351075d8db8..8829befaac7f21a1262ce0bf1410bce71546a3ed 100644 --- a/crates/project/src/agent_server_store.rs +++ b/crates/project/src/agent_server_store.rs @@ -1868,6 +1868,7 @@ pub struct BuiltinAgentServerSettings { pub ignore_system_version: Option, pub default_mode: Option, pub default_model: Option, + pub favorite_models: Vec, } impl BuiltinAgentServerSettings { @@ -1891,6 +1892,7 @@ impl From for BuiltinAgentServerSettings { ignore_system_version: value.ignore_system_version, default_mode: value.default_mode, default_model: value.default_model, + favorite_models: value.favorite_models, } } } @@ -1922,6 +1924,10 @@ pub enum CustomAgentServerSettings { /// /// Default: None default_model: Option, + /// The favorite models for this agent. + /// + /// Default: [] + favorite_models: Vec, }, Extension { /// The default mode to use for this agent. @@ -1936,6 +1942,10 @@ pub enum CustomAgentServerSettings { /// /// Default: None default_model: Option, + /// The favorite models for this agent. + /// + /// Default: [] + favorite_models: Vec, }, } @@ -1962,6 +1972,17 @@ impl CustomAgentServerSettings { } } } + + pub fn favorite_models(&self) -> &[String] { + match self { + CustomAgentServerSettings::Custom { + favorite_models, .. + } + | CustomAgentServerSettings::Extension { + favorite_models, .. + } => favorite_models, + } + } } impl From for CustomAgentServerSettings { @@ -1973,6 +1994,7 @@ impl From for CustomAgentServerSettings { env, default_mode, default_model, + favorite_models, } => CustomAgentServerSettings::Custom { command: AgentServerCommand { path: PathBuf::from(shellexpand::tilde(&path.to_string_lossy()).as_ref()), @@ -1981,13 +2003,16 @@ impl From for CustomAgentServerSettings { }, default_mode, default_model, + favorite_models, }, settings::CustomAgentServerSettings::Extension { default_mode, default_model, + favorite_models, } => CustomAgentServerSettings::Extension { default_mode, default_model, + favorite_models, }, } } @@ -2313,6 +2338,7 @@ mod extension_agent_tests { ignore_system_version: None, default_mode: None, default_model: None, + favorite_models: vec![], }; let BuiltinAgentServerSettings { path, .. } = settings.into(); @@ -2329,6 +2355,7 @@ mod extension_agent_tests { env: None, default_mode: None, default_model: None, + favorite_models: vec![], }; let converted: CustomAgentServerSettings = settings.into(); diff --git a/crates/settings/src/settings_content/agent.rs b/crates/settings/src/settings_content/agent.rs index d3a8e40084fc5db7fd348908b1b721617c7c8206..2abf00777af2308c4c2339bd180db47fb3d5e02f 100644 --- a/crates/settings/src/settings_content/agent.rs +++ b/crates/settings/src/settings_content/agent.rs @@ -363,6 +363,13 @@ pub struct BuiltinAgentServerSettings { /// /// Default: None pub default_model: Option, + /// The favorite models for this agent. + /// + /// These are the model IDs as reported by the agent. + /// + /// Default: [] + #[serde(default)] + pub favorite_models: Vec, } #[with_fallible_options] @@ -387,6 +394,13 @@ pub enum CustomAgentServerSettings { /// /// Default: None default_model: Option, + /// The favorite models for this agent. + /// + /// These are the model IDs as reported by the agent. + /// + /// Default: [] + #[serde(default)] + favorite_models: Vec, }, Extension { /// The default mode to use for this agent. @@ -401,5 +415,12 @@ pub enum CustomAgentServerSettings { /// /// Default: None default_model: Option, + /// The favorite models for this agent. + /// + /// These are the model IDs as reported by the agent. + /// + /// Default: [] + #[serde(default)] + favorite_models: Vec, }, } From dd521a96fb60bd01aa587e61449425324fd71aff Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Mon, 22 Dec 2025 20:40:27 +0200 Subject: [PATCH 606/621] Bump proto extension to 0.3.1 (#45531) Includes https://github.com/zed-industries/zed/pull/45413 Release Notes: - N/A --- Cargo.lock | 2 +- extensions/proto/Cargo.toml | 2 +- extensions/proto/extension.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e71461d72b0894c0049a90d2f65edbd68a477648..467ce89d1d4b07dfdad247d76dc1874c90a986f4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -20970,7 +20970,7 @@ dependencies = [ [[package]] name = "zed_proto" -version = "0.3.0" +version = "0.3.1" dependencies = [ "zed_extension_api 0.7.0", ] diff --git a/extensions/proto/Cargo.toml b/extensions/proto/Cargo.toml index c3606f668aa01d7a8baa20d54d073a7004a6f8c0..68a524ed944b0db1fd75b9ec5ca5e0b1aa99e89f 100644 --- a/extensions/proto/Cargo.toml +++ b/extensions/proto/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zed_proto" -version = "0.3.0" +version = "0.3.1" edition.workspace = true publish.workspace = true license = "Apache-2.0" diff --git a/extensions/proto/extension.toml b/extensions/proto/extension.toml index 13c4054eef083e131ab311b1ec6e5a63aff545d8..70ebed1ca50635d9e818ce216920937a547b64c4 100644 --- a/extensions/proto/extension.toml +++ b/extensions/proto/extension.toml @@ -1,7 +1,7 @@ id = "proto" name = "Proto" description = "Protocol Buffers support." -version = "0.3.0" +version = "0.3.1" schema_version = 1 authors = ["Zed Industries "] repository = "https://github.com/zed-industries/zed" From 07ada5846663a67945238141c7c0010ee98385c3 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 22 Dec 2025 12:40:02 -0800 Subject: [PATCH 607/621] Improve edit prediction example capture (#45536) This PR improves the `edit prediction: Capture Example` in several ways: * fixed bugs in how the uncommitted diff was calculated * added a `edit_predictions.examples_dir` setting that can be set in order to have the action automatically save examples into the given folder * moved the action into the `edit_predictions` crate, in preparation for collecting this data passively from end users, when they have opted in to data sharing, similar to what we did for Zeta 1 Release Notes: - N/A --- Cargo.lock | 12 +- crates/buffer_diff/src/buffer_diff.rs | 6 + crates/edit_prediction/Cargo.toml | 3 + crates/edit_prediction/src/capture_example.rs | 375 ++++++++++++++++++ crates/edit_prediction/src/edit_prediction.rs | 96 ++++- .../src/edit_prediction_tests.rs | 76 +++- crates/edit_prediction/src/example_spec.rs | 2 +- .../edit_prediction_cli/src/format_prompt.rs | 7 +- crates/edit_prediction_ui/Cargo.toml | 10 +- .../src/edit_prediction_button.rs | 7 +- .../src/edit_prediction_ui.rs | 209 ++-------- crates/fs/src/fake_git_repo.rs | 12 +- crates/fs/src/fs.rs | 12 + crates/language/src/language.rs | 2 +- crates/language/src/language_settings.rs | 2 + crates/language/src/text_diff.rs | 148 ++++++- crates/project/src/git_store.rs | 1 + crates/settings/src/merge_from.rs | 1 + .../settings/src/settings_content/language.rs | 4 +- 19 files changed, 770 insertions(+), 215 deletions(-) create mode 100644 crates/edit_prediction/src/capture_example.rs diff --git a/Cargo.lock b/Cargo.lock index 467ce89d1d4b07dfdad247d76dc1874c90a986f4..d73200e3ced437f1e61e8c5b0da06f306358eb14 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5212,6 +5212,7 @@ dependencies = [ "anyhow", "arrayvec", "brotli", + "buffer_diff", "client", "clock", "cloud_api_types", @@ -5249,7 +5250,9 @@ dependencies = [ "strum 0.27.2", "telemetry", "telemetry_events", + "text", "thiserror 2.0.17", + "time", "ui", "util", "uuid", @@ -5354,8 +5357,10 @@ dependencies = [ "anyhow", "buffer_diff", "client", + "clock", "cloud_llm_client", "codestral", + "collections", "command_palette_hooks", "copilot", "edit_prediction", @@ -5364,18 +5369,20 @@ dependencies = [ "feature_flags", "fs", "futures 0.3.31", - "git", "gpui", "indoc", "language", - "log", + "language_model", "lsp", "markdown", "menu", "multi_buffer", "paths", + "pretty_assertions", "project", "regex", + "release_channel", + "semver", "serde_json", "settings", "supermaven", @@ -5388,6 +5395,7 @@ dependencies = [ "workspace", "zed_actions", "zeta_prompt", + "zlog", ] [[package]] diff --git a/crates/buffer_diff/src/buffer_diff.rs b/crates/buffer_diff/src/buffer_diff.rs index 111b18233b6500de7de4485c8a408eec1e8cb822..bce2bed058e9bfe27c54df5c978ad23bc2896726 100644 --- a/crates/buffer_diff/src/buffer_diff.rs +++ b/crates/buffer_diff/src/buffer_diff.rs @@ -314,6 +314,12 @@ impl BufferDiffSnapshot { self.inner.hunks.is_empty() } + pub fn base_text_string(&self) -> Option { + self.inner + .base_text_exists + .then(|| self.inner.base_text.text()) + } + pub fn secondary_diff(&self) -> Option<&BufferDiffSnapshot> { self.secondary_diff.as_deref() } diff --git a/crates/edit_prediction/Cargo.toml b/crates/edit_prediction/Cargo.toml index 2d5fb36a581f7bd17bb76f79791c276c86c9c631..5145777ff0733d674f33a597db6682e611e4d0fc 100644 --- a/crates/edit_prediction/Cargo.toml +++ b/crates/edit_prediction/Cargo.toml @@ -19,6 +19,7 @@ ai_onboarding.workspace = true anyhow.workspace = true arrayvec.workspace = true brotli.workspace = true +buffer_diff.workspace = true client.workspace = true cloud_llm_client.workspace = true collections.workspace = true @@ -52,7 +53,9 @@ settings.workspace = true strum.workspace = true telemetry.workspace = true telemetry_events.workspace = true +text.workspace = true thiserror.workspace = true +time.workspace = true ui.workspace = true util.workspace = true uuid.workspace = true diff --git a/crates/edit_prediction/src/capture_example.rs b/crates/edit_prediction/src/capture_example.rs new file mode 100644 index 0000000000000000000000000000000000000000..0171b711dd24384e1588c076d4b4f678723d7459 --- /dev/null +++ b/crates/edit_prediction/src/capture_example.rs @@ -0,0 +1,375 @@ +use crate::{ + EditPredictionStore, StoredEvent, + cursor_excerpt::editable_and_context_ranges_for_cursor_position, example_spec::ExampleSpec, +}; +use anyhow::Result; +use buffer_diff::BufferDiffSnapshot; +use collections::HashMap; +use gpui::{App, Entity, Task}; +use language::{Buffer, ToPoint as _}; +use project::Project; +use std::{collections::hash_map, fmt::Write as _, path::Path, sync::Arc}; +use text::{BufferSnapshot as TextBufferSnapshot, ToOffset as _}; + +pub fn capture_example( + project: Entity, + buffer: Entity, + cursor_anchor: language::Anchor, + last_event_is_expected_patch: bool, + cx: &mut App, +) -> Option>> { + let ep_store = EditPredictionStore::try_global(cx)?; + let snapshot = buffer.read(cx).snapshot(); + let file = snapshot.file()?; + let worktree_id = file.worktree_id(cx); + let repository = project.read(cx).active_repository(cx)?; + let repository_snapshot = repository.read(cx).snapshot(); + let worktree = project.read(cx).worktree_for_id(worktree_id, cx)?; + let cursor_path = worktree.read(cx).root_name().join(file.path()); + if worktree.read(cx).abs_path() != repository_snapshot.work_directory_abs_path { + return None; + } + + let repository_url = repository_snapshot + .remote_origin_url + .clone() + .or_else(|| repository_snapshot.remote_upstream_url.clone())?; + let revision = repository_snapshot.head_commit.as_ref()?.sha.to_string(); + + let mut events = ep_store.update(cx, |store, cx| { + store.edit_history_for_project_with_pause_split_last_event(&project, cx) + }); + + let git_store = project.read(cx).git_store().clone(); + + Some(cx.spawn(async move |mut cx| { + let snapshots_by_path = collect_snapshots(&project, &git_store, &events, &mut cx).await?; + let cursor_excerpt = cx + .background_executor() + .spawn(async move { compute_cursor_excerpt(&snapshot, cursor_anchor) }) + .await; + let uncommitted_diff = cx + .background_executor() + .spawn(async move { compute_uncommitted_diff(snapshots_by_path) }) + .await; + + let mut edit_history = String::new(); + let mut expected_patch = String::new(); + if last_event_is_expected_patch { + if let Some(stored_event) = events.pop() { + zeta_prompt::write_event(&mut expected_patch, &stored_event.event); + } + } + + for stored_event in &events { + zeta_prompt::write_event(&mut edit_history, &stored_event.event); + if !edit_history.ends_with('\n') { + edit_history.push('\n'); + } + } + + let name = generate_timestamp_name(); + + Ok(ExampleSpec { + name, + repository_url, + revision, + uncommitted_diff, + cursor_path: cursor_path.as_std_path().into(), + cursor_position: cursor_excerpt, + edit_history, + expected_patch, + }) + })) +} + +fn compute_cursor_excerpt( + snapshot: &language::BufferSnapshot, + cursor_anchor: language::Anchor, +) -> String { + let cursor_point = cursor_anchor.to_point(snapshot); + let (_editable_range, context_range) = + editable_and_context_ranges_for_cursor_position(cursor_point, snapshot, 100, 50); + + let context_start_offset = context_range.start.to_offset(snapshot); + let cursor_offset = cursor_anchor.to_offset(snapshot); + let cursor_offset_in_excerpt = cursor_offset.saturating_sub(context_start_offset); + let mut excerpt = snapshot.text_for_range(context_range).collect::(); + if cursor_offset_in_excerpt <= excerpt.len() { + excerpt.insert_str(cursor_offset_in_excerpt, zeta_prompt::CURSOR_MARKER); + } + excerpt +} + +async fn collect_snapshots( + project: &Entity, + git_store: &Entity, + events: &[StoredEvent], + cx: &mut gpui::AsyncApp, +) -> Result, (TextBufferSnapshot, BufferDiffSnapshot)>> { + let mut snapshots_by_path = HashMap::default(); + for stored_event in events { + let zeta_prompt::Event::BufferChange { path, .. } = stored_event.event.as_ref(); + if let Some((project_path, full_path)) = project.read_with(cx, |project, cx| { + let project_path = project.find_project_path(path, cx)?; + let full_path = project + .worktree_for_id(project_path.worktree_id, cx)? + .read(cx) + .root_name() + .join(&project_path.path) + .as_std_path() + .into(); + Some((project_path, full_path)) + })? { + if let hash_map::Entry::Vacant(entry) = snapshots_by_path.entry(full_path) { + let buffer = project + .update(cx, |project, cx| { + project.open_buffer(project_path.clone(), cx) + })? + .await?; + let diff = git_store + .update(cx, |git_store, cx| { + git_store.open_uncommitted_diff(buffer.clone(), cx) + })? + .await?; + let diff_snapshot = diff.update(cx, |diff, cx| diff.snapshot(cx))?; + entry.insert((stored_event.old_snapshot.clone(), diff_snapshot)); + } + } + } + Ok(snapshots_by_path) +} + +fn compute_uncommitted_diff( + snapshots_by_path: HashMap, (TextBufferSnapshot, BufferDiffSnapshot)>, +) -> String { + let mut uncommitted_diff = String::new(); + for (full_path, (before_text, diff_snapshot)) in snapshots_by_path { + if let Some(head_text) = &diff_snapshot.base_text_string() { + let file_diff = language::unified_diff(head_text, &before_text.text()); + if !file_diff.is_empty() { + let path_str = full_path.to_string_lossy(); + writeln!(uncommitted_diff, "--- a/{path_str}").ok(); + writeln!(uncommitted_diff, "+++ b/{path_str}").ok(); + uncommitted_diff.push_str(&file_diff); + if !uncommitted_diff.ends_with('\n') { + uncommitted_diff.push('\n'); + } + } + } + } + uncommitted_diff +} + +fn generate_timestamp_name() -> String { + let format = time::format_description::parse("[year]-[month]-[day] [hour]:[minute]:[second]"); + match format { + Ok(format) => { + let now = time::OffsetDateTime::now_local() + .unwrap_or_else(|_| time::OffsetDateTime::now_utc()); + now.format(&format) + .unwrap_or_else(|_| "unknown-time".to_string()) + } + Err(_) => "unknown-time".to_string(), + } +} + +#[cfg(test)] +mod tests { + use super::*; + use client::{Client, UserStore}; + use clock::FakeSystemClock; + use gpui::{AppContext as _, TestAppContext, http_client::FakeHttpClient}; + use indoc::indoc; + use language::{Anchor, Point}; + use project::{FakeFs, Project}; + use serde_json::json; + use settings::SettingsStore; + use std::path::Path; + + #[gpui::test] + async fn test_capture_example(cx: &mut TestAppContext) { + init_test(cx); + let fs = FakeFs::new(cx.executor()); + + let committed_contents = indoc! {" + fn main() { + one(); + two(); + three(); + four(); + five(); + six(); + seven(); + eight(); + nine(); + } + "}; + + let disk_contents = indoc! {" + fn main() { + // comment 1 + one(); + two(); + three(); + four(); + five(); + six(); + seven(); + eight(); + // comment 2 + nine(); + } + "}; + + fs.insert_tree( + "/project", + json!({ + ".git": {}, + "src": { + "main.rs": disk_contents, + } + }), + ) + .await; + + fs.set_head_for_repo( + Path::new("/project/.git"), + &[("src/main.rs", committed_contents.to_string())], + "abc123def456", + ); + fs.set_remote_for_repo( + Path::new("/project/.git"), + "origin", + "https://github.com/test/repo.git", + ); + + let project = Project::test(fs.clone(), ["/project".as_ref()], cx).await; + + let buffer = project + .update(cx, |project, cx| { + project.open_local_buffer("/project/src/main.rs", cx) + }) + .await + .unwrap(); + + let ep_store = cx.read(|cx| EditPredictionStore::try_global(cx).unwrap()); + ep_store.update(cx, |ep_store, cx| { + ep_store.register_buffer(&buffer, &project, cx) + }); + cx.run_until_parked(); + + buffer.update(cx, |buffer, cx| { + let point = Point::new(6, 0); + buffer.edit([(point..point, " // comment 3\n")], None, cx); + let point = Point::new(4, 0); + buffer.edit([(point..point, " // comment 4\n")], None, cx); + + pretty_assertions::assert_eq!( + buffer.text(), + indoc! {" + fn main() { + // comment 1 + one(); + two(); + // comment 4 + three(); + four(); + // comment 3 + five(); + six(); + seven(); + eight(); + // comment 2 + nine(); + } + "} + ); + }); + cx.run_until_parked(); + + let mut example = cx + .update(|cx| { + capture_example(project.clone(), buffer.clone(), Anchor::MIN, false, cx).unwrap() + }) + .await + .unwrap(); + example.name = "test".to_string(); + + pretty_assertions::assert_eq!( + example, + ExampleSpec { + name: "test".to_string(), + repository_url: "https://github.com/test/repo.git".to_string(), + revision: "abc123def456".to_string(), + uncommitted_diff: indoc! {" + --- a/project/src/main.rs + +++ b/project/src/main.rs + @@ -1,4 +1,5 @@ + fn main() { + + // comment 1 + one(); + two(); + three(); + @@ -7,5 +8,6 @@ + six(); + seven(); + eight(); + + // comment 2 + nine(); + } + "} + .to_string(), + cursor_path: Path::new("project/src/main.rs").into(), + cursor_position: indoc! {" + <|user_cursor|>fn main() { + // comment 1 + one(); + two(); + // comment 4 + three(); + four(); + // comment 3 + five(); + six(); + seven(); + eight(); + // comment 2 + nine(); + } + "} + .to_string(), + edit_history: indoc! {" + --- a/project/src/main.rs + +++ b/project/src/main.rs + @@ -2,8 +2,10 @@ + // comment 1 + one(); + two(); + + // comment 4 + three(); + four(); + + // comment 3 + five(); + six(); + seven(); + "} + .to_string(), + expected_patch: "".to_string(), + } + ); + } + + fn init_test(cx: &mut TestAppContext) { + cx.update(|cx| { + let settings_store = SettingsStore::test(cx); + cx.set_global(settings_store); + zlog::init_test(); + let http_client = FakeHttpClient::with_404_response(); + let client = Client::new(Arc::new(FakeSystemClock::new()), http_client, cx); + language_model::init(client.clone(), cx); + let user_store = cx.new(|cx| UserStore::new(client.clone(), cx)); + EditPredictionStore::global(&client, &user_store, cx); + }) + } +} diff --git a/crates/edit_prediction/src/edit_prediction.rs b/crates/edit_prediction/src/edit_prediction.rs index f5ea7590fcba97ee916af985824e21cdf4ea725f..c47c1a70e843a17cc98083dec664c7fc05933426 100644 --- a/crates/edit_prediction/src/edit_prediction.rs +++ b/crates/edit_prediction/src/edit_prediction.rs @@ -35,6 +35,7 @@ use semver::Version; use serde::de::DeserializeOwned; use settings::{EditPredictionProvider, SettingsStore, update_settings_file}; use std::collections::{VecDeque, hash_map}; +use text::Edit; use workspace::Workspace; use std::ops::Range; @@ -57,9 +58,9 @@ pub mod open_ai_response; mod prediction; pub mod sweep_ai; -#[cfg(any(test, feature = "test-support", feature = "cli-support"))] pub mod udiff; +mod capture_example; mod zed_edit_prediction_delegate; pub mod zeta1; pub mod zeta2; @@ -74,6 +75,7 @@ pub use crate::prediction::EditPrediction; pub use crate::prediction::EditPredictionId; use crate::prediction::EditPredictionResult; pub use crate::sweep_ai::SweepAi; +pub use capture_example::capture_example; pub use language_model::ApiKeyState; pub use telemetry_events::EditPredictionRating; pub use zed_edit_prediction_delegate::ZedEditPredictionDelegate; @@ -231,8 +233,15 @@ pub struct EditPredictionFinishedDebugEvent { pub type RequestDebugInfo = predict_edits_v3::DebugInfo; +/// An event with associated metadata for reconstructing buffer state. +#[derive(Clone)] +pub struct StoredEvent { + pub event: Arc, + pub old_snapshot: TextBufferSnapshot, +} + struct ProjectState { - events: VecDeque>, + events: VecDeque, last_event: Option, recent_paths: VecDeque, registered_buffers: HashMap, @@ -248,7 +257,7 @@ struct ProjectState { } impl ProjectState { - pub fn events(&self, cx: &App) -> Vec> { + pub fn events(&self, cx: &App) -> Vec { self.events .iter() .cloned() @@ -260,7 +269,7 @@ impl ProjectState { .collect() } - pub fn events_split_by_pause(&self, cx: &App) -> Vec> { + pub fn events_split_by_pause(&self, cx: &App) -> Vec { self.events .iter() .cloned() @@ -415,7 +424,7 @@ impl LastEvent { &self, license_detection_watchers: &HashMap>, cx: &App, - ) -> Option> { + ) -> Option { let path = buffer_path_with_id_fallback(self.new_file.as_ref(), &self.new_snapshot, cx); let old_path = buffer_path_with_id_fallback(self.old_file.as_ref(), &self.old_snapshot, cx); @@ -430,19 +439,22 @@ impl LastEvent { }) }); - let diff = language::unified_diff(&self.old_snapshot.text(), &self.new_snapshot.text()); + let diff = compute_diff_between_snapshots(&self.old_snapshot, &self.new_snapshot)?; if path == old_path && diff.is_empty() { None } else { - Some(Arc::new(zeta_prompt::Event::BufferChange { - old_path, - path, - diff, - in_open_source_repo, - // TODO: Actually detect if this edit was predicted or not - predicted: false, - })) + Some(StoredEvent { + event: Arc::new(zeta_prompt::Event::BufferChange { + old_path, + path, + diff, + in_open_source_repo, + // TODO: Actually detect if this edit was predicted or not + predicted: false, + }), + old_snapshot: self.old_snapshot.clone(), + }) } } @@ -475,6 +487,52 @@ impl LastEvent { } } +pub(crate) fn compute_diff_between_snapshots( + old_snapshot: &TextBufferSnapshot, + new_snapshot: &TextBufferSnapshot, +) -> Option { + let edits: Vec> = new_snapshot + .edits_since::(&old_snapshot.version) + .collect(); + + let (first_edit, last_edit) = edits.first().zip(edits.last())?; + + let old_start_point = old_snapshot.offset_to_point(first_edit.old.start); + let old_end_point = old_snapshot.offset_to_point(last_edit.old.end); + let new_start_point = new_snapshot.offset_to_point(first_edit.new.start); + let new_end_point = new_snapshot.offset_to_point(last_edit.new.end); + + const CONTEXT_LINES: u32 = 3; + + let old_context_start_row = old_start_point.row.saturating_sub(CONTEXT_LINES); + let new_context_start_row = new_start_point.row.saturating_sub(CONTEXT_LINES); + let old_context_end_row = + (old_end_point.row + 1 + CONTEXT_LINES).min(old_snapshot.max_point().row); + let new_context_end_row = + (new_end_point.row + 1 + CONTEXT_LINES).min(new_snapshot.max_point().row); + + let old_start_line_offset = old_snapshot.point_to_offset(Point::new(old_context_start_row, 0)); + let new_start_line_offset = new_snapshot.point_to_offset(Point::new(new_context_start_row, 0)); + let old_end_line_offset = old_snapshot + .point_to_offset(Point::new(old_context_end_row + 1, 0).min(old_snapshot.max_point())); + let new_end_line_offset = new_snapshot + .point_to_offset(Point::new(new_context_end_row + 1, 0).min(new_snapshot.max_point())); + let old_edit_range = old_start_line_offset..old_end_line_offset; + let new_edit_range = new_start_line_offset..new_end_line_offset; + + let old_region_text: String = old_snapshot.text_for_range(old_edit_range).collect(); + let new_region_text: String = new_snapshot.text_for_range(new_edit_range).collect(); + + let diff = language::unified_diff_with_offsets( + &old_region_text, + &new_region_text, + old_context_start_row, + new_context_start_row, + ); + + Some(diff) +} + fn buffer_path_with_id_fallback( file: Option<&Arc>, snapshot: &TextBufferSnapshot, @@ -643,7 +701,7 @@ impl EditPredictionStore { &self, project: &Entity, cx: &App, - ) -> Vec> { + ) -> Vec { self.projects .get(&project.entity_id()) .map(|project_state| project_state.events(cx)) @@ -654,7 +712,7 @@ impl EditPredictionStore { &self, project: &Entity, cx: &App, - ) -> Vec> { + ) -> Vec { self.projects .get(&project.entity_id()) .map(|project_state| project_state.events_split_by_pause(cx)) @@ -1536,8 +1594,10 @@ impl EditPredictionStore { self.get_or_init_project(&project, cx); let project_state = self.projects.get(&project.entity_id()).unwrap(); - let events = project_state.events(cx); - let has_events = !events.is_empty(); + let stored_events = project_state.events(cx); + let has_events = !stored_events.is_empty(); + let events: Vec> = + stored_events.into_iter().map(|e| e.event).collect(); let debug_tx = project_state.debug_tx.clone(); let snapshot = active_buffer.read(cx).snapshot(); diff --git a/crates/edit_prediction/src/edit_prediction_tests.rs b/crates/edit_prediction/src/edit_prediction_tests.rs index eee3f1f79e93b60ee3ea7c80bd987af22d613833..40d729f1ebdcedf2c424d8c8df4bea1bb1829300 100644 --- a/crates/edit_prediction/src/edit_prediction_tests.rs +++ b/crates/edit_prediction/src/edit_prediction_tests.rs @@ -1,5 +1,5 @@ use super::*; -use crate::{udiff::apply_diff_to_string, zeta1::MAX_EVENT_TOKENS}; +use crate::{compute_diff_between_snapshots, udiff::apply_diff_to_string, zeta1::MAX_EVENT_TOKENS}; use client::{UserStore, test::FakeServer}; use clock::{FakeSystemClock, ReplicaId}; use cloud_api_types::{CreateLlmTokenResponse, LlmToken}; @@ -360,7 +360,7 @@ async fn test_edit_history_getter_pause_splits_last_event(cx: &mut TestAppContex ep_store.edit_history_for_project(&project, cx) }); assert_eq!(events.len(), 1); - let zeta_prompt::Event::BufferChange { diff, .. } = events[0].as_ref(); + let zeta_prompt::Event::BufferChange { diff, .. } = events[0].event.as_ref(); assert_eq!( diff.as_str(), indoc! {" @@ -377,7 +377,7 @@ async fn test_edit_history_getter_pause_splits_last_event(cx: &mut TestAppContex ep_store.edit_history_for_project_with_pause_split_last_event(&project, cx) }); assert_eq!(events.len(), 2); - let zeta_prompt::Event::BufferChange { diff, .. } = events[0].as_ref(); + let zeta_prompt::Event::BufferChange { diff, .. } = events[0].event.as_ref(); assert_eq!( diff.as_str(), indoc! {" @@ -389,7 +389,7 @@ async fn test_edit_history_getter_pause_splits_last_event(cx: &mut TestAppContex "} ); - let zeta_prompt::Event::BufferChange { diff, .. } = events[1].as_ref(); + let zeta_prompt::Event::BufferChange { diff, .. } = events[1].event.as_ref(); assert_eq!( diff.as_str(), indoc! {" @@ -2082,6 +2082,74 @@ async fn test_unauthenticated_with_custom_url_allows_prediction_impl(cx: &mut Te ); } +#[gpui::test] +fn test_compute_diff_between_snapshots(cx: &mut TestAppContext) { + let buffer = cx.new(|cx| { + Buffer::local( + indoc! {" + zero + one + two + three + four + five + six + seven + eight + nine + ten + eleven + twelve + thirteen + fourteen + fifteen + sixteen + seventeen + eighteen + nineteen + twenty + twenty-one + twenty-two + twenty-three + twenty-four + "}, + cx, + ) + }); + + let old_snapshot = buffer.read_with(cx, |buffer, _| buffer.text_snapshot()); + + buffer.update(cx, |buffer, cx| { + let point = Point::new(12, 0); + buffer.edit([(point..point, "SECOND INSERTION\n")], None, cx); + let point = Point::new(8, 0); + buffer.edit([(point..point, "FIRST INSERTION\n")], None, cx); + }); + + let new_snapshot = buffer.read_with(cx, |buffer, _| buffer.text_snapshot()); + + let diff = compute_diff_between_snapshots(&old_snapshot, &new_snapshot).unwrap(); + + assert_eq!( + diff, + indoc! {" + @@ -6,10 +6,12 @@ + five + six + seven + +FIRST INSERTION + eight + nine + ten + eleven + +SECOND INSERTION + twelve + thirteen + fourteen + "} + ); +} + #[ctor::ctor] fn init_logger() { zlog::init_test(); diff --git a/crates/edit_prediction/src/example_spec.rs b/crates/edit_prediction/src/example_spec.rs index bf221b576b890f1200c4ee3c095f73edaea71462..8a30c7b85c494fcc7a0b32ece665f814e8452bc4 100644 --- a/crates/edit_prediction/src/example_spec.rs +++ b/crates/edit_prediction/src/example_spec.rs @@ -1,7 +1,7 @@ use serde::{Deserialize, Serialize}; use std::{fmt::Write as _, mem, path::Path, sync::Arc}; -#[derive(Clone, Debug, Serialize, Deserialize)] +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct ExampleSpec { #[serde(default)] pub name: String, diff --git a/crates/edit_prediction_cli/src/format_prompt.rs b/crates/edit_prediction_cli/src/format_prompt.rs index f543d0799b379403f0caa980df76954649e1aceb..34e8a92d4140cdbdedb6bd2583e0994eb55b802d 100644 --- a/crates/edit_prediction_cli/src/format_prompt.rs +++ b/crates/edit_prediction_cli/src/format_prompt.rs @@ -45,6 +45,11 @@ pub async fn run_format_prompt( let snapshot = state.buffer.read_with(&cx, |buffer, _| buffer.snapshot())?; let project = state.project.clone(); let (_, input) = ep_store.update(&mut cx, |ep_store, cx| { + let events = ep_store + .edit_history_for_project(&project, cx) + .into_iter() + .map(|e| e.event) + .collect(); anyhow::Ok(zeta2_prompt_input( &snapshot, example @@ -53,7 +58,7 @@ pub async fn run_format_prompt( .context("context must be set")? .files .clone(), - ep_store.edit_history_for_project(&project, cx), + events, example.spec.cursor_path.clone(), example .buffer diff --git a/crates/edit_prediction_ui/Cargo.toml b/crates/edit_prediction_ui/Cargo.toml index b406a450601bef908c27a48be14fe9b1f2204c08..6c4bf735e7cce1b95666b0195d2da8caab57f703 100644 --- a/crates/edit_prediction_ui/Cargo.toml +++ b/crates/edit_prediction_ui/Cargo.toml @@ -15,8 +15,7 @@ doctest = false [dependencies] anyhow.workspace = true buffer_diff.workspace = true -git.workspace = true -log.workspace = true +collections.workspace = true time.workspace = true client.workspace = true cloud_llm_client.workspace = true @@ -50,11 +49,18 @@ zed_actions.workspace = true zeta_prompt.workspace = true [dev-dependencies] +clock.workspace = true copilot = { workspace = true, features = ["test-support"] } editor = { workspace = true, features = ["test-support"] } futures.workspace = true indoc.workspace = true +language_model.workspace = true lsp = { workspace = true, features = ["test-support"] } +pretty_assertions.workspace = true project = { workspace = true, features = ["test-support"] } +release_channel.workspace = true +semver.workspace = true serde_json.workspace = true theme = { workspace = true, features = ["test-support"] } +workspace = { workspace = true, features = ["test-support"] } +zlog.workspace = true diff --git a/crates/edit_prediction_ui/src/edit_prediction_button.rs b/crates/edit_prediction_ui/src/edit_prediction_button.rs index 0dcea477200eef9d1eeb6adeff98f47332d751ca..ca9864753cc759409914b42daa5de6b517a473ba 100644 --- a/crates/edit_prediction_ui/src/edit_prediction_button.rs +++ b/crates/edit_prediction_ui/src/edit_prediction_button.rs @@ -915,11 +915,8 @@ impl EditPredictionButton { .when( cx.has_flag::(), |this| { - this.action( - "Capture Edit Prediction Example", - CaptureExample.boxed_clone(), - ) - .action("Rate Predictions", RatePredictions.boxed_clone()) + this.action("Capture Prediction Example", CaptureExample.boxed_clone()) + .action("Rate Predictions", RatePredictions.boxed_clone()) }, ); } diff --git a/crates/edit_prediction_ui/src/edit_prediction_ui.rs b/crates/edit_prediction_ui/src/edit_prediction_ui.rs index a762fd22aa7c32779a096fa97b2ea20ef3c9b744..9dc7623f79cab61350a06740440bae5cb4e3f40f 100644 --- a/crates/edit_prediction_ui/src/edit_prediction_ui.rs +++ b/crates/edit_prediction_ui/src/edit_prediction_ui.rs @@ -2,25 +2,17 @@ mod edit_prediction_button; mod edit_prediction_context_view; mod rate_prediction_modal; -use std::any::{Any as _, TypeId}; -use std::path::Path; -use std::sync::Arc; - use command_palette_hooks::CommandPaletteFilter; -use edit_prediction::{ - EditPredictionStore, ResetOnboarding, Zeta2FeatureFlag, example_spec::ExampleSpec, -}; +use edit_prediction::{ResetOnboarding, Zeta2FeatureFlag, capture_example}; use edit_prediction_context_view::EditPredictionContextView; use editor::Editor; use feature_flags::FeatureFlagAppExt as _; -use git::repository::DiffType; -use gpui::{Window, actions}; -use language::ToPoint as _; -use log; +use gpui::actions; +use language::language_settings::AllLanguageSettings; use project::DisableAiSettings; use rate_prediction_modal::RatePredictionsModal; use settings::{Settings as _, SettingsStore}; -use text::ToOffset as _; +use std::any::{Any as _, TypeId}; use ui::{App, prelude::*}; use workspace::{SplitDirection, Workspace}; @@ -56,7 +48,9 @@ pub fn init(cx: &mut App) { } }); - workspace.register_action(capture_edit_prediction_example); + workspace.register_action(|workspace, _: &CaptureExample, window, cx| { + capture_example_as_markdown(workspace, window, cx); + }); workspace.register_action_renderer(|div, _, _, cx| { let has_flag = cx.has_flag::(); div.when(has_flag, |div| { @@ -138,182 +132,48 @@ fn feature_gate_predict_edits_actions(cx: &mut App) { .detach(); } -fn capture_edit_prediction_example( +fn capture_example_as_markdown( workspace: &mut Workspace, - _: &CaptureExample, window: &mut Window, cx: &mut Context, -) { - let Some(ep_store) = EditPredictionStore::try_global(cx) else { - return; - }; +) -> Option<()> { + let markdown_language = workspace + .app_state() + .languages + .language_for_name("Markdown"); + let fs = workspace.app_state().fs.clone(); let project = workspace.project().clone(); - - let (worktree_root, repository) = { - let project_ref = project.read(cx); - let worktree_root = project_ref - .visible_worktrees(cx) - .next() - .map(|worktree| worktree.read(cx).abs_path()); - let repository = project_ref.active_repository(cx); - (worktree_root, repository) - }; - - let (Some(worktree_root), Some(repository)) = (worktree_root, repository) else { - log::error!("CaptureExampleSpec: missing worktree or active repository"); - return; - }; - - let repository_snapshot = repository.read(cx).snapshot(); - if worktree_root.as_ref() != repository_snapshot.work_directory_abs_path.as_ref() { - log::error!( - "repository is not at worktree root (repo={:?}, worktree={:?})", - repository_snapshot.work_directory_abs_path, - worktree_root - ); - return; - } - - let Some(repository_url) = repository_snapshot - .remote_origin_url - .clone() - .or_else(|| repository_snapshot.remote_upstream_url.clone()) - else { - log::error!("active repository has no origin/upstream remote url"); - return; - }; - - let Some(revision) = repository_snapshot - .head_commit - .as_ref() - .map(|commit| commit.sha.to_string()) - else { - log::error!("active repository has no head commit"); - return; - }; - - let mut events = ep_store.update(cx, |store, cx| { - store.edit_history_for_project_with_pause_split_last_event(&project, cx) - }); - - let Some(editor) = workspace.active_item_as::(cx) else { - log::error!("no active editor"); - return; - }; - - let Some(project_path) = editor.read(cx).project_path(cx) else { - log::error!("active editor has no project path"); - return; - }; - - let Some((buffer, cursor_anchor)) = editor - .read(cx) + let editor = workspace.active_item_as::(cx)?; + let editor = editor.read(cx); + let (buffer, cursor_anchor) = editor .buffer() .read(cx) - .text_anchor_for_position(editor.read(cx).selections.newest_anchor().head(), cx) - else { - log::error!("failed to resolve cursor buffer/anchor"); - return; - }; - - let snapshot = buffer.read(cx).snapshot(); - let cursor_point = cursor_anchor.to_point(&snapshot); - let (_editable_range, context_range) = - edit_prediction::cursor_excerpt::editable_and_context_ranges_for_cursor_position( - cursor_point, - &snapshot, - 100, - 50, - ); - - let cursor_path: Arc = repository - .read(cx) - .project_path_to_repo_path(&project_path, cx) - .map(|repo_path| Path::new(repo_path.as_unix_str()).into()) - .unwrap_or_else(|| Path::new(project_path.path.as_unix_str()).into()); + .text_anchor_for_position(editor.selections.newest_anchor().head(), cx)?; + let example = capture_example(project.clone(), buffer, cursor_anchor, true, cx)?; - let cursor_position = { - let context_start_offset = context_range.start.to_offset(&snapshot); - let cursor_offset = cursor_anchor.to_offset(&snapshot); - let cursor_offset_in_excerpt = cursor_offset.saturating_sub(context_start_offset); - let mut excerpt = snapshot.text_for_range(context_range).collect::(); - if cursor_offset_in_excerpt <= excerpt.len() { - excerpt.insert_str(cursor_offset_in_excerpt, zeta_prompt::CURSOR_MARKER); - } - excerpt - }; - - let markdown_language = workspace - .app_state() - .languages - .language_for_name("Markdown"); + let examples_dir = AllLanguageSettings::get_global(cx) + .edit_predictions + .examples_dir + .clone(); cx.spawn_in(window, async move |workspace_entity, cx| { let markdown_language = markdown_language.await?; + let example_spec = example.await?; + let buffer = if let Some(dir) = examples_dir { + fs.create_dir(&dir).await.ok(); + let mut path = dir.join(&example_spec.name.replace(' ', "--").replace(':', "-")); + path.set_extension("md"); + project.update(cx, |project, cx| project.open_local_buffer(&path, cx)) + } else { + project.update(cx, |project, cx| project.create_buffer(false, cx)) + }? + .await?; - let uncommitted_diff_rx = repository.update(cx, |repository, cx| { - repository.diff(DiffType::HeadToWorktree, cx) - })?; - - let uncommitted_diff = match uncommitted_diff_rx.await { - Ok(Ok(diff)) => diff, - Ok(Err(error)) => { - log::error!("failed to compute uncommitted diff: {error:#}"); - return Ok(()); - } - Err(error) => { - log::error!("uncommitted diff channel dropped: {error:#}"); - return Ok(()); - } - }; - - let mut edit_history = String::new(); - let mut expected_patch = String::new(); - if let Some(last_event) = events.pop() { - for event in &events { - zeta_prompt::write_event(&mut edit_history, event); - if !edit_history.ends_with('\n') { - edit_history.push('\n'); - } - edit_history.push('\n'); - } - - zeta_prompt::write_event(&mut expected_patch, &last_event); - } - - let format = - time::format_description::parse("[year]-[month]-[day] [hour]:[minute]:[second]"); - let name = match format { - Ok(format) => { - let now = time::OffsetDateTime::now_local() - .unwrap_or_else(|_| time::OffsetDateTime::now_utc()); - now.format(&format) - .unwrap_or_else(|_| "unknown-time".to_string()) - } - Err(_) => "unknown-time".to_string(), - }; - - let markdown = ExampleSpec { - name, - repository_url, - revision, - uncommitted_diff, - cursor_path, - cursor_position, - edit_history, - expected_patch, - } - .to_markdown(); - - let buffer = project - .update(cx, |project, cx| project.create_buffer(false, cx))? - .await?; buffer.update(cx, |buffer, cx| { - buffer.set_text(markdown, cx); + buffer.set_text(example_spec.to_markdown(), cx); buffer.set_language(Some(markdown_language), cx); })?; - workspace_entity.update_in(cx, |workspace, window, cx| { workspace.add_item_to_active_pane( Box::new( @@ -327,4 +187,5 @@ fn capture_edit_prediction_example( }) }) .detach_and_log_err(cx); + None } diff --git a/crates/fs/src/fake_git_repo.rs b/crates/fs/src/fake_git_repo.rs index be9b84ff6acd5e13080148f15103b8a21111de7a..576eb34341dca78f0a9de2d8ad4ce28e4eaff7db 100644 --- a/crates/fs/src/fake_git_repo.rs +++ b/crates/fs/src/fake_git_repo.rs @@ -156,8 +156,16 @@ impl GitRepository for FakeGitRepository { }) } - fn remote_url(&self, _name: &str) -> BoxFuture<'_, Option> { - async move { None }.boxed() + fn remote_url(&self, name: &str) -> BoxFuture<'_, Option> { + let name = name.to_string(); + let fut = self.with_state_async(false, move |state| { + state + .remotes + .get(&name) + .context("remote not found") + .cloned() + }); + async move { fut.await.ok() }.boxed() } fn diff_tree(&self, _request: DiffTreeType) -> BoxFuture<'_, Result> { diff --git a/crates/fs/src/fs.rs b/crates/fs/src/fs.rs index 2cbbf61a21e145464e9dbec01ace3b5510709d0d..3b2f318119fc3e1ff75bf19e30798aaf6630dfa7 100644 --- a/crates/fs/src/fs.rs +++ b/crates/fs/src/fs.rs @@ -1857,6 +1857,18 @@ impl FakeFs { .unwrap(); } + pub fn set_remote_for_repo( + &self, + dot_git: &Path, + name: impl Into, + url: impl Into, + ) { + self.with_git_state(dot_git, true, |state| { + state.remotes.insert(name.into(), url.into()); + }) + .unwrap(); + } + pub fn insert_branches(&self, dot_git: &Path, branches: &[&str]) { self.with_git_state(dot_git, true, |state| { if let Some(first) = branches.first() diff --git a/crates/language/src/language.rs b/crates/language/src/language.rs index 70ddd01d3a3bc4d76b766a73f46cb7a684ac2f91..8493d91ec4fa0b6a5fe810b4064694f2d8feb8d7 100644 --- a/crates/language/src/language.rs +++ b/crates/language/src/language.rs @@ -67,7 +67,7 @@ use task::RunnableTag; pub use task_context::{ContextLocation, ContextProvider, RunnableRange}; pub use text_diff::{ DiffOptions, apply_diff_patch, line_diff, text_diff, text_diff_with_options, unified_diff, - word_diff_ranges, + unified_diff_with_offsets, word_diff_ranges, }; use theme::SyntaxTheme; pub use toolchain::{ diff --git a/crates/language/src/language_settings.rs b/crates/language/src/language_settings.rs index 205f2431c6d9deeaa7661b583caa516bdc77ae79..cd2219b18ec8fda1d8783aaffa0917bfb4ddb041 100644 --- a/crates/language/src/language_settings.rs +++ b/crates/language/src/language_settings.rs @@ -392,6 +392,7 @@ pub struct EditPredictionSettings { /// Whether edit predictions are enabled in the assistant panel. /// This setting has no effect if globally disabled. pub enabled_in_text_threads: bool, + pub examples_dir: Option>, } impl EditPredictionSettings { @@ -699,6 +700,7 @@ impl settings::Settings for AllLanguageSettings { copilot: copilot_settings, codestral: codestral_settings, enabled_in_text_threads, + examples_dir: edit_predictions.examples_dir, }, defaults: default_language_settings, languages, diff --git a/crates/language/src/text_diff.rs b/crates/language/src/text_diff.rs index bc07ec73f0ad2c4738a2ca5f6ff955b53327acc3..4bca5b60febd86972e39dfbab3ae53621eef507e 100644 --- a/crates/language/src/text_diff.rs +++ b/crates/language/src/text_diff.rs @@ -1,25 +1,139 @@ use crate::{CharClassifier, CharKind, CharScopeContext, LanguageScope}; use anyhow::{Context, anyhow}; use imara_diff::{ - Algorithm, UnifiedDiffBuilder, diff, - intern::{InternedInput, Token}, + Algorithm, Sink, diff, + intern::{InternedInput, Interner, Token}, sources::lines_with_terminator, }; -use std::{iter, ops::Range, sync::Arc}; +use std::{fmt::Write, iter, ops::Range, sync::Arc}; const MAX_WORD_DIFF_LEN: usize = 512; const MAX_WORD_DIFF_LINE_COUNT: usize = 8; /// Computes a diff between two strings, returning a unified diff string. pub fn unified_diff(old_text: &str, new_text: &str) -> String { + unified_diff_with_offsets(old_text, new_text, 0, 0) +} + +/// Computes a diff between two strings, returning a unified diff string with +/// hunk headers adjusted to reflect the given starting line numbers (1-indexed). +pub fn unified_diff_with_offsets( + old_text: &str, + new_text: &str, + old_start_line: u32, + new_start_line: u32, +) -> String { let input = InternedInput::new(old_text, new_text); diff( Algorithm::Histogram, &input, - UnifiedDiffBuilder::new(&input), + OffsetUnifiedDiffBuilder::new(&input, old_start_line, new_start_line), ) } +/// A unified diff builder that applies line number offsets to hunk headers. +struct OffsetUnifiedDiffBuilder<'a> { + before: &'a [Token], + after: &'a [Token], + interner: &'a Interner<&'a str>, + + pos: u32, + before_hunk_start: u32, + after_hunk_start: u32, + before_hunk_len: u32, + after_hunk_len: u32, + + old_line_offset: u32, + new_line_offset: u32, + + buffer: String, + dst: String, +} + +impl<'a> OffsetUnifiedDiffBuilder<'a> { + fn new(input: &'a InternedInput<&'a str>, old_line_offset: u32, new_line_offset: u32) -> Self { + Self { + before_hunk_start: 0, + after_hunk_start: 0, + before_hunk_len: 0, + after_hunk_len: 0, + old_line_offset, + new_line_offset, + buffer: String::with_capacity(8), + dst: String::new(), + interner: &input.interner, + before: &input.before, + after: &input.after, + pos: 0, + } + } + + fn print_tokens(&mut self, tokens: &[Token], prefix: char) { + for &token in tokens { + writeln!(&mut self.buffer, "{prefix}{}", self.interner[token]).unwrap(); + } + } + + fn flush(&mut self) { + if self.before_hunk_len == 0 && self.after_hunk_len == 0 { + return; + } + + let end = (self.pos + 3).min(self.before.len() as u32); + self.update_pos(end, end); + + writeln!( + &mut self.dst, + "@@ -{},{} +{},{} @@", + self.before_hunk_start + 1 + self.old_line_offset, + self.before_hunk_len, + self.after_hunk_start + 1 + self.new_line_offset, + self.after_hunk_len, + ) + .unwrap(); + write!(&mut self.dst, "{}", &self.buffer).unwrap(); + self.buffer.clear(); + self.before_hunk_len = 0; + self.after_hunk_len = 0; + } + + fn update_pos(&mut self, print_to: u32, move_to: u32) { + self.print_tokens(&self.before[self.pos as usize..print_to as usize], ' '); + let len = print_to - self.pos; + self.pos = move_to; + self.before_hunk_len += len; + self.after_hunk_len += len; + } +} + +impl Sink for OffsetUnifiedDiffBuilder<'_> { + type Out = String; + + fn process_change(&mut self, before: Range, after: Range) { + if before.start - self.pos > 6 { + self.flush(); + } + if self.before_hunk_len == 0 && self.after_hunk_len == 0 { + self.pos = before.start.saturating_sub(3); + self.before_hunk_start = self.pos; + self.after_hunk_start = after.start.saturating_sub(3); + } + self.update_pos(before.start, before.end); + self.before_hunk_len += before.end - before.start; + self.after_hunk_len += after.end - after.start; + self.print_tokens( + &self.before[before.start as usize..before.end as usize], + '-', + ); + self.print_tokens(&self.after[after.start as usize..after.end as usize], '+'); + } + + fn finish(mut self) -> Self::Out { + self.flush(); + self.dst + } +} + /// Computes a diff between two strings, returning a vector of old and new row /// ranges. pub fn line_diff(old_text: &str, new_text: &str) -> Vec<(Range, Range)> { @@ -327,4 +441,30 @@ mod tests { let patch = unified_diff(old_text, new_text); assert_eq!(apply_diff_patch(old_text, &patch).unwrap(), new_text); } + + #[test] + fn test_unified_diff_with_offsets() { + let old_text = "foo\nbar\nbaz\n"; + let new_text = "foo\nBAR\nbaz\n"; + + let expected_diff_body = " foo\n-bar\n+BAR\n baz\n"; + + let diff_no_offset = unified_diff(old_text, new_text); + assert_eq!( + diff_no_offset, + format!("@@ -1,3 +1,3 @@\n{}", expected_diff_body) + ); + + let diff_with_offset = unified_diff_with_offsets(old_text, new_text, 9, 11); + assert_eq!( + diff_with_offset, + format!("@@ -10,3 +12,3 @@\n{}", expected_diff_body) + ); + + let diff_with_offset = unified_diff_with_offsets(old_text, new_text, 99, 104); + assert_eq!( + diff_with_offset, + format!("@@ -100,3 +105,3 @@\n{}", expected_diff_body) + ); + } } diff --git a/crates/project/src/git_store.rs b/crates/project/src/git_store.rs index d490a2cfdc843a1984bf3f719692af2dcf39aaaa..9ae4f36a497b63ae63ea09440f76fb8823380f5d 100644 --- a/crates/project/src/git_store.rs +++ b/crates/project/src/git_store.rs @@ -5756,6 +5756,7 @@ impl Repository { cx.spawn(|_: &mut AsyncApp| async move { rx.await? }) } + fn load_blob_content(&mut self, oid: Oid, cx: &App) -> Task> { let repository_id = self.snapshot.id; let rx = self.send_job(None, move |state, _| async move { diff --git a/crates/settings/src/merge_from.rs b/crates/settings/src/merge_from.rs index 30ad0d3671a76cc614773030a00efda231657b4e..0a11cd463d6165326ce4f593882de85baf6e72c3 100644 --- a/crates/settings/src/merge_from.rs +++ b/crates/settings/src/merge_from.rs @@ -56,6 +56,7 @@ merge_from_overwrites!( std::sync::Arc, gpui::SharedString, std::path::PathBuf, + std::sync::Arc, gpui::Modifiers, gpui::FontFeatures, gpui::FontWeight diff --git a/crates/settings/src/settings_content/language.rs b/crates/settings/src/settings_content/language.rs index cf8cf7b63589e84a96e6b9d92f23a4488479d1f3..47e6da5d7b44d687c6c6cddbda8167efeb2e5b34 100644 --- a/crates/settings/src/settings_content/language.rs +++ b/crates/settings/src/settings_content/language.rs @@ -1,4 +1,4 @@ -use std::num::NonZeroU32; +use std::{num::NonZeroU32, path::Path}; use collections::{HashMap, HashSet}; use gpui::{Modifiers, SharedString}; @@ -167,6 +167,8 @@ pub struct EditPredictionSettingsContent { /// Whether edit predictions are enabled in the assistant prompt editor. /// This has no effect if globally disabled. pub enabled_in_text_threads: Option, + /// The directory where manually captured edit prediction examples are stored. + pub examples_dir: Option>, } #[with_fallible_options] From 71298e694936cd0fc748bc77671cf4d2b5c91ea4 Mon Sep 17 00:00:00 2001 From: Finn Evers Date: Mon, 22 Dec 2025 23:08:42 +0100 Subject: [PATCH 608/621] extension_ci: Use larger runners for extension bundling (#45540) `2x4` is not nearly enough for some of the grammars in use, hence change this to a larger runner. Also, reduce the size for the Rust runners a bit, as they don't need to be quite as large for the amount of Rust code we have in extensions. Release Notes: - N/A --- .github/actionlint.yml | 1 + .github/workflows/extension_tests.yml | 4 ++-- tooling/xtask/src/tasks/workflows/extension_tests.rs | 4 ++-- tooling/xtask/src/tasks/workflows/runners.rs | 3 +++ 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/actionlint.yml b/.github/actionlint.yml index 6d8e0107e9b42e71bb7266c0629393b9057e05bc..1c931883da4222c92f72a562d3cd58303ee35a06 100644 --- a/.github/actionlint.yml +++ b/.github/actionlint.yml @@ -25,6 +25,7 @@ self-hosted-runner: - namespace-profile-32x64-ubuntu-2204 # Namespace Ubuntu 24.04 (like ubuntu-latest) - namespace-profile-2x4-ubuntu-2404 + - namespace-profile-8x32-ubuntu-2404 # Namespace Limited Preview - namespace-profile-8x16-ubuntu-2004-arm-m4 - namespace-profile-8x32-ubuntu-2004-arm-m4 diff --git a/.github/workflows/extension_tests.yml b/.github/workflows/extension_tests.yml index 9f0917e388c74cffed8f342f7504bc111e6f5147..43f26a2be786eeb41161ab5b36cd4ed71a0bd6f8 100644 --- a/.github/workflows/extension_tests.yml +++ b/.github/workflows/extension_tests.yml @@ -51,7 +51,7 @@ jobs: needs: - orchestrate if: needs.orchestrate.outputs.check_rust == 'true' - runs-on: namespace-profile-16x32-ubuntu-2204 + runs-on: namespace-profile-4x8-ubuntu-2204 steps: - name: steps::checkout_repo uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 @@ -79,7 +79,7 @@ jobs: needs: - orchestrate if: needs.orchestrate.outputs.check_extension == 'true' - runs-on: namespace-profile-2x4-ubuntu-2404 + runs-on: namespace-profile-8x32-ubuntu-2404 steps: - name: steps::checkout_repo uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 diff --git a/tooling/xtask/src/tasks/workflows/extension_tests.rs b/tooling/xtask/src/tasks/workflows/extension_tests.rs index 480559121413ebc88e37300fd632d32b1d79aa91..ae48daa53b24a745219008c8bd365f9fa443d7bb 100644 --- a/tooling/xtask/src/tasks/workflows/extension_tests.rs +++ b/tooling/xtask/src/tasks/workflows/extension_tests.rs @@ -48,7 +48,7 @@ fn run_clippy() -> Step { fn check_rust() -> NamedJob { let job = Job::default() .with_repository_owner_guard() - .runs_on(runners::LINUX_DEFAULT) + .runs_on(runners::LINUX_MEDIUM) .timeout_minutes(3u32) .add_step(steps::checkout_repo()) .add_step(steps::cache_rust_dependencies_namespace()) @@ -66,7 +66,7 @@ pub(crate) fn check_extension() -> NamedJob { let (cache_download, cache_hit) = cache_zed_extension_cli(); let job = Job::default() .with_repository_owner_guard() - .runs_on(runners::LINUX_SMALL) + .runs_on(runners::LINUX_LARGE_RAM) .timeout_minutes(2u32) .add_step(steps::checkout_repo()) .add_step(cache_download) diff --git a/tooling/xtask/src/tasks/workflows/runners.rs b/tooling/xtask/src/tasks/workflows/runners.rs index df98826f8afb7dccb3f9e268fe427634caec8dba..01e79359035380d60033ab2063a9259a730508be 100644 --- a/tooling/xtask/src/tasks/workflows/runners.rs +++ b/tooling/xtask/src/tasks/workflows/runners.rs @@ -8,6 +8,9 @@ pub const LINUX_MEDIUM: Runner = Runner("namespace-profile-4x8-ubuntu-2204"); pub const LINUX_X86_BUNDLER: Runner = Runner("namespace-profile-32x64-ubuntu-2004"); pub const LINUX_ARM_BUNDLER: Runner = Runner("namespace-profile-8x32-ubuntu-2004-arm-m4"); +// Larger Ubuntu runner with glibc 2.39 for extension bundling +pub const LINUX_LARGE_RAM: Runner = Runner("namespace-profile-8x32-ubuntu-2404"); + pub const MAC_DEFAULT: Runner = Runner("self-mini-macos"); pub const WINDOWS_DEFAULT: Runner = Runner("self-32vcpu-windows-2022"); From acee48bfda7b71e1347129bddccfcca85d40b4c7 Mon Sep 17 00:00:00 2001 From: Cole Miller Date: Mon, 22 Dec 2025 21:32:55 -0500 Subject: [PATCH 609/621] git: Fix "Commit Tracked" being shown when files are partially staged (#45551) Release Notes: - N/A --- crates/git_ui/src/git_panel.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs index 1323ee014f76ebde42b8dff436b2abed851d13f0..0540bb55971879c7feb7ebe36276da03684a2b4d 100644 --- a/crates/git_ui/src/git_panel.rs +++ b/crates/git_ui/src/git_panel.rs @@ -3638,7 +3638,7 @@ impl GitPanel { self.entry_count += 1; let is_staging_or_staged = GitPanel::stage_status_for_entry(status_entry, repo) .as_bool() - .unwrap_or(false); + .unwrap_or(true); if repo.had_conflict_on_last_merge_head_change(&status_entry.repo_path) { self.conflicted_count += 1; From 8980333e23bb82a063f7ac250b565e0e8970af9c Mon Sep 17 00:00:00 2001 From: "Joseph T. Lyons" Date: Tue, 23 Dec 2025 03:07:48 -0500 Subject: [PATCH 610/621] Add support for automatic Markdown task list continuation when using uppercase X (#45561) Release Notes: - Added support for automatic Markdown task list continuation when using uppercase X --- crates/editor/src/editor_tests.rs | 11 +++++++++++ crates/languages/src/markdown/config.toml | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rs index 6d53c59d90a8df5d74d0879e965f7f2643deaefa..dc990d69f218dad083c888f75819cadae3f22cb1 100644 --- a/crates/editor/src/editor_tests.rs +++ b/crates/editor/src/editor_tests.rs @@ -29602,6 +29602,17 @@ async fn test_newline_task_list_continuation(cx: &mut TestAppContext) { - [ ] ˇ "}); + // Case 2.1: Works with uppercase checked marker too + cx.set_state(indoc! {" + - [X] completed taskˇ + "}); + cx.update_editor(|e, window, cx| e.newline(&Newline, window, cx)); + cx.wait_for_autoindent_applied().await; + cx.assert_editor_state(indoc! {" + - [X] completed task + - [ ] ˇ + "}); + // Case 3: Cursor position doesn't matter - content after marker is what counts cx.set_state(indoc! {" - [ ] taˇsk diff --git a/crates/languages/src/markdown/config.toml b/crates/languages/src/markdown/config.toml index 423a4c008f6e8a64f3c4e883b0d6e2bde65c88ae..10b1e49757edc106c76e0dc7c591098ebdc6723f 100644 --- a/crates/languages/src/markdown/config.toml +++ b/crates/languages/src/markdown/config.toml @@ -22,7 +22,7 @@ rewrap_prefixes = [ ] unordered_list = ["- ", "* ", "+ "] ordered_list = [{ pattern = "(\\d+)\\. ", format = "{1}. " }] -task_list = { prefixes = ["- [ ] ", "- [x] "], continuation = "- [ ] " } +task_list = { prefixes = ["- [ ] ", "- [x] ", "- [X] "], continuation = "- [ ] " } auto_indent_on_paste = false auto_indent_using_last_non_empty_line = false From ed705c0cbc089374c91b97568e993e3279744298 Mon Sep 17 00:00:00 2001 From: Rocky Shi Date: Wed, 24 Dec 2025 01:28:04 +1300 Subject: [PATCH 611/621] Conditionally display debugger panel icon based on a setting (#45544) Closes [#ISSUE](https://github.com/zed-industries/zed/issues/45506) Release Notes: - Conditionally display the debugger panel icon based on a setting to avoid too many error logs --- crates/debugger_ui/src/debugger_panel.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/debugger_ui/src/debugger_panel.rs b/crates/debugger_ui/src/debugger_panel.rs index 35ce80d3f64e362735c1c020363dbbfc2703a101..0b91b9f28559ac6d7f991b7a0b9822820004148d 100644 --- a/crates/debugger_ui/src/debugger_panel.rs +++ b/crates/debugger_ui/src/debugger_panel.rs @@ -1579,8 +1579,10 @@ impl Panel for DebugPanel { Some(proto::PanelId::DebugPanel) } - fn icon(&self, _window: &Window, _cx: &App) -> Option { - Some(IconName::Debug) + fn icon(&self, _window: &Window, cx: &App) -> Option { + DebuggerSettings::get_global(cx) + .button + .then_some(IconName::Debug) } fn icon_tooltip(&self, _window: &Window, cx: &App) -> Option<&'static str> { From 1281f4672c64cd44ea7f6b9f3d55a7b8ae4dc8e3 Mon Sep 17 00:00:00 2001 From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Date: Tue, 23 Dec 2025 12:09:10 -0300 Subject: [PATCH 612/621] markdown: Add support for right-click menu copy item (#45572) In https://github.com/zed-industries/zed/pull/45440, we're implementing the ability to right-click in the agent panel and copy the rendered markdown. However, that presented itself as not as straightforward as just making the menu item fire the `CopyAsMarkdown` action because any selection in markdown is cleared after a new mouse click, and for the right-click copy menu item to work, we need to persist that selection even after the menu itself is opened and the "Copy" menu item is clicked. This all demanded a bit of work in the markdown file itself, and given we may want to use this functionality for other non-agent thread view markdown use cases in the future, I felt like it'd be better breaking it down into a separate PR that we can more easily track in the future. The context menu still needs to be built in the place where the markdown is created and rendered, though. This PR only adds the infrastructure needed so that this menu can simply fire the `CopyAsMarkdown` and make the copying work. Release Notes: - N/A --- crates/markdown/src/markdown.rs | 42 +++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/crates/markdown/src/markdown.rs b/crates/markdown/src/markdown.rs index 0bc3b9eb726e1782bafb2a31229ea21f308adc6e..2e18055a19c81189adb9a967c3dfe0d1ff55e8ff 100644 --- a/crates/markdown/src/markdown.rs +++ b/crates/markdown/src/markdown.rs @@ -22,9 +22,9 @@ use collections::{HashMap, HashSet}; use gpui::{ AnyElement, App, BorderStyle, Bounds, ClipboardItem, CursorStyle, DispatchPhase, Edges, Entity, FocusHandle, Focusable, FontStyle, FontWeight, GlobalElementId, Hitbox, Hsla, Image, - ImageFormat, KeyContext, Length, MouseDownEvent, MouseEvent, MouseMoveEvent, MouseUpEvent, - Point, ScrollHandle, Stateful, StrikethroughStyle, StyleRefinement, StyledText, Task, - TextLayout, TextRun, TextStyle, TextStyleRefinement, actions, img, point, quad, + ImageFormat, KeyContext, Length, MouseButton, MouseDownEvent, MouseEvent, MouseMoveEvent, + MouseUpEvent, Point, ScrollHandle, Stateful, StrikethroughStyle, StyleRefinement, StyledText, + Task, TextLayout, TextRun, TextStyle, TextStyleRefinement, actions, img, point, quad, }; use language::{Language, LanguageRegistry, Rope}; use parser::CodeBlockMetadata; @@ -112,6 +112,7 @@ pub struct Markdown { options: Options, copied_code_blocks: HashSet, code_block_scroll_handles: HashMap, + context_menu_selected_text: Option, } struct Options { @@ -181,6 +182,7 @@ impl Markdown { }, copied_code_blocks: HashSet::default(), code_block_scroll_handles: HashMap::default(), + context_menu_selected_text: None, }; this.parse(cx); this @@ -205,6 +207,7 @@ impl Markdown { }, copied_code_blocks: HashSet::default(), code_block_scroll_handles: HashMap::default(), + context_menu_selected_text: None, }; this.parse(cx); this @@ -289,6 +292,14 @@ impl Markdown { } } + pub fn selected_text(&self) -> Option { + if self.selection.end <= self.selection.start { + None + } else { + Some(self.source[self.selection.start..self.selection.end].to_string()) + } + } + fn copy(&self, text: &RenderedText, _: &mut Window, cx: &mut Context) { if self.selection.end <= self.selection.start { return; @@ -297,7 +308,11 @@ impl Markdown { cx.write_to_clipboard(ClipboardItem::new_string(text)); } - fn copy_as_markdown(&self, _: &mut Window, cx: &mut Context) { + fn copy_as_markdown(&mut self, _: &mut Window, cx: &mut Context) { + if let Some(text) = self.context_menu_selected_text.take() { + cx.write_to_clipboard(ClipboardItem::new_string(text)); + return; + } if self.selection.end <= self.selection.start { return; } @@ -305,6 +320,10 @@ impl Markdown { cx.write_to_clipboard(ClipboardItem::new_string(text)); } + fn capture_selection_for_context_menu(&mut self) { + self.context_menu_selected_text = self.selected_text(); + } + fn parse(&mut self, cx: &mut Context) { if self.source.is_empty() { return; @@ -665,6 +684,19 @@ impl MarkdownElement { let on_open_url = self.on_url_click.take(); + self.on_mouse_event(window, cx, { + let hitbox = hitbox.clone(); + move |markdown, event: &MouseDownEvent, phase, window, _| { + if phase.capture() + && event.button == MouseButton::Right + && hitbox.is_hovered(window) + { + // Capture selected text so it survives until menu item is clicked + markdown.capture_selection_for_context_menu(); + } + } + }); + self.on_mouse_event(window, cx, { let rendered_text = rendered_text.clone(); let hitbox = hitbox.clone(); @@ -713,7 +745,7 @@ impl MarkdownElement { window.prevent_default(); cx.notify(); } - } else if phase.capture() { + } else if phase.capture() && event.button == MouseButton::Left { markdown.selection = Selection::default(); markdown.pressed_link = None; cx.notify(); From 6bc433ed43f0bc49268e7338d4bec72367141d82 Mon Sep 17 00:00:00 2001 From: zchira Date: Tue, 23 Dec 2025 16:09:46 +0100 Subject: [PATCH 613/621] agent_ui: Add right-click context menu to the thread view (#45440) Closes #23158 Release Notes: - Added a right-click context menu for the thread view in the agent panel. --------- Co-authored-by: Danilo Leal --- crates/agent_ui/src/acp/message_editor.rs | 17 ++++++++++++++++- crates/agent_ui/src/acp/thread_view.rs | 21 ++++++++++++++++----- crates/editor/src/mouse_context_menu.rs | 10 +++++----- 3 files changed, 37 insertions(+), 11 deletions(-) diff --git a/crates/agent_ui/src/acp/message_editor.rs b/crates/agent_ui/src/acp/message_editor.rs index 6bed82accf876aaaba0668d366216c3a965ad8cb..d2c9cf9cb430793d788ed8cb61ecaa01e8f989a8 100644 --- a/crates/agent_ui/src/acp/message_editor.rs +++ b/crates/agent_ui/src/acp/message_editor.rs @@ -31,7 +31,7 @@ use rope::Point; use settings::Settings; use std::{cell::RefCell, fmt::Write, rc::Rc, sync::Arc}; use theme::ThemeSettings; -use ui::prelude::*; +use ui::{ContextMenu, prelude::*}; use util::{ResultExt, debug_panic}; use workspace::{CollaboratorId, Workspace}; use zed_actions::agent::{Chat, PasteRaw}; @@ -132,6 +132,21 @@ impl MessageEditor { placement: Some(ContextMenuPlacement::Above), }); editor.register_addon(MessageEditorAddon::new()); + + editor.set_custom_context_menu(|editor, _point, window, cx| { + let has_selection = editor.has_non_empty_selection(&editor.display_snapshot(cx)); + + Some(ContextMenu::build(window, cx, |menu, _, _| { + menu.action("Cut", Box::new(editor::actions::Cut)) + .action_disabled_when( + !has_selection, + "Copy", + Box::new(editor::actions::Copy), + ) + .action("Paste", Box::new(editor::actions::Paste)) + })) + }); + editor }); let mention_set = diff --git a/crates/agent_ui/src/acp/thread_view.rs b/crates/agent_ui/src/acp/thread_view.rs index 709217fe9f8e532aafa8ac8426473c6c5dacb93d..21790a8f30846af573a9884d40be16aa584122ef 100644 --- a/crates/agent_ui/src/acp/thread_view.rs +++ b/crates/agent_ui/src/acp/thread_view.rs @@ -47,8 +47,9 @@ use terminal_view::terminal_panel::TerminalPanel; use text::Anchor; use theme::{AgentFontSize, ThemeSettings}; use ui::{ - Callout, CommonAnimationExt, Disclosure, Divider, DividerColor, ElevationIndex, KeyBinding, - PopoverMenuHandle, SpinnerLabel, TintColor, Tooltip, WithScrollbar, prelude::*, + Callout, CommonAnimationExt, ContextMenu, Disclosure, Divider, DividerColor, ElevationIndex, + KeyBinding, PopoverMenuHandle, SpinnerLabel, TintColor, Tooltip, WithScrollbar, prelude::*, + right_click_menu, }; use util::{ResultExt, size::format_file_size, time::duration_alt_display}; use workspace::{CollaboratorId, NewTerminal, Workspace}; @@ -2038,7 +2039,7 @@ impl AcpThreadView { } }) .text_xs() - .child(editor.clone().into_any_element()), + .child(editor.clone().into_any_element()) ) .when(editor_focus, |this| { let base_container = h_flex() @@ -2154,7 +2155,6 @@ impl AcpThreadView { if this_is_blank { return None; } - Some( self.render_thinking_block( entry_ix, @@ -2180,7 +2180,18 @@ impl AcpThreadView { .when(is_last, |this| this.pb_4()) .w_full() .text_ui(cx) - .child(message_body) + .child( + right_click_menu(format!("agent_context_menu-{}", entry_ix)) + .trigger(move |_, _, _| message_body) + .menu(move |window, cx| { + let focus = window.focused(cx); + ContextMenu::build(window, cx, move |menu, _, _cx| { + menu.action("Copy", Box::new(markdown::CopyAsMarkdown)) + .when_some(focus, |menu, focus| menu.context(focus)) + }) + }) + .into_any_element(), + ) .into_any() } } diff --git a/crates/editor/src/mouse_context_menu.rs b/crates/editor/src/mouse_context_menu.rs index 7314991bd5e4842f395383888a87b4e2db7e0a0c..1eaaff416ed2415ae147bac361261dc8a3b8bf06 100644 --- a/crates/editor/src/mouse_context_menu.rs +++ b/crates/editor/src/mouse_context_menu.rs @@ -164,11 +164,6 @@ pub fn deploy_context_menu( window.focus(&editor.focus_handle(cx), cx); } - // Don't show context menu for inline editors - if !editor.mode().is_full() { - return; - } - let display_map = editor.display_snapshot(cx); let source_anchor = display_map.display_point_to_anchor(point, text::Bias::Right); let context_menu = if let Some(custom) = editor.custom_context_menu.take() { @@ -179,6 +174,11 @@ pub fn deploy_context_menu( }; menu } else { + // Don't show context menu for inline editors (only applies to default menu) + if !editor.mode().is_full() { + return; + } + // Don't show the context menu if there isn't a project associated with this editor let Some(project) = editor.project.clone() else { return; From fdb8e71b4302057431df1bae486700be1722e9af Mon Sep 17 00:00:00 2001 From: Daniel Byiringiro Date: Tue, 23 Dec 2025 15:15:58 +0000 Subject: [PATCH 614/621] docs: Remove reference to outdated curated issues board (#45568) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The documentation referenced a “Curated board of issues” GitHub Project that no longer exists. The linked project returns a 404, and only three public projects are currently available under zed-industries. This PR removes the outdated reference. Documentation-only change. Release Notes: - N/A --- CONTRIBUTING.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f7aceadce18788ae2b8bb9d0fe4b5f16225e70d2..713546387db36765c2fba3d15b59a87918d71198 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -23,7 +23,6 @@ In particular we love PRs that are: If you're looking for concrete ideas: -- [Curated board of issues](https://github.com/orgs/zed-industries/projects/69) suitable for everyone from first-time contributors to seasoned community champions. - [Triaged bugs with confirmed steps to reproduce](https://github.com/zed-industries/zed/issues?q=is%3Aissue%20state%3Aopen%20type%3ABug%20label%3Astate%3Areproducible). - [Area labels](https://github.com/zed-industries/zed/labels?q=area%3A*) to browse bugs in a specific part of the product you care about (after clicking on an area label, add type:Bug to the search). From d43cc46288559f561e94268c72d61fdcb17abbb6 Mon Sep 17 00:00:00 2001 From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Date: Tue, 23 Dec 2025 13:22:42 -0300 Subject: [PATCH 615/621] agent_ui: Add more items in the right-click context menu (#45575) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Follow up to https://github.com/zed-industries/zed/pull/45440 adding an item for "Open Thread as Markdown" and another for scroll to top and scroll to bottom. Screenshot 2025-12-23 at 1  12@2x Release Notes: - N/A --- crates/agent_ui/src/acp/thread_view.rs | 83 +++++++++++++++++++++----- 1 file changed, 68 insertions(+), 15 deletions(-) diff --git a/crates/agent_ui/src/acp/thread_view.rs b/crates/agent_ui/src/acp/thread_view.rs index 21790a8f30846af573a9884d40be16aa584122ef..f8a849d1b40530c8d00c2709972bd3d64171dc7a 100644 --- a/crates/agent_ui/src/acp/thread_view.rs +++ b/crates/agent_ui/src/acp/thread_view.rs @@ -47,9 +47,9 @@ use terminal_view::terminal_panel::TerminalPanel; use text::Anchor; use theme::{AgentFontSize, ThemeSettings}; use ui::{ - Callout, CommonAnimationExt, ContextMenu, Disclosure, Divider, DividerColor, ElevationIndex, - KeyBinding, PopoverMenuHandle, SpinnerLabel, TintColor, Tooltip, WithScrollbar, prelude::*, - right_click_menu, + Callout, CommonAnimationExt, ContextMenu, ContextMenuEntry, Disclosure, Divider, DividerColor, + ElevationIndex, KeyBinding, PopoverMenuHandle, SpinnerLabel, TintColor, Tooltip, WithScrollbar, + prelude::*, right_click_menu, }; use util::{ResultExt, size::format_file_size, time::duration_alt_display}; use workspace::{CollaboratorId, NewTerminal, Workspace}; @@ -2180,18 +2180,7 @@ impl AcpThreadView { .when(is_last, |this| this.pb_4()) .w_full() .text_ui(cx) - .child( - right_click_menu(format!("agent_context_menu-{}", entry_ix)) - .trigger(move |_, _, _| message_body) - .menu(move |window, cx| { - let focus = window.focused(cx); - ContextMenu::build(window, cx, move |menu, _, _cx| { - menu.action("Copy", Box::new(markdown::CopyAsMarkdown)) - .when_some(focus, |menu, focus| menu.context(focus)) - }) - }) - .into_any_element(), - ) + .child(self.render_message_context_menu(entry_ix, message_body, cx)) .into_any() } } @@ -2298,6 +2287,70 @@ impl AcpThreadView { } } + fn render_message_context_menu( + &self, + entry_ix: usize, + message_body: AnyElement, + cx: &Context, + ) -> AnyElement { + let entity = cx.entity(); + let workspace = self.workspace.clone(); + + right_click_menu(format!("agent_context_menu-{}", entry_ix)) + .trigger(move |_, _, _| message_body) + .menu(move |window, cx| { + let focus = window.focused(cx); + let entity = entity.clone(); + let workspace = workspace.clone(); + + ContextMenu::build(window, cx, move |menu, _, cx| { + let is_at_top = entity.read(cx).list_state.logical_scroll_top().item_ix == 0; + + let scroll_item = if is_at_top { + ContextMenuEntry::new("Scroll to Bottom").handler({ + let entity = entity.clone(); + move |_, cx| { + entity.update(cx, |this, cx| { + this.scroll_to_bottom(cx); + }); + } + }) + } else { + ContextMenuEntry::new("Scroll to Top").handler({ + let entity = entity.clone(); + move |_, cx| { + entity.update(cx, |this, cx| { + this.scroll_to_top(cx); + }); + } + }) + }; + + let open_thread_as_markdown = ContextMenuEntry::new("Open Thread as Markdown") + .handler({ + let entity = entity.clone(); + let workspace = workspace.clone(); + move |window, cx| { + if let Some(workspace) = workspace.upgrade() { + entity + .update(cx, |this, cx| { + this.open_thread_as_markdown(workspace, window, cx) + }) + .detach_and_log_err(cx); + } + } + }); + + menu.when_some(focus, |menu, focus| menu.context(focus)) + .action("Copy", Box::new(markdown::CopyAsMarkdown)) + .separator() + .item(scroll_item) + .item(open_thread_as_markdown) + }) + }) + .into_any_element() + } + fn tool_card_header_bg(&self, cx: &Context) -> Hsla { cx.theme() .colors() From 9f90c1a1b7b77c4ac162b0a0e5f730f5b2637635 Mon Sep 17 00:00:00 2001 From: Xiaobo Liu Date: Wed, 24 Dec 2025 01:11:56 +0800 Subject: [PATCH 616/621] git_ui: Show copy-SHA button on commit header hover (#45478) Release Notes: - git: Added the ability to copy a commit's SHA in the commit view. --------- Signed-off-by: Xiaobo Liu Co-authored-by: Danilo Leal --- crates/git_ui/src/commit_view.rs | 70 +++++++++++++++++++++++++++----- 1 file changed, 59 insertions(+), 11 deletions(-) diff --git a/crates/git_ui/src/commit_view.rs b/crates/git_ui/src/commit_view.rs index 7a4fdc2c73741e5834ac172df28ba5ac023ec20b..fd29328c058e4ce7aed0f4015c99c3788aceb6c1 100644 --- a/crates/git_ui/src/commit_view.rs +++ b/crates/git_ui/src/commit_view.rs @@ -8,9 +8,9 @@ use git::{ parse_git_remote_url, }; use gpui::{ - AnyElement, App, AppContext as _, AsyncApp, AsyncWindowContext, Context, Element, Entity, - EventEmitter, FocusHandle, Focusable, InteractiveElement, IntoElement, ParentElement, - PromptLevel, Render, Styled, Task, WeakEntity, Window, actions, + AnyElement, App, AppContext as _, AsyncApp, AsyncWindowContext, ClipboardItem, Context, + Element, Entity, EventEmitter, FocusHandle, Focusable, InteractiveElement, IntoElement, + ParentElement, PromptLevel, Render, Styled, Task, WeakEntity, Window, actions, }; use language::{ Anchor, Buffer, Capability, DiskState, File, LanguageRegistry, LineEnding, OffsetRangeExt as _, @@ -24,7 +24,7 @@ use std::{ sync::Arc, }; use theme::ActiveTheme; -use ui::{DiffStat, Tooltip, prelude::*}; +use ui::{ButtonLike, DiffStat, Tooltip, prelude::*}; use util::{ResultExt, paths::PathStyle, rel_path::RelPath, truncate_and_trailoff}; use workspace::item::TabTooltipContent; use workspace::{ @@ -383,6 +383,7 @@ impl CommitView { fn render_header(&self, window: &mut Window, cx: &mut Context) -> impl IntoElement { let commit = &self.commit; let author_name = commit.author_name.clone(); + let commit_sha = commit.sha.clone(); let commit_date = time::OffsetDateTime::from_unix_timestamp(commit.commit_timestamp) .unwrap_or_else(|_| time::OffsetDateTime::now_utc()); let local_offset = time::UtcOffset::current_local_offset().unwrap_or(time::UtcOffset::UTC); @@ -429,6 +430,19 @@ impl CommitView { .full_width() }); + let clipboard_has_link = cx + .read_from_clipboard() + .and_then(|entry| entry.text()) + .map_or(false, |clipboard_text| { + clipboard_text.trim() == commit_sha.as_ref() + }); + + let (copy_icon, copy_icon_color) = if clipboard_has_link { + (IconName::Check, Color::Success) + } else { + (IconName::Copy, Color::Muted) + }; + h_flex() .border_b_1() .border_color(cx.theme().colors().border_variant) @@ -454,13 +468,47 @@ impl CommitView { h_flex() .gap_1() .child(Label::new(author_name).color(Color::Default)) - .child( - Label::new(format!("Commit:{}", commit.sha)) - .color(Color::Muted) - .size(LabelSize::Small) - .truncate() - .buffer_font(cx), - ), + .child({ + ButtonLike::new("sha") + .child( + h_flex() + .group("sha_btn") + .size_full() + .max_w_32() + .gap_0p5() + .child( + Label::new(commit_sha.clone()) + .color(Color::Muted) + .size(LabelSize::Small) + .truncate() + .buffer_font(cx), + ) + .child( + div().visible_on_hover("sha_btn").child( + Icon::new(copy_icon) + .color(copy_icon_color) + .size(IconSize::Small), + ), + ), + ) + .tooltip({ + let commit_sha = commit_sha.clone(); + move |_, cx| { + Tooltip::with_meta( + "Copy Commit SHA", + None, + commit_sha.clone(), + cx, + ) + } + }) + .on_click(move |_, _, cx| { + cx.stop_propagation(); + cx.write_to_clipboard(ClipboardItem::new_string( + commit_sha.to_string(), + )); + }) + }), ) .child( h_flex() From 251033f88f4559b3f8faf7272b939bd7352f1e55 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Tue, 23 Dec 2025 21:10:51 +0200 Subject: [PATCH 617/621] Fix the argument order when starting devcontainers (#45584) Release Notes: - (Preview only) Fix devcontainers not starting when certain env variables were set Co-authored-by: KyleBarton --- crates/remote/src/transport.rs | 3 +++ crates/remote/src/transport/docker.rs | 16 +++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/crates/remote/src/transport.rs b/crates/remote/src/transport.rs index ebf643352fce8a14d88b7c870b177d2c6b7e7de0..2dedf7ace0d7eab7daf34cc8e183f84ef5f9126a 100644 --- a/crates/remote/src/transport.rs +++ b/crates/remote/src/transport.rs @@ -158,6 +158,9 @@ fn handle_rpc_messages_over_child_process_stdio( } }; let status = remote_proxy_process.status().await?.code().unwrap_or(1); + if status != 0 { + anyhow::bail!("Remote server exited with status {status}"); + } match result { Ok(_) => Ok(status), Err(error) => Err(error), diff --git a/crates/remote/src/transport/docker.rs b/crates/remote/src/transport/docker.rs index 9c14aa874941a5cdcd824d4adaeb41d694e347d8..1d84181285b19b2f1e2cca57783e77ab74b6bca2 100644 --- a/crates/remote/src/transport/docker.rs +++ b/crates/remote/src/transport/docker.rs @@ -582,19 +582,21 @@ impl RemoteConnection for DockerExecConnection { return Task::ready(Err(anyhow!("Remote binary path not set"))); }; - let mut docker_args = vec![ - "exec".to_string(), - "-w".to_string(), - self.remote_dir_for_server.clone(), - "-i".to_string(), - self.connection_options.container_id.to_string(), - ]; + let mut docker_args = vec!["exec".to_string()]; for env_var in ["RUST_LOG", "RUST_BACKTRACE", "ZED_GENERATE_MINIDUMPS"] { if let Some(value) = std::env::var(env_var).ok() { docker_args.push("-e".to_string()); docker_args.push(format!("{}='{}'", env_var, value)); } } + + docker_args.extend([ + "-w".to_string(), + self.remote_dir_for_server.clone(), + "-i".to_string(), + self.connection_options.container_id.to_string(), + ]); + let val = remote_binary_relpath .display(self.path_style()) .into_owned(); From 0ce484e66c9b77db4da4dd75372046dc7c7ab7b5 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Tue, 23 Dec 2025 21:27:09 +0200 Subject: [PATCH 618/621] Do not trust Docker hosts by default (#45587) It's still possible to leak secrets by spawning odd MCP/LSP servers from `.zed/settings.json` Release Notes: - N/A --- crates/project/src/project.rs | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index fc0779dd1f03729e4812c8cac09a06a6d56d5772..9b8e0790f829e8707e42d2a9581785f4c36685dd 100644 --- a/crates/project/src/project.rs +++ b/crates/project/src/project.rs @@ -1293,34 +1293,13 @@ impl Project { cx.subscribe(&worktree_store, Self::on_worktree_store_event) .detach(); if init_worktree_trust { - let trust_remote_project = match &connection_options { - RemoteConnectionOptions::Ssh(..) | RemoteConnectionOptions::Wsl(..) => false, - RemoteConnectionOptions::Docker(..) => true, - }; - let remote_host = RemoteHostLocation::from(connection_options); trusted_worktrees::track_worktree_trust( worktree_store.clone(), - Some(remote_host.clone()), + Some(RemoteHostLocation::from(connection_options)), None, Some((remote_proto.clone(), REMOTE_SERVER_PROJECT_ID)), cx, ); - if trust_remote_project { - if let Some(trusted_worktres) = TrustedWorktrees::try_get_global(cx) { - trusted_worktres.update(cx, |trusted_worktres, cx| { - trusted_worktres.trust( - worktree_store - .read(cx) - .worktrees() - .map(|worktree| worktree.read(cx).id()) - .map(PathTrust::Worktree) - .collect(), - Some(remote_host), - cx, - ); - }) - } - } } let weak_self = cx.weak_entity(); From a34fe06bb13a4b0d5c9145515f5f4a8f48e2a61d Mon Sep 17 00:00:00 2001 From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Date: Tue, 23 Dec 2025 18:14:58 -0300 Subject: [PATCH 619/621] agent_ui: Allow "token reached" callout to be dismissed (#45595) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It was previously impossible to dismiss the "token usage reaching/reached the limit" callout. Screenshot 2025-12-23 at 5  49@2x Release Notes: - N/A --- crates/agent_ui/src/acp/thread_view.rs | 41 +++++++++++++++----------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/crates/agent_ui/src/acp/thread_view.rs b/crates/agent_ui/src/acp/thread_view.rs index f8a849d1b40530c8d00c2709972bd3d64171dc7a..6ea9102695cf1206ba9b6ec40d2615dce85f8fd4 100644 --- a/crates/agent_ui/src/acp/thread_view.rs +++ b/crates/agent_ui/src/acp/thread_view.rs @@ -278,6 +278,7 @@ pub struct AcpThreadView { thread_retry_status: Option, thread_error: Option, thread_error_markdown: Option>, + token_limit_callout_dismissed: bool, thread_feedback: ThreadFeedbackState, list_state: ListState, auth_task: Option>, @@ -430,13 +431,13 @@ impl AcpThreadView { message_editor, model_selector: None, profile_selector: None, - notifications: Vec::new(), notification_subscriptions: HashMap::default(), list_state: list_state, thread_retry_status: None, thread_error: None, thread_error_markdown: None, + token_limit_callout_dismissed: false, thread_feedback: Default::default(), auth_task: None, expanded_tool_calls: HashSet::default(), @@ -1394,6 +1395,7 @@ impl AcpThreadView { fn clear_thread_error(&mut self, cx: &mut Context) { self.thread_error = None; self.thread_error_markdown = None; + self.token_limit_callout_dismissed = true; cx.notify(); } @@ -5391,22 +5393,26 @@ impl AcpThreadView { cx.notify(); } - fn render_token_limit_callout( - &self, - line_height: Pixels, - cx: &mut Context, - ) -> Option { + fn render_token_limit_callout(&self, cx: &mut Context) -> Option { + if self.token_limit_callout_dismissed { + return None; + } + let token_usage = self.thread()?.read(cx).token_usage()?; let ratio = token_usage.ratio(); - let (severity, title) = match ratio { + let (severity, icon, title) = match ratio { acp_thread::TokenUsageRatio::Normal => return None, - acp_thread::TokenUsageRatio::Warning => { - (Severity::Warning, "Thread reaching the token limit soon") - } - acp_thread::TokenUsageRatio::Exceeded => { - (Severity::Error, "Thread reached the token limit") - } + acp_thread::TokenUsageRatio::Warning => ( + Severity::Warning, + IconName::Warning, + "Thread reaching the token limit soon", + ), + acp_thread::TokenUsageRatio::Exceeded => ( + Severity::Error, + IconName::XCircle, + "Thread reached the token limit", + ), }; let burn_mode_available = self.as_native_thread(cx).is_some_and(|thread| { @@ -5426,7 +5432,7 @@ impl AcpThreadView { Some( Callout::new() .severity(severity) - .line_height(line_height) + .icon(icon) .title(title) .description(description) .actions_slot( @@ -5458,7 +5464,8 @@ impl AcpThreadView { })), ) }), - ), + ) + .dismiss_action(self.dismiss_error_button(cx)), ) } @@ -5892,7 +5899,7 @@ impl AcpThreadView { fn dismiss_error_button(&self, cx: &mut Context) -> impl IntoElement { IconButton::new("dismiss", IconName::Close) .icon_size(IconSize::Small) - .tooltip(Tooltip::text("Dismiss Error")) + .tooltip(Tooltip::text("Dismiss")) .on_click(cx.listener({ move |this, _, _, cx| { this.clear_thread_error(cx); @@ -6152,7 +6159,7 @@ impl Render for AcpThreadView { if let Some(usage_callout) = self.render_usage_callout(line_height, cx) { Some(usage_callout.into_any_element()) } else { - self.render_token_limit_callout(line_height, cx) + self.render_token_limit_callout(cx) .map(|token_limit_callout| token_limit_callout.into_any_element()) }, ) From ca478226677e5f7190a5d8933277522780faaaf7 Mon Sep 17 00:00:00 2001 From: Teoh Han Hui Date: Wed, 24 Dec 2025 05:23:28 +0800 Subject: [PATCH 620/621] Associate devcontainer.json with JSONC language (#45593) Release Notes: - N/A --- crates/languages/src/jsonc/config.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/languages/src/jsonc/config.toml b/crates/languages/src/jsonc/config.toml index cb7ad38ec78fbe4a9b04816400375cefa444f055..bc5fd5b6c69468eba7a4a1cccfdc3406cec9175d 100644 --- a/crates/languages/src/jsonc/config.toml +++ b/crates/languages/src/jsonc/config.toml @@ -1,6 +1,6 @@ name = "JSONC" grammar = "jsonc" -path_suffixes = ["jsonc", "bun.lock", "tsconfig.json", "pyrightconfig.json"] +path_suffixes = ["jsonc", "bun.lock", "devcontainer.json", "pyrightconfig.json", "tsconfig.json"] line_comments = ["// "] autoclose_before = ",]}" brackets = [ From f03987fb68224e3b7fb993ce2ffaf364836a003c Mon Sep 17 00:00:00 2001 From: Marco Mihai Condrache <52580954+marcocondrache@users.noreply.github.com> Date: Thu, 25 Dec 2025 20:29:17 +0100 Subject: [PATCH 621/621] search: Remove intermediate allocation (#45633) Release Notes: - N/A --------- Signed-off-by: Marco Mihai Condrache <52580954+marcocondrache@users.noreply.github.com> --- crates/search/src/project_search.rs | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/crates/search/src/project_search.rs b/crates/search/src/project_search.rs index e0bbf58ce6f1d0c752914bbbfa6fcdf70ea30175..5fbb6788f2d30a4649fd9b5a6f7436488c051b34 100644 --- a/crates/search/src/project_search.rs +++ b/crates/search/src/project_search.rs @@ -1531,14 +1531,20 @@ impl ProjectSearchView { fn update_match_index(&mut self, cx: &mut Context) { let results_editor = self.results_editor.read(cx); - let match_ranges = self.entity.read(cx).match_ranges.clone(); - let new_index = active_match_index( - Direction::Next, - &match_ranges, - &results_editor.selections.newest_anchor().head(), - &results_editor.buffer().read(cx).snapshot(cx), - ); - self.highlight_matches(&match_ranges, new_index, cx); + let newest_anchor = results_editor.selections.newest_anchor().head(); + let buffer_snapshot = results_editor.buffer().read(cx).snapshot(cx); + let new_index = self.entity.update(cx, |this, cx| { + let new_index = active_match_index( + Direction::Next, + &this.match_ranges, + &newest_anchor, + &buffer_snapshot, + ); + + self.highlight_matches(&this.match_ranges, new_index, cx); + new_index + }); + if self.active_match_index != new_index { self.active_match_index = new_index; cx.notify(); @@ -1550,7 +1556,7 @@ impl ProjectSearchView { &self, match_ranges: &[Range], active_index: Option, - cx: &mut Context, + cx: &mut App, ) { self.results_editor.update(cx, |editor, cx| { editor.highlight_background::(