tide: ask the terminal from inside tmux too

The OSC 11 query opted out under tmux on the assumption it would need the
\ePtmux; passthrough wrapper. It does not, and that assumption cost the
fix precisely where it was wanted: ssh'd into a box inside tmux.

tmux answers OSC 11 from a pane itself, out of the background it queried
from the outer terminal, and it re-queries when that terminal reports a
colour scheme change -- so the value tracks the real window rather than
going stale at tmux start. Measured on tmux 3.7b, the version on both
ends: a pane's query is answered without ever reaching the outer
terminal, and after a colour scheme notification the next query returns
the new background. No tmux configuration is required.

Passthrough is the wrong tool here and stays unused: it is output-only,
so the outer terminal's reply goes to tmux rather than to the pane, and
a wrapped query returns nothing at all.

screen keeps opting out -- untested rather than known broken, and there
the caller falls back to the config files as before.

The live pty suite gains a remote-tmux scenario: config files all dark,
terminal reporting light, the whole thing inside tmux. It fails with the
opt-out restored.
This commit is contained in:
Anton Volnuhin 2026-08-06 18:04:39 +03:00
parent af52fcf7a3
commit 513ec573b1
2 changed files with 20 additions and 7 deletions

View File

@ -9,11 +9,16 @@ function __tide_terminal_osc_background \
status is-interactive status is-interactive
or return 1 or return 1
# tmux and screen both need the query wrapped, and each wants it wrapped # tmux needs no special handling: it answers OSC 11 from a pane itself, out
# differently. Leave those to the caller's config-file path instead of # of the background it queried from the outer terminal, and it re-queries
# guessing wrong and eating the user's keystrokes waiting for a reply. # when that terminal reports a colour scheme change -- so the answer tracks
set -q TMUX # the real window. Do not reach for the \ePtmux; passthrough wrapper here:
and return 1 # that is output-only, the reply goes to tmux rather than to this pane, and
# the query then times out having achieved nothing.
#
# screen is left out because it is untested rather than known broken; there
# the caller falls back to reading the config files, as it did everywhere
# before this query existed.
string match -q 'screen*' -- "$TERM" string match -q 'screen*' -- "$TERM"
and return 1 and return 1

View File

@ -18,9 +18,17 @@ set path_label "direct"
set through_tmux 0 set through_tmux 0
set mode [expr {[llength $argv] > 0 ? [lindex $argv 0] : "direct"}] set mode [expr {[llength $argv] > 0 ? [lindex $argv 0] : "direct"}]
if {$mode eq "tmux"} { if {$mode eq "tmux" || $mode eq "remote-tmux"} {
set path_label "tmux" set path_label $mode
set through_tmux 1 set through_tmux 1
if {$mode eq "remote-tmux"} {
# The ssh-inside-tmux case. tmux answers OSC 11 from a pane out of the
# background it holds for the outer terminal, so the query works here
# with no wrapping -- but only if nothing opts out of asking.
set kitty_config [file join $fixtures kitty-remote-dark]
set light_reply "ebeb/e8e8/e4e4"
set light_segment "DFDCD8"
}
spawn env TERM=xterm-kitty KITTY_CONFIG_DIRECTORY=$kitty_config \ spawn env TERM=xterm-kitty KITTY_CONFIG_DIRECTORY=$kitty_config \
tmux -L tide-appearance-test \ tmux -L tide-appearance-test \
-f "$env(HOME)/.tmux.conf" new-session fish --interactive -f "$env(HOME)/.tmux.conf" new-session fish --interactive