Skip to content

fix(windows): recover injector after Codex reopens - #231

Open
nightt5879 wants to merge 2 commits into
Fei-Away:mainfrom
nightt5879:agent/fix-windows-reopen-injector
Open

fix(windows): recover injector after Codex reopens#231
nightt5879 wants to merge 2 commits into
Fei-Away:mainfrom
nightt5879:agent/fix-windows-reopen-injector

Conversation

@nightt5879

Copy link
Copy Markdown
Contributor

Summary / 摘要

  • Add a tray recovery monitor for the stale state left after the original CDP browser identity and watcher exit.
  • Recover only after the recorded injector is confirmed stopped and the replacement CDP endpoint is verified as owned by a registered official Codex Store package.
  • Add a -RecoverExisting start mode that can attach a new watcher but cannot launch, restart, or resume Codex.
  • Preserve exact PID, executable, command-line, start-time, port, and browser-ID validation while sharing it between stop and recovery paths.
  • Add PowerShell 5.1/7 regression coverage and document the Windows fix.

Root cause / 根因

The injector intentionally anchors itself to the original CDP browser WebSocket and exits when that identity closes. This prevents a stale watcher from following an unverified process onto the same port, but the long-lived Windows tray had no reconciliation path. After Codex reopened with a new verified browser identity, the tray continued updating active-theme while no watcher remained to apply those changes.

Type / 类型

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

Platform / 平台

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

Self-check / 自测

Check what you actually ran. Skip items that do not apply and say so under Notes.
请勾选实际跑过的项;不适用的在 Notes 说明。

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

  • Passed: powershell.exe -NoLogo -NoProfile -ExecutionPolicy RemoteSigned -File .\windows\tests\run-tests.ps1.
  • Passed: pwsh.exe -NoLogo -NoProfile -ExecutionPolicy RemoteSigned -File .\windows\tests\run-tests.ps1.
  • Passed: powershell.exe -NoLogo -NoProfile -ExecutionPolicy RemoteSigned -File .\windows\tests\installer-static.tests.ps1.
  • Passed: PowerShell parser checks and git diff --check.
  • The suite now covers recoverable stopped injectors, live-injector duplicate prevention, closed ports, unverified endpoints, exact live-process identity, PID mismatch preservation, and stopped-process detection.
  • Expected cleanup warnings in the suite are fault-injection coverage.
  • Updated windows/CHANGELOG.md; the template's changelog checkbox is macOS-specific.
  • Environment: Windows 11 build 26200; Microsoft Store Codex 26.715.10079.0; Windows PowerShell 5.1.26100.8875; PowerShell 7.6.3; Node.js 22.22.2.
  • A live Codex close/reopen was not run because it would disrupt the active desktop session; the regression exercises the recovery decision and real child-process identity paths without modifying the official package.

Fixes #200

@nightt5879
nightt5879 marked this pull request as ready for review July 23, 2026 10:00
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.

[Bug]: [Windows] Reopening Codex stops injector and breaks live theme switching / 关闭重开后主题切换失效

1 participant