diff --git a/src/hqt/tmux/runner.py b/src/hqt/tmux/runner.py index 5311352..b58cb88 100644 --- a/src/hqt/tmux/runner.py +++ b/src/hqt/tmux/runner.py @@ -351,8 +351,10 @@ class TmuxRunner: return None window_id = stdout.strip() - # Style by window_id: automatic-rename off, the @hqt_label, then the - # Frappé per-window theme — one atomic invocation (";" argv separators). + # Style by window_id: automatic-rename + allow-rename off (nvim/lazygit + # emit OSC title sequences that would otherwise scramble the label), the + # @hqt_label, then the Frappé per-window theme — one atomic invocation + # (";" argv separators). Mirrors new_window's window-option setup. rc, _, err = await self._exec( "set-option", "-w", @@ -365,6 +367,13 @@ class TmuxRunner: "-w", "-t", window_id, + "allow-rename", + "off", + ";", + "set-option", + "-w", + "-t", + window_id, "@hqt_label", label, ";", diff --git a/tests/test_tmux.py b/tests/test_tmux.py index c9047b8..52ffb08 100644 --- a/tests/test_tmux.py +++ b/tests/test_tmux.py @@ -1021,7 +1021,7 @@ async def test_new_aux_window_spawns_styles_and_selects(runner): runner._exec.side_effect = [ (0, "0\n", ""), # _next_window_index: indices [0] -> next index 1 (0, "@7\n", ""), # new-window -P -F '#{window_id}' - (0, "", ""), # set-option (automatic-rename + @hqt_label + theme) + (0, "", ""), # set-option (automatic-rename + allow-rename + @hqt_label + theme) (0, "", ""), # select-window ] wid = await runner.new_aux_window("lazygit", "/proj", ["lazygit"], "lazygit · proj") @@ -1037,6 +1037,8 @@ async def test_new_aux_window_spawns_styles_and_selects(runner): assert calls[2].args[:6] == ( "set-option", "-w", "-t", "@7", "automatic-rename", "off", ) + # allow-rename off too, so nvim/lazygit OSC titles can't scramble the label. + assert "allow-rename" in calls[2].args assert "@hqt_label" in calls[2].args assert "lazygit · proj" in calls[2].args assert "remain-on-exit" not in calls[2].args