Skip to content

fix(hub): support macOS Codex Desktop restart#912

Open
nj-zhangrui-arvin wants to merge 1 commit into
tiann:mainfrom
nj-zhangrui-arvin:fix-macos-codex-desktop-restart
Open

fix(hub): support macOS Codex Desktop restart#912
nj-zhangrui-arvin wants to merge 1 commit into
tiann:mainfrom
nj-zhangrui-arvin:fix-macos-codex-desktop-restart

Conversation

@nj-zhangrui-arvin

Copy link
Copy Markdown

Summary

  • detect Codex Desktop availability on macOS via Codex.app paths or the codex launcher
  • report macOS running state with pgrep -x Codex
  • restart Codex Desktop natively on macOS with osascript + open when no custom restart script is configured
  • keep existing configured restart scripts and Windows PowerShell behavior unchanged

Why

The restart endpoint currently defaults to Restart-CodexDesktop.ps1 and PowerShell. On macOS default installs, Codex Desktop can be installed and runnable while the restart route still fails because there is no .ps1 script or pwsh available.

This PR adds a macOS fallback only when HAPI_CODEX_RESTART_SCRIPT is not configured. Operators who already provide a custom script keep that path.

Related note: I found #886 already covers imported Codex sessions missing machine binding, so this PR intentionally stays scoped to the separate macOS restart failure.

Tests

  • bun test hub/src/web/routes/codexDesktop.test.ts
  • tsc -p hub/tsconfig.json --noEmit

AI assistance disclosure

Prepared with assistance from OpenAI Codex.

The Codex Desktop restart route already supports a Windows PowerShell script, but macOS installations can have Codex.app available without any Restart-CodexDesktop.ps1 file or pwsh. In that case the web restart control reports a missing script even though the desktop app is installed.

This adds a native macOS path that detects Codex.app, reports running state via pgrep, and restarts the app with osascript plus open when no custom restart script is configured. Existing configured scripts and Windows behavior stay unchanged.

Constraint: macOS users may not have PowerShell installed for the Codex Desktop restart control.

Rejected: Require HAPI_CODEX_RESTART_SCRIPT on macOS | preserves the current failure mode for default installs.

Confidence: medium

Scope-risk: narrow

Directive: Keep configured restart scripts higher priority than native macOS fallback so operators can override local app behavior.

Tested: bun test hub/src/web/routes/codexDesktop.test.ts

Tested: tsc -p hub/tsconfig.json --noEmit

Not-tested: Manual click of restart button, to avoid restarting the active Codex desktop session during development.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Findings

  • None.

Summary

  • Review mode: initial. No issues found in the modified lines. Residual risk: macOS restart behavior is only covered at helper-argument level here; native open/osascript behavior is not exercised in this environment.

Testing

  • Not run (automation): bun is not available in this environment. tsc -p hub/tsconfig.json --noEmit also could not complete because dependencies/types are not installed locally.

HAPI Bot

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.

2 participants