fix(lark): 关闭/恢复会话卡片行为收口——关闭不弹 300000,恢复重出流式卡+文本 - #897
Open
47seek wants to merge 2 commits into
Open
Conversation
改了什么: - 关闭会话按钮:点击后不再干等 worker 进程退出(closeSession 新增 awaitWorkerExit 参数,默认 true 不影响其它调用方;卡片按钮传 false)。 忙碌 CLI 只在 ~7s 的 SIGKILL 兜底才退出,会冲破飞书卡片回调 ~3s 的 ACK 窗口,触发客户端「code: 300000」toast。改为同步完成逻辑关闭即返回、worker 后台被杀;bridge send marker 清理挂到同一 fence 后台执行,不丢账。 - 关闭时被点的那张流式卡改为「原地 patch 成已关闭卡」(把关闭卡作为回调响应 返回),不再新发一张卡、也不删除刚点击的卡——删刚点的卡会和回调响应竞态, 同样触发 300000。私有卡模式仍走 ephemeral 发送。 - 恢复会话按钮:先秒回空 ACK,再在后台「重发一张全新流式卡 + 撤回旧的已关闭卡 + 补发『会话已恢复』文本」。流式卡在前、文本在后,两者都保留(恢复才需要 流式卡)。新增 buildStreamingCardJson 复用正常流程的完整流式卡渲染。 为什么:关闭时旧流式卡的按钮已失效,原地变成已关闭卡最干净;而流式卡本身是 「恢复后继续对话」才需要的东西,所以归到 resume 路径重建。 影响面(公共层 core/worker-pool + im/lark/card-handler): - closeSession 新增可选参数,默认行为不变,其它 15+ 调用方不受影响。 - 仅飞书卡片按钮路径改变交互;dashboard/命令行 close 走默认 awaitWorkerExit=true。 - 私有卡模式、adopt/transfer 会话均已分支保留原行为。 测试: - pnpm build 通过(tsc 编译干净)。 - 新增 test/close-stream-card-untouched.test.ts:断言 closeSession 不删流式卡。 - close/resume/frozen-card/card-handler 相关 test 全绿 (recall-frozen-cards / session-resume / ipc-close-route / closed-session-card / card-handler-c2 / card-handler-config / card-handler-relay-pickup)。
Owner
|
自动评审初步发现一个需要修正的点,最终以维护者审阅为准:
{"card":{"type":"raw","data":{}}}并由当前 建议将: return {}; // fast empty ACK改为: return; // dispatcher shapes this into the SDK-serializable empty ACK {}这个问题本身不依赖后台 |
恢复分支原写 `return {}` 作为快速空 ACK,但 `{}` 是 truthy,经
event-dispatcher 的 shapeCardActionResult 会被包成
`{card:{type:raw,data:{}}}`——即用空 body 卡原地 patch 刚点击的那张卡,
而非"不改 UI 的空 ACK"。空 card.data 不合协议,且与后台并行的
deleteMessage 竞争同一张卡。
改为裸 `return`(→ undefined),让 shaper 走到 falsy 分支产出合法的顶层
空 ACK `{}`,与本 handler 其它空 ACK 写法一致。同步修正上方注释里
误导性的 `(return {})` 引用。
补 event-dispatcher 测试:钉死 handler 返回 `{}` 会被 shaper 退化成
空 body 卡 patch 这一陷阱,防止有人再写回 `return {}`。
验证:pnpm build 绿;event-dispatcher / close-stream-card-untouched /
session-resume 三个 suite 共 333 tests 全绿(含新增用例)。
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.
改了什么
关闭会话按钮
closeSession新增可选awaitWorkerExit(默认 true,其它调用方行为不变)。卡片按钮传false:不再干等 worker 进程退出。忙碌 CLI 只在 ~7s 的 SIGKILL 兜底才退出,会冲破飞书卡片回调 ~3s 的 ACK 窗口,触发客户端 「出错了,请稍后重试 code: 300000」 toast。改为同步完成逻辑关闭即返回、worker 后台被杀;bridge send marker 清理挂到同一 fence 后台执行,不丢账。恢复会话按钮
buildStreamingCardJson复用正常流程的完整流式卡渲染(🖥️ 头 + 用量 + 显示输出/终端/操作链接/关闭 按钮),避免恢复后长出一张残缺卡。为什么
关闭时旧流式卡的按钮已失效,原地变成已关闭卡最干净;而流式卡本身是「恢复后继续对话」才需要的东西,所以归到 resume 路径重建。原来点关闭偶发弹 300000、点恢复只发一条文本不出卡,本次一并收口。
影响面(公共层
core/worker-pool+im/lark/card-handler)closeSession新增可选参数,默认行为不变,其它 15+ 调用方(dashboard / 命令行/close/ session-manager 等)均走默认awaitWorkerExit=true,不受影响。测试
pnpm build通过(tsc 编译干净)。test/close-stream-card-untouched.test.ts:断言closeSession不删流式卡。recall-frozen-cards/session-resume/ipc-close-route/closed-session-card/card-handler-c2/card-handler-config/card-handler-relay-pickup。