Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle action of type text #179

Closed
xfalcox opened this issue Nov 14, 2022 · 21 comments · Fixed by #221
Closed

Handle action of type text #179

xfalcox opened this issue Nov 14, 2022 · 21 comments · Fixed by #221
Labels
enhancement New feature or request Low Priority

Comments

@xfalcox
Copy link

xfalcox commented Nov 14, 2022

On Windows/Android/ChromeOS, when you send a notification that contains an action of type text, it will allow the user to type some text in a input box and send the action with the typed text as the parameter.

Android:
image

Windows:
image

When using snc there is a button for the action with type text, but clicking on it send the notification with a null value for the action.

This is useful, for example, in chat apps so you can type a quick response without having to open a window of the app.

@ErikReider
Copy link
Owner

ErikReider commented Nov 14, 2022

is there a application in Linux that sends these kind of notifications?

When using snc there is a button for the action with type text

That is "snc"?

@xfalcox
Copy link
Author

xfalcox commented Nov 14, 2022

is there a application in Linux that sends these kind of notifications?

Chrome does.

That is "snc"?

Sorry, meant that when using SwayNotificationCenter and sending a notification that contains an action with the "text" type it will render the notification button, but since there is no input, clicking on it will send the action back with a null value. Just tested it on my machine by subscribing to a website that sends those types of notifications.

@ErikReider
Copy link
Owner

ErikReider commented Nov 14, 2022

Chrome does.

Which website?

Could you run swaync with all messages enabled (G_MESSAGES_DEBUG=all swaync), receive that notification and paste the output here? The output should be something like this:

** (swaync:181171): DEBUG: 18:18:24.180: notiDaemon.vala:153: Notification: 
category:		(null)
image_data:		false
expire_timeout:		-1
replaces_id:		0
desktop_entry:		(null)
body:			Notification body
app_icon:		
action_icons:		false
time:			1668446304
hints:		
	sender-pid: int64 181220
	urgency: byte 0x02
applied_id:		1
image_path:		(null)
app_name:		notify-send
summary:		Summary
icon_data:		false
resident:		false
default_action:		(null)
actions:		
urgency:		Critical

@ErikReider ErikReider added the enhancement New feature or request label Nov 14, 2022
@xfalcox
Copy link
Author

xfalcox commented Nov 14, 2022

Which website?

For testing you can use https://tests.peter.sh/notification-generator/ and select "Actions = One action (type text with placeholder)" to trigger it as you want with the "Display Notification" button.

If you add a breakpoint to the sw.js file on your Chrome instance DevTools on line 23 and inspect the event object, you will see that the reply attribute value is null. That's where the text would be inserted.

Could you run swaync with all messages enabled (G_MESSAGES_DEBUG=all swaync), receive that notification and paste the output here?

Sure, here it is:

** (swaync:94956): DEBUG: 16:31:38.166: notiDaemon.vala:153: Notification: 
category:		(null)
image_data:		false
expire_timeout:		-1
replaces_id:		0
desktop_entry:		chromium
body:			tests.peter.sh

Notification content
app_icon:		file:///tmp/.org.chromium.Chromium.IfUXnn
action_icons:		false
time:			1668454298
hints:		
	urgency: uint32 1
	desktop-entry: 'chromium'
	image_path: data
	image-path: data
applied_id:		1
image_path:		/tmp/.org.chromium.Chromium.y3MoXf
app_name:		Chromium
summary:		Notification title
icon_data:		false
resident:		false
default_action:		Name: Activate, Id: default
actions:		
	Name: Reply, Id: 0
	Name: Settings, Id: settings
urgency:		Low

@xfalcox
Copy link
Author

xfalcox commented Nov 14, 2022

Out of curiosity, looks like Telegram desktop (native app) also sends those

** (swaync:94956): DEBUG: 16:33:49.604: notiDaemon.vala:153: Notification: 
category:		im.received
image_data:		true
expire_timeout:		-1
replaces_id:		0
desktop_entry:		telegramdesktop
body:			Falco
app_icon:		
action_icons:		false
time:			1668454429
hints:		
	image-data: data
	desktop-entry: 'telegramdesktop'
	category: 'im.received'
applied_id:		3
image_path:		(null)
app_name:		Telegram Desktop
summary:		delmamonteiro
icon_data:		false
resident:		false
default_action:		(null)
actions:		
	Name: Mark as read, Id: mail-mark-read
	Name: Reply, Id: mail-reply-sender
urgency:		Low

@ErikReider
Copy link
Owner

Oh. Looks like the actions only show in Chromium and not Firefox. That's why it didn't work for me... There's no specific hints to indicate that it needs a input. Does it work in Gnome / KDE?

My guess is that it's not implemented on Linux browsers due to it not being in the Freedesktop Notification spec

@xfalcox
Copy link
Author

xfalcox commented Dec 2, 2022

Oh. Looks like the actions only show in Chromium and not Firefox. That's why it didn't work for me...

Yeah, it's still in Firefox backlog per https://bugzilla.mozilla.org/show_bug.cgi?id=1225110

There's no specific hints to indicate that it needs a input.
My guess is that it's not implemented on Linux browsers due to it not being in the Freedesktop Notification spec

The hint is the action "type", but looks like that isn't being passed down as NotificationAction on the spec is still just a string and ID 😢

My guess is that Freedesktop Notification spec will only update when whatwg/notifications#132 is merged so let's see what happens...

@ErikReider
Copy link
Owner

I've turned on notifications for that PR so I'll return to this when it gets updated :)

@slikie
Copy link
Contributor

slikie commented Feb 20, 2023

How about native apps like nheko which definitely have inline reply support on KDE? There is a category: im.received hint but no action detected. Wonder how KDE handles it.

@slikie
Copy link
Contributor

slikie commented Feb 20, 2023

there are actions mentions in nheko's implementation but
swaync doesn't seem to pick it up

** (swaync:119054): DEBUG: 00:03:53.332: notiDaemon.vala:153: Notification: 
category:               im.received
image_data:             true
expire_timeout:         -1
replaces_id:            0
desktop_entry:          nheko
body:                   noodles : test convo
app_icon:               
action_icons:           false
time:                   1676909033
hints:          
        image-data: data
        sound-name: 'message-new-instant'
        desktop-entry: 'nheko'
        category: 'im.received'
applied_id:             22
image_path:             (null)
app_name:               nheko
summary:                noodles 
icon_data:              false
resident:               false
default_action:         (null)
actions:                
urgency:                Low

while dunst does detect the actions. There is also an activation action that raise the correct room as well.

@ErikReider
Copy link
Owner

Maybe adding inline-reply to GetCapabilities would make it visible?

[DBus (name = "GetCapabilities")]
public string[] get_capabilities () throws DBusError, IOError {
return {
"actions",
"body",
"body-markup",
"body-images",
"persistence",
"synchronous",
"private-synchronous",
"x-canonical-private-synchronous",
};
}

@ErikReider
Copy link
Owner

How about native apps like nheko which definitely have inline reply support on KDE? There is a category: im.received hint but no action detected. Wonder how KDE handles it.

Do you know where the KDE notification daemon source code is located? Haven't been able to find it. Maybe they're doing something different?

@ErikReider
Copy link
Owner

PROGRESS! Adding inline-reply to GetCapabilities seems to work! :)

category:		(null)
image_data:		false
expire_timeout:		-1
replaces_id:		0
desktop_entry:		chromium
body:			tests.peter.sh

Notification content
app_icon:		file:///tmp/.org.chromium.Chromium.gtfpFo
action_icons:		false
time:			1676976678
hints:		
	x-kde-reply-placeholder-text: 'Placeholder'
	urgency: uint32 1
	desktop-entry: 'chromium'
	image_path: data
	image-path: data
applied_id:		3
image_path:		/tmp/.org.chromium.Chromium.wyZMU3
app_name:		Chromium
summary:		Notification title
icon_data:		false
resident:		false
default_action:		Name: Activate, Id: default
actions:		
	Name: Reply, Id: inline-reply
	Name: Settings, Id: settings
urgency:		Low

@ErikReider
Copy link
Owner

@xfalcox @slikie See if the #221 PR works for your applications

@slikie
Copy link
Contributor

slikie commented Feb 22, 2023

PROGRESS! Adding inline-reply to GetCapabilities seems to work! :)
For some reason I can't replicate this. The action still doesn't seem to get caught. On firefox it doesn't catch anything, while on chrome it parses the placeholder message right but can't edit or reply. With nheko I can't see the action as well.

category:                (null)
image_data:              false
expire_timeout:          -1
replaces_id:             0
desktop_entry:           chromium
body:                   tests.peter.sh

Notification content
app_icon:                file:///tmp/.org.chromium.Chromium.FpxP0S
action_icons:            false
time:                   1677054974
hints:
        x-kde-reply-placeholder-text: 'Send message'
        urgency: uint32 1
        desktop-entry: 'chromium'
        image_path: data
        image-path: data
applied_id:              1
image_path:              /tmp/.org.chromium.Chromium.OzEaKr
app_name:                Chromium
summary:                 Notification title
icon_data:               false
resident:                false
default_action:          Name: Activate, Id: default
actions:
        Name: Settings, Id: settings
urgency:                 Low

@ErikReider
Copy link
Owner

For some reason I can't replicate this. The action still doesn't seem to get caught. On firefox it doesn't catch anything, while on chrome it parses the placeholder message right but can't edit or reply. With nheko I can't see the action as well.

category:                (null)
image_data:              false
expire_timeout:          -1
replaces_id:             0
desktop_entry:           chromium
body:                   tests.peter.sh

Notification content
app_icon:                file:///tmp/.org.chromium.Chromium.FpxP0S
action_icons:            false
time:                   1677054974
hints:
        x-kde-reply-placeholder-text: 'Send message'
        urgency: uint32 1
        desktop-entry: 'chromium'
        image_path: data
        image-path: data
applied_id:              1
image_path:              /tmp/.org.chromium.Chromium.OzEaKr
app_name:                Chromium
summary:                 Notification title
icon_data:               false
resident:                false
default_action:          Name: Activate, Id: default
actions:
        Name: Settings, Id: settings
urgency:                 Low

With the pr? The "inline-reply" action is removed from the output so that would be why. Firefox isn't working but chromium is. Do you get a text field on your notification?

@slikie
Copy link
Contributor

slikie commented Feb 22, 2023 via email

@ErikReider
Copy link
Owner

swaync 0.7.3 (git-1c80c60, branch 'makepkg')
Yes I get a text field with the debug website and on kde_connect fro phone apparently, but I can't type on it or click the reply button.

This is a sway limitation that I'll need to work around... It'll work if you open the control center

@slikie
Copy link
Contributor

slikie commented Feb 22, 2023

Ah sorry apparently it works... I successfully replied a message on my phone on kde connect.

@ErikReider
Copy link
Owner

Ah sorry apparently it works... I successfully replied a message on my phone on kde connect.

Awesome! Now the remaining todos...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Low Priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants