Repository navigation
feat(mobile): share a link to send its article to the Kindle - #5
Merged
Merged
Conversation
Readability extraction (dom_smoothie), images re-encoded as JPEG, and the page's preview image as the cover. A book without a cover is built as a PDOC with no thumbnail instead of failing.
Shared text with a link becomes an article book that converts from its page. A fetch that fails offline retries once the phone is back online, and the sheet can still send it.
listlessbird
force-pushed
the
feat/article-urls
branch
from
November 21, 2026 16:14
32b4d5b to
959383e
Compare
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.
Sharing a web page from Chrome (
text/plainwith a link) showed "Kindle Drop sends EPUB, AZW3, PDF, and TXT files." There was no way to read an article on the Kindle.How
The pipeline lives in kindle-core. A new
convert_article(url, out_dir)fetches the page, extracts the readable part, and builds the AZW3 through the samebuild()that EPUBs use:ureq(rustls with bundled roots; no new secrets and no third-party service).dom_smoothie, a Rust port of Mozilla's Readability, for the title, byline, site, language and content.image(WebP, PNG, GIF…), scale them to the Paperwhite's 1072 px, and re-encode them as JPEG. kindling embeds images as-is, and the Kindle can't show WebP. An image that won't load is dropped from the book rather than failing it.og:imageas the cover, or else the article's first large image, then write an unpacked EPUB (content.opf,article.xhtml,images/) and hand it to kindling.Why not the other options:
convertEpub) would run the parse on the JS thread, so the share sheet would freeze. It also can't turn WebP into something the Kindle reads.The Kotlin change for
EXTRA_TEXTmakes this a native change regardless, so the new Rust code adds no extra cost.No cover means PDOC. An EBOK without a thumbnail gets Amazon's "No image available" placeholder, so a book without a cover is now built as a PDOC with no thumbnail, and
Converted.thumbnailwas already optional. This also fixes EPUBs that have no cover; before this change they failed to convert at the thumbnail step.App model.
Sourceis now a file or anarticle(urlplus the shared title). An article starts asConvertingand is fetched in the convert step, not at share time. A failed fetch becomesConvertFailed { reason: "unreachable" }, andrefreshretries it once the mailbox answers, the same way it retries an offline upload. A page that isn't an article, or answers with an error, isinvalidand is not retried. Rows stored beforereasonexisted decode asinvalid. The share sheet still offers Send to Kindle when the fetch failed offline. Shared text with no link gets "This text has no link to an article. Share the page from your browser."Native Change:
ShareActivitypassestextandsubject(ignoring a browser's previewclipData), and kindle-core gainsconvert_articleand its dependencies.Verification
Tests written first. Model: offline failures stay sendable,
articleUrlOf, the storage round trip, and old rows. Sender: an article converts and uploads (thumbnail first), an offline fetch retries on refresh, an offline article sent from its sheet survives the sheet closing and sends once online, a page with no article is not fetched again, and a book without a cover is sent alone.check:changedpasses.Rust tests run against a local HTTP server: images become 1072 px JPEGs, a 404 image and the page chrome are dropped,
og:imagebecomes the cover, a page without images builds as a PDOC with no thumbnail, an unreachable host isFetch, and a 404 page isArticle.Real pages on the host, about 1.5 s each:
ebook-metareads back the same title and author, and calibre's text dump shows clean article text without navigation.On emulator-5554, against a local
alchemy devWorker, I shared three pages from Chrome. Each reached Waiting for Kindle with the right title and author. Simon Willison's arrived with its cover thumbnail, and the other two as PDOCs.ebook-metaon the AZW3s pulled from the mailbox read back the same titles and authors, and I then cancelled all three.That pass found a bug, fixed in the last commit. Chrome attaches its link-preview thumbnail as
clipData, andShareActivitywas falling back to it as the shared file, so the sheet showed a PNG named "TXT".clipDatais now ignored when the share carries text.