Repository navigation
Focus the sending web app when a Chromium notification is clicked - #14555
omarchybot wants to merge 3 commits into
Conversation
Chromium-derived browsers notify under their own name for every web app, so the click fallback matched the plain browser window by class. Read the sending origin's host from the link Chromium leads the body with and match it against the web app's window class first. Chromium's own default action raises no window here, since it gets no activation token, so do this even when that action was invoked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A substring match on -<host>__ also took chrome-not-<host>__ for <host>. Compare the class's host part instead. Assert that Service.qml passes the host on a click even after the default action, since the logic tests alone stay green without it. Co-Authored-By: Codex Medium <noreply@openai.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
split on an empty class yields no first element, and sub() on null aborts the whole match, so a classless window listed first stopped every click from focusing anything. Co-Authored-By: Codex Medium <noreply@openai.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
| jq -r --arg pattern "$app" --arg host "$web_app_host" \ | ||
| 'def matches($value): ($value // "") | test($pattern; "i"); | ||
| first( | ||
| (.[] | select($host != "" and ((.class // "") | ascii_downcase | (split("__")[0] // "") | sub("^[a-z]+-"; "")) == $host)), |
There was a problem hiding this comment.
The new host match also accepts non-browser classes such as teams.microsoft.com or custom-teams.microsoft.com. If such a window appears before the sending web app, clicking the notification focuses that unrelated window instead.
Require a supported browser prefix and the __ separator. Add a test with an unrelated matching class before the web app.
|
Read the diff at a8e97c7 against The classification is unsettled, so this gets no class label for now. Claude Opus 5.5 classified it as a It also no longer merges cleanly into Waiting on the maintainer. |
|
Thanks @omarchybot! The new notification engine (#15932) rewrote click routing: exec hint, then the sender's |
Clicking a notification from a Chromium web app never reaches the web app. Chromium-derived browsers send every web notification under their own app name (
Chromium,Brave Origin), and the shell reaches the sender's window throughomarchy-hyprland-focus-app "<app name>", which takes the first window whose class matches that name. That is the plain browser window, or nothing at all when the name has a space in it, as Brave's does. And for a live toast the click never even gets that far: Chromium registers adefaultaction, soinvokePopupDefault()invokes it and skips the fallback, but Chromium raises no window in response, because the shell hands it no activation token. On a clean worker (Hyprland 0.56.2, Chromium 152) the click emitsActionInvoked "default", Hyprland sees no event at all, and focus stays where it was.What identifies the sender is the link Chromium leads the body with:
<a href="https://teams.microsoft.com/">teams.microsoft.com</a>. Its host is the same one Chromium puts in the web app's window class,chrome-teams.microsoft.com__-Default(brave-…for Brave; any path and the profile follow the__; the port is dropped). So:NotificationLogic.webAppHost()reads that host from the body's leading link, only for a senderisChromiumDerived()already recognises (the same checksanitizeBody()uses to strip that link from the toast).omarchy-hyprland-focus-apptakes the host as an optional second argument and first looks for a window whose class names exactly that host, then falls back to the app name as before. A one-argument call, asomarchy-launch-browsermakes, behaves as it did.invokePopupDefault()focuses through the host whenever it has one, even after invoking thedefaultaction, since that action raises nothing on its own.A notification from an ordinary browser tab carries the same link. With no web app open for that site it now focuses the browser, where before the click did nothing. When the same site is open as a web app in two Chromium browsers or profiles, the first window wins: Chromium and Google Chrome both name web app windows
chrome-<host>__…, so the notification carries nothing to tell them apart.Fixes #7260
Fixes #9707
Reviewed by Claude Opus 5.5 and Codex Medium.