fix(provider-wizard): allow multiple custom OpenAI-compatible providers#403
Conversation
Generic/custom providers (custom-openai-compatible, custom-anthropic-compatible) all share the same CatalogID. wizardProviderStoredKey matched by CatalogID, which blocked creating more than one custom provider. Fix: in advanceProviderWizard, skip the ManageKey diversion for custom providers and route directly to the endpoint step instead. The user can overwrite an existing instance by re-entering the same name, or create a new one with a different name. Named providers (OpenAI, Anthropic, etc.) are unaffected — ManageKey is still shown for them. Fixes Gitlawb#375
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
WalkthroughThe wizard now routes endpoint-based providers with stored keys directly past ManageKey and only starts model discovery when advancing into model setup. Tests cover both the custom-provider endpoint path and the named-provider ManageKey path. ChangesProvider Wizard ManageKey Skip
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
internal/tui/provider_wizard_discovery.go (1)
45-67: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueDuplicate advance/discovery branch in
advanceProviderWizard. ClearmanageProviderNamehere and let the sharedadvance()path handle the transition; the nestedstep == providerWizardStepModelcheck never fires on this path.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/tui/provider_wizard_discovery.go` around lines 45 - 67, The duplicate advance/discovery branch in advanceProviderWizard should be simplified so the shared advance() flow handles the transition. In the providerWizardStepProvider path, keep clearing providerWizard.manageProviderName for endpoint-based providers, but remove the nested providerWizardStepModel return/discovery check and rely on the existing step progression instead. Use the advanceProviderWizard logic and providerWizard.advance() as the reference points while preserving the current endpoint and manage-key behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@internal/tui/provider_wizard_discovery.go`:
- Around line 45-67: The duplicate advance/discovery branch in
advanceProviderWizard should be simplified so the shared advance() flow handles
the transition. In the providerWizardStepProvider path, keep clearing
providerWizard.manageProviderName for endpoint-based providers, but remove the
nested providerWizardStepModel return/discovery check and rely on the existing
step progression instead. Use the advanceProviderWizard logic and
providerWizard.advance() as the reference points while preserving the current
endpoint and manage-key behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: c6557893-008c-43e2-8f1f-b21d364522b4
📒 Files selected for processing (2)
internal/tui/provider_wizard_discovery.gointernal/tui/provider_wizard_test.go
Vasanthdev2004
left a comment
There was a problem hiding this comment.
This is the fix we're going with for #375 — I closed the duplicate #389 in favor of this one. Nice approach: gating at the call site in advanceProviderWizard (rather than changing the wizardProviderStoredKey lookup) keeps the lookup's meaning intact, and the table test over both custom transports plus the named-provider guard is exactly the right coverage.
Verified locally: go build ./... clean, and the wizard suite passes — re-selecting the generic "Custom OpenAI-compatible" entry with one already saved now routes to the endpoint step instead of trapping in keep/replace/remove, while a named provider (e.g. openai) still gets keep/replace/remove.
One thing before merge: the new test file isn't gofmt-clean and will trip the format check in CI. Please run:
gofmt -w internal/tui/provider_wizard_test.go
(It's just struct-field alignment on the step: field in the two new tests.)
One heads-up, not a blocker: because the wizard's provider list comes from providercatalog.All(), custom providers only ever appear as the single generic entry — so after this change there's no longer a wizard path to replace/remove an existing custom provider's stored key (the generic descriptor's name won't match a user's saved name). That's an acceptable trade to unblock multi-provider setup, and the old behavior could only manage the first CatalogID match anyway — just flagging it as a good follow-up (list saved custom instances for management).
Once the gofmt is in and CI goes green, this is good to merge. Thanks @Baran3575!
gnanam1990
left a comment
There was a problem hiding this comment.
Approving — this is the fix we're taking for #375.
Verified locally: go build ./..., go vet, and go test ./internal/tui are green, and the two added tests exercise the exact repro (a saved custom profile + re-selecting "Custom OpenAI-compatible" now routes to the Endpoint step instead of ManageKey) plus the regression boundary (a named provider still gets ManageKey). The change is localized to wizard navigation — it doesn't touch providerWizardProfile / UpsertProvider / mergeProvider, so an existing single custom-provider config resolves identically. Clean and well-scoped.
Note: this supersedes #389; I'm requesting changes there in favor of this one.
…anthropic-compatible test
0c98b59 to
c174e3d
Compare
|
@gnanam1990 @Vasanthdev2004 is it possible to run action and review again? |
Problem
Issue #375: After setting up one custom OpenAI-compatible provider, configuring a second one is blocked. The wizard diverts to the Keep/Replace/Remove screen instead of allowing a new setup.
Root Cause
wizardProviderStoredKeymatches saved providers byCatalogID. All generic/custom providers share the sameCatalogID("custom-openai-compatible"or"custom-anthropic-compatible"), so saving one creates a match that blocks creating another.Fix
In
advanceProviderWizard(internal/tui/provider_wizard_discovery.go), skip the ManageKey diversion for custom providers and route directly to the endpoint step. The user can:Named providers (OpenAI, Anthropic, Groq, etc.) are unaffected — ManageKey is still shown for them.
Changes
internal/tui/provider_wizard_discovery.gointernal/tui/provider_wizard.gointernal/tui/provider_wizard_test.goTesting
TestAdvanceProviderWizardCustomSkipsManageKey— custom provider with saved key routes to Endpoint step, not ManageKeyTestAdvanceProviderWizardNamedShowsManageKey— named provider with saved key still routes to ManageKey (no regression)Fixes #375
Summary by CodeRabbit
Bug Fixes
Tests