Skip to content

fix(macos): detect ChatGPT by executable path - #274

Draft
Es1lama wants to merge 1 commit into
Fei-Away:mainfrom
Es1lama:esilama/fix-macos-chatgpt-process-detection
Draft

fix(macos): detect ChatGPT by executable path#274
Es1lama wants to merge 1 commit into
Fei-Away:mainfrom
Es1lama:esilama/fix-macos-chatgpt-process-detection

Conversation

@Es1lama

@Es1lama Es1lama commented Jul 27, 2026

Copy link
Copy Markdown

Summary / 摘要

  • Replace pgrep -x ChatGPT / Codex status detection with one process-table scan that matches the full main executable command path.
  • Reuse the status script's codex result in the menu-bar apply prompt so both UI paths report the same state.
  • Add a regression fixture for a full command path whose process name cannot match the expected app name.

Type / 类型

  • Bug fix / 缺陷修复
  • Feature / 新功能
  • Docs / 文档
  • Theme / CSS / visual / 主题或视觉
  • Scripts / install / restore / 脚本或安装恢复
  • Chore / 杂项

Platform / 平台

  • macOS
  • Windows
  • Both / 双平台
  • Docs / repo only / 仅文档或仓库元数据

Self-check / 自测

Docs-only / 仅文档

  • Links and wording reviewed / 已检查链接与表述

macOS (when code under macos/ changes)

  • macos/tests/run-tests.sh passed / 已通过
  • Doctor (optional): macos/scripts/doctor-macos.sh
  • Live verify (if inject/CSS/start path): verify-dream-skin-macos.sh or Desktop Verify
  • Restore / re-apply smoke (if install/restore/start changed) / 若改了安装恢复启动则做过恢复再应用

Windows (when code under windows/ changes)

  • Relevant install / start / verify / restore scripts exercised / 已按改动跑过对应脚本
  • Environment noted below (OS build, Codex source) / 下方注明环境

User-facing / 用户可见变更

  • Updated macos/CHANGELOG.md (and macos/VERSION if release-worthy) / 已更新 changelog(发版时再 bump VERSION)
  • N/A — no user-facing change / 无用户可见变更

Security / 安全

  • Does not modify official Codex install / asar / signatures / 未修改官方安装与签名
  • Does not silently write API Base URL or keys / 未静默写入 API Base URL 或 Key
  • CDP remains loopback-oriented (127.0.0.1) where applicable / CDP 仍仅本机回环(如适用)

Notes / 补充

Root cause and impact

On the reproduced macOS 26 session, the main process was:

/Applications/ChatGPT.app/Contents/MacOS/ChatGPT --remote-debugging-address=127.0.0.1 --remote-debugging-port=9341

but ps exposed its comm value as /Applications/Ch. Therefore pgrep -x ChatGPT returned no PID even while ChatGPT was running. The menu showed ChatGPT as closed and the apply action offered the cold-start prompt.

The status path remains deliberately cheap: it scans ps once, matches only the saved or standard main executable path, and does not invoke Node, CDP, codesign, or lsof. Helper processes do not use the main executable path. Sensitive start/stop paths continue to use the existing signed runtime and executable identity validation in common-macos.sh.

Validation

  • Before the fix on the affected live session: pgrep -x ChatGPT returned no PID while ps showed the complete main command path.
  • After the fix: status-dream-skin-macos.sh --json reported codexRunning: true for that same running process.
  • Added a regression fixture whose command begins with the saved full executable path while its process name belongs to /bin/sleep.
  • CI=1 CODEX_DREAM_SKIN_SKIP_DOCTOR=1 macos/tests/run-tests.sh passed twice after the final fixture cleanup, including signed-runtime theme switching and runtime-state integration.
  • Bash syntax checks and git diff --check passed.

The repository skipped SwiftPM/XCTest because this host has Command Line Tools rather than a full matching Xcode macOS platform. Doctor was deliberately skipped; this change only affects non-destructive status presentation and prompt selection.

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.

1 participant