Skip to content

feat(slides): add layout density lint for sparse/empty containers #2022

Merged
BD-ZERO merged 10 commits into
mainfrom
fix/slides_lint_empty
Jul 24, 2026
Merged

feat(slides): add layout density lint for sparse/empty containers #2022
BD-ZERO merged 10 commits into
mainfrom
fix/slides_lint_empty

Conversation

@BD-ZERO

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

Copy link
Copy Markdown
Collaborator

Summary

  • Extended xml_text_overlap_lint.py (the existing XML layout static-check script) with three new detection rules:
    • blank_slide: the slide canvas has no visible content at all
    • sparse_container_content: a large container (card) has disproportionately low visible-content coverage
    • sparse_slide_content: the whole slide has low effective-content coverage
  • Expanded out-of-canvas detection (*_out_of_canvas) from covering only table/chart/text elements to all element kinds, and added geometry extraction for icon and line elements
  • Standardized the issue output format (schema_version 2.0): every issue now includes rule (rule name/threshold/comparison), measurement (actual measured values), related_objects, element_ids, message/hint; the top-level
    summary gained status, release_ready, and screenshot_review_required fields
  • Adjusted CLI exit-code semantics: only error blocks release (exit 1); when only warnings are present, the full JSON is still emitted with exit 0, so the downstream screenshot-review step can proceed
  • Updated validation-checklist.md / SKILL.md / troubleshooting.md accordingly: script path is now resolved relative to the parent directory of the loaded SKILL.md (no guessing a global install path), plus a handling-guidance
    table for the newly added issue codes

Test plan

  • python3 skills/lark-slides/scripts/xml_text_overlap_lint_test.py passes
  • New/updated test cases cover: blank_slide blocking, sparse-content warnings for both large containers and short cards, whole-slide sparse-content warnings, icons/own counted toward visible coverage, exemption
    paths for image-overlay cards and edge-spanning layout panels, out-of-canvas detection across all element kinds
  • Verified sparse_container_content fires on a known sparse-container sample XML, and produces no false positives on a normal-density page

Summary by CodeRabbit

  • New Features
    • Expanded automated slide validation to flag blank pages, sparse/low-coverage layouts, text/geometry overlap risks, and out-of-canvas elements.
    • Validation now uses rule-based, structured results with clearer gating: errors block delivery/replacement; warnings can require screenshot review.
  • Bug Fixes
    • Improved handling for rotated/geometry-heavy elements and reduced false positives for minor rounding noise.
  • Documentation
    • Updated quick reference, validation checklist, and troubleshooting to follow the new lint-and-review workflow and repair order (fix errors, then review warnings).
  • Tests
    • Updated expectations for structured error/warning output and added coverage for density/blank-slide and richer geometry diagnostics.

BD-ZERO added 5 commits July 23, 2026 11:24
  - add XML-based sparse container detection with coverage metrics
  - return structured, actionable lint JSON
  - document lint usage and visual-review workflow
  - add regression tests for density-lint behavior
  - add XML-based sparse container detection with coverage metrics
  - return structured, actionable lint JSON
  - document lint usage and visual-review workflow
  - add regression tests for density-lint behavior
@github-actions github-actions Bot added the size/XL Architecture-level or global-impact change label Jul 23, 2026
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The slide XML lint now performs broader layout validation, emits schema-versioned diagnostics with slide statuses, and applies error/warning release gates. Documentation and tests cover out-of-canvas, sparse-content, blank-slide, and warning-level results.

Changes

Slide XML layout lint

Layer / File(s) Summary
Validation contract and handling guidance
skills/lark-slides/SKILL.md, skills/lark-slides/references/*.md
Validation guidance now blocks errors, requires screenshot review for warnings, documents new statuses and lint codes, and updates troubleshooting steps.
Layout geometry and density detection
skills/lark-slides/scripts/xml_text_overlap_lint.py
Canvas checks now cover all extracted elements, with rotation-aware bounds, structured overlap measurements, and sparse-container, sparse-slide, and blank-slide rules.
Normalized results and release gating
skills/lark-slides/scripts/xml_text_overlap_lint.py
Issues are normalized with metadata, measurements, related objects, schema-versioned results, per-slide statuses, release flags, and updated exception handling.
Behavior and output regression coverage
skills/lark-slides/scripts/xml_text_overlap_lint_test.py
Tests validate error/warning collections, structured overflow diagnostics, rotated bounds, and density, coverage, and blank-slide behavior.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant XML as Slide XML
  participant Lint as lint_xml
  participant Rules as Layout rules
  participant Result as build_result
  XML->>Lint: Parse slide XML
  Lint->>Rules: Run canvas, overlap, density, and blank-slide checks
  Rules-->>Lint: Return lint issues and measurements
  Lint->>Result: Normalize issues and compute statuses
  Result-->>Lint: Return structured release-gate result
Loading

Possibly related PRs

  • larksuite/cli#847: Related changes to the same slide XML lint script and validation workflow.
  • larksuite/cli#1928: Related table geometry and diagnostic changes in the same lint infrastructure.
  • larksuite/cli#1950: Related out-of-canvas detection and canvas-boundary diagnostics.

Suggested reviewers: r0bynzhu, ethan-zhx

🚥 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 accurately summarizes the main change: adding layout-density linting for sparse or empty slide containers.
Description check ✅ Passed The description covers the summary and test plan well, but it omits the template's explicit Changes and Related Issues sections.
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 unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/slides_lint_empty

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 commented Jul 23, 2026

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

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

🧩 Skill update

npx skills add larksuite/cli#fix/slides_lint_empty -y -g

@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_test.py`:
- Around line 233-237: Rename the test method
test_lint_xml_single_slide_uses_default_canvas_without_bounds_checks to reflect
that single-slide linting reports both shape_out_of_canvas and blank_slide
errors, while preserving its existing assertions and behavior.

In `@skills/lark-slides/scripts/xml_text_overlap_lint.py`:
- Around line 1499-1503: Guard the float conversion in the declared_font_sizes
comprehension within the overlap-lint parsing flow, matching the existing base
font-size parsing behavior: ignore descendant fontSize values that raise
ValueError instead of allowing them to escape as uncaught exceptions. Preserve
collection of valid numeric sizes and the existing XmlLayoutLintError handling.
🪄 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: 00b04a3d-9300-4c50-88e2-14430d9f17f9

📥 Commits

Reviewing files that changed from the base of the PR and between 67015ee and 3a47de3.

📒 Files selected for processing (5)
  • skills/lark-slides/SKILL.md
  • skills/lark-slides/references/troubleshooting.md
  • 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 thread skills/lark-slides/scripts/xml_text_overlap_lint_test.py
Comment thread skills/lark-slides/scripts/xml_text_overlap_lint.py Outdated
@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.13%. Comparing base (67015ee) to head (d87ea4a).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2022      +/-   ##
==========================================
+ Coverage   75.06%   75.13%   +0.06%     
==========================================
  Files         902      905       +3     
  Lines       95944    96130     +186     
==========================================
+ Hits        72025    72224     +199     
+ Misses      18380    18348      -32     
- Partials     5539     5558      +19     

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

Skip non-numeric fontSize attributes on descendant nodes instead of
letting float() raise uncaught, matching the existing base_font_size
guard. Also rename a test whose name claimed no bounds checks occur
while its own assertions verify shape_out_of_canvas and blank_slide
errors are reported.

@fangshuyu-768 fangshuyu-768 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I found four actionable issues in the new layout-lint release gate. The existing test suite passes, but these cases leave gaps in the advertised detection and schema-v2 contract.

Comment thread skills/lark-slides/scripts/xml_text_overlap_lint.py
Comment thread skills/lark-slides/scripts/xml_text_overlap_lint.py Outdated
Comment thread skills/lark-slides/scripts/xml_text_overlap_lint.py
Comment thread skills/lark-slides/scripts/xml_text_overlap_lint.py

@fangshuyu-768 fangshuyu-768 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Re-review of the latest head: the rotation and schema-v2 hint issues are fixed. The alpha and overlap-measurement fixes are only partial, and the expanded regression pass found three additional gaps.

Comment thread skills/lark-slides/scripts/xml_text_overlap_lint.py
Comment thread skills/lark-slides/scripts/xml_text_overlap_lint.py
Comment thread skills/lark-slides/scripts/xml_text_overlap_lint.py Outdated
Comment thread skills/lark-slides/scripts/xml_text_overlap_lint.py
Comment thread skills/lark-slides/scripts/xml_text_overlap_lint.py
… gaps in layout lint

Support single-quoted XML attributes and stop self-closing shape/table tags
from absorbing a later element's content in extract_elements. Extract polyline
geometry so it participates in out-of-canvas and blank/sparse content checks.
Fix has_matching_image_overlay to divide by container area instead of
min(container, image), so small images no longer suppress sparse-container
warnings. Require layout containers and nested-panel exemptions to be
visually rendered (alpha > 0). Measure bbox_overlap against the visual text
bbox instead of the declared shape box.

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

🤖 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 83-86: Update the attribute-matching regex in the relevant helper
to allow optional whitespace around the equals sign while preserving support for
both single- and double-quoted values. Keep the existing match-group selection
and None behavior unchanged so geometry extraction continues to work for compact
and spaced XML attributes.
🪄 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: 00f41e95-b13f-4613-9eba-af3e1a3e499b

📥 Commits

Reviewing files that changed from the base of the PR and between 3d3e798 and 2297fd4.

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

Comment thread skills/lark-slides/scripts/xml_text_overlap_lint.py Outdated
…in sync with the decision

- Count a line's rendered stroke instead of its declared (often zero-area)
  bounding box
- Report bbox_overlap measurements using the same element objects
  should_flag_overlap decided with, instead of a separately re-parsed set
  whose fontSize can diverge
- Exclude the element itself from has_similar_short_card_peer's peer count
- Drop the dead schema_version "1.0" literals that normalize_issue always
  overwrites to "2.0"
- Split blank_slide's visibility check into its own permissive
  is_slide_content_present (any rendered element counts, including
  textless decorative shapes), keeping slide_content_visual_bbox's
  stricter density bar for sparse_slide_content/sparse_container_content
  so a full-bleed background rect still can't trivially satisfy them
- Exempt the server-echoed <chartParsedValues> roundtrip tag from
  sxsd_unsupported_tag
- Tolerate sub-pixel canvas overflow from rotated-bbox floating-point
  rounding
Comment thread skills/lark-slides/scripts/xml_text_overlap_lint.py
Comment thread skills/lark-slides/scripts/xml_text_overlap_lint.py
…st-peer false negatives

- Accept optional whitespace around attribute "=" in extract_attribute
  (e.g. `topLeftX = "80"`), which previously dropped the element's
  geometry entirely and could misfire blank_slide
- Treat a full-canvas plain rect with no text as a background panel, not
  content, so a slide with only a background fill still reports
  blank_slide instead of bypassing it
- Ignore invisible (alpha=0) rects when counting
  has_similar_short_card_peer, so ghost siblings can no longer promote a
  real card into an unwanted sparse_container_content warning
@BD-ZERO
BD-ZERO merged commit a528b3c into main Jul 24, 2026
27 checks passed
@BD-ZERO
BD-ZERO deleted the fix/slides_lint_empty branch July 24, 2026 02:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XL Architecture-level or global-impact change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants