feat(notifications): Render Rocket Chat as event-typed attachments#1238
Merged
Conversation
…hments Replaces the plain-text concatenation in the Rocket Chat channel with a class-based renderer registry keyed by EventType, modeled on the existing @register_channel pattern. - New package: notifications/channels/rocketchat_renderers/ with a RocketChatRenderer ABC (shared `_fmt_tokens` / `_fmt_cost` / `_fmt_duration` / `_usage_field` / `_cost_field` / `_link` helpers and color constants) plus three @register_renderer subclasses, one per terminal event: JobFinishedRenderer, ScheduleFinishedRenderer, JobBatchFinishedRenderer. - rocketchat.py now dispatches via _build_payload(notification, delivery), which calls get_renderer(event_type) and falls back to the prior `_compose_text` plain-text format when no renderer is registered. New events deliver immediately on the fallback path. - Channel messages now include a colored sidebar (green / red / yellow for partial batches), a leading status emoji, structured fields for repository / trigger / duration / usage / cost, and a per-repo ✓/✗ breakdown for batch rollups.
- Log a warning on the _build_payload plain-text fallback so a missing renderer for a known event type is observable instead of silently degrading messages forever. - Enforce `event_type: ClassVar[EventType]` at subclass-definition time via __init_subclass__ on RocketChatRenderer, so a forgotten assignment surfaces at import rather than inside chat.postMessage. - Mark _usage_field, _cost_field, and _color as @staticmethod to match the rest of the helpers in base.py — they don't use self. Test additions covering branches the reviewers flagged as uncovered: - ScheduleFinishedRenderer's Usage/Cost append paths (production signals emit these for every schedule run). - End-to-end batch wire-format pin: JOB_BATCH_FINISHED dispatched through RocketChatChannel.send() must produce a payload containing the per-repo ✓/✗ breakdown. - RocketChatChannel.send() rejects with UnrecoverableDeliveryError when the channel is disabled.
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.
Stacked on #1237 — please merge that one first; this PR's diff includes only the Piece 2+3 changes once #1237 is in.
Summary
Replaces the plain-text RC payload with class-based renderers keyed by
EventType, mirroring the existing@register_channelpattern.New package `daiv/notifications/channels/rocketchat_renderers/`
Channel change (`rocketchat.py`)
What the user sees now
Three colors: green (success), red (failure), yellow (partial batch). Batch rollups also include a per-repo `✓ / ✗` breakdown (capped at 8 with overflow marker).
Notes
Test plan