Skip to content

fix: web recorder ignores selected transcription language, always sends multi#5547

Open
krushnarout wants to merge 2 commits intomainfrom
fix/transcription-language-preference
Open

fix: web recorder ignores selected transcription language, always sends multi#5547
krushnarout wants to merge 2 commits intomainfrom
fix/transcription-language-preference

Conversation

@krushnarout
Copy link
Member

@krushnarout krushnarout commented Mar 10, 2026

Cause

GET /v1/users/transcription-preferences never returned the language field, so prefs.language was always undefined in the recorder. This caused the WebSocket to fall back to language=multi (auto-detect), overriding whatever language the user had set in Settings.

Fix

  • Added language field to TranscriptionPreferencesResponse in backend/routers/users.py
  • Updated get_user_transcription_preferences in backend/database/users.py to read and return the top-level language field from the user document

Demo

Before

Screen.Recording.2026-03-10.at.10.36.23.PM.mov

After

Screen.Recording.2026-03-10.at.10.59.08.PM.mov

closes #4808

krushnarout and others added 2 commits March 10, 2026 22:41
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 10, 2026

Greptile Summary

This PR fixes a bug where the web recorder always sent language=multi to the WebSocket transcription endpoint, ignoring the user's saved language preference. The root cause was that GET /v1/users/transcription-preferences never included the language field in its response, so the recorder always received undefined and fell back to multi.

Changes:

  • backend/database/users.py: get_user_transcription_preferences now also reads the top-level language field from the user Firestore document (consistent with how set_user_language_preference stores it) and includes it in the returned dict. No additional Firestore reads are introduced since the document was already being fetched.
  • backend/routers/users.py: TranscriptionPreferencesResponse Pydantic model gains a language: str = '' field so the value is serialised in the API response.

The fix is minimal, correct, and well-scoped. The only minor gap is that the endpoint docstring at line 511 was not updated to reflect the new language field.

Confidence Score: 5/5

  • This PR is safe to merge — it is a narrow, backwards-compatible bug fix with no breaking changes.
  • The change is two-line and directly addresses the described bug. The language field is read from the exact same Firestore path used by the existing get_user_language_preference function, so the data source is correct. The Pydantic model addition is additive and the default empty string matches the existing fallback, so no regressions are expected for clients that don't yet consume the new field.
  • No files require special attention.

Important Files Changed

Filename Overview
backend/database/users.py Adds language field to the return dict of get_user_transcription_preferences, correctly reading from the top-level user_data document (consistent with how set_user_language_preference stores it). No extra Firestore reads introduced.
backend/routers/users.py Adds language: str = '' to TranscriptionPreferencesResponse Pydantic model so the field is serialised in the API response. Endpoint docstring is slightly stale (only mentions single_language_mode and vocabulary).

Sequence Diagram

sequenceDiagram
    participant WebRecorder as Web Recorder
    participant API as GET /v1/users/transcription-preferences
    participant DB as Firestore (users/{uid})

    WebRecorder->>API: GET transcription-preferences
    API->>DB: user_ref.get()
    DB-->>API: user_doc { language, transcription_preferences: { single_language_mode, vocabulary } }
    API-->>WebRecorder: { single_language_mode, vocabulary, language }
    Note over WebRecorder: language is now "de" (not undefined)
    WebRecorder->>WebRecorder: Build WS URL with language=de
Loading

Comments Outside Diff (1)

  1. backend/routers/users.py, line 511 (link)

    Outdated endpoint docstring

    The docstring still lists only single language mode, vocabulary but the endpoint now also returns language. Worth keeping this in sync so the docstring accurately reflects the response shape.

Last reviewed commit: ec35510

@krushnarout krushnarout requested a review from mdmohsin7 March 10, 2026 17:16
return {
'single_language_mode': prefs.get('single_language_mode', False),
'vocabulary': prefs.get('vocabulary', []),
'language': user_data.get('language', ''),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to make changes to the backend? How has the mobile app been working with language detection without any of these backend changes?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mobile app:

When a user changes their language in the app, INFO: 192.168.1.25:58408 - "PATCH /v1/users/language HTTP/1.1" 200 OK change the language, but when building the socket url for transcription, the app reads language directly from local SharedPreferences on the device. It never asks the backend for it.

web:

It fetches language from GET /v1/users/transcription-preferences at recording time. The problem was that endpoint never returned a language field, so prefs.language was always undefined, causing the recorder to fall back to language=multi, adding language to that response, so the web recorder can read what the user actually chose, PATCH /v1/users/language already saved it correctly to firestore

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.

Omi Web ignores selected transcription language; recorder always sends language=multi

2 participants