Inject venv environment via the toolchain (#36576)

Instead of manually constructing the venv we now ask the python
toolchain for the relevant information, unifying the approach of vent
inspection

Fixes https://github.com/zed-industries/zed/issues/27350

Release Notes:

- Improved the detection of python virtual environments for terminals
and tasks in remote projects.
This commit is contained in:
Lukas Wirth
2025-08-28 14:40:43 +00:00
committed by GitHub
parent 24ee98b3e1
commit 835e5ba662
19 changed files with 725 additions and 672 deletions
+7 -9
View File
@@ -824,7 +824,6 @@ impl WorkspaceDb {
conn.exec_bound(
sql!(
DELETE FROM breakpoints WHERE workspace_id = ?1;
DELETE FROM toolchains WHERE workspace_id = ?1;
)
)?(workspace.id).context("Clearing old breakpoints")?;
@@ -1097,7 +1096,6 @@ impl WorkspaceDb {
query! {
pub async fn delete_workspace_by_id(id: WorkspaceId) -> Result<()> {
DELETE FROM toolchains WHERE workspace_id = ?1;
DELETE FROM workspaces
WHERE workspace_id IS ?
}
@@ -1424,24 +1422,24 @@ impl WorkspaceDb {
&self,
workspace_id: WorkspaceId,
worktree_id: WorktreeId,
relative_path: String,
relative_worktree_path: String,
language_name: LanguageName,
) -> Result<Option<Toolchain>> {
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_path = ?
SELECT name, path, raw_json FROM toolchains WHERE workspace_id = ? AND language_name = ? AND worktree_id = ? AND relative_worktree_path = ?
))
.context("Preparing insertion")?;
.context("select toolchain")?;
let toolchain: Vec<(String, String, String)> =
select((workspace_id, language_name.as_ref().to_string(), worktree_id.to_usize(), relative_path))?;
select((workspace_id, language_name.as_ref().to_string(), worktree_id.to_usize(), relative_worktree_path))?;
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()?
as_json: serde_json::Value::from_str(&raw_json).ok()?,
})))
})
.await
@@ -1456,7 +1454,7 @@ impl WorkspaceDb {
.select_bound(sql!(
SELECT name, path, worktree_id, relative_worktree_path, language_name, raw_json FROM toolchains WHERE workspace_id = ?
))
.context("Preparing insertion")?;
.context("select toolchains")?;
let toolchain: Vec<(String, String, u64, String, String, String)> =
select(workspace_id)?;
@@ -1465,7 +1463,7 @@ impl WorkspaceDb {
name: name.into(),
path: path.into(),
language_name: LanguageName::new(&language_name),
as_json: serde_json::Value::from_str(&raw_json).ok()?
as_json: serde_json::Value::from_str(&raw_json).ok()?,
}, WorktreeId::from_proto(worktree_id), Arc::from(relative_worktree_path.as_ref())))).collect())
})
.await