Repository navigation
fix(desktop): run Windows servers without console windows - #110
crazy-daddy wants to merge 4 commits into
Conversation
The launcher spawns the servers with CREATE_NO_WINDOW | DETACHED_PROCESS. Windows ignores CREATE_NO_WINDOW alongside DETACHED_PROCESS, and the servers' own console children (uvicorn.exe -> python.exe, npm.cmd -> node.exe) then each open a new, visible console window. --silent spawns them with CREATE_NO_WINDOW | CREATE_NEW_PROCESS_GROUP instead: a hidden console the children inherit, still outliving the launcher. install_karma_app.py --silent bakes the flag into the Desktop shortcut and, with --autostart, the Startup entry. Off by default; no-op note on macOS, which has no per-process console windows.
JayantDevkar
left a comment
There was a problem hiding this comment.
Inline context for reviewers, one note per change area.
|
Good find on the You offered to flip the default or drop the flag, and I'd take the second option. The existing comment says "never flash a window", so windowless was always the intent, and I can't think of a reason someone would opt back into the console windows. Making the new creation flags unconditional turns this into a small change in While you're in there, README line 291 still says no console window flashes on Windows; after this change it'll be true again, so it can stay. I'll approve the CI run so the Windows job picks up your tests. |
Per review: make the hidden-console creation flags the only behavior instead of an opt-in flag. spawn_detached now always uses CREATE_NO_WINDOW | CREATE_NEW_PROCESS_GROUP, so the dashboard's Settings -> Desktop App install gets it too. Reverts the --silent plumbing through the installer, the shortcut arguments and the launcher.
…t-launch # Conflicts: # scripts/karma_desktop/core.py # scripts/tests/test_karma_desktop.py
notify() ran powershell -WindowStyle Hidden without CREATE_NO_WINDOW. Under pythonw the launcher has no console, so powershell got a new, visible one (a Windows Terminal window on Windows 11) before the hidden window style applied, flashing on every cold start.
|
Thanks! Dropped --silent as suggested, so the hidden-console flags are now the only behavior (bbadef8). I also merged in main after #112, which conflicted with spawn_detached (3743a0e). Title and description are updated. |
Summary
On Windows, clicking the Karma desktop icon leaves two console windows open (one for the API, one for the frontend). This PR starts the servers without them, on every install path.
Root cause:
spawn_detachedusesCREATE_NO_WINDOW | DETACHED_PROCESS. Per the CreateProcess flags docs,CREATE_NO_WINDOWis ignored when combined withDETACHED_PROCESS. The detached server has no console, so its own console children (uvicorn.exe→python.exe,npm.cmd→cmd.exe→node.exe) each allocate a new, visible console window.Fix: spawn with
CREATE_NO_WINDOW | CREATE_NEW_PROCESS_GROUPinstead. The server gets a hidden console that its children inherit, and it still outlives the launcher. This matches the existing intent ("never flash a window"), so it is the only behavior: no flag, no opt-in.Changes
core.spawn_detached: Windows creation flags are nowCREATE_NO_WINDOW | CREATE_NEW_PROCESS_GROUP(one line, plus a comment on whyDETACHED_PROCESScan't be used).test_spawn_detached_hides_consoleasserts both flags are set andDETACHED_PROCESSis not;test_notify_opens_no_console_windowasserts the balloon passesCREATE_NO_WINDOW.launcher.notify: the cold-start "Starting servers" balloon ranpowershell -WindowStyle HiddenwithoutCREATE_NO_WINDOW. Underpythonwthe launcher has no console, so PowerShell got a new, visible one (a Windows Terminal window on Windows 11) before the hidden style applied. Found while retesting the cold start; it has been there since feat(desktop): one-click launcher + autostart for macOS and Windows #94. Now passesCREATE_NO_WINDOW, with a test.spawn_detached, so every install path gets the fix.main(after Make local Karma fast: normal-priority autostart, git cache, subagent parse cache, production frontend #112) merged in; the conflict inspawn_detachedis resolved onto the new_popenhelper.run_loggedandstop_process_tree(taskkill /T) are unaffected.Component
scripts/karma_desktop,scripts/install_karma_app.py)Type
Testing
scripts/tests(83 passed, 17 skipped as other-OS) andapi/tests/test_desktop_app_guard.py(12 passed, 2 skipped) pass on Windowsruff checkandruff format --checkclean onscripts/and the endpoint, as in the desktop-launcher workflow--no-open --quietand no extra flag. Running it the way Windows does at login, with both servers stopped, brought both back with no console windows and no browser windowRelated Issues
None filed. Companion PR: #109 (open the dashboard in the Windows default browser). Both touch
launcher.pyand its tests in different places; they merge together without conflicts in either order.