Skip to content

Windows: refresh PATH without reboot after Hyper CLI install (#2823)#8174

Draft
MukundaKatta wants to merge 1 commit intovercel:canaryfrom
MukundaKatta:fix/cli-path-no-reboot-windows
Draft

Windows: refresh PATH without reboot after Hyper CLI install (#2823)#8174
MukundaKatta wants to merge 1 commit intovercel:canaryfrom
MukundaKatta:fix/cli-path-no-reboot-windows

Conversation

@MukundaKatta
Copy link
Copy Markdown

Summary

Fixes #2823. On Windows, Hyper writes the user PATH to HKCU\Environment via native-reg. Raw registry writes do not broadcast WM_SETTINGCHANGE, so already-running shells (Explorer, cmd, WSL, VSCode terminals) keep their stale environment block until logout or reboot.

What it does

  1. After Registry.setValueRaw, spawn powershell.exe -EncodedCommand <utf16le-base64> that P/Invokes user32!SendMessageTimeoutW(HWND_BROADCAST, WM_SETTINGCHANGE, 0, "Environment", SMTO_ABORTIFHUNG, 5000, ...). Encoded-command form sidesteps quoting hazards.
  2. Update process.env.Path/PATH in the running Hyper process so in-app shells spawned via node-pty immediately see the CLI (Stanzilla's suggestion from the issue thread).
  3. Switch the post-install notification to "Open a new terminal window to use it"; reboot wording remains as a fallback if PowerShell is unavailable.

Files

  • app/utils/cli-install.ts — orchestration + runtime PATH update + notification copy
  • app/utils/broadcast-env-change.ts (new) — script payload, args, UTF-16LE base64 encoder
  • test/unit/broadcast-env-change.test.ts (new) — pins HWND_BROADCAST/WM_SETTINGCHANGE/Environment markers + encode round-trip

Test plan

  • yarn run test:unit passes 10/10 (3 new + 7 existing).
  • New files lint clean.
  • End-to-end on a real Windows host not exercised in this branch — would appreciate a maintainer with a Windows VM trying it.

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`.
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.

Add Hyper CLI to user PATH without reboot needing

1 participant