Skip to content

fix(macos): stop stale injector watcher CPU loops - #264

Open
jeromychu23 wants to merge 1 commit into
Fei-Away:mainfrom
jeromychu23:codex/fix-macos-high-cpu-upstream
Open

fix(macos): stop stale injector watcher CPU loops#264
jeromychu23 wants to merge 1 commit into
Fei-Away:mainfrom
jeromychu23:codex/fix-macos-high-cpu-upstream

Conversation

@jeromychu23

@jeromychu23 jeromychu23 commented Jul 26, 2026

Copy link
Copy Markdown

Summary / 摘要

  • Tie every macOS injector watcher to the verified ChatGPT host PID and stop it as soon as that host exits.
  • Replace launchctl submit with a one-shot LaunchAgent using KeepAlive=false, while cleaning up legacy submitted jobs and orphaned jobs whose state file is missing.
  • Back off failed CDP discovery from 250 ms to a 30-second cap, throttle repeated errors to 30 seconds, and keep SIGINT/SIGTERM interruption immediate.
  • Add lifecycle, launch-agent, host-exit, retry, log-throttle, and existing window-readiness regression coverage.

Closes #218

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 / 補充

  • Based on the latest upstream main; the unrelated local add Ado theme commit was intentionally excluded.
  • The current upstream renderer has already replaced the old root-class mutation path from the local CPU investigation, so this PR preserves that unified renderer and ports only the still-relevant macOS watcher/launchd fixes.
  • Passed: CODEX_DREAM_SKIN_SKIP_DOCTOR=1 npm test from macos/, targeted watcher lifecycle and window-readiness tests, shell/Node syntax checks, and git diff --check.
  • The suite skipped SwiftPM/XCTest because this Mac does not have a complete matching Xcode macOS platform.
  • Doctor was attempted but the current live session failed at its renderer verification step; automated tests were rerun with the repository-supported Doctor skip flag. Live verify and restore/re-apply smoke remain unchecked.
  • No files under windows/ changed.

@jeromychu23
jeromychu23 marked this pull request as ready for review July 26, 2026 13:39
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.

[Performance][macOS] CDP 断开后 injector watcher 仍常驻并高频重试,导致系统明显卡顿

1 participant