Skip to content

Clarify saved and effective provider selection#725

Open
PierrunoYT wants to merge 2 commits into
Gitlawb:mainfrom
PierrunoYT:fix/721-provider-selection-overrides
Open

Clarify saved and effective provider selection#725
PierrunoYT wants to merge 2 commits into
Gitlawb:mainfrom
PierrunoYT:fix/721-provider-selection-overrides

Conversation

@PierrunoYT

@PierrunoYT PierrunoYT commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Summary

  • report when ZERO_PROVIDER overrides a provider saved by providers use
  • include the effective provider and override source in JSON output
  • mark provider list entries as user-config/selectable or runtime-only
  • explain why runtime-only providers cannot be selected with providers use

Validation

  • go test ./...
  • go vet ./...
  • govulncheck ./...
  • golangci-lint against new changes: 0 issues

Repository-wide golangci-lint still reports existing findings unrelated to this change.

Fixes #721

Summary by CodeRabbit

  • New Features

    • Provider listings now distinguish saved (selectable) profiles from runtime-only (not selectable) profiles.
    • providers list --json includes per-provider selectability plus a source indicator.
    • providers use reports effective provider selection and whether an environment-based override is active.
  • Bug Fixes

    • Improved messaging when attempting to select a runtime-only provider, including clearer guidance on using configured profiles.

Co-authored-by: Pierre Bruno <pierrebruno@hotmail.ch>
Copilot AI review requested due to automatic review settings July 18, 2026 09:58
@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: eff47a4a-533d-4162-8659-adda3b0c1451

📥 Commits

Reviewing files that changed from the base of the PR and between 4b26069 and fef6c5d.

📒 Files selected for processing (3)
  • internal/cli/command_center.go
  • internal/cli/command_center_test.go
  • internal/cli/provider_onboarding_test.go
🚧 Files skipped from review as they are similar to previous changes (3)
  • internal/cli/command_center_test.go
  • internal/cli/provider_onboarding_test.go
  • internal/cli/command_center.go

Walkthrough

Provider CLI listings now distinguish saved and runtime-only profiles. Provider selection reports environment overrides, effective providers, and clearer errors for non-selectable runtime profiles, with coverage for JSON and human-readable output.

Changes

Provider CLI reporting

Layer / File(s) Summary
Provider listing metadata
internal/cli/command_center.go, internal/cli/command_center_test.go
Provider listings load saved profile names, classify runtime-only profiles, expose selectable and source fields, and render the distinction in JSON and text output.
Provider selection override handling
internal/cli/provider_onboarding.go, internal/cli/provider_onboarding_test.go
providers use reports effective-provider environment overrides, targets connectivity checks at the effective provider, and explains why runtime-only profiles cannot be selected. Tests cover overridden, matching, and rejected selections.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ProvidersUse
  participant UserConfig
  participant ActiveProviderEnv
  participant ConnectivityCheck
  ProvidersUse->>UserConfig: save requested active provider
  ProvidersUse->>ActiveProviderEnv: read active-provider override
  ActiveProviderEnv-->>ProvidersUse: return effective provider
  ProvidersUse->>ConnectivityCheck: check effective provider
Loading

Possibly related PRs

  • Gitlawb/zero#716: Modifies handling of environment-derived and non-persisted providers in the same onboarding flow.
  • Gitlawb/zero#348: Uses the same active-provider environment override mechanism.
  • Gitlawb/zero#366: Adjusts active-provider environment override behavior in provider construction.

Suggested reviewers: anandh8x, gnanam1990, vasanthdev2004

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately reflects the main change: clarifying saved versus effective provider selection.
Linked Issues check ✅ Passed The PR reports saved versus effective providers, surfaces ZERO_PROVIDER overrides, and distinguishes selectable user-config profiles from runtime-only ones.
Out of Scope Changes check ✅ Passed The changes stay focused on provider selection behavior, listing, and related tests with no clear unrelated additions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
internal/cli/command_center_test.go (1)

194-229: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Reset stderr alongside stdout for clean failure messages.

While this test passes correctly, it is a good practice to reset both output buffers before reusing them. This ensures that if the second command fails, stderr.String() only contains the relevant error from the second execution, preventing confusing t.Fatalf error messages containing leftover artifacts.

♻️ Proposed refactor
 	}
 
 	stdout.Reset()
+	stderr.Reset()
 	if code := runWithDeps([]string{"providers", "list"}, &stdout, &stderr, deps); code != exitSuccess {
 		t.Fatalf("code=%d stderr=%s", code, stderr.String())
🤖 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/cli/command_center_test.go` around lines 194 - 229, Reset stderr
alongside stdout before the second runWithDeps invocation in
TestRunProvidersListMarksUserAndRuntimeProfiles, so failure reporting reflects
only the second command’s output.
🤖 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/cli/command_center_test.go`:
- Around line 194-229: Reset stderr alongside stdout before the second
runWithDeps invocation in TestRunProvidersListMarksUserAndRuntimeProfiles, so
failure reporting reflects only the second command’s output.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 86a322da-ff12-4cef-bf1f-5f77bcde8327

📥 Commits

Reviewing files that changed from the base of the PR and between 60dc84e and 4b26069.

📒 Files selected for processing (4)
  • internal/cli/command_center.go
  • internal/cli/command_center_test.go
  • internal/cli/provider_onboarding.go
  • internal/cli/provider_onboarding_test.go

coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 18, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves clarity around provider selection by distinguishing the provider saved in user config from the provider that is actually effective at runtime (especially when ZERO_PROVIDER is set), and by enriching provider listing output so UIs can tell which entries are user-selectable vs runtime-derived.

Changes:

  • Update providers use to report when ZERO_PROVIDER overrides the newly saved active provider, and include effective/override metadata in JSON output.
  • Enhance providers list/current output (human + JSON) with selectable and source metadata to distinguish user-config providers from runtime-only entries.
  • Add tests covering the override messaging/JSON payload and the selectable/source metadata in provider lists.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
internal/cli/provider_onboarding.go Adds override detection for ZERO_PROVIDER to clarify saved vs effective provider; enriches JSON output and error messaging for non-selectable providers.
internal/cli/provider_onboarding_test.go Adds coverage for override messaging/JSON and for improved error text when selecting runtime-only providers.
internal/cli/command_center.go Adds provider list metadata (selectable, source) and updates formatting to mark runtime-only/non-selectable entries.
internal/cli/command_center_test.go Adds coverage for new selectable/source JSON fields and for the runtime-only marker in human output.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +421 to +423
if !provider.Selectable {
line += " (runtime-only; not selectable/saved)"
}
Comment thread internal/cli/command_center_test.go Outdated
Comment on lines +226 to +228
if !strings.Contains(stdout.String(), "runtime-only; not selectable/saved") {
t.Fatalf("runtime marker missing: %s", stdout.String())
}
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.

providers use reports success when ZERO_PROVIDER keeps another provider active

3 participants