Repository navigation
feat(ask): 卡片展示选项说明,支持 --mention 点名 - #3181
Merged
Merged
Conversation
- AskUserQuestion 的 options[].description 透传到 ask 卡片与 turn-reply 卡片, 按钮行下方列出「选项:说明」;IPC 侧校验类型与长度(bad_option_description), 重放判等纳入 description - botmux ask --mention <open_id>:卡片第一问前注入真实 <at>,被点名者能收到通知; daemon 按 peer cross-ref 与 bots-info 剔除 bot open_id,避免飞书 100290 整卡拒收 - mentionedOpenId 随持久化 ask 跨重启保留;IPC 中值为 null 的字段视为未提供 Co-Authored-By: Claude Code <[email protected]>
Co-Authored-By: Claude Code <[email protected]>
混合题型卡片会把选项说明逐行渲染;行为断言分别验证两个选项仍可见,不钉旧分隔符。 Co-Authored-By: Claude Code <[email protected]>
结构护栏改为定位 createAskInput(boundAsk),继续验证会话身份绑定先于可观测 ask 注册,不钉内联对象实现。 Co-Authored-By: Claude Code <[email protected]>
同步到 master 486266c 并解冲突: - ask-broker questionsShape 同时保留 master 的 custom 与本 PR 的 description - daemon 保留 createAskInput 构造与 master 新增的 chat-scope 卡片落点 - codex-user-input-text 采用 master 的混合批次表单断言 - daemon-ipc-session-auth 恢复「ask 身份只取已绑定会话」的来源断言 Co-Authored-By: Claude Fable 5 <[email protected]>
- --mention 只接受显式 ask,open_id 规则与 --answerer 一致;daemon 发卡前查通讯录, 只保留本应用真人,查不到或是机器人时只丢掉 @,卡片照发 - 点名作为展示参数传给显式 ask 续接,不写进回执身份;注册输入恢复 master 的字面量, 身份字段只取已绑定会话,键序不变,升级重启前后的回执仍可续接 - 带点名的 ask 走独立卡(嵌进回复卡是 PATCH,不触发通知);settle 后与文档私聊卡不点名 - 选项说明在按钮卡、自定义输入表单、输入表单、文本作答批次与 settle 卡统一以小字展示, 标签与说明里的 at 标签一律中和 - 整卡超 30KB 时先截选项说明、说明全省仍放不下才截正文;附件包含完整正文与说明; 截到最小仍超预算时先发卡、送达后再发附件,避免话题里只留孤立文件 - hook 来源的超长选项说明截断到 1000 字符,显式调用仍返回 bad_option_description Co-Authored-By: Claude Fable 5 <[email protected]>
deepcoldy
requested review from
47seek,
LucasIcarus,
xiaoxueSunn and
xiongz-c
as code owners
November 8, 2026 07:40
Owner
Author
|
首审(接管后 head 8 条 P2 逐条闭环(独立探针 + 变异验证,非只读代码)
两处与原评审建议不同的取舍,复核后认可
2 条 P3 测试缺口(变异存活,行为本身正确,不阻断)
Follow-up(PR 已列明,合理)纯选择题题数上限(现超限已确定性失败、不留孤儿,加上限会让存量 questions-file 调用 exit 2,单独做);settle 卡独有截断的附件;文本批次 label 内 at 沿用正文口径(master 既有);hook 超 1000 字 clamp 尾部不入任何输出(截断固有)。 无删除文件;持久化仅新增可选字段,旧记录可恢复。等 CI 首跑全绿与复审人在本 head 的结论。 |
…rogate-safe cut A shared description cap always lands mid-pair in some description when their emoji sit at different offsets, so the capChars guard is reachable; cover it on parsed card text, where lone surrogates are not hidden by JSON escaping. Co-Authored-By: Claude Fable 5 <[email protected]>
Exact-value table over odd and even caps on both emoji parities, plus optionDescriptions with two opposite-parity descriptions under one cap. Co-Authored-By: Claude Fable 5 <[email protected]>
…ness handleAskRequest now always calls verifiedAskMention, so the production closure evaluated by ask-chat-scope-turn-target needs it (plus the peer-bot and human lookups it closes over) in scope. Co-Authored-By: Claude Fable 5 <[email protected]>
7 tasks
Both fakes JSON.parse'd every request body, so a host port-scanner probe (GET /probe, empty body) threw inside the async handler and vitest failed the run on the unhandled rejection even though every assertion passed. Filter with isAskPost and read via readRequestBodyJson like the other fakes in this file. Co-Authored-By: Claude Fable 5 <[email protected]>
# Conflicts: # src/core/ask-api.ts # src/daemon.ts # src/im/lark/ask-card.ts # src/im/lark/turn-reply-ask-elements.ts
deepcoldy
pushed a commit
to fangyeqing/botmux
that referenced
this pull request
Nov 8, 2026
合入 deepcoldy#3181(ask --mention)、deepcoldy#2864(替身仅凭 App ID 配置)、deepcoldy#3225(tmux 死窗格用例去偶发)。 无文本冲突。两侧都改过的 src/cli.ts、src/core/dashboard-ipc-server.ts、src/daemon.ts、 src/types.ts、test/dashboard-ipc.test.ts 改动落在不同代码块:master 侧是 ask 点名与替身 App ID,本分支侧是会话合约,彼此不读写对方的字段。 Co-Authored-By: Claude Fable 5 <[email protected]>
This was referenced Nov 8, 2026
|
🚀 Released in v3.59.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.
接管 #1972,保留 wzono 署名;合码时 squash-pr 加 --co-author "wzono [email protected]";评审在原 #1972 评审群继续
改了什么
功能与 #1972 相同:
AskUserQuestion与 OpenCodequestion的options[].description透传到所有 ask 卡型,包括按钮卡、Card 2.0 自定义输入表单、Card 2.0 输入表单(选择题加输入框)、文本作答批次、settle 后的卡,以及嵌在回复卡里的 ask。说明以小字(note或text_size: notation)列在按钮下方,每条写成「选项:说明」,条与条之间空一行。没有 description 时整块不渲染,旧卡片不变。botmux ask --mention <open_id>:在待答卡片的第一问前注入一次真实<at>,让对方收到通知。接管后在作者版本上的修改,对应 #1972 的评审清单:
点名
mentionedOpenId只接受显式 ask(originKind: 'explicit')。open_id 规则与同命令的--answerer一致(^ou_[A-Za-z0-9_-]{1,128}$)。isHumanOpenId)。查不到或查询出错时只丢掉 @,卡片照发,并打 warn 日志。replyCardAskTarget里。cardRootMessageId走同一个通道,不写进回执的调用身份。重连时即使通讯录结果变了,也不会被判成身份冲突。createAskInput,test/daemon-ipc-session-auth.test.ts恢复为 master 原文。原因见下方「与评审建议不同的取舍」。选项说明的预算与附件
渲染与解析
[mention],再转义 markdown 和<>。问题正文保留合法 at 的既有行为不变。bad_option_description。这由显式参数parseAskQuestions(arr, { clampDescription })控制,CLI 读文件的路径不变。--help补上--mention一行;ask 技能文档同步说明「只有本应用通讯录查得到的真人会被 @」。null的未知字段放行),unsupported_fields校验与 master 一致。mentionedOpenId: null返回bad_mentionedOpenId;CLI 只在传了--mention时才带这个字段。为什么
与评审建议不同的取舍
createAskInput的extra类型,并改为对构造结果断言。接管版直接去掉这个构造函数。一是点名已改走展示参数,不再需要它。二是作者的构造函数改变了字段顺序,而显式 ask 回执用整段 JSON 比较调用身份,所以升级重启前后,同一个正在等待的 ask 会被判成explicit ask invocation identity conflict。这一点用探针复现过:先按 master 键序写回执,再用作者键序重连,结果被拒。恢复 master 字面量后键序与 master 完全一致,原有的来源断言原样生效。sameIdentity纳入点名(评审 P3 第 5 条):不改。点名是展示,不是调用身份。同一 askKey 的调用方已由会话绑定确定,只换点名对象的重注册并入首卡没有危害。反过来,如果把点名纳入身份,重连时通讯录核验结果一变(例如 daemon 重启后接口抖动),一个仍在等待的 ask 就会被判失效。回执侧同样不含点名,两处口径一致。--questions-file调用直接 exit 2。而超预算形态在本 PR 里已经变成确定性失败,不会留下孤立附件(见上)。Follow-up(本 PR 不做)
submitCustomReply只做 trim 并检查非空),settle 卡把它完整渲染进结果摘要。一条长文字作答就能让 settle PATCH 超过 30KB 被飞书拒绝:onSettle只记一条 warn,卡片停在待答态;被拒的那张 settle 卡里还带着附件提示,而待答卡当时没截,附件从未发出。实测:两个短说明选项的小卡,comment 9,000 个汉字时 settle 卡 27,770 字节仍完整;9,990 个汉字时说明和正文截到最小仍有 30,845 字节。comment 更短但待答卡本身接近上限时,settle 卡会只截说明、能送达,但同样没有附件。需要让 comment 也进入卡内预算,与问题正文的既有行为一并处理。JSON.stringify会把它转义成\ud83d文本,这条断言抓不到回归。正文截断本身有守卫,现状没有缺陷;应改为解析后检查(本 PR 的说明用例已这样做)。影响面
core/ask-*:api、args、broker、questions、types、persist-store、hook 适配;core/explicit-ask-continuation.ts:展示参数的类型加上mentionedOpenId;core/turn-reply-ask.ts:带点名时不嵌回复卡;im/lark/下的ask-card.ts、ask-custom-form.ts、ask-form-elements.ts、turn-reply-ask-elements.ts,以及新文件ask-option-descriptions.ts;daemon.ts(点名核验)、cli.ts、i18n、ask 技能定义。botmux ask支持点名;--mention时,卡片与现在一致。mentionedOpenId,旧数据可以正常恢复,不涉及存储结构迁移。git diff --diff-filter=D --name-only origin/master HEAD输出为空。测试验证
前三批在修复提交上运行;之后又改了几处,涉及的文件在 d445763 上重跑一遍。f96492ba2 只新增一个测试文件,相关的 7 个文件再跑一遍(另用
bun test跑了新文件)。f96492b 上的回归(已在 9726bdb 修复):第 2 批跑完之后,为通过类型检查,
handleAskRequest改成无条件调用verifiedAskMention,但ask-chat-scope-turn-target没有重跑。这个测试在受控 scope 里执行 daemon 里真实的handleAskRequest,scope 缺少这个函数,5 条用例全部报verifiedAskMention is not a function,CI 的 test (4/4) 分片也因此失败。修法只改测试:scope 补上真实的verifiedAskMention,以及它闭包引用的isKnownPeerBot、isHumanOpenId两个替身,src 不动。仓库里只有这一个测试在 scope 里执行handleAskRequest(daemon-ipc-session-auth只检查源码文本)。test (4/4) 在 f96492b 上只有这 5 条失败,其余 623 个文件通过。9b87964(当前 head):合入 master 到
7b911759c(共三次 merge,都无冲突;本次并入的 master 已包含 #3199)。相对 master 没有删除文件,改动仍是同样 31 个 ask 相关文件。除下面这 6 行测试外,相对 master 的补丁与已评审的 9726bdb 一致;与上一个 head ec7c985 相对其 master 基线的补丁完全相同。只改测试的提交 c858e4e:作者新增的两个
--mentionCLI 用例里,假 daemon 对每个请求都JSON.parse请求体。任何不带 JSON 请求体的请求(同文件注释说明主机端口扫描会打到这类假 daemon,例如GET /probe)都会让异步 handler 抛Unexpected end of JSON input:断言全部通过,但 vitest 因未处理的 rejection 以退出码 1 结束。本地第 1 批并发跑时撞到一次,单跑 3 次都通过,人为注入一个GET /probe可稳定复现。现在和同文件其他用例一样,先用isAskPost过滤,再用readRequestBodyJson读请求体。注入探测后不再报错;把 CLI 改成不透传mentionedOpenId时,这两条用例都失败。bun 一侧:
test:bun:self-check通过。本 PR 改过的测试文件中,CI 选择器判为可在 bun 下跑的 10 个,按 CI 的方式每个文件单独进程运行,全部通过。ask-card用了vi.mock的importOriginal(master 上就有),选择器把它留给 vitest。新增和改写的用例:
ask-option-descriptions(新文件):capChars精确值表:奇数和偶数截断长度,emoji 分别从偶数位和奇数位开始,切点落在代理对中间时退一位。optionDescriptions共用截断长度 1 到 5:两条说明的 emoji 奇偶相反,每个长度都会切到其中一条的代理对,断言两条的精确输出。ask-card:oc_加 32 字符)、ask uuid(ask-加 40 hex)和中文 label,断言promptTruncated === false,请求体字节数不超过 30,000 且高于上限的 80%;附件含全部完整说明。turn-reply-ask:ask-api:verifiedAskMention:只保留真人,同伴 bot 不查通讯录,核验抛错只丢点名;explicit-ask-continuation:点名会传到注册,但不进回执;重连时不带点名也能接上。ask-resume-contract:只改选项说明会得到invalidated,并且不发第二张卡。ask-hook-opencode:断言夹具里的说明(「零停机 / 逐步切流」)透传。变异验证:每条变异单独应用,跑对应测试,记录结果,再还原。16 条全部变红:
capChars去掉代理对守卫本次没有在飞书里实测(不部署、不重启服务)。卡片样式以下方渲染器的实际输出代替截图。
卡片示意(渲染器实际输出,节选)
按钮卡,待答态,带点名:
{ "tag": "div", "text": { "tag": "lark_md", "content": "<at id=ou_member></at>\n**问题 1**\n选哪种发布方式?" } } { "tag": "action", "actions": [ { "tag": "button", "text": { "tag": "plain_text", "content": "灰度" } }, { "tag": "button", "text": { "tag": "plain_text", "content": "全量" } } ] } { "tag": "note", "elements": [ { "tag": "lark_md", "content": "**灰度**:先放 5% 流量\n观察 30 分钟\n\n**全量**:立即放开所有流量" } ] }Card 2.0 自定义输入表单:
{ "tag": "markdown", "content": "<at id=ou_member></at>\n**问题 1**\n选哪种发布方式?" } { "tag": "markdown", "text_size": "notation", "content": "**灰度**:先放 5% 流量\n观察 30 分钟\n\n**全量**:立即放开所有流量" }🤖 Generated with Claude Code