Skip to content

fix(desktop): detach relaunched Desktop from the hand-off console + UTF-8 child streams - #82386

Merged
teknium1 merged 1 commit into
mainfrom
fix/handoff-relaunch-detached-console
Aug 9, 2026
Merged

teknium1 merged 1 commit into
mainfrom
fix/handoff-relaunch-detached-console

Conversation

@teknium1

@teknium1 teknium1 commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator

What does this PR do?

Fixes the two defects from the first real-world run of the #82328/#82366 hand-off:

  1. Console window never closes — and closing it kills the GUI. Start-DesktopRelaunch spawned Hermes.exe as a child of the console PowerShell; Electron calls AttachConsole(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 WMI Win32_Process.Create — parent becomes WmiPrvSE, no console inheritance, same detachment as an explorer.exe launch. Start-Process fallback retained.

  2. 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/PYTHONUTF8 on the child, [Console]::OutputEncoding = UTF8 for our own echo.

E2E (incident machine)

  • WMI-created process parents to WmiPrvSE.exe, not the shell — verified live
  • UTF-8 glyph round-trip through the exact ProcessStartInfo shape: 15/15 chars byte-correct
  • PS 5.1 parse clean (1909 tokens), check-windows-footguns.py clean

Type of Change

  • 🐛 Bug fix

Script-only change (scripts/desktop-update.ps1) — reaches every user on their next hermes update with no Desktop rebuild needed.

…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.
@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

૮ >ﻌ< ა ci review

ran on f768958

⚠️ Warnings

OSV vulnerability scan · View job

22 known vulnerabilities found in pinned dependencies.

How to fix:

Review the findings in the Security tab. Update the affected dependencies if a patched version is available.


debug info

CI timings

CI timings · View report · View job

Wall time 3m34s vs 6m55s (-48.4%). 9 job(s) slower, 12 faster, 2 unchanged.

  • Python tests / Run tests slice 6/12: +41.0s
  • Python tests / Run tests slice 2/12: -8.0s
  • Python tests / Run tests slice 1/12: +8.0s
  • Python tests / Run tests slice 12/12: +7.0s
  • Check uv.lock / uv lock --check: +7.0s

@teknium1
teknium1 merged commit 36eda61 into main Aug 9, 2026
41 checks passed
@teknium1
teknium1 deleted the fix/handoff-relaunch-detached-console branch August 9, 2026 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant