Skip to content

fix(slides): detect text and line boundary violations#2050

Open
BD-ZERO wants to merge 1 commit into
mainfrom
fix/slides-lint-container-boundaries
Open

fix(slides): detect text and line boundary violations#2050
BD-ZERO wants to merge 1 commit into
mainfrom
fix/slides-lint-container-boundaries

Conversation

@BD-ZERO

@BD-ZERO BD-ZERO commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

Strengthen Slides XML linting for text boundary violations. Detect lines crossing text and text touching or extending beyond its container bottom edge, without adding a 2 px overflow buffer.

Changes

  • Add line_crosses_text warning when a line segment intersects a text box.
  • Avoid false positives when only the line’s bounding box overlaps text.
  • Add text_outside_container warning when the estimated visual text bottom touches or exceeds the container bottom.
  • Keep the 2 px tolerance only for associating text with a candidate container, not for deciding whether overflow occurred.
  • Select the smallest matching container when multiple containers overlap.
  • Add rule metadata, validation documentation, and regression tests for positive, negative, diagonal-line, exact-touch, and nested-container cases.

Test Plan

  • python3 -m unittest -v xml_text_overlap_lint_test.py — 97 tests passed
  • make unit-test
  • Verified exact boundary contact (overflow = 0) is reported
  • Verified text remaining inside the container is not reported
  • Verified a diagonal line whose bounding box overlaps text but whose segment does not intersect is not reported
  • Verified against online Slides regression cases:
    • LowWsCcaclZEP9dmgYjc3tv1nnc
    • H0M7sBDHJl4bFFd215wcDfJxnZb
    • PF7esWwISlxhkwdxqEocMKf1nlc

Related Issues

  • None

- flag lines crossing text bounds
- flag text touching or exceeding container boundaries
- use estimated glyph bounds to avoid text-box false positives
- add regression tests and validation guidance
@github-actions github-actions Bot added the size/L Large or sensitive change across domains or core paths label Jul 24, 2026
@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The slide XML lint tool adds warnings for lines crossing text and text visually overflowing candidate containers. Both detectors are integrated into per-slide issue collection, covered by geometry tests, registered in rule metadata, and documented in the validation checklist.

Changes

Slide geometry linting

Layer / File(s) Summary
Geometry detectors and validation
skills/lark-slides/scripts/xml_text_overlap_lint.py, skills/lark-slides/scripts/xml_text_overlap_lint_test.py
Adds line/text intersection detection and text/container bottom-overflow detection, with threshold, tolerance, containment, and diagonal-line test coverage.
Lint pipeline and checklist guidance
skills/lark-slides/scripts/xml_text_overlap_lint.py, skills/lark-slides/references/validation-checklist.md
Registers the two warning codes, adds both detectors to per-slide issue collection, and documents their handling in the validation checklist.

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

Possibly related PRs

Suggested reviewers: liangshuo-1

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 is concise and clearly summarizes the main slide lint boundary-violation fix.
Description check ✅ Passed The description follows the required template and includes a summary, changes, test plan, and related issues.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/slides-lint-container-boundaries

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.

@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: 2

🤖 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 `@skills/lark-slides/scripts/xml_text_overlap_lint.py`:
- Around line 1652-1655: Update the visual line filtering logic in the
overlap-lint collection to retain diagonal lines instead of excluding them based
on zero width or height. Use segment-versus-visual-text-bounds intersection when
evaluating line/text overlap, preserving the existing negative-test behavior
that rejects filled-AABB false positives while warning on actual diagonal
crossings.
- Around line 1656-1668: Update line_crosses_text in
skills/lark-slides/scripts/xml_text_overlap_lint.py (1656-1668) to preserve XML
draw order, skip lines rendered behind text, and intersect each line with
estimate_text_visual_bbox(text) instead of the full text box. In
skills/lark-slides/scripts/xml_text_overlap_lint_test.py (625-645), place the
warning line above the text and add negative cases for background lines and
glyph-whitespace-only intersections. Update
skills/lark-slides/references/validation-checklist.md (67-67) to describe
estimated glyph-bound intersections.
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 3db67f80-905b-4c80-80c6-104df22cb7d5

📥 Commits

Reviewing files that changed from the base of the PR and between f77b7ee and aa9c288.

📒 Files selected for processing (3)
  • skills/lark-slides/references/validation-checklist.md
  • skills/lark-slides/scripts/xml_text_overlap_lint.py
  • skills/lark-slides/scripts/xml_text_overlap_lint_test.py

Comment on lines +1652 to +1655
if element["kind"] == "line"
and is_visually_rendered(element)
and (element["width"] == 0 or element["height"] == 0)
]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Detect diagonal line crossings instead of excluding them.

Lines 1652–1655 discard every diagonal <line>, so a diagonal connector that actually crosses text can never warn. Use segment-vs-visual-text-bounds intersection; that avoids the filled-AABB false positive covered by the existing negative test while detecting real crossings.

🤖 Prompt for 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.

In `@skills/lark-slides/scripts/xml_text_overlap_lint.py` around lines 1652 -
1655, Update the visual line filtering logic in the overlap-lint collection to
retain diagonal lines instead of excluding them based on zero width or height.
Use segment-versus-visual-text-bounds intersection when evaluating line/text
overlap, preserving the existing negative-test behavior that rejects filled-AABB
false positives while warning on actual diagonal crossings.

Comment on lines +1656 to +1668
texts = [
element
for element in elements
if is_text_element(element)
and is_visually_rendered(element)
and has_text_content(element)
and not is_decorative_text(element)
]
for line in lines:
stroke_bbox = line_stroke_bbox(line)
for text in texts:
width = intersection_width(stroke_bbox, text)
height = intersection_height(stroke_bbox, text)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Use glyph bounds and XML draw order for line_crosses_text.

The detector intersects every line with the full declared text box and never checks stacking order. This warns for background lines rendered beneath text and for lines passing only through unused text-box whitespace, contrary to the glyph-bound/z-order objective.

  • skills/lark-slides/scripts/xml_text_overlap_lint.py#L1656-L1668: preserve XML order for lines, skip lines behind text, and intersect estimate_text_visual_bbox(text) rather than text.
  • skills/lark-slides/scripts/xml_text_overlap_lint_test.py#L625-L645: put the warning line above the text in draw order; add negative coverage for background lines and glyph-whitespace intersections.
  • skills/lark-slides/references/validation-checklist.md#L67-L67: describe intersection with estimated glyph bounds rather than declared text-box bounds.

Based on supplied PR objectives: the detector must use estimated glyph bounds and z-order.

📍 Affects 3 files
  • skills/lark-slides/scripts/xml_text_overlap_lint.py#L1656-L1668 (this comment)
  • skills/lark-slides/scripts/xml_text_overlap_lint_test.py#L625-L645
  • skills/lark-slides/references/validation-checklist.md#L67-L67
🤖 Prompt for 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.

In `@skills/lark-slides/scripts/xml_text_overlap_lint.py` around lines 1656 -
1668, Update line_crosses_text in
skills/lark-slides/scripts/xml_text_overlap_lint.py (1656-1668) to preserve XML
draw order, skip lines rendered behind text, and intersect each line with
estimate_text_visual_bbox(text) instead of the full text box. In
skills/lark-slides/scripts/xml_text_overlap_lint_test.py (625-645), place the
warning line above the text and add negative cases for background lines and
glyph-whitespace-only intersections. Update
skills/lark-slides/references/validation-checklist.md (67-67) to describe
estimated glyph-bound intersections.

@github-actions

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

npm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@aa9c288b8ddc834bd2958a7a6d12f5d363b33da3

🧩 Skill update

npx skills add larksuite/cli#fix/slides-lint-container-boundaries -y -g

@codecov

codecov Bot commented Jul 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.14%. Comparing base (e7d5ecd) to head (aa9c288).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2050   +/-   ##
=======================================
  Coverage   75.14%   75.14%           
=======================================
  Files         911      911           
  Lines       96322    96322           
=======================================
+ Hits        72381    72385    +4     
+ Misses      18372    18370    -2     
+ Partials     5569     5567    -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Labels

size/L Large or sensitive change across domains or core paths

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant