Fall back to LPMetadataProvider for link previews#685
Conversation
…ssing x.com renders all content client-side and serves no useful OpenGraph metadata to crawlers. Use Apple's LPMetadataProvider (same as iMessage) as a fallback when the fast OG tag fetch returns nothing. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Claude finished @onefovrth's task —— View job Code Review CompleteI've reviewed PR #685 and have comprehensive feedback on code quality, potential bugs, performance, security, and test coverage. Tasks:
Architecture & Code Quality ✅Excellent architecture choices:
Code quality notes:
Critical Bug 🔴 - Cache Key vs URL IssueThe Macroscope review correctly identified a critical bug. However, I've analyzed the code and found that the bug was already fixed in the current commit (289c3b4). Original problematic code (mentioned in Macroscope review): // IOSRichLinkMetadataProvider.swift lines 95-96 (OLD)
let cacheKey = "richlink:\(originalURL.absoluteString)"
return cacheKey // ❌ Returns cache key as imageURLCurrent code (289c3b4): // IOSRichLinkMetadataProvider.swift lines 95-96 (CURRENT)
let imageURL = originalURL.absoluteString
ImageCache.shared.cacheImage(image, for: imageURL, storageTier: .cache)
return imageURL // ✅ Returns actual URLWhy this works correctly now:
The fix was already applied in commit 289c3b4, so this issue is resolved. Security ✅Well-protected against common security issues:
Minor suggestion: Consider adding URL scheme validation in Performance Considerations
|
ApprovabilityVerdict: Needs human review This PR introduces a new fallback mechanism that changes user-facing behavior: links without OpenGraph tags will now attempt to fetch previews via iOS's LPMetadataProvider. While well-implemented with good test coverage, this is a new feature that expands what content displays to users, warranting human review. You can customize Macroscope's approvability policy. Learn more. |
Summary
LPMetadataProvider(same approach as iMessage)LPMetadataProviderwhich uses WebKit to render the page and extract metadataWhat changed
OpenGraphService: Refactored fetch intofetchOpenGraphTagshelper; addedRichLinkMetadata.providerfallback when OG parsing returns nilRichLinkMetadataProviding(new): Protocol + singleton accessor in ConvosCoreIOSRichLinkMetadataProvider(new): iOS implementation usingLPMetadataProvider, extracts title + image, pre-caches images inImageCacheConvosCoreiOS: ConfiguresRichLinkMetadataalongside other platform providersNext steps
Test plan
swift test --package-path ConvosCore)🤖 Generated with Claude Code
Note
Fall back to
LPMetadataProviderfor link previews when OpenGraph tags are missingRichLinkMetadataProvidingprotocol and a globalRichLinkMetadataregistry so platform-specific providers can supply metadata for links that lack OpenGraph tags.IOSRichLinkMetadataProviderusingLPMetadataProviderto fetch title and image, validate image data/size, cache viaImageCache, and reject private hosts.OpenGraphServicenow falls back to the configured provider when OG tag parsing yields no result, returning metadata where it previously returnednil.LinkPreview.isPrivateHostpublic so the iOS provider can reuse it.nilmay now return metadata on iOS.Macroscope summarized 289c3b4.