Add a plugins panel with settings forms to the `clai2` web UI, and `host.plugins`
Merged
MP
2mo ago+2201+2201+0123456789012345678901234567890123456789-179-179-012345678901234567890123456789
Part 14 of the clai2 web UI stack (… → #10286 → this PR). Based on #10286. No linked issue: requested by the CLAI maintainer.
Why. /plugins in the browser opened the terminal's menu. This brings the menu to the web UI: every plugin with an on/off switch, and a form for its settings. Each change is validated, saved and applied at once, as the terminal does.
New public surface (core)
host.plugins: aPluginCatalogprotocol, likehost.sessions. The shell'sPluginLoadersatisfies it, and hosts built outside the loader getNone.listing()returns onePluginInfoper/pluginsrow. While a plugin is on, the row includes its settings model and its saved settings.enable/disable/reloadare the loader's existing methods.save_settings(name, settings)takes an instance of the plugin's own model. It saves through the plugin's host, exactly as aconfigure()menu does withhost.save_settings, then loads the plugin again if anything changed, as/plugins configuredoes.
PluginEntry.origin/.status/.own_statusnow hold the labels the terminal menu computed privately, so the terminal and the browser share one definition.describe()takes(factory, path)instead of an entry, so the loader can call it without an import cycle.
Web plugin
GET /api/plugins,POST /api/plugins/{name}/{enable|disable|reload},POST /api/plugins/{name}/settings(changes,reset), andPOST /api/plugins/{name}/menu, which sends/plugins configure NAMEto the terminal.- Settings form: built from the settings model's JSON Schema. Values are merged with the saved settings and validated by the model. A rejected value answers 422 with one message per field, and nothing is saved.
- Live updates: every command end publishes a
pluginsmessage, so an open panel follows changes made in the terminal. - Self-protection: the panel refuses to disable, reload or reconfigure
webitself. That would restart the server with a new token and end the page. WebSettingsreads its attribute docstrings, so its form has descriptions.
UI. A modal panel, opened from the puzzle button in the sidebar's footer, ⌘/Ctrl+,, or /plugins typed in the composer.
- List: searchable, with status dots and switches.
- Detail: description, source, errors and notices, what the plugin provides, and its settings form.
- Controls by field type: switches for booleans, dropdowns for enums, constants and mixed literals, fields for text and numbers (an empty optional field means "not set"), one item per line for lists of strings, inline sub-fields for nested models (a
/keysKeyReferencereads as its name), and JSON for anything else. - Saving: each field saves on change, Enter or blur, with a per-field Saved / error state and a Reset to its default. Esc undoes an unsaved edit; the next Esc closes the panel.
- A plugin's own menu (sign-ins, keys) opens in the terminal from Open its menu. The page explains when there is no terminal (
clai2 --web).
Verification.
- Tests:
tests/clai2/test_web.py: the listing (origins, statuses, included, no settings, a model with no JSON Schema, a plugin that is off), per-field 422 errors, reset, the plugin left failed when it refuses new settings at load, enable/disable/reload, a plugin that fails to import, the self-protection, the terminal menu over the WebSocket, and a host withoutplugins.tests/clai2/test_plugin_loader.py: the catalog checks the model and requires a loaded plugin.
- Checks: pyright clean. The web plugin,
describeandplugin_menuhave 100% branch coverage, and the lines this PR adds toloader.pyandplugins/__init__.pyare all covered.tscandnpm run buildare clean. - Headed Playwright, against an isolated config (
XDG_*in/tmp):repo_context: toggledwalk_upand changednested_inject.compaction: savedthreshold=7, which showed "Input should be less than or equal to 1", then saved 0.6 and reset it to 0.85.github: turned on, then its form had a dropdown, a key name, a URL field, switches and a list.web: shown read-only.- Esc,
/pluginsand ⌘, all worked. - From
/webin an interactive CLAI, Open its menu opened Coder's settings menu in the terminal, and its result came back as a notice.
What changes for existing users. A new web UI panel and host.plugins. The terminal's /plugins menu looks and behaves as before.
- 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.