Skip to content

feat: smart notifications — built-in throttling, auto app logo detection, and Claude Code readiness#291

Open
AdhamHossamm wants to merge 2 commits into
Windos:mainfrom
AdhamHossamm:feat/smart-notifications-claude-code-ready
Open

feat: smart notifications — built-in throttling, auto app logo detection, and Claude Code readiness#291
AdhamHossamm wants to merge 2 commits into
Windos:mainfrom
AdhamHossamm:feat/smart-notifications-claude-code-ready

Conversation

@AdhamHossamm
Copy link
Copy Markdown

@AdhamHossamm AdhamHossamm commented May 17, 2026

Summary

BurntToast notifications just got context-aware. Two features that make toasts smarter about who triggered them and when to stay quiet:

  • Notification Throttling (-CooldownSeconds): Built-in spam prevention. A new parameter on both Submit-BTNotification and New-BurntToastNotification that suppresses duplicate toasts within a configurable time window. Each UniqueIdentifier gets its own independent cooldown tracked via lock files in %TEMP%\BurntToast-Throttle. Uses .NET I/O (System.IO.File) instead of PowerShell cmdlets so throttle state persists correctly even under -WhatIf.

  • Auto App Logo Detection (-AutoAppLogo + -AppLogoMap): BurntToast now knows who called it. A new switch on New-BurntToastNotification that walks the process tree to find the first ancestor with a visible window (your terminal, IDE, or app shell), extracts its executable icon via System.Drawing, and caches it in %TEMP%\BurntToast-IconCache. The -AppLogoMap hashtable lets you pin custom icons to specific process names — for example, @{ 'node' = 'C:\icons\claude.ico' } gives Claude Code its own branded notifications.

Motivation

Born from real-world Claude Code integration where hook-driven toast notifications had two problems:

  1. Rapid subagent completions spammed identical toasts (5-10 in seconds)
  2. Every notification used the same generic icon regardless of which app triggered it

These features solve both at the library level so any BurntToast consumer benefits — not just our use case.

Changes

File What
src/Public/Submit-BTNotification.ps1 Added -CooldownSeconds param with lock file throttle logic
src/Public/New-BurntToastNotification.ps1 Added -CooldownSeconds passthrough, -AutoAppLogo switch, -AppLogoMap hashtable, mutual exclusion with -AppLogo
src/Private/Get-BTCallerAppIcon.ps1 New private function — process tree walk, icon extraction, caching, override map
Tests/Throttle.Tests.ps1 8 tests covering throttle behavior
Tests/Get-BTCallerAppIcon.Tests.ps1 10 tests covering auto logo detection
Tests/Advanced-Throttle.Tests.ps1 15 edge-case tests (stress, expiry, isolation, PNG validation, combined features)

Test plan

  • 33 new Pester v5 tests added
  • Full suite: 113/113 passing, zero regressions against existing 80 tests
  • 20-call rapid-fire stress test — only 1 toast fires
  • Cooldown expiry verified via backdated lock file
  • Zero and negative CooldownSeconds handled correctly
  • Lock file integrity: correct path, valid ISO 8601 timestamp
  • Concurrent identifier isolation: independent cooldowns don't interfere
  • Icon cache reuse: same path on repeated calls
  • Cached icon validated as real PNG (magic bytes 89 50 4E 47)
  • Combined throttle + AutoAppLogo interaction tested
  • Graceful fallback when icon extraction fails or mapped path doesn't exist
  • XML well-formedness verified with auto-detected icon

AdhamHossamm and others added 2 commits May 17, 2026 20:08
…tection, and Claude Code ready

Toast notifications just got intelligent. Two features that make BurntToast
aware of its context and respectful of your attention:

1. Notification Throttling (CooldownSeconds):
   Built-in spam prevention via per-identifier lock files in %TEMP%.
   Rapid-fire scripts, CI hooks, and automation loops no longer flood
   your screen — only the first toast within the cooldown window fires.
   Uses .NET I/O to bypass WhatIf scope so state persists during dry runs.

2. Auto App Logo Detection (AutoAppLogo + AppLogoMap):
   BurntToast now knows who called it. Walks the process tree to find the
   parent terminal or IDE, extracts its icon, and uses it as the toast logo.
   AppLogoMap lets you pin custom icons to specific callers — e.g., mapping
   'node' to Claude's logo so Claude Code notifications look native.

Born from real-world Claude Code hook integration where rapid subagent
completions were spamming toasts and every notification looked the same
regardless of which app triggered it.

18 new Pester v5 tests. Full suite: 98/98 passing, zero regressions.

Co-Authored-By: Tawaar Technologies <info@tawaar.net>
Stress tests covering:
- 20-call rapid-fire loop (only 1 toast fires)
- Cooldown expiry via backdated lock file
- Zero and negative CooldownSeconds
- Special characters in UniqueIdentifier
- Lock file integrity and ISO 8601 timestamp validation
- Concurrent identifier isolation (A+B throttled, C fires)
- Nonexistent icon path graceful fallback
- Icon cache reuse and PNG magic byte validation
- Empty and multi-entry AppLogoMap
- XML well-formedness with auto-detected icon
- Combined throttle + AutoAppLogo interaction

Full suite: 113/113 passing.

Co-Authored-By: Tawaar Technologies <info@tawaar.net>
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