Skip to content

fix: custom provider model list overflow and add /provider command #3765

@lanshi17

Description

@lanshi17

Bug Report

Problem 1: Model list overflow in terminal selection menus

When using a custom provider that returns a large number of models (e.g., an OpenAI-compatible endpoint with 100+ models), the selectOne and selectMany menus in the setup wizard render all items at once. If the model list exceeds the terminal window height:

  • Items beyond the visible area are never shown
  • Arrow key navigation only cycles through the visible items
  • Users cannot access or select models that overflow the terminal

This affects all call sites in internal/cli/cli.go that use selectOne/selectMany:

  • selectEnabledProviders() — provider family and model selection
  • promptCustomProviderFromURL() — custom provider model selection
  • promptAnthropicProviderFromURL() — Anthropic provider model selection

Problem 2: No /provider command to switch providers in CLI

When entering the CLI chat interface, there is no obvious way to switch between configured providers. The /model command requires knowing the full provider/model reference. Users need a /provider command to list and switch providers more intuitively.

Proposed Solution

Fix 1: Viewport scrolling + keyword search in select menus

  • Add terminal height detection via term.GetSize()
  • Implement viewport windowing that shows only N items that fit in the terminal
  • Add scroll indicators ("↑ N more above" / "↓ N more below")
  • Add '/' key to enter search/filter mode for keyword-based filtering

Fix 2: /provider slash command

  • /provider — list all configured providers with model counts
  • /provider <name> — switch to that provider's default model
  • Tab autocomplete for provider names
  • Bilingual i18n support (en/zh)

Files Affected

  • internal/cli/select.go — viewport scrolling + search
  • internal/cli/provider.go — new /provider command
  • internal/cli/chat_tui.go — register /provider
  • internal/cli/complete.go — /provider autocomplete
  • internal/cli/help_view.go — /provider in help
  • internal/cli/model.go — providerNames() helper
  • internal/control/slash.go — /provider arg completion
  • internal/i18n/i18n.go — new message fields
  • internal/i18n/messages_en.go — English translations
  • internal/i18n/messages_zh.go — Chinese translations

Metadata

Metadata

Assignees

No one assigned

    Labels

    tuiTerminal UI / CLI (internal/cli, internal/control)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions