feat: alert lifecycle intelligence — new/updated/cancelled summaries (#321)#330
Merged
feat: alert lifecycle intelligence — new/updated/cancelled summaries (#321)#330
Conversation
29f2bf4 to
7ae5ef4
Compare
… WeatherClient + WeatherPresenter
- Add notify_lifecycle_changes() to AlertNotificationSystem - Updated alerts fire UPDATED/ESCALATED toast notifications - Cancelled alerts fire CANCELLED toast notifications - Escalation upgrades play sound; plain updates and cancellations do not - Hook notify_lifecycle_changes() into main_window.py weather update path - Add 6 tests covering all lifecycle notification scenarios
7ae5ef4 to
aab78bd
Compare
…llback Headline changes during updates (e.g. 'in effect until 3 PM' → '5 PM') causing the hash to change — lifecycle diff would emit cancel+new instead of updated. Switch to event+area+severity which are stable across updates.
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.
feat: alert lifecycle intelligence — new/updated/cancelled summaries (#321)
Implements issue #321: surface meaningful alert lifecycle diffs (new, updated, cancelled) so the UI and screen reader output can describe what changed, not just list current alerts.
Changes
US-001:
AlertLifecycleDiffmodel +diff_alerts()function (alert_lifecycle.py)AlertChangeKindenum: NEW, UPDATED, CANCELLEDAlertChangedataclass withis_severity_upgradepropertyAlertLifecycleDiffdataclass:new_alerts,updated_alerts,cancelled_alerts,summary,has_changesdiff_alerts(previous, current)pure function — compares twoWeatherAlertssnapshotsUS-002: Surface diff in
AlertsPresentation+build_alerts()AlertsPresentationgetschange_summary: str | None = Nonefieldbuild_alerts()acceptslifecycle_diffkwarg; when changes exist, prepends"Alert changes: {summary}\n"tofallback_textUS-003: Cache previous alerts per-location in
WeatherClient; wire diff into presenterWeatherDatagetsalert_lifecycle_diff: AlertLifecycleDiff | None = NonefieldWeatherClient.__init__now maintains_previous_alerts: dict[str, WeatherAlerts]_location_key(location)static method:"{lat:.4f},{lon:.4f}"_fetch_smart_auto_source()(auto/multi-source path): computes diff against previous, stores current_do_fetch_weather_data()NWS and VC single-source paths: same lifecycle diff computationWeatherPresenter._build_alerts()now acceptslifecycle_diffkwarg and forwards it tobuild_alerts()WeatherPresenter.present()passesweather_data.alert_lifecycle_diffinto_build_alerts()Tests
tests/test_alert_lifecycle.py— 27 tests for model anddiff_alerts()functiontests/test_alert_lifecycle_presentation.py— 16 tests forAlertsPresentationintegrationtests/test_alert_lifecycle_pipeline.py— 10 new tests forWeatherClientpipeline:_location_key()correctnesshas_changes == Falsecancelled_alertsnon-emptyWeatherData.alert_lifecycle_difffield defaults and assignmentAll 2166 tests pass. Ruff clean.
Closes
Fixes #321