GeezerVison is showing github.com — fix(shared): chunked Markdown links keep the first definition’s destination by saphid · Pull Request #43692 · pingdotgg/t3code
Conversation
Problem
A reference link in a chunked Markdown file preview can open a different destination than the same link in the original document. Appending shared definitions also inserts synthetic text into an unclosed code fence.
Deterministic repro on origin/main (44a533378653164dea96435e23c8ea27efaffedb):
const md = '[id]: /first\n\n' + 'x'.repeat(4100) + '\n\n# Next\n[id]: /later\n\n[id]';
const { chunks, definitions } = splitMarkdown(md);
// Compare the Words-rendered href for md with:
withMarkdownDefinitions(chunks[1].text, definitions);
Import the helpers from packages/shared/src/markdownChunks.ts and render using the bundled @pierre/words WASM. Observed: the whole document links to /first, but the second chunk links to /later. Expected: both link to /first. A second fixture, '[ref]: /dst\n\n```text\nshown', should render only shown inside its code block; base also displays [ref]: /dst.
The runtime transcript includes the complete executable script and base/head commands. Test-only patch repro: vp test run packages/shared/src/markdownChunks.test.ts -t 'keeps the first document|keeps shared definitions'.
Change
Prepend shared link definitions in document order after masking leading frontmatter. Subtract the synthetic prefix from web checkbox offsets; raw chunks remain unchanged for copying. The shared helper covers web, Electron, and mobile file previews; native preview has no source-offset checkbox editing path.
Scope
Small fix for an obvious bug; no issue needed under CONTRIBUTING.md.
Verification
- Base: both focused regressions fail with the incorrect href and extra fenced code; exact assertions are in the transcript.
- Head: 3 consecutive runs of
vp test run packages/shared/src/markdownChunks.test.ts pass 14/14 tests after rebasing onto d6061ec8ad2fa71fe54b3e306e0b8e283ca33bac (which adds one upstream case), including frontmatter masking, leading BOM headings/tasks/quotes without frontmatter, and checkbox source offsets with CRLF and Unicode.
vp run check:changed: exit 0 (format, lint, knip, affected typechecks/tests, React Compiler).
- Bundled Words WASM runtime evidence: href
/later → /first, fenced code contains only shown, checkbox offset stays 44, and raw chunks reconstruct the original source.
- Cross-provider review: Gemini 4 Neon found a BOM regression in the initial fix. It was reproduced, corrected in one pass by preserving the BOM at index zero, and rechecked with the bundled Words runtime and the extended regression. The final independent recheck returned
APPROVE_FOR_PR.
- Not shown: real-app browser screenshots/scenario, Electron shell, native iOS/Android runtime, external-link navigation, checkbox persistence through the server, remote/tunnel connections, or the full repository suite. This is parser/runtime proof; no dev server was launched by the delegated implementation task.
Authored by GPT-6.1 Sol (Codex); reviewed by Gemini 4 Neon (Antigravity).
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
coderabbitai
Bot
commented
Nov 26, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|

No actionable comments were generated in the recent review.
Walkthrough
-
This change prepends shared Markdown definitions to chunk content, preserves a leading BOM, and adjusts task-marker offsets for the added prefix. Tests cover definition resolution, frontmatter, source offsets, rendered output, and unclosed code fences.
Changes: Chunked Markdown definitions
| Layer / File(s) |
Summary |
Definition prefix and source offsets packages/shared/src/markdownChunks.ts, apps/web/src/components/files/ChunkedMarkdown.tsx, packages/shared/src/markdownChunks.test.ts |
withMarkdownDefinitions masks frontmatter and prepends definitions, placing them after a leading BOM when present. Chunked rendering adjusts task-marker offsets for the prefix. Tests cover shared definitions, source offsets, rendered output, and unclosed code fences. |
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Suggested reviewers: marve10s, juliusmarminge
Merge Risk: Minimal · up to 72d50
-
This change makes chunked Markdown previews resolve links to the first definition and stops synthetic definition text from leaking into unclosed code fences. The change is small and covered by focused tests. No actionable merge-blocking risk was found.
Pre-merge checks: 4
-
| Check name |
Status |
Explanation |
| Title check |
 |
The title names the main change: chunked Markdown links keep the first definition's destination, with the conventional fix(shared) prefix. The changeset prepends shared link definitions in document or… |
| Description check |
 |
The description follows the template sections: Problem, Change, Scope, and Verification. The Problem section gives the bug, a deterministic reproduction, and expected behavior. The Change section expl… |
| Linked Issues check |
 |
Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check |
 |
Check skipped because no linked issues were found for this pull request. |
Full details: Title check
-
Explanation
The title names the main change: chunked Markdown links keep the first definition's destination, with the conventional fix(shared) prefix. The changeset prepends shared link definitions in document order so reference links in later chunks resolve to the first definition. The title is 75 characters, which is long but within a single readable sentence.
Full details: Description check
-
Explanation
The description follows the template sections: Problem, Change, Scope, and Verification. The Problem section gives the bug, a deterministic reproduction, and expected behavior. The Change section explains the prepend-after-frontmatter approach and the checkbox offset adjustment. The Scope section states this is a small bug fix and why no issue is needed. The Verification section lists focused test runs, the repo check command, and the runtime evidence. It also lists what was not checked, which matches the template's request. The description keeps the template's optional agent attribution line, as the template asks.
Finishing Touches
-
Generate unit tests (beta)
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info
-
Run configuration
-
Commits
-
Reviewing files that changed from the base of the PR and between 3a495a7 and 72d50de.
Files selected for processing: 1
-
packages/shared/src/markdownChunks.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Evidence
Real web app, Chromium, 1280×800, light theme, fresh synthetic state on each commit. Opened the right panel → Files and rendered the reported fence.md and dup.md. The red link annotation displays the actual DOM href. Also toggled a task in a later chunk and back; only its intended source marker changed, and the original file was restored on both commits.
Proven: the scenario fails on base and passes on head; scenarios:prove exited 0.
Scenario and synthetic seed
Not shown:
- Frontmatter and BOM preservation were not exercised; the reported reproductions contain neither.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Labels
size:S
10-29 changed lines (additions + deletions).
vouch:trusted
Author is trusted by repo permissions or the VOUCHED list.
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.
|