Fix phrase chunk subdoc schema and refactor bundle suggestion RPC #86exnxbwb#38
Merged
navidshad merged 2 commits intoMay 24, 2026
Conversation
…ion path The bundle-name suggestion was piggy-backed on getDetailedTranslation, so it ran on every word lookup (incl. anonymous users). Move it to its own call: - New phrase_bundle RPC getBundleSuggestionForPage (user_access): matches an existing bundle by normalised source URL, else asks the model for a short name from the page title. Best-effort; never blocks saving. - Remove pageTitle/pageUrl from translateWithContext + getDetailedTranslation and suggested_bundle_name from the translation schema/prompt. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…headroom
- Fix Mongoose reserved-key collision: chunks were defined with a bare `type`
field, so the array was treated as [String] and rejected objects (E11000-style
cast error). Use a dedicated chunk sub-schema with the verbose `{ type }` form.
- getBundleSuggestionForPage: if the suggested name already matches a bundle,
return it as matchedBundle so the client preselects it instead of recreating.
- createPhrase dedup now matches by phrase + type (+ owner), not translation —
the AI returns a different translation each call, which caused duplicate docs
and made an already-saved phrase look unsaved.
- Raise max_tokens (detailed translation 700->2000, advisor 400->800): the
richer per-chunk definition + transliteration overflowed and truncated the
JSON ("unterminated string") in token-heavy target languages like Persian.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
Author
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.
🏷️ PR Title: Fix phrase chunk subdoc schema and refactor bundle suggestion RPC
📋 Summary
This PR fixes the chunk subdocument schema related to phrase and translation matching, improving token headroom handling. It also refactors the bundle suggestion feature by implementing a dedicated per-page RPC and removing it from the translation path.
🔗 Related Tasks
#50af640 - Fix chunk subdoc schema, match-by-phrase, token headroom
#9922825 - Refactor bundle suggestion: dedicated per-page RPC, off the translation path
📝 Additional Details
The changes improve schema accuracy for phrase translation handling and optimize the bundle suggestion RPC architecture for better modularity and performance.
📜 Commit List
50af640 Fix phrase chunk subdoc schema, match-by-phrase, token headroom
9922825 Refactor bundle suggestion: dedicated per-page RPC, off the translation path