Skip to content

fix(tui): restore TUI after suspend#28342

Merged
fcoury-oai merged 10 commits into
mainfrom
fcoury/fix-suspend-resume-composer
Jun 16, 2026
Merged

fix(tui): restore TUI after suspend#28342
fcoury-oai merged 10 commits into
mainfrom
fcoury/fix-suspend-resume-composer

Conversation

@fcoury-oai

@fcoury-oai fcoury-oai commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Why

On Linux, suspending Codex with Ctrl+Z and returning with fg can leave the composer misaligned or inject terminal response bytes such as focus reports into the prompt. Shell job-control output moves the cursor while Codex is suspended, and terminal input polling can race with the responses used to restore the inline viewport.

Fixes #26564.

What changed

  • preserve and restore keyboard reporting without disturbing the parent terminal stack
  • pause terminal event polling while Codex is suspended and flush buffered input before resuming it
  • force crossterm's cached raw-mode state back in sync after the shell completes its fg handoff
  • probe the actual post-fg cursor position with the tolerant terminal-response parser, then realign the inline viewport before redrawing

How to Test

  1. On Linux, start the development TUI with just c.
  2. Type text into the composer without submitting it.
  3. Press Ctrl+Z, run any harmless shell command, then run fg.
  4. Confirm the composer redraws below the shell output, the draft text is preserved, and no raw escape sequences appear.
  5. Repeat the suspend/resume cycle and confirm normal typing still works.

Targeted tests:

  • cargo test -p codex-tui --lib parses_cursor_position_as_zero_based -j 1
  • cargo test -p codex-tui --lib tui::event_stream::tests -j 1

@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: 8cd57a5c7b

ℹ️ 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/tui.rs
Comment thread codex-rs/tui/src/tui/event_stream.rs Outdated
Comment thread codex-rs/tui/src/tui/job_control.rs
@fcoury-oai

Copy link
Copy Markdown
Contributor Author

@codex review

@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: 044954fb61

ℹ️ 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/tui/job_control.rs
@fcoury-oai

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: b815ab6ef0

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

@fcoury-oai
fcoury-oai force-pushed the fcoury/fix-suspend-resume-composer branch from b815ab6 to 8abb3af Compare June 15, 2026 19:38
@fcoury-oai
fcoury-oai enabled auto-merge (squash) June 16, 2026 01:04

@etraut-openai etraut-openai 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.

Approach looks reasonable, and code looks good.

@fcoury-oai
fcoury-oai merged commit 76135cb into main Jun 16, 2026
31 checks passed
@fcoury-oai
fcoury-oai deleted the fcoury/fix-suspend-resume-composer branch June 16, 2026 16:09
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 16, 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.

Codex doesn't work properly after resuming from being sent to suspend

2 participants