Skip to content

Use backend model catalog in selector#495

Merged
AnthonyRonning merged 1 commit intomasterfrom
droid/maple-model-catalog-aliases
Apr 28, 2026
Merged

Use backend model catalog in selector#495
AnthonyRonning merged 1 commit intomasterfrom
droid/maple-model-catalog-aliases

Conversation

@AnthonyRonning
Copy link
Copy Markdown
Contributor

@AnthonyRonning AnthonyRonning commented Apr 27, 2026

Summary

  • Store Quick/Powerful as stable auto aliases instead of concrete model IDs.
  • Fetch backend-owned model metadata for selector rendering and advanced models, with legacy fallback support.
  • Migrate sticky cached model choices while keeping explicit advanced model selections concrete.

Validation

  • npm --prefix /Users/tony/Dev/OpenSecret/maple/frontend run typecheck
  • npm --prefix /Users/tony/Dev/OpenSecret/maple/frontend run lint
  • npm --prefix /Users/tony/Dev/OpenSecret/maple/frontend run build
  • nix develop /Users/tony/Dev/OpenSecret/maple -c git commit hook ran bun format/build/test

Open in Devin Review

Summary by CodeRabbit

  • New Features

    • Models now load from a remote catalog with alias-driven "Quick" and "Powerful" defaults and alias-aware selection.
  • Updates

    • Model selector displays richer metadata (badges, access, capabilities), improved filtering/sorting, disabled/restricted states, and vision icons.
    • Image-upload auto-switch now picks a vision-capable accessible model from the catalog.
    • Usage examples updated to alias-based defaults; selected-model persistence and metadata caching improved.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 27, 2026

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Replaces static MODEL_CONFIG with an OpenSecret model catalog + alias system (adds auto:quick/auto:powerful), loads catalog on init, derives access/capabilities/vision from catalog metadata, updates UI and auto-image switching to use aliases, and adds alias-aware migration and cached selected-model metadata.

Changes

Cohort / File(s) Summary
Model selector & examples
frontend/src/components/ModelSelector.tsx, frontend/src/components/apikeys/ProxyConfigSection.tsx
Removed hardcoded MODEL_CONFIG/token-limit exports; switched to fetchModelCatalog()/alias-driven model loading, alias resolution for active/disabled/restricted states, vision-capable auto-switch, UI badges/labels, and updated example snippets to use QUICK_MODEL_ALIAS.
Local state & selection logic
frontend/src/state/LocalStateContext.tsx
Added modelAliases + setModelAliases; introduced QUICK_MODEL_ALIAS/POWERFUL_MODEL_ALIAS as defaults; changed setModel signature to accept optional modelMetadata; added setModelInternal(..., persist) behavior and localStorage caching of selected-model metadata with migration handling.
Types & catalog shapes
frontend/src/state/LocalStateContextDef.ts
Added types for model access tiers, capabilities, aliases, and catalog; extended OpenSecretModel with provider/display/context/access/capabilities/badges/enabled/deprecated/sort_order; updated LocalState to include modelAliases and new setModel signature.
Alias and utils
frontend/src/utils/utils.ts
Added QUICK_MODEL_ALIAS/POWERFUL_MODEL_ALIAS, updated MODEL_NAME_ALIASES to map legacy IDs to auto aliases, added STICKY_MODEL_NAME_ALIASES, and exported migrateStickyModelName() migration helper.

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
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

🐇 I hopped from lists of names to a catalog bright,
Quick and Powerful now ready for flight.
Aliases stitched, metadata hums like a lute,
I nudge the picker—models tidy, astute. 🥕

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and clearly summarizes the primary change: migrating from hardcoded model IDs to using a backend-driven model catalog system in the ModelSelector component.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch droid/maple-model-catalog-aliases

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Apr 27, 2026

Deploying maple with  Cloudflare Pages  Cloudflare Pages

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

View logs

coderabbitai[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

@AnthonyRonning AnthonyRonning force-pushed the droid/maple-model-catalog-aliases branch from cfdef69 to 0c6c054 Compare April 28, 2026 01:35
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>
@AnthonyRonning AnthonyRonning force-pushed the droid/maple-model-catalog-aliases branch from 0c6c054 to bc78224 Compare April 28, 2026 01:38
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 new potential issue.

View 14 additional findings in Devin Review.

Open in Devin Review

Comment on lines +155 to +169
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);
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.

🟡 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.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@AnthonyRonning AnthonyRonning merged commit 0add8c7 into master Apr 28, 2026
14 checks passed
@AnthonyRonning AnthonyRonning deleted the droid/maple-model-catalog-aliases branch April 28, 2026 03:27
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