feat: notify user when claude.ai session expires (tap to re-auth)
Build APK / build (push) Successful in 1m35s

Detection already cleared the session after 3x 401/403 but did so silently —
the widget would just go stale. Now fires a one-time HIGH-priority notification
on its own 'Sign-in alerts' channel that opens LoginActivity for re-paste.
This commit is contained in:
2026-06-21 02:52:22 +00:00
parent 206f572369
commit 7ca0a1db4d
2 changed files with 55 additions and 4 deletions
@@ -31,10 +31,16 @@ class UsageUpdateWorker(
val animJob = launch { rotateRefreshIcon() }
try {
val data = UsageRepository(prefs).fetchUsage()
// Preserve last-good data so a failed/partial fetch never blanks the widget.
prefs.saveUsageData(data.mergedWith(prefs.getUsageData()))
prefs.recordHistory(data) // history records only fresh readings
Notifier.checkAndNotify(context, prefs, data)
// We passed the isLoggedIn() guard above, so if the session is gone now the
// cookie just expired this cycle — tell the user once (next cycle returns early).
if (!prefs.isLoggedIn()) {
Notifier.notifySessionExpired(context)
} else {
// Preserve last-good data so a failed/partial fetch never blanks the widget.
prefs.saveUsageData(data.mergedWith(prefs.getUsageData()))
prefs.recordHistory(data) // history records only fresh readings
Notifier.checkAndNotify(context, prefs, data)
}
} catch (_: Exception) {}
animJob.cancel()
animJob.join()