Skip to content

feat(cli): ask which provider on first run instead of pinning xAI - #577

Merged
emal-avala merged 2 commits into
mainfrom
feat/first-run-provider-choice
Jul 29, 2026
Merged

feat(cli): ask which provider on first run instead of pinning xAI#577
emal-avala merged 2 commits into
mainfrom
feat/first-run-provider-choice

Conversation

@emal-avala

Copy link
Copy Markdown
Member

Summary

  • Phase 1 of epic: first-run and launch experience — parity with grok-build #557: first-time users with no env keys are asked which provider (one screen).
  • --provider / AGENT_CODE_PROVIDER pins the choice for scripts (auto still asks).
  • Silent bootstrap only writes config when an env key already names the provider — no more silent xAI pin.
  • Removes dead run_setup_wizard_legacy and invalid theme ids (midnight, daybreak, …).

Test plan

  • default_setup_does_not_pin_a_vendor
  • map_cli_provider_aliases, api_key_defaults_cover_main_providers
  • existing config render tests
  • clippy clean
  • Manual: fresh config dir, no keys → provider menu appears

Silent bootstrap and run_setup always chose xAI (endpoint + OAuth) when
no env key was present. Ask once interactively (or honour --provider /
AGENT_CODE_PROVIDER), write that provider's defaults, and remove the
dead multi-step legacy wizard with its invalid theme ids.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 89b718b902

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/cli/src/ui/setup.rs Outdated
" {} SuperGrok / X Premium device sign-in…\n",
"→".dark_cyan().bold()
" {}",
"(Or paste a key into config.toml under [api] — env is preferred.)".dark_grey()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Remove the instruction to store API keys in config

This newly tells first-run users to paste a credential into config.toml, directly violating the repository's security requirement that API keys remain in environment variables only. Remove this fallback and only direct users to the appropriate provider environment variable.

AGENTS.md reference: AGENTS.md:L108-L112

Useful? React with 👍 / 👎.

Comment on lines +365 to +367
let result = SetupResult {
api_key: String::new(),
auth_mode: "api_key".into(),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Allow Ollama setup to pass the API-key gate

When a keyless first-run user chooses Ollama, this empty key is omitted from the saved config and run_setup_wizard does not seed AGENT_CODE_API_KEY; after reloading, main.rs lines 682–690 therefore returns “API key required” before constructing the local provider. The advertised Ollama option can never launch unless the user independently supplies a dummy key, so the API-key readiness check needs to recognize this keyless local configuration.

Useful? React with 👍 / 👎.

@emal-avala

Copy link
Copy Markdown
Member Author

@codex review

Stop telling users to paste API keys into config.toml. Persist the
local "ollama" api_key placeholder so has_key passes after Ollama setup.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 89b718b902

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

theme: "auto".into(),
permission_mode: "accept_edits".into(),
};
write_config(&result);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve existing configuration when saving the provider

When an existing user config has no currently usable credential, selecting any API-key provider reaches this unconditional write, which replaces the entire config.toml with only the reconstructed API, permissions, and UI tables. This drops unrelated MCP, hook, and security settings; notably, it can remove security.disable_bypass_permissions, silently weakening later permission enforcement. Update the API fields while preserving existing tables instead of truncating the user config.

AGENTS.md reference: AGENTS.md:L95-L98

Useful? React with 👍 / 👎.

Comment on lines +365 to +367
let result = SetupResult {
api_key: String::new(),
auth_mode: "api_key".into(),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep Ollama usable without an API key

When the user selects Ollama with no environment key, this empty API key is omitted from the rendered config, but the caller reloads it with auth_mode = api_key and main.rs then returns API key required before constructing the local provider. Consequently, the newly advertised no-key Ollama option never reaches the TUI; preserve the local sentinel or exempt the local provider from the API-key gate.

Useful? React with 👍 / 👎.

Comment on lines +224 to +225
let pinned = cli_provider.trim();
if !pinned.is_empty() && !pinned.eq_ignore_ascii_case("auto") {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Bind AGENT_CODE_PROVIDER before resolving the choice

When a script sets only AGENT_CODE_PROVIDER, cli_provider still arrives as auto: the Cli::provider argument in main.rs has no env = "AGENT_CODE_PROVIDER" binding and no other code reads that variable. The process therefore opens the interactive selector and may hang instead of using the promised pinned provider; bind the environment variable while retaining explicit --provider precedence.

AGENTS.md reference: AGENTS.md:L124-L129

Useful? React with 👍 / 👎.

@emal-avala
emal-avala merged commit bf58e2c into main Jul 29, 2026
14 checks passed
@emal-avala
emal-avala deleted the feat/first-run-provider-choice branch July 29, 2026 07:48
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.

1 participant