Repository navigation
fix(desktop): judge machine-path-conflict from a fresh logon PATH - #6888
Conversation
Read a fresh user environment block after the registry transaction and evaluate searchable PATH entries in order until the Desktop directory. Preserve the legacy registry probe only as a conservative fallback when the fresh PATH is unavailable. Cover UTF-16 parsing and PATH precedence with portable tests.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 41 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 799f68fdd8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| pub fn machine_conflict(desktop_dir: &str) -> Result<bool> { | ||
| match fresh_logon_path() { | ||
| Ok(Some(entries)) => conflict_before_desktop(&entries, desktop_dir, has_ocx), | ||
| Err(_) | Ok(None) => match legacy_machine_conflict() { | ||
| Ok(false) => Ok(false), | ||
| Ok(true) => Err("machine-path-unobserved".into()), | ||
| Err(e) => Err(e), | ||
| }, |
There was a problem hiding this comment.
Update the owned terminal-command contract
This changes Windows conflict detection from an unconditional Machine-Path probe to an ordered fresh-logon PATH evaluation with an unobserved fallback, but the mapped structure/desktop-terminal-command.md contract remains unchanged. Update that document in this commit to describe when an earlier entry is a conflict, when unresolved entries are ignored, and when observation fails; both modified files are explicitly owned by that document in structure/INDEX.md.
AGENTS.md reference: AGENTS.md:L38-L46
Useful? React with 👍 / 👎.
|
✅ Deterministic PR hygiene checks passed. |
Summary
On Windows the Desktop terminal command reported
phase: partialwithmachine-path-conflictwhenever the MachinePathheld a directory containingocx.{exe,com,cmd,bat}, even when new terminals select the Desktop'socx.exefirst. On the reporter's nvm-windows host the MachinePathisREG_EXPAND_SZwith%NVM_HOME%;%NVM_SYMLINK%; the Desktop expanded those entries with its own, fully resolved environment, while a fresh logon environment keeps them literal, so nvm'socx.cmdonly arrives through the UserPathafter the Desktop entry.The conflict is now decided the way a new process would search:
os::machine_conflict(desktop_dir)builds the user's fresh environment withCreateEnvironmentBlock(token, bInherit = FALSE)and walks itsPATHin order. Anocxexecutable in a searchable entry before the first Desktop entry is a conflict; reaching the Desktop entry first is not. Relative entries and entries still containing%are not probed:cmdsearches the working directory beforePATHanyway, so their effect depends on the terminal's cwd, not onPATHorder the Desktop can change. A freshPATHwithout the Desktop entry reportsmachine-path-unobserved.PATH, the previous registry probe is used only as a negative proof: "no Machine entry holdsocx" stays clean; a previous-style hit cannot establish order and reportsmachine-path-unobservedinstead of a conflict.plan(), which ran before the HKCU write and would have seen the old UserPath, intoperform_inafter the transaction and notification, using the committed record's entry. It still runs only for enabled, non-remove reconciles, and any issue still makes the phasepartial.Block parsing (case-insensitive
PATH, drive pseudo-variables, missing vs emptyPATH, unterminated blocks, invalid UTF-16) and the ordering decision are portable helpers with unit tests, so the Ubuntudesktop shelljob exercises them.Closes #6854
Verification
desktop/src-tauriwith the CI check scaffolding:cargo fmt --check(0),cargo clippy --all-targets -- -D warnings(0),cargo test cli_command: 53 passed, 0 failed, 2 ignored.cargo clippy --target x86_64-pc-windows-msvccould not reach this crate (theringbuild script needs an MSVC C toolchain), so Windows was checked natively instead.799f68fdd8:cargo clippy --all-targets -- -D warningsexit 0;cargo test cli_command: 30 passed, 0 failed.fresh_logon_path(): the fresh block keeps%NVM_HOME%and%NVM_SYMLINK%literal and marks them unsearchable, and the onlyocxdirectory,C:\nvm4w\nodejs, appears in the User part ofPATH; the probe process's own inheritedPATHhad those entries expanded. That is the difference behind the false positive. After a real install the Desktop entry is first in the User part, so the walk reaches it beforeC:\nvm4w\nodejs; the unit testissue host shapecase covers that order.where ocx. The earlier probe recorded indevlog/_fin/261010_cli_path_crossos_probe/029_wp3_outcome.md(W3-W5) observed new terminals selecting the Desktop'socx.exefirst on that host.desktop shell(Ubuntu fmt/clippy/test) on this PR head.Checklist
PATHis decoded.)