Repository navigation
Conversation
There was a problem hiding this comment.
Pull request overview
该 PR 针对 botmux 在 tmux 模式下的 CoCo 多行粘贴提交确认、以及多 bot 群聊线程内的路由/免 @mention 规则做了修复与一致性补齐,以提升 macOS 兼容性与多 bot 协作体验。
Changes:
- 按平台修正 CoCo
history.jsonl路径(macOS vs Linux),并同步更新相关测试。 - 统一
TmuxBackend与TmuxPipeBackend的pasteText()行为:tmux paste-buffer增加-p以配合 bracketed paste。 - 多 bot 群聊权限/路由 gating 改为基于“是否存在 peer session”而非群内 bot 数量,并新增对应测试覆盖。
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/adapters/cli/coco.ts |
CoCo 提交确认读取的 history 路径改为平台相关,并更新注释说明。 |
src/adapters/backend/tmux-backend.ts |
pasteText() 的 tmux paste-buffer 增加 -p 以插入 bracketed paste 标记。 |
src/adapters/backend/tmux-pipe-backend.ts |
同步 paste-buffer -p,保证 adopt/pipe backend 行为一致。 |
src/im/lark/event-dispatcher.ts |
引入 hasPeerSession 并调整群聊免 @mention 的 relax 判定逻辑。 |
src/daemon.ts |
在 daemon 侧实现 hasPeerSession,用于检测同会话单元是否有其他 bot 会话。 |
test/write-input.test.ts |
测试中使用与 adapter 一致的平台相关 CoCo history 路径。 |
test/tmux-pipe-backend.test.ts |
覆盖 paste-buffer 调用参数包含 -d 与 -p。 |
test/event-dispatcher.test.ts |
增加 sole owner 可免 @mention 与 peer session 必须 @mention 的覆盖。 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| hasPeerSession: (anchor, appId, scope, chatId) => { | ||
| const peers = scope === 'thread' | ||
| ? sessionStore.findActiveSessionsByRoot(anchor) | ||
| : sessionStore.findActiveChatScopeSessionsByChat(chatId); | ||
| return peers.some(s => s.larkAppId && s.larkAppId !== appId); |
There was a problem hiding this comment.
Fixed in b691be0. Added PeerSessionCache with a 1s TTL keyed by (scope, rootMessageId/chatId) and changed the daemon hasPeerSession handler to read through that cache instead of synchronously scanning session files on every owned group message. Added test/peer-session-cache.test.ts covering TTL reuse, refresh after expiry, and chat-scope lookup behavior; reran tsc, dispatcher, tmux-pipe, and write-input tests.
1. tmux-backend pasteText 添加 -p 标志强制 bracketed-paste 标记 2. coco.ts HISTORY_PATH 适配 macOS ~/Library/Caches 路径
b691be0 to
8b3cd7d
Compare
|
感谢 @ZBCccc 的排查与修复!🙏 这个 PR 的实际改动( 另外提醒:本 PR 的描述里提到的 peer-session 路由 / 本 PR 作为 superseded 关闭,改动已通过 #25 进入 master。再次感谢! |
背景
排查 CoCo / Trae CLI 在 botmux tmux 模式下的多行输入提交链路时,发现有几类问题需要一起修复:
history.jsonl路径是平台相关的:macOS 写入~/Library/Caches/coco/history.jsonl,Linux 写入~/.cache/coco/history.jsonl。此前 adapter 和测试都只按 Linux 路径处理,macOS 下会误读不到真实提交历史,影响提交确认、retry/failure 判断。paste-buffer传递多行内容。普通 botmux tmux 会话当前实际走TmuxPipeBackend,不是 legacyTmuxBackend;只改TmuxBackend会漏掉主路径。两套 backend 的 paste 行为需要保持一致。@mention,不应该再由群内 bot 总数决定。真正需要 disambiguate 的场景是同一个 thread/chat conversation unit 已经有 peer bot active session;如果当前 bot 是唯一 session owner,用户在该线程内继续无@mention回复应能路由回当前 bot。hasPeerSession在 group follow-up 热路径上同步扫描 session 文件。已补充 daemon 侧短 TTL 缓存,避免同一 conversation unit 的高频消息重复触发readFileSync + JSON.parse扫描。改动
src/adapters/cli/coco.ts~/Library/Caches/coco/history.jsonl,其他平台保持~/.cache/coco/history.jsonl。src/adapters/backend/tmux-backend.tspasteText()的tmux paste-buffer增加-p,在应用启用 bracketed paste 时插入 paste 边界控制码。src/adapters/backend/tmux-pipe-backend.tspasteText()的paste-buffer -p,覆盖当前普通 tmux 会话实际使用的 backend。src/im/lark/event-dispatcher.ts/src/daemon.tshasPeerSessionhandler。@mention;存在 peer session 时仍要求@mention。hasPeerSession通过PeerSessionCache做 1s TTL 缓存,按(scope, rootMessageId/chatId)缓存跨 bot session-store 查询结果。src/core/peer-session-cache.tstest/write-input.test.ts使用与 adapter 一致的平台相关 CoCo history path,保留 retry/failure 回归用例。test/tmux-pipe-backend.test.ts覆盖paste-buffer -d -p。test/event-dispatcher.test.ts覆盖 sole owner 免@mention与 peer owner 需要@mention两条路径。test/peer-session-cache.test.ts覆盖 TTL 内复用查询、TTL 过期刷新、chat-scope 按 chatId 查询且排除当前 app。排查结论
本次改动中 review 发现的关键问题已修复:
paste-buffer -p必须同步到TmuxPipeBackend,否则正常 botmux tmux 会话路径不会得到 bracketed paste 修复。hasPeerSession不能每次 group follow-up 都同步扫 session 文件;现已在 daemon 侧增加 1s TTL 缓存,降低热路径阻塞风险。TTL 很短,跨 daemon session 变化最多短暂延迟;同一 conversation unit 高频消息不会重复扫盘。验证
pnpm exec tsc --noEmit✅pnpm vitest run test/peer-session-cache.test.ts test/event-dispatcher.test.ts✅ 60 testspnpm vitest run test/tmux-pipe-backend.test.ts✅ 26 testspnpm vitest run test/write-input.test.ts✅ 68 testsgit diff --check✅备注:本机 Node 为
v20.20.2,pnpm会提示项目期望node >=22,但上述验证命令均已通过。