Skip to content

fix: read windows process paths as utf-8 so non-ascii installs match - #35390

Merged
RohanK6 merged 1 commit into
mainfrom
crew/conductor/windows-process-command-utf8
Nov 12, 2026
Merged

RohanK6 merged 1 commit into
mainfrom
crew/conductor/windows-process-command-utf8

Conversation

@RohanK6

@RohanK6 RohanK6 commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: On Windows, the desktop app recognises its own gateway even when it is installed under a non-ASCII path.

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é\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

  • Changing which processes count as the app's own. Identity stays an exact match against the resolver's paths.
  • The WMIC fallback, which runs only when PowerShell is unavailable.

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 execFileText decodes UTF-8. Change: the PowerShell script in website/electron/windows-port.js now 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 in isKirocrewCommand is 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:
    • "windowsProcessCommand asks PowerShell for UTF-8 output without a BOM": the encoding is set before anything is written (fails on main).
    • "a non-ASCII install path is ours only when it matches exactly": our exact José path is ours; the same path with Jose, under another profile (Zoë), with the replacement character the OEM code page produced, and a kirocrew.exe in another non-ASCII folder are all foreign. Passes on main too: it pins that this change leaves identity as strict as it was.
  • All 64 tests that use windows-port.js pass.
  • 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 through windowsProcessCommand, 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

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license.

@RohanK6
RohanK6 requested review from a team and KiroCrewCaptain as code owners November 11, 2026 16:30
@RohanK6
RohanK6 requested a review from CrysisDeu November 11, 2026 16:30
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 11, 2026
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

UX-level review of a0c1860fb9ebaa380c05ce79e5d531728d0d7f69 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of a0c1860fb9ebaa380c05ce79e5d531728d0d7f69 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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 ships

Inventory (3 items) — 3 justified

Intent: let a Windows desktop app installed under a non-ASCII profile path recognise and recover its own gateway. This is a FIX.

  1. The PowerShell process-identity probe now writes UTF-8 without a BOM, so a non-ASCII ExecutablePath arrives intact and matches the app's own paths — justified
  2. A test pins that identity is still an exact match for non-ASCII paths (a Jose, Zoë or replacement-character path counts as foreign) — justified
  3. A Windows-only CI test runs real PowerShell 5.1 against ASCII and non-ASCII folders and requires the exact path back — justified

[FIRST-PRINCIPLES-REVIEWED] a0c1860

Description read

[DESCRIPTION-READ] cf3e6c9b7b73adac7c5250397fd65fea917f73c3e8badb3515c98f1d9841c22e

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed a0c1860fb9ebaa380c05ce79e5d531728d0d7f69 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] a0c1860

Verdict parsed from the review's SHA-scoped output markers for commit a0c1860fb9ebaa380c05ce79e5d531728d0d7f69.

False positive or not applicable? A repository writer can comment:
/ai-review override fable a0c1860fb9ebaa380c05ce79e5d531728d0d7f69 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of a0c1860fb9ebaa380c05ce79e5d531728d0d7f69 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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

  • If [Console]::OutputEncoding throws because no console is attached, PowerShell treats that as a statement-terminating error and runs the rest of the script, so the worst case is today's behaviour, not a lost probe.

[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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of a0c1860fb9ebaa380c05ce79e5d531728d0d7f69 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] a0c1860

False positive or not applicable? A repository writer can comment:
/ai-review override gpt a0c1860fb9ebaa380c05ce79e5d531728d0d7f69 false-positive: <reason, 20 to 500 characters>

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 11, 2026
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Nov 11, 2026
@RohanK6
RohanK6 force-pushed the crew/conductor/windows-process-command-utf8 branch from 96ff708 to eb7e7b5 Compare November 12, 2026 11:06
@KiroCrewCaptain

KiroCrewCaptain commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: Approve

Why: 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 a0c1860fb9 · 81 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

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.
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 12, 2026
@RohanK6
RohanK6 force-pushed the crew/conductor/windows-process-command-utf8 branch from eb7e7b5 to a0c1860 Compare November 12, 2026 12:05
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 12, 2026
@RohanK6
RohanK6 enabled auto-merge (squash) November 12, 2026 13:34

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@RohanK6
RohanK6 merged commit 9f24944 into main Nov 12, 2026
103 of 108 checks passed
@RohanK6
RohanK6 deleted the crew/conductor/windows-process-command-utf8 branch November 12, 2026 14:06
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 12, 2026
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.

Desktop (Windows): a non-ASCII install path makes the app treat its own gateway as foreign

3 participants