From afa9ebde67c89973010ebe7d21dfec0aa60e7585 Mon Sep 17 00:00:00 2001 From: hotwa Date: Wed, 18 Mar 2026 15:12:23 +0800 Subject: [PATCH] Document mac-7 Chrome LaunchAgent fix --- daily/2026-03-18.md | 29 +++++++++++++++++++ .../decisions/browser-endpoints-mac5-mac7.md | 28 +++++++++++++++++- 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/daily/2026-03-18.md b/daily/2026-03-18.md index 2d484e2..c60842a 100644 --- a/daily/2026-03-18.md +++ b/daily/2026-03-18.md @@ -102,3 +102,32 @@ - 因此后续引用时可直接视为: - 稳定本地自动化入口:`mac-7 127.0.0.1:9333` - 稳定 tailnet 远程入口:`mac-7 100.64.0.23:9223` + +## mac-7 automation Chrome LaunchAgent 修正 + +- 用户观察到 mac-7 自动化 Chrome 会不断新增空白页;远程 `remote-mac7` profile 看到的空白 tab 一度累积到大量 `about:blank` +- 现场排查确认:问题不在 mac-5 的 remote CDP profile,而在 mac-7 本地 LaunchAgent `com.lingyuzeng.chrome-cdp-mac7` +- 原始问题配置特征: + - `KeepAlive = true` + - 直接执行 Chrome 二进制 + - `ProgramArguments` 包含 `about:blank` +- 实际运行机理: + - Chrome 发现 automation profile 的现有会话已存在 + - 输出“正在现有的浏览器会话中打开。”后退出 `0` + - launchd 因 `KeepAlive=true` 立即再次拉起 + - 从而持续向同一会话注入新的 `about:blank` tab +- 修正后的 durable 方案: + - 去掉 `KeepAlive` + - 不再由 launchd 直接反复 exec Chrome + - 改为执行包装脚本:`~/.openclaw/bin/start_chrome_cdp_mac7.sh` + - 包装脚本会先检查 `127.0.0.1:9333` 是否已监听;若已存在则直接退出,否则仅启动一次 automation Chrome +- 修正后验证: + - `127.0.0.1:9333` 正常监听 + - `/json/version` 正常返回标准 CDP 信息 + - 远程 tabs 数复测稳定,不再持续增长 +- 运维提示: + - 未来若再次出现空白 tab 不断增长,优先检查该 plist 是否误恢复为 `KeepAlive + 直接执行 Chrome + about:blank` 这一旧模式 +- 补充清理: + - 已清空 mac-7 上相关历史日志: + - `~/Library/Logs/chrome-cdp-mac7.stdout.log` + - `~/Library/Logs/chrome-cdp-mac7.stderr.log` diff --git a/shared/long-term/decisions/browser-endpoints-mac5-mac7.md b/shared/long-term/decisions/browser-endpoints-mac5-mac7.md index 0c7c46b..0d101c6 100644 --- a/shared/long-term/decisions/browser-endpoints-mac5-mac7.md +++ b/shared/long-term/decisions/browser-endpoints-mac5-mac7.md @@ -78,4 +78,30 @@ So future tasks should treat the endpoints as: - For mac-5 intelligent browser takeover: use OpenClaw local `user` profile. - For mac-7 automation on the same machine: use CDP on `127.0.0.1:9333`. -- For mac-5 controlling mac-7 across the tailnet, do not assume `100.64.0.23:9223` is durable unless a persistent proxy/serve configuration is explicitly installed later. +- For mac-5 controlling mac-7 across the tailnet: use the stable remote CDP endpoint `http://100.64.0.23:9223`. + +## LaunchAgent correction after blank-tab loop incident + +Validated on 2026-03-18 later the same day: + +- The original `com.lingyuzeng.chrome-cdp-mac7` LaunchAgent caused repeated blank tabs. +- Root cause: the plist directly executed Chrome with `KeepAlive=true` and `about:blank` in `ProgramArguments`. +- On macOS, Chrome detected the existing browser session, printed `正在现有的浏览器会话中打开。`, exited with code `0`, and launchd immediately re-ran it. +- This created a loop that kept injecting new `about:blank` tabs into the same automation profile. + +### Corrected durable implementation + +- LaunchAgent remains: + - `~/Library/LaunchAgents/com.lingyuzeng.chrome-cdp-mac7.plist` +- It should no longer use `KeepAlive=true` to re-exec Chrome directly. +- It should launch a wrapper script instead: + - `~/.openclaw/bin/start_chrome_cdp_mac7.sh` +- Wrapper behavior: + - check whether `127.0.0.1:9333` is already listening + - if yes, exit without launching another Chrome instance + - if no, start the dedicated automation Chrome profile once + +### Operational takeaway + +- If future symptoms show many new `about:blank` tabs appearing on mac-7, first inspect `com.lingyuzeng.chrome-cdp-mac7.plist` for accidental reintroduction of `KeepAlive` or direct Chrome execution with `about:blank`. +- The repeated-tab issue was caused by LaunchAgent semantics, not by the remote CDP profile on mac-5.