wez / wezterm

A GPU-accelerated cross-platform terminal emulator and multiplexer written by @wez and implemented in Rust
https://wezfurlong.org/wezterm/
Other
17.94k stars 805 forks source link

`wezterm ssh` new window only get focused when UI is first opened, but focus does not work on subsequent runs #4820

Open arthurgeek opened 10 months ago

arthurgeek commented 10 months ago

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

20240119-085337-05eadb7c

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

The command wezterm ssh spawns a new window and that window is focused only for the first time when the wezterm-gui is open. all subsequent commands the new window does not get focus.

To Reproduce

Open wezterm gui and run:

wezterm ssh user@IP

see that the ssh connection works, and the newly spawned window receives focus. exit ssh then run again:

wezterm ssh user@IP

and see that this time the new window is open, but does not receive focus. this will happening every time a new wezterm ssh command runs unless you close gui and start it again.

Configuration

here's the relevant parts of my wezterm config:

local wezterm = require("wezterm")

local config = wezterm.config_builder()

config.unix_domains = {
    {
        name = "unix",
    },
}

config.default_gui_startup_args = { "connect", "unix" }

local mux = wezterm.mux

wezterm.on("gui-attached", function()
    for _, window in ipairs(mux.all_windows()) do
        window:gui_window():set_position(77, 127)
        window:gui_window():set_inner_size(2872, 1756)
    end
end)

return config

I have also tried with ssh_backend = "Ssh2", but there was no difference. If I remove the gui-attached callback, the window doesn't get focus not even in the first run. I also tried adding window:gui_window():focus() but had the same behavior.

Expected Behavior

to be able to connect to ssh and have the newly spawned window focused every time the command is run.

Logs

No response

Anything else?

No response

tjex commented 8 months ago

I'm also experiencing this when opening new processes with wezterm start

Risinggoblin commented 2 months ago

Happening with wezterm connect <my-server> as well.

@wez just another perspective on this - I think this could potentially be a security issue for some pea-brains like me who immediately start typing the ssh password after doing a wezterm ssh xx@xx. I've ended up typing my ssh password in the source window multiple times because of this - the password is then visible in plain text in the GUI. I understand that this is literally solving for the lowest common denominator of users but it is a potential issue nonetheless