Skip to content

Add notification badges for pinned groups - #125

Open
shawnm07 wants to merge 1 commit into
iandiv:masterfrom
shawnm07:pr/notification-badges
Open

shawnm07 wants to merge 1 commit into
iandiv:masterfrom
shawnm07:pr/notification-badges

Conversation

@shawnm07

@shawnm07 shawnm07 commented Dec 3, 2026

Copy link
Copy Markdown

Closes #124

Shows a red count badge on a pinned group's taskbar button, and a dot on the app inside the popup, when an app in the group has notifications.

Notification badge on a pinned group

What changes

File Change
NotificationBadgeManager.cs (new) Background worker that runs every 2.5 s. It finds which apps have notifications, adds them up per group (nested groups included), tracks when you last saw each app, and powers --badge-diag
TaskbarBadgeOverlay.cs (new) Finds the group's taskbar button through UI Automation and draws the badge as a click-through window on top of it
App.xaml.cs Starts the worker, and removes badges on Exit
PopupWindow.xaml.cs Shows the dot in all three item layouts and updates it live; launching an app marks it seen
SettingsHelper.cs, SettingsDialog.xaml(.cs) ShowNotificationBadges setting (default on) and its toggle
Program.cs --badge-diag (writes Badges\diag.txt) and --badge-overlay-test [sec] (shows sample badges, changes nothing)
AppGroup.csproj Interop.UIAutomationClient package

Fitting the planned modular architecture

Thanks for being open to this. On your note about making features more modular: the feature is already mostly self-contained, so it should be easy to lift out.

  • All the logic is in the two new files. The rest is small hooks: start and stop in App.xaml.cs, the setting, the CLI flags, and the dot in PopupWindow.xaml.cs.
  • The taskbar badges could run as their own process. They only read appgroups.json, the pinned shortcuts, and Windows' notification sources.
  • The popup dot is the one part that talks to the main app, through the Changed event and MarkItemSeen. In a separate component, that would become a small message between processes.

Adapting it however suits the new design is completely fine with me. I'm also happy to restructure it myself once the new architecture lands.

Detection (read-only)

  1. Windows' notification database (%LOCALAPPDATA%\Microsoft\Windows\Notifications\wpndatabase.db). It's opened read-only through Windows' own winsqlite3.dll, so no new native dependency. It provides toasts that arrived after the app was last focused or launched, plus app badge counts (Phone Link, Mail, and so on).
  2. Window titles of the app's processes, including windows hidden in the tray, for example ... - 3 new items - Slack or (3) Discord.

To match a group's items to notifications, it uses each shortcut's app ID, the package name for Store apps, and Edge's app ID for website notifications. A badge clears when you focus the app, launch it from the group, or the app clears its own count. Only per-app last-seen times are stored, in Badges\seen.json under the data folder.

Why an overlay instead of changing the pinned icon

Windows 11 doesn't reliably redraw a pinned shortcut after its icon changes. I tried the usual shell refresh calls, and only an Explorer restart worked every time. So the pinned shortcuts are never touched. The badge window is click-through, never takes focus, and has no taskbar entry. It follows its button as the button moves, and hides when the taskbar auto-hides or a full-screen app covers it.

Limitations

  • These rely on undocumented Windows internals: the notification database layout and the taskbar button class Taskbar.TaskListButtonAutomationPeer. If either changes, nothing is drawn and one line is logged to Badges\badges.log.
  • Taskbar buttons are matched by their English UI Automation name ("Work pinned"). Other display languages and Windows 10 get the popup dot only.
  • Website notifications from Edge are counted under Edge, not under a particular site.

Testing

Tested on Windows 11 (build 26300):

  • Slack inside a group that isn't pinned on its own: the group's taskbar button shows the count, and other groups stay clean
  • The badge survives an Explorer restart
  • Four days of daily use (Nov 28 - Dec 2, including restarts): badges on two groups appeared and cleared about 20 times on their own, with no errors logged
  • Badge numbers centred at 100%, 125% and 200% scaling
  • The badge clears after reading the messages in Slack
  • Badges stay on top after clicking the taskbar
  • Badges hide behind full-screen apps and an auto-hidden taskbar
  • The Settings toggle turns badges off and on
  • Exit removes badges
  • Second monitor and a different scaling level

Built with the help of Claude Code; I reviewed and tested the changes.

Shows a red count badge on a pinned group's taskbar button, and a dot on the
app inside the popup, when an app in the group has notifications. Apps that
live only inside a group no longer hide their unread state.

- Detection (read-only, counts only, nothing stored but last-seen times):
  the Windows notification store (unseen Action Center toasts and app badge
  counts, via the built-in winsqlite3.dll) and window-title counts such as
  "3 new items" or "(3) Discord", including tray-hidden windows. A badge
  clears when the app is focused or launched from the group.
- Display: click-through layered windows over the taskbar buttons, located
  through UI Automation. Pinned shortcuts are never modified, because
  Windows 11 does not reliably repaint a pinned shortcut whose icon changes.
  On taskbars where the buttons can't be found, nothing is drawn and one
  line is logged.
- Settings > Others > Notification badges toggle (on by default).
- --badge-diag and --badge-overlay-test command-line diagnostics.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

This branch has not been deployed

No deployments
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.

Feature idea: notification badges on pinned groups (working implementation ready)

1 participant