fix(ths): 交易弹窗结构化处置 + 防卡死 + 超时 unknown 语义 - #5
Merged
Conversation
事故驱动(2026-07-13 委托确认弹窗卡死、MCP 报错但实际成交)。 根因实证:市价提交用 SendMessage(BM_CLICK) 遇模态框死锁 + to_thread 无超时/win_lock 饿死/WS 消息循环内联 await 放大为全端瘫痪。 方案:P0 防卡死(PostMessage 化 + 25s 总超时 + 循环解耦)、 P1 弹窗看门人(识别-分类-处置-回执)、P2 引导与真机回归、 网关超时回执改 unknown 语义。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
根因修复: - 市价提交/验证码确定按钮 SendMessage(BM_CLICK)→PostMessage:同步跨进程 调用遇模态「委托确认」框死锁是本次委托卡死的直接根因 - dispatcher 单笔调用 25s 总超时(低于网关 30s):下单类超时回 code=2 status=unknown +「先核单勿补单」;win_lock 拿锁 5s 超时回 busy; 超时置 degraded,下次调用先跑弹窗清扫自愈 - ws_client call 帧改 create_task:单笔 RPC 卡死不再瘫痪整个消息循环 弹窗看门人(ths/dialogs.py DialogSentry): - 下单/撤单提交后用 pump()「等待-发现-处置」取代三连盲 Enter - 处置不耦合弹窗内容:含 Edit→input_ocr;肯定按钮(是>确定>确认>同意>唯一) →PostMessage 点击;无按钮→向弹窗投递回车(真机验证);两次回车不消才 WM_CLOSE;全程禁 ESC(对确认框语义是否) - 每个弹窗截图存证 + 标题/全文/动作记入回执 dialogs 字段;机会性提取 合同编号;回查失败时弹窗原文进回执(废单真实原因不再丢失) 文档与工具:spec 定稿、PROTOCOL.md 网关超时语义条款、架构文档 7.7 节 PostMessage 铁律、README 弹窗设置建议、tools/ths_dialog_dump.py 真机 弹窗结构诊断脚本。测试:106 passed(新增弹窗决策/超时语义/消息循环 16 例) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
suny911
marked this pull request as ready for review
July 13, 2026 07:32
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.
背景
2026-07-13 14:42 真实事故:市价 sell 弹出「委托确认」模态框,受控端卡死,MCP 30s 后报 -32003,但用户手动点「是」后订单实际成交——「报错但静默成交」差点导致补单事故。
根因(已实证)
SendMessage(BM_CLICK)——同步跨进程调用,按钮 handler 弹模态框后不返回,线程死锁,后续关弹窗代码根本没执行。to_thread无超时 +win_lock永久持有 + WS 消息循环内联 await → 单笔卡死瘫痪整个受控端。修复(P0 + P1 已落码)
P0 防卡死
SendMessage(BM_CLICK)→PostMessage(市价提交 + 验证码确定),并立为铁律写进架构文档 §7.7code=2 status=unknown+「先核单勿补单」;拿锁 5s 超时回 busy;超时置 degraded,下次调用先清弹窗自愈P1 弹窗看门人(
ths/dialogs.pyDialogSentry) —— 处置不耦合弹窗内容(用户定的原则:任何弹窗快速肯定式消除、回到既定轨道),决策只看结构:Edit输入框 → 验证码 → 走既有input_ocrPostMessage(BM_CLICK);绝不点否/取消WM_CLOSE;全程禁 ESC(对确认框语义是「否」)每个弹窗截图存证 + 标题/全文/动作记入回执
dialogs字段;机会性提取合同编号;回查失败时弹窗原文进回执(废单真实原因不再丢失)。协议/文档:PROTOCOL.md 增补网关超时必须回 unknown 语义的强制条款;README 补关弹窗设置建议;spec 定稿于
docs/superpowers/specs/2026-07-13-ths-dialog-handling-design.md。测试
python tools/ths_dialog_dump.py(开着任意弹窗)核对新版皮肤弹窗控件结构;按 spec §6.3 清单回归市价/限价/撤单/废单/风险警示/验证码六类场景🤖 Generated with Claude Code