Skip to content

fix(tui): clear MiMo auth state after logout#2715

Closed
xyuai wants to merge 1 commit into
Hmbown:mainfrom
xyuai:fix-2661-logout-clears-provider-state
Closed

fix(tui): clear MiMo auth state after logout#2715
xyuai wants to merge 1 commit into
Hmbown:mainfrom
xyuai:fix-2661-logout-clears-provider-state

Conversation

@xyuai

@xyuai xyuai commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • clear the in-memory provider API-key slots after /logout, including Xiaomi MiMo and the newer hosted providers
  • keep non-credential provider settings like model, base URL, and auth mode intact
  • add a regression test covering MiMo plus other provider-scoped keys

Fixes #2661.

Greptile Summary

This PR fixes a bug where in-memory API keys for several providers — most notably Xiaomi MiMo — were not cleared when the user issued /logout. The fix extracts a new clear_in_memory_api_keys helper and adds the seven previously-missing providers to the clearing logic, while keeping non-credential settings (model, base URL, auth mode) intact.

  • Refactors the inline logout clearing block in execute_command_input into a standalone clear_in_memory_api_keys function, which is now exhaustive over all 18 ApiProvider variants.
  • Adds WanjieArk, Volcengine, XiaomiMimo, Siliconflow, SiliconflowCn, Arcee, and Moonshot to the clearing list, fixing the regression reported in auth: provider UI can show MiMo as set while auth get reports no key #2661.
  • Adds a unit test that directly calls clear_in_memory_api_keys and asserts MiMo, moonshot, and volcengine keys are cleared while model/base_url/auth_mode fields are preserved.

Confidence Score: 4/5

Safe to merge — the clearing logic is exhaustive over all provider variants and the is_none guard correctly prevents a spurious ProvidersConfig allocation.

The refactor is straightforward and the behavior for every existing provider is preserved. The only wrinkle is that both Siliconflow and SiliconflowCN are listed, but they resolve to the same storage slot — the duplicate write is harmless. All providers that were cleared before are still cleared, and seven that were previously skipped (including XiaomiMimo) are now correctly included.

crates/tui/src/tui/ui.rs — specifically the SiliconflowCn call that maps to the same field as Siliconflow.

Important Files Changed

Filename Overview
crates/tui/src/tui/ui.rs Refactors the /logout handler to call a new clear_in_memory_api_keys helper; adds 7 previously-missing providers (XiaomiMimo, WanjieArk, Volcengine, Siliconflow, SiliconflowCn, Arcee, Moonshot). One call — SiliconflowCn — is redundant because provider_config_for_mut maps both Siliconflow and SiliconflowCn to the same providers.siliconflow slot.
crates/tui/src/tui/ui/tests.rs Adds a regression test that verifies api_key is cleared for xiaomi_mimo, moonshot, and volcengine while non-credential fields (model, base_url, auth_mode) are preserved after clear_in_memory_api_keys.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["/logout command detected"] --> B["clear_in_memory_api_keys(config)"]
    B --> C["config.api_key = None"]
    C --> D{"config.providers\nis None?"}
    D -- Yes --> E["return early\n(no-op for provider slots)"]
    D -- No --> F["provider_config_for_mut() for each ApiProvider variant"]
    F --> G["Deepseek / DeepseekCN / NvidiaNim\nOpenai / Atlascloud / WanjieArk\nVolcengine / Openrouter / XiaomiMimo\nNovita / Fireworks / Siliconflow\nSiliconflowCN / Arcee / Moonshot\nSglang / Vllm / Ollama"]
    G --> H["api_key = None for each slot"]
    H --> I["Back in execute_command_input"]
    I --> J["Recompute api_key_env_only flag"]
Loading

Fix All in Codex Fix All in Claude Code Fix All in Cursor

Reviews (1): Last reviewed commit: "fix(tui): clear MiMo auth state after lo..." | Re-trigger Greptile

Greptile also left 1 inline comment on this PR.

@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown

Thanks @xyuai for taking the time to contribute.

This repository is currently observing a maintainer-managed contribution gate in dry-run mode, so this pull request is staying open. When enforcement is enabled, pull requests from contributors who are not listed in .github/APPROVED_CONTRIBUTORS will be closed automatically.

Please read CONTRIBUTING.md for the expected contribution shape. A maintainer can grant PR access by commenting /lgtm on a pull request.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request refactors the API key clearing logic on logout by extracting it into a dedicated helper function clear_in_memory_api_keys. It also expands the list of providers whose keys are cleared to include several new ones, and adds a unit test to verify that keys are cleared while preserving other provider settings. I have no feedback to provide as the changes are clean and well-tested.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread crates/tui/src/tui/ui.rs
Comment on lines +6240 to +6245
config
.provider_config_for_mut(ApiProvider::Siliconflow)
.api_key = None;
config
.provider_config_for_mut(ApiProvider::SiliconflowCn)
.api_key = None;

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.

P2 The SiliconflowCn call is redundant — provider_config_for_mut routes both Siliconflow and SiliconflowCn to the same providers.siliconflow field (there is no separate siliconflow_cn field in ProvidersConfig). The second call writes None to a slot already set to None, which is harmless today but can mislead a future reader into thinking a distinct CN key is being cleared.

Suggested change
config
.provider_config_for_mut(ApiProvider::Siliconflow)
.api_key = None;
config
.provider_config_for_mut(ApiProvider::SiliconflowCn)
.api_key = None;
config
.provider_config_for_mut(ApiProvider::Siliconflow)
.api_key = None;

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Codex Fix in Claude Code Fix in Cursor

@Hmbown

Hmbown commented Jun 3, 2026

Copy link
Copy Markdown
Owner

Superseded by codex/v0.8.53 5719301 which uses scoped logout (clears only active provider key instead of all providers).

@Hmbown Hmbown closed this Jun 3, 2026
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.

auth: provider UI can show MiMo as set while auth get reports no key

2 participants