Skip to content

Add a reading-time estimate to the TL;DR - #9

Merged
philoking merged 3 commits into
mainfrom
feat/tldr-reading-time
Jun 27, 2026
Merged

philoking merged 3 commits into
mainfrom
feat/tldr-reading-time

Conversation

@philoking

@philoking philoking commented Jun 26, 2026 •

Copy link
Copy Markdown
Owner

Feature: the expanded TL;DR shows "≈ N min read" for the full article.

Why the first attempts were wrong, and the real fix:

  • Counting whole-page text over-estimated (HackerNoon "30 min") because it included nav/related-links chrome.
  • Counting only <p> text then omitted HackerNoon entirely — but its article body is present, embedded in the page's schema.org JSON-LD articleBody (a Next.js data blob), not in <p> tags. That's the same content the TL;DR summarizes; the LLM just tolerates the surrounding noise, whereas a word count can't.
  • Final approach (_article_word_count): prefer JSON-LD wordCount, else count articleBody, else fall back to <p> prose, else omit (below MIN_BODY_WORDS). Fetch cap raised to 300k so the full JSON-LD is captured.

Verified on nova (live generate_tldr):

  • HackerNoon article → read_minutes: 22 (4316-word articleBody; previously omitted/“30”).
  • The Register article → read_minutes: 4.

Client: requestTldr stores readMinutes on the saved item (syncs); the panel renders "≈ N min read" above the bullets. Items saved before this change get it on next TL;DR (re)generation.

Deployed on this branch to nova for testing — do not merge until confirmed.

🤖 Generated with Claude Code

philoking and others added 3 commits June 26, 2026 09:32
generate_tldr already fetches the full article body, so compute its word count
and return read_minutes (≈200 wpm). The expanded TL;DR panel shows "≈ N min
read" above the bullets. The figure persists on the saved item (syncs) and is
guarded against near-empty extractions (paywalls/fetch failures).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Whole-page extraction counted nav/related-links chrome, inflating the estimate
(a HackerNoon post read "30 min"). Count only <p> paragraph text, which isolates
article prose, and omit the estimate entirely below MIN_PROSE_WORDS — JS-rendered
pages (HackerNoon) have no prose in the static HTML, so a figure there would be
pure chrome. Server-rendered articles now read sanely (a Register piece: 8→4 min).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The previous fix counted only <p> text and so omitted reading time for
JS-rendered sites like HackerNoon — but their article body IS available, in the
page's schema.org JSON-LD (articleBody), which is also why the TL;DR works.
Prefer JSON-LD wordCount, else count articleBody, else fall back to <p> prose.
Raise the fetch cap to 300k so the full JSON-LD block is captured.

Now: HackerNoon ~22 min (4316 words, was omitted), Register unchanged-sane.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@philoking
philoking merged commit a345eb7 into main Jun 27, 2026
2 checks passed
@philoking
philoking deleted the feat/tldr-reading-time branch June 27, 2026 23:18
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.

1 participant