Skip to content

fix(desktop): 共用 Work Louder 保护设置并精简重启提示 - #3983

Merged
MagicLizi merged 3 commits into
mainfrom
dash/codex-micro-restart-hint
Sep 6, 2026
Merged

fix(desktop): 共用 Work Louder 保护设置并精简重启提示#3983
MagicLizi merged 3 commits into
mainfrom
dash/codex-micro-restart-hint

Conversation

@dashhuang

@dashhuang dashhuang commented Sep 5, 2026

Copy link
Copy Markdown
Member

这次改了什么

摘要

Codex Micro 与 Creator Micro 2 共用页面底部的保护开关,移除“已关闭”等冗余标签,重启提示放在开关左侧。

用户明确将提示范围收敛为:手动打开选项时,检查 Codex 是否正在运行;开着就提示,没开就不提示。关闭选项或当时的 Codex 退出/重启后清除提示。Cindy 启动恢复偏好不触发提醒。两款键盘继续共用配置与服务,保留默认键位和固件映射差异。

变更类型

  • fix 缺陷修复

范围

  • 关联 Issue / 需求:用户提出的键盘设置位置、条件重启提示和双型号共用需求。
  • 本 PR 包含:共享设置入口与五语文案;手动开启时的本机进程检测和内存提示状态;两型号共用的回归测试。
  • 明确不包含:默认键位、固件键码映射、设备 keymap 恢复流程或已有拦截条件的调整;跨 Cindy 重启推断、逐进程回执、升级迁移或新的持久记录。
  • 用户可见变化:设置置底;只有手动开启时检测到 Codex 在运行才显示提示;关闭选项或当时的进程退出/重启后提示消失。
  • 是否存在 breaking change:无。沿用同一配置和 IPC,新增状态字段为可选字段。
  • 多端:这是本机 macOS 键盘保护,SSH 工作区及手机控制端不执行本机进程探测;未新增 IPC、device-link 通道或远端入口。

UI 变化

  • 两型号的保护设置统一位于页面最下方。正常状态保留功能说明,异常状态保留恢复操作。
  • 引用的设计规范:docs/design-rules/DESIGN.md §1、§5、§10、§11:复用现有设置行、开关与语义颜色,保持低强调提示,去除重复状态文案,同时实现 Light / Dark 主题样式。
  • 平台:Desktop;本次未进行客户端截图或实机目检。

怎么验证的

自动验证

  • pnpm test:unit:related:通过(Desktop 关联单测)。
  • pnpm --filter desktop run --if-present typecheck:通过。
  • pnpm check:i18npnpm check:i18n-glossary:通过,无新增术语违规。
  • 初版全量门禁 bash /Users/dash/Code/XD/dash/Skills/git/scripts/run-unit-gate.sh <worktree>:脚本测试 503 通过,Desktop、Mobile 及其他共享包通过;maker-core 有 2 项 Pi 集成测试失败。
  • 干净 origin/main 基线 47ef43edd9861453c4c5e00583c8184840e2fced 上使用相同 Pi 二进制复跑对应两项测试:同样失败(dotenv symlink 用例 60 秒超时;redirect globs 用例期望 ['bash']、实际 [])。测试位于 packages/maker-core/src/agents/pi/__tests__/pi-agent.integration.test.ts:2361:2510,本 PR 未修改该包。基线工作区复跑后仍干净。
  • 基线复现命令:pnpm --filter @cindy/maker-core exec vitest run src/agents/pi/__tests__/pi-agent.integration.test.ts --pool=forks --maxWorkers=1 --testNamePattern 'auto mode escalates bash input redirects reached through a dotenv symlink|redirect globs fail closed on inherited or runtime Bash options while ordinary globs stay fast'
  • git diff --check:通过。

新增回归覆盖:两型号设置位置及共用开关、恢复操作;手动开启时 Codex 已开/未开、开启后才启动 Codex、退出、PID 复用的重启、关闭开关、Cindy 重启以及扫描失败。

提示状态不变量:仅由显式开启创建当时的进程列表;查询/现有心跳只移除已退出的进程,不加入新进程;关闭、恢复、退出 Cindy 或检测失败清空。空列表不继续扫描。启动恢复偏好不创建列表。进程探测不改变拦截条件。

手工验证

macOS 上执行了只读进程探测,命令正常返回;当时未运行独立 Codex 应用。没有据此宣称硬件保护已实机验证。

未执行的验证

未进行两款真实键盘联调、真实 Codex 重启流程,以及 Light / Dark 客户端目检;本次以回归测试验证状态和界面行为。

风险

风险分类

  • 权限 / 安全 / 用户数据
  • 跨平台差异

影响与回滚

  • 影响范围:保护仍仅在 macOS 可用,继续由同一个 Main 服务管理两款设备。进程扫描仅使用 PID、启动时间和可执行文件路径,不读取进程环境或命令参数,也不终止进程。
  • 状态判据:提示只依据打开开关时是否存在目标进程,不承诺判断该进程实际上是否已受保护。现有心跳仅用于清除已退出/重启进程的提示;扫描失败时静默,保护本身继续工作。
  • 没有新增持久化;原有 hook、回执格式和恢复配置均保持原样。
  • 回滚 / 降级方式:回退本 PR 即恢复原界面与提示逻辑,用户已有保护偏好及原有恢复流程不变。

提交前检查

  • 已 review 完整 diff
  • 每个 commit 都带 DCO 签名(git commit -s
  • UI 改动已注明引用的设计规范章节
  • 未提交凭证、令牌或授权文件
  • 已补充必要说明和回归测试
  • 已确认测试结果或说明未执行原因

@dashhuang
dashhuang requested a review from a team as a code owner September 5, 2026 12:52
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 5, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-05T13:44:10.255983Z 6c086b8 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Sep 5, 2026

Copy link
Copy Markdown

Greptile Summary

此 PR 将 Work Louder 的 Codex 保护设置共享给 Codex Micro 与 Creator Micro 2,并新增基于目标进程身份和拦截回执的条件重启提示。

  • 新增 macOS Codex/ChatGPT 主进程探测,并通过 PID、启动时间和可执行文件识别进程实例。
  • hook 写入按进程保存的拦截回执,Main 服务据此维护 restartRequired 状态并清理过期回执。
  • 将共享保护设置移动到页面底部,移除冗余状态标签,并更新五种语言文案。
  • 增加服务生命周期、PID 复用、探测失败、回执清理及两款键盘共享 UI 的回归测试。

Confidence Score: 5/5

未发现需要阻止合并的具体问题,此 PR 看起来可以安全合并。

进程探测、回执身份匹配、服务生命周期和共享 UI 状态形成了完整闭环,新增测试也覆盖了退出、重启、PID 复用、探测失败及 Cindy 重启等关键路径。

Important Files Changed

Filename Overview
apps/desktop/src/main/worklouder-codex/CodexMicroGuardService.ts 增加进程扫描、条件重启状态、心跳刷新和回执清理编排,未发现确定的生命周期或并发缺陷。
apps/desktop/src/main/worklouder-codex/codexMicroGuardProcesses.ts 使用受限的 ps 调用识别受支持的 Codex 与 ChatGPT 桌面主进程。
apps/desktop/src/main/worklouder-codex/codexMicroGuardHook.cjs 在原有拦截成功时额外写入私有的进程身份回执,诊断写入失败不会改变拦截行为。
apps/desktop/src/main/worklouder-codex/codexMicroGuardCore.ts 新增进程回执验证及仅针对已退出进程的过期回执清理。
apps/desktop/src/renderer/components/settings/WorkLouderCodexSettings.tsx 将共享保护设置置底,并仅在保护尚未应用到存活旧进程时显示重启提示。
apps/desktop/src/shared/codexMicroGuard.ts 为共享保护状态增加向后兼容的可选 restartRequired 字段。

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[启用 Work Louder 保护] --> B[安装 NODE_OPTIONS hook]
  B --> C[记录保护开始时间]
  C --> D[扫描 Codex / ChatGPT 主进程]
  D --> E{进程早于保护启动?}
  E -- 否 --> F[无需重启提示]
  E -- 是 --> G{存在匹配的进程回执?}
  G -- 是 --> F
  G -- 否 --> H[显示完全退出并重新打开提示]
  I[Codex 加载 Work Louder 服务] --> J[hook 拦截服务]
  J --> K[写入 PID、启动时间及路径回执]
  K --> D
  L[心跳刷新或显式读取状态] --> D
Loading

Reviews (1): Last reviewed commit: "fix(desktop): share Work Louder protecti..." | Re-trigger Greptile

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: acc40c2250

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/desktop/src/main/worklouder-codex/CodexMicroGuardService.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 24e1825c0d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/desktop/src/main/worklouder-codex/CodexMicroGuardService.ts Outdated
…n needed

Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
@dashhuang
dashhuang force-pushed the dash/codex-micro-restart-hint branch from 24e1825 to 6c086b8 Compare September 5, 2026 13:39

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6c086b8c55

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/desktop/src/main/worklouder-codex/CodexMicroGuardService.ts
Comment thread apps/desktop/src/main/worklouder-codex/CodexMicroGuardService.ts
@MagicLizi MagicLizi added touches:core 改动碰到架构核心路径(review-pr 自动维护,仅展示) touches:product-ui 改动碰到产品 / UI 面(review-pr 自动维护,仅展示) labels Sep 6, 2026
@MagicLizi

Copy link
Copy Markdown
Contributor

命中 UI 路径(apps/desktop/src/renderer/components/settings/WorkLouderCodexSettings.tsx)但 description 未附界面效果证据——建议补充改动后效果:截图/录屏,或改动后界面的 HTML 页面(```html 代码块、.html 附件或在线预览链接),便于确认界面符合 DESIGN.md 设计规范

@MagicLizi MagicLizi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

代码重审通过:Work Louder 保护设置共用一份本机覆盖,重启提示只暴露 boolean,PID 不出 Main。当前 head 没有 P0/P1。

@MagicLizi
MagicLizi merged commit df05fda into main Sep 6, 2026
26 of 28 checks passed
@MagicLizi
MagicLizi deleted the dash/codex-micro-restart-hint branch September 6, 2026 04:28
@MagicLizi

Copy link
Copy Markdown
Contributor

合了。两套 Work Louder 共用一份保护开关,重启提示也不再把进程细节漏到界面上。

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

Labels

touches:core 改动碰到架构核心路径(review-pr 自动维护,仅展示) touches:product-ui 改动碰到产品 / UI 面(review-pr 自动维护,仅展示)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants