Skip to content

Switching back to an article's language returns the original - #938

Merged
mircealungu merged 2 commits into
masterfrom
wt/translate-back
Nov 7, 2026
Merged

mircealungu merged 2 commits into
masterfrom
wt/translate-back

Conversation

@mircealungu

@mircealungu mircealungu commented Nov 7, 2026 •

Copy link
Copy Markdown
Member

Switching language in the reader from a translated article made a new translation of the translation: Danish → Italian → Danish showed "Adapting..." again, called the LLM, and gave back the Italian adaptation in Danish instead of the original. Every further switch added another hop, because the #translated-from key kept growing and never hit the cache.

translate_and_adapt_article now follows the open article back to its original (reusing SharedArticle.resolve_original_article_id):

  • Back in the original's language: returns the original, or its simplified version at the reader's level if there is one. No LLM call.
  • Any other language: translates from the original, so the key is always <original>#translated-from-da-to-X-level and a language already visited comes from the cache.

Left as they were:

  • Asking for an article's own language still adapts it, because the share flow's "Adapt" depends on that. The shortcut only applies when the open article is in another language.
  • Translations of uploads keep translating from themselves, because the article at the upload's url may only be a paywall teaser. Further translations of them now carry source_upload_id, so this holds across hops.
  • Translations made before this PR need no backfill, since the link is read from their url.

Also removes two local UserArticle imports in the function. They duplicated the module-level import and made the name unbound at the new early return.

Tests: 7 new cases in test_translate_and_adapt_article_switch.py; 6 of them fail without the fix (the seventh pins the unchanged same-language behavior). All 468 API tests pass. Not tried in a browser or on a device. API only, no migration.

🤖 Generated with Claude Code

translate_and_adapt_article took a translation as its own source, so going
da -> it -> da translated the Italian adaptation back into Danish, with a new
LLM call on every hop. Follow a translation back to its original: its own
language returns the original, or its version at the reader's level, and any
other language translates from the original and shares its cache key.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

ArchLens - No architecturally relevant changes to the existing views

… urls

A translation of an upload's translation lost source_upload_id, so a later
switch followed its url to the teaser the upload was made to get past. And a
translation whose url starts from a simplified version stopped at that version.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mircealungu
mircealungu merged commit b25468e into master Nov 7, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant