fix(cua-driver): write the update-check cache to the canonical home - #3002
fix(cua-driver): write the update-check cache to the canonical home#3002rsyuzyov wants to merge 1 commit into
Conversation
`version_check` still resolved its cache under the pre-rename `~/.cua-driver-rs/`, while `telemetry.rs` and `skills.rs` had moved to `~/.cua-driver/` and actively migrate away from the old home. Even `read_config_flag` in this same file already reads the config from `bundle::user_home_subdirectory()` — only the cache path lagged behind. The effect is that every current install re-creates the legacy home the installer just swept, so the telemetry migration can never finish and `~/.cua-driver-rs` looks like a legacy-layout marker on machines that have only ever run current versions (the root cause discussed in trycua#2803, whose installer half shipped in trycua#2805). Resolve the cache through `bundle::user_home_subdirectory()` (which also covers the `.cua-driver-local` source-build case the old inline branch handled), and migrate a cache left in the pre-rename home on first read: move the file, then drop the directory only if it is empty, matching `migrate_legacy_telemetry_home`. Keeping the file is worth the few lines because it carries the dismissed-version list.
There was a problem hiding this comment.
Pull request overview
Updates Cua Driver’s version_check on-disk cache to use the canonical per-user home directory (~/.cua-driver/) instead of the legacy pre-rename home (~/.cua-driver-rs/), and adds a best-effort one-time migration to preserve dismissed-version state for existing installs.
Changes:
- Resolve
version_check.jsonthroughbundle::user_home_subdirectory()so new caches land under the canonical home. - Add best-effort migration from the legacy cache path, attempting to remove the legacy directory only when empty.
- Add unit tests covering canonical placement, migration preserving
dismissed_versions, and non-destructive legacy cleanup.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| libs/cua-driver/rust/crates/cua-driver/src/version_check.rs | Switch cache location to canonical home, add legacy cache migration, and add unit tests for placement/migration/cleanup behavior. |
| libs/cua-driver/rust/crates/cua-driver/Cargo.toml | Update test dependency comment to match the new canonical cache path. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| if !current.exists() { | ||
| if let Some(parent) = current.parent() { | ||
| let _ = std::fs::create_dir_all(parent); | ||
| } | ||
| let _ = std::fs::rename(&legacy, ¤t); | ||
| } | ||
| // Either the rename already took it, or the canonical cache wins and the | ||
| // stale copy goes. Both paths end with the legacy home unreferenced. | ||
| let _ = std::fs::remove_file(&legacy); | ||
| if let Some(parent) = legacy.parent() { | ||
| let _ = std::fs::remove_dir(parent); | ||
| } |
|
Thanks @rsyuzyov — I carried this forward in #3032 using |
|
Closing this in favour of #3032. @injaneity carried the commit forward with For whoever triages next: the root is still live on Happy to test a build against Windows / RDS setups if that helps move it along. |
Summary
version_checkcache throughbundle::user_home_subdirectory()so it lands in~/.cua-driver/instead of the pre-rename~/.cua-driver-rs/migrate_legacy_telemetry_homeThis is the driver half of #2803, offered in this comment when the installer half landed as #2805.
version_checkis the last writer keeping the pre-rename home alive:telemetry.rs.cua-driver.cua-driver-rs, removes the emptied dirskills.rs.cua-driver.cua-driver-rsversion_check.rs.cua-driver-rsWorth noting the file was already inconsistent with itself:
read_config_flaga few lines up readsconfig.jsonfrombundle::user_home_subdirectory(), whilecache_pathhard-coded the old name (plus its own inline.cua-driver-localbranch, whichuser_home_subdirectory()already covers).Consequences on a current install:
_install-rust.shandinstall.ps1sweep~/.cua-driver-rspost-install, and the next update check re-creates it. The telemetry migration therefore never completes, and the directory keeps looking like a v0.2.13 legacy marker on machines that have only ever run current versions.Verification
Toolchain from
rust-toolchain.toml(1.97.1), Windows 11 26100, x86_64.cargo fmt --all -- --check— cleancargo test -p cua-driver --bin cua-driver version_check— 25 passed, 0 failedBehaviour checked on the built binary, not only in unit tests —
HOME/USERPROFILEredirected to a throwaway profile, runningcheck-update:~/.cua-driver/version_check.json~/.cua-driver-rs/version_check.json.cua-driver,dismissed_versionspreserved, legacy dir removedThe third row is the one that matters for existing installs: the dismissed-version list survives the move, so nobody gets re-nagged about a release they already dismissed.
Notes
cache_pathstill resolvesHOME/USERPROFILEdirectly and does not honourCUA_DRIVER_RS_HOMEthe wayskills.rsdoes — that is a separate decision about which modules follow the env override, and I did not want to fold it into a rename fix.remove_dir, neverremove_dir_all: if anything else still lives in the old home, the directory stays. There is a test for exactly that.