Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): keep escaped-bracket footnotes across PR attachments #47870

Mergedsaphid(GitHub profile, opens in a new tab)merged 3 commits intomain fromrefs/pull/47870/headmerged by juliusmarminge View on GitHub

Problem

In PR descriptions and comments rendered through PullRequestMarkdown → splitPullRequestBody → wordsHast, a footnote whose label contains an escaped square bracket (such as [^a\[b] or [^a\]b]) stops linking and its note disappears when a lifted video sits between the citation and definition. markdownFootnoteLabels in apps/web/src/markdown/wordsHast.ts prefilters candidate labels with /\[\^([^\s[\]]+)\]:/g, which excludes all square brackets including escaped ones that @pierre/words accepts.

Deterministic repro on origin/main (baf8956263d5dfcafb3ce6396144a8edde347389):

  • Fixture: pass "See[^a\\[b].\n\nhttps://github.com/user-attachments/assets/a.mp4\n\n[^a\\[b]: note" (or with a\\]b) to splitPullRequestBody, then render its Markdown segments with wordsHast.
  • Command: vp test run apps/web/src/components/pullRequest/pullRequestMarkdown.logic.test.ts -t "keeps a footnote with an"
  • Observed on origin/main: splitPullRequestBody returns segments with footnotes: undefined and no trailing "only" segment; rendering the citation segment emits zero dataFootnoteRef anchors and the note disappears.
  • Expected: splitPullRequestBody installs footnote stubs (footnotes: "omit") and appends the trailing "only" footnote segment so the citation links to #user-content-fn-1 and the note renders, matching the unsplit body.

Change

Update the candidate label scan in markdownFootnoteLabels (apps/web/src/markdown/wordsHast.ts) from /\[\^([^\s[\]]+)\]:/g to /\[\^((?:[^\s\\[\]]|\\.)+)\]:/g so escaped characters (including \[, \], and \\) are consumed atomically while preserving the authored escapes and keeping Words' lookup as the validity check. Added regression cases for escaped opening brackets, escaped closing brackets, and escaped trailing backslashes across a lifted video in apps/web/src/components/pullRequest/pullRequestMarkdown.logic.test.ts.

This covers both Web and Electron PR detail views, which share PullRequestMarkdown and wordsHast (mobile does not split footnotes across attachments).

Scope

Small fix for an obvious bug; no issue needed under CONTRIBUTING.md.

Verification

  • Base failure (baf8956263d5dfcafb3ce6396144a8edde347389): vp test run apps/web/src/components/pullRequest/pullRequestMarkdown.logic.test.ts -t "keeps a footnote with an" failed on both escaped opening bracket and escaped closing bracket (expected [ [ 'markdown', undefined ], …(2) ] to deeply equal [ [ 'markdown', 'omit' ], …(3) ]).
  • Head pass (27f51bd21e0064e5a063289e2a99caa4d5007511): the same targeted command passed (3/3 cases), and vp run check:changed exited 0 (format, lint, knip, typecheck on 2 packages, test on 2 files / 121 tests, react compiler on 1 file).
  • Before/after transcript: https://gist.github.com/saphid/f9c9ea7e03843a1fde84259f1eb9e881
  • Not shown: live browser/Electron UI screenshot of a rendered PR detail view (the bug is purely in markdownFootnoteLabels's regex prefilter and is deterministically verified through splitPullRequestBody + wordsHast).

Authored by Gemini 4 Neon (Antigravity); reviewed by GPT-6.2 Sol (Codex).

Not shown

  • apps/web/src/components/pullRequest/PullRequestSummaryTab.tsx:1122 — The transcript is unit-level only; add before/after screenshots of a rendered PR description with an uploaded video, showing the literal citation and missing note on base versus the link and visible note on head.
  • apps/web/src/components/pullRequest/pullRequestMarkdown.logic.test.ts:121 — The test command is deterministic but not a scenarios:prove repro. Add a real-app fixture that seeds the PR description, opens the PR detail view, and asserts the citation href and matching note target.
  • apps/web/src/markdown/wordsHast.ts:1454 — The gist shows targeted base/head results, not the reported check:changed run. Attach its exit-0 transcript with the reviewed HEAD SHA if independent verification is needed.
  • apps/mobile/src/features/pull-requests/PullRequestMarkdown.tsx:128 — Mobile does split the body around attachments; it uses a separate native renderer without this footnote-reassembly path. Clarify the scope sentence accordingly.
    1. Pushede20daa2

    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    3. Evidence

      Steps on both commits: seed the Footnotes project; open scenario/footnotes#7; render See[^a\\[b]., a blank line, a local placeholder video attachment, a blank line, and [^a\\[b]: note; wait for See; capture; assert one a[data-footnote-ref] and a footnotes section containing note.

      Base 4fec70c4baHead e20daa226d
      Result❌ Failed: a[data-footnote-ref] count was 0; the citation stayed literal and the note was absent.✅ Passed: one numbered footnote link rendered and 1. note remained below the video.
      CaptureBase: escaped footnote after videoHead: escaped footnote after video

      Driver: escaped-footnote-survives-pr-video.e2e.ts

    4. juliusmarminge added labelstakeover:ready

    5. juliusmarminge removed labelstakeover:in-progress

    6. juliusmarminge merged this3067c49

    7. juliusmarminge closed this

    8. juliusmarminge removed labelstakeover:ready

Sign in to join this conversation.