diff --git a/CLAUDE.md b/CLAUDE.md index 106004a..73f94c9 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -47,7 +47,8 @@ failed package never aborts a batch (skip-and-continue, then a `"13 successful, `--dry-run --report -` crashes on Windows/cp1252 (pip 25 *and* 26), data-dependently. 8. **uv writes its plan to stderr**, so classify errors only after a plan-parse attempt. 9. **`env_hash` lowercases the interpreter path on Windows**, or one env splits its pins and - snapshots in two. + snapshots in two — and since 1.6.0 stops at a venv's own `python.exe`, or a `--symlinks` venv + files its pins and snapshots under the Python it was made from. 10. **PipDock enforces `Requires-Python` itself** (`src/compat.rs`) — the engines disagree, and the preview must not depend on which one is selected. @@ -238,8 +239,11 @@ and the installed-build smoke were green: - **The path you check is not the path you run.** `validate_interpreter` canonicalized to compare against PipDock's own venvs and returned that, so a `--symlinks` venv — whose `python.exe` links to its base — was run and stored as the base, and `--env .venv update --all` would have changed - the system Python. Resolve to *decide*; run and store what was given, made absolute. `envHash` - follows links for the same reason, so nothing that must tell a venv from its base may key on it. + the system Python. Resolve to *decide*; run and store what was given, made absolute. **The + identity followed the same link**: `env_hash` filed a linked venv's pins, snapshots and reports + under its base, which nothing showed while no screen could list the two apart. A venv's own + interpreter (recognised by `pyvenv.cfg`) is now resolved only up to its folder. Rows are still + matched by path, never by hash: two names for one Python share one. - **Anything that resolves a path needs a fallback to the path.** A Microsoft Store Python is an app-execution alias that `canonicalize()` refuses (os error 1920). `canonical_interpreter` always fell back; the new validator did not, and `env use` would have broken for every Store user. diff --git a/changelog/1.x.md b/changelog/1.x.md index 4b2567c..c913375 100644 --- a/changelog/1.x.md +++ b/changelog/1.x.md @@ -33,6 +33,9 @@ from being developed to being maintained. ([#119](https://github.com/poli0981org An interpreter you added is checked again whenever the list is read, and a default set with `env use` before 1.6.0 is checked when it is used — if it is refused, it is skipped with a warning, as a deleted one already was. +- **A virtual environment made with `--symlinks` is its own environment.** Its pins, snapshots and + reports were filed under the Python it was made from, because its `python.exe` is a link to that + Python. They are kept apart now; any made before 1.6.0 stay with that Python. - **The repository moved to `github.com/poli0981org/pipdock`.** The bug-report button, the legal documents, About and the docs point there; the old address redirects. - **The first-run screen asks once more.** The privacy policy now names the interpreter paths you diff --git a/crates/pipdock-core/src/envs/mod.rs b/crates/pipdock-core/src/envs/mod.rs index cd1877c..85ca7ee 100644 --- a/crates/pipdock-core/src/envs/mod.rs +++ b/crates/pipdock-core/src/envs/mod.rs @@ -47,7 +47,9 @@ pub struct ProbeResult { /// Identity of an environment: SHA-256 of the canonicalized interpreter path (ARCHITECTURE §6). /// -/// Case-folded on Windows — see the SP-6 note above. This value keys the pin store, the snapshot +/// Case-folded on Windows — see the SP-6 note above. Links are resolved, except that a venv's own +/// interpreter is resolved only up to its folder (since 1.6.0, [`canonical_interpreter`] says why): +/// a `--symlinks` venv is not the Python it was made from. This value keys the pin store, the snapshot /// directory and the recents list, so a change here orphans a user's data. #[must_use] pub fn env_hash(interpreter: &Path) -> String { @@ -467,9 +469,10 @@ pub async fn scan_reporting( /// the order they were added. /// /// Compared by the path as listed — made absolute, case-folded on Windows — and **not** by -/// [`canonical_interpreter`], which follows links: a venv made with `--symlinks` would otherwise -/// collapse into the base interpreter its `python.exe` points at, and the venv a person added would -/// never be listed. +/// [`canonical_interpreter`]: the first version compared identities, and while identity still +/// followed a venv's link, a venv made with `--symlinks` collapsed into the base interpreter its +/// `python.exe` points at and the venv a person added was never listed. Identity resolves other +/// links still, and what a person added is listed as they added it. fn merge_manual(found: BTreeMap, manual: &[PathBuf]) -> Vec { let mut out: Vec = found.into_values().collect(); let mut seen: std::collections::HashSet = diff --git a/crates/pipdock-core/src/exec.rs b/crates/pipdock-core/src/exec.rs index 699ea01..58e3a94 100644 --- a/crates/pipdock-core/src/exec.rs +++ b/crates/pipdock-core/src/exec.rs @@ -625,9 +625,19 @@ pub fn user_file_error(path: &Path, e: &std::io::Error) -> PdError { /// — a Chocolatey shim yields `c:\python314\python.exe` where the direct install yields /// `C:\Python314\python.exe`. `env_hash` is derived from this string (ARCHITECTURE §6), so without /// case folding one environment would silently split its pins and snapshot history in two. +/// +/// **Links are followed — except the one a virtual environment's own interpreter can be.** A venv +/// made with `python -m venv --symlinks` (the default off Windows) has a `python.exe` that links to +/// the Python it was made from, and following it made the venv the same environment as its base: +/// one pin store, one snapshot history, one cached graph, report and audit. Until 1.6.0 nothing in +/// the GUI could list the two apart, so nothing showed it; *Add interpreter…* can, and an +/// independent review of 1.6.0 found what came with it. For an interpreter whose environment has a +/// `pyvenv.cfg`, the folders are resolved and the file's own name is kept. Only such a venv's +/// identity changed: every other path, a copied venv's included, resolves exactly as it did, and a +/// linked venv's pins and snapshots from before stay with the base they were always filed under. #[must_use] pub fn canonical_interpreter(path: &Path) -> String { - let resolved = std::fs::canonicalize(path).unwrap_or_else(|_| path.to_path_buf()); + let resolved = identity_path(path); let text = resolved.display().to_string(); // Strip the Windows verbatim prefix canonicalize() adds; it is noise in logs and in the hash. let text = text.strip_prefix(r"\\?\").unwrap_or(&text).to_owned(); @@ -638,6 +648,21 @@ pub fn canonical_interpreter(path: &Path) -> String { } } +/// The path [`canonical_interpreter`] names: every link resolved, but a venv's own interpreter only +/// up to its folder. A venv is recognised by the `pyvenv.cfg` beside `Scripts\` (`bin/` off +/// Windows), which is how Python itself recognises one. +fn identity_path(path: &Path) -> PathBuf { + if let (Some(dir), Some(name)) = (path.parent(), path.file_name()) + && dir + .parent() + .is_some_and(|prefix| prefix.join("pyvenv.cfg").is_file()) + && let Ok(dir) = std::fs::canonicalize(dir) + { + return dir.join(name); + } + std::fs::canonicalize(path).unwrap_or_else(|_| path.to_path_buf()) +} + #[cfg(test)] mod tests { use super::*; @@ -1083,4 +1108,83 @@ mod tests { let p = canonical_interpreter(Path::new(".")); assert!(!p.starts_with(r"\\?\"), "got {p}"); } + + fn identity_scratch(name: &str) -> PathBuf { + let dir = std::env::temp_dir().join(format!("pd-identity-{name}-{}", std::process::id())); + let _ = std::fs::remove_dir_all(&dir); + std::fs::create_dir_all(&dir).expect("scratch dir"); + dir + } + + fn file_at(path: &Path) -> PathBuf { + std::fs::create_dir_all(path.parent().expect("a parent")).expect("parents"); + std::fs::write(path, "").expect("write"); + path.to_path_buf() + } + + /// A file link, or `None` where this machine may not make one (Windows without Developer Mode). + fn file_link(target: &Path, at: &Path) -> Option<()> { + std::fs::create_dir_all(at.parent().expect("a parent")).expect("parents"); + #[cfg(windows)] + let made = std::os::windows::fs::symlink_file(target, at); + #[cfg(not(windows))] + let made = std::os::unix::fs::symlink(target, at); + made.ok() + } + + /// What the identity was before 1.6.0, for every path it did not mean to change. + fn resolved_fully(path: &Path) -> String { + let text = std::fs::canonicalize(path) + .expect("exists") + .display() + .to_string(); + let text = text.strip_prefix(r"\\?\").unwrap_or(&text).to_owned(); + if cfg!(windows) { + text.to_lowercase() + } else { + text + } + } + + #[test] + fn a_venv_made_with_symlinks_is_its_own_environment() { + let dir = identity_scratch("venv"); + let bin = if cfg!(windows) { "Scripts" } else { "bin" }; + let exe = if cfg!(windows) { + "python.exe" + } else { + "python" + }; + let base = file_at(&dir.join("base").join(exe)); + + // A copied venv — Windows' default — resolves exactly as before. + let copied = file_at(&dir.join("copied").join(bin).join(exe)); + file_at(&dir.join("copied").join("pyvenv.cfg")); + assert_eq!(canonical_interpreter(&copied), resolved_fully(&copied)); + assert_eq!(canonical_interpreter(&base), resolved_fully(&base)); + + let linked = dir.join("linked").join(bin).join(exe); + let Some(()) = file_link(&base, &linked) else { + eprintln!("skipped: this machine cannot create symbolic links"); + return; + }; + // A link that is not a venv's still resolves: two names for one file are one Python. + let alias = dir.join("alias").join(exe); + file_link(&base, &alias).expect("links work here"); + assert_eq!(canonical_interpreter(&alias), canonical_interpreter(&base)); + + // Before it is a venv, the link is the base; once `pyvenv.cfg` says so, it is itself. + assert_eq!(canonical_interpreter(&linked), canonical_interpreter(&base)); + file_at(&dir.join("linked").join("pyvenv.cfg")); + assert_ne!( + canonical_interpreter(&linked), + canonical_interpreter(&base), + "the venv is not the Python it was made from" + ); + let folder = resolved_fully(&dir.join("linked").join(bin)); + assert_eq!( + canonical_interpreter(&linked), + format!("{folder}{}{exe}", std::path::MAIN_SEPARATOR) + ); + } } diff --git a/crates/pipdock-core/src/store/mod.rs b/crates/pipdock-core/src/store/mod.rs index e08add6..133edf2 100644 --- a/crates/pipdock-core/src/store/mod.rs +++ b/crates/pipdock-core/src/store/mod.rs @@ -313,9 +313,9 @@ impl Store { /// this time, which is the absolute one [`crate::envs::validate_interpreter`] returned, links /// left alone. /// - /// Keyed by `env_hash`, which follows links, so a `--symlinks` venv and its base interpreter - /// are one entry here: added after the base, the venv replaces it. Only an added base and an - /// added venv of it meet this; the backlog records it with the rest of that identity. + /// Keyed by `env_hash`, so two names for one interpreter are one entry. A venv made with + /// `--symlinks` has an identity of its own since 1.6.0 (`exec::canonical_interpreter`), and is + /// not its base's entry. /// /// # Errors /// `PD-INT-001` when the write fails. diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 4adcdad..379cf98 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -152,7 +152,7 @@ logs/pipdock..log, logs/pipdock-cli..log # one file per head per U **There is no `config.json`.** This block listed one until 1.4.0; settings and the consent record have always been rows in `index.db`'s `kv` table (`settings::load`), because the store already exists, already handles concurrent access, and a second on-disk format is a second thing to migrate. -`env_hash` = SHA-256 of the canonicalized interpreter path, case-folded on Windows (SP-6). Snapshot `.meta.json` records trigger (which plan), engine, package count, and app version; the engine is what a rollback with the other engine reads (DATA-FLOW §8). Snapshot ids are fixed width, so they sort as the times they name — the timestamp with its punctuation swapped out used to trim its fraction, so `…09-42Z` sorted after `…09-4235606Z` — and the timeline orders by `created_at` either way (M43). +`env_hash` = SHA-256 of the canonicalized interpreter path, case-folded on Windows (SP-6). Links are resolved — two names for one Python are one environment — **except a venv's own interpreter**, resolved only up to its folder since 1.6.0: a `--symlinks` venv's `python.exe` links to the Python it was made from, and following it filed the venv's pins, snapshots and reports under that base. A venv is recognised by its `pyvenv.cfg`; no other path's identity changed. Snapshot `.meta.json` records trigger (which plan), engine, package count, and app version; the engine is what a rollback with the other engine reads (DATA-FLOW §8). Snapshot ids are fixed width, so they sort as the times they name — the timestamp with its punctuation swapped out used to trim its fraction, so `…09-42Z` sorted after `…09-4235606Z` — and the timeline orders by `created_at` either way (M43). **The store migrates only when it is behind.** `user_version` is compared with `store::SCHEMA_VERSION` (4) and the batch runs only when the database is older: every open used to run it — a `journal_mode` write and eight `CREATE TABLE`s, on a store some paths open twice per lookup — and an older build set the version back down, so the next newer one re-ran them (M38). v4 added `release_meta(normalized, version, requires_python)`: a release's `Requires-Python` as PyPI publishes it, never refreshed because an uploaded release's metadata never changes. A NULL there means "declares none"; "unknown" is never stored. @@ -170,7 +170,7 @@ This table is the surface. A command that is not listed here does not exist; add |---|---|---| | `app_info` | `AppInfo` | PipDock's version, and the hash of the legal documents this build ships against. | | `env_scan` | `EnvRow[]` | Discover environments, streaming `scan-progress`. A probe failure is reported on its own row, never fatal to the scan. Carries `pipVersion` and `healthProject`, both read before the probe loop so the store guard is never held across a probe. Probes run four at a time (they ran in series until 1.4.0), each under its own 60 s watchdog, so one hung interpreter costs its own row; rows keep discovery order. An added interpreter is validated again before its probe (`envs::probe_listed`, which `pipdock env list` shares): what it was when added says nothing about what a link points at now. | -| `env_add_manual` | `EnvRow` | Add an interpreter chosen through *Add interpreter…* (*Browse…*, PRD P0-1) to the list `env_scan` appends to discovery, and return its row (1.6.0; the last entry `NOT_YET` held). `envs::validate_interpreter` first — an existing file named like Python, not one of PipDock's own venvs — then the probe, then the store, so a refused or broken interpreter is never listed. The row carries the path that is stored: absolute, links left alone — a `--symlinks` venv's `python.exe` *is* the venv, and its target is the base interpreter. The frontend merges the row by that path, not by `envHash`, which follows links. | +| `env_add_manual` | `EnvRow` | Add an interpreter chosen through *Add interpreter…* (*Browse…*, PRD P0-1) to the list `env_scan` appends to discovery, and return its row (1.6.0; the last entry `NOT_YET` held). `envs::validate_interpreter` first — an existing file named like Python, not one of PipDock's own venvs — then the probe, then the store, so a refused or broken interpreter is never listed. The row carries the path that is stored: absolute, links left alone — a `--symlinks` venv's `python.exe` *is* the venv, and its target is the base interpreter. The frontend merges the row by that path, not by `envHash`: two names for one Python share a hash. | | `env_remove_manual` | `boolean` | Take an added interpreter off that list, by the path its row shows; `false` when it was not on it. The path, not `envHash`: for a file that is gone the hash is recomputed from the stored text and can differ from the one it was added under, so removal by hash reported success while the entry stayed. Touches nothing on disk, and leaves the pins, snapshots and Health folder keyed to it. | | `env_probe` | `EnvRow` | Probe one interpreter without persisting it. Takes an optional `source`: absent means manual, and a **refresh must pass the row's own**, or the row comes back relabelled `manual`. A `manual` path is validated as `env_add_manual` validates one — a check on what the webview *says*, not an enforcement point (SECURITY §2, backlog X36-b). Fills every field `env_scan` does, because `upgradePip` replaces the row wholesale. | | `env_export` | `string` | Write the environment's `Engine::freeze` document to a user-chosen path and return it (PRD P1-3). Byte for byte, with no formatter: a freeze *is* a requirements file, and a constraints file is the same body under a different name. Rust-side for `health_save_report`'s reason — `dialog:allow-save` asks for a path and grants no `fs`. | diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md index 63ee83e..7459553 100644 --- a/docs/ROADMAP.md +++ b/docs/ROADMAP.md @@ -1390,7 +1390,6 @@ starting a slice**: several are cheaper inside a slice that touches the same fil | — | `pipdock-cli` | On a terminal, an impossible package is skipped at the prompt without the engine's explanation; `report-bug` points at a log excerpt the CLI never attaches; `uninstall --json --force` warns about "the breakage above", which JSON mode never printed | Small CLI copy fixes | | X36/U55 | `src-tauri/src/commands.rs:425-467,1189-1214,1350-1377` | Save and export accept any path the webview names, and overwrite a sibling without asking | The picker is the only caller today; defence in depth, not a reachable hole | | X36-b | `src-tauri/src/commands.rs` — every command taking a `PyEnv` (`pkg_list`, `pip_upgrade`, `deps_graph`, `plan_resolve`, `health_run`, `audit_run`, `engine_info`…) and `env_probe` | The interpreter a `PyEnv` names is run as the webview hands it back, and `env_probe` validates only a path the webview calls `manual` | Found by 1.6.0's independent review; predates it. The paths come from `env_scan`, which checks added entries itself, so this is defence in depth against a compromised webview — a `validate_interpreter` per command, its own change | -| — | `envs::env_hash`; `store` `manual_envs` | A venv made with `--symlinks` has its base interpreter's identity, because `env_hash` follows links: it shares the base's pins, snapshots and Health folder, discovery collapses the two into one row, and `manual_envs`, keyed by the hash, holds one of an added base and an added venv of it | Windows makes such a venv only with Developer Mode or as administrator. An identity that stops at the link is a new `env_hash`, so a migration of everything keyed by the old one | | — | `exec.rs:633` `canonical_interpreter` | An interpreter on a share hashes as `unc\server\share\…`: the verbatim prefix `\\?\` is stripped, `\\?\UNC\` is not | Correcting it changes the identity — and orphans the pins and snapshots — of every interpreter on a share | | — | `envs/mod.rs:131-138`, `engine/parse.rs:103-108`, `exec.rs:367-375`, `pins/mod.rs:85-89`, `store/mod.rs:253`, `index/mod.rs:144,448` | Failures that are dropped without a log line (a probe error entry, an unreadable pin row, a Job Object that would not attach…) | The log exists now; each wants a `tracing::warn!` and a look at whether it should surface | | — | `PIP_MIN_VERSION_FOR_REPORT`, `UV_MIN_VERSION`, `probe_supported`, `MIN_PROBE_PYTHON` | Declared floors nothing enforces | Enforcing them is a user-visible refusal and wants its own copy and test | @@ -1733,7 +1732,7 @@ seen to fail first: | # | Severity | Found | Now | |---|---|---|---| -| 1 | High | `validate_interpreter` returned the canonical path, and every caller ran and stored it. A `--symlinks` venv's `python.exe` is a link to its base, so `env use ` stored `C:\Python315\python.exe` (reproduced) and `--env .venv update --all --yes` would have changed the system Python; the GUI merged the added venv into the registry row by `envHash` and selected that. The name check looked at the link while the target was stored, so a `python.exe` linking to `notepad.exe` stored `notepad.exe` | The path made absolute is run and stored, links left alone; canonicalizing only decides where a link leads and whether it is PipDock's own. The UI merges and removes by path | +| 1 | High | `validate_interpreter` returned the canonical path, and every caller ran and stored it. A `--symlinks` venv's `python.exe` is a link to its base, so `env use ` stored `C:\Python315\python.exe` (reproduced) and `--env .venv update --all --yes` would have changed the system Python; the GUI merged the added venv into the registry row by `envHash` and selected that. The name check looked at the link while the target was stored, so a `python.exe` linking to `notepad.exe` stored `notepad.exe` | The path made absolute is run and stored, links left alone; canonicalizing only decides where a link leads and whether it is PipDock's own. The UI merges and removes by path. **Fixing it exposed the identity beneath**: `env_hash` followed the same link, so the venv, listed now beside its base, would have shared the base's pins, snapshots and cached graph, report and audit — a rollback of one offered the other's snapshots. `canonical_interpreter` resolves a venv's own interpreter (recognised by `pyvenv.cfg`) only up to its folder; no other path's identity changed, and a linked venv's earlier pins stay with the base they were filed under. Seen on this machine's real `--symlinks` venv | | 2 | Medium | A Microsoft Store Python was refused: an app-execution alias reports `is_file()` and fails `canonicalize()` with os error 1920, so `--env` and `env use`, which worked in 1.5.0, would have exited 3 | Judged by its own path when it cannot be resolved, as `canonical_interpreter` always fell back | | 3 | Medium | Not an enforcement point over IPC, while SECURITY §2 and `env_probe`'s doc said it was: `env_probe` checks only a path the webview calls `manual`, and every `PyEnv` command runs `env.interpreter` unchecked. Stored entries, and the CLI's default from 1.5.0, were probed unchecked too | Both sentences corrected. Added entries are checked again on every listing (`probe_listed`, both heads), the stored default when it is used. The IPC exposure predates 1.6.0: backlog X36-b | | 4 | Low–Medium | *Remove from list* announced success while the entry stayed, for an entry on a share whose file was gone: the row's `envHash` was recomputed from the stored text, while the identity it was added under had been hashed from `UNC\server\share\…` | Removed by the path the row shows; the store matches either | @@ -1747,7 +1746,7 @@ scripts only, no expression reaching a shell, writes that start no runs), who it v4→v5 migration, the store guard, and the copy in both catalogues. **Left, in the backlog with a reason each:** X36-b, the `PyEnv` commands' trust in the webview's -path; a `--symlinks` venv sharing its base's identity; the identity of an interpreter on a share. +path, and the identity of an interpreter on a share. ## Maintenance mode — from 1.6.0 diff --git a/docs/UI-SPEC.md b/docs/UI-SPEC.md index 07a7ecf..857fcf3 100644 --- a/docs/UI-SPEC.md +++ b/docs/UI-SPEC.md @@ -100,8 +100,8 @@ it adds. An added row carries the `manual` chip and **Remove from list** — kep is gone, so the `PD-ENV-001` row can be removed — and the outcome is said in a `role="status"` line mounted before its words. Both are busy while a scan runs, and a scan waits for either: a scan that read the list before the change would undo it. An added row is matched to the list by its -path, never by `envHash`, which follows links — a venv made with `--symlinks` is listed beside the -base Python it links to, not merged into it. Discovery is unchanged: the registry, the `py` launcher, +path, never by `envHash`, which two names for one Python share — and a venv made with `--symlinks` +is listed beside the base Python it links to, with an identity of its own (ARCHITECTURE §6). Discovery is unchanged: the registry, the `py` launcher, `uv python list`, and a `.venv`, `venv`, `env` or `.env` in the working directory. And there is no star-as-default: the selection lasts for the session, and a rescan keeps it or falls back to the first usable row. The CLI's `env use` stores a default, honoured since 1.4.0; the GUI does not read it. diff --git a/src-tauri/src/commands.rs b/src-tauri/src/commands.rs index 25474b0..02b3ad5 100644 --- a/src-tauri/src/commands.rs +++ b/src-tauri/src/commands.rs @@ -301,7 +301,8 @@ pub async fn env_probe( /// (a `--symlinks` venv's `python.exe` is the venv; its target is the base), which is what is stored /// and what the next `env_scan` returns, so the screen does not change under the user's eyes. /// Adding one already listed — by discovery or by an earlier *Browse…* — is not an error: the row -/// comes back, and the frontend merges it by that path, not by `envHash`, which follows links. +/// comes back, and the frontend merges it by that path, not by `envHash`: a row is what a person +/// sees, and two names for one Python — a link to it — share a hash. /// /// # Errors /// `PD-ENV-001` when the file is missing, is not named like a Python interpreter, or is one of diff --git a/ui/src/screens/PdEnvironments.test.tsx b/ui/src/screens/PdEnvironments.test.tsx index 6864387..63baa24 100644 --- a/ui/src/screens/PdEnvironments.test.tsx +++ b/ui/src/screens/PdEnvironments.test.tsx @@ -3,9 +3,11 @@ * * The store half and the screen half, because the seam between them is where this app's bugs have * lived (CLAUDE.md, `PdPlanPanel`). Both key on the interpreter **path**: the first version merged - * and removed by `envHash`, which follows links — so a venv made with `--symlinks` merged into the - * base Python it points at, and *Remove from list* took every row sharing the hash with it. An - * independent review of 1.6.0 found both, and the cases below are the ones it named. + * and removed by `envHash`, which then followed a venv's link — so a venv made with `--symlinks` + * merged into the base Python it points at, and *Remove from list* took every row sharing the hash + * with it. An independent review of 1.6.0 found both, and the cases below are the ones it named. + * Identity no longer follows a venv's link, but two names for one Python still share a hash, so + * the rows stay keyed on what they show. */ import { act, fireEvent, render, screen, waitFor } from '@testing-library/react' @@ -109,8 +111,9 @@ describe('the store', () => { }) it('lists a venv made with --symlinks beside the base Python it links to, and selects the venv', async () => { - // Its `python.exe` is a link to the base, so the two share an `envHash`. Merging on the hash - // selected the base: the next update would have changed the system's Python, not the venv's. + // Its `python.exe` is a link to the base, and the two shared an `envHash` until 1.6.0's review. + // Merging on the hash selected the base: the next update would have changed the system's + // Python, not the venv's. Any two rows that share a hash must still be told apart by path. const linked: EnvRow = { ...ADDED, envHash: DISCOVERED.envHash } vi.mocked(ipc.pickOpenFile).mockResolvedValueOnce(linked.interpreter) vi.mocked(ipc.envAddManual).mockResolvedValueOnce(linked) diff --git a/ui/src/stores/index.ts b/ui/src/stores/index.ts index 33e4108..6a4c2a6 100644 --- a/ui/src/stores/index.ts +++ b/ui/src/stores/index.ts @@ -185,9 +185,9 @@ interface EnvState { * *Add interpreter…* (PRD P0-1): ask for a `python.exe`, put it on the list, select it. * * `title` arrives localized — `@/ipc` has no `t`. Cancelling the picker changes nothing. The new - * row is merged **by its path, case-insensitively**, not by `envHash`: the hash follows links, so - * a venv made with `--symlinks` shares its base interpreter's, and merging on it selected the - * base Python in place of the venv a person had just added. A listed row with the same path is + * row is merged **by its path, case-insensitively**, not by `envHash`: two names for one Python + * share a hash, and until 1.6.0's review so did a venv made with `--symlinks` and its base, so + * merging on the hash selected the base Python in place of the venv a person had just added. A listed row with the same path is * kept only when discovery found it and it works; one this list put there, or one that is * *broken* — a venv deleted and made again — is replaced by the row Rust returned and selected. * Refused while a scan runs: the scan read the list before this add wrote to it, and its result