Skip to content

feat(notifications): notification topics, real badge count and Catch up in the Huddle inbox (#914) - #931

Open
Dharp02 wants to merge 28 commits into
mainfrom
docs/914-frontend-inbox-plan
Open

Dharp02 wants to merge 28 commits into
mainfrom
docs/914-frontend-inbox-plan

Conversation

@Dharp02

@Dharp02 Dharp02 commented Dec 4, 2026 •

Copy link
Copy Markdown
Collaborator

Refs #914

Implements docs/notification-inbox-frontend-plan.md: notifications appear as topics in the Huddle inbox, the app badge shows the real unread total, and a Catch up view walks through unread cards. Nothing new is stored: no collections, fields or migrations. Server changes are code plus one index (notifications { userId, read }, droppable with dropIndex('unread_by_user')).

Demo

Member, on a phone Owner, on a phone
Catch up on a phone: open, Mark read, Undo, walk to all caught up Approve a join request in the Requests topic, switch teams in Catch up, open the Personal view
Open Catch up, Mark read, Undo, then walk through the cards to "You're all caught up" Approve in the Requests topic, switch teams from the chips, and the Personal view

On desktop: Catch up opens as a centred dialog, with the same Mark read and Undo.

Catch up on desktop with Mark read and Undo

Screenshots

Member, on a phone

1. Shift-end reminder2. Inbox with topics3. Requests topic
Shift-end reminder popupHuddle inbox listing notification topicsThe Requests topic
4. Catch up5. Mark read, with Undo6. All caught up
Catch up cardCatch up after Mark read, with UndoCatch up when the team is all caught up

Owner, on a phone

7. Inbox with topics8. Approve / Decline9. Answered
Huddle inbox for an ownerApprove and Decline inside the Requests topicA request after it was approved
10. Team chips11. Another team12. Personal view
Catch up with a chip per teamCatch up after switching teamCatch up button in the Personal view

On desktop

13. Inbox with topics14. Requests topic
Huddle inbox on desktopThe Requests topic on desktop
15. Catch up16. Mark read, with Undo
Catch up dialogCatch up after Mark read, with Undo

What changed

  • Server (meteor-backend/): clock-out/clock-in alerts always open Huddle; notifications.unreadCount and notifications.markManyRead (returns each row's stored read time); getInbox({ withUnread }); the real unread total in the APNs/FCM badge, a silent badge push after reads and deletes (deleteNotifications helper), and a badge sync when an iOS token registers; "Agree to Clock Out" also records shiftReminderResponse.
  • Inbox state (NotificationInboxContext): one provider for the live inbox and the exact count; it reloads when the rows and the count disagree (reads or deletes on another device, answered requests, more than one load of unread). Web/Android badge sync.
  • Huddle (useNotificationTopics, notificationTopics): virtual topics for tickets, Requests and Clock reminders, unread counts on real conversations, Approve/Decline and Clock out/Keep working inside topics (NoticeActions). Opening a topic marks it read (plan decision D6); not while the tab is hidden or Catch up is open.
  • Catch up (CatchUp): one card at a time per team across every organization, Mentions first / Recent, Mark read with a 5 s Undo (sent only after the window, card hidden while the request is in flight), Open conversation, cards for unread that no team holds, phone full-screen layout.
  • Shift reminder: the popup follows the clock event's own answer (response or agreed flag), not read.
  • Header bell shows the unread count; the Start huddle button is replaced by Catch up (see docs/superchat-inbox-gaps.md for what SuperChat could not do).

Validation

  • Frontend: npx vitest run src 1136 passing; tsc --noEmit, ESLint and Prettier clean.
  • Backend: unit tests 732 passing; notifications integration tests 13 passing against a local backend. shift-end.test.ts needs METEOR_AGENDA_ENABLED=true, and timesheet-approvals.test.ts counts all request notifications in its database, so neither was meaningful on the local seeded database.
  • E2E: tests/e2e/notifications/catch-up.spec.ts (Mark read, Undo, count returns).
  • Checked in a browser at web and phone sizes and on an iPhone (Device Hub, timecore-dev). Not yet confirmed: the app-icon number after a read on another device, and the Android badge.

Known limits

  • The @ mention marker is not shown on conversation rows (SuperChat has no slot).
  • The Android badge updates with each new push but not after a read while the app is closed; that needs a store build.
  • Break reminders and other types not in the plan's table appear as "Other notifications", linking to the Notifications page.

🤖 Generated with Claude Code

Virtual topics built in the browser from the notifications already loaded,
a real app badge count, Catch up, and answering requests inside a topic.
Server code may change but no collection, field or stored data does; the
only database change is one index on notifications.
Copilot AI balanced review requested due to automatic review settings December 4, 2026 17:50
@github-actions

github-actions Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

❌ Preview Build Failed

The preview deployment failed. View logs for details.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Unresolved gaps in unread-state synchronization, visibility-based read tracking, and clock-out behavior could leave notifications and badges stale or sessions running.

9 open issues
What changed in this PR

Adds a documentation-only plan for #914 that groups existing notifications into browser-built Huddle topics without storing new data. Server-stored topics from #928 remain an optional later phase.

Changes:

  • Defines topic mappings and no-new-data constraints.
  • Plans unread counts, badge updates, inline actions and Catch up with delayed Undo.
  • Provides milestone checklists, validation steps and rollout guidance.
File Description
docs/​notification-inbox-frontend-plan.md Adds the phased implementation plan for notification topics and Catch up.

Review effort: Balanced

- [ ] `push.js` `sendApns`: replace `note.badge = 1` (~line 154) with `unreadTotal(userId)`, counted **after** the new notification is inserted.
- [ ] `push.js` `sendFcm`: set `android.notification.notificationCount` to the same total.
- [ ] Helper **`syncBadge(userId)`**: sends a **silent** APNs push (no alert, no sound, `badge: <total>`) to that user's iOS devices. Call it after `markOneRead`, `markAllRead` and `markManyRead`. Don't let a push failure fail the method.
- [ ] Android: when the frontend's unread total reaches 0, call `PushNotifications.removeAllDeliveredNotifications()` (the plugin is already installed). This ships as an **OTA**; no store build.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Not changed. You are right that Android only gets a new count with the next push, and that clearing the shade at zero needs the app to be running. A background update path on Android needs a store build, which this PR avoids; it is listed under Known limits in the description. Leaving this open for the plan's authors to decide.

- [ ] Labels: ticket topics show the ticket key and **current** title, using the tickets the app already loads for the team, and falling back to the newest notification's title (D5). Requests: "Requests". Reminders: "Clock reminders". Put the strings in a `*_TEXT` object.
- [ ] Opening a virtual topic shows its notifications as messages (title, body, time, a link to `data.url`). It has **no composer**: nobody can post into it.
- [ ] Opening a virtual topic calls `markManyRead` with its unread ids (one call). The badge, unread count and Catch up update without a reload.
- [ ] Real conversations: set SuperChat's unread badge (already supported, gaps doc row 1.16) from that conversation's unread post notifications (D3). Show an **@** marker when one is a mention. Opening the conversation calls `markManyRead` for them.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Not changed here. Marking a topic's notifications read when it opens is the plan's decision D6, and the notification list is a short feed rather than a long scroll. What I did change: nothing is read in a hidden tab or while Catch up is open. If #914 needs per-message visibility, that is a decision for the issue owner, so leaving this open.

Dharp02 and others added 13 commits December 4, 2026 13:02
One huddleUrl helper replaces the Work-tab fallbacks in clock-in and clock-out notices.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…#914)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
One NotificationInboxProvider owns the live inbox and the exact unread count;
iOS gets the count in each push and in a badge-only push after reads, Android
clears the shade at zero, and the web sets the Badging API.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ead flag (#914)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
#914)

Ticket, Requests and Clock reminders topics are built in the browser from the live
inbox; post notifications count on the conversation holding the post. Opening
either marks its notifications read in one call.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ic (#914)

Approve/Decline a timesheet change or join request, and Clock out / Keep working,
from the notification topic. The shift-reminder answer is shared with its pop-up.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
One card per conversation with unread items, Mark read held for an undo window,
a team switch and sort. Adds the 1.3.0 release note and an e2e.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… its dialog while the team changes (#914)

- A card for unread that is in no conversation here, and a pointer to the Notifications page for unread with no team
- Undo is a status bar under the card
- The dialog's open state lives in Huddle, so switching team no longer closes it
- Catch up is a full-width row under the filters, not crammed beside the search box

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…sation header (#914)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…t the newest 200 (#914)

getInbox can include older unread rows (withUnread, up to 1000); unread with no team gets its own card; the team's unplaced unread comes before it.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…s in the browser (#914)

- A failed join request lookup no longer reads as answered
- Answer buttons left-align; team buttons in Catch up wrap
- Opening a conversation marks nothing read while Catch up is open
- The phone's full-screen Catch up keeps clear of the notch

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings December 4, 2026 20:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Unresolved notification-state bugs can make unread items inaccessible, leave inboxes and badges inconsistent, and misrepresent shift-reminder responses.

25 open issues

And 5 more that still need to be addressed.

Review effort: Balanced

Comment thread meteor-backend/server/notifications.js Resolved
Comment thread meteor-backend/server/notifications.js Resolved
Comment thread meteor-backend/server/notifications.js Resolved
Comment thread src/features/huddle/CatchUp.tsx Resolved
Comment thread src/features/huddle/CatchUp.tsx Resolved
Comment thread src/pages/Huddle.tsx Resolved
Comment thread src/ui/AppLayout.tsx Resolved
…ts its badge at once (#914)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings December 4, 2026 21:11
…ions

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Unresolved notification bugs mark unseen messages as read, leave cross-device state stale, and make some unread items inaccessible.

25 open issues

And 5 more that still need to be addressed.

3 previously missed issues

In code that hasn't changed since last review

Medium severity Remove decided approval notifications from the shared inbox

src/​features/​notifications/​NoticeActions.tsx:141

Approving or rejecting deletes this request's notifications on the server (timesheet-approvals.js:305-311), but this only updates component-local request state. The shared inbox ignores DDP removals, so the deleted message and potentially its unread Catch up card remain. Remove the matching rows from the shared inbox after a successful decision.

Medium severity Remove answered join-request notifications from the shared inbox

src/​features/​notifications/​NoticeActions.tsx:206

Answering a join request deletes its notification on the server, but this handler updates only component-local state. The additions-only subscription leaves the deleted message in the shared inbox, including an unread Catch up card when answered there. Remove the row from the shared inbox after success, as the NotificationsPage handler already does.

Medium severity Include reminder responses in the DDP clock mapping

src/​lib/​api.ts:1828

The REST clock serializer supplies this field, but ddpDocToClockEvent in src/lib/ddp.ts:787–797 drops it. TeamContext uses that mapper for live updates, so an answer made on another device never updates the new pending-state checks until a REST refresh. Carry shiftReminderResponse through the DDP mapper as well.

Review effort: Balanced

Dharp02 and others added 3 commits December 4, 2026 16:22
…f view

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… are not clipped

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings December 4, 2026 21:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Comment thread src/pages/Huddle.tsx Resolved
Comment thread src/pages/Huddle.tsx Resolved
…e any team

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings December 4, 2026 21:57
… title fits

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Unresolved synchronization, pagination, and reminder-response defects can leave notification cards and badges stale, hide valid actions, and make unread items unreachable.

28 open issues

And 8 more that still need to be addressed.

1 resolved since last review

Review effort: Balanced

… reminder answers

- Refresh the iPhone badge when unread notifications are deleted (one shared helper)
- markManyRead returns each row's stored read time
- Inbox reloads when its rows and the exact count disagree (other-device reads, answered
  requests, more than one load of unread)
- Catch up keeps a card hidden while its request is pending and restores it on failure;
  button shows in Personal; ticket topic titles follow live renames
- Hidden tabs no longer mark notifications read
- Agree to Clock Out counts as an answer (server records it; client reads the flag too);
  DDP adapter maps the response; reminder status comes from its own team
- A failed request lookup is no longer shown as already answered

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings December 4, 2026 22:35
@Dharp02 Dharp02 changed the title docs: Plan for Notifications in the Huddle Inbox Without New Data (#914) feat(notifications): notification topics, real badge count and Catch up in the Huddle inbox (#914) Dec 4, 2026
Dharp02 and others added 3 commits December 4, 2026 17:40
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The notification work moves out of the 1.3.0 note into its own 1.4.0 note.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Unseen notifications are prematurely marked read, while missed cross-device updates and count-response races can leave unread indicators stale.

6 open issues
26 resolved since last review

And 6 more resolved.

Review effort: Balanced

Comment thread src/features/huddle/CatchUp.tsx Resolved
Comment thread src/pages/Huddle.tsx Outdated
Comment on lines +1151 to +1152
if (onScreen && pageVisible && !catchUpOpen && activeConversationId) {
markConversationRead(activeConversationId);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Not changed. Marking a topic's notifications read when it opens is the plan's decision D6 (see the earlier threads on this); whether #914 needs per-message visibility is for the issue owner. What does gate it: a visible tab, a conversation pane that is on screen, and Catch up not being open. Leaving this open.

Copilot AI balanced review requested due to automatic review settings December 4, 2026 22:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Comment thread src/pages/Huddle.tsx Resolved
…pane visibility

- Open notifications on the fallback card no longer marks its rows read
- Counts that answer out of order are ignored; coming back to the foreground reloads the inbox
- The REST clock event carries autoClockoutAgreed, so a shift agreed before the response was
  recorded still reads as answered; the pop-up closes when another device answers
- getInbox({ withUnread }) also returns the unanswered reminder of an open shift, however old
- Auto read waits until the conversation pane is on screen (phones keep it open behind the list)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings December 4, 2026 23:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Comment thread meteor-backend/server/notifications.js Resolved
Comment thread meteor-backend/server/push.js Resolved
Comment thread src/features/huddle/CatchUp.tsx Resolved
Comment thread src/features/huddle/CatchUp.tsx Resolved
…eyed Catch up cards

- Inbox loads are numbered, so an older answer cannot put back a deleted row
- The open-shift reminders are fetched apart from the limited inbox rows
- Every stored notification that sends no phone alert still refreshes the iPhone badge
- Catch up keeps held and in-flight cards by team and id, so same-id cards of other teams show
- Catch up says it could not load (with a retry) instead of "all caught up" after a failed load
- Auto read never sends an id again while its request is out

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings December 4, 2026 23:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Comment thread src/features/huddle/CatchUp.tsx Resolved
… out

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings December 5, 2026 00:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Comment on lines +202 to +203
note.badge = await unreadTotal(userId);
await Promise.allSettled(iosTokens.map((t) => provider.send(note, t.token)));
Comment on lines +185 to +188
if (
pendingClockEventId &&
activeClockEvent?.id === pendingClockEventId &&
shiftReminderAnswerOf(activeClockEvent)

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants