fix(Graph): GRAPH 视图提交记录按作者日期倒序(--topo-order → --author-date-order) - #82
Merged
ThreeFish-AI merged 1 commit intoJul 5, 2026
Merged
Conversation
…成块致日期列回跳;
- 现象:GRAPH 视图(All 范围)提交记录前段日期正常递减,中段日期回跳到最新(旁支提交被整块挤到末尾),严重不符合「按时间倒序」预期;
- 根因:buildLogArgs 取数首参 --topo-order,其「分支成块」语义把不同分支线提交不相邻混排,致从较旧提交分叉但日期较新的旁支提交整块下放;管道各层(engine 解析 / adapter 装配 / webview 渲染)均无二次排序,git 输出序即最终显示序;
- 修复:log-query.ts:39 单行 --topo-order → --author-date-order。选 author-date(非 committer date)以与视图日期列 row.authorDate 对齐(单一事实源);lane 算法仅依赖「子在父之上」不变量,--author-date-order 同样保证,泳道不断裂;
- 测试:log-query.test.ts 断言改 --author-date-order + 补「不含 --topo-order」回归护栏;顺带把 startsWith('--author') 改为 startsWith('--author='),消除与 --author-date-order 的前缀碰撞隐患;
- 注释:同步 log-query/graph-types/graph-layout/log-line/log-webview 共 8 处 topo-order 措辞,澄清「不变量真实要求 = 子在父之上」(非「分支成块」);
- 沉淀:CHANGELOG [Unreleased]/Fixed 记录;docs/.agents/issue.md 追加 #14(表因 / 根因 / 处理 / 防范 / 同类影响);
- 验证:pnpm run test:unit(349 全过)/ check-types / lint 全绿;git log 实测 --author-date-order 序列严格单调递减;
🤖 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.
背景
用户截图反馈:GRAPH 视图(All 范围)的提交记录未按时间倒序排列——前段日期正常递减,中段日期回跳到最新日期。
理应排在最顶部的新提交却落在列表底部,严重不符合「按时间倒序浏览」的预期。
根因
GRAPH 视图唯一的排序机制是
git log的--topo-order参数(src/engine/log/log-query.ts:39),管道各层(engine 解析 / adapter 装配 / webview 渲染)均无任何二次排序——git 输出序即最终显示序。--topo-order语义:保证「子在父之上」(拓扑序),但额外约束「不同分支线历史不相邻混排」——它会把一条分支的提交整块输出后再切到另一条。当仓库存在从较旧提交分叉、但提交日期较新的旁支(如origin/ThreeFish-AI/fix-github-security等远端跟踪分支),这些旁支提交会被整块挤到列表末尾,造成日期列回跳。本仓实测复现(
git log,前 18 条作者日期):修复
核心改动(1 行):
src/engine/log/log-query.ts:39——'--topo-order'→'--author-date-order'。为什么是
--author-date-order--topo-order(修复前)--date-order--author-date-order(采纳)row.authorDate)row.authorDate(log-webview.ts:771:fmtDate(row.authorDate)),排序键须与显示键对齐。graph-layout.ts:32-145,lane 增量算法仅依赖「处理 commit 时其全部在窗口内的子已处理」这一不变量,不依赖 topo-order 的「分支成块」特性。git log --author-date-order契约原文 "Show no parents before all of their children are shown" 同样保证「子在父之上」,故 lane 不会断裂、泳道不变形。改动清单
src/engine/log/log-query.ts:39—— 排序 flag 改为--author-date-order(唯一逻辑改动)tests/unit/log-query.test.ts—— 断言改为--author-date-order,补「不含--topo-order」回归护栏;顺带加固既有--author前缀断言(startsWith('--author')→startsWith('--author=')),消除与本 flag 的前缀碰撞log-query.ts/graph-types.ts/graph-layout.ts/log-line.ts/log-webview.ts,澄清「lane 不变量真实要求 = 子在父之上」(非「分支成块」)CHANGELOG.md[Unreleased]/Fixed 记录;docs/.agents/issue.md追加 chore(Release): v0.0.1-rc.2 发布 #14(表因 / 根因 / 处理 / 后续防范 / 同类问题影响)验证
pnpm run test:unit:349 全过(34 个测试文件)pnpm run check-types(tsc --noEmit):cleanpnpm run lint(eslint):cleangit log --author-date-order --branches --tags --remotes --format='%aI %s':作者日期严格单调递减F5启动 Extension Host,打开多分支仓库,确认 GRAPH 视图日期列无回跳、多分支泳道(lane)渲染正确无断裂、scope 切换 / 增量加载 / author-grep-path 过滤均正常关联
log-query.ts取数参数层——GRAPH 视图多项语义的单一事实源)🤖 Generated with Claude Code, CodeX, Gemini
Co-Authored-By: Aurelius Huangthreefish.ai@gmail.com