feat: notifications & cookie-health monitoring#40
Open
bin101 wants to merge 4 commits into
Open
Conversation
The 1450-line app.js is replaced by 12 focused ES modules: state.js, dom.js, api.js, format.js, schedule-matrix.js, athletes.js, config.js, settings.js, feed.js, status.js, tabs.js, main.js. The importmap in routes.py::serve_index now covers all local modules so every module is cache-busted on release. Entry point changes from app.js to main.js. No behaviour change β all 380 tests pass, coverage 87 %. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add a rolling run-history store (capped at 500 entries, newest-first) and a Statistics tab that aggregates kudos per day, summary cards, and a last-20-runs detail table rendered with a pure-canvas bar chart. - store.py: append_run_history / read_run_history (atomic JSON writes) - app.py: persist compact RunResult entry after every scheduler job - routes.py: GET /api/history?limit= endpoint + ./stats.js in importmap - static/stats.js: loadStats() + drawBarChart() (no CDN, CSP-safe) - static/tabs.js: 'stats' added to validTabs; first-visit loadStats() call - static/main.js: initStatsTab() wired in init() - static/state.js: statsLoaded flag - static/index.html: Statistics tab nav button + tab-pane (inside <main>) - static/i18n.js: DE + EN keys for stats tab - tests/unit/test_run_history.py: 7 unit tests (TDD) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add webhook notifications (ntfy/Telegram/any HTTP POST) and a visible auth-error banner when the Strava session cookie expires. Backend: - notify.py: send_notification() with injected post_fn (testable without network); build_run_payload() and build_auth_error_payload() helpers - models.py: AppSettings + notifyWebhookUrl (http/https validated), notifyOnRun, notifyOnAuthError; RunStatus + authOk (bool | None) - app.py: _run_job tracks auth_ok state, sends webhook on run-complete (if notifyOnRun) and on AuthError (if notifyOnAuthError); AuthError is now caught so a bad cookie no longer leaves the scheduler broken - routes.py: GET /api/status includes authOk from _app_state Frontend: - index.html: auth-error banner (hidden by default) + Notifications settings card (webhook URL, onRun toggle, onAuthError toggle) - status.js: show/hide banner based on s.authOk === false - settings.js: load/save notifyWebhookUrl, notifyOnRun, notifyOnAuthError - i18n.js: DE/EN/FR/ES/IT keys for notify settings + status.authError - styles.css: .auth-error-banner styling (error-bg / error colors) Tests: - tests/unit/test_notify.py: 13 unit tests (TDD β written first) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
notify.pyβ new pure/testable module:send_notification(url, payload, *, post_fn)with an injected HTTP POST function (no network in tests), plusbuild_run_payloadandbuild_auth_error_payloadhelpers. Supports ntfy, Telegram bots, or any generic HTTP endpoint.AppSettingsextended withnotifyWebhookUrl(validated http/https URL or empty),notifyOnRun(defaultFalse),notifyOnAuthError(defaultTrue)RunStatusextended withauthOk: bool | NoneβNone= no run yet,True= last run succeeded auth,False= last run hitAuthError_run_jobinapp.pynow sets_app_state["auth_ok"], catchesAuthError(cookie expired) so the scheduler stays alive, and fires webhook notifications after run-complete or auth-failure eventsauthOk === false; dismissed automatically on the next successful runTest plan
ruff check src testsβ zero errorsruff format --check src testsβ zero issuesmypy srcβ zero type errorspytest --cov=kudosyβ 400 tests pass, 86% coveragenotifyWebhookUrlto a local ntfy instance and trigger a dry-run β notification arrivesauthOkbecomesfalse, warning banner appears, auth-error webhook firesnotifyWebhookUrlempty β no notifications sent (noop)AppSettings(notifyWebhookUrl="not-a-url")raisesValidationErrorπ€ Generated with Claude Code