feat: render an inline PDF viewer for .pdf links in chat#494
Open
X-15 wants to merge 1 commit into
Open
Conversation
|
Reviews (1): Last reviewed commit: "feat: render an inline PDF viewer for .p..." | Re-trigger Greptile |
e5e4311 to
047a561
Compare
When an assistant message contains a link to a PDF (a URL ending in .pdf), render it inline as a preview card instead of a plain hyperlink: tap to open a fullscreen, scrollable viewer; share the file from the card or the viewer. It keys purely off the .pdf link, so it works with any backend that links PDFs. Implementation notes: - Adds pdfrx (PDFium) for rendering. - Pages are pre-rasterized to images so scrolling never flashes a blank white page (pdfrx's live viewer rasterizes lazily on paint, which is very visible in a debug build). The fullscreen viewer renders pages lazily around the viewport and holds them under a hard 64 MB LRU budget, so a large document cannot blow up memory while small documents stay fully resident and flicker-free. - The PDF is downloaded once into a dedicated, bounded cache and opened from the local file; the card pre-renders page 1 to a held image. - Share copies the cached file to a uniquely-named temp file (Android does not reliably honor share_plus fileNameOverrides) and sweeps old temp files so they do not accumulate. - Basic resilience: retry on load failure, per-page error fallback, Semantics labels. User-facing strings are hardcoded English as a starting point and could be moved to AppLocalizations. Verified on Android (Samsung S23, arm64). 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.
What
Renders an inline PDF viewer when an assistant message contains a link to a PDF (a URL ending in
.pdf). Instead of a plain hyperlink, the message shows a preview card:This is a general "Conduit can display PDFs sent in a conversation" capability; it keys purely off the
.pdflink, so it works with any backend that returns/links PDFs.How
flutter_cache_managerinstance; the card pre-renders page 1 to a held image; both card and viewer open from the local file.share_plusfileNameOverrides) so the receiver sees a meaningful name, then sweeps old temp dirs.Semanticslabels.Notes
pdfrx(flutter_cache_manager/path_provider/share_pluswere already present), reflected inpubspec.yaml/pubspec.lock.AppLocalizationsif preferred.🤖 Generated with Claude Code