Repository navigation
Revert PR #5272: translate API optimization - #5383
Conversation
Greptile SummaryThis PR reverts merge commit Key findings:
Confidence Score: 3/5
Sequence DiagramsequenceDiagram
participant WS as WebSocket Handler
participant TR as translate()
participant LC as TranscriptSegmentLanguageCache
participant TS as TranslationService
participant GC as Google Cloud Translate
participant DB as conversations_db
WS->>TR: translate(segments, conversation_id)
loop for each segment
TR->>LC: is_in_target_language(segment.id, text, translation_language)
LC-->>TR: true (skip) / false (translate)
alt needs translation
TR->>TS: translate_text_by_sentence(translation_language, text)
TS->>GC: translate_text(contents, target_language_code)
GC-->>TS: translated_text
TS-->>TR: translated_text
TR->>TR: build Translation(lang=translation_language, text=...)
TR->>TR: update segment.translations
end
end
TR->>DB: get_conversation / update_conversation_segments
TR->>WS: _send_message_event(TranslationEvent)
Last reviewed commit: b9425ce |
| translation = Translation(lang=translation_language, text=translated_text) | ||
| if segment.translations is not None: | ||
| existing_translation_index = next( | ||
| (i for i, t in enumerate(segment.translations) if t.lang == language), None |
There was a problem hiding this comment.
Wrong variable used when matching existing translations
This line uses language (the STT input/speech language, e.g. "multi" or "en") to look for an existing translation entry, but translations are stored with lang=translation_language (the target/output language, e.g. "fr" from user preferences) on line 1272.
When translation_language != language — specifically when user_language_preference is set at line 214 — this lookup will never find an existing entry and will always fall through to segment.translations.append(translation). Over repeated calls, this causes duplicate translation entries to accumulate on the same segment for the same target language.
| (i for i, t in enumerate(segment.translations) if t.lang == language), None | |
| (i for i, t in enumerate(segment.translations) if t.lang == translation_language), None |
…re#5383) ## Summary - Reverts merge commit 8a0c075 (PR BasedHardware#5272) per manager request - PR was merged without explicit manager approval, violating team process ## What's reverted - Translate API cost optimization (detect_language elimination, debounce, Redis cache, batch calls) - 66 unit tests in `test_translation_optimization.py` Code is preserved on the original branch for re-merge when approved. _by AI for @beastoin_
Summary
What's reverted
test_translation_optimization.pyCode is preserved on the original branch for re-merge when approved.
by AI for @beastoin