diff --git a/internal/tui/configure_transcription.go b/internal/tui/configure_transcription.go index edfc333..f37c002 100644 --- a/internal/tui/configure_transcription.go +++ b/internal/tui/configure_transcription.go @@ -125,13 +125,17 @@ func editTranscription(cfg *config.Config, configuredProviders []string) ([]stri modelDesc = fmt.Sprintf("Currently: %s", cfg.Transcription.Model) } - language := cfg.Transcription.Language + selectedLanguage := cfg.Transcription.Language - langDesc := "ISO-639-1 code (e.g., 'en', 'es', 'fr') or empty for auto-detect" - if cfg.Transcription.Language != "" { - langDesc = fmt.Sprintf("Currently: %s. %s", cfg.Transcription.Language, langDesc) + // get current model for language compatibility warnings + var currentModel *provider.Model + registryName := mapConfigProviderToRegistry(selectedProvider) + if m, err := provider.GetModel(registryName, selectedModel); err == nil { + currentModel = m } + languageOptions := getLanguageOptions(currentModel) + modelForm := huh.NewForm( huh.NewGroup( huh.NewSelect[string](). @@ -139,11 +143,12 @@ func editTranscription(cfg *config.Config, configuredProviders []string) ([]stri Description(modelDesc). Options(modelOptions...). Value(&selectedModel), - huh.NewInput(). + huh.NewSelect[string](). Title("Language"). - Description(langDesc). - Placeholder("auto-detect"). - Value(&language), + Description("Select language for transcription"). + Options(languageOptions...). + Filtering(true). + Value(&selectedLanguage), ), ).WithTheme(getTheme()) @@ -203,7 +208,7 @@ func editTranscription(cfg *config.Config, configuredProviders []string) ([]stri } cfg.Transcription.Model = selectedModel - cfg.Transcription.Language = language + cfg.Transcription.Language = selectedLanguage return configuredProviders, nil } diff --git a/internal/tui/languages.go b/internal/tui/languages.go new file mode 100644 index 0000000..7fdb069 --- /dev/null +++ b/internal/tui/languages.go @@ -0,0 +1,40 @@ +package tui + +import ( + "fmt" + + "github.com/charmbracelet/huh" + "github.com/leonardotrapani/hyprvoice/internal/language" + "github.com/leonardotrapani/hyprvoice/internal/provider" +) + +// getLanguageOptions returns language options for the dropdown +// if currentModel is provided, languages unsupported by that model will be marked +func getLanguageOptions(currentModel *provider.Model) []huh.Option[string] { + var options []huh.Option[string] + + // auto-detect is always first and recommended + options = append(options, huh.NewOption("Auto-detect (Recommended)", "")) + + // add all languages + for _, lang := range language.List() { + label := formatLanguageLabel(lang) + + // add warning if model doesn't support this language + if currentModel != nil && !currentModel.SupportsLanguage(lang.Code) { + label += " (not supported by current model)" + } + + options = append(options, huh.NewOption(label, lang.Code)) + } + + return options +} + +// formatLanguageLabel formats a language for display +func formatLanguageLabel(lang language.Language) string { + if lang.Name == lang.NativeName || lang.NativeName == "" { + return fmt.Sprintf("%s (%s)", lang.Name, lang.Code) + } + return fmt.Sprintf("%s - %s (%s)", lang.Name, lang.NativeName, lang.Code) +} diff --git a/progress.txt b/progress.txt index c84c218..57f7f06 100644 --- a/progress.txt +++ b/progress.txt @@ -285,4 +285,16 @@ Started: Sun Feb 1 12:22:47 AM CET 2026 - Updated getTranscriptionModelOptions() to show [x]/[ ] prefix for installed status - Added download confirmation dialog after selecting uninstalled model - Download shows progress percentage (10%, 20%, ...) +- All tests passing, typecheck passes + +### Task 29: Add language picker to TUI using language package +- Created `internal/tui/languages.go` with `getLanguageOptions()` function +- Takes optional `*provider.Model` to show compatibility warnings for non-supported languages +- First option is "Auto-detect (Recommended)" with empty value +- Languages formatted as "Name - NativeName (code)" when native name differs +- English-only models (*.en) show "(not supported by current model)" for non-English languages +- Updated `editTranscription()` to use `huh.NewSelect` with `Filtering(true)` instead of text input +- Pass current model to `getLanguageOptions()` for compatibility warnings +- Language code saved to config, not display name +- All 57 languages + Auto = 58 options total - All tests passing, typecheck passes \ No newline at end of file diff --git a/tasks/prd.jsonc b/tasks/prd.jsonc index 163c303..220e01d 100644 --- a/tasks/prd.jsonc +++ b/tasks/prd.jsonc @@ -689,7 +689,7 @@ "Selecting language saves the Code to config", "Typecheck passes" ], - "passes": false + "passes": true }, { "title": "Add TUI validation for language-model compatibility on save",