Support ChatGPT-branded Desktop app builds (#33901)

## Why

The Desktop app can use Codex or ChatGPT branding while retaining stable platform identities. CLI discovery and TUI handoff should not depend on a single display name or hardcoded executable path.

## What changed

- On macOS, search for both `ChatGPT.app` and `Codex.app`, and accept only bundles with the `com.openai.codex` identifier.
- On Windows, detect installs by their package app ID and resolve the `codex` protocol executable from the AppX manifest before handing off a TUI session.
- Use “Desktop app” consistently in CLI and TUI user-facing text.

## Testing

Add coverage for selecting a ChatGPT-named Codex bundle and rejecting the classic ChatGPT bundle.

GitOrigin-RevId: b84a56eb6e960712152e1a9b023ab530ec9a354a
This commit is contained in:
Eric Traut authored and copyberry committed 2026-07-17 20:46:18 +00:00
1 parent bc5c9161b4
commit 50b8213385
12 files changed
+119 -41

No files matched your search

+27 -12
View File
@@ -5,7 +5,7 @@
use super::*;
const DESKTOP_THREAD_OPENED_MESSAGE: &str = "Opened this session in Codex Desktop.";
const DESKTOP_THREAD_OPENED_MESSAGE: &str = "Opened this session in the Desktop app.";
impl App {
pub(super) fn insert_history_cell(&mut self, tui: &mut tui::Tui, cell: Box<dyn HistoryCell>) {
@@ -179,7 +179,7 @@ impl App {
fn desktop_thread_open_error_message(err: &str) -> String {
format!(
"Failed to open this session in Codex Desktop: {err}. Install or launch Codex Desktop and try again."
"Failed to open this session in the Desktop app: {err}. Install or launch the Desktop app and try again."
)
}
@@ -205,7 +205,7 @@ fn open_desktop_thread_url(url: &str) -> Result<(), String> {
.arg("-Command")
.arg(&script)
.output()
.map_err(|err| format!("failed to launch Codex Desktop through PowerShell: {err}"))?;
.map_err(|err| format!("failed to launch the Desktop app through PowerShell: {err}"))?;
if output.status.success() {
return Ok(());
@@ -214,7 +214,7 @@ fn open_desktop_thread_url(url: &str) -> Result<(), String> {
let stderr = String::from_utf8_lossy(&output.stderr).trim().to_string();
if stderr.is_empty() {
Err(format!(
"failed to launch Codex Desktop through PowerShell with {}",
"failed to launch the Desktop app through PowerShell with {}",
output.status
))
} else {
@@ -230,21 +230,36 @@ fn windows_desktop_app_launch_script(url: &str) -> String {
$ErrorActionPreference = 'Stop'
$url = {url}
$installLocation = (Get-AppxPackage -Name OpenAI.Codex -ErrorAction SilentlyContinue).InstallLocation
if ([string]::IsNullOrWhiteSpace($installLocation)) {{
Write-Error 'Codex Desktop package is not installed'
$package = Get-AppxPackage -Name OpenAI.Codex -ErrorAction SilentlyContinue
if ($null -eq $package) {{
Write-Error 'Desktop app package is not installed'
exit 1
}}
$appDir = Join-Path $installLocation 'app'
$exe = Join-Path $appDir 'Codex.exe'
$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 "Codex Desktop executable not found at $exe"
Write-Error "Desktop app executable not found at $exe"
exit 1
}}
if (-not (Test-Path $app)) {{
Write-Error "Codex Desktop app bundle not found at $app"
Write-Error "Desktop app bundle not found at $app"
exit 1
}}
@@ -260,7 +275,7 @@ fn powershell_single_quoted_string(value: &str) -> String {
#[cfg(not(any(target_os = "macos", target_os = "windows")))]
fn open_desktop_thread_url(_url: &str) -> Result<(), String> {
Err("Codex Desktop is only available on macOS and Windows".to_string())
Err("The Desktop app is only available on macOS and Windows".to_string())
}
#[cfg(test)]
@@ -2,4 +2,4 @@
source: tui/src/app/history_ui_tests.rs
expression: render_cell(&cell)
---
■ Failed to open this session in Codex Desktop: launch failed. Install or launch Codex Desktop and try again.
■ Failed to open this session in the Desktop app: launch failed. Install or launch the Desktop app and try again.
@@ -2,4 +2,4 @@
source: tui/src/app/history_ui_tests.rs
expression: render_cell(&cell)
---
• Opened this session in Codex Desktop.
• Opened this session in the Desktop app.