Skip to content

Conversation

@ghost
Copy link

@ghost ghost commented May 7, 2025

This adds support for the reply field on Linux, using the inline-reply capability. It might not exist everywhere but seems to be standard as it doesn't have a x-vendor prefix.

Support for the button_text field could be achieved, but it doesn't seem to be standardized (yet?), so unsure if this is in the scope of this lib.
linux_reply_field

This adds support for the reply field on Linux, using the `inline-reply` capability. It might not exist everywhere but seems to be standard as it doesn't have a `x-vendor` prefix.
@codecov-commenter
Copy link

codecov-commenter commented May 7, 2025

Codecov Report

Attention: Patch coverage is 43.75000% with 9 lines in your changes missing coverage. Please review.

Project coverage is 85.23%. Comparing base (5dab588) to head (e8fa20d).
Report is 29 commits behind head on main.

Files with missing lines Patch % Lines
src/desktop_notifier/backends/dbus.py 43.75% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #226      +/-   ##
==========================================
+ Coverage   85.06%   85.23%   +0.17%     
==========================================
  Files          10       10              
  Lines         951      962      +11     
==========================================
+ Hits          809      820      +11     
  Misses        142      142              
Flag Coverage Δ
pytest 85.23% <43.75%> (+0.17%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Owner

@samschott samschott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution! It looks like inline replies are not part of the spec at https://specifications.freedesktop.org/notification-spec/latest/protocol.html#command-get-capabilities, even though the capability is not prefixed with "x-vendor". Do you know on which desktop environments you expect this to be supported?

Two requests:

  1. This is currently not tested because. The notification daemon used in our tests does not seem to support reply fields (see setup here) but you can probably still "simulate" a reply here and remove the capability check here from the test case.
  2. Could you add a change log entry?

@ghost
Copy link
Author

ghost commented May 13, 2025

1. [...] you can probably still "simulate" a reply here and remove the capability check here from the test case.

2. Could you add a change log entry?

Yes, I will do both of those things as well. For the change log entry, shall I bump the version?

@samschott
Copy link
Owner

For the change log entry, shall I bump the version?

Yes! 6.2.0 would be appropriate since its a "new" feature for the dbus backend.

@ghost
Copy link
Author

ghost commented May 13, 2025

It looks like inline replies are not part of the spec [...] Do you know on which desktop environments you expect this to be supported?

Forgot to add that part in my other reply, oops. After looking a bit more, it seems like inline-reply was stalled, and that would explain why it's not part of the spec (despite its name indicating otherwise), nor mentioned in KDE's own documentation (despite them supporting it).

On the other hand useful additions to org.freedesktop notifications ( !24 (closed)) got stalled because of vague portal things.

If you still wish to merge that PR, I'd be happy to still bring the requested changed.

@samschott
Copy link
Owner

Given that KDE is a sufficiently popular desktop environment, I'd be happy to proceed with this PR.

@samschott
Copy link
Owner

Support for the button_text field could be achieved, but it doesn't seem to be standardized (yet?), so unsure if this is in the scope of this lib.

Since "inline-reply" is non-standard either, I'd be happy also include button_text support for KDE:

https://github.com/KDE/knotifications/blob/aa0083308a6e547c40f138df53109a04fb1f83b6/src/notifybypopup.cpp#L243

The approach for this lib is to support features where possible and expose notification server capabilities through the API. An app should generally not rely on notifications for key interaction patterns since users may disable them or limit their capabilities on a per-app basis, so a "your milage will vary" approach sounds good to me.

val_int1 added 3 commits May 14, 2025 20:54
Added check to ignore reply field if the notification server doesn't support `inline-reply`, as well as adding support for `x-kde-reply-submit-button-text`
Copy link
Owner

@samschott samschott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot! Only a few minor requests for changes.

hints_v: dict[str, Variant] = dict()
if notification.reply_field and self.supports_inline_reply:
actions += [INLINE_REPLY_ACTION_KEY, notification.reply_field.title]
hints_v["x-kde-reply-submit-button-text"] = Variant(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Could you move "x-kde-reply-submit-button-text" also to a constant?

actions += [button.identifier, button.title]

hints_v: dict[str, Variant] = dict()
if notification.reply_field and self.supports_inline_reply:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if notification.reply_field and self.supports_inline_reply:
if notification.reply_field and Capability.REPLY_FIELD in await self.get_capabilities():

CHANGES.md Outdated
@@ -1,3 +1,10 @@
# v6.2.0

## Added :
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## Added :
## Added:


@pytest.mark.asyncio
async def test_replied_fallback_handler_called(notifier: DesktopNotifier) -> None:
await check_supported(notifier, Capability.REPLY_FIELD)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Darn, it looks like this check is also required for older MacOS versions which now have failing tests.

For now, I'd recommend adding this back again, and accepting that we have a bit less coverage on Linux. I can look later into setting up a notification daemon with inline-reply support on GitHub Actions.

@samschott samschott merged commit 2f0016c into samschott:main May 17, 2025
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants