Skip to content

fix(tui): clear launch missing-key state when a provider switch lands on a keyed route - #6696

Merged
Hmbown merged 1 commit into
integrate/0.10.1from
fix/first-run-configured-route-e2e
Sep 28, 2026
Merged

Hmbown merged 1 commit into
integrate/0.10.1from
fix/first-run-configured-route-e2e

Conversation

@Hmbown

@Hmbown Hmbown commented Sep 28, 2026

Copy link
Copy Markdown
Owner

Root cause of the reported first-launch symptom

This is not a product bug. The tmux server used for the repro has CODEWHALE_PROVIDER=deepseek and CODEWHALE_MODEL=deepseek-v4-flash in its global environment, and every new session inherits them. Config::load then resolves DeepSeek under the documented env > file precedence. Instrumentation showed provider=deepseek already at load_config_from_cli_with_effective_profile, with the env var set. codewhale model resolve from a shell without those vars reported openai, which hid the difference. With the vars unset, the unmodified release build aaaadfe starts on the composer with OpenAI-compatible · gpui-fixture.

Real bug fixed here

After Esc on the recovery picker, /provider openai switched to a keyed route, but switch_provider never recomputed app.onboarding_needs_api_key. Only complete_provider_picker_onboarding clears it, and that runs only while onboarding == Provider. The stale true kept the footer on "model not connected" and left should_adopt_live_local_ollama armed against the provider the user had just chosen.

Fix (crates/tui/src/tui/ui/provider_routes.rs, switch_provider): on success, set onboarding_needs_api_key = !has_api_key(config) for the new route, and clear onboarding_missing_key_recovery when the key is present. The auth-failure rollback already restores the previous value.

Tests (focused, local)

  • New first_run_switch_to_keyed_route_clears_launch_missing_key_state runs the real Config::load + App::new startup with the inherited env pair, then Esc, then switch_provider. It passes with the fix and fails without it.
  • provider_switch|switch_provider|local_ollama|missing_key|onboarding: 109 passed, 0 failed.
  • first_run_|provider_picker: 161 passed, 1 failed. The failure, first_run_ollama_choice_survives_restart_from_canonical_config ("index not found"), also fails on a clean aaaadfe tree and is not touched here.

E2E (tmux 130x40, debug build, fixture at 127.0.0.1:4880)

  • Configured home, env clean: composer, footer OpenAI-compatible · gpui-fixture · thinking: max.
  • Configured home with the inherited deepseek env: picker (correct per precedence), then Esc and /provider openai: footer OpenAI-compatible · gpt-5.6 …. The release build showed model not connected here.
  • Unconfigured home with Ollama unreachable: Choose your model provider picker. With a live local Ollama it auto-adopts ollama/qwen3:4b, the same as the release build.

Out of scope, noted: under an env model override, /provider openai lands on the catalog default (gpt-5.6), not the file's default_text_model, because the env value replaced it in memory.

🤖 Generated with Claude Code

https://claude.ai/code/session_014ZwqatxgVFxHvovngywnks

… on a keyed route

The reported first-launch symptom (a configured openai/gpui-fixture home
opening on "Choose your model provider" with DeepSeek focused) was not a
config-resolution bug. The tmux server used for the repro carries
CODEWHALE_PROVIDER=deepseek and CODEWHALE_MODEL=deepseek-v4-flash in its
global environment, so every new session inherited them. Config::load then
resolved deepseek per the documented env > file precedence (instrumented:
provider=deepseek already at load_config_from_cli_with_effective_profile).
`codewhale model resolve` from a shell without those vars reported openai,
which hid the difference. With the vars unset, the unmodified release build
aaaadfe starts on the composer with "OpenAI-compatible · gpui-fixture".

It did expose a real bug. After Esc on the recovery picker, `/provider openai`
switched to a keyed route, but switch_provider never recomputed
app.onboarding_needs_api_key. Only complete_provider_picker_onboarding clears
it, and that runs only while onboarding == Provider. The stale true kept the
footer on "model not connected" (frame.rs info_segments) and left
should_adopt_live_local_ollama armed against the provider the user had just
chosen.

Fix: on a successful switch, set onboarding_needs_api_key from
has_api_key(config) for the new route, and clear
onboarding_missing_key_recovery when the key is present. The auth-failure
rollback already restores the previous flag.

Tests (focused, local):
- new first_run_switch_to_keyed_route_clears_launch_missing_key_state
  (real Config::load + App::new startup with the inherited env pair, Esc,
  switch_provider): passes; fails without the fix at the
  !onboarding_needs_api_key assert.
- provider_switch|switch_provider|local_ollama|missing_key|onboarding:
  109 passed, 0 failed.
- first_run_|provider_picker: 161 passed, 1 failed. The one failure,
  first_run_ollama_choice_survives_restart_from_canonical_config ("index not
  found"), also fails on a clean aaaadfe tree and is not touched here.
- first_run_route_env_guards now also removes CODEWHALE_PROVIDER.

E2E (tmux 130x40, debug build, fixture at 127.0.0.1:4880):
- configured home, env clean: composer, footer
  "OpenAI-compatible · gpui-fixture · thinking: max".
- configured home with the inherited deepseek env: picker (correct per
  precedence), then Esc and /provider openai: footer
  "OpenAI-compatible · gpt-5.6 ..." (release build: "model not connected").
- unconfigured home with local Ollama unreachable: "Choose your model
  provider" picker. With the live local Ollama it auto-adopts ollama/qwen3:4b,
  same as the release build.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014ZwqatxgVFxHvovngywnks
@Hmbown Hmbown added this to the v0.10.1 milestone Sep 28, 2026
Copilot AI lite review requested due to automatic review settings September 28, 2026 04:04
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Hmbown
Hmbown merged commit 776e3fe into integrate/0.10.1 Sep 28, 2026
7 of 8 checks passed
@Hmbown
Hmbown deleted the fix/first-run-configured-route-e2e branch September 28, 2026 04:05
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