Skip to content

docs: Plan for Notification Topics, Unread Counts and Catch Up (#914) - #928

Open
Dharp02 wants to merge 1 commit into
mainfrom
docs/914-notification-topics-plan
Open

Dharp02 wants to merge 1 commit into
mainfrom
docs/914-notification-topics-plan

Conversation

@Dharp02

@Dharp02 Dharp02 commented Dec 3, 2026

Copy link
Copy Markdown
Collaborator

What

Adds docs/notification-topics-914-plan.md, an implementation plan for #914 written for a junior developer. Docs only, no code changes.

The plan in short

Every notification is delivered into a Huddle conversation topic. The server finds the topic by teamId + topicKey (for example ticket:<id>, requests:<userId>, reminders:<userId>) or creates it, so a second event for the same ticket never makes a second topic. On top of that, the plan adds:

  • Unread counts: each topic shows its unread count, and opening it marks the items read.
  • App badge: the badge shows the real unread total, not a fixed 1.
  • Catch up: a card stack with Mark read, Undo and team switching.
  • Actions in place: Approve / Decline and Clock out / Keep working work inside the topic, using the existing server methods.

Decisions already made:

  • Keep the current Huddle UI, with no filter chips.
  • Topics never close.
  • Renaming a ticket renames its topic.
  • A topic's members are the recipients of its notifications.

Milestones (one PR each)

  1. Clock-out alerts always open Huddle (warm-up fix).
  2. findOrCreateTopic with a unique teamId + topicKey index (backend only).
  3. Ticket notifications go to ticket topics, and a rename follows.
  4. Requests and Clock reminders topics, with buttons inside.
  5. Unread counts in Huddle, marked read on open.
  6. The real number on the app-icon badge, plus a silent update after reads.
  7. Catch up.
  8. Wrap up.

Open questions (marked ⚠️ in the plan, to settle before Milestone 4)

  • A1: team-join-request-approved / -declined go only to the Notifications page, since the requester isn't on the team.
  • A2: Info-only notifications for one person go to their Requests topic, with no buttons.

Prototype

https://claude.ai/artifact/Edq28kMx7c9YFEbR3CtruG (it must be shared before reviewers can open it)

Refs #914

🤖 Generated with Claude Code

Milestone plan for a junior developer: every notification is found-or-created
into a Huddle conversation topic by teamId + topicKey, unread counts per topic,
the real app-icon badge, and the Catch up view. Each milestone is one PR with
checkboxes.
Copilot AI balanced review requested due to automatic review settings December 3, 2026 19:20
@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

🚀 Preview Deployment Ready

Service URL
App https://mieweb-timehuddle-docs-914-notification-topics-plan.os.mieweb.org
API (Meteor) https://mieweb-timehuddle-docs-914-notification-topics-plan-api.os.mieweb.org

Preview auto-deletes when this PR is closed.

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

The plan omits required audience restrictions for recipient-only notices and contains unresolved routing, reminder-action, and unread-state errors.

9 open issues
What changed in this PR

Adds a documentation-only implementation plan for #914, integrating notification topics, unread counts and Catch up into Huddle.

Changes:

  • Defines topic routing, membership and in-topic actions.
  • Plans synchronized unread counts, app badges and Catch up.
  • Breaks delivery into milestones with verification steps and open decisions.
File Description
docs/​notification-topics-914-plan.md Adds the implementation roadmap, design decisions and validation checklist.

Review effort: Balanced


**Why:** Tapping a clock-out alert sometimes opens the profile Work tab instead of Huddle. `clockOutUrl` falls back to `/app/profile/<userId>?tab=work` when there's no session post.

- [ ] In `meteor-backend/server/notify-core.js`, change `clockOutUrl` so the fallback opens Huddle on the team's workday: `/app/huddle?teamId=<teamId>`, plus `&conversationId=<workdayId>` when known. Check `src/ui/ROUTING.md` for the exact param names Huddle reads.

## Milestone 2 — Find-or-create topics (backend only, no visible change)

**Files:** new `meteor-backend/server/notification-topics-core.js` (pure) + `notification-topics-core.test.js`; new `meteor-backend/server/notification-topics.js` (database); `conversations.js` (index).
- [ ] **`deliverToTopic({ teamId, type, data, recipients, actorId, text })`** in `notification-topics.js`:
1. `key = topicKeyFor(type, data, recipient)`. For ticket keys it is the same for every recipient.
2. `findOrCreateTopic(...)` once per recipient (adds each to `memberIds`).
3. Insert **one** notice post into `huddlePosts` for the event: `{ teamId, userId: actorId, conversationId, content: { text }, notice: { type, ref: { ticketId } }, ticketIds: [ticketId], createdAt }`. Use the same fields `createHuddlePost` writes. Look at the `doc` in `huddle.js` around line 932.

**Files:** `timesheet-change-requests.js`, `team-join-requests.js`, `teams.js`, `timers.js`, `notify-core.js`, `settings/notify.js`, `agenda.js`, client Huddle files.

- [ ] Switch every type in the table that has a `requests:` or `reminders:` key to `deliverToTopic`. Each personal topic gets **one** member, the recipient.
Comment on lines +188 to +189
- [ ] Shift reminder: **Clock out** / **Keep working** → `clock.respondShiftReminder` with the same `action` values the Notifications page sends today.
- [ ] After a click, show "Approved by you" / "Declined by you" / "You clocked out" / "You kept working", announced through `aria-live`.
Comment on lines +206 to +209
- [ ] Opening a conversation calls `markConversationRead`, and the count updates without a reload. Reuse the live `notifications.liveForUser` publication if it fits, and don't poll.
- [ ] The team picker menu shows each team's unread count. The Huddle nav item and the mobile tab show `total`.
- [ ] Tests for the aggregation (core function) and for "first read wins" staying true.
- [ ] Manual check: post from user B. User A sees the count go up, opens the topic, and it goes to 0 on web and phone.

- [ ] `push.js` line ~154: replace `note.badge = 1` with the user's unread total (`countDocuments({ userId, read: { $ne: true } })`), counted **after** the new notification is inserted.
- [ ] FCM: set `android.notification.notificationCount` to the same total.
- [ ] When notifications are marked read (`markOneRead`, `markAllRead`, `markConversationRead`, Catch up), send a **silent** APNs push (`contentAvailable: true`, `badge: <new total>`, no alert) to that user's iOS devices. Put this in one helper, `syncBadge(userId)`, and call it from all four.
- [ ] `push.js` line ~154: replace `note.badge = 1` with the user's unread total (`countDocuments({ userId, read: { $ne: true } })`), counted **after** the new notification is inserted.
- [ ] FCM: set `android.notification.notificationCount` to the same total.
- [ ] When notifications are marked read (`markOneRead`, `markAllRead`, `markConversationRead`, Catch up), send a **silent** APNs push (`contentAvailable: true`, `badge: <new total>`, no alert) to that user's iOS devices. Put this in one helper, `syncBadge(userId)`, and call it from all four.
- [ ] Muted teams (#784 preferences) don't create inbox rows, so they're already excluded. Verify with one mute test.

**Files:** new `src/features/huddle/CatchUp.tsx` (+ `CatchUp.test.tsx`), `src/pages/Huddle.tsx` (button), `meteor-backend/server/notifications.js` (methods).

- [ ] Method **`notifications.catchUp({ teamId, sort })`** returns topics with unread items for that team. For each: id, label, kind, unread count, mention count, newest time, and up to 3 unread posts (mentions first). Sort is `mentions` (topics with mentions first, then newest) or `recent`. Expose it.

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