Windows: refresh PATH without reboot after Hyper CLI install (#2823)#8174
Draft
MukundaKatta wants to merge 1 commit intovercel:canaryfrom
Draft
Windows: refresh PATH without reboot after Hyper CLI install (#2823)#8174MukundaKatta wants to merge 1 commit intovercel:canaryfrom
MukundaKatta wants to merge 1 commit intovercel:canaryfrom
Conversation
The CLI installer writes to HKCU\Environment\PATH via native-reg, which does not broadcast WM_SETTINGCHANGE. As a result, already-running shells and Explorer keep the stale environment block until the user reboots or logs out, so `hyper` is missing from PATH in fresh terminals (vercel#2823). Fix: * After writing the registry value, broadcast WM_SETTINGCHANGE via a short PowerShell P/Invoke into user32!SendMessageTimeoutW. The script is shipped through `-EncodedCommand` (UTF-16LE base64) so quoting is not a concern. * Also update process.env.Path/PATH so the currently running Hyper process and any shells it spawns see the bin dir immediately (Stanzilla's suggestion in the issue thread). * Adjust the installation notification: when the broadcast lands the reboot wording is no longer accurate; keep the old wording as the fallback if PowerShell is missing or the broadcast fails. Also adds a small unit test that pins the script payload (HWND_BROADCAST, WM_SETTINGCHANGE, the literal "Environment" lParam) and the UTF-16LE base64 round-trip used by `-EncodedCommand`.
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.
Summary
Fixes #2823. On Windows, Hyper writes the user PATH to
HKCU\Environmentvianative-reg. Raw registry writes do not broadcastWM_SETTINGCHANGE, so already-running shells (Explorer, cmd, WSL, VSCode terminals) keep their stale environment block until logout or reboot.What it does
Registry.setValueRaw, spawnpowershell.exe -EncodedCommand <utf16le-base64>that P/Invokesuser32!SendMessageTimeoutW(HWND_BROADCAST, WM_SETTINGCHANGE, 0, "Environment", SMTO_ABORTIFHUNG, 5000, ...). Encoded-command form sidesteps quoting hazards.process.env.Path/PATHin the running Hyper process so in-app shells spawned vianode-ptyimmediately see the CLI (Stanzilla's suggestion from the issue thread).Files
app/utils/cli-install.ts— orchestration + runtime PATH update + notification copyapp/utils/broadcast-env-change.ts(new) — script payload, args, UTF-16LE base64 encodertest/unit/broadcast-env-change.test.ts(new) — pins HWND_BROADCAST/WM_SETTINGCHANGE/Environmentmarkers + encode round-tripTest plan
yarn run test:unitpasses 10/10 (3 new + 7 existing).