microsoft / terminal

The new Windows Terminal and the original Windows console host, all in the same place!
MIT License
95.11k stars 8.25k forks source link

--window or -w sometimes creates multiple windows with same id #17799

Open minimusubi opened 1 month ago

minimusubi commented 1 month ago

Windows Terminal version

1.19.11213.0

Windows build number

10.0.19045.4651

Other Software

No response

Steps to reproduce

  1. Open a new tab in a new named window (wt.exe --window fancy-window-id new-tab)
  2. Don't close the new window for a month (???) (I'm not sure what's actually required here, but it usually seems to stop working after some time)
  3. Open a new tab in the same named window (wt.exe --window fancy-window-id new-tab)
  4. Observe a new, separate window has opened, instead of a new tab in the existing window

Expected Behavior

A new tab should have opened in the window we opened in step 1.

Actual Behavior

A new window with our new tab opens instead.

Here is a screenshot of two processes in ProcessExplorer. You can see that they have been started nearly a month apart, and that they have the same window ID specified. image Both windows are not elevated (note the absence of shield icons for each window) image

zadjii-msft commented 1 month ago

I'm really glad you mention the "Don't close the new window for a month (???)". I've got a kooky guess. I suspect that this is due to the app platform staging an update to the Terminal. 1.19 is super old at this point - 1.20 has been stable since May.

I fully suspect that because the package is half-updated, the COM object that we use to communicate across processes doesn't match from the new invocation to the old one, and so a new instance is started. Like, the Terminal should only ever have one instance of WindowsTerminal.exe ever. The fact that it's running two separate instances (one for each window) is sus as heck.

I low key bet that the Microsoft.Terminal.Remoting.dll that's used by each of these processes (if you've still got them running) will be different versions.

minimusubi commented 1 month ago

Yep, they're still running. How could I go about checking the dll version used for each process?

minimusubi commented 1 month ago

I think I found them. I used the lower pane to view DLLs for each process in Process Explorer. Let me know if this was incorrect or if there's a better way.

It seems like it's the exact same DLL for both processes. Referencing the same processes from above:

Process 13208 (started 7/27/24)

Process 27872 (started 8/25/24)

The DLL itself was last modified on 5/4/24. image

zadjii-msft commented 1 month ago

Two thoughts:

minimusubi commented 1 month ago

Yeah, you're right- there is a higher version listed, and it was created days after the first process (from the above example) was spawned. image

Both terminal processes are unelevated (see op for screenshot)