Repository navigation
fix(scanner): worktree 归属错乱 + 显示名重复 + tag/SHA 回退 - #11
Merged
deepcoldy merged 1 commit intoMay 15, 2026
Merged
Conversation
issue deepcoldy#7 主修: - isValidGitMarker 不区分主/linked worktree,字典序先撞到 linked 的目录就会 被错误注册成 type:'repo',连带把整组兄弟 worktree 挂在它的 basename 下 - 改用 `git rev-parse --git-common-dir` 做 repo 身份去重 key, `git worktree list --porcelain` 第一条永远当主 worktree (git 约定) - ProjectInfo.name 改为只放 repo basename, branch 单独走 branch 字段, card-builder 已经在拼 `(branch)`,继续 bake 会显示两遍 detached HEAD 支持 (zsh 提示符风格): - porcelain 解析新增 `HEAD <sha>` 行 - ref 解析顺序: branch (refs/heads/...) → tag (describe --tags --exact-match) → 短 SHA (前 7 位) → 'unknown' - 同名 worktree 排序加 branch 作为 tiebreaker,顺序稳定 副带收益: - `git worktree list` 由"每 worktree 一次"变成"每 repo 一次" - describe-tag 只对真正 detached 的 worktree 调用一次,attached 的零额外开销 测试: 173/173 通过 (含 4 个新用例:主修 2 + tag/SHA 回退 2)。 Closes deepcoldy#7 Co-Authored-By: Claude Opus 4.7 <[email protected]>
deepcoldy
added a commit
that referenced
this pull request
May 15, 2026
承接 @YisenFE 在 #11 里修好的三个 bug(worktree 归属 / 显示重复 / detached HEAD),做一轮内部清理: - 抽 runGit() 辅助函数,6 处 execSync 样板合并成一处,timeout/stdio 策略集中 - 抽 compareProjects() 排序比较器,scanProjects 和 scanMultipleProjects 去重 - scanRepoFromAnyWorktree 末尾用 entries.map 替代特判 push - 删掉重述代码做了什么的 JSDoc 和测试注释,保留非显然的 why - runGit 的 trim 会吃掉 porcelain 输出末尾的空行,补一个哨兵空行让最后一条 worktree 也能被 flush 无行为变化,37/37 scanner 用例 + 下游 card-builder / command-handler 测试全过。
sensuossss
added a commit
that referenced
this pull request
Jun 24, 2026
- #10 daemon-run cold-attach: "一 gate 已自愈 + 另一 gate 仍 pending" 时,resume 重驱 会自己重发 pending gate 卡,cold-attach 再发一张就重复 → resume 为真时跳过 rec.repost (repostBlocked/loopGrant/revisitGrant 恒 resume:false,不受影响)。 - #11 journal: readJournal 原先 mid-file 解析失败也静默跳过 → 丢中间事件会让 replay 状态失准(丢 nodeSucceeded 节点永远 pending)。改成只容忍"最后一行"半写截断,中间行 解析失败抛错 fail-loud。 - #13 revisit-grant handler: 补 blocked/loop 都有的幂等恢复——not-budget-blocked (已准许、节点不再受阻)时也 driveRun,救回"上次 grant 的 driveRun 没落地"。 - #14 gate handler: already-settled 且 approved 时也 driveRun(幂等恢复),拒绝是终态不重驱。 - #18 architect test: 加注释说明这些是 prompt 教学文案断言、非强制行为;真正强制在 dag/runtime 套件(含本次新增的 v3-runtime 降权看门测试)。 校验:pnpm build 通过;全量单测(排除 e2e) 6734 passed。
sensuossss
added a commit
that referenced
this pull request
Jun 24, 2026
codex 复核留的非阻塞备注:#11 让 readJournal 对 mid-file corrupt fail-loud(运行时正确), 但只读 dashboard 路径(listRuns 遍历所有 run / projectRunById / ptyLogPathFor)没隔离坏 run ——一个坏 journal 会抛错把整张列表/详情页拖挂。这其实回退了 projectRun 自带的"defensive, sparse view rather than throwing"契约 + dashboard.ts 注释的"corrupt run → 404"。 修复(运行时仍 fail-loud,只读路径降级): - projectRun: readJournal 包 try/catch,坏 journal 降级成空/稀疏视图,列表/详情不崩 - ptyLogPathFor: 同样兜底 → 坏 journal 当 no_pty_log(404) - 补 test: 注入 mid-file 坏行,断言 projectRun/projectRunById/listRuns 不抛 + 健康 run 仍在列表 校验:pnpm build 通过;v3 ops/api/runtime/daemon 相关单测全绿(含新增 1 条)。
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.
TL;DR
flow-web-monorepo+ 6 个 linked)doc-history-comment-popover (fix/doc-history-comment-popover)doc-history-comment-popover/flow-web-monorepo (release/samantha) [worktree]doc-history-comment-popover/docx-selection (feat/docx-share-0512) [worktree]…
flow-web-monorepo (release/samantha)flow-web-monorepo (fix/doc-history-comment-popover) [worktree]flow-web-monorepo (feat/docx-share-0512) [worktree]…
15. flow-web-monorepo (flow-agent) (flow-agent) [worktree]15. flow-web-monorepo (flow-agent) [worktree](unknown) [worktree](v1.2.3) [worktree](unknown) [worktree](c0ffee1) [worktree]问题
src/services/project-scanner.ts有三个独立但相关的问题:1. worktree 归属错乱(主修 / Closes #7)
readdirSync按字典序遍历,先撞到的.git标记被注册为主仓库,然后跑git worktree list --porcelain把所有兄弟 worktree 挂在它名下。主 worktree 反被当作 linked worktree。isValidGitMarker对".git是文件(linked 的 gitlink)"和".git是目录(真主 worktree)"一视同仁,readdir 先撞到谁谁就当 repo,显示前缀完全不稳定。2. 显示名重复
第一次修复时把 branch 直接 bake 进
ProjectInfo.name(flow-web-monorepo (flow-agent)),但card-builder.ts:343又拼了(${p.branch}),导致显示成flow-web-monorepo (flow-agent) (flow-agent) [worktree]。3. detached HEAD 显示
unknownporcelain 输出 detached 状态时只有
HEAD <sha>+detached两行,旧代码只识别branch refs/heads/...,detached 一律显示unknown—— 没有信息量。修复
用
git rev-parse --git-common-dir做 repo 身份去重同一仓库的所有 worktree(主 + linked)共享同一个
common-dir。扫描过程中遇到任何.git标记,先解析 common-dir → 在seenRepos里查重,已处理过的兄弟 worktree 直接 skip。这一下把 readdir 顺序的影响彻底切断。git worktree list --porcelain的第一条永远是主 worktreegit 约定。直接拿它的 basename 当 repo 名,主 worktree 注册成
type:'repo',其余type:'worktree'。ProjectInfo.name只放 repo basenamebranch 单独走
branch字段,渲染层(card-builder / command-handler / card-handler)已经在拼(branch),职责分清。detached HEAD 按 zsh 提示符顺序回退
git describe --tags --exact-match只对真正 detached 的 worktree 调一次,attached 零额外开销。Test plan
should attribute the repo to the main worktree even when a linked worktree is discovered first by readdirshould NOT leak the linked-worktree directory basename into the display nameshould report the tag name when a worktree has detached HEAD pointing at a tagshould fall back to the short SHA when a worktree has detached HEAD not pointing at any tagcard-builder/command-handler)173/173 通过tsc --noEmit通过/Users/bytedance/byte,7 个 worktree)手工回测,飞书卡片显示符合预期Closes #7
🤖 Generated with Claude Code