Repository navigation
[LLM] Show related articles in translation view - #168
Merged
Merged
Conversation
What: adds a Related articles section below the target card in the translation view. Related concepts are fetched lazily after translation via the stable Action API morelike query (generator=search with pageprops|extracts), filtered to main-namespace non-disambiguation pages, capped at 8, cached per source article. Tapping a related article translates that concept directly. Section hides silently on empty/error so translation is never disturbed. Strings localized to all supported languages. Why: the legacy rest_v1/page/related endpoint is decommissioned (HTTP 403, phab:T376297); CirrusSearch morelike is WMF's canonical replacement and matches what Extension:RelatedArticles uses. This implements the source-language inline (Option A) design. Made by Muse Spark. Closes #41
Member
|
The changes are well-architected, resilient, and thoroughly tested. Coroutine cancellation, stale response discarding, and title normalization are all properly handled, and localizations are complete across all supported languages. |
anysoftkeyboard-bot
left a comment
Member
There was a problem hiding this comment.
Changes requested due to an unhandled coroutine cancellation issue in TranslateViewModel that causes stale state overwrites, along with a parameter encoding issue in TranslationRepository.
…ze titles What: tracks the in-flight related-articles fetch as a Job and cancels it on new loads, searches, back-navigation, and clear; results and errors are only posted when the translation view still shows the same source article (sourceLang + pageid guard); CancellationException is rethrown instead of swallowed. Multi-word titles are normalized to MediaWiki canonical form (spaces to underscores) in the morelike query. Why: fixes a race where a late related-articles response overwrote the state of a newer translation, and hardens the CirrusSearch query for multi-word titles. Made by Muse Spark.
anysoftkeyboard-bot
left a comment
Member
There was a problem hiding this comment.
The changes are well-architected, resilient, and thoroughly tested, with complete localizations and proper handling of coroutine cancellation and stale responses.
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
Adds a Related articles section below the target card in the translation view (source-language, inline, up to 8 items).
WikipediaApi.getRelatedArticles():generator=searchwithgsrsearch=morelike:{title}+prop=pageprops|extracts(2-sentence intro extracts).TranslationRepository.getRelatedArticles(): filters to main-namespace, valid, non-disambiguation pages; excludes the source article; caps at limit.TranslateViewModel: newRelatedArticlesState(Hidden/Loading/Loaded) flow, fetched lazily after translation, cached per source article; tapping a related article translates it directly viafetchRelatedTranslation(). Empty/error hides silently.RelatedArticlesSectioninTranslationView, wired throughTranslateScreen; strings localized (en + ar, de, es, fr, he, ru).Why
The legacy
rest_v1/page/relatedendpoint is decommissioned (HTTP 403, phab:T376297). CirrusSearchmorelikeis WMF's canonical replacement and what Extension:RelatedArticles itself uses.Verification
./gradlew testDebugUnitTest+spotlessApplyclean.installGoogleDebug): search “office” → “Office” → Hebrew translation + related list below.Closes #41