[CLI][TUI][Linux] SSH disconnect leaves idle TUI holding the thread writer lock; resume fails with "already has an active writer" until the old process is killed
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 125k
- Forks
- 19.4k
- PR merge metrics
- PR metrics pending
Description
What version of Codex CLI is running?
codex-cli 0.153.4 (npm @openai/codex), reproduced 2026-09-09
What subscription do you have?
API-key authentication through a Responses-compatible provider; no ChatGPT subscription is involved in this reproduction.
Which model were you using?
deepseek-v4-flash
What platform is your computer?
Environment:
- Client: Windows Terminal (Windows 10, built-in OpenSSH ssh.exe), plain SSH session; no ServerAliveInterval configured on the client
- Host: Ubuntu 24.04.4 LTS (x86_64)
- codex-cli 0.153.4 installed via the @openai/codex npm package
- node v22.22.2 / npm 10.9.7
- Remote login shell: bash; no tmux/screen/zellij, no
sudo su, no VS Code
What terminal emulator and version are you using (if applicable)?
No response
Codex doctor report
What issue are you seeing?
If the SSH connection drops while the Codex TUI is running (even when it is
idle and the last turn is complete), the TUI process keeps running and keeps
holding the thread's writer lock. The server never notices the half-open TCP
connection (no ClientAliveInterval), so the process can survive for hours.
A later codex resume from a new SSH session fails with:
Error: Failed to resume session from ~/.codex/sessions//rollout-<...>-.jsonl:
thread/resume failed during TUI bootstrap: thread/resume failed:
thread already has an active writer (code -32600)
What steps can reproduce the bug?
- From Windows Terminal, run
ssh <user>@<host>andcdinto a project
directory on the remote host. - Run
codex, complete one turn, and leave the TUI idle at the prompt. - Abruptly kill the SSH client or drop the network.
- Reconnect and run
codex resume(or resume from the TUI picker). - Observe the "already has an active writer" failure.
What is the expected behavior?
No response
Additional information
This is the simplest possible repro of the "terminal disconnect leaves an
active writer" lifecycle problem: plain SSH, no editor integration, no wrapper
PTY chain. Configuring sshd ClientAliveInterval is only a server-side
workaround and does not help users who need to take over a thread from another
session while the stale process is still alive.
Related: #39345, #37403, #38297, #12515
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the plain SSH disconnect while the TUI is idle, then trace the codex resume path through thread/resume and TUI bootstrap. The issue names no source files or tests, so locate the lifecycle handling for the disconnected TUI and its thread writer lock. Done means a later resume from a new SSH session no longer fails with "already has an active writer".
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli, networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100