Open Windows desktop sessions through the registered URL handler (#61711)

## What changed

Launch desktop session URLs with PowerShell's `Start-Process` instead of resolving and starting the packaged executable directly. Restrict the installed `OpenAI.Codex` package check to the two supported publisher IDs and select the first match.

GitOrigin-RevId: 350029a2101ff048de52fa9f9444e4b5dbdcc12e
This commit is contained in:
Eric Traut
2026-11-16 00:04:24 +00:00
committed by copyberry
parent 96e0673f6e
commit 58d5d3a040
+4 -29
View File
@@ -496,40 +496,15 @@ fn windows_desktop_app_launch_script(url: &str) -> String {
$ErrorActionPreference = 'Stop'
$url = {url}
$package = Get-AppxPackage -Name OpenAI.Codex -ErrorAction SilentlyContinue
$package = Get-AppxPackage -Name OpenAI.Codex -ErrorAction SilentlyContinue |
Where-Object {{ $_.PublisherId -in @('2p2nqsd0c76g0', '3k8sg7r9htsxt') }} |
Select-Object -First 1
if ($null -eq $package) {{
Write-Error 'Desktop app package is not installed'
exit 1
}}
$manifest = Get-AppxPackageManifest -Package $package.PackageFullName
$application = $manifest.Package.Applications.Application |
Where-Object {{
@($_.Extensions.Extension) | Where-Object {{
$_.Category -eq 'windows.protocol' -and $_.Protocol.Name -eq 'codex'
}}
}} |
Select-Object -First 1
if ($null -eq $application -or [string]::IsNullOrWhiteSpace($application.Executable)) {{
Write-Error 'Desktop app package does not declare a codex protocol executable'
exit 1
}}
# Launch the package-declared protocol executable rather than an internal Electron shim.
# Windows can deny direct starts of internal executables under WindowsApps.
$exe = Join-Path $package.InstallLocation $application.Executable
$appDir = Split-Path -Parent $exe
$app = Join-Path $appDir 'resources\app.asar'
if (-not (Test-Path $exe)) {{
Write-Error "Desktop app executable not found at $exe"
exit 1
}}
if (-not (Test-Path $app)) {{
Write-Error "Desktop app bundle not found at $app"
exit 1
}}
Start-Process -FilePath $exe -WorkingDirectory $appDir -ArgumentList @('resources\app.asar', $url)
Start-Process -FilePath $url
"#
)
}