Convert Markdown mention links inside HTML blocks to mention chips#532
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a rich-text edge case where Markdown-style mention links written inside author-supplied HTML blocks bypass the Markdown parser and were partially converted by the fuzzy mention pass, leaving trailing literal garbage text. The change adds a dedicated resolution pass in the richtext layer so mention links are converted into a single <bc-attachment> chip before fuzzy matching runs, affecting all rich-text surfaces consistently.
Changes:
- Added a new
resolveMentionMarkdownLinkspass to convert literal[@Name](mention:SGID)/[@Name](person:ID)into mention chips when Markdown-to-HTML conversion is skipped for HTML blocks. - Updated
ResolveMentionsto run this new pass before@sgid:and fuzzy@Nameresolution. - Added regression tests covering both schemes, skip-guards (e.g.,
<code>), and the fullMarkdownToHTML → ResolveMentionspipeline.
Tip
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| internal/richtext/richtext.go | Adds regex + a new mention-resolution pass for literal Markdown mention links inside HTML blocks, and integrates it into the ResolveMentions pipeline. |
| internal/richtext/richtext_test.go | Adds regression tests validating correct chip conversion and no residual literal markdown link text in the full pipeline. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
A `[@name](mention:SGID)` or `[@name](person:ID)` mention authored inside an author-supplied HTML block rendered as a correct chip for the first name token followed by literal garbage — e.g. a valid `@Jorge` chip trailed by the literal text `Manrubia](mention:SGID)`. Root cause: when input is detected as HTML, `MarkdownToHTML` passes it through verbatim and never runs goldmark, so the Markdown mention link is not converted to an `<a href="mention:...">` anchor. `resolveMentionAnchors` therefore matched nothing, and the fuzzy `@Name` pass then matched only the first name token (its regex stops at the first space), turning that into a chip and leaving the rest of the link as literal text. Add a `resolveMentionMarkdownLinks` pass to `ResolveMentions` that recognizes the literal `[@name](mention:SGID)` / `[@name](person:ID)` form and converts it to a `<bc-attachment>` mention before the fuzzy pass runs. It reuses the existing skip guards so links inside `<code>`, existing attachments, or tags (i.e. documentation) are left untouched. Because the fix lives in the richtext layer, it covers every call site that composes rich text (comments, messages, cards, chat, check-ins, documents, todos, schedule). Reported in card 10088583638.
65853b2 to
d8451dd
Compare
There was a problem hiding this comment.
All reported issues were addressed across 2 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
|
Fixed in 1e8c291. Mention exclusion checks now precompute tag, code, pre, and bc-attachment spans once per pass, eliminating the remaining per-match prefix scans. |
Summary
A
[@Name](mention:SGID)or[@Name](person:ID)mention authored inside an author-supplied HTML block rendered as a correct chip for the first name token followed by literal garbage — e.g. a valid@Jorgechip immediately trailed by the literal textManrubia](mention:SGID).Root cause
When input is detected as HTML,
MarkdownToHTMLpasses it through verbatim and never runs goldmark, so the Markdown mention link is never converted to an<a href="mention:...">anchor.resolveMentionAnchorsmatched nothing, and the fuzzy@Namepass then matched only the first name token (its regex stops at the first space) — turning that into a chip and leaving the rest of the link as literal text.Fix
Add a
resolveMentionMarkdownLinkspass toResolveMentionsthat recognizes the literal[@Name](mention:SGID)/[@Name](person:ID)form and converts it to a<bc-attachment>mention before the fuzzy pass runs. It reuses the existing skip guards, so links inside<code>, existing attachments, or tags (i.e. documentation) are left untouched.Because the fix lives in the richtext layer, it covers every call site that composes rich text: comments, messages, cards, chat, check-ins, documents, todos, and schedule.
Validation
TestResolveMentions_MarkdownLinkInHTMLBlock(mention scheme, person scheme, and the<code>documentation guard) andTestMentionInHTMLBlock_FullPipeline(fullMarkdownToHTML → ResolveMentionssequence asserting exactly one chip and no residue).](mention:…)text; after the fix, the same input stores a single clean mention chip with no residue.bin/cipasses.Reported in card 10088583638.
Summary by cubic
Fixes Markdown mention links inside author-supplied HTML blocks so they render as a single clean mention chip across rich-text surfaces. Adds a faster exclusion index to skip tags/code/attachments and prevent partial chips.
Bug Fixes
[@Name](mention:SGID)/[@Name](person:ID)in HTML blocks to<bc-attachment>before the fuzzy pass;person:useslookupByID.<code>,<pre>, existing<bc-attachment>, or quoted attributes; unescape entities; error onperson:when no lookup is provided.Refactors
MarkdownToHTML → ResolveMentionspipeline.Written for commit 1e8c291. Summary will update on new commits.