Skip to content

feat(models): load chat model selector from server - #89

Open
nutshellfool wants to merge 3 commits into
grapeot:masterfrom
nutshellfool:codex/dynamic-opencode-model-selector
Open

feat(models): load chat model selector from server#89
nutshellfool wants to merge 3 commits into
grapeot:masterfrom
nutshellfool:codex/dynamic-opencode-model-selector

Conversation

@nutshellfool

Copy link
Copy Markdown

Summary

Replace the hardcoded ModelPresets.list chat model selector with the full model list from the configured OpenCode server's GET /config/providers API.

  • AppState.selectedModel: Message.ModelInfo? is now the canonical selection state; the list index is derived for UI only, so server-side list reordering can never silently switch models
  • Model catalog (availableModels + providerModelsIndex) is built once per provider load via buildModelCatalog instead of computed getters on every recomposition
  • Selection persists by providerId/modelId globally and per session; legacy index-based storage is read-only for migration (resolution order: session saved → message inference → global saved → server default → legacy → first model)
  • Host/profile changes funnel through a single configureRepository choke point that clears the catalog only when the effective target actually changes, so same-profile foreground health checks keep the loaded catalog; a request-generation guard drops late provider responses from a previous server
  • buildSelectedModel validates the selection against the current catalog before sending, and omits the model (server default) while providers are loading

Notes

  • Rebased onto master @ v0.1.20260715: kept session deep links / AI usage quota / hostRuntimeScope intact; selectedAIUsageQuota now reads selectedModel?.providerId; GPT-5.6 Sol Pro/Fast short labels ported to the dynamic modelLabel logic; resetRuntimeForHostSwitch also clears the new catalog fields
  • Went through three review rounds (correctness/efficiency/design); plan doc included at docs/dynamic-opencode-model-selector-plan.md

Test plan

  • ./gradlew testDebugUnitTest — BUILD SUCCESSFUL after rebase
  • New coverage: provider-load selection resolution, cold-start inference after providers arrive late, same-profile reconnect keeping the catalog, stale provider response rejection, legacy preset migration

🤖 Generated with Claude Code

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.

1 participant