Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 4 additions & 13 deletions crates/acp_thread/src/acp_thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ mod diff;
mod mention;
mod terminal;

use ::terminal::terminal_settings::TerminalSettings;
use agent_settings::AgentSettings;
use collections::HashSet;
pub use connection::*;
Expand All @@ -12,7 +11,7 @@ use language::language_settings::FormatOnSave;
pub use mention::*;
use project::lsp_store::{FormatTrigger, LspFormatTarget};
use serde::{Deserialize, Serialize};
use settings::{Settings as _, SettingsLocation};
use settings::Settings as _;
use task::{Shell, ShellBuilder};
pub use terminal::*;

Expand Down Expand Up @@ -2113,17 +2112,9 @@ impl AcpThread {
) -> Task<Result<Entity<Terminal>>> {
let env = match &cwd {
Some(dir) => self.project.update(cx, |project, cx| {
let worktree = project.find_worktree(dir.as_path(), cx);
let shell = TerminalSettings::get(
worktree.as_ref().map(|(worktree, path)| SettingsLocation {
worktree_id: worktree.read(cx).id(),
path: &path,
}),
cx,
)
.shell
.clone();
project.directory_environment(&shell, dir.as_path().into(), cx)
project.environment().update(cx, |env, cx| {
env.directory_environment(dir.as_path().into(), cx)
})
}),
None => Task::ready(None).shared(),
};
Expand Down
16 changes: 3 additions & 13 deletions crates/acp_thread/src/terminal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ use gpui::{App, AppContext, AsyncApp, Context, Entity, Task};
use language::LanguageRegistry;
use markdown::Markdown;
use project::Project;
use settings::{Settings as _, SettingsLocation};
use std::{path::PathBuf, process::ExitStatus, sync::Arc, time::Instant};
use task::Shell;
use terminal::terminal_settings::TerminalSettings;
use util::get_default_system_shell_preferring_bash;

pub struct Terminal {
Expand Down Expand Up @@ -187,17 +185,9 @@ pub async fn create_terminal_entity(
let mut env = if let Some(dir) = &cwd {
project
.update(cx, |project, cx| {
let worktree = project.find_worktree(dir.as_path(), cx);
let shell = TerminalSettings::get(
worktree.as_ref().map(|(worktree, path)| SettingsLocation {
worktree_id: worktree.read(cx).id(),
path: &path,
}),
cx,
)
.shell
.clone();
project.directory_environment(&shell, dir.clone().into(), cx)
project.environment().update(cx, |env, cx| {
env.directory_environment(dir.clone().into(), cx)
})
})?
.await
.unwrap_or_default()
Expand Down
12 changes: 7 additions & 5 deletions crates/editor/src/lsp_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ async fn lsp_task_context(
buffer: &Entity<Buffer>,
cx: &mut AsyncApp,
) -> Option<TaskContext> {
let worktree_store = project
.read_with(cx, |project, _| project.worktree_store())
let (worktree_store, environment) = project
.read_with(cx, |project, _| {
(project.worktree_store(), project.environment().clone())
})
.ok()?;

let worktree_abs_path = cx
Expand All @@ -74,9 +76,9 @@ async fn lsp_task_context(
})
.ok()?;

let project_env = project
.update(cx, |project, cx| {
project.buffer_environment(buffer, &worktree_store, cx)
let project_env = environment
.update(cx, |environment, cx| {
environment.buffer_environment(buffer, &worktree_store, cx)
})
.ok()?
.await;
Expand Down
16 changes: 10 additions & 6 deletions crates/project/src/agent_server_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1039,7 +1039,7 @@ impl ExternalAgentServer for LocalGemini {
cx.spawn(async move |cx| {
let mut env = project_environment
.update(cx, |project_environment, cx| {
project_environment.get_local_directory_environment(
project_environment.local_directory_environment(
&Shell::System,
root_dir.clone(),
cx,
Expand Down Expand Up @@ -1135,7 +1135,7 @@ impl ExternalAgentServer for LocalClaudeCode {
cx.spawn(async move |cx| {
let mut env = project_environment
.update(cx, |project_environment, cx| {
project_environment.get_local_directory_environment(
project_environment.local_directory_environment(
&Shell::System,
root_dir.clone(),
cx,
Expand Down Expand Up @@ -1229,7 +1229,7 @@ impl ExternalAgentServer for LocalCodex {
cx.spawn(async move |cx| {
let mut env = project_environment
.update(cx, |project_environment, cx| {
project_environment.get_local_directory_environment(
project_environment.local_directory_environment(
&Shell::System,
root_dir.clone(),
cx,
Expand Down Expand Up @@ -1404,7 +1404,7 @@ impl ExternalAgentServer for LocalExtensionArchiveAgent {
// Get project environment
let mut env = project_environment
.update(cx, |project_environment, cx| {
project_environment.get_local_directory_environment(
project_environment.local_directory_environment(
&Shell::System,
root_dir.clone(),
cx,
Expand Down Expand Up @@ -1587,7 +1587,7 @@ impl ExternalAgentServer for LocalCustomAgent {
cx.spawn(async move |cx| {
let mut env = project_environment
.update(cx, |project_environment, cx| {
project_environment.get_local_directory_environment(
project_environment.local_directory_environment(
&Shell::System,
root_dir.clone(),
cx,
Expand Down Expand Up @@ -1702,6 +1702,8 @@ impl settings::Settings for AllAgentServersSettings {

#[cfg(test)]
mod extension_agent_tests {
use crate::worktree_store::WorktreeStore;

use super::*;
use gpui::TestAppContext;
use std::sync::Arc;
Expand Down Expand Up @@ -1826,7 +1828,9 @@ mod extension_agent_tests {
async fn archive_agent_uses_extension_and_agent_id_for_cache_key(cx: &mut TestAppContext) {
let fs = fs::FakeFs::new(cx.background_executor.clone());
let http_client = http_client::FakeHttpClient::with_404_response();
let project_environment = cx.new(|cx| crate::ProjectEnvironment::new(None, cx));
let worktree_store = cx.new(|_| WorktreeStore::local(false, fs.clone()));
let project_environment =
cx.new(|cx| crate::ProjectEnvironment::new(None, worktree_store.downgrade(), None, cx));

let agent = LocalExtensionArchiveAgent {
fs,
Expand Down
16 changes: 6 additions & 10 deletions crates/project/src/debugger/dap_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ use std::{
path::{Path, PathBuf},
sync::{Arc, Once},
};
use task::{DebugScenario, Shell, SpawnInTerminal, TaskContext, TaskTemplate};
use task::{DebugScenario, SpawnInTerminal, TaskContext, TaskTemplate};
use util::{ResultExt as _, rel_path::RelPath};
use worktree::Worktree;

Expand Down Expand Up @@ -267,8 +267,8 @@ impl DapStore {
let user_env = dap_settings.map(|s| s.env.clone());

let delegate = self.delegate(worktree, console, cx);
let cwd: Arc<Path> = worktree.read(cx).abs_path().as_ref().into();

let worktree = worktree.clone();
cx.spawn(async move |this, cx| {
let mut binary = adapter
.get_binary(
Expand All @@ -287,11 +287,7 @@ impl DapStore {
.unwrap()
.environment
.update(cx, |environment, cx| {
environment.get_local_directory_environment(
&Shell::System,
cwd,
cx,
)
environment.worktree_environment(worktree, cx)
})
})?
.await;
Expand Down Expand Up @@ -607,9 +603,9 @@ impl DapStore {
local_store.node_runtime.clone(),
local_store.http_client.clone(),
local_store.toolchain_store.clone(),
local_store.environment.update(cx, |env, cx| {
env.get_worktree_environment(worktree.clone(), cx)
}),
local_store
.environment
.update(cx, |env, cx| env.worktree_environment(worktree.clone(), cx)),
local_store.is_headless,
))
}
Expand Down
Loading
Loading