fix(desktop): detach relaunched Desktop from the hand-off console + UTF-8 child streams - #82386
Merged
Merged
Conversation
…TF-8 child streams First real-world run of the #82328/#82366 hand-off (2026-08-09, ryanc) surfaced two defects: 1. The console window never closes after the update finishes -- and closing it manually KILLS the freshly relaunched GUI. Root cause: Start-DesktopRelaunch spawned Hermes.exe as a child of the console PowerShell. Electron/Chromium calls AttachConsole(ATTACH_PARENT_ PROCESS) at boot, so the new Desktop latched onto the hand-off's console: the console can't close while an attached process lives, and closing it takes the attached GUI down with it. Fix: create the process via WMI (Win32_Process.Create) -- parent becomes WmiPrvSE, no console to inherit or attach, same detachment explorer.exe gives a normal launch. Start-Process fallback retained (tethered Desktop beats no Desktop). 2. Both the console and the progress box render hermes update's UTF-8 glyphs (checkmarks, arrows) as mojibake. PS 5.1 defaults redirected child streams to the OEM codepage. Fix: StandardOutput/ErrorEncoding = UTF8 on the child, PYTHONIOENCODING/PYTHONUTF8 so Python emits UTF-8, and [Console]::OutputEncoding = UTF8 for our own echo. Verified live on the incident machine: WMI-created process parents to WmiPrvSE.exe (not the shell); UTF-8 glyph round-trip through the exact ProcessStartInfo shape reads back byte-correct (15/15 chars). PS 5.1 parse clean, check-windows-footguns clean.
Contributor
૮ >ﻌ< ა ci reviewran on f768958
|
Merged
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes the two defects from the first real-world run of the #82328/#82366 hand-off:
Console window never closes — and closing it kills the GUI.
Start-DesktopRelaunchspawned Hermes.exe as a child of the console PowerShell; Electron callsAttachConsole(ATTACH_PARENT_PROCESS)at boot, so the relaunched Desktop latched onto the hand-off console. The console can't close while an attached process lives, and closing it manually takes the GUI down. Fix: relaunch via WMIWin32_Process.Create— parent becomes WmiPrvSE, no console inheritance, same detachment as an explorer.exe launch.Start-Processfallback retained.Mojibake in both the console and the progress box. PS 5.1 defaults redirected child streams to the OEM codepage. Fix:
StandardOutput/ErrorEncoding = UTF8,PYTHONIOENCODING/PYTHONUTF8on the child,[Console]::OutputEncoding = UTF8for our own echo.E2E (incident machine)
WmiPrvSE.exe, not the shell — verified livecheck-windows-footguns.pycleanType of Change
Script-only change (
scripts/desktop-update.ps1) — reaches every user on their nexthermes updatewith no Desktop rebuild needed.