Panes keep a departed client's OSC 11 background and get no mode-2031 notification when a light client reattaches
Is this a reproducible bug?
- I confirm this is a reproducible bug, not a feature request, idea, question, contribution proposal, or direction check.
- I reproduced this bug on the version and environment reported below using the exact steps provided.
Current behavior
Claude Code: after a client with a dark background attaches and leaves, panes keep answering OSC 11 with that client's background, even with no client attached. When a light client attaches again, OSC 11 answers light, but panes that enabled mode 2031 get no CSI ? 997 ; n notification.
Where I hit it: my local light Ghostty client detaches when the display turns off, a terminal from another host with a dark background attaches, and Claude Code sessions ("theme": "auto") that query during that window switch to their dark theme. They stay dark after the light Ghostty reattaches: light-grey text on a white background.
Expected behavior
When the colours panes are answered with change because a different client attached, panes with mode 2031 enabled receive CSI ? 997 ; n for the new scheme. With no client attached, panes are not answered with the colours of a client that has left.
Reproduction
Probe, run in the pane (touch /tmp/q to send an OSC 11 query; everything the pane receives goes to /tmp/probe.log):
import os, tty, select
fd = os.open('/dev/tty', os.O_RDWR); tty.setraw(fd); os.write(fd, b'\x1b[?2031h')
log = open('/tmp/probe.log', 'a')
while True:
r, _, _ = select.select([fd], [], [], 1)
if r: log.write(repr(os.read(fd, 4096)) + '\n'); log.flush()
if os.path.exists('/tmp/q'): os.remove('/tmp/q'); os.write(fd, b'\x1b]11;?\x1b\\')- System in light mode.
ghostty -e herdr session attach repro, run the probe in the pane,touch /tmp/q→rgb:fafa/fafa/fafa. Close the window. ghostty --theme="One Half Dark" -e herdr session attach repro, then close it.touch /tmp/qwith nothing attached →rgb:2828/2c2c/3434(the closed dark window's background).ghostty -e herdr session attach repro(light). Nothing arrives in/tmp/probe.log.touch /tmp/q→rgb:fafa/fafa/fafa.
A program that sampled OSC 11 in step 3 is never told about step 4.
Possibly related: #4183 (live appearance flips on macOS/0.9.0; on 0.9.1/Linux a live flip reported by the attached client does reach panes), #3773.
Impact
Long-running Claude Code panes become unreadable (light text on the light background) after a client from another host has attached, until each session is restarted.
Environment
- Herdr version: 0.9.1
- Update channel (stable or preview): stable
- Operating system: Arch Linux (kernel 7.2.7), KDE Plasma Wayland
- Terminal: Ghostty 1.3.1,
theme = dark:One Half Dark,light:One Half Light - Shell, if relevant: fish
- Relevant config, if any:
[theme] name = "one-light",auto_switch = false
Source: herdrdev/herdr