jatui

MentionParser

@-mention parsing — per-type URL registry, agent mentions, helper queries

Per-type URL registry

registerMentionType(type, generator) gives each mention type its own routing — the single app-wide setMentionUrlGenerator cannot express per-type routes. Resolution per mention: an explicit generator argument > the registered type generator > the app-wide default.

registerMentionType('agent', () => '/admin/settings/agent')
registerMentionType('task', (_t, id) => '/tasks/' + encodeURIComponent(id))

Rendered output

Ping @Jane and @Ops Agent about @Fix login, then @Jane for the follow-up.
MentionResolved route
@Janeuser → /profile/u1
@Ops Agentagent → /admin/settings/agent
@Fix logintask → /tasks/t-42

Agent mentions

extractAgentMentions(content) pulls just the type='agent' mentions — apps route them to their admin agent settings page.

Display nameAgent idRoute
@Ops Agentops-7/admin/settings/agent

Helper queries

Quick reads over message content: hasMentions, countMentions, getMentionedUserIds (unique user ids in first-appearance order), and getUniqueMentionsByType (deduped by type+id, optional type filter).

hasMentions(SAMPLE)            → true
countMentions(SAMPLE)          → 4
getMentionedUserIds(SAMPLE)    → [u1]
getUniqueMentionsByType(SAMPLE)→ 3 unique of 4 total
getUniqueMentionsByType(SAMPLE, 'agent') → 1