windows: Add support for fetching shell environment in remote projects (#39831)
Closes #39216 Note that this affects all platforms, I'm just using the prefix to make auto-cherry-picking easier. Release Notes: - Fixed shell commands run by agents failing to find installed programs in some cases.
This commit is contained in:
@@ -50,6 +50,7 @@ pub struct HeadlessProject {
|
||||
pub languages: Arc<LanguageRegistry>,
|
||||
pub extensions: Entity<HeadlessExtensionStore>,
|
||||
pub git_store: Entity<GitStore>,
|
||||
pub environment: Entity<ProjectEnvironment>,
|
||||
// Used mostly to keep alive the toolchain store for RPC handlers.
|
||||
// Local variant is used within LSP store, but that's a separate entity.
|
||||
pub _toolchain_store: Entity<ToolchainStore>,
|
||||
@@ -199,7 +200,7 @@ impl HeadlessProject {
|
||||
let mut agent_server_store = AgentServerStore::local(
|
||||
node_runtime.clone(),
|
||||
fs.clone(),
|
||||
environment,
|
||||
environment.clone(),
|
||||
http_client.clone(),
|
||||
cx,
|
||||
);
|
||||
@@ -255,6 +256,7 @@ impl HeadlessProject {
|
||||
session.add_entity_request_handler(Self::handle_open_new_buffer);
|
||||
session.add_entity_request_handler(Self::handle_find_search_candidates);
|
||||
session.add_entity_request_handler(Self::handle_open_server_settings);
|
||||
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(BufferStore::handle_update_buffer);
|
||||
@@ -295,6 +297,7 @@ impl HeadlessProject {
|
||||
languages,
|
||||
extensions,
|
||||
git_store,
|
||||
environment,
|
||||
_toolchain_store: toolchain_store,
|
||||
}
|
||||
}
|
||||
@@ -764,6 +767,26 @@ impl HeadlessProject {
|
||||
|
||||
Ok(proto::GetProcessesResponse { processes })
|
||||
}
|
||||
|
||||
async fn handle_get_directory_environment(
|
||||
this: Entity<Self>,
|
||||
envelope: TypedEnvelope<proto::GetDirectoryEnvironment>,
|
||||
mut cx: AsyncApp,
|
||||
) -> Result<proto::DirectoryEnvironment> {
|
||||
let shell = task::Shell::from_proto(envelope.payload.shell.context("missing shell")?)?;
|
||||
let directory = PathBuf::from(envelope.payload.directory);
|
||||
let environment = this
|
||||
.update(&mut cx, |this, cx| {
|
||||
this.environment.update(cx, |environment, cx| {
|
||||
environment.get_local_directory_environment(&shell, directory.into(), cx)
|
||||
})
|
||||
})?
|
||||
.await
|
||||
.context("failed to get directory environment")?
|
||||
.into_iter()
|
||||
.collect();
|
||||
Ok(proto::DirectoryEnvironment { environment })
|
||||
}
|
||||
}
|
||||
|
||||
fn prompt_to_proto(
|
||||
|
||||
Reference in New Issue
Block a user