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

@github-actions

Copy link
Copy Markdown
Contributor

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

@nickvergessen

Copy link
Copy Markdown
Member

/backport to stable34

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