Add desktop notifications with anti-spam throttling to AEA monitor#4
Add desktop notifications with anti-spam throttling to AEA monitor#4
Conversation
|
Unable to perform a code review. You have run out of credits 😔 |
Co-authored-by: 0xrinegade <101195284+0xrinegade@users.noreply.github.com>
Co-authored-by: 0xrinegade <101195284+0xrinegade@users.noreply.github.com>
There was a problem hiding this comment.
Pull Request Overview
This PR adds desktop notification support to the AEA monitor script, alerting users when new messages are detected even when the terminal is not in focus.
Key Changes:
- Added
send_notification()helper function that usesnotify-sendwhen available - Integrated desktop notifications into the message detection workflow
- Notifications display for 10 seconds with graceful fallback if
notify-sendis unavailable
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
scripts/aea-monitor.sh
Outdated
| fi | ||
|
|
||
| # Send desktop notification | ||
| send_notification "AEA Monitor" "New messages in $project_name" |
There was a problem hiding this comment.
The notification is sent every time check_project_messages() detects unprocessed messages, which could result in repeated notifications during the same monitoring cycle. Consider adding a condition to only send the notification when messages are first detected, or throttling notifications to avoid spam.
|
@copilot The notification is sent every time check_project_messages() detects unprocessed messages, which could result in repeated notifications during the same monitoring cycle. Consider adding a condition to only send the notification when messages are first detected, or throttling notifications to avoid spam. |
Co-authored-by: 0xrinegade <101195284+0xrinegade@users.noreply.github.com>
Added notification throttling in commit 5156e7b. The monitor now tracks message count per project and only sends notifications when the count increases (new messages arrive). Repeated checks for the same messages no longer trigger notifications. State is automatically cleared when all messages are processed. |
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| # Send desktop notification only if message count has increased | ||
| # Track notification state to avoid spam | ||
| local notif_state_file="$CONFIG_DIR/.notification_state_$(echo "$project_path" | md5sum | cut -d' ' -f1)" |
There was a problem hiding this comment.
The state file path construction is duplicated in two places (lines 362 and 381). Extract this to a local variable at the beginning of the function to avoid repetition and ensure consistency.
| local notif_state_file="$CONFIG_DIR/.notification_state_$(echo "$project_path" | md5sum | cut -d' ' -f1)" | |
| local notif_state_file | |
| notif_state_file="$CONFIG_DIR/.notification_state_$(echo "$project_path" | md5sum | cut -d' ' -f1)" |
| local last_notified_count=0 | ||
|
|
||
| if [ -f "$notif_state_file" ]; then | ||
| last_notified_count=$(cat "$notif_state_file" 2>/dev/null || echo 0) |
There was a problem hiding this comment.
The fallback || echo 0 executes when cat fails (file doesn't exist), but also when the file exists and is empty or contains invalid data. This could lead to notifications being sent repeatedly if the state file is corrupted. Consider explicit validation of the file content or initialization with a default value.
| last_notified_count=$(cat "$notif_state_file" 2>/dev/null || echo 0) | |
| notif_content=$(cat "$notif_state_file" 2>/dev/null) | |
| if [[ "$notif_content" =~ ^[0-9]+$ ]]; then | |
| last_notified_count="$notif_content" | |
| else | |
| last_notified_count=0 | |
| fi |
…ovides no no ... (truncated)
The AEA monitor logs message arrivals to the terminal but provides no notification when the terminal is not in focus.
Changes
scripts/aea-monitor.sh(+31 lines)send_notification()helper that conditionally callsnotify-sendif availablecheck_project_messages()when unprocessed messages are detectedImplementation
Notification displays for 10 seconds with
dialog-informationicon. Gracefully no-ops ifnotify-sendunavailable.Anti-Spam Throttling
The notification system includes intelligent throttling to prevent spam:
~/.config/aea/.notification_state_<hash>Example behavior:
Ready for extension to macOS/Windows notification systems.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.