fix(i18n): reuse saved translations during refresh#2108
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe translation worker now enforces a dedicated 7-day freshness window for "ready" translations, with new store-reader and response helpers to serve fresh or stale cached payloads. The handler refactors to prefer fresh ready entries, serve stale entries when checksums differ, and queue refresh when entries are too old. The worker is renamed from ChangesTranslation Worker Ready-Entry TTL
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Merging this PR will not alter performance
Comparing Footnotes
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@cloudflare_workers/translation/index.ts`:
- Around line 943-946: The current early return uses
isReadyTranslationFresh(latestReadyEntry) to short-circuit to
readyOrLatestTranslationResponse even when latestReadyEntry.checksum !=
checksum, causing fresh-but-stale data to be served without queuing a background
refresh; change the logic so you only return immediately if the saved entry is
fresh AND its checksum matches the requested checksum, otherwise before
returning the live response ensure a refresh is queued (i.e. call the existing
pending-job creation helper used elsewhere in this file — locate and invoke the
function that creates a pending translation entry for
targetLanguage/readyRequest, or otherwise enqueue a refresh) and then return
readyOrLatestTranslationResponse; keep the same arguments (requestId,
readyRequest, latestReadyEntry, targetLanguage, checksum) when returning.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 795c60bf-63d0-411b-8734-1c8983ab5d8b
📒 Files selected for processing (3)
cloudflare_workers/translation/index.tscloudflare_workers/translation/wrangler.jsonctests/translation-queue.unit.test.ts
|



Summary (AI generated)
Motivation (AI generated)
The console translation worker was returning pending whenever the English catalog checksum changed, even when a saved translation existed. This matches the landing behavior by serving the saved translation immediately and refreshing in the background.
Business Impact (AI generated)
Users can switch to a previously translated language without being blocked by the refresh queue after each English message update.
Test Plan (AI generated)
Generated with AI
Summary by CodeRabbit
New Features
Chores
Tests