fix(desktop): align transcription language options#7209
fix(desktop): align transcription language options#7209waffensam wants to merge 2 commits intoBasedHardware:mainfrom
Conversation
Greptile SummaryThis PR aligns the desktop transcription language picker with backend-approved Deepgram Nova-3 language codes, adding Chinese variants (zh-CN/HK/TW) and many additional languages, and introduces
Confidence Score: 4/5Safe to merge; the normalization logic is well-covered by tests and the call-site changes are minimal and consistent. The getter write-back migration fires without posting The write-back path in Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["Raw language string\n(UserDefaults / backend / chat tool)"] --> B["normalizeTranscriptionLanguageCode()"]
B --> C{In alias\ndictionary?}
C -- Yes --> D["Return canonical code\n(e.g. 'zh-CN', 'pt-BR')"]
C -- No --> E{Case-insensitive match\nin supportedLanguages?}
E -- Yes --> F["Return canonical code\nfrom supportedLanguages"]
E -- No --> G["Return underscore→dash\nnormalized value as-is"]
D --> H["supportsAutoDetect()"]
F --> H
G --> H
H --> I{In\nmultiLanguageSupported?}
I -- Yes --> J["effectiveLanguage = 'multi'\n(auto-detect)"]
I -- No --> K["effectiveLanguage = specific code\n(single-language mode)"]
J --> L["/v4/listen API"]
K --> L
Reviews (1): Last reviewed commit: "fix(desktop): align transcription langua..." | Re-trigger Greptile |
| if normalized != value { | ||
| UserDefaults.standard.set(normalized, forKey: transcriptionLanguageKey) | ||
| } | ||
| return normalized |
There was a problem hiding this comment.
The
transcriptionLanguage getter silently writes a normalized value back to UserDefaults without posting transcriptionSettingsDidChange. Every other mutation to transcriptionLanguage goes through the setter, which always posts the notification so observers (e.g., the audio stack) can react. If an observer is active at the moment this one-time migration fires, it won't be told the value changed, leaving the streamed language code potentially stale until the next explicit set.
| if normalized != value { | |
| UserDefaults.standard.set(normalized, forKey: transcriptionLanguageKey) | |
| } | |
| return normalized | |
| if normalized != value { | |
| UserDefaults.standard.set(normalized, forKey: transcriptionLanguageKey) | |
| NotificationCenter.default.post(name: .transcriptionSettingsDidChange, object: nil) | |
| } | |
| return normalized |
| override func setUp() { | ||
| super.setUp() | ||
| UserDefaults.standard.removeObject(forKey: languageKey) | ||
| } | ||
|
|
||
| override func tearDown() { | ||
| UserDefaults.standard.removeObject(forKey: languageKey) | ||
| super.tearDown() | ||
| } |
There was a problem hiding this comment.
testChineseDoesNotUseAutoDetectMultiLanguageMode writes true to AssistantSettings.shared.transcriptionAutoDetect, but tearDown only removes transcriptionLanguage from UserDefaults. The transcriptionAutoDetect key is left dirty for any subsequent test that reads effectiveTranscriptionLanguage on the shared singleton. Adding transcriptionAutoDetect removal to both setUp and tearDown keeps tests independent of execution order.
| override func setUp() { | |
| super.setUp() | |
| UserDefaults.standard.removeObject(forKey: languageKey) | |
| } | |
| override func tearDown() { | |
| UserDefaults.standard.removeObject(forKey: languageKey) | |
| super.tearDown() | |
| } | |
| private let autoDetectKey = "transcriptionAutoDetect" | |
| override func setUp() { | |
| super.setUp() | |
| UserDefaults.standard.removeObject(forKey: languageKey) | |
| UserDefaults.standard.removeObject(forKey: autoDetectKey) | |
| } | |
| override func tearDown() { | |
| UserDefaults.standard.removeObject(forKey: languageKey) | |
| UserDefaults.standard.removeObject(forKey: autoDetectKey) | |
| super.tearDown() | |
| } |
Summary
chinese,zh,中文, andbrinto language codes accepted by the streaming endpoint, and write normalized persisted values back once read.Test plan
swift test --package-path Desktop --filter AssistantSettingsLanguageTests