fix(tui): route each OAuth picker row to its own provider, not kimi.com

Root cause: PendingMenuItem::Login carried only a label, so every provider
row collapsed to the id-less Action::Login, and dispatch_login resolved
the FIRST advertised interactive method — the Kimi device flow. Selecting
Grok/Claude/Copilot/Codex all opened kimi.com. (The shell side was already
correct: authenticate() dispatches each method id to its own OAuth flow.)

- PendingMenuItem::Login now carries the advertised method id (None only
  on the no-interactive-method fallback row).
- New Action::LoginWith(AuthMethodId); the picker dispatches it with the
  row's own id. Action::Login keeps its meaning (resolved/default method)
  for /login, auto-login, and re-auth.
- dispatch_login_with resolves the id against the advertised methods and
  FAILS CLOSED on an unknown id — no silent first-method fallback — then
  adopts the method's label and start mode.

Tests: picker rows pinned to their method ids; LoginWith(claude-pro-max)
must authenticate with claude-pro-max even when kimi-code was previously
resolved; unknown ids surface an error and start nothing.

Verified: kigi-tui 6867 tests green, clippy clean.
This commit is contained in:
ZacharyZhang-NY committed 2026-07-22 15:51:46 -04:00
1 parent c2d1067f0d
commit 1e57cd9225
5 files changed
+195 -29

No files matched your search

@@ -1,8 +1,8 @@
//! Top-level action router: maps actions and action results to handlers.
use super::auth::{
dispatch_begin_platform_key_entry, dispatch_cancel_login, dispatch_cancel_platform_key_entry,
dispatch_login, dispatch_logout, dispatch_submit_auth_code, dispatch_submit_platform_api_key,
dispatch_switch_account,
dispatch_login, dispatch_login_with, dispatch_logout, dispatch_submit_auth_code,
dispatch_submit_platform_api_key, dispatch_switch_account,
};
use super::ctx::{
active_agent_session_id, get_active_agent_mut, navigate_clearing_selection,
@@ -876,6 +876,7 @@ pub(crate) fn dispatch(action: Action, app: &mut AppView) -> Vec<Effect> {
vec![]
}
Action::Login => dispatch_login(app),
Action::LoginWith(method_id) => dispatch_login_with(app, Some(method_id)),
Action::CancelLogin => dispatch_cancel_login(app),
Action::SubmitAuthCode(code) => dispatch_submit_auth_code(app, code),
Action::BeginPlatformKeyEntry(target) => dispatch_begin_platform_key_entry(app, target),