resurrect.wezterm icon indicating copy to clipboard operation
resurrect.wezterm copied to clipboard

flickering pop-up windows on launch and config reload

Open clement-deltel opened this issue 2 months ago • 6 comments

What Operating System(s) are you seeing this problem on?

  • Windows

WezTerm version

20240203.110809.0

Describe the bug

Every time I launch WezTerm or reload the configuration with the keybinding below, I get flickering cmd.exe pop-up windows.

{ key = "R",          mods = "CTRL|SHIFT",   action = act.ReloadConfiguration }

Here is a GiF to showcase the issue:

Image

Configuration

Just adding this line below in my wezterm.lua is sufficient to trigger this behavior.

local resurrect = wezterm.plugin.require("https://github.com/MLFlexer/resurrect.wezterm")

Expected Behavior

There should no such pop-up windows.

Logs

No error logs found.

clement-deltel avatar Oct 03 '25 02:10 clement-deltel

same issue.
wezterm 20250909-070512-bf9a2aee OS: Win 11

azinsharaf avatar Nov 03 '25 02:11 azinsharaf

I am having this same issue. Fresh install, no config except the module importing line in my config, yet it still happens...

SaiShubham624 avatar Nov 04 '25 06:11 SaiShubham624

@azinsharaf @clement-deltel Okay, figured it out a little. But don't know how to solve it yet... The problem is coming from this file: {wezterm-plugin-folder-path}/{this-plugin}/plugin/resurrect/utils.lua

There is a function named ensure_folder_exists in this file which just creates the necessary folders for saving the workspaces and window layouts Main problem is this line: os.execute('mkdir -p "' .. path:gsub("/", "\\" .. '"')) on line 75 and os.execute('mkdir -p "' .. path .. '"') on line 77

The os.execute function starts an external terminal windows to execute the commands, that's why the pop-up windows appears. The reason they are happening multiple times is because this statment is in a for loop

So, really just need a way to figure out, how to run external commands in wezterm configuration silently in background without using a pop-up console window

SaiShubham624 avatar Nov 05 '25 07:11 SaiShubham624

it probably needs to use lfs.mkdir() instead. i need to check it.

azinsharaf avatar Nov 05 '25 14:11 azinsharaf

Please, post the solution if you manage to solve it!

SaiShubham624 avatar Nov 05 '25 16:11 SaiShubham624

replacing the code snippets below fixes the flickering, but i haven't tested it fully to ensure it doesn't break other parts.

change this in utils.lua:

-- Create the folder if it does not exist
---@param path string
function utils.ensure_folder_exists(path)
	if utils.is_windows then
		os.execute('mkdir /p "' .. path:gsub("/", "\\" .. '"'))
	else
		os.execute('mkdir -p "' .. path .. '"')
	end
end

to this:

-- Create the folder if it does not exist
---@param path string
function utils.ensure_folder_exists(path)
  -- Normalize separators
  local sep = utils.is_windows and "\\" or "/"
  path = path:gsub("[/\\]+", sep)

  local parts = {}
  for part in string.gmatch(path, "[^" .. sep .. "]+") do
    table.insert(parts, part)
  end

  local current = ""
  for i, part in ipairs(parts) do
    current = current == "" and part or (current .. sep .. part)

    -- Check if the folder exists by attempting rename
    local ok = os.rename(current, current)
    if not ok then
      -- Pure Lua "mkdir" using io.open
      -- Create a temp file inside the directory to force the folder to exist
      local tmp = current .. sep .. ".mkdir_tmp"
      local f = io.open(tmp, "w")
      if f then
        f:close()
        os.remove(tmp)
      else
        -- directory creation failed
        return false
      end
    end
  end

  return true
end

azinsharaf avatar Nov 07 '25 17:11 azinsharaf