feat(alerts): show lifecycle status labels using NWS messageType#337
Merged
feat(alerts): show lifecycle status labels using NWS messageType#337
Conversation
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.
Closes #332
What changed
Adds lifecycle status labels to alert list items — (New), (Updated) — so users can see at a glance what's changed since the last poll.
Approach
Labels are driven directly by the NWS API's
messageTypefield on each alert:messageTypeAlertUpdateCancelVisual Crossing alerts get no label — VC doesn't provide a
messageTypeequivalent; it repackages NWS data with less metadata, so labels would be unreliable.Why not snapshot diffing?
An earlier approach used before/after snapshot comparison to derive labels. That had edge cases: labels were wrong on first launch (everything appeared New), broke on app restart, and misclassified amended alerts that NWS re-issues with a new ID. Using
messageTypedirectly fixes all of these — it reflects NWS's intent, is stateless, and survives restarts.Note: the diff infrastructure (
diff_alerts,AlertLifecycleDiff) is kept — it still drives the notification system (sounds/toasts for escalations, cancellations, etc.), which is a separate concern.Files changed
models/alerts.py— addedmessage_type: str | Nonefield toWeatherAlertweather_client_nws.py— passmessageTypefrom NWS props through to the modelalert_lifecycle.py—compute_lifecycle_labelsnow takeslist[WeatherAlert]instead of a diffui/main_window.py— updated caller; label computation is now fully statelesstests/test_alert_lifecycle.py— updated tests for new signature and NWS/VC behavior