flyingpie / windows-terminal-quake

Turn any app into a Quake-style toggleable app.
https://wtq.flyingpie.nl
MIT License
547 stars 35 forks source link

Main window handle not available yet. #126

Closed furaone closed 1 month ago

furaone commented 2 months ago

Hi - today I installed wtq and I was not able to run it. When I run wtq then it loops and starts new terminal window every 5 seconds. Here are logs: 20240419.txt

this behavior happens for v2.0.0-prerelease7 and v2.0.0-prerelease6

Windows Terminal Version: 1.19.10821.0

flyingpie commented 2 months ago

@furaone Thank you for reporting this issue!

Could you show me your settings file?

bllngr commented 2 months ago

I'm having the same issue using the default settings file shipped with the winget version 2.0.8.

wtq.jsonc 20240502.txt

Windows 10.0.19045 Windows Terminal installed via Microsoft Store (?) in C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_1.19.10821.0_x64__8wekyb3d8bbwe

flyingpie commented 2 months ago

@bllngr Thank you for chiming in, I'll test this asap!

flyingpie commented 2 months ago

@bllngr Two questions:

bllngr commented 2 months ago

@bllngr Two questions:

  • You are aware that the default wtq.jsonc doesn't actually run Windows Terminal, it runs PowerShell in the standard command prompt? This is due to the WinGet version otherwise requiring a dependency on WT, which I'd like to avoid.

I actually wasn't. Probably because the powershell.exe is opened in Windows Terminal by default on my machine.

The is how Windows Terminal is configured, which is opened when running powershell from the Run dialog:

image

When I set the default terminal application to "Windows Console Host", wtq works as expected. So the problem seems to be Powershell starting (itself?) in Windows Terminal, which then wtq doesn't pick up?

  • How are you starting wtq?

Doesn't matter, it behaves the same whether it's started via shortcut from shell:startup, doubleclick from explorer, wtq from run menu, or wtq from the start menu.

flyingpie commented 2 months ago

@bllngr Thank you for answering!

I think I know what the problem is now, thanks to your explanation. This is an excellent case I didn't really consider before.

I'll notify you when an update is available that solves this.

You could try to change wtq.jsonc to directly start Windows Terminal in the mean time, see if that fixes the issue as well?

bllngr commented 2 months ago

You could try to change wtq.jsonc to directly start Windows Terminal in the mean time, see if that fixes the issue as well?

When uncommenting the wt example from the default config file, a new instance isn't opened every five seconds anymore. But it still opens the Windows Terminal window regularly, writes a few error logs in the log file, and only then grabs the Terminal window and resizes/moves/hides it (after about five seconds).

20240506.txt

flyingpie commented 2 months ago

@bllngr

Did you arrive at a configuration that works for you, with the current version? If so, could you share it, so we're definitely talking about the same setup?

The problem ultimately boils down to a couple things: The version of WTQ for WinGet doesn't assume Windows Terminal to be installed, since that would require a dependency in the manifest, which I'd like to avoid. Especially for people that don't actually use it with WT.

Though, this means that the default configuration needs to do something different than attach to WT, since it may or may not be there.

In the current version, I've included a wtq.jsonc file that attaches to a PowerShell 5 prompt, since that is always available on Windows machines.

But in the case where Windows Terminal is installed, and it is configured as the default console host, it takes over the PowerShell window that's started by WTQ, making it unavailable for WTQ to attach to (it basically removes its window entirely).

The out-of-box experience needs to be a lot better, there's many more failure modes since we can attach to apps other than Windows Terminal. I'm thinking maybe a minimal UI that suggests some configuration options and points the user in the right direction. In that case, we wouldn't include or generate any default wtq.jsonc, but guide the user to making one. Which would hopefully also avoid all the current edge cases.

Do you have any thoughts or suggestions on this?

furaone commented 2 months ago

I downloaded repository and debugged my issue - in my case this behavior was caused by ohmyposh that I'm using for powershell... you are basing on a window title which in my case was changing because of startup script. Finally I configured Windows Terminal to work close to perfection (I was not able to manage toggle animation for fullscreen terminal).

From my side - I stopped using wqt when I went through code and saw some solutions that you have. Hoping that my feedback with issue helped.

flyingpie commented 1 month ago

@furaone Thank you for your feedback, It's definitely helpful.

flyingpie commented 1 month ago

The latest versions of WTQ fix a lot of "Main window handle not available yet" errors. Closing this issue for now.