Use backend model catalog in selector#495
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughReplaces static MODEL_CONFIG with an OpenSecret model catalog + alias system (adds Changes
Sequence Diagram(s)sequenceDiagram
participant UI as Client UI
participant MS as ModelSelector
participant API as OpenSecret Catalog API
participant LS as LocalState
UI->>MS: init/open
MS->>API: fetchModelCatalog()
API-->>MS: catalog + aliases
MS->>LS: setModelAliases(catalog.aliases)
MS->>LS: setModel(modelIdOrAlias, modelMetadata)
LS-->>MS: persist metadata / ack
MS->>UI: render list (aliases, capabilities, vision)
UI->>MS: user selects model or uploads image
MS->>LS: choose accessible vision-capable model (alias-aware)
LS-->>UI: active model applied
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Deploying maple with
|
| Latest commit: |
bc78224
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://253efa2e.maple-ca8.pages.dev |
| Branch Preview URL: | https://droid-maple-model-catalog-al.maple-ca8.pages.dev |
cfdef69 to
0c6c054
Compare
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> Preserve concrete model selections Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> Address model selector review feedback Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> Harden model catalog fallback handling Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> Align catalog selection filters Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> Remove legacy model migrations Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> Update OpenSecret SDK to 3.1.1 Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
0c6c054 to
bc78224
Compare
| if (modelClient.fetchModels) { | ||
| const models = await modelClient.fetchModels(); | ||
| const availableGenerateModels = models.filter((availableModel) => { | ||
| const tasks = availableModel.tasks || []; | ||
| if (tasks.length > 0) return tasks.includes("generate"); | ||
| const id = availableModel.id.toLowerCase(); | ||
| return !id.includes("whisper") && !id.includes("embed"); | ||
| }); | ||
| hasFetched.current = true; | ||
| setHasWhisperModel( | ||
| models.some((availableModel) => availableModel.id === "whisper-large-v3") | ||
| ); | ||
| setAvailableModels(availableGenerateModels); | ||
| setModelAliases(buildFallbackModelAliases(availableGenerateModels)); | ||
| reconcileSelectedConcreteModel(availableGenerateModels); |
There was a problem hiding this comment.
🟡 Loss of model access-tier restrictions in fetchModels fallback path
When fetchModelCatalog is unavailable or throws (falling back to the old fetchModels API), the returned Model objects lack the access property. In the hasAccessToModel callback, getAccess defaults to "free" when access is undefined (modelById.get(modelId)?.access || "free" at frontend/src/components/ModelSelector.tsx:219). This means all models appear accessible to all users in the advanced model list, including pro-only models like "kimi-k2-6" that free-tier users should not be able to select.
The old code used hardcoded MODEL_CONFIG entries with requiresPro/requiresStarter flags which always enforced access restrictions regardless of the API response. The buildFallbackModelAliases function at frontend/src/components/ModelSelector.tsx:59-75 correctly sets access tiers on the aliases (Quick/Powerful), but individual concrete models shown in "More models" lose their restrictions. A free user could select a pro-only model from the advanced list without seeing the upgrade dialog (though the backend would still reject the API call).
Prompt for agents
In the fetchModels fallback path (ModelSelector.tsx lines 155-169), models returned by the old fetchModels API lack the access property that the new catalog API provides. This means hasAccessToModel (which defaults to 'free' when access is undefined) treats all models as free-tier, removing the lock icon and upgrade prompt for pro/starter models in the advanced model list.
Consider enriching the fallback models with access metadata from a hardcoded mapping (similar to the removed MODEL_CONFIG), or include the access info in buildFallbackModelAliases so it can be used to annotate individual models. For example, maintain a small FALLBACK_MODEL_ACCESS map (e.g. {"kimi-k2-6": "pro", "gemma4-31b": "starter"}) and apply it to models in the fallback filter. This way the access restrictions degrade gracefully when the catalog endpoint is unavailable.
Was this helpful? React with 👍 or 👎 to provide feedback.
Summary
Validation
Summary by CodeRabbit
New Features
Updates