Conversation
📝 WalkthroughWalkthroughThis pull request fixes MDX code placeholder generation and detection by changing the placeholder format from HTML-comment style delimiters to a simpler token format with a trailing suffix and truncating MD5 hashes to 16 characters. The implementation and corresponding tests are updated to reflect this format change. Changes
Estimated Code Review Effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@packages/cli/src/cli/loaders/mdx2/code-placeholder.spec.ts`:
- Around line 607-611: Replace the stale assertion that checks for the old block
comment placeholder with one that asserts the new placeholder format is not
present: update the second expect that currently reads against /\{\/\*
CODE_PLACEHOLDER_[0-9a-f]+\s*\*\/\}/ to instead assert
pushedResult.not.toMatch(/CODE_PLACEHOLDER_[0-9a-f]+_END/); locate the assertion
referencing pushedResult in code-placeholder.spec.ts and swap the regex
accordingly so the test verifies the new placeholder format.
- Around line 641-645: The test contains a stale assertion checking for the old
block-comment format (/\{\/\* CODE_PLACEHOLDER_[0-9a-f]+\s*\*\/\}/) against the
variable pushedResult; replace that assertion with one that ensures the new
end-marker format is not present, e.g. change the second expect to verify
pushedResult does not match /CODE_PLACEHOLDER_[0-9a-f]+_END/ so the test asserts
absence of the new CODE_PLACEHOLDER_<hash>_END pattern (refer to pushedResult
and the spec in code-placeholder.spec.ts).
🧹 Nitpick comments (1)
packages/cli/src/cli/loaders/mdx2/code-placeholder.spec.ts (1)
872-874: Stale comment referencing old{/* */}format.The comment on line 874 still references the old
{/* */}placeholder format. Should be updated to reflect the new_ENDsuffix format.
| expect(pushedResult).not.toMatch( | ||
| /\{\/\* INLINE_CODE_PLACEHOLDER_[0-9a-f]+\s*\*\/\}/, | ||
| /INLINE_CODE_PLACEHOLDER_[0-9a-f]+_END/, | ||
| ); | ||
| expect(pushedResult).not.toMatch(/\{\/\* CODE_PLACEHOLDER_[0-9a-f]+\s*\*\/\}/); | ||
|
|
There was a problem hiding this comment.
Stale assertion checking old placeholder format that no longer exists.
Line 610 still checks for the old {/* CODE_PLACEHOLDER_... */} format. Since code-block placeholders now use CODE_PLACEHOLDER_<hash>_END, this assertion will always pass trivially and doesn't verify anything useful. It should check the new format instead:
Suggested fix
expect(pushedResult).not.toMatch(
/INLINE_CODE_PLACEHOLDER_[0-9a-f]+_END/,
);
- expect(pushedResult).not.toMatch(/\{\/\* CODE_PLACEHOLDER_[0-9a-f]+\s*\*\/\}/);
+ expect(pushedResult).not.toMatch(/CODE_PLACEHOLDER_[0-9a-f]+_END/);📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| expect(pushedResult).not.toMatch( | |
| /\{\/\* INLINE_CODE_PLACEHOLDER_[0-9a-f]+\s*\*\/\}/, | |
| /INLINE_CODE_PLACEHOLDER_[0-9a-f]+_END/, | |
| ); | |
| expect(pushedResult).not.toMatch(/\{\/\* CODE_PLACEHOLDER_[0-9a-f]+\s*\*\/\}/); | |
| expect(pushedResult).not.toMatch( | |
| /INLINE_CODE_PLACEHOLDER_[0-9a-f]+_END/, | |
| ); | |
| expect(pushedResult).not.toMatch(/CODE_PLACEHOLDER_[0-9a-f]+_END/); |
🤖 Prompt for AI Agents
In `@packages/cli/src/cli/loaders/mdx2/code-placeholder.spec.ts` around lines 607
- 611, Replace the stale assertion that checks for the old block comment
placeholder with one that asserts the new placeholder format is not present:
update the second expect that currently reads against /\{\/\*
CODE_PLACEHOLDER_[0-9a-f]+\s*\*\/\}/ to instead assert
pushedResult.not.toMatch(/CODE_PLACEHOLDER_[0-9a-f]+_END/); locate the assertion
referencing pushedResult in code-placeholder.spec.ts and swap the regex
accordingly so the test verifies the new placeholder format.
| expect(pushedResult).not.toMatch( | ||
| /\{\/\* INLINE_CODE_PLACEHOLDER_[0-9a-f]+\s*\*\/\}/, | ||
| /INLINE_CODE_PLACEHOLDER_[0-9a-f]+_END/, | ||
| ); | ||
| expect(pushedResult).not.toMatch(/\{\/\* CODE_PLACEHOLDER_[0-9a-f]+\s*\*\/\}/); | ||
| expect(pushedResult).toContain("`الحصول_على_البيانات()`"); |
There was a problem hiding this comment.
Same stale old-format assertion as above.
Line 644 has the same issue — checking for the defunct {/* ... */} format instead of the new CODE_PLACEHOLDER_<hash>_END format.
Suggested fix
expect(pushedResult).not.toMatch(
/INLINE_CODE_PLACEHOLDER_[0-9a-f]+_END/,
);
- expect(pushedResult).not.toMatch(/\{\/\* CODE_PLACEHOLDER_[0-9a-f]+\s*\*\/\}/);
+ expect(pushedResult).not.toMatch(/CODE_PLACEHOLDER_[0-9a-f]+_END/);📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| expect(pushedResult).not.toMatch( | |
| /\{\/\* INLINE_CODE_PLACEHOLDER_[0-9a-f]+\s*\*\/\}/, | |
| /INLINE_CODE_PLACEHOLDER_[0-9a-f]+_END/, | |
| ); | |
| expect(pushedResult).not.toMatch(/\{\/\* CODE_PLACEHOLDER_[0-9a-f]+\s*\*\/\}/); | |
| expect(pushedResult).toContain("`الحصول_على_البيانات()`"); | |
| expect(pushedResult).not.toMatch( | |
| /INLINE_CODE_PLACEHOLDER_[0-9a-f]+_END/, | |
| ); | |
| expect(pushedResult).not.toMatch(/CODE_PLACEHOLDER_[0-9a-f]+_END/); | |
| expect(pushedResult).toContain("`الحصول_على_البيانات()`"); |
🤖 Prompt for AI Agents
In `@packages/cli/src/cli/loaders/mdx2/code-placeholder.spec.ts` around lines 641
- 645, The test contains a stale assertion checking for the old block-comment
format (/\{\/\* CODE_PLACEHOLDER_[0-9a-f]+\s*\*\/\}/) against the variable
pushedResult; replace that assertion with one that ensures the new end-marker
format is not present, e.g. change the second expect to verify pushedResult does
not match /CODE_PLACEHOLDER_[0-9a-f]+_END/ so the test asserts absence of the
new CODE_PLACEHOLDER_<hash>_END pattern (refer to pushedResult and the spec in
code-placeholder.spec.ts).
Summary by CodeRabbit