Skip to content

app-server: use connection-specific thread unload delays#20487

Closed
euroelessar wants to merge 2 commits into
mainfrom
ruslan/thread-unload-connection-delay
Closed

app-server: use connection-specific thread unload delays#20487
euroelessar wants to merge 2 commits into
mainfrom
ruslan/thread-unload-connection-delay

Conversation

@euroelessar
Copy link
Copy Markdown
Collaborator

Why

Threads are eligible for unload after the last connection unsubscribes, but the appropriate grace period depends on the connection type. Local in-process and stdio clients can release immediately after the last subscriber leaves, while socket, TCP websocket, and remote-control clients should keep the existing 30-minute grace window to preserve reconnect behavior.

What changed

  • Added per-origin unload delays on ConnectionOrigin.
  • Carried each initialized connection delay into app-server thread subscription state.
  • Made ThreadStateManager publish whether subscribers exist plus the winning unload delay, using the maximum delay among active subscribers and retaining that value once the thread becomes idle.
  • Passed distinct unix socket and websocket origins through transport setup.
  • Updated v2 unsubscribe tests and README notes for immediate stdio unload behavior.

Verification

  • git diff --check ae863e72a27a283c08023dcf039871c917209120
  • CARGO_TARGET_DIR=/tmp/codex-app-server-target cargo test -p codex-app-server connection_origin_sets_thread_unloading_delay
  • CARGO_TARGET_DIR=/tmp/codex-app-server-target cargo test -p codex-app-server adding_connection_to_thread_updates_subscription_watcher
  • CARGO_TARGET_DIR=/tmp/codex-app-server-target cargo test -p codex-app-server thread_unsubscribe_over_stdio
  • CARGO_TARGET_DIR=/tmp/codex-app-server-target cargo test -p codex-app-server thread_unsubscribe_during_turn_keeps_turn_running

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: eaf60c2b68

ℹ️ 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/app-server/src/codex_message_processor.rs
@euroelessar euroelessar changed the title Use connection-specific thread unload delays app-server: use connection-specific thread unload delays Apr 30, 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.

@github-actions github-actions Bot closed this May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant