Skip to content

feat: Add edge alert notifications to Synth Overlay extension#25

Merged
e35ventura merged 10 commits intoentrius:mainfrom
MkDev11:feature/issue-17-edge-alert-notifications
Mar 9, 2026
Merged

feat: Add edge alert notifications to Synth Overlay extension#25
e35ventura merged 10 commits intoentrius:mainfrom
MkDev11:feature/issue-17-edge-alert-notifications

Conversation

@MkDev11
Copy link
Copy Markdown
Contributor

@MkDev11 MkDev11 commented Mar 9, 2026

Summary

Add edge alert notifications to the Synth Overlay extension. Users can watch markets and get browser notifications when the edge crosses their threshold — turning the overlay from a passive viewer into an active opportunity scanner.

Closes #17

Demo Video

📹 Demo video

Key Changes

Component Changes
extension/alerts.js (new) SynthAlerts module — watchlist CRUD, threshold validation, cooldown management, notification history, auto-dismiss setting, shared chrome.storage.local schema
extension/background.js Alert polling engine using chrome.alarms (60s), immediate poll on tab switch, notification dispatch with 5-min cooldown, suppression logic, click-to-navigate handler, badge count, notification history persistence
extension/sidepanel.js Alerts UI wiring — renderWatchlist, updateWatchBtnState, renderHistory, initAlertsUI, auto-dismiss toggle, live history updates via chrome.storage.onChanged
extension/sidepanel.html Alerts card: toggle switch, threshold input, auto-dismiss toggle, watch button, watchlist display, recent alerts history panel with clear button
extension/sidepanel.css Alert styles: toggle (+ small variant), threshold input, watch button, watchlist items, notification history panel
extension/manifest.json Added notifications, storage, alarms permissions; version 1.3.0; registered all icon sizes with default_icon
extension/icon{16,48,128}.png (new) Branded icon set with "S" lettermark at all Chrome-required sizes
tests/test_alerts.py (new) 50 tests covering threshold, cooldown, watchlist, notification formatting, history CRUD, auto-dismiss, badge count, end-to-end pipeline
README.md Documented alerts feature in How It Works section

Related Issues

Closes #17

How It Works

  1. User toggles Alerts on in the side panel and sets an edge threshold (default 3.0pp)
  2. User clicks + Watch this market to add the current market to the watchlist
  3. Badge count appears on the extension icon showing number of watched markets
  4. Background service worker polls all watched markets every 60 seconds via chrome.alarms
  5. When user switches away from a Polymarket tab, an immediate poll is triggered — notification fires within seconds
  6. When edge exceeds threshold → fires a browser notification with asset, edge size, signal direction, strength, and confidence
  7. Clicking the notification focuses the existing Polymarket tab or opens a new one
  8. Notification history: Last 10 alerts are saved and displayed in the side panel's "Recent Alerts" section, live-updating as new alerts fire
  9. Auto-dismiss toggle: User can choose whether notifications stay until clicked (default) or auto-dismiss
  10. Suppression: No notification fires if user is already viewing that market page
  11. Cooldown: 5-minute cooldown per market prevents notification spam
  12. Persistence: All state stored in chrome.storage.local — survives service worker restarts

Edge Cases Handled

  • iconUrl required for chrome.notifications.create on all platforms
  • Duplicate notification suppression (checks if notification with same ID is already showing)
  • Cooldown per market persisted in storage (survives MV3 service worker kills)
  • Suppressed when user is already on the specific market page
  • Watchlist capacity limit (20 markets max)
  • Threshold validation and clamping (0.1–50 pp range)
  • Graceful API error handling (server down, HTTP errors, missing data)
  • Stale cooldown entry cleanup
  • Watch button state updates after market data loads

Type of Change

  • Improvement to existing tool
  • Documentation

Testing

  • Tested against Synth API
  • Manually tested
  • Tests added/updated
python3 -m pytest tools/synth-overlay/tests/ -v  # 132 passed (82 existing + 50 new)

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • Changes are documented (if applicable)

MkDev11 added 10 commits March 9, 2026 10:31
Closes entrius#17

Add browser notifications when edge on a watched Polymarket market
exceeds a user-defined threshold. Users can monitor multiple markets
and get notified without watching the side panel.

Components:
- alerts.js: SynthAlerts module (watchlist CRUD, threshold validation,
  cooldown management, shared storage schema)
- background.js: alarm-based polling engine (chrome.alarms every 60s),
  notification dispatch with 5-min cooldown, suppression when user is
  on the market page, click-to-navigate handler
- sidepanel UI: toggle, threshold input, watchlist with add/remove
- manifest.json: notifications, storage, alarms permissions

Edge cases handled:
- Duplicate notification suppression (same notifId still showing)
- Cooldown per market to prevent spam (5 min, persisted in storage)
- Suppressed when user is already viewing that market
- Watchlist capacity limit (20 markets)
- Threshold validation and clamping (0.1-50 pp)
- Service worker restart resilience (state in chrome.storage.local)
- Graceful handling of API errors and unreachable server
…fresh

- Add icon128.png and iconUrl property to chrome.notifications.create
  (required on Linux, was causing 'missing type, iconUrl, title, message' error)
- Register icon in manifest.json
- Set requireInteraction: true so notification stays until clicked
- Call updateWatchBtnState() after currentSlug is set in refresh()
  (fixes '+ Watch this market' button staying disabled after data loads)
- Add logging to notification click handler for debugging
Trigger instant poll when user switches to a non-Polymarket tab,
so notifications fire within seconds of leaving the market page
instead of waiting for the next 60s alarm cycle. Also poll
immediately on any watchlist or settings change.
…nded icons

- Generate branded icon set (16, 48, 128) with 'S' lettermark
- Register all icon sizes in manifest + default_icon in action
- Bump version to 1.3.0
- Add badge count on extension icon showing watched market count
- Add notification history panel (last 10 alerts, viewable in side panel)
- History live-updates when background fires a notification
- Add auto-dismiss toggle (controls requireInteraction per user preference)
- Add 12 new tests: history CRUD, auto-dismiss logic, badge count
- Total: 132 tests passing (50 alert + 82 existing)
chrome.tabs.get doesn't expose url for chrome:// pages even with
tabs permission. Previously the condition short-circuited and
pollWatchlist was never called. Now treat missing url as
non-Polymarket and poll immediately.
@MkDev11
Copy link
Copy Markdown
Contributor Author

MkDev11 commented Mar 9, 2026

@e35ventura can you please review the PR and let me know your feedback?

@e35ventura e35ventura merged commit 4d66b57 into entrius:main Mar 9, 2026
1 check passed
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.

Synth Overlay: Edge Alert Notifications

2 participants