Repository navigation
fix(codex): distinguish a failed desktop probe from an absent app - #2593
Conversation
Two defects on the Windows --restart-desktop-app path. The probe script joined its PowerShell statements with a space, so $ErrorActionPreference='SilentlyContinue' $root = '...' became one malformed statement and the whole script was rejected. The resulting throw was caught and returned [], which is indistinguishable from a successful enumeration that found nothing. That became no_targets and the CLI told the user the app was not running, silently skipping the restart they had asked for. Statements are now newline-separated, a failed probe returns null, and the caller reports the new process_probe_failed reason. The PID re-check fails closed the same way: it guards a kill, so 'we could not look' must never read as 'the pid was recycled'. Both driven red first: reverting either fails exactly its own cases.
|
✅ Deterministic PR hygiene checks passed. |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughWindows desktop restart handling now separates failed process probes from empty process results. PowerShell probe statements use newline separators. Process identity checks fail closed when reprobes fail. The CLI reports failed probes, with regression tests covering these cases. ChangesDesktop restart probe handling
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant CLI
participant DesktopAppRestart
participant PowerShell
CLI->>DesktopAppRestart: request desktop app restart
DesktopAppRestart->>PowerShell: enumerate desktop processes
PowerShell-->>DesktopAppRestart: process list or probe failure
DesktopAppRestart-->>CLI: restart result
CLI-->>CLI: report success, no_targets, or process_probe_failed
Suggested reviewers: ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 01afdfe367
ℹ️ 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".
| const processes = listPackageProcesses(exec, installLocation); | ||
| // Fail CLOSED on a failed re-probe: this guards a kill, and "we could not look" must not be | ||
| // read as "the pid was recycled and is now someone else's process". | ||
| if (processes === null) return false; |
There was a problem hiding this comment.
Propagate a failed re-probe instead of marking the target stopped
When the initial enumeration succeeds but this immediate or pre-force re-probe times out or throws, null becomes false; both callers interpret false as though the process disappeared, add its PID to stopped, and eventually run Start-Process. The original desktop process may still be alive, so this unreadable-evidence path can falsely report a successful restart and relaunch alongside an unverified survivor. Preserve the probe-failure state and return process_probe_failed without relaunching.
Useful? React with 👍 / 👎.
…dge-jun#2593) Two defects on the Windows --restart-desktop-app path. The probe script joined its PowerShell statements with a space, so $ErrorActionPreference='SilentlyContinue' $root = '...' became one malformed statement and the whole script was rejected. The resulting throw was caught and returned [], which is indistinguishable from a successful enumeration that found nothing. That became no_targets and the CLI told the user the app was not running, silently skipping the restart they had asked for. Statements are now newline-separated, a failed probe returns null, and the caller reports the new process_probe_failed reason. The PID re-check fails closed the same way: it guards a kill, so 'we could not look' must never read as 'the pid was recycled'. Both driven red first: reverting either fails exactly its own cases.
…dge-jun#2593) Two defects on the Windows --restart-desktop-app path. The probe script joined its PowerShell statements with a space, so $ErrorActionPreference='SilentlyContinue' $root = '...' became one malformed statement and the whole script was rejected. The resulting throw was caught and returned [], which is indistinguishable from a successful enumeration that found nothing. That became no_targets and the CLI told the user the app was not running, silently skipping the restart they had asked for. Statements are now newline-separated, a failed probe returns null, and the caller reports the new process_probe_failed reason. The PID re-check fails closed the same way: it guards a kill, so 'we could not look' must never read as 'the pid was recycled'. Both driven red first: reverting either fails exactly its own cases.
Summary
Closes #2557. Two defects on the Windows
--restart-desktop-apppath, and the second iswhat made the first invisible.
The probe script was malformed.
listPackageProcessesjoined its PowerShell statementswith a space, so
$ErrorActionPreference='SilentlyContinue' $root = '...'became a singlestatement and PowerShell rejected the whole script. Statements are now newline-separated.
A failed probe was reported as an absent app. The resulting throw was caught and
returned
[], which is indistinguishable from a successful enumeration that found nothing.That became
no_targets, and the CLI told the user "Codex desktop app is not running;nothing to restart" — silently skipping the restart they had explicitly asked for. A failed
probe now returns
nulland the caller reports a newprocess_probe_failedreason with anhonest message.
The PID re-check (
stillSameProcess) fails closed the same way. It guards a kill, so "wecould not look" must never be read as "the pid was recycled and now belongs to someone
else".
Verification
Each fix was driven red independently — reverting one fails exactly its own cases:
The new cases assert that a throwing probe reports
process_probe_failedwhile terminatingnothing and relaunching nothing, that an empty enumeration still reports
no_targetsso thetwo states stay distinguishable in both directions, and that the emitted script separates
its statements.
This is exercised through the existing
ioseam, so the guards are proved on any platformrather than asserted from a comment — the convention
#2292established for this file.Checklist
devdevheadSummary by CodeRabbit