Repository navigation
Conversation
Summary of Provider Selection Feature Implementation
1. Initial Problem
- Users were locked into a single provider after initial setup
- No way to switch providers without restarting the app
2. Core Features Implemented
Provider Switching (/providers command)
- Implemented provider dialog that shows all available providers
- Added visual indicators (green/hollow dots) for authenticated vs unauthenticated providers
- Added "→ Add new provider..." option at the bottom of the list
- Changed command from /provider to /providers for consistency
In-TUI Authentication
- Created complete auth flow without exiting TUI:
- auth_provider_select.go - Shows only unauthenticated providers
- auth_api_key.go - Text input for API key providers
- auth_oauth.go - OAuth flow for Anthropic/GitHub Copilot
- auth_method_select.go - Special handling for Anthropic (Claude Pro vs API key)
- Fixed OAuth dialog initialization issue
- Improved OAuth UI with wider modal (80 chars) and better URL display
Model Memory per Provider
- Added ProviderModels map to State struct to remember selected model per provider
- When switching providers, the last selected model for that provider is restored
- State is persisted to disk automatically
3. Technical Changes
Files Modified:
- packages/tui/internal/components/dialog/providers.go - Main provider dialog
- packages/tui/internal/components/dialog/auth_*.go - Auth flow dialogs
- packages/tui/internal/tui/tui.go - Message handling and modal initialization
- packages/tui/internal/app/app.go - Provider initialization logic
- packages/tui/internal/config/config.go - State structure with ProviderModels
- packages/tui/internal/commands/command.go - Changed trigger to "providers"
- packages/opencode/src/server/server.ts - Added authenticated field to /auth/providers
4. Known Limitations
- New providers don't appear in the list until app restart (due to server-side caching)
- Users see message: "Provider added! Restart the app to see it in the list"
5. Key Improvements
- No more exiting TUI to add providers
- Visual feedback for authenticated providers
- Automatic model selection memory
- Better OAuth flow with proper error handling and timeouts
- Consistent UI/UX with the rest of the application
This implementation allows users to easily switch between providers and add new ones without losing their chat
context, with the only limitation being the need to restart to see newly added providers due to server-side
architecture constraints.
Git Summary - Provider Removal Feature Files Created: packages/tui/internal/components/dialog/remove_provider.go packages/tui/internal/components/dialog/confirm_remove_provider.go Files Modified: packages/tui/internal/components/dialog/providers.go packages/tui/internal/tui/tui.go packages/opencode/src/server/server.ts packages/opencode/src/auth/index.ts (already had remove method) packages/tui/pkg/client/generated-client.go (regenerated) Key Changes: 1. providers.go - Changed provider list allocation from +1 to +2 to accommodate both "Add" and "Remove" options - Added "→ Remove provider..." option to the list - Added handler for when "Remove provider" is selected - Added RemoveProviderRequestMsg type definition 2. remove_provider.go (new file) - Created dialog showing only authenticated providers - Displays providers with red ✕ icon - Handles selection to show confirmation dialog - Defines ProviderRemovedMsg and ShowConfirmRemoveMsg types 3. confirm_remove_provider.go (new file) - Confirmation dialog with warning message - Y/N key handling for confirmation - Calls /auth/remove endpoint when confirmed - Shows provider name and explains consequences 4. tui.go - Added handler for RemoveProviderRequestMsg to show remove dialog - Added handler for ShowConfirmRemoveMsg to show confirmation - Added handler for ProviderRemovedMsg to show success and refresh provider list 5. server.ts - Added /auth/remove POST endpoint - Takes providerId parameter - Calls Auth.remove() to delete credentials - Returns success response Commit Message Suggestion: feat: add provider removal functionality to TUI - Add "Remove provider..." option to provider selection dialog - Create remove provider dialog showing authenticated providers - Add confirmation dialog with y/n prompt before removal - Implement /auth/remove endpoint in server - Show success toast and refresh provider list after removal - Providers can now be fully managed without leaving TUI Note: Removed providers still require restart to disappear from list due to server-side provider caching.
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
It didn’t have the ability to switch between providers in the middle of chat, and it would not let you set up more than one provider after you set up your initial one. So, now the workflow is you started up it asks you to set up your provider, then in the TUI, you have a providers modal that will allow you to add additional providers with the key or authentication. And from that point forward, you can switch between different providers and it will remember the model you had selected.
I wanted to use anthropic and o3 for different parts of the chat. I'm doing a PR on this, because I'm pretty sure this is a main feature you'd want in the app.
I'm going to add a favorites section, or hot swap section it quickly let me swap from one provider to another. Might do another PR for that one later.