Unexpected extra window when opening a workspace in a domain.
What Operating System(s) are you seeing this problem on?
macOS
Which Wayland compositor or X11 Window manager(s) are you using?
No response
WezTerm version
20231030-074559-75909682
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 have a very simple config set up to automatically open a workspace in a domain.
It works, but it has some unexpected behavior: If I switch to parsonos.lab / Parsonos Lab, then back to local / default, I suddenly also have a window open at parsonos.lab / default. This window (re)opens every time I switch back and forth.
The docs:
The wezterm GUI is focused on the active workspace, which means that it will present a GUI window for each MuxWindow that is present in that workspace.
So I wouldn't expect the default workspace to care about the parsonos.lab domain at all.
To Reproduce
My other config is cosmetic only. To reproduce: set up the config as above, then switch back and forth between workspaces using the keymaps.
Configuration
config.unix_domains = {
{
name = "parsonos.lab",
},
}
config.leader = { key = "a", mods = "CTRL" }
config.keys = {
-- Switch to the default workspace
{
key = "=",
mods = "LEADER",
action = act.SwitchToWorkspace({
name = "default",
}),
},
{
key = "!",
mods = "LEADER",
action = wezterm.action({
SwitchToWorkspace = {
name = "Parsonos Lab",
spawn = {
domain = { DomainName = "parsonos.lab" },
},
},
}),
},
-- Create a new workspace with a random name and switch to it
{ key = "i", mods = "CTRL|SHIFT", action = act.SwitchToWorkspace },
-- Show the launcher in fuzzy selection mode and have it list all workspaces
-- and allow activating one.
{
key = "*",
mods = "LEADER",
action = act.ShowLauncherArgs({
flags = "FUZZY|WORKSPACES",
}),
},
}
Expected Behavior
I expected no window parsonos.lab / default to appear.
Logs
❯ wezterm 17:45:14.225 WARN wezterm_client::client > While connecting to Socket("/Users/ruben/.local/share/wezterm/sock"): connecting to /Users/ruben/.local/share/wezterm/sock. Will try spawning the server. 17:45:14.227 WARN wezterm_client::client > Running: "/opt/homebrew/bin/wezterm-mux-server" "--daemonize" 17:45:23.284 INFO mux > detaching domain 17:45:23.285 INFO wezterm_client::domain > detached domain 1 17:45:23.285 INFO mux > domain detached panes: [3, 2] 17:45:23.316 INFO wezterm_client::domain > detached domain 1 17:45:23.316 INFO mux > domain detached panes: []
Anything else?
No response
I was trying to work around this issue by writing my own implementation of the behaviour I wanted, with the added benefit of more fine-grained control. However, this made the issue much worse?
local open_default_workspace = wezterm.action_callback(function(window, pane)
mux.set_active_workspace("default")
end)
local open_lab_workspace = wezterm.action_callback(function(window, pane)
if pcall(mux.set_active_workspace, "parsonos-lab") then
return
end
local project_dir = "parsonos-lab"
local tab, build_pane, window = mux.spawn_window({
workspace = "parsonos-lab",
cwd = project_dir,
domain = { DomainName = "parsonos.lab" },
})
local editor_pane = build_pane:split({
direction = "Top",
size = 0.8,
cwd = project_dir,
domain = { DomainName = "parsonos.lab" },
})
editor_pane:send_text("nvim .\n")
mux.set_active_workspace("parsonos-lab")
end)
Now, every time I switch back to default from lab, I get increasingly more windows in default with a domain of parsonos.lab. Half of them share the pane setup from the open_lab_workspace, except the split has different proportions. Finally, when I close any one of the "extra" windows, all of them close.
Hope this helps!
Can you minimize the steps that reproduce this? What I'd like to see is a precise/deterministic set of steps (so, avoid instructions like "try switching back and forth"), and what would be helpful is seeing the output from wezterm cli list --format json from before and after the critical step that triggers the misbehavior.
Thank you!
Ok, I simplified this as far as I could. 😅 Here goes:
local wezterm = require("wezterm")
local act = wezterm.action
local mux = wezterm.mux
local config = wezterm.config_builder()
wezterm.on("update-status", function(window, pane)
window:set_left_status(wezterm.format({
{ Foreground = { AnsiColor = "Red" } },
{ Text = " " .. window:active_workspace() .. " / " .. pane:get_domain_name() .. " " },
}))
end)
config.unix_domains = {
{
name = "parsonos.lab",
},
}
config.keys = {
-- Switch to the default workspace
{
key = "1",
mods = "CTRL",
action = act.SwitchToWorkspace({
name = "default",
}),
},
{
key = "2",
mods = "CTRL",
action = wezterm.action({
SwitchToWorkspace = {
name = "Parsonos Lab",
spawn = {
domain = { DomainName = "parsonos.lab" },
},
},
}),
},
}
return config
- Open Wezterm. Status shows
default / localas expected - Hit CTRL-2. After a short lag of starting up domain, the window is exchanged with
Parsonos Lab / parsonos.labas expected - Hit CTRL-1. GUI instantly switches to two windows. One is
default / localas expected, the other isdefault / parsonos.lab(unexpected!) - Bonus: Hit CTRL-2 again. If you did not close the extra
default / parsonos.labwindow, then it just switchesParsonos Lab / parsonos.labas expected. If you did close the extradefault / parsonos.labwindow, then a new tab is opened (the old ones are still there), running the default command.
Additional observation: The unexpected extra window appears at random locations whenever switching back to default.
Cheers! 🍻
The even weirder behaviour from my attempted workaround still stands, it follows the same pattern. It just spawns more "extra" windows, which close all together when any one is closed.
Please also include the wezterm cli list --format json output from before and after the critical step
After clean startup (restarted mux as well):
[
{
"window_id": 0,
"tab_id": 0,
"pane_id": 0,
"workspace": "default",
"size": {
"rows": 24,
"cols": 80,
"pixel_width": 1120,
"pixel_height": 768,
"dpi": 144
},
"title": "zsh",
"cwd": "file://rubens-macbook-air.local/Users/ruben",
"cursor_x": 0,
"cursor_y": 1,
"cursor_shape": "Default",
"cursor_visibility": "Visible",
"left_col": 0,
"top_row": 0,
"tab_title": "",
"window_title": "",
"is_active": true,
"is_zoomed": false,
"tty_name": "/dev/ttys000"
}
]
After first step out to Parsonos Lab / parsonos.lab
[
{
"window_id": 0,
"tab_id": 0,
"pane_id": 0,
"workspace": "default",
"size": {
"rows": 24,
"cols": 80,
"pixel_width": 640,
"pixel_height": 384,
"dpi": 0
},
"title": "zsh",
"cwd": "file://rubens-macbook-air.local/Users/ruben",
"cursor_x": 3,
"cursor_y": 1,
"cursor_shape": "SteadyBar",
"cursor_visibility": "Visible",
"left_col": 0,
"top_row": 0,
"tab_title": "",
"window_title": "",
"is_active": true,
"is_zoomed": false,
"tty_name": "/dev/ttys001"
},
{
"window_id": 1,
"tab_id": 1,
"pane_id": 1,
"workspace": "Parsonos Lab",
"size": {
"rows": 24,
"cols": 80,
"pixel_width": 1120,
"pixel_height": 768,
"dpi": 144
},
"title": "zsh",
"cwd": "file://rubens-macbook-air.local/Users/ruben",
"cursor_x": 0,
"cursor_y": 1,
"cursor_shape": "Default",
"cursor_visibility": "Visible",
"left_col": 0,
"top_row": 0,
"tab_title": "",
"window_title": "",
"is_active": true,
"is_zoomed": false,
"tty_name": "/dev/ttys002"
}
]
After switching back to default:
[
{
"window_id": 2,
"tab_id": 2,
"pane_id": 2,
"workspace": "default",
"size": {
"rows": 24,
"cols": 80,
"pixel_width": 1120,
"pixel_height": 768,
"dpi": 144
},
"title": "zsh",
"cwd": "file://rubens-macbook-air.local/Users/ruben",
"cursor_x": 3,
"cursor_y": 1,
"cursor_shape": "SteadyBar",
"cursor_visibility": "Visible",
"left_col": 0,
"top_row": 0,
"tab_title": "",
"window_title": "",
"is_active": true,
"is_zoomed": false,
"tty_name": null
},
{
"window_id": 1,
"tab_id": 3,
"pane_id": 3,
"workspace": "Parsonos Lab",
"size": {
"rows": 24,
"cols": 80,
"pixel_width": 1120,
"pixel_height": 768,
"dpi": 144
},
"title": "zsh",
"cwd": "file://rubens-macbook-air.local/Users/ruben",
"cursor_x": 3,
"cursor_y": 23,
"cursor_shape": "SteadyBar",
"cursor_visibility": "Visible",
"left_col": 0,
"top_row": 0,
"tab_title": "",
"window_title": "",
"is_active": true,
"is_zoomed": false,
"tty_name": null
},
{
"window_id": 0,
"tab_id": 0,
"pane_id": 0,
"workspace": "default",
"size": {
"rows": 24,
"cols": 80,
"pixel_width": 1120,
"pixel_height": 768,
"dpi": 144
},
"title": "zsh",
"cwd": "file://rubens-macbook-air.local/Users/ruben",
"cursor_x": 0,
"cursor_y": 22,
"cursor_shape": "Default",
"cursor_visibility": "Visible",
"left_col": 0,
"top_row": 0,
"tab_title": "",
"window_title": "",
"is_active": true,
"is_zoomed": false,
"tty_name": "/dev/ttys000"
}
]
I noticed the same issue with my workspace sessionizer script on my Linux machine running X11 and i3.
Every new workspace switch would create what would register as a separate window in the background (that i3 couldn't manage).