Commit c4d184d
authored
fix(chat): render footnote citations under a single Sources header (#987)
### What this fixes
Follow-up to #981. On the reported chat (`57493241`, dashboard) the
agentic reply showed **two headings** ("Sources" and "Footnotes"), the
**superscript citation links gave no feedback** when clicked, and every
source line stacked **several arrow icons** (the external-link arrow
plus one ↩ back-reference per citation).
### Why it happened
- The prompt told the model to write a literal "Sources" header above
its footnote definitions. remark-gfm then moves the definitions into its
own trailing section headed "Footnotes", so the model's header stays
behind as an empty duplicate.
- The renderer's "Footnotes" heading ships with an `sr-only` class,
which our Tailwind build never generates (no source file uses it), so
the heading that is meant to be invisible is visible.
- The superscripts use fragment navigation. Every message mints the same
ids (`#user-content-fn-1`), a repeated click on the same fragment does
nothing, and when the footnote list is already on screen (the exact case
in the reported chat, verified against the stored row in prod) nothing
visibly happens at all.
### What changed
- `Markdown.tsx` takes an optional footnote label and id prefix and
passes them through remark-rehype: the section heading is ours now
(visible, localised) and footnote ids are unique per message. Surfaces
that pass no label keep the default "Footnotes" heading but hidden
behind `dembrane-sr-only`, a visually-hidden class we define ourselves
in `index.css` (our own name so it cannot collide with Tailwind's
`sr-only` utility).
- `ChatHistoryMessage.tsx` passes `Sources` (per locale, `Bronnen` in
Dutch, other catalogs fall back to English until translated) plus a
per-message id prefix. A superscript click scrolls to the source line
and flashes it with the same cyan highlight the transcript page uses for
a deep-linked chunk — feedback even when the target was already on
screen, no URL rewrite, no history entries. The ↩ back-references are
dropped in agentic chat: one icon per source line.
- `agent.py` no longer asks the model for a header above the
definitions; the renderer owns the heading. Prompt test updated to pin
this.
### Already-persisted rows
Exactly one row in all of production stores the old model-written header
(verified by query): the beta test chat this was reported on. Agentic
chat is beta; the row stays as is. No migration, no render-time
compatibility code.
### Tests
- `AgenticChatPanel.test.tsx`: 15 passed, including a new case pinning
that footnote definition tags become rich transcript links.
- `agent/tests/test_agent_tools.py`: 65 passed.
- `tsc --noEmit` and `biome lint` clean; end-to-end renders verified:
one "Sources" heading in chat, hidden "Footnotes" heading on label-less
surfaces, unique prefixed ids.
Discussion:
https://dembraneworkspace.slack.com/archives/C0884QPQF6W/p17863811861843691 parent eef4fe0 commit c4d184d
23 files changed
Lines changed: 238 additions & 84 deletions
File tree
- echo
- agent
- tests
- frontend/src
- components
- chat
- common
- locales
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
319 | 319 | | |
320 | 320 | | |
321 | 321 | | |
322 | | - | |
| 322 | + | |
323 | 323 | | |
324 | 324 | | |
325 | 325 | | |
326 | | - | |
| 326 | + | |
327 | 327 | | |
328 | 328 | | |
329 | 329 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
485 | 485 | | |
486 | 486 | | |
487 | 487 | | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
488 | 491 | | |
489 | 492 | | |
490 | 493 | | |
| |||
Lines changed: 24 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
200 | | - | |
| 200 | + | |
201 | 201 | | |
202 | 202 | | |
203 | 203 | | |
| |||
650 | 650 | | |
651 | 651 | | |
652 | 652 | | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
246 | 246 | | |
247 | 247 | | |
248 | 248 | | |
249 | | - | |
| 249 | + | |
250 | 250 | | |
251 | 251 | | |
252 | 252 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
79 | 99 | | |
80 | 100 | | |
81 | 101 | | |
| |||
216 | 236 | | |
217 | 237 | | |
218 | 238 | | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
219 | 272 | | |
220 | 273 | | |
221 | 274 | | |
| |||
333 | 386 | | |
334 | 387 | | |
335 | 388 | | |
| 389 | + | |
| 390 | + | |
336 | 391 | | |
337 | 392 | | |
338 | 393 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| 17 | + | |
16 | 18 | | |
17 | 19 | | |
18 | 20 | | |
19 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
20 | 30 | | |
21 | 31 | | |
22 | 32 | | |
| |||
57 | 67 | | |
58 | 68 | | |
59 | 69 | | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
60 | 84 | | |
61 | 85 | | |
62 | 86 | | |
63 | 87 | | |
64 | 88 | | |
65 | 89 | | |
66 | 90 | | |
| 91 | + | |
67 | 92 | | |
68 | 93 | | |
69 | 94 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
101 | 117 | | |
102 | 118 | | |
103 | 119 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2528 | 2528 | | |
2529 | 2529 | | |
2530 | 2530 | | |
2531 | | - | |
| 2531 | + | |
2532 | 2532 | | |
2533 | 2533 | | |
2534 | 2534 | | |
| |||
3435 | 3435 | | |
3436 | 3436 | | |
3437 | 3437 | | |
3438 | | - | |
| 3438 | + | |
3439 | 3439 | | |
3440 | 3440 | | |
3441 | 3441 | | |
| |||
4763 | 4763 | | |
4764 | 4764 | | |
4765 | 4765 | | |
4766 | | - | |
| 4766 | + | |
4767 | 4767 | | |
4768 | 4768 | | |
4769 | 4769 | | |
| |||
6742 | 6742 | | |
6743 | 6743 | | |
6744 | 6744 | | |
6745 | | - | |
| 6745 | + | |
6746 | 6746 | | |
6747 | 6747 | | |
6748 | 6748 | | |
| |||
6752 | 6752 | | |
6753 | 6753 | | |
6754 | 6754 | | |
6755 | | - | |
| 6755 | + | |
6756 | 6756 | | |
6757 | 6757 | | |
6758 | 6758 | | |
| |||
6798 | 6798 | | |
6799 | 6799 | | |
6800 | 6800 | | |
6801 | | - | |
6802 | | - | |
| 6801 | + | |
| 6802 | + | |
6803 | 6803 | | |
6804 | 6804 | | |
6805 | 6805 | | |
| |||
8515 | 8515 | | |
8516 | 8516 | | |
8517 | 8517 | | |
8518 | | - | |
| 8518 | + | |
8519 | 8519 | | |
8520 | 8520 | | |
8521 | 8521 | | |
| |||
9372 | 9372 | | |
9373 | 9373 | | |
9374 | 9374 | | |
| 9375 | + | |
| 9376 | + | |
| 9377 | + | |
| 9378 | + | |
9375 | 9379 | | |
9376 | 9380 | | |
9377 | 9381 | | |
| |||
9866 | 9870 | | |
9867 | 9871 | | |
9868 | 9872 | | |
9869 | | - | |
| 9873 | + | |
9870 | 9874 | | |
9871 | 9875 | | |
9872 | 9876 | | |
| |||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2529 | 2529 | | |
2530 | 2530 | | |
2531 | 2531 | | |
2532 | | - | |
| 2532 | + | |
2533 | 2533 | | |
2534 | 2534 | | |
2535 | 2535 | | |
| |||
3436 | 3436 | | |
3437 | 3437 | | |
3438 | 3438 | | |
3439 | | - | |
| 3439 | + | |
3440 | 3440 | | |
3441 | 3441 | | |
3442 | 3442 | | |
| |||
4764 | 4764 | | |
4765 | 4765 | | |
4766 | 4766 | | |
4767 | | - | |
| 4767 | + | |
4768 | 4768 | | |
4769 | 4769 | | |
4770 | 4770 | | |
| |||
6743 | 6743 | | |
6744 | 6744 | | |
6745 | 6745 | | |
6746 | | - | |
| 6746 | + | |
6747 | 6747 | | |
6748 | 6748 | | |
6749 | 6749 | | |
| |||
6753 | 6753 | | |
6754 | 6754 | | |
6755 | 6755 | | |
6756 | | - | |
| 6756 | + | |
6757 | 6757 | | |
6758 | 6758 | | |
6759 | 6759 | | |
| |||
6799 | 6799 | | |
6800 | 6800 | | |
6801 | 6801 | | |
6802 | | - | |
6803 | | - | |
| 6802 | + | |
| 6803 | + | |
6804 | 6804 | | |
6805 | 6805 | | |
6806 | 6806 | | |
| |||
8516 | 8516 | | |
8517 | 8517 | | |
8518 | 8518 | | |
8519 | | - | |
| 8519 | + | |
8520 | 8520 | | |
8521 | 8521 | | |
8522 | 8522 | | |
| |||
9373 | 9373 | | |
9374 | 9374 | | |
9375 | 9375 | | |
| 9376 | + | |
| 9377 | + | |
| 9378 | + | |
| 9379 | + | |
9376 | 9380 | | |
9377 | 9381 | | |
9378 | 9382 | | |
| |||
9867 | 9871 | | |
9868 | 9872 | | |
9869 | 9873 | | |
9870 | | - | |
| 9874 | + | |
9871 | 9875 | | |
9872 | 9876 | | |
9873 | 9877 | | |
| |||
0 commit comments