Skip to content

Prepare side threads off the TUI event loop#26754

Open
etraut-openai wants to merge 9 commits into
mainfrom
etraut/side-thread-nonblocking-prepare
Open

Prepare side threads off the TUI event loop#26754
etraut-openai wants to merge 9 commits into
mainfrom
etraut/side-thread-nonblocking-prepare

Conversation

@etraut-openai
Copy link
Copy Markdown
Collaborator

@etraut-openai etraut-openai commented Jun 6, 2026

This PR fixes a deadlock that can occur when the TUI prepares a side conversation. Specifically, this can occur if the main thread generates many events in a short period of time when the side preparation takes a long time because of a slow fork operation.

Previously, /side waited for the fork and boundary-injection requests on the main event loop. App-server responses and notifications share a bounded transport, so a notification backlog could block the fork response while the TUI was no longer draining notifications. The backend would keep running, but the TUI could stop rendering and reading input permanently.

Changes

  • Run the side-thread fork and boundary injection in the background so the TUI continues to process app-server notifications and input events.
  • Switch to the prepared side thread using the returned local snapshot, avoiding another app-server round trip on the TUI event loop.
  • Make the composer temporarily read-only while preparation is in progress.
  • Allow the user to cancel a long-running preparation with Esc, restore the pending message, and clean up the unused side thread if the fork completes afterward.

Verification

  • Added coverage that cancelling side-thread preparation restores the pending message.
  • Updated the /side TUI snapshot to cover the read-only composer and cancellation hint.

@etraut-openai etraut-openai marked this pull request as ready for review June 6, 2026 07:19
@etraut-openai etraut-openai changed the title [codex] Prepare side threads off the TUI event loop Fix TUI deadlock while preparing side conversations Jun 6, 2026
@etraut-openai etraut-openai changed the title Fix TUI deadlock while preparing side conversations Prepare side threads off the TUI event loop Jun 6, 2026
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: e6d6bdd589

ℹ️ 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/tui/src/app/side.rs Outdated
Comment thread codex-rs/tui/src/app/side.rs Outdated
Comment thread codex-rs/tui/src/app/side_server.rs Outdated
@openai openai deleted a comment from Bnilesh0210 Jun 6, 2026
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: 6adf62f75c

ℹ️ 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/tui/src/app/side.rs Outdated
Comment thread codex-rs/tui/src/app/side.rs Outdated
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: e5b9dc45d0

ℹ️ 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/tui/src/app/side_server.rs Outdated
Comment thread codex-rs/tui/src/app_event.rs Outdated
Comment thread codex-rs/tui/src/app/side.rs
Comment thread codex-rs/tui/src/app/side.rs Outdated
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: 1664555828

ℹ️ 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/tui/src/app/side.rs Outdated
Comment thread codex-rs/tui/src/app/side.rs
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: e748bdced2

ℹ️ 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/tui/src/app/side_server.rs Outdated
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