-
Notifications
You must be signed in to change notification settings - Fork 0
Add desktop notifications with anti-spam throttling to AEA monitor #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -54,6 +54,16 @@ info() { | |||||||||||||||
| echo -e "${BLUE}[AEA Monitor]${NC} $1" | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| send_notification() { | ||||||||||||||||
| local title="$1" | ||||||||||||||||
| local message="$2" | ||||||||||||||||
|
|
||||||||||||||||
| # Optional: Send desktop notification if available | ||||||||||||||||
| if command -v notify-send &> /dev/null; then | ||||||||||||||||
| notify-send "$title" "$message" -i dialog-information -t 10000 2>/dev/null || true | ||||||||||||||||
| fi | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| #=============================================================================== | ||||||||||||||||
| # PID Management | ||||||||||||||||
| #=============================================================================== | ||||||||||||||||
|
|
@@ -347,10 +357,29 @@ check_project_messages() { | |||||||||||||||
| echo "[$timestamp] Monitor found $unprocessed_count unprocessed messages" >> ".aea/agent.log" | ||||||||||||||||
| fi | ||||||||||||||||
|
|
||||||||||||||||
| # 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)" | ||||||||||||||||
| local last_notified_count=0 | ||||||||||||||||
|
|
||||||||||||||||
| if [ -f "$notif_state_file" ]; then | ||||||||||||||||
| last_notified_count=$(cat "$notif_state_file" 2>/dev/null || echo 0) | ||||||||||||||||
|
||||||||||||||||
| 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.