Ask for `clai2` plugin keys and sign-ins through `Dialogs`
Part 17 of the clai2 web UI stack (… → #10315 → this PR). Based on #10315. No linked issue: requested by the CLAI maintainer.
Why. Almost every plugin menu picks a /keys entry or signs in through a few shared helpers that drew termflow widgets. Making them ask through Dialogs (#10312) lets a ported plugin's settings menu action call them with whatever dialogs it was given, so the same action works in the terminal and, through #10315, in the browser. The plugins themselves are ported in the next PRs, one each.
API changes
plugins.keys.choose_key(*, name, label, dialogs, check=...)now takesdialogsinstead ofrunners:- It offers the saved
/keysnames plus "Enter a different API key" throughdialogs.choose, or goes straight to a maskeddialogs.textwhen none are saved. - Replacing an existing key is confirmed with
dialogs.confirm, "Keep the saved token" first. - It keeps the
checksemantics, theKeyExistsErrorretry,finish_write, and thekey prompttelemetry span. The span never records the value. - It no longer goes through
config.api_keys.prompt_api_key, which core menus such as/model addstill use unchanged. Itsmenu.run()call also bypassedRunners, so tests couldn't script it.
- It offers the saved
plugins.keys.browser_sign_in(session, dialogs).plugins.sign_in.wait_for_sign_in,sign_in_nowandrun_subcommandtakedialogs: Dialogs | None, whereNonemeans the terminal (TerminalDialogs(RUNNERS)). Messages are unchanged.MaskedPromptandconfirm_replaceare removed fromplugins.keys; nothing else used them.
Callers. Every built-in caller (day_ai, grain, logfire_mcp, notion, ordinal, posthog, pylon, slack, mcp/_command.py) now passes TerminalDialogs(runners) where it passed runners. This is minimal on purpose: their menus are ported in the following PRs, and the terminal looks as before.
Tests.
- New
tests/clai2/dialog_script.py::ScriptedDialogs: a typedDialogsdriven by scripted answers (Pick,Type,Confirm,Finish,Back) that records each dialog asked (Asked). The plugin ports will use it. test_plugin_keys.py,test_sign_in.py,test_day_ai.py,test_slack.pyandtest_ui_telemetry.pyare updated, with termflow-level checks kept where they prove the terminal widgets.
Verification. Pyright clean on the plugins, builtin_plugins, mcp and the touched tests. 887 tests pass across every suite that touches keys, sign-in, dialogs, the affected plugins and the web UI. The new code has full branch coverage. A real terminal check in tmux, against an isolated config, opened a plugin's token row: the /keys picker, the masked input and Esc behave as before.
What changes for existing users. In the terminal, a plugin's /keys picker is now the shared choose list: the same names plus "Enter a different API key", searchable past 8 keys, with a short description beside it. Nothing else changes.
- No breaking changes in accordance with the version policy.
- Any permitted compatibility impact has a label, warning, migration, release note, and exact API-check waiver.
- PR title is fit for the release changelog.