feat(login): /login opens the provider picker with green connected badges

/login previously fired the resolved method's flow immediately — there was
no way to see providers or their status. It now lands on the provider
picker; already-connected providers show a green 'connected' badge in the
key column.

Shell: initialize() probes stored credentials once (primary session flag,
auth.json oauth/<provider> scopes, resolved platform keys env>auth.json>
config) and stamps _meta.connected on each advertised method
(connected_method_ids + stamp_connected_meta, pure and unit-tested).
Display state only — never an authorization input.

TUI:
- PendingMenuItem::connected() reads the badge from method meta; the
  picker renders it green (accent_success), replacing the shortcut hint.
- New Action::OpenLoginPicker: /login shows the picker; mid-session it
  stashes the view like dispatch_login, and starts no flow by itself.
- Mid-session picker: last row reads 'Cancel' and dispatches CancelLogin
  (clicking it must not exit the app); Esc also returns to the session.
- After a successful login, the just-authenticated method is stamped
  connected in the TUI's advertised-methods copy (auth_in_flight_method →
  AuthComplete), so a later /login shows the badge without re-initialize.

Verified: kigi-shell 5256 + kigi-tui 6870 tests green, clippy clean.
This commit is contained in:
2026-07-22 16:14:42 -04:00
parent 1e57cd9225
commit fc7c2a1b9b
11 changed files with 384 additions and 15 deletions
@@ -221,7 +221,24 @@ impl acp::Agent for MvpAgent {
has_cached_token,
login_label: None,
});
let auth_methods = built.methods;
let mut auth_methods = built.methods;
// Connected badges for the client's login picker: probe stored
// credentials once (auth.json scopes + resolved platform keys) and
// stamp `_meta.connected` on every method that already has one.
{
let store = crate::auth::read_auth_json(
&crate::util::kigi_home::kigi_home().join("auth.json"),
)
.unwrap_or_default();
let keys = crate::agent::models::PlatformApiKeys::resolve_from_effective_config();
let connected = auth_method::connected_method_ids(
has_cached_token,
has_external_api_key,
|scope| store.contains_key(scope),
|p| keys.key_for(p).is_some(),
);
auth_method::stamp_connected_meta(&mut auth_methods, &connected);
}
kigi_log::unified_log::info(
"auth: initialize() built auth_methods for ACP response",
None,