Skip to content

fix: try to fix freezes 2#9951

Merged
jif-oai merged 2 commits intomainfrom
jif/fix-freeze-2
Jan 27, 2026
Merged

fix: try to fix freezes 2#9951
jif-oai merged 2 commits intomainfrom
jif/fix-freeze-2

Conversation

@jif-oai
Copy link
Collaborator

@jif-oai jif-oai commented Jan 27, 2026

Fixes a TUI freeze caused by awaiting mpsc::Sender::send() that blocks the tokio thread, stopping the consumption runtime and creating a deadlock. This could happen if the server was producing enough chunks to fill the mpsc fast enough. To solve this we try on insert using a try_send() (not requiring an await) and delegate to a tokio task if this does not work

This is a temporary solution as it can contain races for delta elements and a stronger design should come here

@jif-oai jif-oai enabled auto-merge (squash) January 27, 2026 00:54
@openai openai deleted a comment from chatgpt-codex-connector bot Jan 27, 2026
if should_send {
// Never await a bounded channel send on the main TUI loop: if the receiver falls behind,
// `send().await` can block and the UI stops drawing. If the channel is full, wait in a
// spawned task instead.
Copy link
Collaborator

Choose a reason for hiding this comment

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

@codex scan all uses of channels in codex-rs and propose an AGENTS.md update with best practices to improve our usage of them

@jif-oai jif-oai disabled auto-merge January 27, 2026 01:02
@jif-oai jif-oai merged commit 73bd84d into main Jan 27, 2026
30 of 32 checks passed
@jif-oai jif-oai deleted the jif/fix-freeze-2 branch January 27, 2026 01:02
@github-actions github-actions bot locked and limited conversation to collaborators Jan 27, 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.

2 participants