fix(tui): clear MiMo auth state after logout#2715
Conversation
|
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 Please read |
There was a problem hiding this comment.
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.
| config | ||
| .provider_config_for_mut(ApiProvider::Siliconflow) | ||
| .api_key = None; | ||
| config | ||
| .provider_config_for_mut(ApiProvider::SiliconflowCn) | ||
| .api_key = None; |
There was a problem hiding this comment.
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.
| 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!
|
Superseded by codex/v0.8.53 5719301 which uses scoped logout (clears only active provider key instead of all providers). |
Summary
/logout, including Xiaomi MiMo and the newer hosted providersFixes #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 newclear_in_memory_api_keyshelper and adds the seven previously-missing providers to the clearing logic, while keeping non-credential settings (model, base URL, auth mode) intact.execute_command_inputinto a standaloneclear_in_memory_api_keysfunction, which is now exhaustive over all 18ApiProvidervariants.WanjieArk,Volcengine,XiaomiMimo,Siliconflow,SiliconflowCn,Arcee, andMoonshotto the clearing list, fixing the regression reported in auth: provider UI can show MiMo as set while auth get reports no key #2661.clear_in_memory_api_keysand 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
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"]Reviews (1): Last reviewed commit: "fix(tui): clear MiMo auth state after lo..." | Re-trigger Greptile