Repository navigation
fix(worker): 修复首轮启动期卡片跳过工作中状态 - #819
Merged
Merged
Conversation
argv 烘焙首条消息(passesInitialPromptViaArgs,不走 flushPending)期间, startScreenUpdates() 的 2s 采样器被 `if (awaitingFirstPrompt) return;` 整个 gate 掉,直到首轮结束的 markPromptReady 或 15s 软超时才解除;首轮内 onBusy 忙转换要求先出现过 idle 边、markPromptReady 的 working seed 只在首轮结束瞬间 发出,实时卡片都用不上。结果 daemon 侧卡片状态(lastScreenStatus ?? 'starting') 从「启动中」直接跳「等待输入」,缺「工作中」。 把裸 return 换成 busy 窄通道:仅当 backendScreenEvidenceIsAuthoritativeForMutation() 且存在 cliAdapter.busyPattern 且 backend 可捕获时,取当前 viewport 测 busy marker, 命中且 lastSentStatus 未处于 working 时发一次 working 的 screen_update 并置 lastSentStatus=working(去重),try/catch 兜底异常则保持原 return。ZMX 非权威屏 在任何 capture 之前即退出(fail-open);无 busyPattern 的 CLI 保持原裸 return 行为。 纯 publisher:不改 isPromptReady、idle detector、spawnArgvInitialPromptBusy / spawnArgvNeedsWorkingSeed 任一状态,首轮就绪证据机制与首轮结束 working→idle seed 均不变;15s 软超时解除 gate 后正常路径经 status 去重不重发 working,seed 的 working→idle 仍照常形成 finishTurnReactions 所需的边。 影响面: - 仅 worker 侧 startScreenUpdates() 首轮 gate 分支;async 采样器主体逐字未动 - 跨 CLI:窄通道靠「存在 busyPattern + 权威屏显示 marker」自选人群,当前仅 pi/genius/grok/codex 定义了 busyPattern,其中 Pi 首轮受益最直接;无 busyPattern 的 CLI(gemini/mtr/opencode 等)命中 no-op 保持原行为;非首轮/adopt 路径不经此分支 - 跨后端:PtyBackend/TmuxBackend 经 captureBackendScreen 统一取 viewport;ZMX 在权威判定处即 fail-open,不触发窄通道 - 公共层未改 测试: - 新增集成回归 worker-argv-reaction-status.integration「publishes a working card during an argv-baked first turn before it completes」:fake Pi argv 首轮持续 Working... → 断言 prompt_ready 前已收到 working 的 screen_update 且只发一次(去重) → marker 清除后正常 idle;撤掉 src 修复后该用例稳定失败(等不到窄通道日志) - 新增源码级回归 worker-structured-lifecycle-status「publishes first-turn working only on an authoritative viewport...」:钉住权威判定先于 capture、busyPattern 必需、 纯 publisher 不触碰就绪/idle/seed 状态;撤修复后失败 - pnpm build 通过;tsc --noEmit 通过 - 定向 pnpm vitest run idle-detector / worker-argv-reaction-status.integration / worker-pipe-initial-screen-order / worker-structured-lifecycle-status:122 通过 / 1 失败;失败项「forces the synthetic working seed before classifying a limited settle」为既有环境 flake,在干净 master 上以逐字节相同断言([limited,working] vs [working,limited])3/3 复现,与本改动无关(本改动不改变该用例前两条更新的顺序) - 相邻 screen-capture-decision / worker-zmx-submit-recovery / first-prompt-timeout-repro 全绿
deepcoldy
commented
Aug 11, 2026
deepcoldy
left a comment
Owner
Author
There was a problem hiding this comment.
复审未通过,发现 1 个阻断问题:首轮窄通道会重新打开 Grok card-off 的过早 DONE 窗口。Pi 场景与“纯 publisher”本身验证通过,但需要先修复 Grok-class 状态顺序并补回归后再合并。
说明:当前 GitHub 身份是 PR 作者,平台不允许对自己的 PR 提交 REQUEST_CHANGES,因此以阻断性 COMMENT 记录;结论仍是不要合并。
deepcoldy
commented
Aug 11, 2026
deepcoldy
left a comment
Owner
Author
There was a problem hiding this comment.
对 head 10d371cd6 的代码复核通过,原阻断项已修复:
markPromptReady()的通用快照现在由!spawnArgvInitialPromptBusy闸住;当前 adapter 组合里只有 Grok 会 arm 该标志,因此 Pi 的正常收尾路径不受影响。- 首轮 publisher 改由
spawnArgvNeedsWorkingSeed圈定 argv 烘焙首条 prompt;非 argv CLI、defer/queued prompt、adopt 空 prompt 都不会误开。publisher 仍只发布状态,不修改 ready/idle/seed 状态机。 - 用实际安装的 Grok SessionStart ready hook 重放旧故障,daemon 可见状态为
working → working,prompt_ready后、terminal 前没有idle,不会再触发过早 DONE。
本地验证:
pnpm build:通过。- 5 个相关测试文件:103/103 通过(含 Pi、Grok、Gemini、adopt、turn reactions)。
- CI 中 3 个 codex-app-runner 超时用例隔离运行:3/3 通过。
- CI 的 2 个 slash 文档失败在 PR base
426b8f7a0上原样复现;本 PR diff 仅src/worker.ts与两个 worker 测试文件。因此当前 CI 红与本 PR 无关。
合并前仍需整理公开记录:
- PR 描述仍在陈述已废弃的 busyPattern/权威截屏/capture/ZMX fail-open 方案,也错误声称 Gemini/MTR/OpenCode 保持 no-op。请改成当前“argv 烘焙首轮直接发布投影 working + Grok generic-idle guard”的实现、影响面与最新验证结果。
- 新 commit body 首句的“复审发现”请改成客观实现描述(例如“原实现会……”),避免把内部协作编排措辞写进公开 git 历史。
代码层没有新增阻断;完成上述两项记录修正并重新跑 CI 后,可由维护者确认合并。未执行合并或 live daemon 切换。
首轮「工作中」原以截屏匹配 busyPattern 才发 working,会让 Grok 首轮出现 「工作中→等待输入→工作中」闪变并过早翻 DONE。改按「消息成功发给 CLI 即 working」的既有投影模型重做,并收敛触发范围。 改动一(startScreenUpdates 首轮通道):首轮 awaitingFirstPrompt 期间不再 截屏找 busy 标记,而是直接发布投影状态——首轮 isPromptReady 仍为 false, 投影本就是 working(与提交后每一轮同一条规则)。闸门改为 spawnArgvNeedsWorkingSeed (argv 烘焙首条 prompt),对非 argv 首轮(Claude/Codex/type-ahead,prompt 还在 队列、真在启动)保持 no-op,空 prompt 的 adopt 会话也不误报 working。纯发布者: 只 send 状态 + 本地 lastSentStatus 去重,不碰 isPromptReady/idle 检测器/argv seed 标志。 改动二(markPromptReady 通用 idle 快照):Grok 类首个 ready 是执行前的 SessionStart 边沿而非收尾,此前会在消费 spawnArgvInitialPromptBusy(busy arm) 之前先发一条通用 快照——彼时 isPromptReady 刚置 true,投影成 idle,抢在 arm 补 working 之前到达 daemon, 与首轮已发的 working 组成 working→idle,触发 finishTurnReactions 过早 DONE。为该快照 加 !spawnArgvInitialPromptBusy 闸;working 由下方 arm 负责发布,idle 不再抢跑。 影响面:仅 argv 烘焙且有 busy arm 的 Grok 类受改动二影响;改动一惠及全部 argv 烘焙 首轮(Pi 为主),非 argv CLI 与 adopt 空 prompt 均 no-op。worker 热路径,合并后需 canonical 部署方在飞书生效。 验证:tsc 通过、pnpm build 通过;新增 Grok 状态序列回归(首轮发过 working 后 terminal 前不得出现 idle);两处修复分别变异坐实有牙(去改动二→Grok 回归见 idle 泄漏转红; 去改动一→Pi/Grok 首轮 working 不再发布转红),两处 PR 测试文件全绿。
deepcoldy
force-pushed
the
fix/first-turn-working-card
branch
from
August 11, 2026 15:48
10d371c to
d022b56
Compare
deepcoldy
commented
Aug 11, 2026
Owner
Author
There was a problem hiding this comment.
对当前 head d022b5680 的最终验收结论:代码层通过,公开记录已修正。
d022b5680与已验证的10d371cd6tree 均为8f90445a2…,代码零差异;commit message 与 PR 描述现已准确反映“argv 首轮投影 working + Grok generic-idle guard”的实现。- 本 PR 两个测试文件在本轮 CI 分别 28/28、6/6 通过。
- build 的 7 个失败均在 diff 外:2 个 slash 文档同步用例在基线
426b8f7a0原样失败;5 个 codex-app-runner 用例是非确定性 timeout。对同一组 runner 用例单独重跑,head 出现 3 通过/2 超时,基线出现 4 通过/1 超时,确认该 flake 不由本 PR 引入。 - CodeQL 全部通过。
因此没有 #819 自身的代码阻断。GitHub 当前 BLOCKED 的门禁来自 REVIEW_REQUIRED:master 没有 required status checks,但要求 1 条 approving review 且 code owner 必审;管理员不受该门禁强制约束(enforce_admins=false)。正常合并需由非作者 code owner Approve;admin bypass 属维护者需明确作出的决策。
未执行合并、代码修改或 live daemon 切换。
|
🚀 Released in v3.14.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
改了什么、为什么
用户给 Pi 发第一句话时,飞书卡片从「启动中」直接跳「等待输入」,缺「工作中」状态。修复遵循「消息成功发给 CLI 即 working」的既有投影模型,并收敛触发范围,避免波及其它 CLI。
根因(已实证)
passesInitialPromptViaArgs),不经flushPending。worker.tsstartScreenUpdates()的 2s 采样器被if (awaitingFirstPrompt) return;整个 gate 掉,要等首轮结束的markPromptReady或 15s 软超时才解除,期间 daemon 收不到任何screen_update。working(isPromptReady初始为 false,投影规则isPromptReady ? idle : working与提交后每一轮一致)——问题不是缺 working 态,而是这条投影在首轮被上面那句裸return静音了,没往 daemon 发。lastScreenStatus ?? 'starting',首轮结束收到第一条screen_update(idle)时直接跳「等待输入」。怎么改
改动一 · 首轮通道(
startScreenUpdates):把裸if (awaitingFirstPrompt) return;换成一条投影发布者(不再截屏找 busyPattern):spawnArgvNeedsWorkingSeed——即「argv 烘焙了首条 prompt」。对非 argv 首轮(Claude/Codex/type-ahead,prompt 还在队列、CLI 真在启动)保持 no-op;空 prompt 的 adopt 会话也不 arm 该 flag,不误报 working。projectedRuntimeScreenStatus();仅当投影为working(首轮isPromptReady=false即成立)时发一次working的screen_update(当前快照 +turnId/dispatchAttempt)。lastSentStatus !== 'working'去重,发后置lastSentStatus = 'working'。return,async 采样器主体在首轮期间照旧不跑。纯 publisher:只
send状态 + 更新本地lastSentStatus,不改isPromptReady/ idle detector /spawnArgvInitialPromptBusy/spawnArgvNeedsWorkingSeed任一状态。首轮就绪证据机制、首轮结束的 seed 均不变。改动二 ·
markPromptReady的通用 idle 快照(worker.ts:9337):加!spawnArgvInitialPromptBusy闸。injectsReadyHook+reliableTurnTerminal)的首个 ready 是执行前的 SessionStart 边沿,不是收尾——spawnArgvInitialPromptBusy存在正是为此。markPromptReady在消费该 busy arm 之前会先发一条通用 idle 快照:此刻isPromptReady刚置 true → 投影成idle,抢在下方 arm 补working之前到达 daemon。它与改动一在首轮已发的working组成working→idle,触发 daemonfinishTurnReactions()→ 过早 ✅ DONE(并在实时卡片上表现为「工作中→等待输入→工作中」闪变)。working由下方 busy arm 负责发布,idle不再抢跑。真正的收尾 idle(assistant_final/fireIdle)仍照常形成 daemon 所需的working→idle边。影响面
worker.ts两处——startScreenUpdates()首轮 gate 分支、markPromptReady()的立即 idle 快照守卫。async 采样器主体、busy arm、seed 逻辑逐字未动。spawnArgvNeedsWorkingSeed:Pi/Gemini/MTR/OpenCode/Grok),不再挑「是否有 busyPattern」。已逐个核对:Claude/Codex/traex/coco/kimi/hermes 均passesInitialPromptViaArgs=false→ flag 为 false → 该分支 no-op(它们经正常flushPending提交后自然显示 working)。spawnArgvInitialPromptBusy的 Grok 类(需 argv +injectsReadyHook+reliableTurnTerminal三者全真,当前仅 Grok 满足)。Pi 走spawnArgvNeedsWorkingSeedseed 路径、其working→idle是真收尾,不受改动二影响。shouldTrackArgvBakedFirstPrompt要求preparedInitialPrompt非空且未 defer → adopt 空 prompt、defer/queued prompt 均返回 false,不误报。renderer.snapshot()+ 投影,不依赖后端截屏能力;PtyBackend / TmuxBackend 一致。测试验证
test/worker-argv-reaction-status.integration.test.ts「publishes a working card during an argv-baked first turn before it completes」:fake Pi argv 首轮,断言prompt_ready之前已收到status: working且只发一次(lastSentStatus去重),随后正常idle。撤掉改动一后该用例转红(首轮全程静默)。working后、terminal 前不得出现idle。撤掉改动二后该用例转红(idle 泄漏、includes('idle')变 true,复现过早 DONE 序列)。test/worker-structured-lifecycle-status.test.ts:钉住首轮通道按spawnArgvNeedsWorkingSeed+ 投影发布、不再截屏、纯 publisher 不碰就绪/idle/seed;并钉住markPromptReady的 idle 快照带!spawnArgvInitialPromptBusy闸、working 由下方 arm 发。pnpm build通过;tsc --noEmit通过(exit 0)。slash-commands-doc-sync(缺/introduce)与 gemini seed 顺序失败,均在 PR base426b8f7a0原样复现,PR 未改相关文件,与本改动无关。pnpm switch:here && pnpm daemon:restart(canonical checkout)方在飞书生效;如需飞书内手动验证 Pi/Grok 首轮卡片请先告知。