Repository navigation
fix(cli): make fragment anchor failures carry the repair - #457
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reached
Next review available in: 58 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (4)
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 |
Closes #121. When a consumer project's RenderBlocks.tsx or Pages/index.ts has drifted from the shape the text patcher expects, the install stops and the user has to finish the wiring by hand. The errors named the anchor and nothing else, so doing that meant reading the CLI source to work out which file was meant and what was supposed to go in it. Both files' four failure paths now report the resolved host path, what was missing, and the exact lines the install would have written. The path comes from hostFiles rather than the canonical constant, so a non-starter layout is told about its own file. insertLineBeforeAnchor takes the enriched message as an optional callback: localizeBlockConfigSource patches a file this CLI wrote itself, where the bare anchor message is already precise, so it keeps it. Regenerates the how-renderblocks-works blog figure, which embeds a live 11-line excerpt of applyRenderBlocksFragment as provenance evidence. Co-Authored-By: Claude Opus 5 <[email protected]>
Review caught the repair listing the block import unconditionally. When a file already carries the import but its blockComponents object or layout blocks list is unreadable, the message told the user to add it again, so pasting the repair produced a duplicate import — in the one message whose whole purpose is being safe to paste. Presence is decided against the source as it exists on disk, not the in-memory patched copy: nothing is written when a fragment fails, so an import this run would have inserted is still absent for the user. Co-Authored-By: Claude Opus 5 <[email protected]>
d006012 to
55ed02c
Compare
Closes #121.
The problem
When a consumer project's
RenderBlocks.tsxorPages/index.tshas drifted from the shape the text patcher expects, the install stops and the user has to finish the wiring by hand. That's the correct behavior — the CLI shouldn't guess at a shape it doesn't recognize. But the errors named the anchor and nothing else:So the user knows something is wrong and has no way to act on it without reading
project.tsto work out which file was meant and what was supposed to go in it.After
All four failure paths across the two files now report the file, what was missing, and the exact lines the install would have written:
Two things worth calling out:
The path comes from
hostFiles, not the canonical constant. A project on thepayload-blocks-apptarget keeps its collection atsrc/collections/Pages.ts, and telling that user aboutsrc/collections/Pages/index.tswould send them to a file that doesn't exist. There's a test pinning this specifically.insertLineBeforeAnchortakes the enriched message as an optional callback.localizeBlockConfigSourcealso uses that helper, but it patches a block config this CLI wrote itself — the shape is known and the bare anchor message is already precise there, so it keeps it. Only the consumer-file callers opt in.This stays a text-anchor patcher; no AST rewrite, as the issue scopes.
Tests
The two failure cases the issue asks for already existed but only asserted a single regex. They now assert each fact separately — file, missing anchor, import line, entry — so the wording can change without pinning a paragraph. Added the two remaining failure paths and the resolved-path case:
payload-components-fragment.int.spec.ts— RenderBlocks anchor missing, RenderBlocks object unreadable, Pages anchor missing, Pages blocks list unreadable. Each also re-asserts the file is left untouched.payload-components-target-detection.int.spec.ts— a drifted variant layout namessrc/collections/Pages.tsand not the canonical starter path.captureRejectionwent into the sharedpayload-components-assertions.tsrather than being duplicated:rejects.toThrowmatches one pattern per call, which is the wrong shape for an error asserted fact by fact.The unsupported-project-shape error is untouched, and
payload-components-target-detection.int.spec.ts:175already pins that it lists every supported shape.Verification
pnpm run test:int— 508 passed, 1 skipped, 44 files.pnpm exec tsc --noEmit— clean.pnpm lint— clean.pnpm format:check— clean.One note on the run: an earlier pass failed on
blog-visual-system.int.spec.tswith a 15s timeout in the contact-sheet renderer. That test uses ~14s of its 15s budget in isolation, so it tips over under parallel load. I ran the full suite on cleanorigin/devto attribute it and it passed there, then re-ran on this branch and it passed too — variance, not this change.Regenerated asset
public/blog/how-renderblocks-works/figure-01-renderer-dispatch.svgembeds a live 11-line excerpt ofapplyRenderBlocksFragmentas provenance evidence, anchored atconst propertyLine. Adding the failure builder shifted those lines, sopnpm blog:visuals:figuresregenerated it. The diff is 8 lines, confined to the evidence excerpt.🤖 Generated with Claude Code