Commit afa3fb6
feat(ai): inline wowhead links across every prose section
Today's analysis card has Wowhead-tooltip chips clipped under each
finding's prose — and the rotation / cooldown / talent / gear /
comparison sections have no links at all even though their prose
frequently names spells/items/talents. This adds inline links to every
prose surface without letting the AI write actual Wowhead URLs.
How
- Prompt: every spell / item / talent reference in any prose field
(findings.detail, rotation_summary, cooldown_usage_summary,
stat_recommendations, talent_recommendations, gear_and_trinket_notes,
comparison_to_top_logs, headline, strengths) MUST be written as a
markdown link ``[Label](kind:id)``. Three kinds: ``spell``, ``item``,
``talent``. Names come from ``localized_names``, IDs from the existing
data fields. Same EN + DE wording.
- Backend: new ``_collect_talent_spell_ids`` helper resolves the
``TraitNodeEntry.ID → SpellID`` mapping from ``wow_localizations.
extras['spell_id']`` (populated by ``_import_talents``) for every
talent id that appears in the player or any reference. Stitched into
the analysis's structured output as ``_talent_spell_ids`` so the
frontend can turn ``talent:<id>`` markdown into a proper /spell/<id>
Wowhead URL — talent ids collide with old MoP spell ids, so a naïve
link would 404 onto an unrelated MoP spell.
- Frontend: new ``ProseWithLinks`` component parses
``[Label](kind:id)`` with a strict regex and substitutes SpellLink /
ItemLink / SpellLink-via-talent-map components. Renders as
``<span class="block">`` so it can sit inside ``<h2>`` (headline) and
block contexts equally well. Used in every prose surface of
``AnalysisCard``.
- Chip-list fallback: still shown on each finding when the prose has
no inline refs at all (legacy analyses). Hidden once any inline
markdown link is present in the prose, so users don't see both the
link and a redundant chip below.
Regex verified against typical AI outputs:
- single inline link → matches
- multiple per line → all matches
- legacy plain prose → no false positives
- malformed markdown → graceful (just renders as text)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 12360ba commit afa3fb6
5 files changed
Lines changed: 324 additions & 11 deletions
File tree
- backend/app/services/ai
- frontend/src
- components
- types
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
548 | 549 | | |
549 | 550 | | |
550 | 551 | | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
551 | 601 | | |
552 | 602 | | |
553 | 603 | | |
| |||
821 | 871 | | |
822 | 872 | | |
823 | 873 | | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
824 | 877 | | |
825 | 878 | | |
826 | 879 | | |
| |||
915 | 968 | | |
916 | 969 | | |
917 | 970 | | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
918 | 976 | | |
919 | 977 | | |
920 | 978 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
85 | 106 | | |
86 | 107 | | |
87 | 108 | | |
| |||
257 | 278 | | |
258 | 279 | | |
259 | 280 | | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
260 | 303 | | |
261 | 304 | | |
262 | 305 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
29 | 36 | | |
30 | 37 | | |
31 | 38 | | |
| |||
88 | 95 | | |
89 | 96 | | |
90 | 97 | | |
91 | | - | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
92 | 107 | | |
93 | 108 | | |
94 | 109 | | |
| |||
169 | 184 | | |
170 | 185 | | |
171 | 186 | | |
172 | | - | |
173 | | - | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
174 | 200 | | |
175 | 201 | | |
176 | 202 | | |
| |||
196 | 222 | | |
197 | 223 | | |
198 | 224 | | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
205 | 231 | | |
206 | 232 | | |
207 | 233 | | |
| |||
211 | 237 | | |
212 | 238 | | |
213 | 239 | | |
214 | | - | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
215 | 247 | | |
216 | 248 | | |
217 | 249 | | |
218 | 250 | | |
219 | | - | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
220 | 257 | | |
221 | 258 | | |
222 | 259 | | |
0 commit comments