From 58d5d3a0404bdd4e5d6af0f90a729068eb30396a Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Sun, 15 Nov 2026 23:43:56 +0000 Subject: [PATCH] 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 --- codex-rs/tui/src/app/history_ui.rs | 33 ++++-------------------------- 1 file changed, 4 insertions(+), 29 deletions(-) diff --git a/codex-rs/tui/src/app/history_ui.rs b/codex-rs/tui/src/app/history_ui.rs index 4b4a1c0215..653c2e5620 100644 --- a/codex-rs/tui/src/app/history_ui.rs +++ b/codex-rs/tui/src/app/history_ui.rs @@ -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 "# ) }