Some panes don't resize properly when reattaching to a domain
What Operating System(s) are you seeing this problem on?
macOS
Which Wayland compositor or X11 Window manager(s) are you using?
macOS default
WezTerm version
wezterm 20240226-174525-22424c32
Did you try the latest nightly build to see if the issue is better (or worse!) than your current version?
Yes, and I updated the version box above to show the version of the nightly that I tried
Describe the bug
I'm using unix domains to manage sets of tabs and windows on remote machines, and I usually like to lay things out something like this:
+---------+--------+
| | Pane 1 |
| Pane 0 +--------+
| | Pane 2 |
+---------+--------+
That is, I start with the first pane, split that ↔ right, then split that ↕ down
I'll then detach from the domain to get distracted with things, and when I reattach the bottom-right pane (2) will have an incorrect size such that many rows & columns will overshoot the bottom & right sides of the window, and the rows will not be corrected by resizing the main window. Columns will be fixed, however. I believe it's sized to the full-window size, since zooming into the pane will result in everything being on-screen (it will not cause a re-size, though, so doesn't fix the issue)
To Reproduce
- Connect to a unix domain (I can reproduce this reliably with the local and remote domains based on an SSH
proxy_command) - Split the panes like I've described
- Detach from the domain
- Reattach
- Bottom-right pane will now have an incorrect size and not fit into the space in the window
Configuration
I've tested it with this, which is essentially a completely default config:
local wezterm = require "wezterm"
-- local env = require "env"
local config = wezterm.config_builder()
-- stylua: ignore start
if
not (
env.hostname == "desktop.local" or
env.hostname == "laptop.local"
)
then
wezterm.log_warn "disabling config"
return config
end
-- stylua: ignore end
-- require("conf")(config)
-- require("keys")(config)
-- require("layouts")(config)
-- require("domains")(config)
-- require("status")(config)
-- require("tab")(config)
-- require("theme")(config)
return config
Expected Behavior
I'd expect that all panes would resize properly after re-attaching, such that the entire content fits within the split pane.
I'd also expect that everything would resize to my current window size anyway, since I'm always running in maximised, meaning that attaching to a domain that had been previously opened on a differently-sized screen requires me to un-maximise and then re-maximise to get everything sized properly. Not sure if this is a different issue, though.
Logs
Debug Overlay
wezterm version: 20240226-174525-22424c32 aarch64-apple-darwin
Window Environment: macOS 14.3.1 (23D60)
Lua Version: Lua 5.4
OpenGL: Apple M1 Max 4.1 Metal - 88
Enter lua statements or expressions and hit Enter.
Press ESC or CTRL-D to exit
20:13:33.689 INFO wezterm_client::domain > detached domain 1
20:13:33.689 INFO mux > domain detached panes: [29, 28, 25, 30, 27, 26]
20:13:33.692 INFO wezterm_client::domain > detached domain 1
20:13:33.692 INFO mux > domain detached panes: []
Anything else?
Other than this frustrating little issue, I'm very much enjoying this terminal, so thank you!
I've also just found that, when a pane gets into this state, trying to swap panes results in some weird behaviour. I'll attempt to swap them, the window will flash, and then nothing will happen. Not sure what's going on, but exiting all but the first pane and opening them back up again seems to fix it.
Edit: It seems to only occur when there's splits in multiple directions, but even multiple splits in the same direction results in some weird behaviour with swapping.
I've retested this - its still present on nightly, and also works with SSH domains. It's one of the main reasons I'm still using tmux :(
I'd be tempted to try having a stab at this myself, but with the size of the codebase I'd probably need some pointer to start so I dont go mad.
I encountered a similar issue and investigated the root cause.
Environment:
- OS: Kubuntu 22.04 (X11)
- mux server: Unix domain
- Version: Nightly 20251201-075747-d3b0fdad
Reproduction scenario:
- Connect to mux server via unix domain
- Open two windows: one with horizontally split panes (100x50 + 100x50), one single pane (100x50)
- Close the single-pane window (which disconnects the client)
- Reconnect
- The split pane window now has incorrect sizes (100x50 + 201x50 instead of the original 100x50 + 100x50)
Root cause:
When closing a window triggers domain.detach(), the following call chain occurs:
mux.kill_window()→domain.detach()→domain_was_detached()→kill_panes_in_domain()→remove_pane_if()
Inside remove_pane_if(), when panes are removed, remaining panes are resized to fill the space. This resize is sent to the server via ClientPane::resize(), corrupting the pane sizes stored on the server.
Fix:
Skip sending resize to the server when the domain is in the Detached state (similar to how ClientPane::kill() already handles this case).
I'm attaching a working patch below.