Use formatted_id and displayId in WP MentionFilter rendering#23150
Merged
akabiru merged 3 commits intoMay 12, 2026
Conversation
66961d9 to
b5badf2
Compare
3f75980 to
ecdc7d7
Compare
`MentionFilter#work_package_mention` and `LinkHandlers::WorkPackages#render_work_package_macro` render `<opce-macro-wp-quickinfo data-id="<wp.id>" data-display-id="<wp.display_id>" data-detailed="…">`. `data-id` is the work-package id (stable across renames); `data-display-id` is the user-facing identifier (semantic in semantic mode, numeric string in classic). The convention matches the wire form on `<mention>` envelopes and the `data-type="user"`/`"group"` mention convention, where `data-id` has always been the record id. The link-handler fetches the work package on the semantic-mode quickinfo branch too — the preload is already populated in semantic mode, so this is a `RequestStore` hit, not a SELECT. `MentionFilter` reads `data-id` and resolves via `find_by(id:)`. Non-numeric `data-id` (parser-emitted source-typed mentions) falls back to literal text. `WorkPackageQuickinfoMacroComponent` reads `dataset.displayId ?? dataset.id` so stored markdown produced before the attribute split keeps loading: legacy `<opce-macro-wp-quickinfo data-id="DISPLAY">` resolves via the fallback; new shape resolves via the preferred attribute. Backend specs lock the new shape end-to-end: the link handler test fixture, the in-tool-links pipeline test, and the MentionFilter spec all assert distinct `data-id` (id) and `data-display-id` (display_id) values where they diverge, and identical values where they don't.
The `## / ###` autocomplete assertions pin both `data-id` (the record id, `mentioned_work_package.id` in either mode) and `data-display-id` (what the user typed — `wp_display_id` resolving to the numeric id in classic and the identifier in semantic) on the widget DOM that appears in the editor right after a pick. The classic / semantic asymmetry now lives in the assertion itself rather than in a per-context CSS selector.
0ec9220 to
1fbe9d2
Compare
Picks up the matched upstream work in opf/commonmark-ckeditor-build#113: - Parser recognises semantic identifiers (`#PROJ-N` / `##PROJ-N` / `###PROJ-N`) and guards stored mention envelopes against re-promotion on reload. - Mention feed and caster pass record id (`dataId`) and displayed identifier (`dataDisplayId`) through to the wire as `data-id` and `data-display-id`. The sidecar emission is gated to work-package mentions; user/group mentions stay single-attribute. - `##` / `###` autocomplete picks render as quickinfo widgets in both classic and semantic modes. Autocomplete persists as a `<mention>` envelope (id survives a rename or alias drop); source-typed shorthand persists as bare markdown. - Constantises the quickinfo model element name alongside the view tag for typo safety.
b71b078 to
5df1456
Compare
9001986
into
implementation/74315-use-formatted-id-and-displayid-for-wp-text-macros
13 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ticket
Follow-up to #22976. Paired with opf/commonmark-ckeditor-build#113, which carries the matching frontend changes.
Contract
data-id= work-package id.data-display-id= user-facing identifier (PROJ-7in semantic mode, the numeric id in classic). Same convention on<mention>envelopes and<opce-macro-wp-quickinfo>. Matchesdata-type="user"/"group"mentions, which already used numericdata-id.Storage rule
One invariant across both modes:
<mention>envelope.Backend render matrix
<mention data-type="work_package" data-text="#X" data-id="<id>" data-display-id="<displayId>"><a class="issue work_package" href="/work_packages/<displayId>"><displayId></a><mention …data-text="##X">/<mention …data-text="###X"><opce-macro-wp-quickinfo data-id="<id>" data-display-id="<displayId>" data-detailed="false">/"true"#X/##X/###Xmarkdown (any mode)<a>/<opce-macro-wp-quickinfo>shapes<mention …data-id="42">legacy (nodata-display-id)find_by(id:); renders the WP's currentdisplay_idlabelChanges
MentionFilter#work_package_mentionandLinkHandlers::WorkPackages#render_work_package_macroemit bothdata-id(work-package id) anddata-display-id(display_id) on<opce-macro-wp-quickinfo>.render_for_semanticfetches the preloaded work package so the rendered macro can carry the id. The preload is already populated in semantic mode — no extra query.MentionFilterreadsdata-idas the id and resolves viafind_by(id:). Non-numericdata-id(parser-emitted source-typed mentions) falls back to literal text.WorkPackageQuickinfoMacroComponentreadsdataset.displayId ?? dataset.idso legacy stored markdown keeps working.Notes
PatternMatcherFilter.process_text_nodeswalks every text node, including text inside<a>ancestors, so the label this filter emits gets re-matched and produces a sibling anchor. Invisible in classic mode (identical href/hover-card-url, empty rendering) but doubles the DOM per mention. Semantic mode no longer triggers it after this change —formatted_id(PROJ-N) doesn't matchWP_REF_RE. A proper fix needs cross-matcher impact analysis and warrants its own ticket.Merge checklist