Repository navigation
fix(updater): relaunch desktop shell after update and preserve preflight errors - #1344
Conversation
…ght errors Fixes two Rust update/restart failures reproduced in end-to-end isolated update testing: 1. Preserve Desktop Shell across updates: - Detect an active Desktop Shell (desktop-shell-ready.json with live owner) in launcher service_update::prepare_request and pass backward-compatible restart_desktop_shell: true in UpdateRequest (keeping restart_target unchanged for official Codex Desktop and background Web coexistence). - After codexhost-updater finishes restoring services and writes terminal status-v1.json (on both update success and successful failure rollback), relaunch the updated Desktop Shell via detached `codexhost app` with CODEXHOST_DATA_DIR and npm runtime env vars preserved. 2. Preserve updater preflight failure errors during handshake: - Parse status-v1.json's error field in launcher active_update::wait_for_updater_ready (including a final re-read after child exit to avoid the exit race) and avoid clobbering an already-recorded non-empty failed error in service_update::record_failure.
|
No actionable comments were generated in the recent review. Summary
Merge Risk:
|
Summary
Fix two Rust update/restart bugs reproduced during end-to-end isolated update testing:
services::stop_for_updatestopped a running Desktop Shell (desktop-shell-ready.json), butservice_update,UpdateRequest, andcodexhost-updateronly tracked official Codex Desktop ("desktop") and background Web ("web"), leaving Desktop Shell closed permanently after updates.codexhost-updaterrejected an update in preflight (e.g. npm global prefix mismatch) and wrote a specific actionable error intostatus-v1.json,active_update.rsandservice_update::record_failureoverwrote it with the generic"background Updater failed before waiting for Launcher exit"message.Changes
crates/launcher/src/desktop_shell.rs: Adddesktop_shell::running(data)sharinglive_owneridentity verification withstop, plus unit test coverage.crates/launcher/src/service_update.rs:desktop_shell::running(data)inprepare_request/bind_requestand set"restart_desktop_shell": trueonly when active (preserving existing"desktop"/"web"restart_targetbehavior and official Codex Desktop coexistence).phase == "failed"errors inrecord_failureinstead of overwriting them.crates/launcher/src/active_update.rs: ParseerrorinUpdateStatusProbe, propagate specific updater failure messages inwait_for_updater_ready(with a final status re-read afterchild.try_wait()catches exit to eliminate the exit race), and add regression testpreserves_preflight_failure_error_written_by_updater.crates/updater/src/request.rs: Add backward-compatible#[serde(default)] restart_desktop_shell: booltoUpdateRequestand require an explicit absolutedata_directorywhen enabled.crates/updater/src/restart.rs&crates/updater/src/main.rs: Shareapply_restart_environment(CODEXHOST_DATA_DIRandCODEXHOST_NPM_*), add detachedrelaunch_desktop_shellinvoking updatedcodexhost app, and trigger it after writing terminalstatus-v1.jsonon both update success and successful service rollback recovery.crates/updater/tests/background_services.rs&crates/launcher/tests/web_service.rs: Add mock integration tests covering Desktop Shell relaunch after update success and rollback recovery, pure-Web non-regression, andrestart_desktop_shellhandoff propagation.Visual Changes
No visual changes: native Rust launcher and updater lifecycle/error-preservation fixes only.
Validation
cargo fmt --all -- --check: passed (implementation session).cargo test --locked -p codexhost-updater: 45 unit + 4background_servicesintegration tests passed (implementation session).cargo test --locked -p codexhost-launcher -- active_update service_update web_service host_service desktop_shell: 23 unit tests passed (implementation session).cargo test --locked -p codexhost-launcher --test web_service: 20 integration tests passed (implementation session).pre-commitformatting check: passed.AGENTS.md.