Skip to content

feat(cli) Restart Codex after completing update flow - #9240

Closed
dylan-hurd-oai wants to merge 1 commit into
mainfrom
codex/change-update-check-flow-to-restart-codex
Closed

dylan-hurd-oai wants to merge 1 commit into
mainfrom
codex/change-update-check-flow-to-restart-codex

Conversation

@dylan-hurd-oai

Copy link
Copy Markdown
Contributor

Motivation

  • Make the CLI restart itself automatically after running a successful update so users don’t need to manually relaunch Codex.

Description

  • Capture the original command-line invocation via std::env::args_os() and carry it through the exit path.
  • Change handle_app_exit and run_update_action to accept the captured restart_args and propagate them when an update runs.
  • Add restart_codex which relaunches the saved command (command + args) after a successful update and update the user-facing message to indicate an automatic restart.
  • All edits are contained in codex-rs/cli/src/main.rs.

Testing

  • Ran just fmt in codex-rs successfully.
  • Ran just fix -p codex-cli to apply lints and fixes successfully.
  • Ran cargo test -p codex-cli and the test suite passed (all tests green).

Codex Task

@dylan-hurd-oai dylan-hurd-oai added the codex Label used by connector to tag PRs that have been reviewed by Codex label Jan 15, 2026 — with ChatGPT Codex Connector
@dylan-hurd-oai

Copy link
Copy Markdown
Contributor Author

@codex review this change, in particular consider edge cases across platforms

@dylan-hurd-oai
dylan-hurd-oai marked this pull request as ready for review January 15, 2026 19:58

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 99af97cd7e

ℹ️ 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".

Comment thread codex-rs/cli/src/main.rs
Comment on lines +413 to +417
fn restart_codex(restart_args: &[OsString]) -> anyhow::Result<()> {
let Some((command, args)) = restart_args.split_first() else {
anyhow::bail!("No command found to restart Codex");
};
std::process::Command::new(command).args(args).status()?;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Handle Windows .cmd/.bat shims when restarting

On Windows, global npm/bun installs typically expose codex as a .cmd shim. The update path already uses cmd /C specifically to resolve .CMD/.BAT via PATHEXT, but restart_codex directly calls Command::new(command) with the original argv[0]. If the user started Codex via the shim (common when CODEX_MANAGED_BY_NPM/_BUN is set), command will be codex and Command::new will not execute the .cmd shim, causing the restart to fail right after a successful update. Consider mirroring the Windows cmd /C handling here or otherwise resolving .cmd/.bat shims before invoking the restart.

Useful? React with 👍 / 👎.

@dylan-hurd-oai dylan-hurd-oai changed the title Restart Codex after completing update flow feat(cli) Restart Codex after completing update flow Jan 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Closing this pull request because it has had no updates for more than 14 days. If you plan to continue working on it, feel free to reopen or open a new PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codex Label used by connector to tag PRs that have been reviewed by Codex

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants