fix(core): /adopt 发现兼容含空格的 tmux 会话名#516
Merged
deepcoldy merged 1 commit intoJul 18, 2026
Merged
Conversation
discoverAdoptableSessions 解析 tmux list-panes 输出时按第一个空格切分, 会话名本身含空格(如「AD 智投星核心指标」)时 pid 被解析成 NaN, pane 被静默跳过,/adopt 永远扫不到该会话。改为按最后一个空格切分 (pane_pid 恒为行尾 token),并补含空格会话名的回归用例。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
deepcoldy
approved these changes
Jul 18, 2026
deepcoldy
left a comment
Owner
There was a problem hiding this comment.
二次复核通过:tmux format 的 pane_pid 是行尾 token,按最后一个空格切分能完整保留含空格会话名;回归用例能稳定捕获旧实现,zellij/herdr 与跨 CLI/平台路径无额外影响。已复跑 session-discovery 44/44 与 pnpm build。
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.
改了什么 & 为什么
discoverAdoptableSessions解析tmux list-panes -a -F '#{session_name}:#{window_index}.#{pane_index} #{pane_pid}'输出时按第一个空格切分(line.indexOf(' '))。tmux 会话名本身可以含空格(真实场景:用户手动命名的「测试 A」),此时第一个空格落在会话名内部,pid 段被解析成 NaN,该 pane 被静默continue跳过——/adopt无参卡片和直连目标都永远扫不到这个会话,且无任何报错提示。修复:改为按最后一个空格切分(
lastIndexOf)。format 串中pane_pid恒为行尾 token 且不含空格,因此对任意会话名都成立。影响面评估
src/core/session-discovery.ts中 tmux pane 行解析一处;bmx-*过滤基于切分后的 tmuxTarget,无空格会话名的行为与原先逐字节一致zellij-adopt-discovery/discoverHerdrAdoptableSessions),不受影响getPaneDimensions/validateTmuxAdoptTarget均已用 shellescape 包 target,含空格 target 传递无问题(已在真实 tmux 验证)实际测试验证
npx vitest run test/session-discovery.test.ts→ 44 passed(44)pnpm build→ 通过(tsc + dashboard bundle + build-audit)pnpm test全量 unit 与本地 origin/master 基线对照:失败测试文件集逐文件一致(均为本机环境性失败,如 node comm 显示 MainThread),差集为空,本 PR 零回归;通过数 7620→7621(+1 为新增用例)测试 A:0.0且 sessionId/cwd 正确🤖 Generated with Claude Code