Input color becomes black in tmux control mode (tmux -CC) when SSH

Resolved 💬 9 comments Opened Oct 9, 2025 by zeyugao Closed Oct 14, 2025
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

What version of Codex is running?

codex-cli 0.46.0

Which model were you using?

gpt-5-codex high

What platform is your computer?

Linux 6.6.94 x86_64 x86_64
Ubuntu 22.04
tmux 3.4

Darwin 25.0.0 arm64 arm
macOS 26.0.1
tmux 3.5a

iTerm2 Build 3.6.2

What steps can reproduce the bug?

The input becomes black when using tmux control mode (tmux -CC) in ssh, it works fine in local's tmux control mode and common tmux (no control mode)

  • SSH, no tmux

<img width="676" height="397" alt="Image" src="https://github.com/user-attachments/assets/3c9826bb-544c-4913-889d-439466a3f5c9" />

  • SSH, normal tmux

<img width="567" height="652" alt="Image" src="https://github.com/user-attachments/assets/2f18e2eb-81b4-40bc-9903-da782b4f393f" />

  • localhost, no tmux

<img width="637" height="463" alt="Image" src="https://github.com/user-attachments/assets/e6842d43-34ad-45a9-942b-76095a9d8cb8" />

  • localhost, normal tmux

<img width="692" height="656" alt="Image" src="https://github.com/user-attachments/assets/d867cac7-816b-477a-87ec-e0c89bfda802" />

  • localhost, tmux control mode

<img width="639" height="480" alt="Image" src="https://github.com/user-attachments/assets/bed4b96d-543e-4e62-b422-6950c9863deb" />

  • SSH, tmux control mode

<img width="561" height="441" alt="Image" src="https://github.com/user-attachments/assets/d4225164-e3f2-4fec-ac26-7410be654312" />

What is the expected behavior?

_No response_

What do you see instead?

_No response_

Additional information

_No response_

View original on GitHub ↗

9 Comments

github-actions[bot] contributor · 9 months ago

Potential duplicates detected. Please review them and close your issue if it is a duplicate.

  • #4744
  • #4960

Powered by Codex Action

nornagon-openai contributor · 9 months ago

are all the relevant tmux installs >= 3.4? this looks like possibly related to https://github.com/openai/codex/issues/4744#issuecomment-3386362145

not super familiar with tmux, but i'm not sure at first brush why control mode would prevent background color querying from working.

Artawower · 9 months ago

I have exactly the same situation with zellij. This wasn't the case in earlier versions of Codex

zeyugao · 9 months ago

@nornagon-openai I use tmux 3.4 and 3.5a, more specific environment version has been updated in the original issue

zeyugao · 9 months ago

different 0.46.0 alpha behave quite differently, specifically, alpha 4, 5, 6 has a lot of change I think.

By the way, on the version before alpha-4, even I use tmux >= 3.4, I still experienced the issue mentioned in https://github.com/openai/codex/issues/4744

Two related commit are: https://github.com/openai/codex/pull/4957 (in alpha 5) and https://github.com/openai/codex/commit/f4bc03d7c049aaec020d431498949dfb6523f32e (in alpha 6)

0.46.0-alpha.4

  • ssh with tmux control mode

<img width="797" height="323" alt="Image" src="https://github.com/user-attachments/assets/beff9d2a-e396-4936-acbc-20ca29a0a176" />

  • ssh with normal tmux

<img width="616" height="303" alt="Image" src="https://github.com/user-attachments/assets/d78a8590-2870-47d3-893b-4eed0595333b" />

  • ssh without tmux

<img width="562" height="327" alt="Image" src="https://github.com/user-attachments/assets/54e36756-7e01-4822-be5a-0b13238fb18f" />

0.46.0-alpha.5

  • ssh with tmux control mode

<img width="863" height="310" alt="Image" src="https://github.com/user-attachments/assets/c4b90cb4-c027-4686-ba12-03cebf67b751" />

  • ssh with normal tmux

<img width="852" height="315" alt="Image" src="https://github.com/user-attachments/assets/ca343454-f730-4827-9c8c-7b511dc14132" />

  • ssh without tmux

<img width="856" height="312" alt="Image" src="https://github.com/user-attachments/assets/cacc7871-c0ec-4877-ab4c-0b2ea12b84eb" />

0.46.0-alpha.6

  • ssh with tmux control mode

<img width="847" height="305" alt="Image" src="https://github.com/user-attachments/assets/725e93a1-d6fe-42f8-b30b-cba4d4b35023" />

  • ssh with normal tmux

<img width="857" height="332" alt="Image" src="https://github.com/user-attachments/assets/a071649d-71dc-4053-9073-5ed78eaabd75" />

  • ssh without tmux

<img width="803" height="332" alt="Image" src="https://github.com/user-attachments/assets/616065e6-1b56-42c2-9bb9-89146db36f5c" />

zeyugao · 9 months ago

I found that, it is due to the wrong bg readout

https://github.com/openai/codex/blob/26f7c46856060f440615645bdf2faf9e62c74e72/codex-rs/tui/src/terminal_palette.rs#L143-L152

  • normal tmux
query_default_colors called
read 48 bytes, buffer len: 48, fg: Some((0, 0, 0)), bg: Some((255, 255, 255))
returning Some((0, 0, 0), (255, 255, 255))
  • tmux control mode
query_default_colors called
read 48 bytes, buffer len: 48, fg: Some((0, 0, 0)), bg: Some((0, 0, 0))
returning Some((0, 0, 0), (0, 0, 0))

So it failed to give a correct input for

https://github.com/openai/codex/blob/26f7c46856060f440615645bdf2faf9e62c74e72/codex-rs/tui/src/style.rs#L21-L28

  • normal tmux
user_message_bg called with terminal_bg: (255, 255, 255)
top: (0, 0, 0)
blended: (229, 229, 229)
best_color result: Indexed(254)
  • tmux control mode
user_message_bg called with terminal_bg: (0, 0, 0)
top: (255, 255, 255)
blended: (25, 25, 25)
best_color result: Indexed(234)

In the parent commit of https://github.com/openai/codex/commit/e896db1180cc1e893f6d3d878bafe909c518c24e (that is https://github.com/openai/codex/commit/96acb8a74e14897faa36d66cd50768c0b0978e59)

the query_default_colors function is also broken, but the user_message_bg is also broken either

  • normal tmux
Starting user_message_bg with terminal_bg: (255, 255, 255)
top: (0, 0, 0), bottom: (255, 255, 255)
color_level: ColorLevel { level: 2, has_basic: true, has_256: true, has_16m: false }
target: (229, 229, 229)
Using default color
Returning color: Reset
  • tmux control mode
Starting user_message_bg with terminal_bg: (0, 0, 0)
top: (255, 255, 255), bottom: (0, 0, 0)
color_level: ColorLevel { level: 2, has_basic: true, has_256: true, has_16m: false }
target: (25, 25, 25)
Using default color
Returning color: Reset
  • without tmux
Starting user_message_bg with terminal_bg: (255, 255, 255)
top: (0, 0, 0), bottom: (255, 255, 255)
color_level: ColorLevel { level: 2, has_basic: true, has_256: true, has_16m: false }
target: (229, 229, 229)
Using 256 colors, index: 254
Returning color: Indexed(254)

Only the last one works fine, it is due to in the old version of codex, terminal_palette() returns None when using under tmux, but now, terminal_palette() no longer exists, so just let it go.

Now the problem becomes that query_default_colors is broken all the time

zeyugao · 9 months ago

A minimal repro

import sys

sys.stdout.buffer.write(b"\x1b]10;?\x07\x1b]11;?\x07")
sys.stdout.flush()

In normal tmux, it will print

]10;rgb:0000/0000/0000\]11;rgb:fffe/ffff/ffff\

we will get 0,0,0 as fg and 255,255,255 as bg

But in tmux control mode, it will print

^[]10;rgb:0000/0000/0000^G^[]11;rgb:0000/0000/0000^G

that is, we get 0,0,0 as fg and bg both

Edit: well, it seems that it is fixed in a later tmux verison, but it is too new for a lts ubuntu, tmux 3.5a works, so maybe that why my local tmux works but the ssh's tmux doesn't.

nornagon-openai contributor · 9 months ago

Thanks for the detailed investigation. It seems like this is a tmux bug which is fixed in 3.5a (or possibly earlier?), so I'm going to close this out.

zeyugao · 9 months ago

@Artawower I would suggest to try the previous minimal repo in zellij to determine whether it is the same issue