Skip to content

feat(Log): Log 视图升级为 IDEA 风格提交图(Graph DAG)#34

Merged
ThreeFish-AI merged 3 commits into
feature/1.x.xfrom
ThreeFish-AI/log-graph-view
Jun 29, 2026
Merged

feat(Log): Log 视图升级为 IDEA 风格提交图(Graph DAG)#34
ThreeFish-AI merged 3 commits into
feature/1.x.xfrom
ThreeFish-AI/log-graph-view

Conversation

@ThreeFish-AI

Copy link
Copy Markdown
Owner

背景

Hyper Git 当前的 Log 视图hyperGit.log)是原生 TreeView,仅以折叠行展示 author · date · hash · [merge]完全没有 Graph;另一独立面板 showGraph 只是把 git log --graph粗糙 ASCII 逐字符还原成 SVG(lane 由 git 分配、随列号抖动着色),与 IntelliJ IDEA 的「干净彩色泳道」相去甚远。

本 PR 将 Log 视图原地升级为 Webview,基于 commit 父子关系自计算 DAG lane 布局,完整复刻 IDEA Git Log 的提交图效果。

核心改动

1. 自计算 lane 布局引擎(src/engine/log/,纯逻辑、零 vscode 依赖)

  • graph-layout.ts:单遍增量 lane 状态机,维护活跃 lane 表(槽值 = 待下行抵达的父 hash 或 nil 空洞);nil-slot 复用保证分支「直顺」(移除=置 nil、插入=复用 nil 或追加,均不引起其他 lane 位移);统一处理 octopus 合并 / 多 root / 收敛 / 截断 dangling 边
  • graph-color.ts:沿首父链继承色(IDEA 语义)+ 相邻 lane pickDistinctColor 异色。
  • log-line.tsgit log NUL/RS 全字段解析(%H %P %an %ae %aI %s)。
  • log-query.ts--topo-order 保拓扑序(lane 算法的硬性前提)+ author/grep/path 服务端翻译(pathspec 置尾)。
  • log-filter.ts:下沉 LogFilter 单一事实源 + toClientFilter(mergeMode/date/regex 客户端复用 applyClientFilters)。

2. Log 视图迁移为 Webview(src/adapter/webview/log-webview.ts

  • 单次 git log --topo-order --all 取数 + for-each-ref 取 HEAD/分支/标签 chips(full hash 精确匹配)。
  • Webview 端虚拟化「每行内联 SVG(本行入边/出边/贯穿边+节点)+ 文本列」,仅渲染可见窗口;主题调色板(--vscode-charts-* 令牌 + hex 回退)、All/Current 范围切换、滚动增量加载、↑↓ 键导航、选中提交内联展示变更文件(点击打开 diff)、右键 per-commit 操作菜单(复用既有 9 个命令)。

3. 零行为改动的迁移

  • 新增 LogFilterControl 接口,4 个命令注册器(history/git-cli/remote/misc)按接口而非具体类引用,7 个过滤命令与 9 个 per-commit 操作全部保留(右键 → host executeCommand 重调用,经审计 9 个 handler 仅需 hash)。
  • src/shared/protocol.ts 新增独立的 Log Graph 消息契约(不复用 Commit union)。
  • 移除独立 showGraph 面板、graph-webview.tsgraph-parser.ts(单一事实源去重,净减 435 行)。

验证

  • pnpm run compile(tsc --noEmit + eslint + esbuild)全绿,产物 dist/extension.js 212KB。
  • pnpm test:unit218/218 通过(含新增 engine 单测 29 例:单链/钻石分支合并/octopus/多 root/截断 dangling/收敛/相邻异色/确定性/边界)。
  • package.json 一致性校验:showGraph 已完全移除、无悬挂菜单引用、hyperGit.logwebview 类型。
  • 待 F5 Extension Development Host 实机回归(多分支仓库图渲染、过滤、右键 9 项操作、选中变更文件、All/Current 切换、实时刷新、深浅/高对比主题)——本环境无 GUI,请在合并前由 reviewer 在本地 F5 验证。

已知限制 / 后续

  • messageRegex 过滤近似作用于 subject(%s),多行 body 正则匹配为 v2 增强。
  • lane 着色按几何确定性分配(未接入「主分支靠左」的 head 重要性排序),与 IDEA 像素级仍有细微差异,可在 v2 接入 refs 重要性排序。
  • 主题 lane 调色板用固定 hex(深浅均可辨);VS Code --vscode-charts-* 令牌不足 8 色,故未用于保证 lane 间区分度。

🤖 Generated with Claude Code, CodeX, Gemini
Co-Authored-By: Aurelius Huangthreefish.ai@gmail.com

- graph-types/color/layout:单遍增量 lane 状态机(nil-slot 复用保证分支直顺、沿首父链继承色 + 相邻 lane 异色),覆盖 octopus 合并 / 多 root / 收敛 / 截断 dangling 边;
- log-line:git log NUL/RS 全字段解析(%H %P %an %ae %aI %s);
- log-query:--topo-order 保拓扑序 + author/grep/path 服务端翻译(pathspec 置尾);
- log-filter:下沉 LogFilter 单一事实源 + toClientFilter 抽取客户端维度;
- 单测 29 例覆盖各拓扑场景、解析与查询构造。

🤖 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>
- hyperGit.log 由原生 TreeView 迁移为 Webview:基于父子关系自计算 DAG lane 布局,渲染彩色泳道 / 节点 / 分叉·合并连线 / HEAD·分支·标签标签,完整复刻 IDEA Git Log,弃用 git log --graph 粗糙 ASCII;
- 单次 git log --topo-order --all 取数 + for-each-ref 取引用标签;Webview 端虚拟化「每行 SVG + 文本列」、主题调色板(--vscode- 令牌 + hex 回退)、All/Current 切换、滚动增量加载、↑↓ 键导航、选中提交内联变更文件、右键 per-commit 操作菜单(复用既有 9 个命令);
- 新增 LogFilterControl 接口使 4 个命令注册器零行为改动迁移;新增 protocol Log 消息契约;
- 移除独立 showGraph 面板、graph-webview、graph-parser(单一事实源去重)。

🤖 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>
showGraph 独立面板在前序提交中按「单一事实源去重」移除(Log 视图本身已具备完整 Graph),集成冒烟测试仍断言该命令注册导致 CI 失败;同步移除断言,并已校验列表中其余 61 个命令全部注册。

🤖 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>
@ThreeFish-AI ThreeFish-AI merged commit e4b9331 into feature/1.x.x Jun 29, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant