Skip to content

feat: provider selection - #479

Closed
Tech0001 wants to merge 2 commits into
anomalyco:devfrom
Tech0001:provider-selection
Closed

Tech0001 wants to merge 2 commits into
anomalyco:devfrom
Tech0001:provider-selection

Conversation

@Tech0001

Copy link
Copy Markdown

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.

Tech0001 added 2 commits June 27, 2025 12:52
  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.
@Tech0001 Tech0001 mentioned this pull request Jun 27, 2025
@Tech0001 Tech0001 changed the title Provider selection feat: provider selection Jun 27, 2025
@thdxr thdxr self-assigned this Jul 2, 2025
@Tech0001 Tech0001 closed this Aug 7, 2025
@Tech0001
Tech0001 deleted the provider-selection branch August 7, 2025 18:13
bussard76 pushed a commit to bussard76/openwork that referenced this pull request May 12, 2026
)

* feat(workspace): add Share modal in workspace menu

* feat(workspace): share workspace from session view

* feat(workspace): store OpenWork token per workspace

* feat(workspace): scope OpenWork sharing via /w/:id mounts
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