Skip to content

fix: emit thread stop lifecycle on implicit shutdown#22482

Merged
jif-oai merged 2 commits into
mainfrom
jif/runtime-fix
May 13, 2026
Merged

fix: emit thread stop lifecycle on implicit shutdown#22482
jif-oai merged 2 commits into
mainfrom
jif/runtime-fix

Conversation

@jif-oai
Copy link
Copy Markdown
Collaborator

@jif-oai jif-oai commented May 13, 2026

Why

The thread lifecycle contributor hooks from #22476 should observe every session teardown. The explicit Op::Shutdown path already emitted on_thread_stop, but when submission_loop exited because its submission channel closed, it only tore down runtime services. That meant extensions could miss the thread-stop lifecycle signal on implicit runtime shutdown.

What Changed

  • Split shared runtime teardown into shutdown_runtime_services(...).
  • Split thread-stop lifecycle emission into emit_thread_stop_lifecycle(...).
  • Reused those helpers from both explicit shutdown and the channel-close shutdown path.
  • Tracked whether Op::Shutdown was received so the explicit path does not double-emit lifecycle events after it exits the loop.
  • Added a regression test that closes the submission channel and asserts ThreadLifecycleContributor::on_thread_stop runs once with the expected thread/session stores.

Testing

  • cargo test -p codex-core submission_loop_channel_close_emits_thread_stop_lifecycle

@jif-oai jif-oai requested a review from a team as a code owner May 13, 2026 11:49
@jif-oai jif-oai changed the title fix: shutdown runtime emission fix: emit thread stop lifecycle on implicit shutdown May 13, 2026
@jif-oai
Copy link
Copy Markdown
Collaborator Author

jif-oai commented May 13, 2026

@codex review

Copy link
Copy Markdown
Contributor

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

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: 190300c0ea

ℹ️ 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/core/src/session/handlers.rs
@jif-oai
Copy link
Copy Markdown
Collaborator Author

jif-oai commented May 13, 2026

@codex review

Copy link
Copy Markdown
Contributor

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

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: 072fa9fbcf

ℹ️ 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/core/src/session/handlers.rs
@jif-oai jif-oai merged commit fcc2a92 into main May 13, 2026
27 checks passed
@jif-oai jif-oai deleted the jif/runtime-fix branch May 13, 2026 12:20
@github-actions github-actions Bot locked and limited conversation to collaborators May 13, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant