Skip to content

Preserve source text and annotation metadata - #25

Open
M-Hassan-Raza wants to merge 1 commit into
TanStack:mainfrom
M-Hassan-Raza:fix/annotation-rendering
Open

M-Hassan-Raza wants to merge 1 commit into
TanStack:mainfrom
M-Hassan-Raza:fix/annotation-rendering

Conversation

@M-Hassan-Raza

@M-Hassan-Raza M-Hassan-Raza commented Oct 1, 2026 •

Copy link
Copy Markdown

Ignore non-integer, empty and reversed character ranges to prevent source duplication. Preserve own line-annotation metadata keys and avoid an intermediate line-offset array.

pnpm verify passes: 118 tests and all size/benchmark budgets. Three regression tests fail against the original source.

@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: c873ad8c-b720-4302-86b9-324261700882

📥 Commits

Reviewing files that changed from the base of the PR and between 8c2a665 and 5b6a0db.

📒 Files selected for processing (5)
  • .changeset/valid-decoration-offsets.md
  • docs/guides/annotations.md
  • docs/reference/core.md
  • src/core.ts
  • test/core.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The renderer now ignores decorations with invalid offsets, clips out-of-bounds ranges as documented, updates newline traversal, and preserves arbitrary line-decoration data keys. Tests cover invalid ranges and metadata merging.

Changes

Decoration rendering

Layer / File(s) Summary
Validate and render decorations
src/core.ts, test/core.test.ts, docs/guides/annotations.md, docs/reference/core.md, .changeset/valid-decoration-offsets.md
The renderer filters non-integer, empty, and reversed ranges, and updates newline traversal. It creates merged metadata only when decorations provide data. Tests cover invalid offsets and metadata keys; documentation and the changeset describe the behavior.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Suggested reviewers: tannerlinsley

Merge Risk: ⚪ Minimal · up to 5b6a0

This change makes the renderer ignore invalid decoration ranges and keep arbitrary line metadata keys. It has regression tests and updated docs. No merge-blocking risk is evident.

Architecture Summary

Architecture risk: 🟡 Medium · up to 5b6a0

The change affects 3 systems.

Changed systems: src, docs, test

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — src (service) was modified; 1 changed file maps to changed impact.
  • observed — docs (service) was modified; 2 changed files map to changed impact.
  • observed — test (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in docs/guides/annotations.md: The renderer description now documents integer offsets, the start < end requirement, ignoring invalid ranges, and clipping ranges that extend beyond the source.
  • observed — Modified behavior in docs/reference/core.md: The range-offset documentation now states that non-integer offsets and ranges where start is not less than end are ignored, and that out-of-bounds ranges are clipped to the source.
  • observed — Modified behavior in src/core.ts: renderTokens now filters range decorations to integer offsets with start < end. It replaces the wrapLines flag with a direct check for line numbers or line decorations, and iterates through the code by locating newline characters.
  • observed — Modified behavior in src/core.ts: The line loop now stops when no newline remains or the next line would start at the end of the code; otherwise it emits the newline and advances. This replaces the previous hasNewline-based newline emission.

Reliability and maintainability

  • inferred — Risk-relevant change factors for src: blast_radius_1; direct_dependents_1
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 2 files. (3 skipped: 3 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly describes the primary changes: preserving source text and annotation metadata.
Description check ✅ Passed The description covers the behavior changes and validation results. It includes the required Changes and Validation sections, reports 118 passing tests and size/benchmark results, but does not identif…
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 2 files. (3 skipped: 3 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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.

❤️ Share

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

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant