From 513ec573b1133dc0ec44692ba4dd92832bca4774 Mon Sep 17 00:00:00 2001 From: Anton Volnuhin Date: Thu, 6 Aug 2026 18:04:39 +0300 Subject: [PATCH] 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. --- .../private___tide_terminal_osc_background.fish | 15 ++++++++++----- .../private_verify_tide_terminal_events.exp | 12 ++++++++++-- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/private_dot_config/private_fish/functions/private___tide_terminal_osc_background.fish b/private_dot_config/private_fish/functions/private___tide_terminal_osc_background.fish index ac297d3..42a0388 100644 --- a/private_dot_config/private_fish/functions/private___tide_terminal_osc_background.fish +++ b/private_dot_config/private_fish/functions/private___tide_terminal_osc_background.fish @@ -9,11 +9,16 @@ function __tide_terminal_osc_background \ status is-interactive or return 1 - # tmux and screen both need the query wrapped, and each wants it wrapped - # differently. Leave those to the caller's config-file path instead of - # guessing wrong and eating the user's keystrokes waiting for a reply. - set -q TMUX - and return 1 + # tmux needs no special handling: it 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 answer tracks + # the real window. Do not reach for the \ePtmux; passthrough wrapper here: + # 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" and return 1 diff --git a/private_dot_config/private_fish/private_tests/private_verify_tide_terminal_events.exp b/private_dot_config/private_fish/private_tests/private_verify_tide_terminal_events.exp index 4613cd4..39f8cb0 100644 --- a/private_dot_config/private_fish/private_tests/private_verify_tide_terminal_events.exp +++ b/private_dot_config/private_fish/private_tests/private_verify_tide_terminal_events.exp @@ -18,9 +18,17 @@ set path_label "direct" set through_tmux 0 set mode [expr {[llength $argv] > 0 ? [lindex $argv 0] : "direct"}] -if {$mode eq "tmux"} { - set path_label "tmux" +if {$mode eq "tmux" || $mode eq "remote-tmux"} { + set path_label $mode 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 \ tmux -L tide-appearance-test \ -f "$env(HOME)/.tmux.conf" new-session fish --interactive