Repository navigation
feat(tui): /model lists the current provider's live models - #490
Conversation
Bare /model only listed configured roles, so a config with just a default role opened a one-row picker. It now shows the roles followed by every model the current provider serves, fetched asynchronously, and falls back to the roles-only picker when the listing fails. - /model switch [provider] lists one provider's models (current by default). - /model provider picks a configured provider, then one of its models. - Listed IDs keep their routing prefix when switching: agentgateway and openrouter serve IDs like openai/gpt-5, which resolution would otherwise cut to gpt-5 and send to the wrong route. The RPC switcher shares the fix. Signed-off-by: pi <dimetron@me.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #490 +/- ##
==========================================
+ Coverage 92.21% 92.25% +0.03%
==========================================
Files 426 427 +1
Lines 57744 57912 +168
==========================================
+ Hits 53251 53427 +176
+ Misses 4487 4479 -8
Partials 6 6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Move the TUI's four /model hooks into applyModelSwitching so they can be driven against a stub gateway, and cover the provider/model popup rendering, row descriptions and switch guards. Signed-off-by: pi <dimetron@me.com>
dimetron
left a comment
There was a problem hiding this comment.
Codex review of git diff origin/main...HEAD: 7 findings (6 medium, 1 low) — stale async listing results, routing of listed IDs (openrouter namespaces, gemma on gemini, ollama cloud via RPC), openrouter persistence, and initial scroll position.
— Codex review
- Drop a listing result superseded by a newer /model, or arriving after a run started or another popup opened; remove only its own placeholder. - Open the picker scrolled so the active model is visible. - Always prefix listed IDs for routing providers, so openrouter/auto keeps its namespace; leave ollama unprefixed so cloud models stay off localhost, and restore the RPC switcher's previous name handling. - With a provider named, fall back to it when detection does not know the name (gemma on Gemini, llama3 on Ollama) and let catalog validation decide. - Save OpenRouter models with their routing prefix so they resolve on restart. Signed-off-by: pi <dimetron@me.com>
|
Summary
Bare
/modelonly listed configured roles, so a config with a single default role opened a one-row picker. It now shows the roles followed by every model the current provider serves./model— roles first, then the current provider's live model list (fetched async, filterable, opens on the active model). Falls back to the roles-only picker, with the error, when the listing fails./model switch [provider]— one provider's models; the current provider by default./model provider— pick a configured provider (current first), then one of its models.Provider selection follows pi's and opencode's selectors, which both offer models across configured providers. Against agentgateway the list already spans every upstream (866 models: openrouter, openai, ollama, mistral, gemini, anthropic, xai, …).
Routing fix
A listed ID must reach its provider verbatim. Resolution strips known
<provider>/prefixes, so pickingopenai/gpt-5on agentgateway resolved togpt-5and hit the wrong route.buildSwitchedLLMForProvidernow prefixes the provider when needed (routedModelName); the RPC/ACP switcher shares it.TestResolveWithoutRoutingPrefixCutsGatewayIDpins the bug.Refactors
applySwitchedModelholds the rebuild/persist/report tail shared by role and provider switches.configuredListProvidersandsortModelsNewestFirstare extracted frompi model listand reused.openSearchPopupItemsopens the popup over caller-built rows;popupCmdlets a popup selection start an async command.Test plan
make build,make test,make lint,go vet/model,/model switch,/model provider, role rows, failures, and routing throughresolveSwitchedModel/modelshowsModels · agentgateway (867), typingdeepseekfilters to 48Known, not in this PR
/command popup captures typed text in its own search field (prompt stays/, space and Enter-on-no-match swallowed, description matches). Separate fix.