fix(herdr): 修复多会话接管与后端复用#489
Open
Phoobobo wants to merge 1 commit into
Open
Conversation
Phoobobo
force-pushed
the
fix/herdr-adopt-session-discovery
branch
6 times, most recently
from
July 18, 2026 18:58
268f022 to
91d859b
Compare
Phoobobo
force-pushed
the
fix/herdr-adopt-session-discovery
branch
from
July 18, 2026 20:58
91d859b to
faa1c6c
Compare
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.
改了什么
/adopt遍历所有运行中的 Herdr session,并继续按当前 bot 的cliId过滤,避免 Pi bot 混入 Codex/TRAE 候选。agent list尚未识别的 pane,补充使用pane list + pane process-info识别前台 CLI;覆盖 TraeX hook 尚未上报、状态仍为unknown的场景。/adopt二次校验同步支持 process-info,校验 pane、CLI 与 PID,避免候选出现后点击仍报已退出。HERDR_SESSION,其次复用 default/其他运行中 session;仅在没有可复用 session 时创建bmx-*,并向飞书提示新 session 名。botmux-<id>agent 名;关闭会话时只关闭对应 pane,不停止用户整个 Herdr session。TRAE · herdr · collie:w1:p1 · 1h36m,不再展示容易误解的 cwd basename。为什么
原实现有三个问题:
/adopt只依赖agent list;TraeX 在 lifecycle hook 尚未上报时会处于unknown,因此完全不进入候选。bmx-*session,即使用户已有正在运行的 Herdr workspace。botmux),用户无法直接确认后端类型。影响面
cliId过滤;TraeX 增加 process-info fallback,Codex/Claude/CoCo 可复用同一 PID 元数据路径;其他 CLI 原有 agent-list 路径不变。/adopt、新建、resume、daemon 重启 reattach。读隔离/写沙箱会话继续使用 bot-owned Herdr session,避免隔离恢复逻辑误停用户共享 session。实际验证
pnpm build:通过。pnpm vitest run test/herdr-backend.test.ts test/herdr-discovery.test.ts test/herdr-session-discovery.test.ts test/tmux-reattach-backend.test.ts test/command-handler.test.ts test/card-builder.test.ts:6 files / 368 tests 全通过。pnpm test:8356 passed / 6 skipped;3 个与本改动无关的既有失败:dashboard-ipc.test.ts:中英文错误文案断言不一致。dashboard-monitoring-ui.test.ts:既有 CSS pointer-events 断言失败。sandbox.test.ts:macOS symlink 目录清理失败。collie:w1:p1的traex --resume前台进程成功发现 TraeX 候选。TRAE · herdr · collie:w1:p1 · 1h36m。/adopt手动验证通过候选发现链路。