You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(shared): Markdown previews keep first references with next-line destinations - #43807
Chunked Markdown previews could open a later URL when the first reference definition put its destination on the next line. The chunker now collects complete definitions in document order using bounded batches and preserves their labels, destinations, and titles. It distinguishes a separate quote-led paragraph from a continued title and keeps later duplicates from overriding a confirmed oversized title in its source chunk.
Open a Markdown file from the project files. If the project has none, add one.
Replace the file with these lines, then save it: a line [Release notes][release], a blank line, a line [release]:, a line of two spaces then https://example.com/current, a blank line, a line Notes., a blank line, a line ## Appendix, a blank line, and a line [release]: https://example.com/previous.
Open that file in the preview if it is not already open, and press Show rendered markdown.
The cause is at packages/shared/src/markdownChunks.ts:180. Ran pnpm scenarios:prove scripts/scenarios/markdown-first-multiline-definition.e2e.ts --target web with the repro scenario added: it failed in 2 of 2 runs on a clean checkout, with expect.toHaveAttribute failed in the output.
Evidence
Environment: The web app in Chromium on Linux x64, a fresh checkout.
Reviewing files that changed from the base of the PR and between 14abf45 and aacc95e.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Walkthrough
Markdown splitting now uses Remark to collect eligible link reference definitions across multiple lines. It tracks definition spans and applies the existing 16 KiB shared-definition limit. Tests cover parsing, chunking, and rendered link destinations.
Remark parsing identifies link definitions and their source spans. Run scanning recognizes definition boundaries, display-math openers, and the shared-definition size limit.
Integrate definition spans and validate rendering packages/shared/src/markdownChunks.ts, packages/shared/src/markdownChunks.test.ts, scripts/scenarios/markdown-first-multiline-definition.e2e.ts
splitMarkdown tracks parsed definition spans and omits definitions that exceed the shared limit. Unit and end-to-end tests cover multiline definitions, chunk boundaries, and rendered links.
Markdown previews now resolve multiline link reference definitions to the first definition's destination. No concrete merge-blocking risk was identified, and the change is easy to revert if needed.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the fix and its scope: Markdown previews in the shared package now keep the first link reference when its destination is on the next line. The changeset adds multiline reference-defini…
Description check
The description follows the template's sections (Problem, Change, Scope, Verification) and fills them with specific content. The Problem is covered by the reproduction steps and the expected behavior.…
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 fix and its scope: Markdown previews in the shared package now keep the first link reference when its destination is on the next line. The changeset adds multiline reference-definition parsing in markdownChunks.ts and a matching test, so the title covers the main change. It is 80 characters, slightly long but within a readable range, and it follows the conventional commit format.
Full details: Description check
Explanation
The description follows the template's sections (Problem, Change, Scope, Verification) and fills them with specific content. The Problem is covered by the reproduction steps and the expected behavior. The Change explains the bounded batch collection, label, destination, and title preservation, and the quote-led paragraph distinction. The Scope links related issues and the Verification section gives concrete commands, commit hashes, and before/after results. Minor gaps: the Problem section is not a separate heading with a one or two sentence statement, and the Scope section does not state explicitly why the change is a bug fix rather than a feature. The Verification section also lists tests run, and the 'Not in this change' section is an extra section not in the template. These gaps are non-critical, so the check passes.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.
Created the reported long Markdown document with a next-line first reference destination and a later one-line duplicate. Opened its rendered file preview and hovered Release notes. Environment on both sides: Chromium, 1280×800, light theme, fresh database, synthetic project and Replay thread.
Multiline reference labels and titles were not exercised; this scenario covers the reported next-line destination and duplicate-definition ordering across preview chunks.
The short-file variant was not separately exercised.
External-tab navigation was not clicked; the app's visible tooltip and actual anchor href were checked on both commits.
…prose once
Main's remark-based definition reader (pingdotgg#43807) already rejects invalid labels, so it replaces this branch's one-line matcher. Kept the label tests, kept definition indentation so tabbed labels keep their width, and dropped the scenario that main now passes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…estinations (pingdotgg#43807)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
(cherry picked from commit 3ebc46f)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
size:L100-499 changed lines (additions + deletions).vouch:trustedAuthor is trusted by repo permissions or the VOUCHED list.
2 participants
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.
Chunked Markdown previews could open a later URL when the first reference definition put its destination on the next line. The chunker now collects complete definitions in document order using bounded batches and preserves their labels, destinations, and titles. It distinguishes a separate quote-led paragraph from a continued title and keeps later duplicates from overriding a confirmed oversized title in its source chunk.
Related: #43647, #43654, #23503, #43673, #43709, #43711
Reproduction on main
Commit f08bafe07f (main), in the running web app:
The link opens https://example.com/previous, the address from the later one-line reference. Expected: The link opens https://example.com/current, the address from the first reference.
The cause is at
packages/shared/src/markdownChunks.ts:180. Ranpnpm scenarios:prove scripts/scenarios/markdown-first-multiline-definition.e2e.ts --target webwith the repro scenario added: it failed in 2 of 2 runs on a clean checkout, withexpect.toHaveAttribute failedin the output.Evidence
Environment: The web app in Chromium on Linux x64, a fresh checkout.
Proven: the repro fails at the test commit 91523cf9fc and passes on the head 14abf45ce3, both on main 6252f1f203.
Before the fix, recorded:
https://pub-b182a4071edc4521829926b34990540b.r2.dev/files/0f552df4-d97a-4904-a206-605fc6507b1c/before-recording.webm
After the fix, recorded:
https://pub-b182a4071edc4521829926b34990540b.r2.dev/files/0b73322e-d838-4806-b7e8-bcd646bc7e69/after-recording.webm
Outside view: a person sees it in the running web app by following the steps under Reproduction on main.
Tests
pnpm exec vp run check:changed 6252f1f203f389b9c8aa2f41b4d415324e8d1fd9passed on head.Not in this change
Who did the work
Made in T3 Code by GPT 6.2 Sol, Claude Opus 5.5, Grok 4.7 and Gemini 4 Neon