Skip to content

fix(slides): improve text width overflow detection#2056

Merged
ethan-zhx merged 9 commits into
mainfrom
fix/slides_text_width_detect
Jul 27, 2026
Merged

fix(slides): improve text width overflow detection#2056
ethan-zhx merged 9 commits into
mainfrom
fix/slides_text_width_detect

Conversation

@ethan-zhx

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

Copy link
Copy Markdown
Collaborator

Summary

  • account for letter spacing in text-width and wrapping estimates
  • report significant text overflow as errors while retaining background-decoration findings as informational
  • limit canvas-overflow checks to supported shape, table, and chart types

Root cause

The lint estimator ignored letter spacing and applied uniform severity and canvas geometry checks to elements that do not need them, causing missed or noisy overflow findings.

Validation

Not run (not requested).

Summary by CodeRabbit

  • Bug Fixes

    • Improved overflow and wrapped-line calculations by resolving letterSpacing, padding, and paragraph context, and applying tolerance for more accurate line fitting.
    • Enhanced text measurement using font-family–aware width estimation and bold multipliers, with updated dense-body line-height handling.
    • Tightened ghost/transparent text handling to reduce incorrect overlap and out-of-canvas reports.
    • Refined diagnostics so informational (info) issues are preserved and counted consistently, with adjusted severity for likely decorative content.
  • Tests

    • Expanded/updated coverage for overflow, out-of-canvas, canvas overlap, chart parsing roundtrips, and reporting counts/severities.

Text-shape overflow was always reported as a warning, which let clearly
broken pages pass the lint gate. Overflow > 10px now upgrades to error;
smaller overflows stay as warning to avoid flagging near-fit cases.
Extract letterSpacing from content/paragraph attrs and factor it into
width and line-count estimates, and stop short-circuiting the shape
overflow check for autoFit shapes so that letterSpacing-heavy captions
under normal-auto-fit no longer escape detection.
@coderabbitai

coderabbitai Bot commented Jul 25, 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

Text overflow linting now accounts for paragraph and shape letter spacing, font attributes, padding, and decorative background text. Canvas validation uses restricted element types and selective rotation bounds. Lint results preserve informational issues with document- and slide-level counts and lists.

Changes

Lint behavior

Layer / File(s) Summary
Text measurement and overflow classification
skills/lark-slides/scripts/xml_text_overlap_lint.py, skills/lark-slides/scripts/xml_text_overlap_lint_test.py
Text parsing and width estimation incorporate letter spacing, font family, boldness, and padding. Overflow checks include paragraph-specific spacing, auto-fit handling, decorative-background downgrades, and expanded diagnostic tests.
Canvas bounds filtering and validation
skills/lark-slides/scripts/xml_text_overlap_lint.py, skills/lark-slides/scripts/xml_text_overlap_lint_test.py
Rotation-aware bounds and out-of-canvas checks are limited to supported element types; ghost text, images, lines, and rotated-rectangle expectations are updated.
Informational result aggregation
skills/lark-slides/scripts/xml_text_overlap_lint.py, skills/lark-slides/scripts/xml_text_overlap_lint_test.py
Info-level issues are preserved and reported through document and slide infos lists and info_count, with related reporting assertions updated.

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

Sequence Diagram(s)

sequenceDiagram
  participant XMLContent
  participant TextEstimator
  participant OverflowDetector
  participant LintResult
  XMLContent->>TextEstimator: paragraph and shape text attributes
  TextEstimator->>OverflowDetector: estimated widths and line counts
  OverflowDetector->>LintResult: severity and diagnostic fields
  LintResult->>LintResult: aggregate errors, warnings, and infos
Loading

Possibly related PRs

  • larksuite/cli#1928: Preserves and aggregates info-level diagnostics in related lint result plumbing.
  • larksuite/cli#1950: Updates the same canvas bounding-box and out-of-canvas detection logic.
  • larksuite/cli#1963: Modifies the same text overflow estimation and detection paths.

Suggested reviewers: fangshuyu-768

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is missing required template sections for Changes, Test Plan, and Related Issues. Add a Changes list, complete the Test Plan checklist with verification details, and include a Related Issues section or None.
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 (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: improving slide text-width and overflow detection.
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_text_width_detect

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/L Large or sensitive change across domains or core paths label Jul 25, 2026
@ethan-zhx
ethan-zhx marked this pull request as ready for review July 25, 2026 17:58

@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

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.py (1)

910-932: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Advice is contradictory now that autoFit="normal-auto-fit" shapes are no longer skipped.

Removing the auto-fit early-continue means shapes that already declare wrap="true" autoFit="normal-auto-fit" get an error telling them to set exactly that. Suppress that clause when the element already has those values.

🐛 Suggested tweak
-        message = (
-            f'text shape {element["id"]} may overflow its own content box '
-            f'(estimated {estimated_height:g}px, available {available_height:g}px); '
-            'consider setting content wrap="true" autoFit="normal-auto-fit"'
-        )
+        already_auto_fit = element.get("autoFit") == "normal-auto-fit"
+        message = (
+            f'text shape {element["id"]} may overflow its own content box '
+            f'(estimated {estimated_height:g}px, available {available_height:g}px)'
+        )
+        if not already_auto_fit:
+            message += '; consider setting content wrap="true" autoFit="normal-auto-fit"'
+        else:
+            message += '; autoFit="normal-auto-fit" will shrink the text, verify the rendered size'
🤖 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 910 - 932,
The overflow warning in the message construction should avoid recommending wrap
and normal-auto-fit when the element already declares both settings. Update the
logic around the existing message and element attributes in the text-overflow
lint path, using an alternative hint for shapes that already have those values
while preserving the current advice for all others.
🧹 Nitpick comments (6)
skills/lark-slides/scripts/xml_text_overlap_lint.py (3)

1269-1274: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

The whitelist makes the extra_elements canvas pass dead code.

lint_xml calls detect_elements_out_of_canvas(extra_elements, ...) with only icon/polyline/line kinds, none of which pass this filter, so extra_overflow_issues is now always empty. Drop that call (or add the intended kinds to the whitelist) so the intent is explicit rather than silently no-op.

🤖 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 1269 -
1274, The whitelist in the element iteration excludes all kinds passed to the
extra_elements canvas check, making lint_xml’s extra_overflow_issues path
ineffective. Update lint_xml and the related element filtering so the intended
extra_elements kinds are processed, or remove the now-dead
detect_elements_out_of_canvas(extra_elements, ...) call; keep the chosen
behavior explicit and ensure extra_overflow_issues is not silently always empty.

938-956: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Extract the magic thresholds into module constants.

96, 0.5 here and the overflow > 10 cutoff at line 909 are tuning knobs; this module already keeps such values as named constants (e.g. CANVAS_OVERFLOW_TOLERANCE), which makes them discoverable and testable.

🤖 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 938 - 956,
Define module-level named constants for the decorative-text font-size threshold,
alpha threshold, and the overflow cutoff currently using 96, 0.5, and 10. Update
is_background_decorative_text and the overflow check near the existing tolerance
constants to reference those constants, preserving the current threshold
behavior.

809-815: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

estimate_text_max_line_width still ignores paragraph-level letterSpacing.

It splits element["text"] on newlines and resolves spacing element-only, so a <p letterSpacing="4"> override is invisible to horizontal-overflow and visual-bbox estimates even though line counting now honors it. Iterating element["paragraphs"] (falling back to the split when absent) would keep both paths consistent.

♻️ Sketch
 def estimate_text_max_line_width(element: dict[str, Any]) -> int | float:
     font_size = element["fontSize"] if isinstance(element["fontSize"], (int, float)) else 16
-    letter_spacing = resolve_letter_spacing(element)
-    paragraphs = [paragraph for paragraph in re.split(r"\n+", element["text"]) if paragraph]
-    return max(
-        [estimate_text_width(paragraph, font_size, letter_spacing) for paragraph in paragraphs] or [1]
-    )
+    records = element.get("paragraphs") or [{"text": element["text"]}]
+    widths = [
+        estimate_text_width(line, font_size, resolve_letter_spacing(element, record))
+        for record in records
+        for line in re.split(r"\n+", record.get("text") or "")
+        if line
+    ]
+    return max(widths or [1])
🤖 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 809 - 815,
Update estimate_text_max_line_width to iterate element["paragraphs"] when
available, resolving each paragraph’s letterSpacing override through the
existing spacing-resolution logic; fall back to the current newline-split text
when paragraphs are absent. Preserve the existing width calculation and default
minimum width so horizontal-overflow and visual-bbox estimates match
paragraph-level line counting.
skills/lark-slides/scripts/xml_text_overlap_lint_test.py (3)

689-689: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Stale test name.

test_lint_xml_warns_when_text_may_overflow_its_own_shape now asserts two errors; rename to reflect the error classification (and that auto-fit shapes are included).

Also applies to: 714-725

🤖 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` at line 689, Rename
test_lint_xml_warns_when_text_may_overflow_its_own_shape to describe that it
asserts both error classifications and includes auto-fit shapes, updating any
related references consistently.

799-861: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider parameterizing these three near-identical cases.

The alpha / no-foreground / order variants differ only in the shape XML; a single subTest loop over (name, shapes, expected element id) would cut the duplication.

🤖 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 799 -
861, Parameterize the three near-identical tests for text overflow severity into
one test method using a subTest loop over each XML shape variant and expected
element ID. Preserve the existing assertions that the matching
text_may_overflow_shape issue has level "error", including the alpha,
missing-foreground, and ordering cases.

1101-1143: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Fixtures rely on short-circuit evaluation to avoid KeyError: "type".

The table, chart and image dicts omit type; the test only passes because the or/and ordering in the filter (and in element_canvas_bbox) never reaches element["type"] for those kinds. Adding "type" to each fixture makes the test robust against a harmless reordering.

🤖 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 1101 -
1143, Add the appropriate type field to the table, chart, and image fixtures in
test_detect_elements_out_of_canvas_limits_detection_to_whitelist, so each
element dictionary is complete and the test no longer depends on short-circuit
evaluation avoiding element["type"].
🤖 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 905-909: The background-decoration classification in
`xml_text_overlap_lint.py` must match normalization behavior: either update
`normalize_issue`/`build_result` so `info` is preserved and counted correctly,
or change the classification near `is_background_decorative_text` to emit
`warning`. In `skills/lark-slides/scripts/xml_text_overlap_lint.py` lines
905-909, apply the chosen contract; in
`skills/lark-slides/scripts/xml_text_overlap_lint_test.py` lines 796-797, assert
the resulting level, updating the expectation to `warning` unless normalization
is changed to preserve `info`.

---

Outside diff comments:
In `@skills/lark-slides/scripts/xml_text_overlap_lint.py`:
- Around line 910-932: The overflow warning in the message construction should
avoid recommending wrap and normal-auto-fit when the element already declares
both settings. Update the logic around the existing message and element
attributes in the text-overflow lint path, using an alternative hint for shapes
that already have those values while preserving the current advice for all
others.

---

Nitpick comments:
In `@skills/lark-slides/scripts/xml_text_overlap_lint_test.py`:
- Line 689: Rename test_lint_xml_warns_when_text_may_overflow_its_own_shape to
describe that it asserts both error classifications and includes auto-fit
shapes, updating any related references consistently.
- Around line 799-861: Parameterize the three near-identical tests for text
overflow severity into one test method using a subTest loop over each XML shape
variant and expected element ID. Preserve the existing assertions that the
matching text_may_overflow_shape issue has level "error", including the alpha,
missing-foreground, and ordering cases.
- Around line 1101-1143: Add the appropriate type field to the table, chart, and
image fixtures in
test_detect_elements_out_of_canvas_limits_detection_to_whitelist, so each
element dictionary is complete and the test no longer depends on short-circuit
evaluation avoiding element["type"].

In `@skills/lark-slides/scripts/xml_text_overlap_lint.py`:
- Around line 1269-1274: The whitelist in the element iteration excludes all
kinds passed to the extra_elements canvas check, making lint_xml’s
extra_overflow_issues path ineffective. Update lint_xml and the related element
filtering so the intended extra_elements kinds are processed, or remove the
now-dead detect_elements_out_of_canvas(extra_elements, ...) call; keep the
chosen behavior explicit and ensure extra_overflow_issues is not silently always
empty.
- Around line 938-956: Define module-level named constants for the
decorative-text font-size threshold, alpha threshold, and the overflow cutoff
currently using 96, 0.5, and 10. Update is_background_decorative_text and the
overflow check near the existing tolerance constants to reference those
constants, preserving the current threshold behavior.
- Around line 809-815: Update estimate_text_max_line_width to iterate
element["paragraphs"] when available, resolving each paragraph’s letterSpacing
override through the existing spacing-resolution logic; fall back to the current
newline-split text when paragraphs are absent. Preserve the existing width
calculation and default minimum width so horizontal-overflow and visual-bbox
estimates match paragraph-level line counting.
🪄 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: da340127-da0d-44be-9b2e-bf1a05ef28a5

📥 Commits

Reviewing files that changed from the base of the PR and between a7865cd and bbb1311.

📒 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
@github-actions

github-actions Bot commented Jul 25, 2026

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

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

🧩 Skill update

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

@codecov

codecov Bot commented Jul 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.15%. Comparing base (a7865cd) to head (3ad5810).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff            @@
##             main    #2056    +/-   ##
========================================
  Coverage   75.14%   75.15%            
========================================
  Files         911      912     +1     
  Lines       96322    96453   +131     
========================================
+ Hits        72385    72492   +107     
- Misses      18370    18383    +13     
- Partials     5567     5578    +11     

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

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

🧹 Nitpick comments (2)
skills/lark-slides/scripts/xml_text_overlap_lint.py (1)

717-750: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Bold/italic detection logic looks correct; consider adding direct unit coverage for all 4 fallback paths.

The cascading checks (content attr → shape attr → inline <strong>/<b>/<i>/<em> tag → <span bold/italic> attr) are logically sound. However, the visible test file only appears to exercise the content-attribute path (e.g. bold="true" on <content>); I don't see a dedicated test for the shape-level attribute, inline-tag, or span-attribute fallbacks. Since this is new, multi-branch logic feeding directly into width/line estimation, a regression in any of these paths would silently affect overflow accuracy.

Do you want me to draft extract_elements-focused unit tests covering each fallback (shape bold/italic attr, <strong>/<em> tags, <span bold="true">) ?

🤖 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 717 - 750,
Add extract_elements-focused unit coverage for bold and italic detection through
the shape-level attributes, inline strong/b/em tags, and span boolean
attributes, in addition to the existing content-attribute cases. Assert each
fallback sets the corresponding element flags so width and line estimation
receive the correct formatting state.
skills/lark-slides/scripts/xml_text_overlap_lint_test.py (1)

945-1146: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Canvas-scope-restriction tests align with the intended new behavior.

The updated expectations (images/lines ignored, rotated rect uses declared bounds, whitelist test) are internally consistent with the element_canvas_bbox/detect_elements_out_of_canvas changes. See the related comment on xml_text_overlap_lint.py (Lines 1354-1363) about whether icon/polyline exclusion here was fully intentional, since no test in this range explicitly exercises those two kinds against detect_elements_out_of_canvas.

🤖 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 945 -
1146, Review the canvas-scope whitelist in detect_elements_out_of_canvas and
explicitly confirm the intended handling of icon and polyline elements alongside
the tested image and line exclusions. If they should be ignored, preserve that
behavior; otherwise update the whitelist and add focused coverage for both kinds
without changing the existing rotated-rect and supported-element behavior.
🤖 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.

Nitpick comments:
In `@skills/lark-slides/scripts/xml_text_overlap_lint_test.py`:
- Around line 945-1146: Review the canvas-scope whitelist in
detect_elements_out_of_canvas and explicitly confirm the intended handling of
icon and polyline elements alongside the tested image and line exclusions. If
they should be ignored, preserve that behavior; otherwise update the whitelist
and add focused coverage for both kinds without changing the existing
rotated-rect and supported-element behavior.

In `@skills/lark-slides/scripts/xml_text_overlap_lint.py`:
- Around line 717-750: Add extract_elements-focused unit coverage for bold and
italic detection through the shape-level attributes, inline strong/b/em tags,
and span boolean attributes, in addition to the existing content-attribute
cases. Assert each fallback sets the corresponding element flags so width and
line estimation receive the correct formatting state.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 39e13736-9529-4887-97d9-c68a12bcd582

📥 Commits

Reviewing files that changed from the base of the PR and between bbb1311 and ba422b0.

📒 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
Comment thread skills/lark-slides/scripts/xml_text_overlap_lint.py Outdated

@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.py (1)

1413-1416: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Expand rotated rect shapes for canvas overflow checks

rect shapes are included in detect_elements_out_of_canvas, but element_canvas_bbox only applies rotation-expanded bounds to chart and shape text. A rotated rect therefore uses its unrotated 100×100 rect, so a right overflow is reported (40px) while the actual rotated footprint also hits the left/top edges. Include rect in the rotation-expansion whitelist.

🐛 Proposed fix
-    if element["kind"] != "chart" and not (element["kind"] == "shape" and element["type"] == "text"):
+    if element["kind"] != "chart" and not (
+        element["kind"] == "shape" and element["type"] in {"text", "rect"}
+    ):
         return bbox
🤖 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 1413 -
1416, Update the rotation-expansion condition in element_canvas_bbox to include
rect shapes alongside chart and shape text elements. Preserve the existing
unrotated-bounds behavior for all other element kinds while ensuring rotated
rects use their expanded footprint for canvas overflow checks.
🧹 Nitpick comments (2)
skills/lark-slides/scripts/xml_text_overlap_lint_test.py (2)

689-726: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Test names still describe the pre-reclassification severity levels. This PR changed several diagnostics' levels, but the affected test method names were not updated, so they now contradict their own assertions.

  • skills/lark-slides/scripts/xml_text_overlap_lint_test.py#L689-L726: rename test_lint_xml_warns_when_text_may_overflow_its_own_shape — it asserts error_count == 1.
  • skills/lark-slides/scripts/xml_text_overlap_lint_test.py#L1684-L1698: rename test_lint_xml_reports_vertical_text_image_overlap_as_warning to ..._as_info — it asserts level == "info".
🤖 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 689 -
726, Rename test_lint_xml_warns_when_text_may_overflow_its_own_shape in
skills/lark-slides/scripts/xml_text_overlap_lint_test.py:689-726 to reflect that
it asserts an error-level diagnostic. Also rename
test_lint_xml_reports_vertical_text_image_overlap_as_warning in
skills/lark-slides/scripts/xml_text_overlap_lint_test.py:1684-1698 so its name
ends with _as_info, matching the asserted level.

1201-1242: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Assert image-specific absence, not just error_count == 0.

These tests previously pinned img_out_of_canvas; now they only check error_count, so they'd still pass if images were reported at warning/info. Consider asserting no issue code contains out_of_canvas for the image ids.

♻️ Example tightening
-        self.assertEqual(result["summary"]["error_count"], 0)
+        self.assertEqual(result["summary"]["error_count"], 0)
+        self.assertEqual(
+            [issue for issue in result["slides"][0]["issues"] if issue["code"].endswith("_out_of_canvas")],
+            [],
+        )
🤖 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 1201 -
1242, Strengthen the assertions in the three image
tests—test_lint_xml_ignores_small_out_of_bounds_images,
test_lint_xml_ignores_out_of_canvas_images, and
test_lint_xml_ignores_full_bleed_images_outside_canvas—by inspecting reported
issues and asserting none for the corresponding image IDs contains the
out_of_canvas code, rather than relying only on summary error_count.
🤖 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.py`:
- Around line 1413-1416: Update the rotation-expansion condition in
element_canvas_bbox to include rect shapes alongside chart and shape text
elements. Preserve the existing unrotated-bounds behavior for all other element
kinds while ensuring rotated rects use their expanded footprint for canvas
overflow checks.

---

Nitpick comments:
In `@skills/lark-slides/scripts/xml_text_overlap_lint_test.py`:
- Around line 689-726: Rename
test_lint_xml_warns_when_text_may_overflow_its_own_shape in
skills/lark-slides/scripts/xml_text_overlap_lint_test.py:689-726 to reflect that
it asserts an error-level diagnostic. Also rename
test_lint_xml_reports_vertical_text_image_overlap_as_warning in
skills/lark-slides/scripts/xml_text_overlap_lint_test.py:1684-1698 so its name
ends with _as_info, matching the asserted level.
- Around line 1201-1242: Strengthen the assertions in the three image
tests—test_lint_xml_ignores_small_out_of_bounds_images,
test_lint_xml_ignores_out_of_canvas_images, and
test_lint_xml_ignores_full_bleed_images_outside_canvas—by inspecting reported
issues and asserting none for the corresponding image IDs contains the
out_of_canvas code, rather than relying only on summary error_count.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: cb379e16-3621-40be-91cb-a9eb30ec59bf

📥 Commits

Reviewing files that changed from the base of the PR and between ba422b0 and 89a94d9.

📒 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_test.py
Comment thread skills/lark-slides/scripts/xml_text_overlap_lint.py
Comment thread skills/lark-slides/scripts/xml_text_overlap_lint.py Outdated
@ethan-zhx
ethan-zhx force-pushed the fix/slides_text_width_detect branch from 7b3373f to 42399ce Compare July 27, 2026 03: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.

Actionable comments posted: 1

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.py (1)

1467-1487: 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Expand element_canvas_bbox to supported rotated tables.

extract_elements parses a <table> rotation attribute, but element_canvas_bbox only rotates chart and text shapes. A rotated table can become out-of-canvas while still binding to its unrotated declared bounds, so tables should be included in the rotation-aware path unless the schema excludes rotation for table.

🤖 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 1467 -
1487, Update element_canvas_bbox so its rotation-aware condition also includes
elements with kind "table", preserving the existing chart and text-shape
handling and all rotation calculations.
🧹 Nitpick comments (1)
skills/lark-slides/scripts/xml_text_overlap_lint_test.py (1)

905-930: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Dense-body test only exercises a modest overage; doesn't cover the clamp's false-negative risk.

Both dense-body tests use lineSpacing="multiple:1.7", which is only slightly above DENSE_BODY_LINE_SPACING_MAX_MULTIPLE (1.6). Consider adding a case with a much larger explicit multiple (e.g. multiple:10) to catch the false-negative behavior flagged on adjust_dense_body_line_height in xml_text_overlap_lint.py.

🤖 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 905 -
930, Strengthen the dense-body overflow test around
test_lint_xml_reports_dense_body_when_adjusted_height_still_overflows by using a
substantially larger explicit line spacing multiple, such as multiple:10,
instead of the modest 1.7 value. Keep the existing assertions that exactly one
text_may_overflow_shape issue is reported for dense-body, ensuring
adjust_dense_body_line_height does not produce a false negative.
🤖 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 1048-1061: Update adjust_dense_body_line_height so explicit
multiple line spacing values only receive the dense-body adjustment within the
intended modest band above DENSE_BODY_LINE_SPACING_MAX_MULTIPLE; for
substantially larger declared multiples, return the uncapped line_height
unchanged. Preserve the existing behavior for non-multiple spacing, sparse
paragraphs, larger fonts, and values within the supported adjustment range, and
add coverage for a grossly large multiple such as 10.

---

Outside diff comments:
In `@skills/lark-slides/scripts/xml_text_overlap_lint.py`:
- Around line 1467-1487: Update element_canvas_bbox so its rotation-aware
condition also includes elements with kind "table", preserving the existing
chart and text-shape handling and all rotation calculations.

---

Nitpick comments:
In `@skills/lark-slides/scripts/xml_text_overlap_lint_test.py`:
- Around line 905-930: Strengthen the dense-body overflow test around
test_lint_xml_reports_dense_body_when_adjusted_height_still_overflows by using a
substantially larger explicit line spacing multiple, such as multiple:10,
instead of the modest 1.7 value. Keep the existing assertions that exactly one
text_may_overflow_shape issue is reported for dense-body, ensuring
adjust_dense_body_line_height does not produce a false negative.
🪄 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: b7806aa4-4908-4d05-81e0-138278eccb67

📥 Commits

Reviewing files that changed from the base of the PR and between 7b3373f and 42399ce.

📒 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
Comment thread skills/lark-slides/scripts/xml_text_overlap_lint.py
Large low-alpha text underneath other text shapes is typically a
background design element; treat text_may_overflow_shape as info in
that case instead of warning/error.
chartParsedValues is a server-injected roundtrip child tag under
chartField, not an attribute. Move it from ROUNDTRIP_SXSD_ATTRS to a
new ROUNDTRIP_SXSD_TAGS set and skip the tag (and its subtree) in the
SXSD tag whitelist check.
Replace the uniform 0.55em half-width coefficient with per-character-type
coefficients, add font-family awareness (sans/serif), bold multiplier,
letter-spacing support, and fix padding-aware line wrapping.

- Split half-width chars into uppercase (0.57), lowercase (0.51 sans / 0.53
  serif), digits (0.58), and punctuation (0.50)
- Add classify_font_family() to apply slightly wider lowercase widths for
  serif fonts (Georgia, Source Han Serif/思源宋体, Times, etc.)
- Add 5% width multiplier for bold text; detect <strong>/<b>/<i>/<em> tags
  and span-level bold/italic attributes in addition to content attrs
- Fix estimate_text_line_count_for_text to subtract paddingLeft/paddingRight
  from available width before computing wrap lines
- Add resolve_letter_spacing and wire letterSpacing through estimate_text_width
- Extract fontFamily/bold/italic/letterSpacing into element dict during parse
@ethan-zhx
ethan-zhx force-pushed the fix/slides_text_width_detect branch from 42399ce to 3ad5810 Compare July 27, 2026 03:41
@ethan-zhx
ethan-zhx merged commit 56c9a2a into main Jul 27, 2026
28 checks passed
@ethan-zhx
ethan-zhx deleted the fix/slides_text_width_detect branch July 27, 2026 03:59
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.

2 participants