From 5a06069f686809e7ccd9faebbe61e2697d49339c Mon Sep 17 00:00:00 2001 From: "zed-zippy[bot]" <234243425+zed-zippy[bot]@users.noreply.github.com> Date: Thu, 11 Dec 2025 15:08:31 +0000 Subject: [PATCH] agent_ui: Fix `project path not found` error when pasting code from other project (#44555) (cherry-pick to preview) (#44633) Cherry-pick of #44555 to preview ---- The problem with inserting the absolute paths is that the agent will try to read them. However, we don't allow the agent to read files outside the current project. For now, we will only insert the crease in case the code that is getting pasted is from the same project Release Notes: - Fixed an issue where pasting code into the agent panel from another window would show an error Co-authored-by: Bennet Bo Fenner --- crates/agent_ui/src/acp/message_editor.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/crates/agent_ui/src/acp/message_editor.rs b/crates/agent_ui/src/acp/message_editor.rs index bc293c98a84540c1e00d9895be2cc05b0bdd08a5..5e9c55cc56868ac2e7db65043d13eb46efcd89a6 100644 --- a/crates/agent_ui/src/acp/message_editor.rs +++ b/crates/agent_ui/src/acp/message_editor.rs @@ -565,8 +565,26 @@ impl MessageEditor { if let Some((workspace, selections)) = self.workspace.upgrade().zip(editor_clipboard_selections) { - cx.stop_propagation(); + 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; + } + } + cx.stop_propagation(); let insertion_target = self .editor .read(cx)