Skip to content

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

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

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

Conversation

@nightt5879

@nightt5879 nightt5879 commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Summary / 摘要

  • Replay the Windows reopen recovery on current main (v1.5.14).
  • Add a single-instance tray reconciliation timer that acts only after the recorded watcher PID + process start time is gone and a different Browser ID is verified on the saved port.
  • Add fail-closed -RecoverExisting startup mode. It rechecks the operation lock, pause marker, state schema, watcher liveness, Store package ownership, port and Browser identity; it never launches or restarts Codex.
  • Preserve current Store-update adoption, appearance rollback, one-click apply, localized tray and source-independent installed-engine contracts.
  • Keep cleanup command-line identity out of this PR so it does not duplicate or conflict with fix(windows): require exact cleanup process identity #148's exact argv boundary work.
  • Add en-US / zh-CN recovery copy and dedicated PowerShell 5.1/7 regressions.

Safety / 安全边界

Recovery is inert when any of these is true:

  • Dream Skin is paused.
  • The recorded watcher PID and start time are still alive.
  • The Browser ID has not changed.
  • The saved port is closed or changes during attachment.
  • The listener is not owned by a registered official OpenAI.Codex Store package.
  • A durable appearance transaction still needs reconciliation.
  • Another start, pause, theme apply, or restore owns the operation lock.

-RecoverExisting rejects restart/prompt flags and cannot enter the Codex launch or restart paths.

Verification / 验证

Passed on Windows:

  • powershell.exe -NoLogo -NoProfile -ExecutionPolicy RemoteSigned -File .\windows\tests\run-tests.ps1
  • pwsh.exe -NoLogo -NoProfile -ExecutionPolicy RemoteSigned -File .\windows\tests\run-tests.ps1
  • powershell.exe -NoLogo -NoProfile -ExecutionPolicy RemoteSigned -File .\windows\tests\installer-static.tests.ps1
  • pwsh.exe -NoLogo -NoProfile -ExecutionPolicy RemoteSigned -File .\windows\tests\installer-static.tests.ps1
  • node --test windows/tests/*.test.mjs (27 tests)
  • Inno Setup 6.7.1 compile: CodexDreamSkin-Setup-v1.5.14.exe, 24,486,926 bytes, SHA-256 1868AB09E50143644B9C7640E95AEEA9F0E4D27389919A9E51C968C6CF650E69
  • git diff --check

The true Store Codex full-close/reopen/theme-switch smoke is still pending. It was not claimed from this development session because closing Codex would terminate the active Codex task hosting the test run.

Fixes #200

@nightt5879
nightt5879 marked this pull request as ready for review July 23, 2026 10:00
@Fei-Away Fei-Away added the status: considering Maintainer likes the idea, evaluating for a future merge label Aug 8, 2026
@Fei-Away

Fei-Away commented Aug 8, 2026

Copy link
Copy Markdown
Owner

维护者 current-main 复核(main@6f789be / v1.5.12):#200 的恢复缺口仍在,PR 保持开放。当前 watcher 在原 Browser identity 关闭后退出,tray 没有针对“新端点已验证、旧 watcher 已停止”的 reconciliation monitor;-RecoverExisting 严禁启动或重启 Codex 的设计仍合适。

请基于 current main 重放,复用当前 Browser ownership、process start time、state schema 与 tray localization,避免与正常 start/pause/restore 竞态。合入前需要 PowerShell 5.1/7 全套、Setup compile,以及真实 Codex 完全关闭后重开并再切换主题的 Windows smoke。

@Fei-Away

Fei-Away commented Aug 8, 2026

Copy link
Copy Markdown
Owner

维护者复核(当前 main@6f789be / v1.5.12):#200 的根因仍在,PR 保持开放。

current Windows watcher 按设计在原 Browser ID 关闭后退出;start-dream-skin.ps1 没有 fail-closed 的 RecoverExisting 模式,长驻托盘也没有在新且已验证的 Codex CDP endpoint 出现后恢复 watcher 的 reconciliation monitor。因此仍可能出现“托盘写入 active theme 成功、但界面不再热切换”。

请基于 current main 只移植 recovery context、RecoverExisting 和单实例托盘协调;不要带回旧 raw-regex process matching,进程身份应与 #148 的精确参数边界协调,并保留现行 operation lock、Store 自动更新、一键换肤和 source-independent engine 合同。新增用户文案必须进入 en-US / zh-CN catalog。验收需要 PowerShell 5.1/7 与兼容的真实 Store Codex 关闭/重开,证明只产生一个 watcher,并在 paused、端口关闭、非官方 listener 时绝不启动、重启或恢复 Codex。

@nightt5879
nightt5879 force-pushed the agent/fix-windows-reopen-injector branch from 0331b6c to 5e34285 Compare August 13, 2026 02:33
@nightt5879

Copy link
Copy Markdown
Contributor Author

已按这条复核意见基于 current main(现为 v1.5.14)重做并 force-push:5e34285

本次只移植 reopen recovery 所需边界:

  • tray reconciliation 仅在旧 watcher 的 PID + process start time 已失效、保存端口出现不同 Browser ID,且 endpoint 再次通过官方 Store 包 ownership 校验后触发;
  • -RecoverExisting 在 operation lock 内重复校验 state / pause / watcher liveness / Store ownership / port / Browser identity,拒绝 restart/prompt flags,不能进入 Codex launch/restart 路径;
  • paused、旧 watcher 仍活着、同 Browser ID、端口关闭/切换、非官方 listener、pending appearance transaction 全部 fail-closed;
  • 保留 current Store auto-update adoption、appearance rollback、一键换肤、source-independent engine 和 tray localization;新增文案已进入 en-US / zh-CN
  • 没有把旧 raw-regex process matching 带回 recovery context;cleanup argv identity 仍留给 fix(windows): require exact cleanup process identity #148,避免两边重复实现/冲突。

验证结果:

  • 本机 Windows PowerShell 5.1 / PowerShell 7 完整 run-tests.ps1 均通过;
  • 两种 shell 的 installer-static.tests.ps1 均通过;
  • node --test windows/tests/*.test.mjs:27/27;
  • 本机 Inno Setup 6.7.1 成功编译 CodexDreamSkin-Setup-v1.5.14.exe
  • GitHub CI run 31661172332 四个 required jobs 全部通过(含 5.1 Setup compile)。

真实 Store Codex 完全关闭 → 重开 → 再切换主题的 smoke 仍未冒充完成:当前开发/验证本身运行在 Codex Desktop 内,关闭它会终止本任务。PR 描述已明确保留这项独立人工验收。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: considering Maintainer likes the idea, evaluating for a future merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants