pediatric-ai-scribe-v3/test
Daniel 8a6a4df121 refactor: citations are a markdown-it token, and the numbers you see are display order
The old renderer rewrote the text: it found "[n]" with regexes, renumbered
them, and swapped the result back in — which broke inside `arr[2][1]`, inside
HTML attributes, and whenever two turns disagreed about what "[3]" meant. It
also had a fallback markdown renderer of its own for when the rewrite
produced something markdown-it would not parse.

Now "[n]" is an inline rule registered on the same markdown-it instance that
renders everything else. The parser decides what is prose and what is code, a
link, or a URL, so the rule never sees "[1]" inside a code span, and it steps
aside for "[1](url)". Math is two more rules on the same parser instead of a
regex pre-pass, so "$" inside a URL is no longer math.

Identity vs display: the stored "[n]" and each card's id are the source's
identity (sourceNumber) and are never rewritten. The number a reader sees is
the order of first appearance, computed at render time from the token stream
(orderSourcesByCitation), so "one, then seven" cannot happen and a saved chat
re-opens pointing at the same cards it was saved with. Stored messages and
sources are untouched; export and the modal resolve by identity.

Translated HTML gets the same links through a TreeWalker over text nodes
(linkCitationsInHtml) rather than a regex over markup.

Deleted: renderCitationLinks, normalizeAdjacentCitationClusters, the
fallback renderer (fallbackMarkdown/renderMixedList/renderFallbackTable),
renderLatexText, CITATION_SCAN. Tests that asserted rewritten text now assert
token output; harnesses that render for real are given a parser.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Dv6sqaY6Vq3ChZHMem3cnU
2026-09-13 04:41:40 +02:00
..
account-boundary.test.js feat: retire Learning Hub 2026-09-12 20:14:20 +02:00
admin-clinical-assistant-wiring.test.js refactor: remove the embedding settings, whose only consumer is gone 2026-09-12 21:47:09 +02:00
admin-docs-toc.test.js
assistant-attachment-roundtrip.test.js refactor: citations are a markdown-it token, and the numbers you see are display order 2026-09-13 04:41:40 +02:00
assistant-autosave.test.js refactor: citations are a markdown-it token, and the numbers you see are display order 2026-09-13 04:41:40 +02:00
assistant-citation-modal.test.js refactor: citations are a markdown-it token, and the numbers you see are display order 2026-09-13 04:41:40 +02:00
assistant-citations.test.js refactor: citations are a markdown-it token, and the numbers you see are display order 2026-09-13 04:41:40 +02:00
assistant-component-css.test.js
assistant-enter-to-send.test.js feat: Enter sends in the assistant, and the person chooses 2026-09-12 18:05:36 +02:00
assistant-export-owner.test.js
assistant-image-attachments.test.js feat: sources are numbered in the order the answer cites them 2026-09-13 03:26:17 +02:00
assistant-image-done.test.js
assistant-image-intent.test.js feat: a text-only model can ask a model that can see; and the image regex is gone 2026-09-12 15:43:36 +02:00
assistant-math-mhchem.test.js refactor: citations are a markdown-it token, and the numbers you see are display order 2026-09-13 04:41:40 +02:00
assistant-message-actions.test.js refactor: citations are a markdown-it token, and the numbers you see are display order 2026-09-13 04:41:40 +02:00
assistant-mobile.test.js
assistant-saved-tables.test.js refactor: citations are a markdown-it token, and the numbers you see are display order 2026-09-13 04:41:40 +02:00
assistant-sharing-boundary.test.js
assistant-sources-cleaning.test.js
assistant-streaming-blocks.test.js refactor: citations are a markdown-it token, and the numbers you see are display order 2026-09-13 04:41:40 +02:00
assistant-translate.test.js refactor: citations are a markdown-it token, and the numbers you see are display order 2026-09-13 04:41:40 +02:00
assistant-user-markdown.test.js refactor: citations are a markdown-it token, and the numbers you see are display order 2026-09-13 04:41:40 +02:00
assistant-voice-mode.test.js
assistant-voice.test.js refactor: citations are a markdown-it token, and the numbers you see are display order 2026-09-13 04:41:40 +02:00
assistant-workspace-layout.test.js refactor: citations are a markdown-it token, and the numbers you see are display order 2026-09-13 04:41:40 +02:00
attachment-magic-bytes.test.js fix: an assistant attachment must be the image type it claims to be 2026-09-12 19:00:10 +02:00
backend-hardening.test.js feat: a revoked invitation can be deleted 2026-09-13 03:30:05 +02:00
bedside-respiratory-ventilation.test.js
build-id.test.js
calc-math.test.js
calculators-data.test.js
chat-model-discovery-filter.test.js wip: invite codes stay copyable 2026-09-12 21:00:22 +02:00
citation-ordering.test.js refactor: citations are a markdown-it token, and the numbers you see are display order 2026-09-13 04:41:40 +02:00
clinical-assistant-prompt-pool.test.js
clinical-conversation.test.js refactor: citations are a markdown-it token, and the numbers you see are display order 2026-09-13 04:41:40 +02:00
clinical-generation-options.test.js
clinical-mcp-session-lifecycle.test.js
clinical-notes-entrypoints.test.js
clinical-release-integration.test.js refactor: citations are a markdown-it token, and the numbers you see are display order 2026-09-13 04:41:40 +02:00
clinical-retrieval-title.test.js
clinical-table-preservation.test.js
corpus-retrieval.test.js feat: retire Learning Hub 2026-09-12 20:14:20 +02:00
crypto-context-binding.test.js feat: a ciphertext now only decrypts in the row it was written for 2026-09-12 21:25:24 +02:00
deck-review.test.js
deck-theme-applied.test.js fix: the theme reaches the renderer, so changing it changes the deck 2026-09-13 01:25:31 +02:00
deck-theme-sample.test.js feat: a theme is shown by a sample deck you download, not a picture 2026-09-12 22:24:05 +02:00
deck-themes.test.js feat: a theme is shown by a sample deck you download, not a picture 2026-09-12 22:24:05 +02:00
doc-spec.test.js
e2e-harness.test.js
empty-answer.test.js fix: an empty answer from the model was the one failure never caught 2026-09-12 07:41:04 +02:00
extension-transfer.test.js
frontend-prompt-env.test.js fix: My Resources uses the image model you chose for it, and says so on save 2026-09-13 02:37:57 +02:00
frontend-rendering-safety.test.js
generated-image-cache.test.js feat: an image library — every picture this account has made 2026-09-12 14:36:30 +02:00
generated-image-storage.test.js
generated-image-tools.test.js feat: retire Learning Hub 2026-09-12 20:14:20 +02:00
generated-images-ui.test.js refactor: citations are a markdown-it token, and the numbers you see are display order 2026-09-13 04:41:40 +02:00
image-fallback-chain.test.js feat: image fallback chains for every workflow, and a library worth looking at 2026-09-12 14:53:04 +02:00
image-key-collision.test.js fix: a second deck reused the first deck's pictures 2026-09-12 08:26:09 +02:00
image-library.test.js feat: image fallback chains for every workflow, and a library worth looking at 2026-09-12 14:53:04 +02:00
login-codes.test.js
mcp-shutdown.test.js
metrics.test.js
model-defaults.test.js feat: retire Learning Hub 2026-09-12 20:14:20 +02:00
model-roster-pruning.test.js feat: send a resource to your own Nextcloud, as the rendered file 2026-09-12 20:34:58 +02:00
models-changed-propagation.test.js fix: a newly added model reaches every picker, including the user-facing ones 2026-09-12 17:46:18 +02:00
module-entrypoints.test.js feat: retire Learning Hub 2026-09-12 20:14:20 +02:00
my-resources-refine.test.js feat: a theme is shown by a sample deck you download, not a picture 2026-09-12 22:24:05 +02:00
my-resources-stale-results.test.js fix: the last run's illustration no longer sits under an empty form 2026-09-12 17:43:19 +02:00
my-resources.test.js feat: retire Learning Hub 2026-09-12 20:14:20 +02:00
nextcloud-login-flow.test.js fix: "Sign in with Nextcloud" opens the sign-in page 2026-09-12 21:36:51 +02:00
notes-sanitize.test.js
openapi.test.js feat: the API describes itself, at /api/openapi.json 2026-09-13 00:52:55 +02:00
patient-takehome.test.js refactor: citations are a markdown-it token, and the numbers you see are display order 2026-09-13 04:41:40 +02:00
pe-guide-data.test.js
policy-flows.test.js refactor: rebuild the admin settings page around what each card does 2026-09-12 21:42:27 +02:00
policy-ui.test.js feat: retire Learning Hub 2026-09-12 20:14:20 +02:00
prompt-administration.test.js fix: the image settings card can save again; Learning Hub is out of the admin 2026-09-13 01:39:15 +02:00
release.test.js ci: fix the failing job, split deploy out, and drop the Android build 2026-09-12 23:30:52 +02:00
resource-to-nextcloud.test.js feat: a ciphertext now only decrypts in the row it was written for 2026-09-12 21:25:24 +02:00
review-model-vision-guard.test.js feat: a text-only model can ask a model that can see; and the image regex is gone 2026-09-12 15:43:36 +02:00
session-quiz-ed-regressions.test.js feat: retire Learning Hub 2026-09-12 20:14:20 +02:00
slide-shapes.test.js
slide-spec.test.js
stt-provider.test.js
transcription-memory-policy.test.js
tts-provider.test.js fix: each TTS model offers only the voices it will accept 2026-09-13 03:54:31 +02:00
vision-tool.test.js fix: the active library view is unmistakable, and a leading question cannot mislead the vision model 2026-09-12 16:27:21 +02:00
web-search.test.js feat: a key per search provider, and the sign-in code email looks like our mail 2026-09-13 02:30:17 +02:00
well-visit-data.test.js