Skip to content

Reconnect Codex tmux proxy after app-server drops#54

Merged
axeldelafosse merged 5 commits intomainfrom
codex/codex-tmux-proxy-reconnect
Mar 31, 2026
Merged

Reconnect Codex tmux proxy after app-server drops#54
axeldelafosse merged 5 commits intomainfrom
codex/codex-tmux-proxy-reconnect

Conversation

@axeldelafosse
Copy link
Copy Markdown
Owner

Summary

  • keep the Codex tmux proxy alive when its upstream app-server websocket drops
  • reconnect the proxy upstream with capped backoff and reinitialize the upstream protocol state after reconnect
  • add a live websocket regression test proving the TUI-side socket stays connected and can submit another turn after reconnect

Root cause

In paired tmux mode, tmux handoff releases the local Codex app-server handles. That leaves the tmux proxy as the only remaining supervisor for the Codex-side connection. The proxy previously treated any upstream websocket close as terminal and stopped immediately, which dropped the Codex TUI remote socket and left only a dead pane via remain-on-exit.

User impact

Paired tmux sessions no longer fail fast on a live app-server websocket drop. The proxy retries the upstream connection instead of immediately tearing down the TUI-side socket.

Validation

  • bun test
  • bun run fix
  • bun run check

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces automatic reconnection logic for the CodexTmuxProxy, featuring exponential backoff, a formal initialization handshake, and updated health check endpoints. These changes ensure that the proxy can recover from upstream disconnects without dropping existing TUI socket connections. Feedback was provided to improve the clarity of the error message returned while the proxy is attempting to reconnect to the app-server.

Comment on lines +595 to +602
if (!this.upstream) {
this.forwardToTui(
JSON.stringify(
proxyErrorFrame(frame.id, "codex app-server is reconnecting")
)
);
return;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The error message 'codex app-server is reconnecting' is slightly misleading because the proxy is the one reconnecting to the app-server. Consider changing this to 'codex app-server connection is being established' for better clarity.

@axeldelafosse axeldelafosse changed the title [codex] reconnect Codex tmux proxy after app-server drops Reconnect Codex tmux proxy after app-server drops Mar 31, 2026
@axeldelafosse axeldelafosse marked this pull request as ready for review March 31, 2026 21:47
@axeldelafosse axeldelafosse merged commit bd72aec into main Mar 31, 2026
2 checks passed
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