Show the `grain` plugin settings menu in the `clai2` web UI
Merged
MP
2mo ago+214+214+012345678901234567890123456789-128-128-012345678901234567890123456789
Part 18 of the clai2 web UI stack (… → #10316 → this PR). Based on #10316. No linked issue: requested by the CLAI maintainer.
Why. One PR per plugin: grain now declares its settings menu (settings_menu(), #10312) instead of running termflow widgets in configure(). The same menu, sign-in and /keys steps included, opens in the terminal and in the web UI's plugins panel (#10315), where those steps show as dialogs.
What changes
- Token row → action. It asks through
Dialogs: "A /keys entry" (the sharedchoose_key, which now asks before replacing an existingGRAIN_ACCESS_TOKEN, where it used to overwrite it silently), or "No API key", which forgets the key choice and starts the browser sign-in (sign_in_now(SIGN_IN, dialogs)) unless one is stored. - First save of the defaults. It used to happen only when the terminal menu closed. Choosing a token now saves them in the web UI too. The terminal keeps the save on close through a thin
configureoverride. /grain keyruns the same action throughTerminalDialogs./grainstill opens the menu.- Removed: the
_PickTokenexception round trip, the prompt_toolkitPromptSessionprompt, and the module-levelconfigure/choose_key. - Its tests drive the actions with
ScriptedDialogs(#10316) and the terminal path throughplugin.configure()with scripted runners. Its PLUGINS.md section says the menu also opens in the web UI's plugins panel.
Verification.
- Ported in its own herdr worktree and stacked here.
- On the stacked branch (grain, linear, notion and pylon together): 308 tests pass across the four plugins' suites plus web, loader, keys, sign-in, reload and startup imports. Pyright is clean on the plugins and their tests.
- Headed Playwright against an isolated
clai2 --web -m testwith all four enabled: the rows render, each action's first dialog opens, Esc backs out with the plugin's "unchanged" message, and there are no page errors. Screenshots are in/tmp/clai-web-shots/port-grain-*.png.
What changes for existing users. The terminal menu keeps its rows, labels and messages. The /keys step uses the shared picker and confirmation from #10316. The menu now also works in the web UI.
- 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.