Repository navigation
fix: read windows process paths as utf-8 so non-ascii installs match - #35390
Conversation
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing to check. The diff only changes how the Electron process-identity probe decodes PowerShell output, plus tests. It adds or changes no user-visible control, string or state, so the missing blind read leaves no gaps. [UX-REVIEWED] a0c1860 Description read[DESCRIPTION-READ] 42688ef89c7d7dca703da6f5f51ae2eee064beb9718eae3a1c76e746bc81459c That sha256 names everything this verdict read: the PR description, plus the 3 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks: one encoding line at the cause, the only PowerShell text read-back in the Electron shell. The patch's Jira hunks are already on base (#35659), so they are not this PR's. What this change shipsInventory (3 items) — 3 justifiedIntent: let a Windows desktop app installed under a non-ASCII profile path recognise and recover its own gateway. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] a0c1860 Description read[DESCRIPTION-READ] cf3e6c9b7b73adac7c5250397fd65fea917f73c3e8badb3515c98f1d9841c22e That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks. The fix goes after the root cause, the encoding at the PowerShell source, and leaves identity matching exactly as strict as it was. CI's Windows job checks it against real PowerShell 5.1. Notes
[DESIGN-REVIEWED] a0c1860 Description read[DESCRIPTION-READ] 00e134f23057ba9962eae2f65a2d0639d0efd61943a8087d545212a3f7dad2c3 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
96ff708 to
eb7e7b5
Compare
Code change approver recommendation: ApproveWhy: the decider estimates a 6% chance that this change introduces a defect, within the 12% limit for approving on its own, and every check passes. One-line fix at the root cause: the PowerShell identity probe now sets [Console]::OutputEncoding to UTF-8 without a BOM, which matches execFileText's UTF-8 decoding, so a non-ASCII install path arrives intact. Identity stays an exact match in isKirocrewCommand, so nothing that was foreign can now count as the app's own. If setting the encoding throws, the worst case is today's behaviour. There is a unit test that fails on main, a strictness pin, and a Windows-only test that runs real PowerShell 5.1 and passed in CI. Both callers (windowsTaskkill and shutdown.js) are unaffected apart from the intended fix, and no test pins the old script text. An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit |
windowsProcessCommand asks Windows PowerShell 5.1 for a process's executable path and reads its stdout as UTF-8. A redirected console writes in the OEM code page, so an install under a non-ASCII profile (C:\Users\José\...) came back with replacement characters. The exact path match against the launch resolver's own paths then failed, so the app treated its own gateway as foreign: it would not adopt it and refused to stop it on force-retry or wedge recovery. Set [Console]::OutputEncoding to UTF-8 without a BOM before writing. Only how the path is read changes; which paths count as ours does not. Tests pin that a foreign path, one letter off ours or carrying the replacement character, is still refused.
eb7e7b5 to
a0c1860
Compare
bolichen97
left a comment
There was a problem hiding this comment.
Approve at a0c1860. windowsProcessCommand now sets [Console]::OutputEncoding to UTF-8 without a BOM before it writes the process path. Before, a redirected console wrote in the OEM code page, so a non-ASCII install path came back with replacement characters and never matched. The fix changes only how the path is read, not which path is trusted: isKirocrewCommand still needs an exact match against the resolver's own paths, and the new unit test pins that a one-letter-off path, another profile and the replacement-character spelling all stay foreign. The real-PowerShell test covers an ASCII folder and a non-ASCII folder. The product change is one PowerShell line, the only regex is in tests, there is no new refusal, and nothing is live red (the cancelled runs are superseded by newer passes). Approving without auto because the author holds auto-merge.
Problem / Motivation
Goal: On Windows, the desktop app recognises its own gateway even when it is installed under a non-ASCII path.
windowsProcessCommandasks Windows PowerShell 5.1 for a process's executable path and reads its stdout as UTF-8. A redirected console writes in the OEM code page, so an install under a non-ASCII profile (C:\Users\José\AppData\Local\Programs\..., the default per-user location) came back with replacement characters. The exact path match against the launch resolver's own paths then failed, and the app classified its own gateway as foreign.Why it matters
For Windows users whose profile name has a non-ASCII letter, the app cannot adopt the gateway it started, and force-retry and wedge recovery refuse to stop it, so a wedged gateway cannot be recovered without a restart.
Not a goal
What changed (motivation → approach → change)
Symptom: the app's own gateway is reported foreign under a non-ASCII install path. Root cause: PowerShell 5.1's redirected output is OEM-encoded while
execFileTextdecodes UTF-8. Change: the PowerShell script inwebsite/electron/windows-port.jsnow starts with[Console]::OutputEncoding = New-Object System.Text.UTF8Encoding $false;(UTF-8 without a BOM, so nothing is prepended to the path). Only how the path is read changes; the comparison inisKirocrewCommandis untouched.Backwards compatibility
Compatible: an ASCII path reads identically in UTF-8 and the OEM code pages, so every install that matches today still matches.
Removes nothing: no key, path or record is taken away.
Tests
website/electron/test/windows-port.test.js:Josépath is ours; the same path withJose, under another profile (Zoë), with the replacement character the OEM code page produced, and akirocrew.exein another non-ASCII folder are all foreign. Passes on main too: it pins that this change leaves identity as strict as it was.windows-port.jspass.website/electron/test/windows-port-real-junction.test.js(Windows-only, run by CI's "Electron Shell Tests (Windows port identity)" job): "the identity probe reports a process under 'Programs' byte-exact" and "... under 'José Zoë Ünïcode' byte-exact". Each copies the Node interpreter into that folder, spawns it with a hidden console as the desktop app does, asks real Windows PowerShell 5.1 throughwindowsProcessCommand, and requires the reported ExecutablePath to be the launched path exactly, with no replacement character. The ASCII case proves the encoding line changes nothing for an ordinary install.Proof: not provable -- frontend test (prove.py runs Python only)
Manual verification
Covered by the Windows CI job above on real PowerShell 5.1; not run by hand.
Related Issues
Fixes #35388
Sibling sweep
Swept: grep -rni "powershell" website/electron --include=*.js (excluding tests)
Sibling: website/electron/windows-port.js:windowsProcessCommand -- changed here
Sibling: website/electron/runtime/gateway/shutdown.js -- not affected -- it calls windowsProcessCommand, so it gets the fix
Pattern harvest
Not generalizable: this is the shell's only PowerShell call that reads text back.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license.