Skip to content

feat(channels): add thread @-mentions and an Activity page#3158

Merged
k11kirky merged 5 commits into
mainfrom
posthog-code/channel-thread-mentions
Jul 7, 2026
Merged

feat(channels): add thread @-mentions and an Activity page#3158
k11kirky merged 5 commits into
mainfrom
posthog-code/channel-thread-mentions

Conversation

@k11kirky

@k11kirky k11kirky commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Note

Stacked on #3157 (channel/thread deep links) — review that first; this PR targets its branch and reuses its thread deep-link routing.
The mentions feed is served by a new backend index — PostHog/posthog#68853 must deploy first. Until it does, the Activity page shows an empty state (acceptable for a pre-GA surface behind the project-bluebird flag).

Problem

Channel threads (project-bluebird) are multiplayer, but there's no way to pull a teammate into one — you can't @-tag anyone, and nothing tells you a thread needs your attention.

Why

Requested for Bluebird channels: tag any member of your org in a thread and have them see the notification in a new Activity page in the top-left nav, built on the deep links from #3157.

Changes

  • @-mentions in thread composers — typing @ in a thread's "Reply in thread…" box opens a typeahead over the org's members (new /api/organizations/@current/members/ client call). Selecting one inserts an inline @[Name](email) token, so mentions ride in existing message content; older clients degrade to readable text. Mentions render as highlighted chips, with a stronger highlight when it's you.
  • Activity page — new /website/activity route plus an Activity item (with unread red-dot badge) in the channels sidebar nav. It lists thread messages across all channels that mention you, newest first; clicking one opens the thread through the channel deep-link route from feat(channels): add shareable deep links for channels and threads #3157, and each row offers the shareable thread link via the same copy-link helper.
  • The feed comes from the backend mentions index (PostHog/posthog#68853): useMentionActivity wraps exactly one getTaskMentions() query against the new GET /task_mentions/ endpoint (AGENTS.md Rule 5). An earlier iteration on this branch assembled the feed client-side by scanning every channel's task feeds and threads; that fan-out and its mention-matching helpers are deleted, and mentionActivity in core is reduced to a DTO→item mapper. ActivityView resolves desktop folder-channel ids itself (same caller-owns-the-subscription precedent as useTaskChannelMap).
  • Unread state is a persisted last-seen timestamp; opening the page clears the badge.
  • Instrumented via Channel action (mention_member, view_activity, open_mention, nav_click). Everything lives inside the Channels space, which is gated by the project-bluebird flag at the route.

How did you test this?

  • Unit tests: mention token parse/format (shared), DTO→item mapping + unseen counting (core), composer caret/query/insert helpers (ui), getTaskMentions client shape (api-client).
  • Full suites pass: ui (1245), core (1991), shared (441), api-client (66).
  • Full-repo pnpm typecheck (22/22), Biome clean, knip shows no new dead exports.
  • Not run: end-to-end in the packaged app (no desktop environment in this session), and the endpoint itself wasn't exercised against a live backend — the server half must land and deploy first.

Automatic notifications

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

Created with PostHog Code

@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown

React Doctor found 1 issue in 1 file · 1 warning.

1 warning

src/features/canvas/components/MentionComposer.tsx

Reviewed by React Doctor for commit 8c7055c.

@greptile-apps

greptile-apps Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "feat(channels): add thread @-mentions an..." | Re-trigger Greptile

Comment thread packages/ui/src/features/canvas/utils/mentionComposer.ts Outdated
Comment thread packages/ui/src/features/canvas/utils/mentionComposer.ts Outdated
@k11kirky k11kirky force-pushed the posthog-code/channel-share-links branch from d912d55 to 727d133 Compare July 7, 2026 10:00
Base automatically changed from posthog-code/channel-share-links to main July 7, 2026 10:14
@trunk-io

trunk-io Bot commented Jul 7, 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

@k11kirky k11kirky marked this pull request as ready for review July 7, 2026 11:45
@greptile-apps

greptile-apps Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Reviews (2): Last reviewed commit: "Extract folder-channel id lookup into a ..." | Re-trigger Greptile

k11kirky added 3 commits July 7, 2026 13:06
Thread composers in the Channels space get an @-mention typeahead over the
org's members; mentions are stored as inline @[Name](email) tokens in the
message content, so no message schema change is needed. A new Activity page
(nav item with unread badge in the channels sidebar) lists mentions of the
viewer across channel threads, derived client-side from the task feeds and
threads already polled, and opens the thread via the channel deep-link route.

Generated-By: PostHog Code
Task-Id: a2ff8500-aaa6-4ce0-b01a-656d3b2c3b61
…mposer

applyMention now replaces the whole @word (caret moved backward mid-query no
longer leaks typed characters into the message) and reuses an existing
following space instead of doubling it. MentionComposer drops its state-sync
effects for ref-guarded render-time adjustments and scrolls in the key
handler, clearing react-doctor's no-adjust-state-on-prop-change errors.
MentionText keys segments by character offset instead of array index.

Generated-By: PostHog Code
Task-Id: a2ff8500-aaa6-4ce0-b01a-656d3b2c3b61
Generated-By: PostHog Code
Task-Id: a2ff8500-aaa6-4ce0-b01a-656d3b2c3b61
@k11kirky k11kirky force-pushed the posthog-code/channel-thread-mentions branch from a766a20 to 56cc7ff Compare July 7, 2026 12:06
Comment thread packages/shared/src/mentions.ts Fixed
k11kirky added 2 commits July 7, 2026 13:13
CodeQL flagged js/polynomial-redos on MENTION_PATTERN: with `@` allowed on
both sides of the email separator, an unterminated token like `@[Z](!@!@…`
backtracks quadratically. Excluding `@` from both character classes makes the
separator position unambiguous and the scan linear; real emails carry exactly
one `@`, so no valid token changes meaning. Adds a malformed double-@ case and
a linear-time regression test over a 100k-char adversarial input.

Generated-By: PostHog Code
Task-Id: a2ff8500-aaa6-4ce0-b01a-656d3b2c3b61
…ementally

A branch rewind dropped the earlier "replace mention fan-out with backend
index" work, leaving useMentionActivity back on the per-channel/per-task
client-side scan it was meant to replace. This restores the backend-indexed
version (getTaskMentions against /task_mentions/, mentionActivity reduced to
a DTO-to-item mapper, ActivityView resolving desktop folder-channel ids
itself) and folds in the fix identified in review: repolls now track the
newest cached mention's created_at and ask the backend only for what's new
via since, merging (dedupe by message, capped at 300) into the existing
cache, instead of refetching the whole top page every 60s.

Generated-By: PostHog Code
Task-Id: 873b03f3-dd0b-4cee-ac3d-c3766520382a
@k11kirky k11kirky merged commit 622b5af into main Jul 7, 2026
27 of 28 checks passed
@k11kirky k11kirky deleted the posthog-code/channel-thread-mentions branch July 7, 2026 14:57
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.

3 participants