You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(launcher): don't block updates on detached or foreign-install Desktop records - #1314
Fixes automatic updates failing with Desktop belongs to a different CODEXHOST_DATA_DIR; no GUI action taken (or Desktop is still running without its Launcher; orphan cleanup refused) when an unrelated external Desktop GUI (Codex.app / ChatGPT.app) remains open from another CODEXHOST_DATA_DIR or a detached previous session.
Root Cause
On Unix, the Desktop lifecycle owner record (desktop-lifecycle-v1/owner.json) is stored per-user across all CODEXHOST_DATA_DIR instances. When an isolated test (or earlier dev run) launched an official Desktop GUI under a different CODEXHOST_DATA_DIR and its launcher / controller exited while the external GUI process stayed alive, owner.ended() remained false. Subsequent updates for the primary CODEXHOST_DATA_DIR called running_for_update() and stop_managed(), which unconditionally ran Owner::check_scope() and aborted the entire update.
Changes
crates/launcher/src/desktop_lifecycle.rs:
Added Owner::managed_ended, Owner::belongs_to_data, Owner::ignored_for_update_scope, and is_current_installation.
In running_for_update_at and stop_managed_at, ignore non-ended owner.json records (returning Ok(false) without touching the external GUI or removing owner.json) when either:
all codexhost-managed processes (launcher, controller, and control listener) have already exited, or
the owner belongs to both a different CODEXHOST_DATA_DIR and a different installation executable.
Preserved strict refusal when the same installation has an active launcher/controller on another CODEXHOST_DATA_DIR, or when another installation has an active launcher/controller on the sameCODEXHOST_DATA_DIR, and included the conflicting CODEXHOST_DATA_DIR and launcher PID in the scope error message.
Kept Lifecycle::reconcile and Lifecycle::attachment strict scope checks intact for direct Desktop takeover/launch.
crates/launcher/src/desktop_lifecycle_tests.rs:
Added 5 regression tests covering foreign detached Desktop, active foreign-install Desktop, active same-install foreign-data Desktop (still rejected with directory + PID details), same-data detached Desktop, and same-data foreign-install active Desktop (still rejected).
Automatic updates are no longer blocked by unrelated Desktop GUI processes from another data directory or by detached sessions. Strict refusal is kept where the same installation is active under another data directory, or another installation is active under the same data directory. No actionable merge-blocking risk remains.
Reviewing files that changed from the base of the PR and between cec2495 and 11adc32.
Files selected for processing: 2
crates/launcher/src/desktop_lifecycle.rs
crates/launcher/src/desktop_lifecycle_tests.rs
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.
Recent review details
Context from checks skipped due to timeout: 8
GitHub Check: CodeRabbit
GitHub Check: Check Linux ARM64
GitHub Check: Web Host tests
GitHub Check: Check ubuntu-22.04
GitHub Check: Check windows-latest
GitHub Check: Vitest
GitHub Check: Check macos-26
GitHub Check: Static checks
Additional context used
Code guidelines: 1
CLAUDE.md — auto-discovered
Path-based instructions: 1
Source excerpt: Rust owns native launch, process management, update installation, and platform integration.
CodeRabbit inference engine (CLAUDE.md)
Files:
crates/launcher/src/desktop_lifecycle.rs
crates/launcher/src/desktop_lifecycle_tests.rs
Additional comments: 1
crates/launcher/src/desktop_lifecycle.rs: 1
454-454: Data Integrity & Integration
Ignored owner records can hide an active Launcher on Windows.
On Unix, the managed launch replaces the owner record before it writes the descriptor, and reconcile refuses or stops any non-ended owner. The reported state, with a stale owner from another installation beside an active current-installation descriptor, does not arise on that path.
On Windows, the attachment branch acquires the launcher guard without reading the owner record. publish_runtime_descriptor at crates/launcher/src/main.rs:1120 then writes the descriptor. If that path runs while a non-ended owner from another data directory and installation remains on disk, the new gate in running_for_update_at and stop_managed_at returns before the generation check and can report the Desktop as not running. The enclosing function and its platform gate at main.rs:1120 are needed to decide whether that path can run in that state.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes automatic updates failing with
Desktop belongs to a different CODEXHOST_DATA_DIR; no GUI action taken(orDesktop is still running without its Launcher; orphan cleanup refused) when an unrelated external Desktop GUI (Codex.app/ChatGPT.app) remains open from anotherCODEXHOST_DATA_DIRor a detached previous session.Root Cause
On Unix, the Desktop lifecycle owner record (
desktop-lifecycle-v1/owner.json) is stored per-user across allCODEXHOST_DATA_DIRinstances. When an isolated test (or earlier dev run) launched an official Desktop GUI under a differentCODEXHOST_DATA_DIRand itslauncher/controllerexited while the external GUI process stayed alive,owner.ended()remainedfalse. Subsequent updates for the primaryCODEXHOST_DATA_DIRcalledrunning_for_update()andstop_managed(), which unconditionally ranOwner::check_scope()and aborted the entire update.Changes
crates/launcher/src/desktop_lifecycle.rs:Owner::managed_ended,Owner::belongs_to_data,Owner::ignored_for_update_scope, andis_current_installation.running_for_update_atandstop_managed_at, ignore non-endedowner.jsonrecords (returningOk(false)without touching the external GUI or removingowner.json) when either:codexhost-managed processes (launcher,controller, and control listener) have already exited, orCODEXHOST_DATA_DIRand a different installation executable.launcher/controlleron anotherCODEXHOST_DATA_DIR, or when another installation has an activelauncher/controlleron the sameCODEXHOST_DATA_DIR, and included the conflictingCODEXHOST_DATA_DIRand launcher PID in the scope error message.Lifecycle::reconcileandLifecycle::attachmentstrict scope checks intact for direct Desktop takeover/launch.crates/launcher/src/desktop_lifecycle_tests.rs:Validation
cargo test -p codexhost-launcher desktop_lifecycle(8 passed, 0 failed, 1 ignored release-bundle test)cargo test -p codexhost-launcher service_update(2 passed, 0 failed)cargo fmt -p codexhost-launcher -- --check(passed)cargo clippy -p codexhost-launcher --tests -- -D warnings(passed)No visual changes: Rust launcher lifecycle/update logic only.