diff --git a/.gitignore b/.gitignore index 58b351c..0cb6a8d 100644 --- a/.gitignore +++ b/.gitignore @@ -16,9 +16,9 @@ dist-ssr/ # Environments (test venvs created by the integration suite / spikes) .venv/ venv/ -# Verifying an environment feature by hand needs a venv the GUI can *see*, and `env_add_manual` -# (Browse…) is still owed — so venv_scan's "below the working directory" is the only way in, which -# means the repo root. `.venv-oldpip` for the pip-upkeep floor, and whatever the next one needs. +# Scratch venvs for verifying by hand. Note that the GUI will only ever *see* one named exactly +# `.venv`, `venv`, `env` or `.env` in the working directory — `envs::venv_scan` matches that fixed +# list and `env_add_manual` (Browse…) is still owed — so a suffixed one here is CLI-only. /.venv-*/ __pycache__/ *.py[cod] diff --git a/crates/pipdock-cli/src/run.rs b/crates/pipdock-cli/src/run.rs index 8cc3e22..156cc70 100644 --- a/crates/pipdock-cli/src/run.rs +++ b/crates/pipdock-cli/src/run.rs @@ -197,6 +197,11 @@ pub async fn env_list(opts: &GlobalOpts) -> Result { "hiddenUserSite": p.env.hidden_user_site, "packages": p.dists.len(), "envHash": envs::env_hash(path), + // Same field the GUI's EnvRow carries, out of the same list, so `env list` + // and the Environments screen cannot disagree about which pip is installed. + "pipVersion": p.dists.iter() + .find(|d| d.name.as_str() == "pip") + .map(|d| d.version.0.clone()), }), Err(e) => serde_json::json!({ "interpreter": path, diff --git a/src-tauri/src/commands.rs b/src-tauri/src/commands.rs index 9407538..3fea2dc 100644 --- a/src-tauri/src/commands.rs +++ b/src-tauri/src/commands.rs @@ -87,6 +87,19 @@ pub struct EnvRow { /// How many distributions the probe saw. #[serde(skip_serializing_if = "Option::is_none")] pub packages: Option, + /// The environment's own pip, when it has one (PRD P0-10). + /// + /// **Read out of the probe's distribution list, not from `engine_info`.** `engine_info` spawns + /// two subprocesses per call — pip's `--version` and uv's — so calling it per row would add + /// 2N spawns to the landing screen on top of the N `probe.py` runs already happening. pip is + /// an ordinary distribution in site-packages and the probe has already read it; this is the + /// same list `packages` counts. + /// + /// `None` means the probe found no pip, which is a real state — a `--without-pip` venv, or a + /// system Python where `-I` hid a user-site install (ARCHITECTURE §4's trade-off, disclosed as + /// `hidden_user_site`). It is not "unknown". + #[serde(skip_serializing_if = "Option::is_none")] + pub pip_version: Option, /// Present when the probe failed; the row renders as unusable with this code. #[serde(skip_serializing_if = "Option::is_none")] pub error: Option, @@ -101,6 +114,7 @@ async fn probe_row(path: std::path::PathBuf, source: EnvSource) -> EnvRow { source, env_hash, packages: Some(probed.dists.len()), + pip_version: pip_version_of(&probed.dists), env: Some(probed.env), error: None, }, @@ -110,11 +124,23 @@ async fn probe_row(path: std::path::PathBuf, source: EnvSource) -> EnvRow { env_hash, env: None, packages: None, + pip_version: None, error: Some(e.into()), }, } } +/// pip's version out of a probed distribution list. +/// +/// Names arrive PEP 503-normalized from `PkgName::parse`, so an exact match is enough — there is no +/// casing or separator variant of `pip` to worry about. +fn pip_version_of(dists: &[pipdock_core::Dist]) -> Option { + dists + .iter() + .find(|d| d.name.as_str() == "pip") + .map(|d| d.version.0.clone()) +} + /// Discover environments, streaming `scan-progress` as each source is read. /// /// # Errors @@ -135,7 +161,12 @@ pub async fn env_scan(app: tauri::AppHandle) -> Wire> { Ok(rows) } -/// Probe one interpreter, for the manual *Browse…* path. +/// Probe one interpreter, for the manual *Browse…* path — and to refresh a single row. +/// +/// The second use is what P0-10 needs: after `pip_upgrade` the Environments row must show the new +/// version without a full rescan, and one probe is the cheapest honest way to get it. That makes +/// carrying `pip_version` here load-bearing rather than tidy — a row refreshed through a path that +/// omitted it would blank the field it was refreshed to update. /// /// # Errors /// `PD-ENV-001` when there is no usable interpreter there, `PD-ENV-003` when the probe output @@ -149,6 +180,7 @@ pub async fn env_probe(interpreter: String) -> Wire { source: EnvSource::Manual, env_hash: envs::env_hash(&path), packages: Some(probed.dists.len()), + pip_version: pip_version_of(&probed.dists), env: Some(probed.env), error: None, }) diff --git a/ui/src/ipc/index.ts b/ui/src/ipc/index.ts index 1153fbb..85f1ea2 100644 --- a/ui/src/ipc/index.ts +++ b/ui/src/ipc/index.ts @@ -124,6 +124,14 @@ export interface EnvRow { envHash: string env?: PyEnv packages?: number + /** + * The environment's own pip, out of the probe's distribution list — not `engine_info`, which + * would add two subprocesses per row to the landing screen. + * + * Absent means the probe found no pip, which is a real state (`--without-pip`, or `-I` hiding a + * user-site install), not "not yet known". + */ + pipVersion?: string error?: PdError }