Repository navigation
Add a reading-time estimate to the TL;DR - #9
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Feature: the expanded TL;DR shows "≈ N min read" for the full article.
Why the first attempts were wrong, and the real fix:
<p>text then omitted HackerNoon entirely — but its article body is present, embedded in the page's schema.org JSON-LDarticleBody(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._article_word_count): prefer JSON-LDwordCount, else countarticleBody, else fall back to<p>prose, else omit (belowMIN_BODY_WORDS). Fetch cap raised to 300k so the full JSON-LD is captured.Verified on nova (live
generate_tldr):read_minutes: 22(4316-wordarticleBody; previously omitted/“30”).read_minutes: 4.Client:
requestTldrstoresreadMinuteson 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