OSC 4 palette reply fragments leak into the focused pane when Herdr runs inside tmux 3.6 (macOS)
Author: ConnerV42Created Sep 13, 2026Updated Sep 30, 2026
Labelsbugmaintainer-neededp2macosinput
Symptom
Text like this appears in the focused pane's input (here: Claude Code's prompt), typically after the outer terminal regains focus:
e4/e4e4/e4e4;rgb:0000/afaf/d7d7ffafaf/ffff/5f5fd7/ffff/8787d7d7/5 f5f/5f5fff/afaf/0000Those are tails of OSC 4;<n>;rgb:… palette replies (xterm-256 cube/gray values).
herdr-client.log at the same moments:
WARN herdr::raw_input: flushing lone escape after input timeout; if this follows an alt chord or focus switch it may reach the pane as plain esc bytes=[27]Environment
- Herdr 0.9.0 (stable), macOS (Darwin 25.6, Apple Silicon)
- Outer terminal: Alacritty → tmux 3.6b (
focus-events on) →herdrclient in a tmux pane - Local session, not remote
Mechanism (from reading v0.9.0 source)
- tmux
focus-events onforwardsESC[Ito the pane →RawInputEvent::OuterFocusGained→outcome.query_host_appearance→ Herdr writesESC[?996n(terminal_theme::HOST_COLOR_SCHEME_QUERY_SEQUENCE). - tmux 3.6 implements mode 2031 and answers
ESC[?997;1n→RawInputEvent::HostColorSchemeChanged→outcome.query_host_theme = trueunconditionally (src/client/shell/input.rs). write_host_terminal_theme_querycallshost_terminal_theme_query_sequence(should_query_host_terminal_palette());platform/macos.rsreturnstrue, so Herdr emits 256 ×ESC]4;<n>;?ESC\in one burst — on every focus gain.- tmux 3.6 changed OSC 4 handling: "If tmux receives a palette request (OSC 4) in a pane and the palette entry has not been set, send a request to the most recently used client and forward any response instead" (tmux issue 4665). Each of the 256 queries becomes an async round-trip to Alacritty; replies are relayed back one at a time with arbitrary gaps.
RawInputByteFrameronly holds incompleteESC]10;/ESC]11;replies (starts_with_incomplete_default_color_response). An incompleteESC]4;…reply at a read boundary hitsRAW_INPUT_IDLE_FLUSH_TIMEOUT_MS = 10, gets discarded (discard_until = Osc) or, when the chunk was a bareESC, flushed as a plain escape (the WARN above). The remainder of that reply then arrives without an introducer and is forwarded to the focused pane as ordinary text.
The same class of bug was fixed for WSL/ConPTY by skipping the palette burst entirely (#2440); macOS-under-tmux has no such exemption, and #549's split-reply fix covers only OSC 10/11.
Suggested fixes
- Hold incomplete
ESC]4;replies the same way OSC 10/11 are held whilehost_color_replies_awaited > 0, with a longer timeout than 10 ms (tmux forwarding easily exceeds that). - Or skip the 256-entry palette burst when
TERM_PROGRAM=tmux(like the WSL exemption), and/or only re-query the palette when the reported appearance actually changed rather than on everyHostColorSchemeChanged.
Workarounds that stop the recurrence
set -g focus-events offin.tmux.conf(removes the per-focus trigger; the burst on Herdr client start remains).- Run Herdr directly in the outer terminal instead of inside tmux.
Source: herdrdev/herdr