Skip to content

fix(mdxish): restore correct end position for fully-consumed nested component blocks#1527

Merged
kevinports merged 5 commits into
nextfrom
fix/mdx-component-end-position-regression
Jun 29, 2026
Merged

fix(mdxish): restore correct end position for fully-consumed nested component blocks#1527
kevinports merged 5 commits into
nextfrom
fix/mdx-component-end-position-regression

Conversation

@kevinports

@kevinports kevinports commented Jun 29, 2026

Copy link
Copy Markdown
Contributor
🎫 Resolve ISSUE_ID

🎯 What does this PR do?

Fixes a regression introduced by #1519. This regression is causing test failures for the monorepo update.

positionEndingAtConsumed computes end.offset as start.offset + value.length, where value is the html node's string content after remark strips blockquote/list-item prefix characters (> , leading spaces, etc.). Inside the original source those prefixes are still present on every continuation line, so the computed offset is too small — nodeToSource slices the original source too early and the closing tag of any multi-line JSX block is dropped.

The fix is narrow: positionEndingAtConsumed is only needed when there is trailing content after the closing tag (the case #1519 targeted). When the entire html node is consumed, the original node.position is already correct and should be used directly.

Before: <Cards>\n <Card />\n (closing tag dropped)
After: <Cards>\n <Card />\n</Cards>

🧪 QA tips

  • [ ]

📸 Screenshot or Loom

@kevinports

Copy link
Copy Markdown
Contributor Author

@coderabbitai review full

@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown

@kevinports Re-running a full review of this PR now.

✅ Action performed

Full review finished.

@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 064f976c-e1b4-408c-b568-3041f34da4cd

📥 Commits

Reviewing files that changed from the base of the PR and between bac1f3f and ec3fa08.

📒 Files selected for processing (1)
  • __tests__/transformers/mdx-component-blocks.test.ts
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • readmeio/ai (manual)
  • readmeio/gitto (manual)
  • readmeio/markdown (manual)
  • readmeio/readme (manual)
💤 Files with no reviewable changes (1)
  • tests/transformers/mdx-component-blocks.test.ts

Walkthrough

The MDX component-block transformer now uses source text from file.value to compute end positions for self-contained component blocks when trailing content follows a closing tag. It adds a helper that locates the closing tag within the original source slice, and it keeps node.position unchanged when no trailing content exists. The test suite now runs the transformer with a VFile and adds regression coverage for multi-line components inside blockquotes and list items.

Warning

Review ran into problems

🔥 Problems

Linked repositories: Couldn't analyze readmeio/readme - clone failed: Clone operation failed: Cloning into '/home/jailuser/git'...
warning: templates not found in /usr/share/git-core/templates
remote: Repository not found.
fatal: repository 'https://github.com/readmeio/readme.git/' not found


Linked repositories: Couldn't analyze readmeio/ai - clone failed: Clone operation failed: Cloning into '/home/jailuser/git'...
warning: templates not found in /usr/share/git-core/templates
remote: Repository not found.
fatal: repository 'https://github.com/readmeio/ai.git/' not found


Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@processor/transform/mdxish/components/mdx-blocks.ts`:
- Around line 231-236: The trailing-content path in mdx-blocks.ts still computes
endPosition with positionEndingAtConsumed, which uses the stripped value and can
undercount original source offsets when blockquote/list prefixes were removed.
Update the branch in the component position mapping logic to account for
original-source coordinates or apply the same prefix-aware adjustment used
elsewhere in the function, using the existing symbols positionEndingAtConsumed,
contentAfterClose, and nodeToSource as guides. Also add a regression test
covering a nested component with trailing sibling content inside a blockquote or
list to verify the closing tag is not truncated.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 9eee7e2c-7b4f-4597-a2fe-a709bb5d4130

📥 Commits

Reviewing files that changed from the base of the PR and between c7cb83a and cffa2ad.

📒 Files selected for processing (2)
  • __tests__/transformers/mdx-component-blocks.test.ts
  • processor/transform/mdxish/components/mdx-blocks.ts
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • readmeio/ai (manual)
  • readmeio/gitto (manual)
  • readmeio/markdown (manual)
  • readmeio/readme (manual)

Comment thread processor/transform/mdxish/components/mdx-blocks.ts Outdated
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jun 29, 2026
@kevinports kevinports merged commit e0a276c into next Jun 29, 2026
7 of 8 checks passed
@kevinports kevinports deleted the fix/mdx-component-end-position-regression branch June 29, 2026 22:10
rafegoldberg pushed a commit that referenced this pull request Jun 29, 2026
## Version 14.10.2
### 🛠 Fixes & Updates

* **mdxish:** restore correct end position for fully-consumed nested component blocks ([#1527](#1527)) ([e0a276c](e0a276c)), closes [#1519](#1519)

<!--SKIP CI-->
@rafegoldberg

Copy link
Copy Markdown
Collaborator

This PR was released!

🚀 Changes included in v14.10.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants