Skip to content

feat(tui): add and remove providers from the Providers tab (PR-4) - #70

Merged
xjoker merged 1 commit into
cursor/provider-tui-panel-5a91from
cursor/provider-tui-add-remove-5a91
Aug 26, 2026
Merged

feat(tui): add and remove providers from the Providers tab (PR-4)#70
xjoker merged 1 commit into
cursor/provider-tui-panel-5a91from
cursor/provider-tui-add-remove-5a91

Conversation

@xjoker

@xjoker xjoker commented Aug 26, 2026

Copy link
Copy Markdown
Owner

Fourth slice of custom-provider support (方案 A). Makes the Providers tab interactive.

Stacked on PR-3 (#69) — base branch is cursor/provider-tui-panel-5a91; retarget down the stack as they merge.

What's in this PR

On the Providers tab:

  • a — add wizard: a multi-step, single-line prompt walking through alias → base URL → model → API key, reusing the existing input pattern. The API-key step is masked in the status bar and the key is never echoed. Each step validates (alias rules + collision with existing providers/accounts, http(s):// base URL, non-empty model/key). On completion it derives env_key (CODEX_SWITCH_<ALIAS>_KEY) and provider_id, saves via provider::save, reloads, and selects the new row.
  • d — remove: deletes the selected provider after a y/n confirmation (ConfirmAction::RemoveProvider).
  • Keys route per tab; the wizard consumes raw, case-sensitive input (aliases/URLs/keys are case-sensitive). A tab-aware footer shows the Providers key hints (j/k nav · a add · d remove · Tab accounts · h help · q quit).

Now both entry points requested — CLI (PR-1) and TUI — can add providers.

Tests

  • provider_add_wizard_collects_fields_and_saves — drives the wizard key-by-key (hermetic CODEX_SWITCH_HOME/CODEX_HOME) and asserts the saved profile (base_url/model/derived env_key/key/wire_api), tab switch, and reload.
  • provider_add_wizard_stays_on_step_for_a_bad_base_url — invalid base URL keeps the wizard on that step.
  • request_and_confirm_remove_provider_deletes_itd asks for confirmation; y removes and reloads.
  • cargo fmt --check, cargo clippy --all-targets --all-features -- -D warnings, cargo test --all — all pass, 0 failed.

Manual demo (real TUI, verified via video review)

Empty Providers tab → a → typed alias/base URL/model/masked API key → provider appears in the table (no secret) → dRemove provider 'openrouter'? (y/n)y → table empty again.

tui_provider_add_remove_wizard_demo.mp4

API-key step masked:

add wizard API key masked

Provider added (no secret shown):

provider added

Remove confirmation:

remove confirmation

Note: CI Format and audit will be red until #63 (webbrowser RUSTSEC bump) merges to dev; pre-existing and unrelated.

To show artifacts inline, enable in settings.

Open in Web Open in Cursor 

On the Providers tab:
- 'a' opens a multi-step add wizard (alias -> base URL -> model -> API key)
  reusing the single-line input pattern; the API-key step is masked in the
  status bar and the key is never echoed. Each step validates (alias rules +
  collision with providers/accounts, http(s) base URL, non-empty model/key);
  on completion it derives env_key/provider_id, saves via provider::save, and
  reloads.
- 'd' removes the selected provider after a y/n confirmation
  (ConfirmAction::RemoveProvider).
- Keys route per tab; the wizard consumes raw case-sensitive input. A
  tab-aware footer shows the Providers key hints.

Unit tests: wizard collects fields and saves (with hermetic CODEX_SWITCH_HOME/
CODEX_HOME), stays on-step for a bad base URL, and request+confirm removes a
provider.

Co-authored-by: xJoker <xjoker@users.noreply.github.com>
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