Skip to content

feat: open the target when a background push notification is clicked - #3478

Merged
nickvergessen merged 1 commit into
nextcloud:masterfrom
WSHAPER:feat/webpush-click-target
Oct 13, 2026
Merged

nickvergessen merged 1 commit into
nextcloud:masterfrom
WSHAPER:feat/webpush-click-target

Conversation

@WSHAPER

@WSHAPER WSHAPER commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Fixes #3477

Recon (fully) and implementation (partially) assisted-by: opencode:glm-5.3

@WSHAPER

WSHAPER commented Oct 12, 2026

Copy link
Copy Markdown
Contributor Author

Hey @nickvergessen,
I'm Ilia, a recent addition to the AI/Integrations team, and I'm glad to be contributing!

Just wanted to let you know that this is a possible blocker for nextcloud/assistant#695

If you have any suggestions, I'd be glad to discuss them in the PR.
Have a great time until then!

Comment thread src/workers/service-worker.js Outdated
Comment on lines +97 to +123
if (!link) {
// no target: focus an existing window of this instance if any
event.waitUntil(self.clients.matchAll({ type: 'window' }).then((clientList) => {
for (const client of clientList) {
if (client.url.startsWith(self.location.origin)) {
return client.focus()
}
}
}))
return
}
event.waitUntil(self.clients.matchAll({ type: 'window' }).then(async (clientList) => {
for (const client of clientList) {
// navigate() only works for same-origin targets
if (client.url.startsWith(self.location.origin)
&& link.startsWith(self.location.origin + '/')
&& 'focus' in client) {
try {
await client.focus()
return await client.navigate(link)
} catch (e) {
console.warn('Failed to navigate the focused client, opening a new window', e)
return self.clients.openWindow(link)
}
}
}
// cross-origin link or no existing window: openWindow handles both

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Since this would overwrite pinned tabs or opened tabs meant to be a working-task reminder, I'd prefer to simply always open a new tab?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

LGTM, landed in ca16bd5

Looking forward to the merge

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Related, but in another repo: Talk is intercepting notifications when app is open, and switching you to another chat. Would you want it also to open a new tab?
(it needs to be fixed anyway, so rfc are welcome)

Fixes nextcloud#3477

Assisted-by: opencode:glm-5.3
Signed-off-by: WSHAPER <42714629+WSHAPER@users.noreply.github.com>
@nickvergessen
nickvergessen merged commit e682ec5 into nextcloud:master Oct 13, 2026
41 checks passed
@nickvergessen

Copy link
Copy Markdown
Member

/backport to stable35

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clicking a background web push notification does not open its target

3 participants