Modernize Desktop-Notifier#712
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughThe change adds layered configuration resolution for job fields and updates desktop notifications to use asynchronous dispatch, stricter message handling, and revised sound defaults. Related tests now mock and verify the asynchronous notification method. ChangesConfiguration Resolution
Desktop Notifications
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant plugin
participant send_notification
participant DesktopNotifier
plugin->>send_notification: asyncio.run(message, title, sound)
send_notification->>DesktopNotifier: await send(message, title, sound)
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Comment |
8c38f62 to
0b4dfc2
Compare
There was a problem hiding this comment.
Actionable comments posted: 5
🧹 Nitpick comments (2)
mqttwarn/services/desktopnotify.py (1)
67-68: 🩺 Stability & Availability | 🔵 Trivial | 🏗️ Heavy liftResolve the known blocking behavior before merging.
asyncio.run()blocks the synchronous plugin untilsend_notification()completes. If the TODO is accurate,mqttwarn/core.py’s 10-second plugin timeout can report failure while the underlying thread remains alive, consuming worker capacity. Confirm backend behavior and use a long-lived event loop or background dispatch if sending does not return promptly.tests/services/test_desktopnotify.py (1)
79-103: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd regression coverage for the new payload shapes.
Cover a raw
{"message": ...}dictionary and scalar/list JSON values. These cases exercise the new branches and would catch the current.get()crash and missing-key behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: b575ff8e-37f0-4ee7-b472-476dbb6ee6ab
📒 Files selected for processing (3)
mqttwarn/core.pymqttwarn/services/desktopnotify.pytests/services/test_desktopnotify.py
| try: | ||
| msg = t.cast(t.Dict, message).get('message') | ||
| except: | ||
| msg = str(message) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Handle dictionary payloads explicitly.
For a dictionary without "message", .get() returns None, so the notification becomes "None" at Line 64. The bare except also masks unrelated errors; use an explicit isinstance/mapping check and define a fallback for missing keys.
🧰 Tools
🪛 Ruff (0.15.20)
[error] 56-56: Do not use bare except
(E722)
Source: Linters/SAST tools
0b4dfc2 to
405f938
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (3)
mqttwarn/services/desktopnotify.py (3)
21-21: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUpdate the message type contract for dictionary support.
is_json()andProcessorItem.messagestill advertise onlystr/bytes, although this branch intentionally accepts dictionaries. Define a shared message type and narrow withisinstanceinstead ofcast.Also applies to: 48-55
43-46: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winUse the notifier’s
Sound/Nonecontract.
desktop-notifierv5+ deprecated boolean sound values; its current API expectsSound | None. The mocked tests will not catch this integration issue. PreferDEFAULT_SOUND if playSound else None, or verify the pinned version intentionally supports booleans. (raw.githubusercontent.com)Also applies to: 66-68
Source: MCP tools
66-68: 🩺 Stability & Availability | 🔵 TrivialVerify that notification dispatch returns promptly.
core.process_jobruns this synchronous plugin under a timeout, while this TODO states thatasyncio.run()may wait until the notification closes. If reproducible with the pinned notifier version, jobs can time out while the plugin worker continues running. Confirm the coroutine completes after scheduling and add a regression test; I can help redesign the loop ownership if needed. The upstream API documentssend()as scheduling a notification and returning its identifier. (desktop-notifier.readthedocs.io)Source: MCP tools
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 60ba1bb5-7ba8-434e-9f3b-0516e04bf8fb
📒 Files selected for processing (3)
mqttwarn/core.pymqttwarn/services/desktopnotify.pytests/services/test_desktopnotify.py
🚧 Files skipped from review as they are similar to previous changes (2)
- mqttwarn/core.py
- tests/services/test_desktopnotify.py
405f938 to
e70165c
Compare
Rough fix for #706 - sync calls no longer support by current library version. Also allows service to work with non-string data (ie. dictionaries).
e70165c to
512e17b
Compare
There was a problem hiding this comment.
Actionable comments posted: 3
♻️ Duplicate comments (1)
mqttwarn/core.py (1)
581-583: 🎯 Functional Correctness | 🟡 MinorThe previous
xformsentinel issue still applies.When no title is configured,
origin_titleis passed asfunction, soxformenters transformation and may log failed-invocation stack traces. Keep the missing option asNoneand passorigin_titleonly asorig_value.
🧹 Nitpick comments (1)
mqttwarn/services/desktopnotify.py (1)
21-28: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winAvoid decoding JSON twice.
is_json()fully parses the payload, thenplugin()parses it again. Return the parsed value from one helper or parse once insideplugin().Also applies to: 51-52
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: cf9bd91b-355e-468f-968f-39a6df16c7d1
📒 Files selected for processing (4)
mqttwarn/core.pymqttwarn/services/desktopnotify.pytests/services/test_desktopnotify.pytests/test_core_infra.py
🚧 Files skipped from review as they are similar to previous changes (1)
- tests/services/test_desktopnotify.py
21bcbf3 to
e43ac00
Compare
About
References