Skip to content

fix(slides): detect visual elements outside canvas#1950

Merged
ethan-zhx merged 1 commit into
mainfrom
feat/lint_outside_canvas
Jul 19, 2026
Merged

fix(slides): detect visual elements outside canvas#1950
ethan-zhx merged 1 commit into
mainfrom
feat/lint_outside_canvas

Conversation

@ethan-zhx

@ethan-zhx ethan-zhx commented Jul 18, 2026

Copy link
Copy Markdown
Collaborator

Summary

Extend the Slides XML lint to report text shapes and charts that exceed the canvas. The reported bounds account for rotation while images and whiteboards continue to permit intentional bleed.

Changes

  • Generalize canvas-bound validation from tables to tables, text shapes, and charts.
  • Add rotation-aware bounds and regression coverage for in-canvas and out-of-canvas elements.

Test Plan

  • Unit tests pass (not run; tests were not requested in this turn)
  • Manual local verification confirms the lark-cli <domain> <command> flow works as expected (not run; this change only updates the lint script and its unit tests)

Related Issues

  • None

Summary by CodeRabbit

  • Bug Fixes

    • Slide validation now flags text, chart, and table elements that extend beyond the slide canvas.
    • Canvas boundary checks are now rotation-aware and handle non-finite rotations as unrotated.
    • Overflow diagnostics now provide more specific per-element details, including overflow distances and more tailored guidance.
  • Tests

    • Updated and expanded test coverage for canvas overflow reporting, including rotated text and charts and revised expectations for default-canvas bounds.

@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The slide linter now extracts element rotation and performs rotation-aware canvas-bound validation for tables, charts, and text shapes, with element-specific diagnostics and expanded tests.

Changes

Generalized canvas validation

Layer / File(s) Summary
Rotation-aware bounds and detection
skills/lark-slides/scripts/xml_text_overlap_lint.py
Element extraction records rotation, while new helpers calculate effective bounds and overflow for tables, charts, and text shapes.
Diagnostics, integration, and tests
skills/lark-slides/scripts/xml_text_overlap_lint.py, skills/lark-slides/scripts/xml_text_overlap_lint_test.py
lint_slide uses the generalized detector, emits element-specific diagnostics with bounding-box details, and tests text, chart, image, rotated-geometry, and non-finite-rotation behavior.

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

Sequence Diagram(s)

sequenceDiagram
  participant SlideXML
  participant lint_slide
  participant detect_elements_out_of_canvas
  participant Diagnostics
  SlideXML->>lint_slide: extract elements with rotation
  lint_slide->>detect_elements_out_of_canvas: validate elements against canvas
  detect_elements_out_of_canvas->>Diagnostics: return bbox and overflow
  Diagnostics->>lint_slide: emit element-specific lint issues
Loading

Possibly related PRs

  • larksuite/cli#1928: Introduces the table-specific canvas detection path that this change generalizes.

Suggested reviewers: liangshuo-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%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change: detecting out-of-canvas visual elements.
Description check ✅ Passed The description follows the template and includes summary, changes, test plan, and related issues.
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.
✨ 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 feat/lint_outside_canvas

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.

@github-actions github-actions Bot added the size/M Single-domain feat or fix with limited business impact label Jul 18, 2026
@ethan-zhx
ethan-zhx marked this pull request as ready for review July 18, 2026 18:06

@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`:
- Line 1114: Update the standalone-slide test around the shape defined in
xml_text_overlap_lint_test.py lines 206-220 to expect the shape_out_of_canvas
diagnostic produced by detect_elements_out_of_canvas. Keep the existing
standalone-slide assertions unchanged except for this expected error.
- Line 608: Update the rotation handling in element_canvas_bbox to validate the
extracted value with a finite-number check before passing it to math.sin or
math.cos. Preserve valid rotations, but replace inf, -inf, and other non-finite
values with 0 so linting continues and reports diagnostics.
🪄 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

Run ID: 525cd02f-d313-4a13-a970-bdf9768c00f7

📥 Commits

Reviewing files that changed from the base of the PR and between 4a56748 and 41c89fb.

📒 Files selected for processing (2)
  • skills/lark-slides/scripts/xml_text_overlap_lint.py
  • skills/lark-slides/scripts/xml_text_overlap_lint_test.py

Comment thread skills/lark-slides/scripts/xml_text_overlap_lint.py
Comment thread skills/lark-slides/scripts/xml_text_overlap_lint.py
@github-actions

github-actions Bot commented Jul 18, 2026

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

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

🧩 Skill update

npx skills add larksuite/cli#feat/lint_outside_canvas -y -g

@codecov

codecov Bot commented Jul 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.02%. Comparing base (1efe2df) to head (4d3910b).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1950   +/-   ##
=======================================
  Coverage   75.02%   75.02%           
=======================================
  Files         894      894           
  Lines       94294    94294           
=======================================
  Hits        70746    70746           
  Misses      18137    18137           
  Partials     5411     5411           

☔ 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.

@ethan-zhx
ethan-zhx force-pushed the feat/lint_outside_canvas branch from 41c89fb to 4d3910b Compare July 19, 2026 07:12

@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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
skills/lark-slides/scripts/xml_text_overlap_lint_test.py (1)

206-221: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Test name no longer matches its own assertions.

test_lint_xml_single_slide_uses_default_canvas_without_bounds_checks now asserts error_count == 1 and code == "shape_out_of_canvas" — i.e., bounds checks now fire on the default canvas, which is the opposite of what the method name promises. Left as-is, this will confuse future readers into thinking default-canvas bounds checking is still disabled.

✏️ Suggested rename
-    def test_lint_xml_single_slide_uses_default_canvas_without_bounds_checks(self) -> None:
+    def test_lint_xml_single_slide_uses_default_canvas_and_reports_out_of_canvas_shape(self) -> None:
🤖 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_test.py` around lines 206 -
221, Rename the test method
test_lint_xml_single_slide_uses_default_canvas_without_bounds_checks to reflect
that the default canvas performs bounds checks and reports shape_out_of_canvas.
Keep the test body and assertions unchanged.
🤖 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.

Outside diff comments:
In `@skills/lark-slides/scripts/xml_text_overlap_lint_test.py`:
- Around line 206-221: Rename the test method
test_lint_xml_single_slide_uses_default_canvas_without_bounds_checks to reflect
that the default canvas performs bounds checks and reports shape_out_of_canvas.
Keep the test body and assertions unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: de44d709-36d4-48bc-a453-35d85f1d1a79

📥 Commits

Reviewing files that changed from the base of the PR and between 41c89fb and 4d3910b.

📒 Files selected for processing (2)
  • skills/lark-slides/scripts/xml_text_overlap_lint.py
  • skills/lark-slides/scripts/xml_text_overlap_lint_test.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • skills/lark-slides/scripts/xml_text_overlap_lint.py

@ethan-zhx
ethan-zhx merged commit 44514ad into main Jul 19, 2026
30 of 42 checks passed
@ethan-zhx
ethan-zhx deleted the feat/lint_outside_canvas branch July 19, 2026 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Single-domain feat or fix with limited business impact

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants