feat(Branches): 分支视图支持按 / 前缀分组为可折叠文件夹树(平铺⇄树切换);#86
Merged
ThreeFish-AI merged 1 commit intoJul 6, 2026
Conversation
Local/Remote/Tags 三段支持在平铺与「按 / 前缀分组的文件夹树」间切换:共享前缀的分支 收拢到以前缀命名的可折叠文件夹下、叶子仅显示末段后缀(如 bak/2025、bak/master-2025-07 → 📁bak → 2025 / master-2025-07;远程整体收拢为 origin 文件夹并内嵌 feature)。 - 新增纯逻辑引擎 buildRefTree(engine/ref/ref-tree.ts,零 vscode 依赖):复用变更文件目录树 buildFileTree 的 trie 构建 + compact 折叠范式;叶子携完整 RawRef(命令定位不受影响); 分支感知排序(当前 HEAD → 收藏 → 同档文件夹优先、名称数字感知升序)。含 12 条单测。 - 隐藏 origin/HEAD 符号引用:对齐主流 Git UI,消除 origin 叶子与 origin 文件夹同名冲突, 远程计数归为真实分支数。 - 工具栏「平铺 ⇄ 树」切换(branchesGroupByPrefix / branchesFlatten,context key 驱动按钮 互斥),偏好按仓库持久化于 workspaceState(默认树形),文件夹默认展开、展开态跨刷新稳定。 - 文件夹节点用独立 contextValue(hyperGit.branchFolder)且不登记右键命令,多选经 selectedBranchRefs 只保留 branch 节点,checkout/delete/rename/merge/rebase/compare/ favorite 与多选批量均零改动、零破坏。 - 文档:CHANGELOG、docs/features/branch-tree-group-by-prefix、knowledge-map、README(EN/zh)。 🤖 Generated with [Claude Code](https://github.com/claude), [CodeX](https://openai.com), [Gemini](https://github.com/apps/gemini-code-assist) Co-Authored-By: Aurelius Huang<threefish.ai@gmail.com>
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.
改动内容
为 Branches 视图的 Local / Remote / Tags 三段新增「按
/前缀分组为可折叠文件夹树」形态,支持与「平铺列表」一键互切(工具栏按钮、按仓库记忆偏好、默认树形)。共享前缀的分支收拢到以前缀命名的文件夹下,叶子仅显示末段后缀(如bak/2025、bak/master-2025-07→ 📁bak→2025/master-2025-07;远程整体收拢为origin文件夹并内嵌feature)。Favorites 段恒平铺并显示完整短名。动机
对齐 VS Code SCM / GitLens 的分支分组范式,降低大量带前缀分支(
feature/*、bak/*、release/*)场景下的视觉噪音与检索成本;同时消除远程符号引用origin/HEAD与分组后origin文件夹的同名冲突。实现要点
buildRefTree:零 vscode 依赖,复用「变更文件目录树」buildFileTree的 trie 构建 + compact 折叠范式;叶子携带完整RawRef(命令定位不受影响),分支感知排序(当前 HEAD → 收藏 → 同档文件夹优先 → 名称数字感知升序 → 稳定),compact折叠单目录子链(遇含叶子或多子目录即停,对齐explorer.compactFolders)。含/的远程名(forkmyorg/repo)经 compact 视觉合并为单文件夹,无需特判。branches-tree.ts:新增BranchFolderNode、按仓库持久化的grouping状态、isRemoteHead过滤(隐藏origin/HEAD)、sectionNodes/toBranchNodes桥接;文件夹TreeItem默认展开、id按folder:<group>:<path>隔离令展开态跨刷新稳定。contextValuehyperGit.branchFolder且不登记任何右键命令;单节点命令与多选批量(经selectedBranchRefs)均以kind === 'branch'守卫,文件夹被安全忽略 —— checkout / delete / rename / merge / rebase / compare / favorite 全部零改动。hyperGit.branchesGroupByPrefix/hyperGit.branchesFlatten)+setContext('hyperGit.branchesGrouping')驱动工具栏按钮互斥显隐;偏好持久化于workspaceState(键hyperGit.branchesGrouping:${repoRoot})。tests/unit/ref-tree.test.ts共 12 用例,覆盖空输入、单/多前缀收拢、排序档位、compact 折叠边界、远程收拢、去重、空段跳过、count 递归统计。验证
pnpm typecheckclean;pnpm run test全绿(unit 12/12 + Extension Development Host 集成冒烟)。完整叙述见 分支前缀分组树。🤖 Generated with Claude Code, CodeX, Gemini
Co-Authored-By: Aurelius Huangthreefish.ai@gmail.com