fix: keep Windows notification badge state in sync#12451
Open
huhuanming wants to merge 3 commits into
Open
Conversation
huhuanming
marked this pull request as ready for review
July 11, 2026 08:13
huhuanming
requested review from
ezailWang,
originalix,
revan-zhang and
sidmorizon
as code owners
July 11, 2026 08:13
huhuanming
marked this pull request as draft
July 11, 2026 08:26
huhuanming
marked this pull request as ready for review
July 16, 2026 07:01
huhuanming
enabled auto-merge (squash)
July 16, 2026 07:01
originalix
reviewed
Jul 16, 2026
| : 0; | ||
| this.updateVersion += 1; | ||
| const updateVersion = this.updateVersion; | ||
| this.currentCount = count; |
Collaborator
There was a problem hiding this comment.
当窗口已有旧 badge,而新的非零更新在 executeJavaScript、data URL 校验或 nativeImage 校验任一阶段失败时,这里已经把 currentCount 更新为新值,但 currentOverlayIcon 和任务栏仍保留旧图片。之后触发 show 会再次挂载旧数字,并使用新计数 description,导致可见 badge 与内部状态长期不一致。
请把 count 与 overlay icon 作为一次原子提交:仅在最新版本成功生成图片后同时写入;若最新版本渲染失败,则明确清空 overlay 状态,不能继续保留旧图标。
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.
Summary
electron-taskbar-badgewith a OneKey-owned Windows taskbar badge helper.Intent & Context
This is a follow-up to #12447. The CommonJS loader fixed the original
BadgeGenerator2 is not a constructorcrash, but clearing the Windows notification badge could still restore the previous count.The stale badge was reproduced after hiding/showing the window, changing the Windows accent color, and resolving an older asynchronous badge draw after a clear.
Root Cause
The previous clear path updated
BrowserWindow.setOverlayIcon()without synchronizing the third-party package's module-level state. The package also allowed an olderexecuteJavaScript()render to overwrite a newer clear.Design Decisions
NativeImagesupports PNG/JPEG data.Changes Detail
packages/kit-bg/src/desktopApis/WindowsTaskbarBadge.ts: OneKey-owned badge rendering and lifecycle implementation.packages/kit-bg/src/desktopApis/WindowsTaskbarBadge.test.ts: regression coverage for clear/show/accent behavior and stale renders.packages/kit-bg/src/desktopApis/DesktopApiNotification.ts: use the local helper for Windows badge updates.package.json/yarn.lock: removeelectron-taskbar-badge.patches/electron-taskbar-badge+1.1.2.patch: remove the obsolete dependency patch.Risk Assessment
Test plan
electron-taskbar-badgecode remains and the stale-render guard is present.