fix(Badge): 修复活动栏未提交变更数角标更新不及时(迁至隐藏 TreeView 承载) - #52
Merged
ThreeFish-AI merged 2 commits intoJul 4, 2026
Conversation
- 根因:角标挂在 Commit WebviewView 上,VS Code 在 resolveWebviewView(用户打开过面板)前无法显示 webview 角标(vscode#164974/#146330),故面板未打开时新变更不点亮、提交/撤销后不清除; - 承载迁移:改由隐藏 TreeView(hyperGit.changesBadge, when:false)承载,createTreeView 于 activate 即实例化,其 badge 无论面板是否打开都可靠聚合到容器图标; - 单一事实源:新增 engine 纯函数 change-count(toRelKey/countUniqueChanges)与 GitRepositoryService.getChangeCount(),getChanges 复用同一去重逻辑,避免双实现漂移; - 及时且高效:角标走独立 40ms 微防抖快路径,与 150ms 重刷新解耦、合并事件风暴;释放期清理悬挂定时器; - 熵减:移除 Commit webview 死代码(updateBadge/pendingBadge)杜绝容器求和 2× 计数;补充 change-count 单元测试锁定计数等值不变式。 🤖 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>
留存本次角标更新不及时问题的表因/根因/处理/防范,并交叉引用 #8 关于 badge 承载与 pendingBadge 时序的预警。 🤖 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
added a commit
that referenced
this pull request
Jul 4, 2026
…ELOG; (#58) - package.json version 0.0.9 → 0.0.10(方案 A:纯 major.minor.patch,由 --pre-release 标志发预发布,规避 VS Code Marketplace 不接受 -rc.N semver 后缀的限制); - 新增 docs/releases/v0.0.10-rc.1.md(文件名精确匹配 tag ref_name,作 GitHub Release 正文单一事实源),归纳 v0.0.9→HEAD 真实变更:Graph 视图对齐官方 (#53)、悬浮浮层 iframe 裁剪修复 (#53)、未提交角标承载迁移 (#52)、README 双语与真实性校准 (#51); - CHANGELOG 新增 [0.0.10-rc.1] 段(遵循 Keep a Changelog); - 本版作为 VS Code Marketplace 发布链路打通的验证版(首次以 vsce publish --pre-release 于 Marketplace/OpenVSX/GitHub Release 三渠道并发)。 🤖 Generated with [Claude Code](https://github.com/claude), [CodeX](https://openai.com), [Gemini](https://github.com/apps/gemini-code-assist)
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.
背景
活动栏 Hyper Git 图标的「未提交变更数」角标更新不及时:有时已有变更文件却不显示角标,有时文件已提交/撤销角标却不消失,误导用户对仓库状态的判断。
根因(循证)
角标此前承载于 Commit WebviewView 的
WebviewView.badge(#8 移除 Changes 视图后迁入)。命中 VS Code 已知限制:webview 角标在resolveWebviewView(即用户至少打开过一次面板)之前无法显示 —— microsoft/vscode#164974、#146330。源码印证:未 resolve 时updateBadge仅写入pendingBadge、永不上屏。因此只要面板未打开/隐藏(用户在编辑器或其他活动容器工作),新变更无法点亮、提交/撤销后无法清除 —— 与两个症状完全吻合。TreeView无此限制:createTreeView可在activate()强制实例化视图对象,其.badge无论视图是否可见都可靠聚合到容器图标(容器角标 = 容器内各视图 badge 之和)。改动
hyperGit.changesBadge(when:false,永不渲染)。toRelKey+countUniqueChanges,作为变更去重的单一事实源。getChangeCount()(仅计数、不构造ChangeItem),getChanges()复用toRelKey。createTreeView承载角标;角标走独立 40ms 微防抖快路径(面板未开也近实时、合并事件风暴),与 150ms 重刷新解耦;释放期清理定时器;首帧同步置初值。updateBadge/pendingBadge(杜绝容器求和 2× 计数),更新 JSDoc。getChangeCount() === getChanges().length去重不变式。验证
check-types(tsc) /lint(eslint) /esbuild编译 /test:unit(332/332 通过,含新增 8 例)。@vscode/test-electron)本地因下载 VS Code 网络超时未跑通(环境限制,非代码问题)。when:false承载实机不上屏,回退为visibility:collapsed空视图(仅改 package.json 一处)。影响面
活动栏角标承载由 WebviewView 迁至隐藏 TreeView;不改变计数语义(index+工作区+未跟踪去重);不新增可见视图、不影响现有 Commit/Log/Branches 等视图与命令。