Repository navigation
fix(worker-pool): worker 重启走 POST 路径时补发 set_display_mode - #45
Merged
deepcoldy merged 2 commits intoMay 23, 2026
Merged
Conversation
当 worker ready 后旧卡片 PATCH 失败(过期/撤回/streamCardPending), 会走 POST 新卡片路径。此路径之前漏掉了向 worker 发送 set_display_mode, 导致 displayMode 为 screenshot 时新 worker 仍停在默认 hidden,截图循环 不会启动,飞书卡片截图静默失效。 与 PATCH 路径(line 755)对齐,在 POST 成功后同样 re-sync display mode。
覆盖场景: - POST 路径 + displayMode='screenshot' → worker.send 被调用 - POST 路径 + displayMode='hidden' → worker.send 不被调用 - PATCH 路径 + displayMode='screenshot' → worker.send 被调用(对称性) 去掉修复后用例 1 失败,证明修复有效。
deepcoldy
approved these changes
May 23, 2026
deepcoldy
left a comment
Owner
There was a problem hiding this comment.
感谢 @LikaiLee 的修复!🙏
定位精准:worker 重启走 POST 路径(旧卡片 PATCH 失败 fallback 新建卡片)时遗漏补发 set_display_mode,导致新 worker 的 displayMode 停留在 'hidden'、截图循环静默失效。修复与 PATCH 路径完全对称,放在 streamCardId 提交之后也合理,纯增量、低风险,并附带 3 个回归用例。
双人 review 通过:
- Claude:build ✅ / 新测试 3/3 ✅ / 全量单测 65 文件 1272 用例 ✅
- Codex:独立交叉核对 merge ref,LGTM,无 blocking
LGTM,合并。
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.
背景
botmux 的截图循环由 worker 中的
captureAndUpload()驱动,只有在displayMode === 'screenshot'时才拍照上传。daemon 在卡片就绪时通过 IPC 发送set_display_mode消息激活 worker 的截图循环。问题
当 worker 崩溃/重启后,daemon 通过
streamCardPending决定走 PATCH(复用旧卡片)还是 POST(新建卡片)两条路径恢复流式卡片。worker-pool.ts~L614):已正确在卡片恢复后向新 worker 发送set_display_mode。worker-pool.ts~L653):遗漏了这一步。后果:如果旧卡片 PATCH 失败(如消息被撤回)导致 fallback 到 POST 创建新卡片,新 worker 的
displayMode一直停留在'hidden',截图循环静默失效,飞书端和网页端截图不再更新。修改
在 POST 路径成功创建新卡片后,补发
set_display_mode给 worker(与 PATCH 路径对齐):同时导出
__testOnly_setupWorkerHandlers供单测直接触发case 'ready'处理逻辑。验证
displayMode='screenshot'worker.send被调用,参数含{ type: 'set_display_mode', mode: 'screenshot' }displayMode='hidden'worker.send不被调用displayMode='screenshot'worker.send被调用(对称性回归保护)注释掉修复代码后用例 1 失败(
worker.send调用次数为 0),证明测试有效覆盖该路径。