feat(i18n-isr): persist bot-path auto-translations to registry backend#264
Draft
snomiao wants to merge 2 commits into
Draft
feat(i18n-isr): persist bot-path auto-translations to registry backend#264snomiao wants to merge 2 commits into
snomiao wants to merge 2 commits into
Conversation
…ckend
After the bot path's OpenAI translation succeeds, fire-and-forget
POST /nodes/{id}/translations with X-Comfy-Admin-Secret so subsequent
ISR builds (and the human path) read the stored translation instead
of re-calling OpenAI.
- New persistNodeTranslation helper (server-only). No-ops unless both
COMFY_REGISTRY_ADMIN_SECRET and NEXT_PUBLIC_BACKEND_URL are set and
the translation came from OpenAI (source: "auto"). Failures are
logged, never thrown — page render must not depend on the write.
- loadNodeStaticProps calls it only when blocking: true and a new
auto-translation was generated.
- Doc update in i18n-isr-implementation.md with the new env var.
Depends on Comfy-Org/cloud#3641 (backend attaches APISecretMiddleware
to the translations route). Without that PR the backend will return
401 and the persistence call will simply be ignored.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Summary
After the bot path's OpenAI auto-translation succeeds, fire-and-forget a
POST /nodes/{id}/translationsto the registry backend so subsequent ISR builds (and the human path) read the stored translation instead of re-calling OpenAI.Unblocks #258.
Why this PR exists
Today (after #257), the bot path generates translations via OpenAI every time the ISR cache cold-misses. Without persistence:
/nodes/[id]) never sees the auto-translation because nothing writes it back.This PR persists the result, which:
Dependencies
Comfy-Org/cloud#3641attachesAPISecretMiddlewaretoPOST /nodes/{id}/translations. Without it the backend returns 401 and the persistence step silently warns + no-ops; the page still renders the OpenAI translation.sno-i18n-isr(PR feat: ISR with auto-translated content i18n for node pages #257). Once feat: ISR with auto-translated content i18n for node pages #257 merges, rebase ontomain.Operational config
COMFY_REGISTRY_ADMIN_SECRET— server-only (NOTNEXT_PUBLIC_*). Same value as backend'sAdminAPISecret. Add to Vercel project env (production + preview as desired).Changes
src/hooks/i18n/persistNodeTranslation.ts— new helper. Validates content source is"auto", uses 10sAbortControllertimeout, logs but never throws.src/hooks/i18n/nodeStaticProps.ts— callpersistNodeTranslation(fire-and-forget) whenblocking: trueand the loader generated a new"auto"translation. Awaiting is deliberately avoided..env— placeholder forCOMFY_REGISTRY_ADMIN_SECRETmatching the existingGITHUB_CLIENT_IDpattern.docs/i18n-isr-implementation.md— Key Decisions §4a documents the persistence path and the dependency on the backend PR.Test plan
COMFY_REGISTRY_ADMIN_SECRETunset: no behavior change, no warnings (Decision: silently no-op).COMFY_REGISTRY_ADMIN_SECRETset but backend unupdated: persistence call returns 401, warning logged, page still renders translated content.node.translations[locale]; second hit returnssource: "stored"(no OpenAI call); human path on the same (node, locale) now also returns the translated description.Out of scope
🤖 Generated with Claude Code