Skip to content

feat(settings): real-time dynamic Gemini/Groq model lists + bundle dependabot updates - #153

Merged
Musheer360 merged 15 commits into
masterfrom
feat/dynamic-model-lists
Sep 2, 2026
Merged

Musheer360 merged 15 commits into
masterfrom
feat/dynamic-model-lists

Conversation

@Musheer360

@Musheer360 Musheer360 commented Aug 26, 2026 •

Copy link
Copy Markdown
Owner

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)

  • Instant Dropdown Expansion: Opening the dropdown menu renders immediately (0ms UI lag) with cached or curated defaults, avoiding freezing.
  • Real-Time On-Open Fetching: Expanding the dropdown (onExpandedChange) triggers a live asynchronous query to the provider's /models endpoint in the background.
  • In-Menu Loading Feedback: While the request is in flight, an elegant inline loader (CircularProgressIndicator + settings_fetch_models_loading) appears at the top of the menu, followed by a SlateDivider. Once fetched, the menu recomposes in place.
  • Strict Read-Only Selection: Anchored with SlateTextField(readOnly = true, PrimaryNotEditable) so users select valid active models without manual typing errors.
  • Bounded & Scrollable: Constrained to Modifier.heightIn(max = 300.dp) with smooth vertical scroll so large catalogs (50+ models) stay compact.
  • 100% Theme-Consistent: Uses SwiftSlate design tokens (RoundedCornerShape(10.dp), MaterialTheme.colorScheme.surface, primary, onSurface, SlateTextField, SlateDivider).
  • Resilient Fallbacks: Network failures or offline states preserve fallback/curated presets (GeminiModels.ALL and GroqModels.ALL) without clearing the list.

Provider Listing Contracts

  • Gemini (GET v1beta/models): Implements GeminiClient.fetchModels(apiKey). Checks supportedGenerationMethods / supportedActions for "generateContent", strips "models/" prefix, and safely URL-encodes nextPageToken (up to 3 pages).
  • Groq (GET /openai/v1/models): Probes endpoint via OpenAICompatibleClient.fetchModels and filters out audio (whisper), TTS (playai, -tts), and safety classifiers (guard) via GroqModels.isChatCandidate.
  • Model Normalization (sanitize): Updates GeminiModels.sanitize and GroqModels.sanitize to pass through trimmed dynamic IDs while migrating retired IDs (gemini-2.5-flash-lite, llama-3.3-70b-versatile) to DEFAULT.
  • Localization: All 4 new settings strings translated across all 40+ supported locales.

Consolidated Dependabot Upgrades

Testing

  • Unit tests: GeminiModelsListParserTest, CatalogTest, ProviderConfigTest. Full ./gradlew testDebugUnitTest passing cleanly on Gradle 9.7.1 and AGP 9.3.2.
  • Lint verification: ./gradlew :app:lintDebug passing with 0 errors across all 40+ locales.
  • Live API verification: Tested against real Gemini and Groq API endpoints.

…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.
Copilot AI lite review requested due to automatic review settings August 26, 2026 09:01
@github-actions

github-actions Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

📦 Preview APK — PR #153 · 40c5a9a · 1.44 MB

Direct download · Run · SwiftSlate-preview-pr153.zip → single .apk, no folders · expires 14d

Unzip → installs as SwiftSlate Preview (com.musheer360.swiftslate.preview), separate from stable. Enable in Settings → Accessibility.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 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() (paginated v1beta/models) and parse/filter to generateContent-capable entries.
  • Fetch Groq models via the existing OpenAI-compatible /openai/v1/models prober 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"
Comment thread app/src/main/res/values/strings.xml Outdated
Comment on lines +151 to +152
<!-- TODO translate: new strings for the dynamic Gemini/Groq model dropdowns; they fall
back to English in the other locales until translated. -->
Comment on lines +326 to +332
// 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,
Musheer360 and others added 7 commits August 26, 2026 15:04
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>
@Musheer360

Copy link
Copy Markdown
Owner Author

Superseded by #162 which implements real-time dynamic model fetching on dropdown open, fixes Copilot review catches, and consolidates all 5 open Dependabot updates.

@Musheer360 Musheer360 closed this Sep 2, 2026
@Musheer360
Musheer360 deleted the feat/dynamic-model-lists branch September 2, 2026 17:52
@Musheer360 Musheer360 reopened this Sep 2, 2026
@Musheer360 Musheer360 changed the title feat(settings): dynamic Gemini/Groq model lists from live /models endpoints feat(settings): real-time dynamic Gemini/Groq model lists + bundle dependabot updates Sep 2, 2026
@Musheer360

Copy link
Copy Markdown
Owner Author

Reopened with all improvements incorporated:

@Musheer360
Musheer360 merged commit cba3cdb into master Sep 2, 2026
9 checks passed
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.

Allow custom model name input for Gemini and Groq providers

2 participants