notificationclick always focuses the first matching window client, not the one most relevant to the notification #78

Closed
opened 2026-09-12 01:51:30 -04:00 by jared · 0 comments
Owner

Severity: low · Type: ux · Confidence: medium

Location: src/sw.ts:145-170

Problem

When a service-worker-owned notification is clicked, the handler takes windowClients.find((c) => 'focus' in c) — the first window client returned by clients.matchAll() — and forwards the notification's path to it via postMessage. If the user has multiple Lotus Chat tabs/windows open, the click can focus and navigate an arbitrary tab (not necessarily the one currently showing the room, or the most recently used one) rather than the tab the user is most likely to want, since the Clients API does not guarantee "most recently focused" ordering across browsers.

How to trigger

Open Lotus Chat in two tabs, background both, click a native/SW notification — navigation may land in the "wrong" tab from the user's perspective.

Suggested fix

Track the most-recently-focused client id (e.g. via a visibilitychange/focus message to the SW) and prefer that one, falling back to the first result.


Filed from the September 2026 client audit (branch lotus @ 4bea4895).

**Severity:** low · **Type:** ux · **Confidence:** medium **Location:** `src/sw.ts:145-170` ### Problem When a service-worker-owned notification is clicked, the handler takes `windowClients.find((c) => 'focus' in c)` — the first window client returned by `clients.matchAll()` — and forwards the notification's `path` to it via `postMessage`. If the user has multiple Lotus Chat tabs/windows open, the click can focus and navigate an arbitrary tab (not necessarily the one currently showing the room, or the most recently used one) rather than the tab the user is most likely to want, since the Clients API does not guarantee "most recently focused" ordering across browsers. ### How to trigger Open Lotus Chat in two tabs, background both, click a native/SW notification — navigation may land in the "wrong" tab from the user's perspective. ### Suggested fix Track the most-recently-focused client id (e.g. via a `visibilitychange`/`focus` message to the SW) and prefer that one, falling back to the first result. --- _Filed from the September 2026 client audit (branch `lotus` @ 4bea4895)._
jared added this to the Audit 2026-09 · Medium & Low milestone 2026-09-12 01:51:30 -04:00
jared added the priority: lowuxarea: desktop labels 2026-09-12 01:51:30 -04:00
jared self-assigned this 2026-09-12 01:51:30 -04:00
jared closed this issue 2026-09-12 20:29:07 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: LotusGuild/cinny#78