Skip to content

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

Closed
Musheer360 wants to merge 9 commits into
masterfrom
feat/realtime-dynamic-model-lists
Closed

Musheer360 wants to merge 9 commits into
masterfrom
feat/realtime-dynamic-model-lists

Conversation

@Musheer360

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.

Musheer360 and others added 8 commits August 26, 2026 14:28
…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.
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>
Copilot AI lite review requested due to automatic review settings September 2, 2026 17:44

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

The provider model-fetch cache currently only records “attempted” on non-empty success, which can cause repeated auto-fetching behavior and conflicts with the cache contract.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds dynamic, live-fetched model catalogs for Gemini and Groq in Settings (with session caching + refreshed localization), while consolidating several dependency/tooling upgrades (Gradle/AGP/Compose BOM + GitHub Actions).

Changes:

  • Implement provider-backed /models listing for Gemini/Groq and render read-only, scrollable dynamic dropdowns in Settings, with session cache and refresh affordance.
  • Update model normalization for Gemini/Groq to allow trimmed pass-through of dynamic IDs while migrating known-retired IDs to defaults; add/adjust unit tests accordingly.
  • Apply consolidated dependency and CI workflow bumps (Gradle wrapper, AGP plugin, Compose BOM, actions/github-script, actions/setup-java) plus new localized strings.
File summaries
File Description
gradle/wrapper/gradle-wrapper.properties Bumps Gradle wrapper to 9.7.1 with updated SHA.
build.gradle.kts Bumps Android Gradle plugin version to 9.3.2 (apply false).
app/build.gradle.kts Updates Compose BOM to 2026.08.00.
.github/workflows/preview-comment.yml Updates actions/github-script pin to v9.0.0 commit.
.github/workflows/build.yml Updates actions/setup-java pin to v6.0.0 commit.
app/src/main/java/com/musheer360/swiftslate/ui/SettingsScreen.kt Adds dynamic Gemini/Groq dropdowns, background model fetch, refresh UI, and per-provider status messaging.
app/src/main/java/com/musheer360/swiftslate/api/GeminiClient.kt Adds Gemini models listing (fetchModels) and JSON parsing helper for /models.
app/src/main/java/com/musheer360/swiftslate/manager/ProviderModelsCache.kt Introduces process-lifetime cache for provider model lists and “attempted” tracking.
app/src/main/java/com/musheer360/swiftslate/model/GeminiModels.kt Updates sanitize behavior to allow trimmed pass-through except for blank/retired IDs.
app/src/main/java/com/musheer360/swiftslate/model/GroqModels.kt Adds retired IDs list, chat-candidate filtering helper, and updated sanitize behavior.
app/src/test/java/com/musheer360/swiftslate/api/GeminiModelsListParserTest.kt Adds parser unit tests for Gemini /models responses (Robolectric).
app/src/test/java/com/musheer360/swiftslate/model/CatalogTest.kt Updates tests for new sanitize behavior and Groq chat-candidate filtering.
app/src/test/java/com/musheer360/swiftslate/provider/ProviderConfigTest.kt Updates Gemini config test to cover dynamic ID pass-through.
app/src/main/res/values/strings.xml Adds new Settings strings for refresh/need-key/failure/empty-provider states.
app/src/main/res/values-ar/strings.xml Translates new Settings strings (Arabic).
app/src/main/res/values-bg/strings.xml Translates new Settings strings (Bulgarian).
app/src/main/res/values-ca/strings.xml Translates new Settings strings (Catalan).
app/src/main/res/values-cs/strings.xml Translates new Settings strings (Czech).
app/src/main/res/values-da/strings.xml Translates new Settings strings (Danish).
app/src/main/res/values-de/strings.xml Translates new Settings strings (German).
app/src/main/res/values-el/strings.xml Translates new Settings strings (Greek).
app/src/main/res/values-es/strings.xml Translates new Settings strings (Spanish).
app/src/main/res/values-et/strings.xml Translates new Settings strings (Estonian).
app/src/main/res/values-fa/strings.xml Translates new Settings strings (Persian).
app/src/main/res/values-fi/strings.xml Translates new Settings strings (Finnish).
app/src/main/res/values-fr/strings.xml Translates new Settings strings (French).
app/src/main/res/values-hi/strings.xml Translates new Settings strings (Hindi).
app/src/main/res/values-hr/strings.xml Translates new Settings strings (Croatian).
app/src/main/res/values-hu/strings.xml Translates new Settings strings (Hungarian).
app/src/main/res/values-in/strings.xml Translates new Settings strings (Indonesian).
app/src/main/res/values-it/strings.xml Translates new Settings strings (Italian).
app/src/main/res/values-iw/strings.xml Translates new Settings strings (Hebrew).
app/src/main/res/values-ja/strings.xml Translates new Settings strings (Japanese).
app/src/main/res/values-ko/strings.xml Translates new Settings strings (Korean).
app/src/main/res/values-lt/strings.xml Translates new Settings strings (Lithuanian).
app/src/main/res/values-lv/strings.xml Translates new Settings strings (Latvian).
app/src/main/res/values-ms/strings.xml Translates new Settings strings (Malay).
app/src/main/res/values-nb/strings.xml Translates new Settings strings (Norwegian Bokmål).
app/src/main/res/values-nl/strings.xml Translates new Settings strings (Dutch).
app/src/main/res/values-pl/strings.xml Translates new Settings strings (Polish).
app/src/main/res/values-pt/strings.xml Translates new Settings strings (Portuguese).
app/src/main/res/values-pt-rBR/strings.xml Translates new Settings strings (Portuguese, Brazil).
app/src/main/res/values-ro/strings.xml Translates new Settings strings (Romanian).
app/src/main/res/values-ru/strings.xml Translates new Settings strings (Russian).
app/src/main/res/values-sk/strings.xml Translates new Settings strings (Slovak).
app/src/main/res/values-sl/strings.xml Translates new Settings strings (Slovenian).
app/src/main/res/values-sr/strings.xml Translates new Settings strings (Serbian).
app/src/main/res/values-sv/strings.xml Translates new Settings strings (Swedish).
app/src/main/res/values-th/strings.xml Translates new Settings strings (Thai).
app/src/main/res/values-tr/strings.xml Translates new Settings strings (Turkish).
app/src/main/res/values-uk/strings.xml Translates new Settings strings (Ukrainian).
app/src/main/res/values-vi/strings.xml Translates new Settings strings (Vietnamese).
app/src/main/res/values-zh/strings.xml Translates new Settings strings (Chinese).
app/src/main/res/values-zh-rCN/strings.xml Translates new Settings strings (Chinese, China).
Review details
  • Files reviewed: 53/54 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +142 to +151
val models = result.getOrNull().orEmpty()
val success = result.isSuccess && models.isNotEmpty()
val message = when {
result.isSuccess && models.isEmpty() -> modelsEmptyProviderMsg
result.isSuccess -> String.format(modelsLoadedMsg, models.size)
else -> modelsLoadFailedMsg
}
if (success) {
ProviderModelsCache.put(type, ProviderModelsCache.Entry(models, attempted = true))
}
Comment on lines +824 to +828
DropdownMenuItem(
text = {
Text(
text = if (!enabled) needKeyText else stringResource(R.string.settings_fetch_models_empty),
fontSize = 13.sp,
@github-actions

github-actions Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

📦 Preview APK — PR #162 · b6e7acd · 1.45 MB

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

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

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