Skip to content

feat: load available models. - #149

Merged
knightedcodemonkey merged 2 commits into
chatfrom
chat-phase-4
Sep 7, 2026
Merged

feat: load available models.#149
knightedcodemonkey merged 2 commits into
chatfrom
chat-phase-4

Conversation

@knightedcodemonkey

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI lite review requested due to automatic review settings September 7, 2026 14:41

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

It currently performs unnecessary model-catalog network requests when no key is present and has a robustness issue in free-model detection that can misclassify pricing responses.

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

Pull request overview

Adds a live model catalog flow to the chat drawer so the model <select> can be populated from OpenRouter’s /models endpoint (with fallback to the existing static list), and refactors the picker logic into a dedicated module.

Changes:

  • Introduces createChatModelPicker() to manage model option rendering, grouping (Free/Paid), and catalog caching.
  • Adds fetchChatModelOptions() to query and normalize the OpenRouter models catalog (tool-capable models only).
  • Wires the drawer to refresh model options on open and on key changes.
File summaries
File Description
src/modules/chat/model-picker.js New module encapsulating model select state, option rendering, and catalog loading/caching.
src/modules/chat/drawer.js Refactors drawer to delegate model selection and catalog refresh behavior to the new picker.
src/modules/chat/api/models.js New OpenRouter models catalog fetch + normalization logic (tools-capable filtering, free-first sorting).
src/modules/chat/api/constants.js Adds the /models endpoint constant.
src/modules/chat/api/completions.js Re-exports model-catalog helpers alongside existing completions API exports.
Review details

Suppressed comments (1)

src/modules/chat/drawer.js:238

  • Opening the drawer currently attempts to load the model catalog even when no key is present (the composer/select are disabled). Guarding this avoids an unnecessary network request.
    if (open) {
      void modelPicker.loadModelOptionsFromCatalog()
    }
  • Files reviewed: 5/5 changed files
  • Comments generated: 5
  • 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 thread src/modules/chat/api/models.js Outdated
return false
}

return pricing.prompt === '0' && pricing.completion === '0'
Comment thread src/modules/chat/drawer.js Outdated
Comment on lines +185 to +187
if (open) {
void modelPicker.loadModelOptionsFromCatalog({ force: true })
}
Comment on lines +92 to +93
const token = getChatKey()
const normalizedToken = typeof token === 'string' ? token.trim() : ''
Comment thread src/modules/chat/api/completions.js Outdated
Comment on lines +454 to +458
export {
chatModelOptions,
defaultChatModel,
fetchChatModelOptions,
isFreeChatModel,
Comment thread src/modules/chat/model-picker.js Outdated
@knightedcodemonkey
knightedcodemonkey merged commit 2c2cd87 into chat Sep 7, 2026
5 checks passed
@knightedcodemonkey
knightedcodemonkey deleted the chat-phase-4 branch September 7, 2026 16:00
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.

2 participants