hex/scripts/setup-windows.ps1
Luke Parker 8efd9909bd
feat: Windows beta with streaming dictation, Hold/Toggle shortcut mode, and x64 + ARM64 release (#141)
* feat: Windows beta with streaming dictation, Hold/Toggle shortcut mode, and release pipeline

Ports the windows-shell branch onto main, adds a GPU streaming finish for Parakeet Unified English with a whole-clip fallback, a cross-platform Hold/Toggle shortcut mode, x64 and ARM64 Windows CI and release feeds, and the website Windows download.

* copy: Enabled/Disabled status on Linux and in the shared Activity labels

* ci: install SPIRV-Headers for the x64 Vulkan build and gate the Windows-only device query

* refactor: one implementation per concept across macOS, Linux, and Windows

The Windows port carried its own copies of modules main already has. Each
concept now has one implementation:

- UI: Windows uses main's design system (design_tokens, desktop_ui,
  text_input, desktop_transcription_picker types) instead of a Fluent copy.
  Windows-only bits are small cfg additions: Segoe Fluent Icons for Icon,
  Windows text-editing key bindings, fixed-height and read-only text inputs,
  and the shared slider_track component. windows_ui keeps the window chrome
  and the anchored dropdowns, now drawn with menu/menu_item.
- Windows chrome: the sidebar runs the full window height as on macOS. The
  caption row is split: the brand sits over the sidebar, the window buttons
  over the content, and both halves stay OS drag regions.
- Commands: Windows uses main's commands, command_grammar, context, keys,
  and personal_commands. The SDK provisioner accepts the embedded TypeScript
  src layout; Windows execute() opens URLs and paths with ShellExecuteW.
- OpenCode: dictation_processor is the one client and ordered policy
  (corrections, rewrite, transformations) on macOS and Windows. Windows keeps
  its opencode2 api CLI transport in a cfg'd submodule; the ranked catalog,
  prompts, Voice Action generation, and the transformation stage are shared.
- desktop_activity is shared; the Windows Settings contract is
  windows_desktop_host, without #[path] aliases.
- self_update is the signed-feed core for both the Linux and Windows
  updaters.
- Windows copy follows the design system: sentence case and "Hex".

* chore(windows): flat app icon that stays crisp at taskbar sizes

* chore: mark the Windows-only screens to consolidate with app_window after #138

* fix(linux): wait for partial X11 grabs to be released before reporting a conflict
2026-10-19 11:00:46 +10:00

153 lines
5.3 KiB
PowerShell

[CmdletBinding()]
param(
[switch]$SkipCheck
)
$ErrorActionPreference = "Stop"
Set-StrictMode -Version Latest
function Test-Tool {
param([Parameter(Mandatory)][string]$Name)
return $null -ne (Get-Command $Name -ErrorAction SilentlyContinue)
}
function Invoke-WingetInstall {
param(
[Parameter(Mandatory)][string]$Id,
[string[]]$ExtraArguments = @()
)
& winget install --id $Id -e --silent --accept-package-agreements `
--accept-source-agreements @ExtraArguments
if ($LASTEXITCODE -ne 0) {
throw "winget could not install $Id (exit code $LASTEXITCODE)"
}
}
function Invoke-Rustup {
param([Parameter(Mandatory)][string[]]$Arguments)
for ($attempt = 0; $attempt -lt 40; $attempt++) {
if (Test-Path -LiteralPath $script:RustupPath) {
& $script:RustupPath @Arguments
if ($LASTEXITCODE -ne 0) {
throw "rustup $($Arguments -join ' ') failed (exit code $LASTEXITCODE)"
}
return
}
Start-Sleep -Milliseconds 250
}
throw "rustup did not finish replacing $script:RustupPath"
}
function Find-FxcCompiler {
$configured = [Environment]::GetEnvironmentVariable("GPUI_FXC_PATH", "User")
if (-not [string]::IsNullOrWhiteSpace($configured) -and
(Test-Path -LiteralPath $configured -PathType Leaf)) {
return $configured
}
$onPath = Get-Command "fxc.exe" -ErrorAction SilentlyContinue
if ($null -ne $onPath) {
return $onPath.Source
}
$kitBin = Join-Path ${env:ProgramFiles(x86)} "Windows Kits\10\bin"
if (-not (Test-Path -LiteralPath $kitBin -PathType Container)) {
return $null
}
return Get-ChildItem -LiteralPath $kitBin -Directory |
Sort-Object Name -Descending |
ForEach-Object { Join-Path $_.FullName "x64\fxc.exe" } |
Where-Object { Test-Path -LiteralPath $_ -PathType Leaf } |
Select-Object -First 1
}
if (-not (Test-Tool "winget")) {
throw "winget is required. Install or update App Installer from Microsoft Store."
}
$cargoBin = Join-Path $env:USERPROFILE ".cargo\bin"
$wingetLinks = Join-Path $env:LOCALAPPDATA "Microsoft\WinGet\Links"
$env:Path = "$cargoBin;$wingetLinks;$env:Path"
if (-not (Test-Tool "rustup")) {
Write-Host "Installing rustup..."
Invoke-WingetInstall -Id "Rustlang.Rustup"
}
$script:RustupPath = (Get-Command "rustup" -ErrorAction Stop).Source
if (-not (Test-Tool "cmake")) {
Write-Host "Installing CMake for the current user..."
Invoke-WingetInstall -Id "Kitware.CMake" -ExtraArguments @("--scope", "user")
}
$arm64 = $env:PROCESSOR_ARCHITECTURE -eq "ARM64"
if (-not $arm64) {
# The x64 build decodes on the GPU through ggml's Vulkan backend.
$vulkanSdk = [Environment]::GetEnvironmentVariable("VULKAN_SDK", "Machine")
if ([string]::IsNullOrWhiteSpace($vulkanSdk)) {
Write-Host "Installing the Vulkan SDK..."
Invoke-WingetInstall -Id "KhronosGroup.VulkanSDK"
$vulkanSdk = [Environment]::GetEnvironmentVariable("VULKAN_SDK", "Machine")
}
if ([string]::IsNullOrWhiteSpace($vulkanSdk)) {
throw "The Vulkan SDK installed but VULKAN_SDK is not set; open a new terminal and rerun."
}
$env:VULKAN_SDK = $vulkanSdk
Write-Host "Using Vulkan SDK: $vulkanSdk"
}
$vswhere = Join-Path ${env:ProgramFiles(x86)} "Microsoft Visual Studio\Installer\vswhere.exe"
$hasCppTools = $false
if (Test-Path -LiteralPath $vswhere) {
$cppInstallation = & $vswhere -latest -products * `
-requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 `
-property installationPath
$hasCppTools = -not [string]::IsNullOrWhiteSpace(($cppInstallation -join ""))
}
if (-not $hasCppTools) {
Write-Host "Installing Visual Studio Build Tools with the C++ workload..."
Invoke-WingetInstall -Id "Microsoft.VisualStudio.2022.BuildTools" -ExtraArguments @(
"--override",
"--wait --passive --norestart --add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Component.VC.Llvm.Clang --includeRecommended"
)
}
if ($arm64) {
# ggml's ARM CPU backend refuses MSVC; build the native core with clang-cl.
$env:CC = "clang-cl"
$env:CXX = "clang-cl"
$env:CMAKE_GENERATOR = "Ninja"
$env:TRANSCRIBE_CMAKE_ARGS = "-DGGML_NATIVE=OFF -DGGML_OPENMP=OFF"
Write-Host "ARM64: building with clang-cl and Ninja from a Developer PowerShell for VS."
}
$fxcPath = Find-FxcCompiler
if ([string]::IsNullOrWhiteSpace($fxcPath)) {
throw "fxc.exe is required by GPUI. Install the Windows 10/11 SDK through Visual Studio Installer."
}
$env:GPUI_FXC_PATH = $fxcPath
[Environment]::SetEnvironmentVariable("GPUI_FXC_PATH", $fxcPath, "User")
Write-Host "Using GPUI shader compiler: $fxcPath"
Invoke-Rustup -Arguments @("toolchain", "install", "stable", "--profile", "minimal")
Invoke-Rustup -Arguments @("default", "stable")
Invoke-Rustup -Arguments @("target", "add", "x86_64-pc-windows-msvc")
Invoke-Rustup -Arguments @("component", "add", "rustfmt", "clippy", "rust-analyzer")
$repository = Split-Path -Parent $PSScriptRoot
Push-Location $repository
try {
cargo fetch --target x86_64-pc-windows-msvc
if (-not $SkipCheck) {
cargo check --all-targets
}
}
finally {
Pop-Location
}
Write-Host "Windows Rust environment is ready."
Write-Host "Next: cargo run -- devices"