Skip to content

A cold push click does not mark the notification read #312

Closed

Description

@HMarzban

Problem

A push click with no open app window does not mark the notification read.

public/service-worker.js posts NOTIFICATION_CLICK only to an existing window. With no window it calls clients.openWindow(url) and posts nothing. The mark-read path in usePushNotifications.ts never runs. So the bell and the app icon badge (#258) keep the old count after a cold launch from a push.

Fix

Carry the notification_id in the opened URL as a query parameter. In public/service-worker.js, add it to the URL that clients.openWindow opens. On load, after the session exists, mark it read the same way handleNotificationClick in useNotificationClickBridge.ts does. Then strip the parameter, as stripChatDeepLinkFromUrl does, so Share never copies it.

Do not mark it read from the service worker. It has no user session, and it must never hold the service-role key.

Check

Close every app window. Send a push, then click it. The pad opens, and the bell and badge drop by 1.

Part of #249.

Activity

  1. added
    bug
    Chat
    on Sep 23, 2026
  2. added this to the v2.3.0 milestone on Oct 24, 2026
  3. HMarzban commented on Oct 25, 2026

    @HMarzban
    CollaboratorAuthor

    Built and committed on local main. Awaits the maintainer's final push.

    Remaining gates: the webapp deploy, then a real push click with every window closed, in the device session.

  4. HMarzban commented on Nov 3, 2026

    @HMarzban
    CollaboratorAuthor

    Status, 2026-11-03. The cold-click mark-read fix shipped in bcc19b4e0, with a review follow-up in 5cfcc023d. It is pushed and deployed. Left:

  5. HMarzban commented on Nov 3, 2026

    @HMarzban
    CollaboratorAuthor

    #355 device check, 2026-11-03. Local stack, production build, desktop Chrome 156 in a throwaway profile, app installed and standalone. Push is real: subscription endpoint on fcm.googleapis.com, a mention row went through the worker, and the notification reached the service worker about 11 s later ("docsplus_qa402_local mentioned you").

    • Service worker, every window closed: not proven. clients.matchAll returned [], and the worker built the right URL: /hovercard-switch-r1-light-in?chatroom=X5oruGFz2DZMZcDES0W&notification_id=139cec0d-…. The click was synthetic (NotificationEvent('notificationclick')), because this Mac gives no assistive access to click a real macOS notification. So clients.openWindow failed with InvalidAccessError: Not allowed to open a window. A real OS click carries user activation, so this needs one real click.
    • Page side: pass. Opening that exact URL marked 139cec0d-… read (readed_at 12:40:01) and stripped notification_id from the URL. An earlier dev run did the same (4 → 3 unread).

    Left: one real notification click with every app window closed.

  6. HMarzban commented on Nov 3, 2026

    @HMarzban
    CollaboratorAuthor

    Device check, 2026-11-03. Production (1b05cb24d), desktop Chrome on macOS. Every docs.plus window was closed. A real OS click on three push notifications opened the pad at the right spot and marked each one read: 7b42a0ef 18:00:07, f050aa50 18:00:11 and 459267ec 18:00:15 UTC. This passes the last open check, so I'm closing this issue.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Chatbug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions