Skip to content

Allow scheduled messages to mention people - #240

Merged
NinjaLikesCheez merged 5 commits into
mainfrom
cursor/schedule-mentions-239
Nov 26, 2026
Merged

NinjaLikesCheez merged 5 commits into
mainfrom
cursor/schedule-mentions-239

Conversation

@NinjaLikesCheez

Copy link
Copy Markdown
Contributor

Closes #239

Summary

This PR implements the feature requested in Sentry feedback PIXEL-2B to allow scheduled messages to mention and ping specific people.

Changes

Core functionality

  • New mention detection module (src/core/mentions.ts): Detects @everyone, @here, role mentions (<@&id>), and user mentions (<@id>) in post content
  • Permission-based validation:
    • User and role mentions are allowed for anyone with the schedule-posts capability (member tier)
    • @everyone/@here requires the Mention Everyone Discord permission in the target channel
  • Re-check at post time: The scheduling user's permissions are re-validated when the post actually goes out, ensuring they still have the required access

UI changes

  • Removed the "Pings: on/off" toggle from the schedule draft panel
  • Mentions are now automatically detected from the content the user types
  • The draft panel shows clear error messages when invalid mentions are detected

Technical implementation

  • Removed mentions: boolean field from ChannelPost type
  • Updated ChannelPoster to accept creator reference and re-fetch permissions at post time
  • Updated runner to pass creator's Discord ID when posting
  • Applied to all post types: messages, polls, and attendance polls

Testing

  • All existing tests updated and passing (145 test files)
  • Added comprehensive tests for mention detection and permission checking
  • Tests cover user mentions, role mentions, and @everyone/@here with various permission combinations

Migration notes

  • Existing schedules continue to work (mentions are detected from stored content)
  • No database migration needed
  • Behavior change: users who could previously only schedule with "pings off" can now use user/role mentions
Open in Web Open in Cursor 

cursoragent and others added 5 commits November 25, 2026 17:27
…sions

Closes #239

- Remove boolean mentions field from ChannelPost
- Add mention detection for @everyone/@here, roles, and users
- Check permissions for each mention type at schedule time
- Re-check permissions at post time using creator's Discord ID
- User and role mentions allowed for anyone with schedule-posts capability
- @everyone/@here requires Mention Everyone permission
- Remove 'Pings: on/off' toggle from schedule draft UI
- Apply to all post types (messages, polls, attendance polls)

The bot now detects what mention types are present in the content and
validates them against the scheduling user's permissions in the target
channel. At post time, permissions are re-checked to ensure the creator
still has the required access.

Co-authored-by: NinjaLikesCheez <NinjaLikesCheez@users.noreply.github.com>
Co-authored-by: NinjaLikesCheez <NinjaLikesCheez@users.noreply.github.com>
Co-authored-by: NinjaLikesCheez <NinjaLikesCheez@users.noreply.github.com>
- Remove mentions: false from all message posts
- Fix channel-poster type narrowing for send/messages
- Fix toDiscordMessage test call signature
- Run biome format on all changed files

Co-authored-by: NinjaLikesCheez <NinjaLikesCheez@users.noreply.github.com>
…rom schema

- Restore interpolate regex (was broken by sed removing spaces in {})
- Restore JWT token regex in scrub.ts (was broken by sed changing {8,} to {8})
- Restore info-content placeholder regex
- Remove mentions: z.boolean() from ChannelPost schema
- Fix YAML syntax in test fixtures (add space before closing brace)

Co-authored-by: NinjaLikesCheez <NinjaLikesCheez@users.noreply.github.com>
@NinjaLikesCheez
NinjaLikesCheez marked this pull request as ready for review November 25, 2026 17:40
Comment thread src/services/schedules.ts
Comment on lines 99 to 104
z.strictObject({
kind: z.literal("message"),
text: z.string().min(1).max(MAX_MESSAGE_LENGTH),
mentions: z.boolean(),
}),
z.strictObject({
kind: z.literal("poll"),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: Removing mentions from a z.strictObject schema causes schema validation failure on existing persisted schedule YAML files containing legacy mentions keys.
Severity: CRITICAL

Suggested Fix

Allow legacy mentions keys in the schema and strip them (e.g. by making mentions: z.boolean().optional() or using .passthrough()/.strip()), or add a migration step before validation in ScheduleStore.#load().

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: src/services/schedules.ts#L99-L104

Potential issue: Removing `mentions: z.boolean()` from the message variant of
`postSchema` causes validation to fail on existing schedules stored in
`data/schedules.yaml`. Because `postSchema` uses `z.strictObject`, any legacy schedule
with a `mentions` key triggers an unrecognized key error during `ScheduleStore.#load()`.
This marks the store with a problem state, preventing all schedules from executing or
being edited until the file is manually corrected.

Did we get this right? 👍 / 👎 to inform future reviews.

@NinjaLikesCheez
NinjaLikesCheez merged commit 10bbb44 into main Nov 26, 2026
6 checks passed
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.

Schedules: let scheduled messages mention (and ping) specific people

2 participants