#!/usr/bin/env bash
set -euo pipefail
OUT=${1:-/tmp/hevy-notification-probe-$(date +%Y%m%d-%H%M%S)}
mkdir -p "$OUT"
echo "[probe] output: $OUT"
adb devices | tee "$OUT/adb-devices.txt"
# Snapshot notifications and try to isolate Hevy blocks.
adb shell dumpsys notification > "$OUT/notifications.txt"
python3 - <<'PY' "$OUT/notifications.txt" "$OUT/hevy-notifications.txt"
import sys,re
src,dst=sys.argv[1:]
s=open(src,errors='ignore').read().splitlines()
blocks=[]; cur=[]; keep=False
for line in s:
    if line.startswith('  NotificationRecord') or line.startswith('    NotificationRecord'):
        if cur and keep: blocks.append('\n'.join(cur))
        cur=[line]; keep='com.hevy' in line.lower()
    else:
        cur.append(line)
        if 'com.hevy' in line.lower() or 'hevy' in line.lower(): keep=True
if cur and keep: blocks.append('\n'.join(cur))
open(dst,'w').write('\n\n---BLOCK---\n\n'.join(blocks) or 'NO_HEVY_NOTIFICATION_BLOCK_FOUND\n')
PY
cat "$OUT/hevy-notifications.txt"
echo "[probe] If no Hevy block: start an active Hevy workout/rest timer and rerun."
