Skip to content

feat(notifications): native OS notifications for @-mentions - #4019

Draft
adboio wants to merge 4 commits into
mainfrom
posthog-code/mention-os-notifications
Draft

feat(notifications): native OS notifications for @-mentions#4019
adboio wants to merge 4 commits into
mainfrom
posthog-code/mention-os-notifications

Conversation

@adboio

@adboio adboio commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Problem

When a teammate @-mentions you in a task thread, nothing surfaces outside the Activity feed — and there, one-row-per-task projection means the mention row is often overwritten by the next agent event before it's seen. Agent events (completed, needs input) already fire native desktop notifications; human mentions, the highest-signal event in a thread, do not.

Why

Raised while dogfooding channels: mentions from teammates were effectively invisible unless you happened to be watching the Activity page at the right moment.

Changes

  • New MentionNotificationsContribution watches the task-mentions query the channels UI already polls (useMentionActivity) and dispatches new mentions through the existing NotificationBus, so mentions get the same tiering (suppressed while viewing the task / toast while focused / native + sound otherwise), notification settings gating, and click-through-to-task as agent activity. No new fetch path — one poll, one source of truth; notifications live where the spaces layout lives.
  • Pure watch-state logic (baselineMentionWatch / advanceMentionWatch) lives in @posthog/core/canvas/mentionNotifications: the first page after boot or login baselines silently (the backlog isn't news), updates dedupe by message id, and a batch of several new mentions collapses into a single notification — one banner, one sound (same-task batches keep click-through to the task; mixed-task batches fall back to a count), and the auth-scoped query's removal on logout resets the baseline so another account's backlog stays silent.

How did you test this?

  • Unit tests for the core watch-state (baseline, ordering, dedupe, watermark, cap) and the contribution (silent first page, per-mention dispatch shape, no re-notify on refresh, burst summary, logout re-baseline, auth-scoped meta gating) — 14 tests, all passing.
  • Ran the existing notifications and canvas suites — passing.
  • Biome clean; biome lint packages/core shows zero noRestrictedImports.

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

Created with PostHog Code

Poll the task-mentions index from a boot contribution and route new
mentions of the current user through the NotificationBus, so they get
the same suppression, settings gating, completion sound, and
click-through-to-task behavior as agent activity notifications.

Generated-By: PostHog Code
Task-Id: d77f2cfe-cdea-4bc9-af8a-1d3eea39da59
@trunk-io

trunk-io Bot commented Jul 30, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit 61d5db0.

adboio added 3 commits July 30, 2026 17:11
… query cache

Watch the channels UI's existing task-mentions query instead of running a
second poll: one fetch path, one source of truth. Notifications now live
where the spaces layout lives, which is the surface the product is
converging on.

Generated-By: PostHog Code
Task-Id: d77f2cfe-cdea-4bc9-af8a-1d3eea39da59
NotificationDescriptor gains muteSound (skip the completion sound and
native chime) and notify() reports the routed channel, so the mention
batch mutes every notification after its first delivered one — three
mentions in a poll window ring once instead of three times. A
suppressed mention (its task is being viewed) hands the sound to the
next one.

Generated-By: PostHog Code
Task-Id: d77f2cfe-cdea-4bc9-af8a-1d3eea39da59
A batch of new mentions is now a single notification — one banner, one
sound — instead of individual notifications sharing a sound. Same-task
batches keep click-through ("Charles mentioned you 2 times in ..."),
mixed-task batches fall back to a count. Reverts the muteSound bus
machinery, which this makes unnecessary.

Generated-By: PostHog Code
Task-Id: d77f2cfe-cdea-4bc9-af8a-1d3eea39da59

adboio commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

CI note: the visual-regression failure here is not this PR — all 187 story screenshots pass. The job dies in "Install Visual Review CLI" because products/visual_review/cli's lockfile in PostHog/posthog went out of sync with the sharp bump (PostHog/posthog#74334, ~21:46 UTC); every PostHog/code branch run since ~21:48 fails the same way. Fix: PostHog/posthog#75785. Re-run this job once that merges.

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.

1 participant