Skip to content

fix(shared): Markdown previews show bracketed prose once - #43814

Closed
StiensWout wants to merge 10 commits into
pingdotgg:mainfrom
StiensWout:wf/find-bb8b2d320313f41c73724683
Closed

StiensWout wants to merge 10 commits into
pingdotgg:mainfrom
StiensWout:wf/find-bb8b2d320313f41c73724683

Conversation

@StiensWout

Copy link
Copy Markdown
Contributor

Chunked Markdown previews could repeat ordinary text that resembled a link reference definition. The splitter now shares only single-line definitions whose labels meet the renderer’s bracket, whitespace, and length rules. Bare carriage returns inside a candidate keep it out of the shared prefix, while valid definitions with CRLF endings still resolve across chunks.

Related: #43647, #43654, #34144, #23503, #43673, #43709, #43711

Reproduction on main

Commit f08bafe07f (main), in the running web app:

  1. Start the web app and open a project.
  2. Put a Markdown file in that project whose first line is [Release [candidate]: https://example.com/releases, followed by a blank line and the line Publish the notes.
  3. Open that file from the project's files.
  4. Click Show rendered markdown.

The line [Release [candidate]: https://example.com/releases appears twice, followed by Publish the notes. Expected: The line [Release [candidate]: https://example.com/releases appears once, followed by Publish the notes.

The cause is at packages/shared/src/markdownChunks.ts:103. Ran pnpm scenarios:prove scripts/scenarios/markdown-bracketed-label-renders-once.e2e.ts --target web with the repro scenario added: it failed in 2 of 2 runs on a clean checkout, with expect.toHaveCount failed in the output.

Evidence

Environment: The web app in Chromium on Linux x64, a fresh checkout.

Proven: the repro fails at the test commit 6a27adafa1 and passes on the head 0ea50e2e98, both on main 43530f99e7.

Before After
Commit 6a27adafa1 0ea50e2e98
Result ASSERTION_FAILED: expect.toHaveCount failed passed
bracketed text line Before: bracketed text line After: bracketed text line
failure Before: failure

Before the fix, recorded:

https://pub-b182a4071edc4521829926b34990540b.r2.dev/files/eb27ba64-ec37-43b6-9be1-d74101641490/before-recording.webm

After the fix, recorded:

https://pub-b182a4071edc4521829926b34990540b.r2.dev/files/c8fa29a9-5001-4649-be0f-7cfc2845ae80/after-recording.webm

Outside view: a person sees it in the running web app by following the steps under Reproduction on main.

Tests

  • 6a27adafa1 adds the failing test, alone, before the fix.
  • pnpm exec vp run check:changed 43530f99e7ee875fc1eec09d3a6cb7ea34ce70ba passed on head.

Not in this change

  • Multiline definitions and footnotes resolve within their own chunk. This applies to multiline definitions with bare carriage returns as well as LF and CRLF.
  • Mobile uses the shared splitter. Native rendering was not exercised separately.

Who did the work

  • Repro written by GPT 6.2 Sol, in Codex
  • Outside view by Grok 4.7, in Grok
  • Duplicate check judged by Claude Opus 5.5, in Claude Code
  • Written by GPT 6.2 Sol, in Codex
  • Trimmed by Claude Opus 5.5, in Claude Code
  • Reviewed by Claude Opus 5.5, in Claude Code, and by GPT 6.2 Sol, in Codex, and by Gemini 4 Neon, in Antigravity
  • Reproduction, checks and proof run by a program on base and head, not by an agent

Made in T3 Code by GPT 6.2 Sol, Claude Opus 5.5, Grok 4.7 and Gemini 4 Neon

StiensWout and others added 7 commits November 26, 2026 23:47
Co-authored-by: GPT 6.2 Sol <codex@openai.com>
Co-authored-by: GPT 6.2 Sol <codex@openai.com>
Co-authored-by: GPT 6.2 Sol <codex@openai.com>
The label group always matches, and a label without tabs has the same width as its length, so the empty-label guard, the separate length check and the tab guard go.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: GPT 6.2 Sol <codex@openai.com>
Co-authored-by: GPT 6.2 Sol <codex@openai.com>
The heading, blockquote, fence and spaced blank-line rows reach the same interior-CR check as the continuation row.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Nov 26, 2026
@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The change preserves leading indentation when extracting Markdown link definitions. Tests cover label parsing boundaries and carriage-return handling when shared definitions are reapplied.

Changes: Markdown link-definition parsing

Layer / File(s) Summary
Definition extraction and parsing tests
packages/shared/src/markdownChunks.ts, packages/shared/src/markdownChunks.test.ts
Extraction now includes the source line’s leading indentation. Tests cover label parsing cases and verify that bare carriage returns do not alter later chunks when shared definitions are reapplied.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: saphid, juliusmarminge

Merge Risk: Minimal · up to e63d7

This change stops bracketed prose in chunked Markdown previews from appearing twice. No merge-blocking risk was found in the supplied changes.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: Markdown previews of bracketed prose no longer repeat a line that resembles a link reference definition. It uses the conventional commit form with the shared scope, an…
Description check Passed The description follows the template. It gives a problem statement with reproduction steps, explains the change in the splitter, links related issues, and includes verification with test results, befo…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: Markdown previews of bracketed prose no longer repeat a line that resembles a link reference definition. It uses the conventional commit form with the shared scope, and the changeset (markdownChunks.ts and its tests) matches it. The title is specific and concise.

Full details: Description check

Explanation

The description follows the template. It gives a problem statement with reproduction steps, explains the change in the splitter, links related issues, and includes verification with test results, before/after evidence, and a 'not in this change' section. The template asks for a Scope section that links the bug issue or explains why no issue is needed. The description links related numbers (#43647 and others) but does not state clearly that they are the bug issue, nor does it explain why no issue is needed. The Scope section is therefore only partly addressed. The description is otherwise mostly complete.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • 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 34624ae and e63d7f8.

Files selected for processing: 2

  • packages/shared/src/markdownChunks.test.ts
  • packages/shared/src/markdownChunks.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.

@juliusmarminge juliusmarminge added the takeover:in-progress A takeover lead is working on this PR label Nov 26, 2026
…prose once

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@juliusmarminge
juliusmarminge force-pushed the wf/find-bb8b2d320313f41c73724683 branch from 1814d8f to 34624ae Compare November 26, 2026 23:06
@juliusmarminge

Copy link
Copy Markdown
Member

Evidence

Opened a fresh synthetic project thread → right panel → Files → release.md → Show rendered markdown. The file contains the bracketed line once, a blank line, and “Publish the notes.” Both runs used the real web app, Replay dev provider, fresh databases, a 1280×800 viewport, and light theme.

Before After
beb24ffed8 34624ae978
Before: bracketed prose appears twice After: bracketed prose appears once
Observed two matching paragraphs Observed one matching paragraph
Before recording After recording

Reproduction scenario. scenarios:prove exited 0: fails on base and passes on head.

Not shown:

  • Bare carriage returns affecting later chunks were not exercised because the supplied reproduction contains only LF line endings.
  • Valid reference definitions resolving across chunks and other label-validation changes were not exercised by this minimal bracketed-prose reproduction.

@juliusmarminge juliusmarminge added takeover:ready Takeover done; auto-lands when gates pass and removed takeover:in-progress A takeover lead is working on this PR labels Nov 26, 2026
juliusmarminge and others added 2 commits November 26, 2026 23:24
…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>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added size:XS 0-9 changed lines (additions + deletions). and removed size:M 30-99 changed lines (additions + deletions). labels Nov 26, 2026
@juliusmarminge

Copy link
Copy Markdown
Member

The automated pipeline ran the reported steps in the real app without this change, and the problem did not appear. So it cannot show that this change fixes anything.

What was run on 3ebc46f867, the commit before this change:

Created a project containing only release.md with exactly '[Release [candidate]: https://example.com/releases\n\nPublish the notes.\n'. Created and opened a Replay thread, opened the right panel, selected Files, clicked release.md, and clicked Show rendered markdown. Captured the preview and checked that the bracketed line appeared once. Both sides displayed it once, followed by Publish the notes. The final scenario comparison exited 1 because both sides passed.

How: scenarios:prove drove the real web app with fresh isolated server state, a Replay thread, and identical 1280×800 light-theme browser views on both commits. Both final captures were opened and visually inspected.

Closing this pull request. If you can share the exact steps, what you see, and the version and platform you are on, it can be reopened.

@juliusmarminge juliusmarminge added takeover:blocked Takeover blocked; reason in the PR body and removed takeover:ready Takeover done; auto-lands when gates pass labels Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS 0-9 changed lines (additions + deletions). takeover:blocked Takeover blocked; reason in the PR body vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants