Repository navigation
feat(settings): real-time dynamic Gemini/Groq model lists + bundle dependabot updates - #153
Conversation
…points Replaces the two hardcoded two-model dropdowns with lists fetched from each provider's models endpoint (issue #148): - GeminiClient.fetchModels(): paginated GET v1beta/models keeping only generateContent-capable entries (fail-open when the capability array is absent); error mapping mirrors validateKey - Groq rides the existing OpenAI-compatible prober against its fixed endpoint; whisper/tts/guard entries filtered client-side - auto-fetch once per process per provider, session-only cache (ProviderModelsCache) so tab switches don't refetch; manual Refresh, inline failure message + Retry path; no-key hint state - dropdown capped at 320dp and scrolls for long catalogs - sanitize() passes unknown ids through trimmed; only blank values and known-retired ids migrate to DEFAULT (RETIRED_IDS) - strings translated across all 40 locales Verified: :app:testDebugUnitTest and :app:lintDebug green.
📦 Preview APK — PR #153 ·
|
There was a problem hiding this comment.
🟡 Changes recommended
There are correctness and contract gaps (e.g., Gemini pagination token should be URL-encoded, and the PR claims to resolve #148 but Gemini/Groq UI remains read-only without custom model input).
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR updates the Settings model selection for Gemini and Groq to use dynamic model lists fetched from each provider’s live /models endpoint, and adjusts model sanitization logic so dynamically selected (unknown) model IDs are preserved instead of being coerced back to defaults.
Changes:
- Fetch Gemini models via
GeminiClient.fetchModels()(paginatedv1beta/models) and parse/filter togenerateContent-capable entries. - Fetch Groq models via the existing OpenAI-compatible
/openai/v1/modelsprober and filter out non-chat entries client-side. - Update Gemini/Groq model sanitization to pass through unknown IDs (trimmed) while still migrating blank/retired IDs to defaults; add/adjust unit tests and localized strings.
File summaries
| File | Description |
|---|---|
| app/src/main/java/com/musheer360/swiftslate/api/GeminiClient.kt | Adds /models listing fetch + JSON parser for Gemini model IDs. |
| app/src/main/java/com/musheer360/swiftslate/manager/ProviderModelsCache.kt | Adds session-only cache for provider model lists and “attempted” state. |
| app/src/main/java/com/musheer360/swiftslate/model/GeminiModels.kt | Allows trimmed unknown model IDs; retains retired-ID migration. |
| app/src/main/java/com/musheer360/swiftslate/model/GroqModels.kt | Allows trimmed unknown model IDs; adds retired-ID migration + chat-candidate filtering helpers. |
| app/src/main/java/com/musheer360/swiftslate/ui/SettingsScreen.kt | Replaces hardcoded Gemini/Groq dropdown options with dynamic lists, refresh UI, and status messaging. |
| app/src/main/res/values/strings.xml | Adds new Settings strings for refresh/key-needed/error/empty states. |
| app/src/main/res/values-ar/strings.xml | Translates new Settings model-list strings. |
| app/src/main/res/values-bg/strings.xml | Translates new Settings model-list strings. |
| app/src/main/res/values-ca/strings.xml | Translates new Settings model-list strings. |
| app/src/main/res/values-cs/strings.xml | Translates new Settings model-list strings. |
| app/src/main/res/values-da/strings.xml | Translates new Settings model-list strings. |
| app/src/main/res/values-de/strings.xml | Translates new Settings model-list strings. |
| app/src/main/res/values-el/strings.xml | Translates new Settings model-list strings. |
| app/src/main/res/values-es/strings.xml | Translates new Settings model-list strings. |
| app/src/main/res/values-et/strings.xml | Translates new Settings model-list strings. |
| app/src/main/res/values-fa/strings.xml | Translates new Settings model-list strings. |
| app/src/main/res/values-fi/strings.xml | Translates new Settings model-list strings. |
| app/src/main/res/values-fr/strings.xml | Translates new Settings model-list strings. |
| app/src/main/res/values-hi/strings.xml | Translates new Settings model-list strings. |
| app/src/main/res/values-hr/strings.xml | Translates new Settings model-list strings. |
| app/src/main/res/values-hu/strings.xml | Translates new Settings model-list strings. |
| app/src/main/res/values-in/strings.xml | Translates new Settings model-list strings. |
| app/src/main/res/values-it/strings.xml | Translates new Settings model-list strings. |
| app/src/main/res/values-iw/strings.xml | Translates new Settings model-list strings. |
| app/src/main/res/values-ja/strings.xml | Translates new Settings model-list strings. |
| app/src/main/res/values-ko/strings.xml | Translates new Settings model-list strings. |
| app/src/main/res/values-lt/strings.xml | Translates new Settings model-list strings. |
| app/src/main/res/values-lv/strings.xml | Translates new Settings model-list strings. |
| app/src/main/res/values-ms/strings.xml | Translates new Settings model-list strings. |
| app/src/main/res/values-nb/strings.xml | Translates new Settings model-list strings. |
| app/src/main/res/values-nl/strings.xml | Translates new Settings model-list strings. |
| app/src/main/res/values-pl/strings.xml | Translates new Settings model-list strings. |
| app/src/main/res/values-pt/strings.xml | Translates new Settings model-list strings. |
| app/src/main/res/values-pt-rBR/strings.xml | Translates new Settings model-list strings. |
| app/src/main/res/values-ro/strings.xml | Translates new Settings model-list strings. |
| app/src/main/res/values-ru/strings.xml | Translates new Settings model-list strings. |
| app/src/main/res/values-sk/strings.xml | Translates new Settings model-list strings. |
| app/src/main/res/values-sl/strings.xml | Translates new Settings model-list strings. |
| app/src/main/res/values-sr/strings.xml | Translates new Settings model-list strings. |
| app/src/main/res/values-sv/strings.xml | Translates new Settings model-list strings. |
| app/src/main/res/values-th/strings.xml | Translates new Settings model-list strings. |
| app/src/main/res/values-tr/strings.xml | Translates new Settings model-list strings. |
| app/src/main/res/values-uk/strings.xml | Translates new Settings model-list strings. |
| app/src/main/res/values-vi/strings.xml | Translates new Settings model-list strings. |
| app/src/main/res/values-zh/strings.xml | Translates new Settings model-list strings. |
| app/src/main/res/values-zh-rCN/strings.xml | Translates new Settings model-list strings. |
| app/src/test/java/com/musheer360/swiftslate/api/GeminiModelsListParserTest.kt | Adds Robolectric test coverage for Gemini models JSON parsing/filtering. |
| app/src/test/java/com/musheer360/swiftslate/model/CatalogTest.kt | Updates Gemini/Groq sanitize expectations + adds Groq chat-candidate filtering tests. |
| app/src/test/java/com/musheer360/swiftslate/provider/ProviderConfigTest.kt | Updates Gemini config test to reflect new sanitize behavior. |
Review details
- Files reviewed: 49/49 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| try { | ||
| var pages = 0 | ||
| while (true) { | ||
| val pageSuffix = if (pageToken.isNullOrEmpty()) "" else "&pageToken=$pageToken" |
| <!-- TODO translate: new strings for the dynamic Gemini/Groq model dropdowns; they fall | ||
| back to English in the other locales until translated. --> |
| // Dynamic list (issue #148): fetched from the live /models endpoint. | ||
| DynamicModelDropdown( | ||
| selectedLabel = GeminiModels.label(selectedModel), | ||
| enabled = apiKeys.isNotEmpty(), | ||
| expanded = modelExpanded, | ||
| onExpandedChange = { modelExpanded = !modelExpanded } | ||
| ) { | ||
| SlateTextField( | ||
| value = GeminiModels.label(selectedModel), | ||
| onValueChange = {}, | ||
| readOnly = true, | ||
|
|
||
| modifier = Modifier.menuAnchor(ExposedDropdownMenuAnchorType.PrimaryNotEditable) | ||
| ) | ||
| ExposedDropdownMenu( | ||
| containerColor = MaterialTheme.colorScheme.surface, | ||
| shape = RoundedCornerShape(10.dp), | ||
| expanded = modelExpanded, | ||
| onDismissRequest = { modelExpanded = false } | ||
| ) { | ||
| geminiModels.forEach { (id, label) -> | ||
| DropdownMenuItem( | ||
| text = { Text(label) }, | ||
| onClick = { | ||
| haptic.performHapticFeedback(HapticFeedbackType.LongPress) | ||
| selectedModel = id | ||
| prefs.edit().putString(PrefKeys.GEMINI_MODEL, id).remove(PrefKeys.STRUCTURED_OUTPUT_DISABLED_AT).apply() | ||
| modelExpanded = false | ||
| } | ||
| ) | ||
| } | ||
| onExpandedChange = { modelExpanded = it }, | ||
| models = geminiModelList, |
Addresses the copilot review on PR #153: nextPageToken may contain '+', '/' or '=' which corrupt the query string when interpolated raw. Also removes the now-stale English-fallback TODO, since this branch ships all locale translations.
Bumps androidx.compose:compose-bom from 2026.06.01 to 2026.08.00. --- updated-dependencies: - dependency-name: androidx.compose:compose-bom dependency-version: 2026.08.00 dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com>
Bumps [actions/github-script](https://github.com/actions/github-script) from 7.1.0 to 9.0.0. - [Release notes](https://github.com/actions/github-script/releases) - [Commits](actions/github-script@f28e40c...3a2844b) --- updated-dependencies: - dependency-name: actions/github-script dependency-version: 9.0.0 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com>
Bumps com.android.application from 9.3.1 to 9.3.2. --- updated-dependencies: - dependency-name: com.android.application dependency-version: 9.3.2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
Bumps [actions/setup-java](https://github.com/actions/setup-java) from 5.7.0 to 6.0.0. - [Release notes](https://github.com/actions/setup-java/releases) - [Commits](actions/setup-java@b6effb0...dd06d9c) --- updated-dependencies: - dependency-name: actions/setup-java dependency-version: 6.0.0 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com>
Bumps [gradle-wrapper](https://github.com/gradle/gradle) from 9.7.0 to 9.7.1. - [Release notes](https://github.com/gradle/gradle/releases) - [Commits](gradle/gradle@v9.7.0...v9.7.1) --- updated-dependencies: - dependency-name: gradle-wrapper dependency-version: 9.7.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
…provider-specific empty text
|
Superseded by #162 which implements real-time dynamic model fetching on dropdown open, fixes Copilot review catches, and consolidates all 5 open Dependabot updates. |
|
Reopened with all improvements incorporated:
|
…S23 bottom clipping
…S23 height alignment
…ttom of built-ins
What does this PR do?
Resolves #148. Supersedes and consolidates #153 and all open Dependabot PRs (#149, #150, #156, #157, #158) into a single unified release candidate.
Real-Time Dynamic Model Dropdown (Gemini & Groq)
onExpandedChange) triggers a live asynchronous query to the provider's/modelsendpoint in the background.CircularProgressIndicator+settings_fetch_models_loading) appears at the top of the menu, followed by aSlateDivider. Once fetched, the menu recomposes in place.SlateTextField(readOnly = true, PrimaryNotEditable)so users select valid active models without manual typing errors.Modifier.heightIn(max = 300.dp)with smooth vertical scroll so large catalogs (50+ models) stay compact.RoundedCornerShape(10.dp),MaterialTheme.colorScheme.surface,primary,onSurface,SlateTextField,SlateDivider).GeminiModels.ALLandGroqModels.ALL) without clearing the list.Provider Listing Contracts
GET v1beta/models): ImplementsGeminiClient.fetchModels(apiKey). CheckssupportedGenerationMethods/supportedActionsfor"generateContent", strips"models/"prefix, and safely URL-encodesnextPageToken(up to 3 pages).GET /openai/v1/models): Probes endpoint viaOpenAICompatibleClient.fetchModelsand filters out audio (whisper), TTS (playai,-tts), and safety classifiers (guard) viaGroqModels.isChatCandidate.sanitize): UpdatesGeminiModels.sanitizeandGroqModels.sanitizeto pass through trimmed dynamic IDs while migrating retired IDs (gemini-2.5-flash-lite,llama-3.3-70b-versatile) toDEFAULT.Consolidated Dependabot Upgrades
androidx.compose:compose-bomfrom2026.06.01to2026.08.00(chore(deps): bump androidx.compose:compose-bom from 2026.06.01 to 2026.08.00 #149)actions/github-scriptfrom7.1.0to9.0.0(chore(deps): bump actions/github-script from 7.1.0 to 9.0.0 #150)com.android.applicationfrom9.3.1to9.3.2(chore(deps): bump com.android.application from 9.3.2 to 9.4.0 #156)actions/setup-javafrom5.7.0to6.0.0(chore(deps): bump actions/setup-java from 5.7.0 to 6.0.0 #157)gradle-wrapperfrom9.7.0to9.7.1(chore(deps): bump gradle-wrapper from 9.7.0 to 9.7.1 #158)Testing
GeminiModelsListParserTest,CatalogTest,ProviderConfigTest. Full./gradlew testDebugUnitTestpassing cleanly on Gradle 9.7.1 and AGP 9.3.2../gradlew :app:lintDebugpassing with 0 errors across all 40+ locales.