Skip to content

fix(cli): count line_unread words from the block's rendered text - #6456

Merged
jrusso1020 merged 1 commit into
heygen-com:mainfrom
NavpreetSSidhu:craft-audit-glyph-spans
Oct 30, 2026
Merged

jrusso1020 merged 1 commit into
heygen-com:mainfrom
NavpreetSSidhu:craft-audit-glyph-spans

Conversation

@NavpreetSSidhu

Copy link
Copy Markdown
Contributor

What

line_unread now counts a block's words from the block's rendered text (innerText) instead of joining its parts with spaces.

Why

A line built from one <span> per glyph arrives as one part per character, so readableBlocks joined it into T h a t c a m e r a … and counted every letter as a word (25 instead of 7). The parts don't carry the author's whitespace, so the join can't know where words break.

Related work

Fixes #6443 (the fix suggested in the issue).

How

craftTextParts also reports blockText: textContentFor(block, false) for each part. readableBlocks takes the block's text from it and still unions the parts' rects.

Test plan

  • Unit tests added/updated
  • Manual testing performed
  • Documentation updated (if applicable)
  • Comments follow CONTRIBUTING.md "Comments": they say why, not what, and a bug fix says what the code must do and how to reproduce the bug

Ran the issue's repro through hyperframes check: line_unread no longer fires on #spans, and only the expected dead_stretch remains. I used Claude Code to write this change; I reviewed it myself.

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

Reviewed at eabf072d8f7ab4655e89bcaffeb8b97be791f755.

The glyph word-count fix is useful. I found one non-blocking accuracy follow-up at layout-audit.browser.js:2603: whole-block innerText includes opacity-hidden siblings that the readable-part filter removes. In an exact-head headless Chrome sampler control, only Hi is visible, but blockText includes 14 hidden sibling words. Five samples over two seconds through the actual detector produce a 15-word line_unread warning; the visible-only control produces none.

Nit: build block text from nodes passing the same readability opacity, visibility and clipping filters, preserving DOM whitespace. Add opacity 0/below 0.5 sibling cases alongside the existing glyph tests. I checked the downstream consumer: checkPipeline.ts:1915 explicitly excludes craft warnings from the strict gate, and check.test.ts:2193 pins exit 0 even under --strict. This false warning does not fail the check, so I am leaving the bounded follow-up non-blocking.

The authored craftAudit suite passes 21 tests. The extra witness exercises the actual browser sampler and analyzer with synthetic frames, not a full animated-film render. No full workspace run.

Need: yes · Size: ok · Reuse: existing readable-part sampler · Simpler: keep one visibility-aware text source · Structure: fine
Risk: low - advisory text audit accuracy; render and check success remain unchanged.

Verdict: APPROVE
Reasoning: The main word-count correction holds; the measured hidden-word warning is a focused follow-up.

Reasoning: The glyph word-count fix is useful; the remaining hidden-word case is advisory and explicitly does not gate check, even under --strict.

@jrusso1020
jrusso1020 added this pull request to the merge queue Oct 30, 2026
Merged via the queue into heygen-com:main with commit f64b028 Oct 30, 2026
68 of 69 checks passed
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.

check: line_unread counts every per-character span as a word

2 participants